Autor Zpráva
tre-SKA
Profil *
cafko

toto mi pise na stranke, nevite nekdo co s tim ??


Notice: Undefined variable: imglist in /var/www/treska.eu/_sub/ycb/htdocs/gallery/common.php on line 23

Warning: implode() [function.implode]: Invalid arguments passed in /var/www/treska.eu/_sub/ycb/htdocs/gallery/common.php on line 45



   1.
      <?php
   2.
       
   3.
      //*********************************************************************
   4.
      // gets image list from http post var if they exist,
   5.
      // otherwise gets list from thumb dir
   6.
       
   7.
      function getImageList($gallerydir) {
   8.
              if (isset($_POST['imglist'])) {
   9.
                      $imglist = $_POST['imglist'];
  10.
              } else {
  11.
                      $fh = opendir("$gallerydir/thumbs");
  12.
       
  13.
                      // read directory, and loop through retreived filenames
  14.
                      while ($file = readdir($fh)) {
  15.
                              // if image, add filename to image list
  16.
                              if (eregi("\.(jpg|gif|png|jpeg|jpe)$", $file)) {
  17.
                                      $imglist[] = $file;
  18.
                              }
  19.
                      }
  20.
                      closedir($fh);
  21.
              }
  22.
       
  23.
              if (is_array($imglist)) {
  24.
                      ksort($imglist);
  25.
              } else {
  26.
                      $imglist = false;
  27.
              }
  28.
              return $imglist;
  29.
      }
  30.
       
  31.
      //*********************************************************************
  32.
      // Javascript writes image list as http posted array
  33.
       
  34.
      function getJavaScript($imglist) {
  35.
              $str = '
  36.
              <script language="JavaScript">
  37.
              function imgSubmit(s) {
  38.
                      document.img.method = "post";
  39.
                      document.img.action = s;
  40.
                      document.img.submit();
  41.
              }
  42.
       
  43.
              function imgList() {
  44.
              ';
  45.
              $str .= "\tvar imglist = new Array('" . implode("', '", $imglist) . "');\n";
  46.
              $str .= '
  47.
                      for (var i=0; i < imglist.length; i++) {
  48.
                              document.write ("<input type=\"hidden\" name=\"imglist[]\" ");
  49.
                              document.write ("value=\"" + imglist[i] + "\" />");     
  50.
                      }
  51.
              }
  52.
              </script>
  53.
              ';
  54.
              return $str;
  55.
      }
  56.
       
  57.
      //*********************************************************************
  58.
       
  59.
       
  60.
       
  61.
      ?>
AM_
Profil
hnedka za první else ve funkci getImageList musíš dát
$imglist = array();
abys zinicializoval tu proměnnou na prázdné pole.
tre-SKA
Profil *
chyba odstranena ale galeria aj tak negeneruje nahlady
<?php
error_reporting(E_ALL);

require("config.php");
require("common.php");

$gallery    = $_GET['gallery'];
$gallerydir = DOC_ROOT . GALLERY_ROOT . '/' . $gallery;
$imglist    = getImageList($gallerydir);
$imgcnt     = count($imglist);
$currpage   = (isset($_GET['currpage'])) 
	? (int) $_GET['currpage'] 
	: 1;

// get page elements 
$js 		 = getJavaScript($imglist);
$thumb_table = getThumbTableHTML($gallery, $imglist, $imgcnt, $currpage);
$image_cnt   = getImageRangeHTML($imgcnt, $currpage);
$page_nav    = getPageNavHTML($imgcnt, $currpage, $gallery);

// load template header and body 
$head = file_get_contents("./template/header.html");
$body = file_get_contents("./template/thumb_page.html");

// insert page elements 
$head = str_replace('<-- JAVASCRIPT -->', $js, $head);
$body = str_replace('<-- THUMBNAIL_TABLE -->', $thumb_table, $body);
$body = str_replace('<-- IMAGE_COUNT -->', $image_cnt, $body);
$body = str_replace('<-- PAGE_NAVIGATION -->', $page_nav, $body);

// output
echo $head;
echo $body;

//********************************************************************* 
// Begin thumbnail page related functions 
//*********************************************************************

function getImageRangeHTML($imgcnt, $currpage) {
	$max_per_page = TABLE_COLS * TABLE_ROWS;
	$pagecnt      = getThumbPageCount($imgcnt); 
	$first_image  = ($currpage - 1) * $max_per_page + 1;
	$last_image   = ($currpage == $pagecnt) 
		? $imgcnt 
		: $currpage * $max_per_page;

	$str = "
		<span id=\"image_range\">
		$first_image-$last_image of $imgcnt images
		</span>
	";
	return $str;
}

//********************************************************************* 

function getPageNavHTML($imgcnt, $currpage, $gallery) {
	$pagecnt  = getThumbPageCount($imgcnt); 
	$self     = $_SERVER['PHP_SELF'];

	// only proceed if there is more than 1 page of thumbs
	if ($pagecnt == 1) { return; }

	$str = "<ul>\n";

	for ($i = 1; $i <= $pagecnt; $i++) {
		if ($i == $currpage) {
			$str .= "<li class=\"active\">$i</li>";
		} else {
			$str .= "<li><a href=\"javascript:imgSubmit('$self?";
			$str .= "gallery=$gallery&currpage=$i');\">$i</a></li>";
		}
	}
	
	$str .= "</ul>\n";

	return $str;
}

//******************************************************************** 

function getThumbTableHTML($gallery, $imglist, $imgcnt, $currpage) {
	$max_per_page = TABLE_COLS * TABLE_ROWS;

	// set index of page's first image in image list array
	$first_image_index = ($currpage - 1) * $max_per_page;

	// set index of page's last image in image list array 
	$last_image_index = ($imgcnt < $currpage * $max_per_page)
		? $last_image_index = $imgcnt
		: $currpage * $max_per_page;
	
	$str = '<table border="0" id="thumb_table">' . "\n";

	// loop control var
	$column_cnt  = 1;
	
	// loop through current page images
	for ($i = $first_image_index; $i < $last_image_index; $i++) {
		# build path to thumb
		$thumburl  = GALLERY_ROOT . "/$gallery/thumbs/" . $imglist[$i];

		// insert row tag if this is the first column
		if ($column_cnt == 1) { $str .= "<tr>\n"; }
		
		// insert thumbnail, and surrounding html
		$str .= "<td>";
		$str .= "<a href=\"javascript:imgSubmit('image.php?gallery=$gallery";
		$str .= "&imgnum=" . ($i + 1) . "');\">";
		$str .= "<img src=\"$thumburl\" class=\"thumb_img\" ";
		$str .= "border=\"0\" /></a>";
		$str .= "</td>\n";
		
		if ($column_cnt == TABLE_COLS) {
			$str .= "</tr>\n\n";
			$column_cnt = 1;
		} else {
			$column_cnt++;
		}
	}
	$str .= "</table>\n";
	return $str;
}

// ********************************************************************* 

function getThumbPageCount($imgcnt) {
	$page_cnt = (int) (($imgcnt - 1) / (TABLE_COLS * TABLE_ROWS)) + 1;
	return $page_cnt;
}

// ********************************************************************* 
?>
AM_
Profil
chyba odstranena ale galeria aj tak negeneruje nahlady
asi je rozbitá
tre-SKA
Profil *
no galeria je umiestnena tu http://ycb.treska.eu/gallery/index.php?gallery=hody

ked si dam vypisat premenu
$gallerydir
tak cesta k suboru sedi... prava adresara "thumbs" su 777... tak ja uz neviem cim to moze byt... ale zaujimave ze ta galeria isla... :( dokonca ani neviem ktora cast kodu generuje nahlady...
AM_
Profil
"no such file or directory" mluvi za vse, ta slozka tam proste neni :) mozna mas nekde preklep, mozna velka/mala pismena...
tre-SKA
Profil *
pozri na ten odkaz este raz... ciadnu chybu nehlasi...
AM_
Profil
http://ycb.treska.eu/gallery/index.php?gallery=aaa tady už jo...
jinak těžko říct kde je problém pokud to není tvůj kód, zkus podporu přímo té galerie

Vaše odpověď

Mohlo by se hodit


Prosím používejte diakritiku a interpunkci.

Ochrana proti spamu. Napište prosím číslo dvě-sta čtyřicet-sedm: