コード例 #1
0
ファイル: news.php プロジェクト: romlg/blank-xpage
 function ocd_update()
 {
     $this->pageTitle = "Новости : режим редактирования";
     $this->pageHeader = "Новости : режим редактирования";
     $id = $this->GetGP("id");
     $article = $this->enc($this->GetValidGP("article", "Краткое описание", VALIDATE_NOT_EMPTY));
     $title = $this->enc($this->GetValidGP("title", "Заголовок", VALIDATE_NOT_EMPTY));
     if ($this->errors['err_count'] > 0) {
         $this->fill_form("update", FORM_FROM_GP);
     } else {
         $date = mktime(0, 0, 0, $this->GetGP("dateMonth"), $this->GetGP("dateDay"), $this->GetGP("dateYear"));
         $description = $this->enc($this->GetGP("progress"));
         $this->db->ExecuteSql("Update {$this->object} Set z_date='{$date}', article='{$article}', title='{$title}', description='{$description}' Where item_id='{$id}'");
         $physical_path = $this->sitePath;
         if (array_key_exists("photo", $_FILES) and $_FILES['photo']['error'] < 3) {
             $symbs = getUnID(5);
             $oldname = $_FILES['photo']['name'];
             $tmp_name = $_FILES['photo']['tmp_name'];
             $short_name = $id . "_" . $symbs;
             $new_name = $short_name . ".jpg";
             $thumb_name = "small_" . $new_name;
             if (is_uploaded_file($tmp_name)) {
                 move_uploaded_file($tmp_name, $physical_path . "data/news/" . $new_name);
                 $cmd = "chmod 666 " . $physical_path . "data/news/" . $new_name;
                 @exec($cmd, $output, $retval);
                 @chmod($physical_path . "data/news/" . $new_name, 0777);
                 copy($physical_path . "data/news/" . $new_name, $physical_path . "data/news/" . $thumb_name);
                 $cmd = "chmod 666 " . $physical_path . "data/news/" . $thumb_name;
                 @exec($cmd, $output, $retval);
                 @chmod($physical_path . "data/news/" . $thumb_name, 0777);
                 makeThumbnail($physical_path . "data/news/" . $thumb_name, 0);
                 makeThumbnail($physical_path . "data/news/" . $new_name, 1);
                 $this->db->ExecuteSql("Update {$this->object} Set photo='{$short_name}' Where item_id='{$id}'");
             }
         }
         if (array_key_exists("photo2", $_FILES) and $_FILES['photo2']['error'] < 3) {
             $symbs = getUnID(5);
             $oldname = $_FILES['photo2']['name'];
             $tmp_name = $_FILES['photo2']['tmp_name'];
             $short_name = $id . "_" . $symbs;
             $new_name = $short_name . ".jpg";
             $thumb_name = "small_" . $new_name;
             if (is_uploaded_file($tmp_name)) {
                 move_uploaded_file($tmp_name, $physical_path . "data/news/" . $new_name);
                 $cmd = "chmod 666 " . $physical_path . "data/news/" . $new_name;
                 @exec($cmd, $output, $retval);
                 @chmod($physical_path . "data/news/" . $new_name, 0777);
                 copy($physical_path . "data/news/" . $new_name, $physical_path . "data/news/" . $thumb_name);
                 $cmd = "chmod 666 " . $physical_path . "data/news/" . $thumb_name;
                 @exec($cmd, $output, $retval);
                 @chmod($physical_path . "data/news/" . $thumb_name, 0777);
                 makeThumbnail($physical_path . "data/news/" . $thumb_name, 0);
                 makeThumbnail($physical_path . "data/news/" . $new_name, 1);
                 $this->db->ExecuteSql("Update {$this->object} Set photo2='{$short_name}' Where item_id='{$id}'");
             }
         }
         $this->Redirect($this->pageUrl . "?mes=up");
     }
 }
コード例 #2
0
ファイル: photos.php プロジェクト: romlg/blank-xpage
 function ocd_update()
 {
     $gallery_id = $this->GetStateValue("gallery_id", 0);
     $c_title = $this->db->GetOne("Select title From `pgalleries` Where gallery_id='{$gallery_id}'", "");
     $this->pageHeader = "Фотографии галереи '{$c_title}' : режим редактирования";
     $this->pageTitle = "Фотографии галереи '{$c_title}' : режим редактирования";
     $id = $this->GetGP("id");
     $content = $this->enc($this->GetValidGP("content", "Описание", VALIDATE_NOT_EMPTY));
     $z_date = mktime(0, 0, 0, $this->GetGP("dateMonth"), $this->GetGP("dateDay"), $this->GetGP("dateYear"));
     $gallery_id = $this->GetGP("gallery_id", 0);
     if ($this->errors['err_count'] > 0) {
         $this->fill_form("update", FORM_FROM_GP);
     } else {
         if (array_key_exists("photo", $_FILES) and $_FILES['photo']['error'] < 3) {
             $symbs = getUnID(5);
             $oldname = $_FILES['photo']['name'];
             $tmp_name = $_FILES['photo']['tmp_name'];
             $short_name = $id . "_" . $symbs;
             $new_name = $short_name . ".jpg";
             $thumb_name = "small_" . $new_name;
             if (is_uploaded_file($tmp_name)) {
                 $physical_path = $this->sitePath;
                 move_uploaded_file($tmp_name, $physical_path . "data/photos/" . $new_name);
                 $cmd = "chmod 666 " . $physical_path . "data/photos/" . $new_name;
                 @exec($cmd, $output, $retval);
                 @chmod($physical_path . "data/photos/" . $new_name, 0777);
                 copy($physical_path . "data/photos/" . $new_name, $physical_path . "data/photos/" . $thumb_name);
                 $cmd = "chmod 666 " . $physical_path . "data/photos/" . $thumb_name;
                 @exec($cmd, $output, $retval);
                 @chmod($physical_path . "data/photos/" . $thumb_name, 0777);
                 makeThumbnail($physical_path . "data/photos/" . $thumb_name, 0);
                 makeThumbnail($physical_path . "data/photos/" . $new_name, 1);
                 $this->db->ExecuteSql("Update `{$this->object}` Set photo='{$new_name}' Where photo_id='{$id}'");
             }
         }
         $this->db->ExecuteSql("Update `{$this->object}` Set z_date='{$z_date}', gallery_id='{$gallery_id}', content='{$content}' Where photo_id='{$id}'");
         $this->Redirect($this->pageUrl);
     }
 }