public function actionChangeCover()
 {
     $this->retVal = new stdClass();
     $relativePath = '/images/class_cover/' . Yii::app()->request->getPost('class_id_cover') . '/';
     $dir = "images/class_cover/" . Yii::app()->request->getPost('class_id_cover');
     @mkdir(Yii::getPathOfAlias('webroot') . '/' . $dir, 0777, true);
     $image = "";
     if (isset($_FILES["file_upload_cover"]["name"])) {
         if ($_FILES["file_upload_cover"]["type"] == "image/jpeg" || $_FILES["file_upload_cover"]["type"] == "image/jpg" || $_FILES["file_upload_cover"]["type"] == "image/pjpeg" || $_FILES["file_upload_cover"]["type"] == "image/x-png" || $_FILES["file_upload_cover"]["type"] == "image/png") {
             if ($_FILES["file_upload_cover"]["error"] > 0) {
                 $arr->message = "Return Code: " . $_FILES["file_upload_cover"]["error"];
             }
             $tempFile = $_FILES["file_upload_cover"]["tmp_name"];
             //3
             $targetPath = Yii::getPathOfAlias('webroot') . '/' . $dir . "/";
             //4
             $targetFile = $targetPath . $_FILES["file_upload_cover"]["name"];
             //5
             move_uploaded_file($tempFile, $targetFile);
             //6
             $image = $relativePath . $_FILES["file_upload_cover"]["name"];
         }
     }
     $image_resize = $relativePath . 'coverresize' . $_FILES["file_upload_cover"]["name"];
     imageresize::resize_image(Yii::getPathOfAlias('webroot') . $image, null, 1000, 315, false, Yii::getPathOfAlias('webroot') . $image_resize, false, false, 100);
     $this->retVal->message = Yii::app()->createUrl($image_resize);
     $class_cover = class_model::model()->findByAttributes(array('class_id' => Yii::app()->request->getPost('class_id_cover')));
     $class_cover->class_cover = $image_resize;
     $class_cover->save(FALSE);
     echo CJSON::encode($this->retVal);
     Yii::app()->end();
 }
Example #2
0
 function displayhomegallery()
 {
     if (strlen($_POST[setposition])) {
         while (list($key, $val) = each($_POST)) {
             if (strstr($key, "chk_")) {
                 $key = str_replace("chk_", "", $key);
                 config::query("UPDATE " . $this->tblpfx . "homegallery SET position='" . addslashes($val) . "' WHERE sno='{$key}'");
             }
         }
         self::filecreation();
         echo "<script>alert('Records has been updated successfully');window.location.href='?pg=" . $this->pg . "';</script>";
     }
     if (strlen($this->delid)) {
         config::query("DELETE FROM " . $this->tblpfx . "homegallery WHERE sno='" . $this->delid . "'");
         self::filecreation();
         echo "<script>window.location.href='?pg=" . $this->pg . "&success=3';</script>";
     }
     if (strlen($_POST[submit])) {
         if (strlen($_FILES[filename][name])) {
             $filename = $_FILES[filename][name];
             $additional .= ",imagename='" . addslashes($filename) . "'";
         }
         $CHKQRY = config::fetch_all_array("SELECT COUNT(*) FROM " . $this->tblpfx . "homegallery WHERE imagename='" . addslashes($filename) . "'", 1);
         if ($CHKQRY[0] == 0) {
             if ($_POST[tagdate_Month] < 10) {
                 $_POST[tagdate_Month] = "0" . ($_POST[tagdate_Month] + 1);
             }
             if ($_POST[tagdate_Day] < 10) {
                 $_POST[tagdate_Day] = "0" . $_POST[tagdate_Day];
             }
             $additional .= ",tagdate='{$_POST['tagdate_Year']}-{$_POST['tagdate_Month']}-{$_POST['tagdate_Day']}'";
             if (intval($this->upd) > 0) {
                 config::insertdb("homegallery", "update", " sno='" . $this->upd . "'", $additional);
                 $success = 2;
             } else {
                 $this->upd = config::insertdb("homegallery", "insert", "", $additional);
                 $success = 1;
             }
             if (strlen($_FILES[filename][name])) {
                 $filename = $this->upd . "-" . $filename;
                 $image = new imageresize();
                 $image->load($_FILES["filename"]["tmp_name"]);
                 $image->resize(698, 464);
                 $image->save($this->path . $filename);
             }
             self::filecreation();
             echo "<script>window.location.href='?pg=" . $this->pg . "&success={$success}'</script>";
         } else {
             $errormessage = "<div class='error'>Duplicate Image not allowed</div>";
             while (list($key, $val) = each($_POST)) {
                 if (strstr($key, "shall_")) {
                     $key = str_replace("shall_", "", $key);
                     $UPDATEROWS[$key] = $val;
                 }
             }
         }
     }
     if ($this->upd > 0) {
         $UPDATEROWS = config::fetch_all_array("SELECT * FROM " . $this->tblpfx . "homegallery WHERE sno='" . $this->upd . "'", 1);
         //if(strlen($UPDATEROWS[imagename]))
         //$imagename="<img src='".$this->path.$UPDATEROWS[sno]."-".$UPDATEROWS[imagename]."' height='50'>";
         $UPDATEROWS[tagdate] = config::datechange($UPDATEROWS[tagdate], "-", "-", "1");
     }
     if (!strlen($UPDATEROWS[tagdate]) || $UPDATEROWS[tagdate] == "00-00-0000") {
         $UPDATEROWS[tagdate] = date("d-m-Y");
     }
     if (strlen($this->upd)) {
         $TAGQUERY = config::fetch_all_array("SELECT * FROM " . $this->tblpfx . "tags a ORDER BY title");
     }
     $messagearray = array("", "Photo Uploaded<br>By default the last updated will appear first. To change the order please use Set Position", "Photo Updated", "Photo Deleted");
     $message = $_GET[success];
     $message = $messagearray[$message];
     $QUERY = config::fetch_all_array("SELECT * FROM " . $this->tblpfx . "homegallery ORDER BY position asc,sno desc");
     include "template/homegallery.tpl";
 }
 function photodisplay()
 {
     if (strlen($_POST[setposition])) {
         while (list($key, $val) = each($_POST)) {
             if (strstr($key, "chk_")) {
                 $key = str_replace("chk_", "", $key);
                 config::query("UPDATE " . $this->tblpfx . "photogallery SET position='" . addslashes($val) . "' WHERE sno='{$key}'");
             }
         }
         echo "<script>window.location.href='?pg=" . $this->pg . "&albumid=" . $this->albumid . "&albumtitle=" . $this->albumtitle . "&success=3';</script>";
     }
     if (strlen($this->delid)) {
         config::query("DELETE FROM " . $this->tblpfx . "photogallery WHERE sno='" . $this->delid . "'");
         unlink($this->path . $this->delid . "-" . $_GET[img]);
         echo "<script>window.location.href='?pg=" . $this->pg . "&albumid=" . $this->albumid . "&albumtitle=" . $this->albumtitle . "&success=3';</script>";
     }
     if (strlen($_POST[submit])) {
         if (strlen($_FILES[filename][name])) {
             $filename = $_FILES[filename][name];
             $additional .= ",imagename='" . addslashes($filename) . "'";
         }
         $CHKQRY = config::fetch_all_array("SELECT COUNT(*) FROM " . $this->tblpfx . "photogallery WHERE imagename='" . addslashes($filename) . "'", 1);
         if ($CHKQRY[0] == 0) {
             if ($_POST[tagdate_Month] < 10) {
                 $_POST[tagdate_Month] = "0" . ($_POST[tagdate_Month] + 1);
             }
             if ($_POST[tagdate_Day] < 10) {
                 $_POST[tagdate_Day] = "0" . $_POST[tagdate_Day];
             }
             $additional .= ",tagdate='{$_POST['tagdate_Year']}-{$_POST['tagdate_Month']}-{$_POST['tagdate_Day']}',albumid='" . addslashes($this->albumid) . "'";
             if (intval($this->upd) > 0) {
                 config::insertdb("photogallery", "update", " sno='" . $this->upd . "'", $additional);
                 $success = 2;
             } else {
                 $this->upd = config::insertdb("photogallery", "insert", "", $additional);
                 $success = 1;
             }
             if (strlen($_FILES[filename][name])) {
                 $filename = $this->upd . "-" . $filename;
                 //copy($_FILES[filename][tmp_name],$this->path."large/".$filename);
                 if (!is_dir($this->path)) {
                     mkdir($this->path);
                     chmod($this->path, 0777);
                     mkdir($this->path . "large/");
                     chmod($this->path . "large/", 0777);
                 }
                 list($width, $height) = getimagesize($_FILES["filename"]["tmp_name"]);
                 $newheight = 145;
                 $newwidth = $width / $height * $newheight;
                 if ($newwidth > 218) {
                     $newwidth = 218;
                 }
                 $image = new imageresize();
                 $image->load($_FILES["filename"]["tmp_name"]);
                 $image->resize($newwidth, 145);
                 $image->save($this->path . $filename);
                 ///large image
                 if ($height > 470) {
                     $newheight = 470;
                     $newwidth = $width / $height * $newheight;
                 } elseif ($width > 700) {
                     $newwidth = 700;
                     $newheight = $height / $width * $newwidth;
                 } else {
                     $newheight = $height;
                     $newwidth = $width;
                 }
                 $image->load($_FILES["filename"]["tmp_name"]);
                 $image->resize($newwidth, $newheight);
                 $image->save($this->path . "large/" . $filename);
             }
             echo "<script>window.location.href='?pg=" . $this->pg . "&albumid=" . $this->albumid . "&albumtitle=" . $this->albumtitle . "&success={$success}'</script>";
         } else {
             $errormessage = "<div class='error'>Duplicate Image not allowed</div>";
             while (list($key, $val) = each($_POST)) {
                 if (strstr($key, "shall_")) {
                     $key = str_replace("shall_", "", $key);
                     $UPDATEROWS[$key] = $val;
                 }
             }
         }
     }
     //if($UPDATEROWS[tagdate]=='' && $UPDATEROWS[city]=='' && $UPDATEROWS[religion]=='' && $UPDATEROWS[film]=='' && $UPDATEROWS[camera]=='' && $UPDATEROWS[lens]=='' && $UPDATEROWS[typeimg]=='')
     if ($this->upd > 0) {
         $UPDATEROWS = config::fetch_all_array("SELECT * FROM " . $this->tblpfx . "photogallery WHERE sno='" . $this->upd . "'", 1);
         $UPDATEROWS[tagdate] = config::datechange($UPDATEROWS[tagdate], "-", "-", "1");
         if ($UPDATEROWS[tagdate] == "00-00-0000") {
             $UPDATEROWS[tagdate] = "";
         }
         if (!strlen($UPDATEROWS[tagdate])) {
             $UPDATEROWS[tagdate] = date("d-m-Y");
         }
     } elseif (strlen($this->upd)) {
         $ALBUMROWS = config::fetch_all_array("SELECT tagdate,city,religion,typeimg,lens,film,camera FROM " . $this->tblpfx . "album WHERE sno='" . $this->albumid . "'", 1);
         $UPDATEROWS[tagdate] = config::datechange($ALBUMROWS[tagdate], "-", "-", "1");
         $UPDATEROWS[country] = $ALBUMROWS[country];
         $UPDATEROWS[city] = $ALBUMROWS[city];
         $UPDATEROWS[religion] = $ALBUMROWS[religion];
         $UPDATEROWS[film] = $ALBUMROWS[film];
         $UPDATEROWS[camera] = $ALBUMROWS[camera];
         $UPDATEROWS[lens] = $ALBUMROWS[lens];
         $UPDATEROWS[typeimg] = $ALBUMROWS[typeimg];
         if ($UPDATEROWS[tagdate] == "00-00-0000") {
             $UPDATEROWS[tagdate] = "";
         }
     }
     $QUERY = config::fetch_all_array("SELECT * FROM " . $this->tblpfx . "photogallery a where albumid='" . $this->albumid . "' ORDER BY position asc, sno desc");
     if (strlen($this->upd)) {
         $TAGQUERY = config::fetch_all_array("SELECT * FROM " . $this->tblpfx . "tags a ORDER BY title");
     }
     $messagearray = array("", "Images uploaded<br>By default the last updated will appear first. To change the order please use Set Position", "Images Updated", "Images Deleted");
     $message = $_GET[success];
     $message = $messagearray[$message];
     if (!strlen($UPDATEROWS[tagdate])) {
         $UPDATEROWS[tagdate] = date("d-m-Y");
     }
     include "template/photogallery.tpl";
 }
Example #4
0
 $path = "../photos/gallery/" . $albumname;
 //$MAXROWS=mysql_fetch_array(mysql_query("SELECT max(sno) FROM gns_photogallery"));
 mysql_query("INSERT INTO gns_photogallery SET imagename='" . $_FILES["Filedata"]["name"] . "',albumid='" . $_GET[albumid] . "'");
 $mysqlinsid = mysql_insert_id();
 include "class/imageresize.php";
 if (!is_dir($path)) {
     mkdir($path);
     chmod($path, 0777);
     mkdir($path . "large/");
     chmod($path . "large/", 0777);
 }
 list($width, $height) = getimagesize($_FILES["Filedata"]["tmp_name"]);
 $filename = $mysqlinsid . "-" . $_FILES["Filedata"]["name"];
 $newheight = 145;
 $newwidth = $width / $height * $newheight;
 $image = new imageresize();
 $image->load($_FILES["Filedata"]["tmp_name"]);
 $image->resize($newwidth, 145);
 $image->save($path . $filename);
 ///large image
 if ($height > 470) {
     $newheight = 470;
     $newwidth = $width / $height * $newheight;
 } elseif ($width > 700) {
     $newwidth = 700;
     $newheight = $height / $width * $newwidth;
 } else {
     $newheight = $height;
     $newwidth = $width;
 }
 $image->load($_FILES["Filedata"]["tmp_name"]);