2015-06-20 62 views
0

以下php腳本創建一個拇指,並且是圖像庫包的一部分。雖然從版本5.6的PHP更新,但代碼不再工作,因爲在依賴文件中出現'eregi'。PHP代碼來創建更新後不工作的拇指

有沒有人知道'eregi'的替代功能?

<?php 
    include('config.inc.php'); 
    $C_JGALL['extentions'] = "jpg|jpeg|gif|png"; 

    if(is_dir('themes/' . $C_JGALL['gall_theme']) && file_exists('themes/' .$C_JGALL['gall_theme'] . '/' . $C_JGALL['gall_theme'] . '.css') && file_exists('themes/' . $C_JGALL['gall_theme'] . '/' . $C_JGALL['gall_theme'] . '.conf.php')) 
    { 
     include('themes/' . $C_JGALL['gall_theme'] . '/' . $C_JGALL['gall_theme'] . '.conf.php'); 
    } 
    else 
    { 
     die('corrupt theme'); 
    } 


    $MaxSize = $_GET['MaxSize']; 

    switch ($_GET['src']) { 
     case 'folder': 
      $src = $G_JGALL['inc_path'] . 'themes/' . $C_JGALL['gall_theme'] . '/images/folder.jpg'; 
      break; 
     case 'question': 
      $src = $G_JGALL['inc_path'] . 'themes/' . $C_JGALL['gall_theme'] . '/images/no_image.jpg'; 
      break; 
     default: 
      $src= $_GET['src']; 
      break; 
    } 

    function GetExtention($filename) { 
     $FileNameArray = explode('.',$filename); 
     return($FileNameArray[count($FileNameArray)-1]); 
    } 
    $ext = GetExtention($src); 

    $srcSize = getImageSize($src); 

    $srcRatio = $srcSize[0]/$srcSize[1]; 
    $destRatio = $MaxSize/$MaxSize; 

    if ($destRatio > $srcRatio) { 
     $MaxSize = (($C_JGALL['gall_show_filenames'] != 'y') OR isset($_GET['view'])) ? $MaxSize : $MaxSize/100 * 80; 
     $destSize[1] = $MaxSize; 
     $destSize[0] = $MaxSize*$srcRatio; 
    } 
    else { 
     $destSize[0] = $MaxSize; 
     $destSize[1] = $MaxSize/$srcRatio; 
    } 

    if(eregi($C_JGALL['extentions'],$ext) AND (substr($srcSize['mime'],0,5) == 'image')) 
     if(eregi("jpg|jpeg",$ext)) { 
      $destImage = imagecreatetruecolor($destSize[0],$destSize[1]); 
      $srcImage = imagecreatefromjpeg($src); 
      imagecopyresampled($destImage, $srcImage, 0, 0, 0, 0,$destSize[0],$destSize[1],$srcSize[0],$srcSize[1]); 
      imagejpeg($destImage,'',80); 
     } 
     elseif(eregi("gif",$ext)) { 
      $destImage = imageCreateTrueColor($destSize[0],$destSize[1]); 
      $srcImage = imageCreateFromGIF($src); 
      imageCopyResampled($destImage, $srcImage, 0, 0, 0, 0,$destSize[0],$destSize[1],$srcSize[0],$srcSize[1]); 
      imageGIF($destImage,'',80); 
     } 
     elseif(eregi("png",$ext)) { 
      $destImage = imageCreateTrueColor($destSize[0],$destSize[1]); 
      $srcImage = imageCreateFromPNG($src); 
      imageCopyResampled($destImage, $srcImage, 0, 0, 0, 0,$destSize[0],$destSize[1],$srcSize[0],$srcSize[1]); 
      imagePNG($destImage,'',80); 
     } 
    else { 
     die('ongeldige extentie of mime-type.'); 
    } 

    // --> End 
    ?> 
+0

你可以發佈(在你的原始問題中通過編輯)你看到的錯誤?檢查目錄以查看是否有error_log文件並從那裏獲取最新(相關)日誌。 – Tarquin

+0

這是由於使用'eregi'函數引起的。我改變了我的問題。 – ABC

回答