ANTICHAT

ANTICHAT (https://forum.antichat.io/index.php)
-   PHP (https://forum.antichat.io/forumdisplay.php?f=37)
-   -   Ошибка в коде? (https://forum.antichat.io/showthread.php?t=148241)

cren 14.10.2009 15:51

Ошибка в коде?
 
PHP код:

<?php

  
class image_controller 
  
{                                                                                             // Пишет что тут ошибка
    
var $img;
    var 
$source = '';
    var 
$allow_watermark = true;
    var 
$images = array ();
    var 
$thumbs = array ();
    var 
$prefix = '';
    var 
$upload_images = array ();
    function 
get_images ($content)
    {
      
preg_match_all ('#\\[img\\](.+?)\\[/img\\]#ie', $content, $preg_array);
      if (
count ($preg_array[1]) != 0)
      {
        foreach (
$preg_array[1] as $item)
        {
          if (!(
in_array ($item, $this->images)))
          {
            
$this->images[] = $item;
            continue;
          }
        }
      }
    }

    function 
download ($image_url)
    {
       global 
$db, $parse, $config;
      
$image_name = basename ($image_url);
      
$image_arr = explode ('/', $image_name);
      if (
count ($image_arr) != 0)
      {
        
$image_name = end ($image_arr);
      }
if (!
is_dir(ROOT_DIR."/uploads/posts/".FOLDER_PREFIX)) {

@
mkdir(ROOT_DIR."/uploads/posts/".FOLDER_PREFIX, 0777);
@
chmod(ROOT_DIR."/uploads/posts/".FOLDER_PREFIX, 0777);
@
mkdir(ROOT_DIR."/uploads/posts/".FOLDER_PREFIX."/thumbs", 0777);
@
chmod(ROOT_DIR."/uploads/posts/".FOLDER_PREFIX."/thumbs", 0777);
}
$config_path_image_upload = 'uploads/posts/'.FOLDER_PREFIX.'/';

$image_name = $this->prefix . '_' . $image_name;
@
copy ($image_url, UPLOAD_PATH . $image_name);

$news_id = 0 ;
$added_time = $this->prefix;
$author = $this->author;
                       
$row = $db->super_query("SELECT COUNT(*) as count FROM " . PREFIX . "_images where date = '$added_time' AND news_id = '$news_id'");
                          if(!
$row['count']) {
                             
                             
$inserts = FOLDER_PREFIX."/".$image_name;
                             
$db->query("INSERT INTO " . PREFIX . "_images (images, author, news_id, date) values ('$inserts', '$author', '$news_id', '$added_time')");
                          } else {
                             
$row = $db->super_query("SELECT images  FROM " . PREFIX . "_images where date = '$added_time' AND news_id = '$news_id'");
                             if (
$row['images'] == "") $listimages = array(); 
                             else 
$listimages = explode("|||", $row['images']);
                             foreach (
$listimages as $dataimages) {
                                if (
$dataimages == FOLDER_PREFIX."/".$image_name) $error_image = "stop";
                             }
                             if (
$error_image != "stop") {
                                
$listimages[] = FOLDER_PREFIX."/".$image_name;
                                
$row['images'] = implode("|||", $listimages);
                                
$db->query("UPDATE " . PREFIX . "_images set images='{$row['images']}' where date = '$added_time' AND news_id = '$news_id'");
                             }
                          }

$this->state = true;
$this->img['format']=ereg_replace(".*\.(.*)$","\\1",UPLOAD_PATH . $image_name);
        
$this->img['format']=strtoupper($this->img['format']);
        if (
$this->img['format']=="JPG" || $this->img['format']=="JPEG") {
            
$this->img['format']="JPEG";
            
$this->img['src'] = @imagecreatefromjpeg (UPLOAD_PATH . $image_name);
        } elseif (
$this->img['format']=="PNG") {
            
$this->img['format']="PNG";
            
$this->img['src'] = @imagecreatefrompng (UPLOAD_PATH . $image_name);
        } elseif (
$this->img['format']=="GIF") {
            
$this->img['format']="GIF";
            
$this->img['src'] = @imagecreatefromgif (UPLOAD_PATH . $image_name);
        } else {
$this->state = false;
        }
        
if (
$this->state and $this->img['src'] != "") {
      if (
$this->allow_watermark) {
        
$thumb = new thumbnail (UPLOAD_PATH . $image_name);
        
$thumb->jpeg_quality ($config['jpeg_quality']);
        
$thumb->insert_watermark ($config['max_watermark']);
        
$thumb->save (UPLOAD_PATH . $image_name);
        unset (
$thumb);
        }

          
$thumb = new thumbnail (UPLOAD_PATH . $image_name);
          if (
$thumb->size_auto($config['max_image']))
        {
          
$thumb->jpeg_quality ($config['jpeg_quality']);
          
$thumb->save (THUMB_PATH . $image_name);
          unset (
$thumb);
        }
      }else{
            @
unlink(UPLOAD_PATH . $image_name);
            return 
false;
        }
if (@
file_exists(THUMB_PATH . $image_name)){
        
$serv_image_url ="[thumb]".$config['http_home_url'] . $config_path_image_upload . $image_name."[/thumb]";
        
$thumb_url= "[img]".$image_url."[/img]";
        
$this->source = str_replace ($thumb_url, $serv_image_url, $this->source);
      }else{
      
$serv_image_url = $config['http_home_url'] . $config_path_image_upload . $image_name;
      
$this->source = str_replace ($image_url, $serv_image_url, $this->source);
            }
}

    function 
process ()
    {
      
$this->prefix = time()+ ($config['date_adjust']*60);
      if (
trim ($this->source) != '')
      {
        
$this->get_images ($this->source);
      }

      foreach (
$this->images as $image_url)
      {
        
$this->download ($image_url);
      }
    }
  }





  if (!(
defined ('DATALIFEENGINE')))
  {
    exit (
'Hacking attempt!');
  }

  
define('FOLDER_PREFIX', date("Y-m"));
  
define ('UPLOAD_PATH', ROOT_DIR."/uploads/posts/".FOLDER_PREFIX."/");
  
define ('THUMB_PATH', UPLOAD_PATH . "thumbs/");

?>


Пишет что ошибка на строке с коментарием, помогите исправить =))

Fepsis 14.10.2009 16:07

У меня на денвере выдал "Hacking attempt"

Gray_Wolf 14.10.2009 16:09

А где фаил в котором вы используете этот класс?

cren 14.10.2009 16:16

http://vkovtakti.ru/grab.rar - это рсс граббер

wildshaman 14.10.2009 16:25

Естественно хакинг аттемп - от Дле куско, там првоерка на их переменную.
Покажи, откуда инклудится, возможно переобъявление класса или хз что.

cren 14.10.2009 16:41

Fatal error: Cannot redeclare class image_controller in S:\home\localhost\www\dle\engine\inc\image_functio n.php on line 15


выдаёт такую ошыбку

[dword] 14.10.2009 16:45

Цитата:

Сообщение от cren
Fatal error: Cannot redeclare class image_controller in S:\home\localhost\www\dle\engine\inc\image_functio n.php on line 15


выдаёт такую ошыбку

два раза объявляется один и тот же класс.. скорее всего где-то два раза подключается этот файл.

Gray_Wolf 14.10.2009 16:46

Ну дак написано же что класс с таким именем уже обьявлен.
ищи где ещё ты подключаеш image_function.php

cren 14.10.2009 16:50

спасибо всем..я нашёл ошибку....

wildshaman 14.10.2009 17:00

Ну как я и говорил - переобъявление класса)


Время: 22:37