на PHP 5.2 работает а на PHP 5.4 нет

Статус
В этой теме нельзя размещать новые ответы.

vave

Полезный
Регистрация
22 Июн 2007
Сообщения
466
Реакции
16
Поправьте пожалуйста код!
На PHP 5.2 работает а на PHP 5.4 нет, просто белый экран...
Сойти на 5.2 не могу, так как тогда другие сайты перестанут работать.

PHP:
<?

  require 'cp-includes/inc-confdata.php';
  require 'cp-includes/inc-branding.php';


  require 'cp-includes/inc-resource.php';


  require 'cp-includes/inc-general.php';


  require 'cp-includes/inc-functions.php';


  require 'cp-includes/inc-secure.php';


  if ($demo)
  {
    $dis = 'disabled=\'disabled\'';
  }
  else
  {
    $dis = '';
  }

  $page_titl = 'Photo Manager';
  $page_desc = '';
  $page_keys = '';
  $page_this = 'l';
  $page_mode = 'lb';
  $page_subn = 'p';
  $path_root = '';
  $link = mysql_connect ($dbhost, $dbuser, $dbpass);
  mysql_select_db ($dbname, $link);
  $result = mysql_query ('SELECT * FROM ' . $dbconf, $link);
  $conf = mysql_fetch_array ($result);
  $conf = safe_data ($conf, 'display');
  $_GET = safe_data ($_GET, 'query');
  $result = mysql_query ('SELECT * FROM ' . $dblist . ' WHERE id=\'' . $_GET['id'] . '\' LIMIT 1', $link);
  $row = mysql_fetch_assoc ($result);
  if ($_SESSION[c2][user_type] == 1)
  {
    if ($_SESSION[c2][user_type] <= $row[user_type])
    {
      if ($row[userid] != $_SESSION[c2][userid])
      {
        if (!($conf[user_mod]))
        {
          header ('location:cp-list-index.php');
        }
      }
    }
  }
  else
  {
    if ($_SESSION[c2][user_type] == 2)
    {
      if ($_SESSION[c2][user_type] <= $row[user_type])
      {
        if ($row[userid] != $_SESSION[c2][userid])
        {
          if (!($conf[admin_mod]))
          {
            header ('location:cp-list-index.php');
          }
        }
      }
    }
  }

  if ($_POST[submit])
  {
    if (!($demo))
    {
      $_GET[id] = $_POST[id];
      $_POST = safe_data ($_POST, 'query');
      foreach ($_FILES as $line)
      {
        if (!(empty ($line[name])))
        {
          $info = getimagesize ($line[tmp_name]);
          if (!((!($info[2] == 2) AND !($info[2] == 3))))
          {
            $file = substr (time () . rand (10000, 99999), -15);
            if ($info[2] == 2)
            {
              $file .= '.jpg';
            }
            else
            {
              $file .= '.png';
            }

            copy ($line[tmp_name], '../temp/' . $file);
            $new = new_dim ($info[0], $info[1], $sizes[small][0], $sizes[small][1]);
            resize ('../temp/' . $file, 'cp-thumbs/' . $file, $info[0], $info[1], $new[x], $new[y], $info[2]);
            $new = new_dim ($info[0], $info[1], $sizes[thumb][0], $sizes[thumb][1]);
            resize ('../temp/' . $file, '../thumbs/' . $file, $info[0], $info[1], $new[x], $new[y], $info[2]);
            $new = new_dim ($info[0], $info[1], $sizes[large][0], $sizes[large][1]);
            resize ('../temp/' . $file, '../images/' . $file, $info[0], $info[1], $new[x], $new[y], $info[2]);
            $new = new_dim ($info[0], $info[1], $sizes[enlarge][0], $sizes[enlarge][1]);
            resize ('../temp/' . $file, '../enlarge/' . $file, $info[0], $info[1], $new[x], $new[y], $info[2]);
            unlink ('../temp/' . $file);
            mysql_query ('INSERT INTO ' . $dbimgs . ' VALUES(\'0\', \'' . $_POST['id'] . '\', \'' . $file . '\')', $link);
            mysql_query ('UPDATE ' . $dblist . ' SET images=images+1 WHERE id=\'' . $_POST['id'] . '\' LIMIT 1', $link);
            $upload = true;
            continue;
          }
          else
          {
            $error .= 'The photo (' . $line[name] . ') you attempted to upload is not a valid JPG or PNG file.<br/>';
            continue;
          }

          continue;
        }
      }
    }
  }

  if ($_GET[remove])
  {
    if (!($demo))
    {
      $_GET = safe_data ($_GET, 'query');
      unlink ('../images/' . $_GET['remove']);
      unlink ('../enlarge/' . $_GET['remove']);
      unlink ('../thumbs/' . $_GET['remove']);
      unlink ('cp-thumbs/' . $_GET['remove']);
      mysql_query ('DELETE FROM ' . $dbimgs . ' WHERE fname=\'' . $_GET['remove'] . '\' LIMIT 1', $link);
      mysql_query ('UPDATE ' . $dblist . ' SET images=images-1 WHERE id=\'' . $_GET['id'] . '\' LIMIT 1', $link);
    }
  }

  if ($_GET[crnt])
  {
    if ($_GET[trgt])
    {
      if (!($demo))
      {
        $_GET = safe_data ($_GET, 'query');
        $result = mysql_query ('SELECT * FROM ' . $dbimgs . ' WHERE id=\'' . $_GET['crnt'] . '\' LIMIT 1', $link);
        $current = mysql_fetch_array ($result);
        $result = mysql_query ('SELECT * FROM ' . $dbimgs . ' WHERE id=\'' . $_GET['trgt'] . '\' LIMIT 1', $link);
        $target = mysql_fetch_array ($result);
        mysql_query ('UPDATE ' . $dbimgs . ' SET
    listid=\'' . $current['listid'] . '\',
    fname=\'' . $current['fname'] . '\'
    WHERE id=\'' . $_GET['trgt'] . '\' LIMIT 1', $link);
        mysql_query ('UPDATE ' . $dbimgs . ' SET
    listid=\'' . $target['listid'] . '\',
    fname=\'' . $target['fname'] . '\'
    WHERE id=\'' . $_GET['crnt'] . '\' LIMIT 1', $link);
      }
    }
  }

  $_GET = safe_data ($_GET, 'query');
  $result = mysql_query ('SELECT * FROM ' . $dblist . ' WHERE id=\'' . $_GET['id'] . '\' LIMIT 1', $link);
  $_POST = mysql_fetch_array ($result);
  $_POST = safe_data ($_POST, 'display');
  require 'cp-includes/inc-header.php';
  require 'cp-includes/inc-navigation.php';
  echo '   
<div id=\'content\'>
   
    <h1>Photo Manager</h1>
   
    <p>You can use the form below to upload photos for this listing.  Your photos will automatically be resized to a
    maximum of 500x375.<br/> We recommend uploading photos no larger than 1024x768.</p>
   
    ';
  if ($error)
  {
    echo '<div id=\'msg-error\'>' . $error . '</div>';
  }

  echo '    ';
  if ($upload)
  {
    echo '<div id=\'msg-success\'>The photo(s) you uploaded have been resized and stored successfully.</div>';
  }

  echo '   
    <div class=\'form alt\'>
        ';
  $result = mysql_query ('SELECT id,fname FROM ' . $dbimgs . ' WHERE listid=\'' . $_GET['id'] . '\' ORDER BY id ASC', $link);
  if (mysql_num_rows ($result))
  {
    $files = array ();
    while ($row = mysql_fetch_array ($result))
    {
      array_push (&$files, $row);
    }

    echo '<table border=\'0\' cellpadding=\'0\' cellspacing=\'0\'><tr>';
    for ($n = 0; $n < count ($files); ++$n)
    {
      $file = $files[$n][1];
      echo '<td style=\'padding-bottom:10px;\' width=\'144\' align=\'center\' valign=\'bottom\'>';
      echo '<img style=\'margin-bottom:5px; width:100px;\' src=\'../thumbs/' . $file . '\'/><br/>';
      if (0 < $n)
      {
        if (1 < count ($files))
        {
          echo '<a href=\'' . $_SERVER['PHP_SELF'] . '?id=' . $_GET['id'] . '&amp;crnt=' . $files[$n][0] . '&amp;trgt=' . $files[$n - 1][0] . '\'><img class=\'none\' src=\'cp-interface/arrow-left.gif\' align=\'middle\'/></a> ';
        }
      }

      echo '<a href=\'' . $_SERVER['PHP_SELF'] . '?remove=' . $file . '&id=' . $_GET['id'] . '\'>Remove Photo</a>';
      if ($n < count ($files) - 1)
      {
        echo ' <a href=\'' . $_SERVER['PHP_SELF'] . '?id=' . $_GET['id'] . '&amp;crnt=' . $files[$n][0] . '&amp;trgt=' . $files[$n + 1][0] . '\'><img class=\'none\' src=\'cp-interface/arrow-right.gif\' align=\'middle\'/></a> ';
      }

      echo '</td>';
      if (!(($n + 1) % 5))
      {
        if ($n < count ($files))
        {
          echo '</tr><tr>';
          continue;
        }

        continue;
      }
    }

    echo '</tr></table>';
  }
  else
  {
    echo '<div align=\'center\'>There are no photos to display for this listing.</div>';
  }

  echo '    </div>
   
    <form action=\'';
  echo $_SERVER[PHP_SELF];
  echo '\' method=\'post\' enctype=\'multipart/form-data\'>
    <div class=\'form\'>
        <table width=\'100%\' border=\'0\' cellpadding=\'0\' cellspacing=\'0\'>
           
            <tr>
                <td class=\'label\'><label for=\'photo1\'>Photo Upload 1:</label></td>
                <td><input type=\'file\' id=\'photo1\' name=\'photo1\'/></td>
            </tr>
            <tr>
                <td><label for=\'photo2\'>Photo Upload 2:</label></td>
                <td><input type=\'file\' id=\'photo2\' name=\'photo2\'/></td>
            </tr>
            <tr>
                <td><label for=\'photo3\'>Photo Upload 3:</label></td>
                <td><input type=\'file\' id=\'photo3\' name=\'photo3\'/></td>
            </tr>
            <tr>
                <td><label for=\'photo4\'>Photo Upload 4:</label></td>
                <td><input type=\'file\' id=\'photo4\' name=\'photo4\'/></td>
            </tr>
            <tr>
                <td><label for=\'photo5\'>Photo Upload 5:</label></td>
                <td><input type=\'file\' id=\'photo5\' name=\'photo5\'/></td>
            </tr>
            <tr>
                <td><label for=\'photo6\'>Photo Upload 6:</label></td>
                <td><input type=\'file\' id=\'photo6\' name=\'photo6\'/></td>
            </tr>
           
        </table>
    </div>
   
    <div class=\'form alt\'>
        <table width=\'100%\' border=\'0\' cellpadding=\'0\' cellspacing=\'0\'>
           
            <tr>
                <td align=\'center\'><input type=\'submit\' name=\'submit\' value=\'Upload Photos\' ';
  echo $dis;
  echo '/></td>
            </tr>
           
        </table>
    </div>
    <input type=\'hidden\' name=\'id\' value=\'';
  echo $_POST[id];
  echo '\'/>
    </form>
       
</div>
   
';
  require 'cp-includes/inc-footer.php';
?>
 
Замени
Код:
array_push (&$files, $row);
на
Код:
array_push ($files, $row);
 
  • Нравится
Реакции: vave
Всё заработало!
 
Статус
В этой теме нельзя размещать новые ответы.
Назад
Сверху