Folders:


Create a new Folder    
'.$_SESSION['msg'].'!'; unset($_SESSION['msg']); } ?>

Photo Galleries >

Preview Html Html Mobile
0 or count($images_diff) > 0) { ?>

Photo Galleries >

Preview Html

'."\n"; } else if ($show=="html") { $str_preview.=htmlentities('')."
\n"; } // display files_ar $counter = 0; //$template = file_get_contents('admin-image.html'); $template = file_get_contents($html_template); foreach (array_merge($images_data, $images_diff) as $file => $caption) { if (file_exists($originals_dir.$file)) { // if file is an image $ext = strtolower(pathinfo($file, PATHINFO_EXTENSION)); if ($ext == 'jpg' or $ext == 'jpeg' or $ext == 'gif' or $ext == 'png') { // check if its thumbnail exist, otherwise create it. check_thumbnail_exist($folder, $file); //thumb size (on 'thumbs-125' folder) check_regular_exist($folder, $file); //normal size (on 'images' folder) // display thumbnail if ($show=="html") { //$str = strtolower($folder); //$str = str_replace(array(' ','_'),'-', $str); $str = urlencode($folder); // remove multiple _'s //while (strpos($str, "--") !== FALSE) //{ // $str=str_replace("--", "-", $str); //} // remove starting _'s and ending _'s //$str=trim($str, "-"); $folder_name = $str; } else { $folder_name = $folder; } $str = str_replace(array('[image_id]','[image_filename]','[image_caption]','[folder_name]'), array('ad'.($counter+1), $file, $caption, $folder_name), $template); if ($show=="") { $str_preview.=$str."\n"; } else { $str_preview.=htmlentities($str)."
\n"; } $counter++; if ($counter % 6 == 0) { if ($show=="") { $str_preview.="\n\n"; } else if ($show=="html") { $str_preview.=htmlentities("")."
\n".htmlentities("")."
\n"; } } } else { } } } if ($show=="") { $str_preview.=''."\n"; } else if ($show=="html") { $str_preview.=htmlentities('')."
\n"; } if ($show=="") { $template_preview = file_get_contents('admin-preview.html'); $str_preview = str_replace(array('[folder_url]','[folder_name]','[content_preview]'), array($url, $folder, $str_preview), $template_preview); } else if ($show=="html") { $str_preview = htmlentities('')."
\n".$str_preview.htmlentities('
'); } echo $str_preview; } function check_thumbnail_exist($folder, $file, $create=false) { global $BASE_IMG_PATH, $BASE_IMG_URL; $dir = $BASE_IMG_PATH.$folder.'/'; $originals_dir = $dir.'originals/'; $thumbs_dir = $dir.'thumbs-125/'; // thumbnail size image doesn't exist if (!file_exists($thumbs_dir.$file)) { if ($create) a_makethumb($originals_dir.$file,$thumbs_dir.$file,$height=125,$width=125); else return false; } // thumbnail size image is out dated if (file_exists($thumbs_dir.$file)) { $stat = stat($originals_dir.$file); $thumbnail_stat = stat($thumbs_dir.$file); if ($thumbnail_stat['mtime'] < $stat['mtime']) { if ($create) { unlink($thumbs_dir.$file); a_makethumb($originals_dir.$file,$thumbs_dir.$file,$height=125,$width=125); } else return false; } } return true; } function check_regular_exist($folder, $file, $create=false) { global $BASE_IMG_PATH, $BASE_IMG_URL; $dir = $BASE_IMG_PATH.$folder.'/'; $originals_dir = $dir.'originals/'; $images_dir = $dir.'images/'; // regular size image doesn't exist if (!file_exists($images_dir.$file)) { if ($create) a_makethumb($originals_dir.$file,$images_dir.$file,$height=650,$width=650); else return false; } // thumbnail is out dated if (file_exists($images_dir.$file)) { $stat = stat($originals_dir.$file); $image_stat = stat($images_dir.$file); if ($image_stat['mtime'] < $stat['mtime']) { if ($create) { unlink($images_dir.$file); a_makethumb($originals_dir.$file,$images_dir.$file,$height=650,$width=650); } else return false; } } return true; } function image_create() { global $BASE_IMG_PATH, $BASE_IMG_URL; $folder = $_GET['f']; $file = $_GET['image']; $size = $_GET['size']; $dir = $BASE_IMG_PATH.$folder.'/'; $originals_dir = $dir.'originals/'; $thumbs_dir = $dir.'thumbs-125/'; $images_dir = $dir.'images/'; $url = $BASE_IMG_URL.$folder.'/'; $originals_url = $url.'originals/'; $thumbs_url = $url.'thumbs-125/'; $images_url = $url.'images/'; header("Content-Type: image/jpeg"); if ($size == 'thumbnail') { check_thumbnail_exist($folder, $file, $create=true); readfile($thumbs_dir.$file); } if ($size == 'regular') { check_regular_exist($folder, $file, $create=true); readfile($images_dir.$file); } exit; } //function images_update() //{ // $folder = $_GET['f']; // // $image_name_ar = $_POST['image_name']; // $image_caption_ar = $_POST['image_caption']; // // csv_file_write($folder, $image_name_ar, $image_caption_ar); // // header('Location: admin-gallery.php?method=folder_view&f='.$folder); // exit; //} function csv_file_write($folder, $image_name_ar, $image_caption_ar) { global $BASE_IMG_PATH, $BASE_IMG_URL; $csv_file = $BASE_IMG_PATH.$folder.'/'.$folder.'.csv'; $set_permissions = false; if (!file_exists($csv_file)) { $set_permissions = true; } if (file_exists($csv_file) and !is_writable($csv_file)) { chmod($csv_file, 0664); } if (file_exists($csv_file) and !is_writable($csv_file)) { echo '.csv file is not writable'; exit; } $fp = fopen($csv_file, 'w'); for ($i=0; $i0) { return false; } return true; } function a_makethumb($origimg,$newimg,$height=200,$width=200,$quality=85) { // Get new dimensions list($width_orig, $height_orig) = getimagesize($origimg); $size = getimagesize($origimg); if ($size) { $width_orig = $size[0]; $height_orig = $size[1]; } else { // could get the image dimmensions return; } if ($height_orig<=$height && $width_orig<=$width) { // already small enough $width=$width_orig; $height=$height_orig; } else { // shrink if (($width/$width_orig)>($height/$height_orig)) { $height=round($height); $width=round($width_orig*($height/$height_orig)); } else { $width=round($width); $height=round($height_orig*($width/$width_orig)); } } $image_p = imagecreatetruecolor($width, $height); $ext = strtolower(pathinfo($origimg, PATHINFO_EXTENSION)); if ($ext == 'gif') { $image = imagecreatefromgif($origimg); } elseif ($ext == 'png') { $image = imagecreatefrompng($origimg); } else { $image = imagecreatefromjpeg($origimg); } imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig); // Output if ($ext == 'gif') { imagegif($image_p, $newimg); } elseif ($ext == 'png') { imagepng($image_p, $newimg); } else { // rotate $exif = exif_read_data($origimg); if (is_array($exif)) { if (!empty($exif['Orientation']) and $exif['Orientation']==6) { $image_p = imagerotate($image_p, $degrees=270, 0); } if (!empty($exif['Orientation']) and $exif['Orientation']==8) { $image_p = imagerotate($image_p, $degrees=90, 0); } } imagejpeg($image_p, $newimg, $quality); } imagedestroy($image_p); } function login() { global $GALLERY_USERS; $error = ''; if ($_SERVER['REQUEST_METHOD'] == 'POST' and !empty($_POST['submit']) and $_POST['submit'] == 'Login') { $login = trim($_POST['login']); $pass = trim($_POST['pass']); if (!empty($login) and !empty($pass)) { if (!empty($GALLERY_USERS[$login]) and $GALLERY_USERS[$login] == md5($pass)) { $_SESSION['GalleryUser'] = $login; cookie_set($login); header('Location: admin-gallery.php'); exit; } else { $error = 'Incorrect Login/Password'; } } else { $error = 'Login or Password are empty'; } } template_header(); ?>
Login
Password
Gallery'; ?> '; } } function template_footer() { global $HIDE_TEMPLATE; if (!$HIDE_TEMPLATE) { echo ' '; } } $method = @$_GET['method']; if ($method == 'folder_preview' or $method == 'folder_html' or $method == 'folder_html_mobile' or $method == 'image_create') { $HIDE_TEMPLATE=1; } template_header(); switch ($method) { case 'folders_main': folders_main(); break; case 'folder_add': folder_add(); break; case 'folder_view': folder_view(); break; case 'folder_preview': folder_preview(); break; case 'folder_html': folder_preview($show="html"); break; case 'folder_html_mobile': folder_preview($show="html_mobile", 'admin-image-mobile.html'); break; case 'image_create': image_create(); break; // case 'images_update': // images_update(); // break; case 'captions_update': captions_update(); break; default: folders_main(); } template_footer(); ?>