开发者

How to define index on galleryfile

can anyone tell me how to define index for the following code:

<?php

///////////////////////////////////////////////////////////////////////////////
// GENERAL SETTINGS
///////////////////////////////////////////////////////////////////////////////
$folder_sort_order = "asc"; //asc or desc
$image_sort_order = "asc"; //asc or desc
$mainfolder = "autogallery"; //only change this if you rename the folder

# path to the script, shouldnt need to change it unless you change the path
# for example $path_to_script = "/path/to/my/script/autogallery/" . $mainfolder; 
$path_to_script = "/autogallery/" . $mainfolder; 

///////////////////////////////////////////////////////////////////////////////
// CODE STARTS HERE, YOU SHOULD NOT HAVE TO EDIT BELOW THIS LINE
///////////////////////////////////////////////////////////////////////////////
$basepath = $_SERVER["DOCUMENT_ROOT"] . $path_to_script;
$gallerypath = $basepath . "/galleries/";
$galleryid = $_REQUEST['directory']; //get gallery id from ajax request

//instantiate the autoGallery class
require 'autoGallery.php'; 
$autogallery 开发者_开发知识库= new autoGallery();

//if ajax is disabled, degrade
if(empty($galleryid)) {
    $galleryid = $_GET['gid'];
}

//get all photos from selected gallery or from latest gallery
if(isset($galleryid)){
    $galleryname = $autogallery->getGalleryNameByID($gallerypath, $galleryid);
} else {
    $galleryname = $autogallery->latestGallery($gallerypath, $folder_sort_order);
}

$imagepath = $gallerypath . $galleryname . "/";
$imagefiles = $autogallery->getPhotos($imagepath, $image_sort_order);

//remove id from gallery name for viewing purposes
$galleryname = substr($galleryname, 4);

//get gallery list to build nav
$gallerylist = $autogallery->getGalleries($gallerypath, $folder_sort_order);

//remove base path from image path
$imagepath = str_replace($basepath . "/", "", $imagepath);

//path for ajax request
$datapath = str_replace($basepath . "/", "", $path_to_script);

I keep getting the following error messages: Notice: Undefined index: directory in C:wampwwwautogalleryautogallerysettings.php on line 19 Notice: Undefined index: gid in C:wampwwwautogalleryautogallerysettings.php on line 27 The code for line 19 is:

$galleryid = $_REQUEST['directory']; //get gallery id from ajax request

The code for line 27 is:

$galleryid = $_GET['gid'];

full code for line 26-28:

if(empty($galleryid)) {
    $galleryid = $_GET['gid'];
}


Check variable existence before using them with

isset()

function

if(empty($galleryid)) {

  if (isset($_GET['gid'])) {
     $galleryid = $_GET['gid'];
  }

}

$_GET['gid'] and $_REQUEST['directory'] both are not set

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜