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";
 }
Exemple #3
0
    $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"]);
    $image->resize($newwidth, $newheight);
    $image->save($path . "large/" . $filename);
}