include код

mizarck

Registered
Здравейте,
след като инклудня следният код в индекса
код-а губи деиствието си и нищо неправи
Код:
<?php
$template = "";
# Desired width of thumbnails (or 0 for auto)
$thumbw = 0;
# Desired height of thumbnails (or 0 for auto)
$thumbh = 100;
# $perrow = number of thumbnails to display in each row
$perrow = 4;
# really should be some multiple of $perrow
$perpage = 8;
# Size of the border for the table, in pixels
$tableborder = 0;
# Width of the table
$tablewidth = "100%";
# Cell spacing for the table, in pixels
$cellspacing = 3;
# Color of the table
$bgcolor = "#f0f0f0";
# Font to use for displaying the table
$fontface = "Verdana, Arial";
# Font size
$fontsize = 2;
# Display file name
$showname = 0;
# Display image coordinates
$showcoords = 1;
# Display file size in KB
$showsize = 0;
$header = '';
$footer = '';
$linkurl = "%picname%";
set_time_limit(0);

if(!$template){
  $template .= <<<EOT
</center><p align="center"><font face="$fontface" size="$fontsize">%output%</font></p>
EOT;
}
else{
  $template = implode("", file($template));
}

$jpegs = array();
$directory = opendir(getcwd());
while($filename = readdir($directory)){

  if((strlen($filename) > 2) && (strcasecmp(substr($filename, 0, 5), 'thumb') != 0)){
    $localext = substr($filename, -3);
    if(strcasecmp($localext, 'jpg') != 0)
      continue;
    else{
      array_push($jpegs, $filename);
    }
  }
}

sort($jpegs);
reset($jpegs);


foreach($jpegs as $var){
  if(!file_exists("thumb$var")){
    if(!isset($pleasehold)){
      $pleasehold = 1;
      echo "<font face='$fontface' size='$fontsize'><b>One moment please...</b><br><br>New images were found in this gallery, and thumbnails must be made for them.<br><br>Processing images: ";
      flush();
    }
    echo "<font face='$fontface' size='$fontsize'>$var... </font>";
    flush();
    makejpegthumb("$var", $thumbw, $thumbh, "thumb$var", 100);
  }
}
if($pleasehold){
  echo "<font face='$fontface' size='$fontsize'><br><br><b>Thumbnails created!</b></font><br>";
}


$nav = "<center><font face='$fontface' size='$fontsize'>";

$numlinks = (int)ceil(count($jpegs)/$perpage);
$linkstart = 1;
for($i=1; $i<=$numlinks; $i++){
  $nav .= "<a href='$_SERVER[PHP_SELF]?start=$linkstart' title='Go to page $i'>Page $i</a> ";
  $linkstart += $perpage;
}
$nav .= '</font></center><br>';

$output = "$nav\n";


$picnum = (isset($_GET[start])) ? (($_GET[start] == 0) ? 0 : $_GET[start] - 1) : 0;
$output .= <<<EOT

EOT;
for($i=0; $i<(int)($perpage/$perrow); $i++){
  $output .= '<tr>';
  for($j=0; $j<$perrow; $j++){
    $output .= "<td align='center' valign='middle'>";
    if(file_exists($jpegs[$picnum])){
      $target = str_replace('%picname%', $jpegs[$picnum], $linkurl);
      $output .= "<a href='$target' target='_blank'><img src='thumb$jpegs[$picnum]' border='0' alt='Click to view $jpegs[$picnum]'></a>";
      if($showname == 1){
        $output .= "<br><font face='$fontface' size='$fontsize'>$jpegs[$picnum]</font>";
      }
      if($showcoords == 1){
        $coords = getimagesize($jpegs[$picnum]);
        $output .= "<br><font face='$fontface' size='$fontsize'>$coords[0] x $coords[1]</font>";
      }
      if($showsize == 1){
        $output .= "<br><font face='$fontface' size='$fontsize'>" . sprintf("%.02f", (float)(filesize($jpegs[$picnum]) / 1024)) . 'KB</font>';
      }
      $output .= "\n";
    }
    $picnum++;
  }
  $output .= '</tr>';
}
$output .= "</table><br>$nav\n\n";

$template = str_replace('%output%', $output, $template);
if($header){
  include($header);
}
echo $template;
if($footer){
  include($footer);
}

function makejpegthumb($infile, $outxcoord, $outycoord, $outfile, $quality){
  $insize = getimagesize("$infile");

  $inxcoord = $insize[0];
  $inycoord = $insize[1];
  $inresource = imageCreateFromJPEG("$infile");

  if($outxcoord == 0){
    $ratio = (float)($outycoord / $inycoord);
    $outxcoord = $inxcoord * $ratio;
  }
  else if($outycoord == 0){
    $ratio = (float)($outxcoord / $inxcoord);
    $outycoord = $inycoord * $ratio;
  }

  $outresource = imagecreatetruecolor($outxcoord, $outycoord);

  $target_pic = imagecopyresampled($outresource, $inresource, 0, 0, 0, 0, $outxcoord, $outycoord, $inxcoord, $inycoord);
  imagejpeg($outresource, "$outfile", $quality);
}

?>
как да го оправя това нещо

Блаодаря предварително
 
А този код къде е бил преди това?

Някъде другаде ли се include?

include кода е просто час от друг много голям код.

Ако имаш някакъв файл който да е със следния код:

<?
include ('header.php');
include ('login.php');
include ('post.php');

?>

Не значи, че може да вземеш да include файла post.php някъде другаде.

Той работи само тук ако примерно в предишните файлове някой е дефинирал променливи свързани с него.

post.php е код който обикновено сам по себе си не може да прави нищо.

Не винаги но в повечето случай е така.
 
Кодът не е бил никаде другаде преди
това е код който създава малки копия на оригиналните пикове и създава галерия с тях
код-ът си работи до като не го инклудна в самият сайт
ето как го инклудвам
Код:
<?php
$id = $_GET['index'];
switch ($index)
{
case "imageupload":
include('image_upload.php');
break;
case "gallery":
include('gallery/index.php');
break;
}
?>
кодът който съм дал в първият си пост е gallery/index.php
това е целият код няма други файлове
 
еми как ще стане..
<?php
$id = $_GET['index'];
switch ($id)
{
case "imageupload":
include('image_upload.php');
break;
case "gallery":
include('gallery/index.php');
break;
}
?>
..
 
bafitu каза:
еми как ще стане..
<?php
$id = $_GET['index'];
switch ($id)
{
case "imageupload":
include('image_upload.php');
break;
case "gallery":
include('gallery/index.php');
break;
}
?>
..
да много странен проблем
но в интерес на истината image_upload.php ми го отваря по този начинкакто е макар че променливата съм я сгрешил
 
Оправих променливата но пак нестава ето резултата (плс не опсъждайте URL адреса)
http://worldbg.org/sopol/?index=gallery
а ето и че друг доста по сложен код работи
http://worldbg.org/sopol/?index=imageupload
и нз какво му е на този
а ето ако файлат е отворен без инклуд
http://worldbg.org/sopol/gallery/
както виждате кода си работи а аз само го инклудвам
 
на скрипта за оразмеряването на този ред
$directory = opendir(getcwd());
го промени на :
$directory = opendir('gallery'); примерно.
getcwd(); връща текущата директория т.е. главната в случая след инклудето.T.e. ако имаше картинки в главната директория където е интекса щеше да се усетиш :)
П.С.
сега като го направиш така
http://worldbg.org/sopol/gallery/index.php
най-вероятно няма да работи , но при http://worldbg.org/sopol/?index=gallery ще работи :?:
 
Невади нищо а в индекса ми създаде 162 тъмба (празни)

пп ако имате подобен скрипт дайте го (не е задължително да оразмерява)
 

Back
Горе