public function addPicDb($tid, $title, $picUrl, $yid, $lid) { //检测是否已经有此图片 $isExists = $this->dbPic->frow("picurl='{$picUrl}'"); if (!empty($isExists)) { return true; } $yPicFile = $this->copyYuantu($picUrl); if ($yPicFile == false) { return false; } $picName = substr($yPicFile, strrpos($yPicFile, '/') + 1); $hPicPath = $this->hpicPath . date('YmdH') . '/'; $mPicPath = $this->mpicPath . date('YmdH') . '/'; $lPicPath = $this->lpicPath . date('YmdH') . '/'; $tPicPath = $this->tpicPath . date('YmdH') . '/'; if (!is_dir($hPicPath)) { mkdir($hPicPath); chmod($hPicPath, 777); } if (!is_dir($mPicPath)) { mkdir($mPicPath); chmod($mPicPath, 777); } if (!is_dir($lPicPath)) { mkdir($lPicPath); chmod($lPicPath, 777); } if (!is_dir($tPicPath)) { mkdir($tPicPath); chmod($tPicPath, 777); } $hPicFile = resizeThumbnailImage($hPicPath . $picName, $yPicFile, $this->sHpic); $mPicFile = resizeThumbnailImage($mPicPath . $picName, $yPicFile, $this->sMpic); $lPicFile = resizeThumbnailImage($lPicPath . $picName, $yPicFile, $this->sLpic); $tPicFile = resizeThumbnailImage($tPicPath . $picName, $yPicFile, 1, $this->sTpic); $insert = array('lid' => $lid, 'yid' => $yid, 'tid' => $tid, 'picurl' => $picUrl, 'pname' => $title, 'ypicurl' => substr($yPicFile, strpos($yPicFile, '/upload')), 'hpicurl' => substr($hPicFile, strpos($hPicFile, '/upload')), 'mpicurl' => substr($mPicFile, strpos($mPicFile, '/upload')), 'lpicurl' => substr($lPicFile, strpos($lPicFile, '/upload')), 'tpicurl' => substr($tPicFile, strpos($tPicFile, '/upload')), 'status' => 1, 'created' => time()); return $this->dbPic->insert($insert); }
//Refresh the page to show the new uploaded image header("location:" . $_SERVER["PHP_SELF"]); exit; } } if (isset($_POST["upload_thumbnail"]) && strlen($large_photo_exists) > 0) { //Get the new coordinates to crop the image. $x1 = $_POST["x1"]; $y1 = $_POST["y1"]; $x2 = $_POST["x2"]; $y2 = $_POST["y2"]; $w = $_POST["w"]; $h = $_POST["h"]; //Scale the image to the thumb_width set above $scale = $thumb_width / $w; $cropped = resizeThumbnailImage($thumb_image_location, $large_image_location, $w, $h, $x1, $y1, $scale); //Reload the page again to view the thumbnail //header("location:".$_SERVER["PHP_SELF"]); $login_id = $_SESSION['userid']; $dbimagefilename = str_replace("uploads/profile/", "", $thumb_image_location); require_once "db/db.php"; $data_layer = new db_layer(); $update_query = mysql_query("update registration SET profile_pic='{$dbimagefilename}' where id={$login_id}") or die("{$sql_error}" . mysql_error()); mysql_close(); Header("Location:imagesavesuccess.php"); exit; } if ($_GET['a'] == "delete" && strlen($_GET['t']) > 0) { //get the file locations $large_image_location = $upload_path . $large_image_prefix . $_GET['t']; $thumb_image_location = $upload_path . $thumb_image_prefix . $_GET['t'];
function blogsmu_features_page() { global $blog_id, $themename, $theme_version, $image_prefix_name; $image_prefix_name = 'blogsmu'; $service_block = "Service"; //////////////////////////////////////////// $uploads = wp_upload_dir(); $upload_files_path = get_option('upload_path'); //echo wp_upload_dir() . '<br /><br />'; //echo get_option('upload_path'). '<br /><br />'; //echo $uploads['path'] . '<br /><br />'; //echo $uploads['url'] . '<br /><br />'; //echo $uploads['subdir'] . '<br /><br />'; //echo $uploads['basedir'] . '<br /><br />'; //echo $uploads['baseurl'] . '<br /><br />'; //echo $uploads['error'] . ' - ERROR<br /><br />'; //echo WP_CONTENT_DIR . '<br /><br />'; //echo WP_CONTENT_URL . '<br /><br />'; $upload_url_trim = str_replace(WP_CONTENT_DIR, "", $uploads['basedir']); //echo $upload_url_trim . '<br /><br />'; if (substr($upload_url_trim, -1) == '/') { $upload_url_trim = rtrim($upload_url_trim, '/'); } /////////////////////////////////////////////////////You can alter these options/////////////////////////// $tpl_url = get_site_url(); $ptp = get_template(); $uploads_folder = "thumb"; $upload_path = $uploads['basedir'] . '/' . $uploads_folder . "/"; $upload_path_check = $uploads['basedir'] . '/' . $uploads_folder; $ttpl = get_template_directory_uri(); $ttpl_url = get_site_url(); $upload_url = WP_CONTENT_URL . $upload_url_trim . '/' . $uploads_folder; //echo $upload_url; //Create the upload directory with the right permissions if it doesn't exist if (!is_dir($upload_path_check)) { mkdir($upload_path_check, 0777); } chmod($upload_path_check, 0777); // Only one of these image types should be allowed for upload $allowed_image_types = array('image/pjpeg' => "jpg", 'image/jpeg' => "jpg", 'image/jpg' => "jpg", 'image/png' => "png", 'image/x-png' => "png", 'image/gif' => "gif"); $allowed_image_ext = array_unique($allowed_image_types); // do not change this $image_ext = ""; // initialise variable, do not change this. foreach ($allowed_image_ext as $mime_type => $ext) { $image_ext .= strtoupper($ext) . " "; } ?> <div id="options-panel"> <div id="options-head"><h2><?php echo $themename; ?> <?php _e("Custom Homepage Options", TEMPLATE_DOMAIN); ?> </h2> <div class="theme-versions"><?php _e("Version", TEMPLATE_DOMAIN); ?> <?php echo $theme_version; ?> </div> </div> <div id="sbtabs_uploads"> <div id='tab1' class="tabc"> <?php ///////////////////////////////////////////////////////////////////////////////////////////////////////// $large_image_name = $image_prefix_name . '1.jpg'; // New name of the large image $normal_image_name = $image_prefix_name . '1_normal.jpg'; // New name of the large image $thumb_image_name = $image_prefix_name . '1_thumb.jpg'; // New name of the thumbnail image $max_file = "1000000"; // Approx below 1MB $max_width = "850"; // Max width allowed for the large image $thumb_width = "260"; // Width of thumbnail image $thumb_height = "150"; // Height of thumbnail image //Image Locations $normal_image_location = $upload_path . $normal_image_name; $large_image_location = $upload_path . $large_image_name; $thumb_image_location = $upload_path . $thumb_image_name; //Check to see if any images with the same names already exist if (file_exists($large_image_location)) { if (file_exists($thumb_image_location)) { $thumb_photo_exists = "<img src=\"" . $upload_path . $thumb_image_name . "\" alt=\"Thumbnail Image\"/>"; } else { $thumb_photo_exists = ""; } $large_photo_exists = "<img src=\"" . $upload_path . $large_image_name . "\" alt=\"Large Image\"/>"; } else { $large_photo_exists = ""; $thumb_photo_exists = ""; } // normal photo check if (file_exists($normal_image_location)) { $normal_photo_exists = "<img src=\"" . $upload_path . $normal_image_name . "\" alt=\"Large Image\"/>"; } else { $normal_photo_exists = ""; } if (isset($_POST['upload1'])) { //Get the file information $userfile_name = $_FILES['image']['name']; $userfile_tmp = $_FILES['image']['tmp_name']; $userfile_type = $_FILES['image']['type']; $userfile_size = $_FILES['image']['size']; $filename = basename($_FILES['image']['name']); $file_ext = substr($filename, strrpos($filename, '.') + 1); //Only process if the file is a JPG, PNG or GIF and below the allowed limit if (!empty($_FILES["image"]) && $_FILES['image']['error'] == 0) { foreach ($allowed_image_types as $mime_type => $ext) { //loop through the specified image types and if they match the extension then break out //everything is ok so go and check file size if ($file_ext == $ext && $userfile_type == $mime_type) { $error = ""; break; } else { $error = __("Only", TEMPLATE_DOMAIN) . "<strong>" . $image_ext . "</strong>" . __("images accepted for upload", TEMPLATE_DOMAIN) . "<br />"; } } //check if the file size is above the allowed limit if ($userfile_size > $max_file) { $error .= __("Images must be under 1 MB in size", TEMPLATE_DOMAIN); } } else { $error = __("Select an image to upload", TEMPLATE_DOMAIN); } //Everything is ok, so we can upload the image. if (strlen($error) == 0) { if (isset($_FILES['image']['name'])) { move_uploaded_file($userfile_tmp, $large_image_location); chmod($large_image_location, 0777); $width = getWidth($large_image_location); $height = getHeight($large_image_location); //Scale the image if it is greater than the width set above if ($width > $max_width) { $scale = $max_width / $width; $uploaded = resizeImage($large_image_location, $width, $height, $scale); } else { $scale = 1; $uploaded = resizeImage($large_image_location, $width, $height, $scale); } //Delete the thumbnail file so the user can create a new one if (file_exists($thumb_image_location)) { unlink($thumb_image_location); } } //Refresh the page to show the new uploaded image print '<meta http-equiv="Pragma" content="no-cache">'; echo "<h4 id=\"loading-bar\">Please wait..Your Image Currently Processing</h4>"; echo '<img src="' . get_template_directory_uri() . '/_inc/admin/loading_bar.gif' . '">'; print "<meta http-equiv=\"refresh\" content=\"5;url={$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php&#tab1\">"; exit; //double refresh to clear cache..its a bit catchy but it get the job done } } /////////////////////////////////////////////////////////////////////////////// // if upload with no crop features /////////////////////////////////////////////////////////////////////////////// if (isset($_POST["normal_upload1"])) { //Get the file information $userfile_name = $_FILES['image']['name']; $userfile_type = $_FILES['image']['type']; $userfile_tmp = $_FILES['image']['tmp_name']; $userfile_size = $_FILES['image']['size']; $filename = basename($_FILES['image']['name']); $file_ext = substr($filename, strrpos($filename, '.') + 1); //Only process if the file is a JPG and below the allowed limit if (!empty($_FILES["image"]) && $_FILES['image']['error'] == 0) { foreach ($allowed_image_types as $mime_type => $ext) { //loop through the specified image types and if they match the extension then break out //everything is ok so go and check file size if ($file_ext == $ext && $userfile_type == $mime_type) { $error = ""; break; } else { $error = __("Only", TEMPLATE_DOMAIN) . "<strong>" . $image_ext . "</strong>" . __("images accepted for upload", TEMPLATE_DOMAIN) . "<br />"; } } if ($userfile_size > $max_file) { $error = __("ONLY images under 1MB are accepted for upload", TEMPLATE_DOMAIN); } } else { $error = __("Select an image for upload", TEMPLATE_DOMAIN); } //Everything is ok, so we can upload the image. if (strlen($error) == 0) { if (isset($_FILES['image']['name'])) { move_uploaded_file($userfile_tmp, $normal_image_location); chmod($normal_image_location, 0777); //Delete the thumbnail file so the user can create a new one if (file_exists($thumb_image_location)) { unlink($thumb_image_location); } } //Refresh the page to show the new uploaded image print '<meta http-equiv="Pragma" content="no-cache">'; echo "<h4 id=\"loading-bar\">Please wait..Your Image Currently Processing</h4>"; echo '<img src="' . get_template_directory_uri() . '/_inc/admin/loading_bar.gif' . '">'; print "<meta http-equiv=\"refresh\" content=\"5;url={$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php&#tab1\">"; exit; //double refresh to clear cache..its a bit catchy but it get the job done } } if (isset($_POST['upload_thumbnail1']) && strlen($large_photo_exists) > 0) { //Get the new coordinates to crop the image. $x1 = $_POST["x1"]; $y1 = $_POST["y1"]; $x2 = $_POST["x2"]; $y2 = $_POST["y2"]; $w = $_POST["w"]; $h = $_POST["h"]; //Scale the image to the thumb_width set above $scale = $thumb_width / $w; $cropped = resizeThumbnailImage($thumb_image_location, $large_image_location, $w, $h, $x1, $y1, $scale); //Refresh the page to show the new uploaded image print '<meta http-equiv="Pragma" content="no-cache">'; echo "<h4 id=\"loading-bar\">Please wait..Your Image Currently Processing</h4>"; echo '<img src="' . get_template_directory_uri() . '/_inc/admin/loading_bar.gif' . '">'; print "<meta http-equiv=\"refresh\" content=\"5;url={$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php&#tab1\">"; exit; //double refresh to clear cache..its a bit catchy but it get the job done } ?> <?php //Only display the javacript if an image has been uploaded if (strlen($large_photo_exists) > 0) { $current_large_image_width = getWidth($large_image_location); $current_large_image_height = getHeight($large_image_location); ?> <script type="text/javascript"> function preview(img, selection) { var scaleX = <?php echo $thumb_width; ?> / selection.width; var scaleY = <?php echo $thumb_height; ?> / selection.height; $('#thumbnail + div > img').css({ width: Math.round(scaleX * <?php echo $current_large_image_width; ?> ) + 'px', height: Math.round(scaleY * <?php echo $current_large_image_height; ?> ) + 'px', marginLeft: '-' + Math.round(scaleX * selection.x1) + 'px', marginTop: '-' + Math.round(scaleY * selection.y1) + 'px' }); $('#x1').val(selection.x1); $('#y1').val(selection.y1); $('#x2').val(selection.x2); $('#y2').val(selection.y2); $('#w').val(selection.width); $('#h').val(selection.height); } $(document).ready(function () { $('#save_thumb').click(function() { var x1 = $('#x1').val(); var y1 = $('#y1').val(); var x2 = $('#x2').val(); var y2 = $('#y2').val(); var w = $('#w').val(); var h = $('#h').val(); if(x1=="" || y1=="" || x2=="" || y2=="" || w=="" || h==""){ alert("You must make a selection first"); return false; } else { return true; } }); }); function selectionStart(img, selection) { width:260; height:150; } $(window).load(function () { $('#thumbnail').imgAreaSelect({ onSelectStart: selectionStart, resizable: true, x1: 20, y1: 20, x2: 280, y2: 170, aspectRatio: '28:17', onSelectChange: preview }); }); </script> <?php } ?> <div class="admin-options"> <?php global $themename, $shortname; if ($_REQUEST['resetall']) { echo '<div id="message" class="updated fade"><p><strong>' . __("All images deleted and settings reset", TEMPLATE_DOMAIN) . '</strong></p></div>'; } ?> <?php global $themename, $shortname, $options4; if ($_REQUEST['saved4']) { echo '<div id="message" class="updated fade"><p><strong>' . $themename . __(' Featured image 1 Settings saved.', TEMPLATE_DOMAIN) . '</strong></p></div>'; } if ($_REQUEST['reset4']) { echo '<div id="message" class="updated fade"><p><strong>' . $themename . __(' Featured image 1 Settings reset.', TEMPLATE_DOMAIN) . '</strong></p></div>'; } ?> <h4><?php _e("Featured images 1 Setting", TEMPLATE_DOMAIN); ?> </h4> <div class="tab-option"> <div class="option-save"> <?php if (isset($_POST['delete_thumbnail1'])) { unlink($upload_path . $large_image_name); unlink($upload_path . $thumb_image_name); echo "<h2 id='file-delete'>" . __("File successfully deleted", TEMPLATE_DOMAIN) . "</h2>"; print "<meta http-equiv=\"refresh\" content=\"1;url={$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php&#tab1\">"; exit; } if (isset($_POST["delete_normal_upload1"])) { unlink("{$upload_path}/{$normal_image_name}"); echo "<h2 id='file-delete'>" . __('File successfully deleted', TEMPLATE_DOMAIN) . "</h2>"; print "<meta http-equiv=\"refresh\" content=\"1;url={$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php&#tab1\">"; exit; } ?> <?php //Display error message if there are any if (strlen($error) > 0) { echo "<p class=\"uperror\"><strong>" . __("Error!", TEMPLATE_DOMAIN) . " </strong>" . $error . "</p>"; } if (strlen($large_photo_exists) > 0 && strlen($thumb_photo_exists) > 0) { ?> <img src="<?php echo "{$upload_url}/{$thumb_image_name}"; ?> " class="timg"/><br /><br /> <form id="form-del" name="thumbnail" action="" method="post"> <div class="submit"><input type="submit" name="delete_thumbnail1" class="button-secondary" value="<?php _e("Delete This Image", TEMPLATE_DOMAIN); ?> " /></div> </form> <?php } else { if (strlen($normal_photo_exists) > 0) { ?> <img src="<?php echo "{$upload_url}/{$normal_image_name}"; ?> " class="timg"/><br /><br /> <form id="form-del" name="thumbnail" action="" method="post"> <input type="submit" class="button-secondary" name="delete_normal_upload1" value="<?php _e("Delete This Image", TEMPLATE_DOMAIN); ?> " /> </form> <?php } } ?> <?php if (strlen($large_photo_exists) > 0 && strlen($thumb_photo_exists) > 0) { } else { if (strlen($large_photo_exists) > 0) { ?> <h3><?php _e('Crop And Save Your Thumbnail', TEMPLATE_DOMAIN); ?> </h3> <div> <img src="<?php echo "{$upload_url}/{$large_image_name}"; ?> " style="clear: both; margin-bottom: 10px;" id="thumbnail" alt="Create Thumbnail" /> <br style="clear:both;"/> <form name="thumbnail" action="" method="post"> <input type="hidden" name="x1" value="" id="x1" /> <input type="hidden" name="y1" value="" id="y1" /> <input type="hidden" name="x2" value="" id="x2" /> <input type="hidden" name="y2" value="" id="y2" /> <input type="hidden" name="w" value="" id="w" /> <input type="hidden" name="h" value="" id="h" /> <div class="submit"><input type="submit" class="sbutton button-secondary" name="upload_thumbnail1" value="<?php _e("Save Thumbnail", TEMPLATE_DOMAIN); ?> " id="save_thumb" /></div> </form> </div> <?php } } ?> <?php if (strlen($large_photo_exists) == 0 && strlen($normal_photo_exists) == 0) { ?> <h3><?php _e("Upload Image", TEMPLATE_DOMAIN); ?> <?php echo $thumb_width . ' X ' . $thumb_height; ?> </h3> <form name="photo" enctype="multipart/form-data" action="<?php echo admin_url('themes.php?page=custom-homepage.php&#tab1'); ?> " method="post"> <input type="file" class="ups" name="image" /> <input type="submit" name="upload1" class="sbutton button-secondary" value="<?php _e("Upload and crop »", TEMPLATE_DOMAIN); ?> " /> <input type="submit" name="normal_upload1" class="sbutton button-secondary" value="<?php _e("Upload »", TEMPLATE_DOMAIN); ?> " /> <p class="onlyjpg">* <?php _e("only", TEMPLATE_DOMAIN); ?> <?php echo $image_ext; ?> <?php _e("image file are allowed", TEMPLATE_DOMAIN); ?> </p> </form> <?php } ?> <br /> <form method="post"> <?php foreach ($options4 as $value) { ?> <?php switch ($value['type']) { case 'text': ?> <div class="description"><?php echo $value['name']; ?> </div> <p><input name="<?php echo $value['id']; ?> " class="myfield" id="<?php echo $value['id']; ?> " type="<?php echo $value['type']; ?> " value="<?php if (get_option($value['id']) != "") { echo get_option($value['id']); } else { echo $value['std']; } ?> " /> </p> <?php break; case 'textarea': ?> <?php $valuex = $value['id']; $valuey = stripslashes($valuex); $video_code = get_option($valuey); ?> <div class="description"><?php echo $value['name']; ?> </div> <p><textarea name="<?php echo $valuey; ?> " class="mytext" cols="40%" rows="8" /><?php if (get_option($valuey) != "") { echo stripslashes($video_code); } else { echo $value['std']; } ?> </textarea></p> <?php break; default: ?> <?php break; } ?> <?php } ?> <p class="submit"> <input name="save" type="submit" class="sbutton button-primary" value="<?php _e("Save setting", TEMPLATE_DOMAIN); ?> " /> <input type="hidden" name="action" value="save4" /> </p> </form> <form method="post"> <p class="submit"> <input name="reset" type="submit" class="sbutton button-primary" value="<?php _e("Reset setting", TEMPLATE_DOMAIN); ?> " /> <input type="hidden" name="action" value="reset4" /> </p> </form> </div> </div> </div><!-- admin-options --> </div><!-- end tabc --> <?php echo "<div id='tab2' class='tabc'>"; $large_image_name = $image_prefix_name . '2.jpg'; // New name of the large image $normal_image_name = $image_prefix_name . '2_normal.jpg'; // New name of the thumbnail image $thumb_image_name = $image_prefix_name . '2_thumb.jpg'; // New name of the thumbnail image $max_file = "1000000"; // Approx below 1MB $max_width = "850"; // Max width allowed for the large image $thumb_width = "260"; // Width of thumbnail image $thumb_height = "150"; // Height of thumbnail image //Image Locations $normal_image_location = $upload_path . $normal_image_name; $large_image_location = $upload_path . $large_image_name; $thumb_image_location = $upload_path . $thumb_image_name; //Check to see if any images with the same names already exist if (file_exists($large_image_location)) { if (file_exists($thumb_image_location)) { $thumb_photo_exists = "<img src=\"" . $upload_path . $thumb_image_name . "\" alt=\"Thumbnail Image\"/>"; } else { $thumb_photo_exists = ""; } $large_photo_exists = "<img src=\"" . $upload_path . $large_image_name . "\" alt=\"Large Image\"/>"; } else { $large_photo_exists = ""; $thumb_photo_exists = ""; } //Check normal image if (file_exists($normal_image_location)) { $normal_photo_exists = "<img src=\"" . $upload_path . $normal_image_name . "\" alt=\"Large Image\"/>"; } else { $normal_photo_exists = ""; } if (isset($_POST['upload2'])) { //Get the file information $userfile_name = $_FILES['image']['name']; $userfile_tmp = $_FILES['image']['tmp_name']; $userfile_type = $_FILES['image']['type']; $userfile_size = $_FILES['image']['size']; $filename = basename($_FILES['image']['name']); $file_ext = substr($filename, strrpos($filename, '.') + 1); //Only process if the file is a JPG, PNG or GIF and below the allowed limit if (!empty($_FILES["image"]) && $_FILES['image']['error'] == 0) { foreach ($allowed_image_types as $mime_type => $ext) { //loop through the specified image types and if they match the extension then break out //everything is ok so go and check file size if ($file_ext == $ext && $userfile_type == $mime_type) { $error = ""; break; } else { $error = __("Only", TEMPLATE_DOMAIN) . " <strong>" . $image_ext . "</strong>" . __(" images accepted for upload", TEMPLATE_DOMAIN) . "<br />"; } } //check if the file size is above the allowed limit if ($userfile_size > $max_file) { $error .= __("Images must be under 1 MB in size", TEMPLATE_DOMAIN); } } else { $error = __("Select an image for upload", TEMPLATE_DOMAIN); } //Everything is ok, so we can upload the image. if (strlen($error) == 0) { if (isset($_FILES['image']['name'])) { move_uploaded_file($userfile_tmp, $large_image_location); chmod($large_image_location, 0777); $width = getWidth($large_image_location); $height = getHeight($large_image_location); //Scale the image if it is greater than the width set above if ($width > $max_width) { $scale = $max_width / $width; $uploaded = resizeImage($large_image_location, $width, $height, $scale); } else { $scale = 1; $uploaded = resizeImage($large_image_location, $width, $height, $scale); } //Delete the thumbnail file so the user can create a new one if (file_exists($thumb_image_location)) { unlink($thumb_image_location); } } //Refresh the page to show the new uploaded image print '<meta http-equiv="Pragma" content="no-cache">'; echo "<h4 id=\"loading-bar\">Please wait..Your Image Currently Processing</h4>"; echo '<img src="' . get_template_directory_uri() . '/_inc/admin/loading_bar.gif' . '">'; print "<meta http-equiv=\"refresh\" content=\"5;url={$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php&#tab2\">"; exit; //double refresh to clear cache..its a bit catchy but it get the job done } } //normal image if (isset($_POST["normal_upload2"])) { //Get the file information $userfile_name = $_FILES['image']['name']; $userfile_tmp = $_FILES['image']['tmp_name']; $userfile_type = $_FILES['image']['type']; $userfile_size = $_FILES['image']['size']; $filename = basename($_FILES['image']['name']); $file_ext = substr($filename, strrpos($filename, '.') + 1); //Only process if the file is a JPG and below the allowed limit if (!empty($_FILES["image"]) && $_FILES['image']['error'] == 0) { foreach ($allowed_image_types as $mime_type => $ext) { //loop through the specified image types and if they match the extension then break out //everything is ok so go and check file size if ($file_ext == $ext && $userfile_type == $mime_type) { $error = ""; break; } else { $error = __("Only", TEMPLATE_DOMAIN) . "<strong>" . $image_ext . "</strong>" . __("images accepted for upload", TEMPLATE_DOMAIN) . "<br />"; } } if ($userfile_size > $max_file) { $error = __("ONLY images under 1MB are accepted for upload", TEMPLATE_DOMAIN); } } else { $error = __("Select an image for upload", TEMPLATE_DOMAIN); } //Everything is ok, so we can upload the image. if (strlen($error) == 0) { if (isset($_FILES['image']['name'])) { move_uploaded_file($userfile_tmp, $normal_image_location); chmod($normal_image_location, 0777); //Delete the thumbnail file so the user can create a new one if (file_exists($thumb_image_location)) { unlink($thumb_image_location); } } //Refresh the page to show the new uploaded image print '<meta http-equiv="Pragma" content="no-cache">'; echo "<h4 id=\"loading-bar\">Please wait..Your Image Currently Processing</h4>"; echo '<img src="' . get_template_directory_uri() . '/_inc/admin/loading_bar.gif' . '">'; print "<meta http-equiv=\"refresh\" content=\"5;url={$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php&#tab2\">"; exit; //double refresh to clear cache..its a bit catchy but it get the job done } } if (isset($_POST['upload_thumbnail2']) && strlen($large_photo_exists) > 0) { //Get the new coordinates to crop the image. $x1 = $_POST["x1"]; $y1 = $_POST["y1"]; $x2 = $_POST["x2"]; $y2 = $_POST["y2"]; $w = $_POST["w"]; $h = $_POST["h"]; //Scale the image to the thumb_width set above $scale = $thumb_width / $w; $cropped = resizeThumbnailImage($thumb_image_location, $large_image_location, $w, $h, $x1, $y1, $scale); //Refresh the page to show the new uploaded image print '<meta http-equiv="Pragma" content="no-cache">'; echo "<h4 id=\"loading-bar\">Please wait..Your Image Currently Processing</h4>"; echo '<img src="' . get_template_directory_uri() . '/_inc/admin/loading_bar.gif' . '">'; print "<meta http-equiv=\"refresh\" content=\"5;url={$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php&#tab2\">"; exit; //double refresh to clear cache..its a bit catchy but it get the job done } ?> <?php //Only display the javacript if an image has been uploaded if (strlen($large_photo_exists) > 0) { $current_large_image_width = getWidth($large_image_location); $current_large_image_height = getHeight($large_image_location); ?> <script type="text/javascript"> function preview(img, selection) { var scaleX = <?php echo $thumb_width; ?> / selection.width; var scaleY = <?php echo $thumb_height; ?> / selection.height; $('#thumbnail + div > img').css({ width: Math.round(scaleX * <?php echo $current_large_image_width; ?> ) + 'px', height: Math.round(scaleY * <?php echo $current_large_image_height; ?> ) + 'px', marginLeft: '-' + Math.round(scaleX * selection.x1) + 'px', marginTop: '-' + Math.round(scaleY * selection.y1) + 'px' }); $('#x1').val(selection.x1); $('#y1').val(selection.y1); $('#x2').val(selection.x2); $('#y2').val(selection.y2); $('#w').val(selection.width); $('#h').val(selection.height); } $(document).ready(function () { $('#save_thumb').click(function() { var x1 = $('#x1').val(); var y1 = $('#y1').val(); var x2 = $('#x2').val(); var y2 = $('#y2').val(); var w = $('#w').val(); var h = $('#h').val(); if(x1=="" || y1=="" || x2=="" || y2=="" || w=="" || h==""){ alert("You must make a selection first"); return false; } else { return true; } }); }); function selectionStart(img, selection) { width:260;height:150 } $(window).load(function () { $('#thumbnail').imgAreaSelect({ onSelectStart: selectionStart, resizable: true, x1: 20, y1: 20, x2: 280, y2: 170, aspectRatio: '28:17', onSelectChange: preview }); }); </script> <?php } ?> <div class="admin-options"> <?php global $themename, $shortname, $options5; if ($_REQUEST['saved5']) { echo '<div id="message" class="updated fade"><p><strong>' . $themename . __(' Featured image 2 Settings saved.', TEMPLATE_DOMAIN) . '</strong></p></div>'; } if ($_REQUEST['reset5']) { echo '<div id="message" class="updated fade"><p><strong>' . $themename . __(' Featured image 2 Settings reset.', TEMPLATE_DOMAIN) . '</strong></p></div>'; } ?> <h4><?php _e("Featured image 2 Setting", TEMPLATE_DOMAIN); ?> </h4> <div class="tab-option"> <div class="option-save"> <?php if (isset($_POST['delete_thumbnail2'])) { unlink($upload_path . $large_image_name); unlink($upload_path . $thumb_image_name); echo "<h5 id='file-delete'>" . __('File successfully deleted', TEMPLATE_DOMAIN) . "</h4>"; print "<meta http-equiv=\"refresh\" content=\"1;url={$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php&#tab2\">"; exit; } if (isset($_POST["delete_normal_upload2"])) { unlink("{$upload_path}/{$normal_image_name}"); echo "<h5 id='file-delete'>" . __('File successfully deleted', TEMPLATE_DOMAIN) . "</h4>"; print "<meta http-equiv=\"refresh\" content=\"1;url={$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php&#tab2\">"; exit; } ?> <?php //Display error message if there are any if (strlen($error) > 0) { echo "<p class=\"uperror\"><strong>" . __("Error!", TEMPLATE_DOMAIN) . " </strong>" . $error . "</p>"; } if (strlen($large_photo_exists) > 0 && strlen($thumb_photo_exists) > 0) { ?> <img src="<?php echo "{$upload_url}/{$thumb_image_name}"; ?> " class="timg"/><br /><br /> <form id="form-del" name="thumbnail" action="" method="post"> <div class="submit"><input type="submit" name="delete_thumbnail2" class="sbutton button-secondary" value="<?php _e("Delete This Image", TEMPLATE_DOMAIN); ?> " /></div> </form> <?php } else { if (strlen($normal_photo_exists) > 0) { ?> <img src="<?php echo "{$upload_url}/{$normal_image_name}"; ?> " class="timg"/><br /><br /> <form id="form-del" name="thumbnail" action="" method="post"> <input type="submit" name="delete_normal_upload2" class="button-secondary" value="<?php _e("Delete This Image", TEMPLATE_DOMAIN); ?> " /> </form> <?php } } ?> <?php if (strlen($large_photo_exists) > 0 && strlen($thumb_photo_exists) > 0) { } else { if (strlen($large_photo_exists) > 0) { ?> <h3><?php _e('Crop And Save Your Thumbnail', TEMPLATE_DOMAIN); ?> </h3> <div> <img src="<?php echo "{$upload_url}/{$large_image_name}"; ?> " style="clear: both; margin-bottom: 10px;" id="thumbnail" alt="Create Thumbnail" /> <br style="clear:both;"/> <form name="thumbnail" action="" method="post"> <input type="hidden" name="x1" value="" id="x1" /> <input type="hidden" name="y1" value="" id="y1" /> <input type="hidden" name="x2" value="" id="x2" /> <input type="hidden" name="y2" value="" id="y2" /> <input type="hidden" name="w" value="" id="w" /> <input type="hidden" name="h" value="" id="h" /> <div class="submit"><input type="submit" class="sbutton button-secondary" name="upload_thumbnail2" value="<?php _e("Save Thumbnail", TEMPLATE_DOMAIN); ?> " id="save_thumb" /></div> </form> </div> <?php } } ?> <?php if (strlen($large_photo_exists) == 0 && strlen($normal_photo_exists) == 0) { ?> <h3><?php _e("Upload Image", TEMPLATE_DOMAIN); ?> <?php echo $thumb_width . ' X ' . $thumb_height; ?> </h3> <form name="photo" enctype="multipart/form-data" action="<?php echo admin_url('themes.php?page=custom-homepage.php&#tab2'); ?> " method="post"> <input type="file" class="ups" name="image" /> <input type="submit" class="button-secondary" name="upload2" value="Upload and crop »" /> <input type="submit" class="button-secondary" name="normal_upload2" value="Upload »" /> <p class="onlyjpg">* only <?php echo $image_ext; ?> image file are allowed</p> </form> <?php } ?> <br /> <form method="post"> <?php foreach ($options5 as $value) { ?> <?php switch ($value['type']) { case 'text': ?> <div class="description"><?php echo $value['name']; ?> </div> <p><input name="<?php echo $value['id']; ?> " class="myfield" id="<?php echo $value['id']; ?> " type="<?php echo $value['type']; ?> " value="<?php if (get_option($value['id']) != "") { echo get_option($value['id']); } else { echo $value['std']; } ?> " /> </p> <?php break; case 'textarea': ?> <?php $valuex = $value['id']; $valuey = stripslashes($valuex); $video_code = get_option($valuey); ?> <div class="description"><?php echo $value['name']; ?> </div> <p><textarea name="<?php echo $valuey; ?> " class="mytext" cols="40%" rows="8" /><?php if (get_option($valuey) != "") { echo stripslashes($video_code); } else { echo $value['std']; } ?> </textarea></p> <?php break; default: ?> <?php break; } ?> <?php } ?> <p class="submit"> <input name="save" type="submit" class="sbutton button-primary" value="<?php _e("Save setting", TEMPLATE_DOMAIN); ?> " /> <input type="hidden" name="action" value="save5" /> </p> </form> <form method="post"> <p class="submit"> <input name="reset" type="submit" class="sbutton button-primary" value="<?php _e("Reset setting", TEMPLATE_DOMAIN); ?> " /> <input type="hidden" name="action" value="reset5" /> </p> </form> </div> </div> </div> </div><!-- end tabc --> <?php echo "<div id='tab3' class='tabc'>"; $normal_image_name = $image_prefix_name . '3_normal.jpg'; // New name of the large image $large_image_name = $image_prefix_name . '3.jpg'; // New name of the large image $thumb_image_name = $image_prefix_name . '3_thumb.jpg'; // New name of the thumbnail image $max_file = "1000000"; // Approx below 1MB $max_width = "850"; // Max width allowed for the large image $thumb_width = "260"; // Width of thumbnail image $thumb_height = "150"; // Height of thumbnail image //Image Locations $normal_image_location = $upload_path . $normal_image_name; $large_image_location = $upload_path . $large_image_name; $thumb_image_location = $upload_path . $thumb_image_name; //Check to see if any images with the same names already exist if (file_exists($large_image_location)) { if (file_exists($thumb_image_location)) { $thumb_photo_exists = "<img src=\"" . $upload_path . $thumb_image_name . "\" alt=\"Thumbnail Image\"/>"; } else { $thumb_photo_exists = ""; } $large_photo_exists = "<img src=\"" . $upload_path . $large_image_name . "\" alt=\"Large Image\"/>"; } else { $large_photo_exists = ""; $thumb_photo_exists = ""; } //Check normal image if (file_exists($normal_image_location)) { $normal_photo_exists = "<img src=\"" . $upload_path . $normal_image_name . "\" alt=\"Large Image\"/>"; } else { $normal_photo_exists = ""; } ?> <div class="admin-options"> <?php global $themename, $shortname, $options6; if ($_REQUEST['saved6']) { echo '<div id="message" class="updated fade"><p><strong>' . $themename . __(' Featured image 3 Settings saved.', TEMPLATE_DOMAIN) . '</strong></p></div>'; } if ($_REQUEST['reset6']) { echo '<div id="message" class="updated fade"><p><strong>' . $themename . __(' Featured image 3 Settings reset.', TEMPLATE_DOMAIN) . '</strong></p></div>'; } ?> <h4><?php _e("Featured image 3 Setting", TEMPLATE_DOMAIN); ?> </h4> <div class="tab-option"> <div class="option-save"> <?php if (isset($_POST['upload3'])) { //Get the file information $userfile_name = $_FILES['image']['name']; $userfile_tmp = $_FILES['image']['tmp_name']; $userfile_type = $_FILES['image']['type']; $userfile_size = $_FILES['image']['size']; $filename = basename($_FILES['image']['name']); $file_ext = substr($filename, strrpos($filename, '.') + 1); //Only process if the file is a JPG, PNG or GIF and below the allowed limit if (!empty($_FILES["image"]) && $_FILES['image']['error'] == 0) { foreach ($allowed_image_types as $mime_type => $ext) { //loop through the specified image types and if they match the extension then break out //everything is ok so go and check file size if ($file_ext == $ext && $userfile_type == $mime_type) { $error = ""; break; } else { $error = __("Only", TEMPLATE_DOMAIN) . " <strong>" . $image_ext . "</strong>" . __(" images accepted for upload", TEMPLATE_DOMAIN) . "<br />"; } } //check if the file size is above the allowed limit if ($userfile_size > $max_file) { $error .= __("Images must be under 1 MB in size", TEMPLATE_DOMAIN); } } else { $error = __("Select an image for upload", TEMPLATE_DOMAIN); } //Everything is ok, so we can upload the image. if (strlen($error) == 0) { if (isset($_FILES['image']['name'])) { move_uploaded_file($userfile_tmp, $large_image_location); chmod($large_image_location, 0777); $width = getWidth($large_image_location); $height = getHeight($large_image_location); //Scale the image if it is greater than the width set above if ($width > $max_width) { $scale = $max_width / $width; $uploaded = resizeImage($large_image_location, $width, $height, $scale); } else { $scale = 1; $uploaded = resizeImage($large_image_location, $width, $height, $scale); } //Delete the thumbnail file so the user can create a new one if (file_exists($thumb_image_location)) { unlink($thumb_image_location); } } //Refresh the page to show the new uploaded image print '<meta http-equiv="Pragma" content="no-cache">'; echo "<h4 id=\"loading-bar\">Please wait..Your Image Currently Processing</h4>"; echo '<img src="' . get_template_directory_uri() . '/_inc/admin/loading_bar.gif' . '">'; print "<meta http-equiv=\"refresh\" content=\"5;url={$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php&#tab3\">"; exit; //double refresh to clear cache..its a bit catchy but it get the job done } } //normal upload if (isset($_POST["normal_upload3"])) { //Get the file information $userfile_name = $_FILES['image']['name']; $userfile_tmp = $_FILES['image']['tmp_name']; $userfile_type = $_FILES['image']['type']; $userfile_size = $_FILES['image']['size']; $filename = basename($_FILES['image']['name']); $file_ext = substr($filename, strrpos($filename, '.') + 1); //Only process if the file is a JPG and below the allowed limit if (!empty($_FILES["image"]) && $_FILES['image']['error'] == 0) { foreach ($allowed_image_types as $mime_type => $ext) { //loop through the specified image types and if they match the extension then break out //everything is ok so go and check file size if ($file_ext == $ext && $userfile_type == $mime_type) { $error = ""; break; } else { $error = __("Only", TEMPLATE_DOMAIN) . "<strong>" . $image_ext . "</strong>" . __("images accepted for upload", TEMPLATE_DOMAIN) . "<br />"; } } if ($userfile_size > $max_file) { $error = __("ONLY images under 1MB are accepted for upload", TEMPLATE_DOMAIN); } } else { $error = __("Select an image for upload", TEMPLATE_DOMAIN); } //Everything is ok, so we can upload the image. if (strlen($error) == 0) { if (isset($_FILES['image']['name'])) { move_uploaded_file($userfile_tmp, $normal_image_location); chmod($normal_image_location, 0777); //Delete the thumbnail file so the user can create a new one if (file_exists($thumb_image_location)) { unlink($thumb_image_location); } } //Refresh the page to show the new uploaded image print '<meta http-equiv="Pragma" content="no-cache">'; echo "<h4 id=\"loading-bar\">Please wait..Your Image Currently Processing</h4>"; echo '<img src="' . get_template_directory_uri() . '/_inc/admin/loading_bar.gif' . '">'; print "<meta http-equiv=\"refresh\" content=\"5;url={$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php&#tab3\">"; exit; //double refresh to clear cache..its a bit catchy but it get the job done } } if (isset($_POST['upload_thumbnail3']) && strlen($large_photo_exists) > 0) { //Get the new coordinates to crop the image. $x1 = $_POST["x1"]; $y1 = $_POST["y1"]; $x2 = $_POST["x2"]; $y2 = $_POST["y2"]; $w = $_POST["w"]; $h = $_POST["h"]; //Scale the image to the thumb_width set above $scale = $thumb_width / $w; $cropped = resizeThumbnailImage($thumb_image_location, $large_image_location, $w, $h, $x1, $y1, $scale); //Reload the page again to view the thumbnail //Refresh the page to show the new uploaded image print '<meta http-equiv="Pragma" content="no-cache">'; echo "<h4 id=\"loading-bar\">Please wait..Your Image Currently Processing</h4>"; echo '<img src="' . get_template_directory_uri() . '/_inc/admin/loading_bar.gif' . '">'; print "<meta http-equiv=\"refresh\" content=\"5;url={$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php&#tab3\">"; exit; //double refresh to clear cache..its a bit catchy but it get the job done } ?> <?php //Only display the javacript if an image has been uploaded if (strlen($large_photo_exists) > 0) { $current_large_image_width = getWidth($large_image_location); $current_large_image_height = getHeight($large_image_location); ?> <script type="text/javascript"> function preview(img, selection) { var scaleX = <?php echo $thumb_width; ?> / selection.width; var scaleY = <?php echo $thumb_height; ?> / selection.height; $('#thumbnail + div > img').css({ width: Math.round(scaleX * <?php echo $current_large_image_width; ?> ) + 'px', height: Math.round(scaleY * <?php echo $current_large_image_height; ?> ) + 'px', marginLeft: '-' + Math.round(scaleX * selection.x1) + 'px', marginTop: '-' + Math.round(scaleY * selection.y1) + 'px' }); $('#x1').val(selection.x1); $('#y1').val(selection.y1); $('#x2').val(selection.x2); $('#y2').val(selection.y2); $('#w').val(selection.width); $('#h').val(selection.height); } $(document).ready(function () { $('#save_thumb').click(function() { var x1 = $('#x1').val(); var y1 = $('#y1').val(); var x2 = $('#x2').val(); var y2 = $('#y2').val(); var w = $('#w').val(); var h = $('#h').val(); if(x1=="" || y1=="" || x2=="" || y2=="" || w=="" || h==""){ alert("You must make a selection first"); return false; } else { return true; } }); }); function selectionStart(img, selection) { width:260;height:150 } $(window).load(function () { $('#thumbnail').imgAreaSelect({ onSelectStart: selectionStart, resizable: true, x1: 20, y1: 20, x2: 280, y2: 170, aspectRatio: '28:17', onSelectChange: preview }); }); </script> <?php } ?> <?php if (isset($_POST['delete_thumbnail3'])) { unlink($upload_path . $large_image_name); unlink($upload_path . $thumb_image_name); echo "<h5 id='file-delete'>" . __('File successfully deleted', TEMPLATE_DOMAIN) . "</h4>"; print "<meta http-equiv=\"refresh\" content=\"1;url={$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php&#tab3\">"; exit; } if (isset($_POST["delete_normal_upload3"])) { unlink("{$upload_path}/{$normal_image_name}"); echo "<h5 id='file-delete'>" . __('File successfully deleted', TEMPLATE_DOMAIN) . "</h4>"; print "<meta http-equiv=\"refresh\" content=\"1;url={$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php&#tab3\">"; exit; } ?> <?php //Display error message if there are any if (strlen($error) > 0) { echo "<p class=\"uperror\"><strong>" . __("Error!", TEMPLATE_DOMAIN) . " </strong>" . $error . "</p>"; } if (strlen($large_photo_exists) > 0 && strlen($thumb_photo_exists) > 0) { ?> <img src="<?php echo "{$upload_url}/{$thumb_image_name}"; ?> " class="timg"/><br /><br /> <form id="form-del" name="thumbnail" action="" method="post"> <div class="submit"><input type="submit" name="delete_thumbnail3" class="sbutton button-secondary" value="<?php _e("Delete This Image", TEMPLATE_DOMAIN); ?> " /></div> </form> <?php } else { if (strlen($normal_photo_exists) > 0) { ?> <img src="<?php echo "{$upload_url}/{$normal_image_name}"; ?> " class="timg"/><br /><br /> <form id="form-del" name="thumbnail" action="" method="post"> <input type="submit" name="delete_normal_upload3" class="button-secondary" value="Delete This Image" /> </form> <?php } } ?> <?php if (strlen($large_photo_exists) > 0 && strlen($thumb_photo_exists) > 0) { } else { if (strlen($large_photo_exists) > 0) { ?> <h3><?php _e('Crop And Save Your Thumbnail', TEMPLATE_DOMAIN); ?> </h3> <div> <img src="<?php echo "{$upload_url}/{$large_image_name}"; ?> " style="clear: both; margin-bottom: 10px;" id="thumbnail" alt="Create Thumbnail" /> <br style="clear:both;"/> <form name="thumbnail" action="" method="post"> <input type="hidden" name="x1" value="" id="x1" /> <input type="hidden" name="y1" value="" id="y1" /> <input type="hidden" name="x2" value="" id="x2" /> <input type="hidden" name="y2" value="" id="y2" /> <input type="hidden" name="w" value="" id="w" /> <input type="hidden" name="h" value="" id="h" /> <input type="submit" name="upload_thumbnail3" class="button-secondary" value="Save Thumbnail" id="save_thumb" /> </form> </div> <?php } } ?> <?php if (strlen($large_photo_exists) == 0 && strlen($normal_photo_exists) == 0) { ?> <h3><?php _e("Upload Image", TEMPLATE_DOMAIN); ?> <?php echo $thumb_width . ' X ' . $thumb_height; ?> </h3> <form name="photo" enctype="multipart/form-data" action="<?php echo admin_url('themes.php?page=custom-homepage.php&#tab3'); ?> " method="post"> <input type="file" class="ups" name="image" /> <input type="submit" class="button-secondary" name="upload3" value="Upload and crop »" /> <input type="submit" class="button-secondary" name="normal_upload3" value="Upload »" /> <p class="onlyjpg">* only <?php echo $image_ext; ?> image file are allowed</p> </form> <?php } ?> <br /> <form method="post"> <?php foreach ($options6 as $value) { ?> <?php switch ($value['type']) { case 'text': ?> <div class="description"><?php echo $value['name']; ?> </div> <p><input name="<?php echo $value['id']; ?> " class="myfield" id="<?php echo $value['id']; ?> " type="<?php echo $value['type']; ?> " value="<?php if (get_option($value['id']) != "") { echo get_option($value['id']); } else { echo $value['std']; } ?> " /> </p> <?php break; case 'textarea': ?> <?php $valuex = $value['id']; $valuey = stripslashes($valuex); $video_code = get_option($valuey); ?> <div class="description"><?php echo $value['name']; ?> </div> <p><textarea name="<?php echo $valuey; ?> " class="mytext" cols="40%" rows="8" /><?php if (get_option($valuey) != "") { echo stripslashes($video_code); } else { echo $value['std']; } ?> </textarea></p> <?php break; default: ?> <?php break; } ?> <?php } ?> <p class="submit"> <input name="save" type="submit" class="sbutton button-primary" value="<?php _e("Save setting", TEMPLATE_DOMAIN); ?> " /> <input type="hidden" name="action" value="save6" /> </p> </form> <form method="post"> <p class="submit"> <input name="reset" type="submit" class="sbutton button-primary" value="<?php _e("Reset setting", TEMPLATE_DOMAIN); ?> " /> <input type="hidden" name="action" value="reset6" /> </p> </form> </div> </div> </div> </div><!-- end tabc --> <?php echo "<div id='tab4' class='tabc'>"; $normal_image_name = $image_prefix_name . '4_normal.jpg'; // New name of the normal image $large_image_name = $image_prefix_name . '4.jpg'; // New name of the large image $thumb_image_name = $image_prefix_name . '4_thumb.jpg'; // New name of the thumbnail image $max_file = "1000000"; // Approx below 1MB $max_width = "850"; // Max width allowed for the large image $thumb_width = "260"; // Width of thumbnail image $thumb_height = "150"; // Height of thumbnail image //Image Locations $normal_image_location = $upload_path . $normal_image_name; $large_image_location = $upload_path . $large_image_name; $thumb_image_location = $upload_path . $thumb_image_name; //Check to see if any images with the same names already exist if (file_exists($large_image_location)) { if (file_exists($thumb_image_location)) { $thumb_photo_exists = "<img src=\"" . $upload_path . $thumb_image_name . "\" alt=\"Thumbnail Image\"/>"; } else { $thumb_photo_exists = ""; } $large_photo_exists = "<img src=\"" . $upload_path . $large_image_name . "\" alt=\"Large Image\"/>"; } else { $large_photo_exists = ""; $thumb_photo_exists = ""; } //Check normal image if (file_exists($normal_image_location)) { $normal_photo_exists = "<img src=\"" . $upload_path . $normal_image_name . "\" alt=\"Large Image\"/>"; } else { $normal_photo_exists = ""; } ?> <div class="admin-options"> <?php global $themename, $shortname, $options7; if ($_REQUEST['saved7']) { echo '<div id="message" class="info"><p><strong>' . $themename . __(' Slider 4 Settings saved.', TEMPLATE_DOMAIN) . '</strong></p></div>'; } if ($_REQUEST['reset7']) { echo '<div id="message" class="info"><p><strong>' . $themename . __(' Slider 4 Settings reset.', TEMPLATE_DOMAIN) . '</strong></p></div>'; } ?> <h4><?php _e("Featured image 4 Setting", TEMPLATE_DOMAIN); ?> </h4> <div class="tab-option"> <div class="option-save"> <?php if (isset($_POST['upload4'])) { //Get the file information $userfile_name = $_FILES['image']['name']; $userfile_tmp = $_FILES['image']['tmp_name']; $userfile_type = $_FILES['image']['type']; $userfile_size = $_FILES['image']['size']; $filename = basename($_FILES['image']['name']); $file_ext = substr($filename, strrpos($filename, '.') + 1); //Only process if the file is a JPG, PNG or GIF and below the allowed limit if (!empty($_FILES["image"]) && $_FILES['image']['error'] == 0) { foreach ($allowed_image_types as $mime_type => $ext) { //loop through the specified image types and if they match the extension then break out //everything is ok so go and check file size if ($file_ext == $ext && $userfile_type == $mime_type) { $error = ""; break; } else { $error = __("Only", TEMPLATE_DOMAIN) . " <strong>" . $image_ext . "</strong>" . __(" images accepted for upload", TEMPLATE_DOMAIN) . "<br />"; } } //check if the file size is above the allowed limit if ($userfile_size > $max_file) { $error .= __("Images must be under 1 MB in size", TEMPLATE_DOMAIN); } } else { $error = __("Select an image for upload", TEMPLATE_DOMAIN); } //Everything is ok, so we can upload the image. if (strlen($error) == 0) { if (isset($_FILES['image']['name'])) { move_uploaded_file($userfile_tmp, $large_image_location); chmod($large_image_location, 0777); $width = getWidth($large_image_location); $height = getHeight($large_image_location); //Scale the image if it is greater than the width set above if ($width > $max_width) { $scale = $max_width / $width; $uploaded = resizeImage($large_image_location, $width, $height, $scale); } else { $scale = 1; $uploaded = resizeImage($large_image_location, $width, $height, $scale); } //Delete the thumbnail file so the user can create a new one if (file_exists($thumb_image_location)) { unlink($thumb_image_location); } } //Refresh the page to show the new uploaded image print '<meta http-equiv="Pragma" content="no-cache">'; echo "<h4 id=\"loading-bar\">Please wait..Your Image Currently Processing</h4>"; echo '<img src="' . get_template_directory_uri() . '/_inc/admin/loading_bar.gif' . '">'; print "<meta http-equiv=\"refresh\" content=\"5;url={$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php&#tab4\">"; exit; //double refresh to clear cache..its a bit catchy but it get the job done } } if (isset($_POST["normal_upload4"])) { //Get the file information $userfile_name = $_FILES['image']['name']; $userfile_tmp = $_FILES['image']['tmp_name']; $userfile_type = $_FILES['image']['type']; $userfile_size = $_FILES['image']['size']; $filename = basename($_FILES['image']['name']); $file_ext = substr($filename, strrpos($filename, '.') + 1); //Only process if the file is a JPG and below the allowed limit if (!empty($_FILES["image"]) && $_FILES['image']['error'] == 0) { foreach ($allowed_image_types as $mime_type => $ext) { //loop through the specified image types and if they match the extension then break out //everything is ok so go and check file size if ($file_ext == $ext && $userfile_type == $mime_type) { $error = ""; break; } else { $error = __("Only", TEMPLATE_DOMAIN) . "<strong>" . $image_ext . "</strong>" . __("images accepted for upload", TEMPLATE_DOMAIN) . "<br />"; } } if ($userfile_size > $max_file) { $error = __("ONLY images under 1MB are accepted for upload", TEMPLATE_DOMAIN); } } else { $error = __("Select an image for upload", TEMPLATE_DOMAIN); } //Everything is ok, so we can upload the image. if (strlen($error) == 0) { if (isset($_FILES['image']['name'])) { move_uploaded_file($userfile_tmp, $normal_image_location); chmod($normal_image_location, 0777); //Delete the thumbnail file so the user can create a new one if (file_exists($thumb_image_location)) { unlink($thumb_image_location); } } //Refresh the page to show the new uploaded image print '<meta http-equiv="Pragma" content="no-cache">'; echo "<h4 id=\"loading-bar\">Please wait..Your Image Currently Processing</h4>"; echo '<img src="' . get_template_directory_uri() . '/_inc/admin/loading_bar.gif' . '">'; print "<meta http-equiv=\"refresh\" content=\"5;url={$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php&#tab4\">"; exit; //double refresh to clear cache..its a bit catchy but it get the job done } } if (isset($_POST['upload_thumbnail4']) && strlen($large_photo_exists) > 0) { //Get the new coordinates to crop the image. $x1 = $_POST["x1"]; $y1 = $_POST["y1"]; $x2 = $_POST["x2"]; $y2 = $_POST["y2"]; $w = $_POST["w"]; $h = $_POST["h"]; //Scale the image to the thumb_width set above $scale = $thumb_width / $w; $cropped = resizeThumbnailImage($thumb_image_location, $large_image_location, $w, $h, $x1, $y1, $scale); //Refresh the page to show the new uploaded image print '<meta http-equiv="Pragma" content="no-cache">'; echo "<h4 id=\"loading-bar\">Please wait..Your Image Currently Processing</h4>"; echo '<img src="' . get_template_directory_uri() . '/_inc/admin/loading_bar.gif' . '">'; print "<meta http-equiv=\"refresh\" content=\"5;url={$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php&#tab4\">"; exit; //double refresh to clear cache..its a bit catchy but it get the job done } ?> <?php //Only display the javacript if an image has been uploaded if (strlen($large_photo_exists) > 0) { $current_large_image_width = getWidth($large_image_location); $current_large_image_height = getHeight($large_image_location); ?> <script type="text/javascript"> function preview(img, selection) { var scaleX = <?php echo $thumb_width; ?> / selection.width; var scaleY = <?php echo $thumb_height; ?> / selection.height; $('#thumbnail + div > img').css({ width: Math.round(scaleX * <?php echo $current_large_image_width; ?> ) + 'px', height: Math.round(scaleY * <?php echo $current_large_image_height; ?> ) + 'px', marginLeft: '-' + Math.round(scaleX * selection.x1) + 'px', marginTop: '-' + Math.round(scaleY * selection.y1) + 'px' }); $('#x1').val(selection.x1); $('#y1').val(selection.y1); $('#x2').val(selection.x2); $('#y2').val(selection.y2); $('#w').val(selection.width); $('#h').val(selection.height); } $(document).ready(function () { $('#save_thumb').click(function() { var x1 = $('#x1').val(); var y1 = $('#y1').val(); var x2 = $('#x2').val(); var y2 = $('#y2').val(); var w = $('#w').val(); var h = $('#h').val(); if(x1=="" || y1=="" || x2=="" || y2=="" || w=="" || h==""){ alert("You must make a selection first"); return false; } else { return true; } }); }); function selectionStart(img, selection) { width:260;height:150 } $(window).load(function () { $('#thumbnail').imgAreaSelect({ onSelectStart: selectionStart, resizable: true, x1: 20, y1: 20, x2: 280, y2: 170, aspectRatio: '28:17', onSelectChange: preview }); }); </script> <?php } ?> <?php if (isset($_POST['delete_thumbnail4'])) { unlink($upload_path . $large_image_name); unlink($upload_path . $thumb_image_name); echo "<h5 id='file-delete'>" . __('File successfully deleted', TEMPLATE_DOMAIN) . "</h4>"; print "<meta http-equiv=\"refresh\" content=\"1;url={$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php&#tab4\">"; exit; } if (isset($_POST["delete_normal_upload4"])) { unlink("{$upload_path}/{$normal_image_name}"); echo "<h5 id='file-delete'>" . __('File successfully deleted', TEMPLATE_DOMAIN) . "</h4>"; print "<meta http-equiv=\"refresh\" content=\"1;url={$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php&#tab4\">"; exit; } ?> <?php //Display error message if there are any if (strlen($error) > 0) { echo "<p class=\"uperror\"><strong>" . __("Error!", TEMPLATE_DOMAIN) . " </strong>" . $error . "</p>"; } if (strlen($large_photo_exists) > 0 && strlen($thumb_photo_exists) > 0) { ?> <img src="<?php echo "{$upload_url}/{$thumb_image_name}"; ?> " class="timg"/><br /><br /> <form id="form-del" name="thumbnail" action="" method="post"> <div class="submit"><input type="submit" name="delete_thumbnail4" class="sbutton button-secondary" value="<?php _e("Delete This Image", TEMPLATE_DOMAIN); ?> " /></div> </form> <?php } else { if (strlen($normal_photo_exists) > 0) { ?> <img src="<?php echo "{$upload_url}/{$normal_image_name}"; ?> " class="timg"/><br /><br /> <form id="form-del" name="thumbnail" action="" method="post"> <input type="submit" name="delete_normal_upload4" class="button-secondary" value="Delete This Image" /> </form> <?php } } ?> <?php if (strlen($large_photo_exists) > 0 && strlen($thumb_photo_exists) > 0) { } else { if (strlen($large_photo_exists) > 0) { ?> <h3><?php _e('Crop And Save Your Thumbnail', TEMPLATE_DOMAIN); ?> </h3> <div> <img src="<?php echo "{$upload_url}/{$large_image_name}"; ?> " style="clear: both; margin-bottom: 10px;" id="thumbnail" alt="Create Thumbnail" /> <br style="clear:both;"/> <form name="thumbnail" action="" method="post"> <input type="hidden" name="x1" value="" id="x1" /> <input type="hidden" name="y1" value="" id="y1" /> <input type="hidden" name="x2" value="" id="x2" /> <input type="hidden" name="y2" value="" id="y2" /> <input type="hidden" name="w" value="" id="w" /> <input type="hidden" name="h" value="" id="h" /> <input type="submit" name="upload_thumbnail4" class="button-secondary" value="Save Thumbnail" id="save_thumb" /> </form> </div> <?php } } ?> <?php if (strlen($large_photo_exists) == 0 && strlen($normal_photo_exists) == 0) { ?> <h3><?php _e("Upload Image", TEMPLATE_DOMAIN); ?> <?php echo $thumb_width . ' X ' . $thumb_height; ?> </h3> <form name="photo" enctype="multipart/form-data" action="<?php echo admin_url('themes.php?page=custom-homepage.php&#tab4'); ?> " method="post"> <input type="file" class="ups" name="image" /> <input type="submit" class="button-secondary" name="upload4" value="Upload and crop »" /> <input type="submit" class="button-secondary" name="normal_upload4" value="Upload »" /> <p class="onlyjpg">* only <?php echo $image_ext; ?> image file are allowed</p> </form> <?php } ?> <br /> <form method="post"> <?php foreach ($options7 as $value) { ?> <?php switch ($value['type']) { case 'text': ?> <div class="description"><?php echo $value['name']; ?> </div> <p><input name="<?php echo $value['id']; ?> " class="myfield" id="<?php echo $value['id']; ?> " type="<?php echo $value['type']; ?> " value="<?php if (get_option($value['id']) != "") { echo get_option($value['id']); } else { echo $value['std']; } ?> " /> </p> <?php break; case 'textarea': ?> <?php $valuex = $value['id']; $valuey = stripslashes($valuex); $video_code = get_option($valuey); ?> <div class="description"><?php echo $value['name']; ?> </div> <p><textarea name="<?php echo $valuey; ?> " class="mytext" cols="40%" rows="8" /><?php if (get_option($valuey) != "") { echo stripslashes($video_code); } else { echo $value['std']; } ?> </textarea></p> <?php break; default: ?> <?php break; } ?> <?php } ?> <p class="submit"> <input name="save" type="submit" class="sbutton button-primary" value="<?php _e("Save setting", TEMPLATE_DOMAIN); ?> " /> <input type="hidden" name="action" value="save7" /> </p> </form> <form method="post"> <p class="submit"> <input name="reset" type="submit" class="sbutton button-primary" value="<?php _e("Reset setting", TEMPLATE_DOMAIN); ?> " /> <input type="hidden" name="action" value="reset7" /> </p> </form> </div> </div> </div> </div><!-- end tabc --> <?php echo "<div id='tab5' class='tabc'>"; $normal_image_name = $image_prefix_name . '5_normal.jpg'; // New name of the large image $large_image_name = $image_prefix_name . '5.jpg'; // New name of the large image $thumb_image_name = $image_prefix_name . '5_thumb.jpg'; // New name of the thumbnail image $max_file = "1000000"; // Approx below 1MB $max_width = "850"; // Max width allowed for the large image $thumb_width = "260"; // Width of thumbnail image $thumb_height = "150"; // Height of thumbnail image //Image Locations $normal_image_location = $upload_path . $normal_image_name; $large_image_location = $upload_path . $large_image_name; $thumb_image_location = $upload_path . $thumb_image_name; //Check to see if any images with the same names already exist if (file_exists($large_image_location)) { if (file_exists($thumb_image_location)) { $thumb_photo_exists = "<img src=\"" . $upload_path . $thumb_image_name . "\" alt=\"Thumbnail Image\"/>"; } else { $thumb_photo_exists = ""; } $large_photo_exists = "<img src=\"" . $upload_path . $large_image_name . "\" alt=\"Large Image\"/>"; } else { $large_photo_exists = ""; $thumb_photo_exists = ""; } ?> <div class="admin-options"> <?php global $themename, $shortname, $options8; if ($_REQUEST['saved8']) { echo '<div id="message" class="updated fade"><p><strong>' . $themename . __(' Featured image 5 Settings saved.', TEMPLATE_DOMAIN) . '</strong></p></div>'; } if ($_REQUEST['reset8']) { echo '<div id="message" class="updated fade"><p><strong>' . $themename . __(' Featured image 5 Settings reset.', TEMPLATE_DOMAIN) . '</strong></p></div>'; } ?> <h4><?php _e("Featured image 5 Setting", TEMPLATE_DOMAIN); ?> </h4> <div class="tab-option"> <div class="option-save"> <?php if (isset($_POST['upload5'])) { //Get the file information $userfile_name = $_FILES['image']['name']; $userfile_tmp = $_FILES['image']['tmp_name']; $userfile_type = $_FILES['image']['type']; $userfile_size = $_FILES['image']['size']; $filename = basename($_FILES['image']['name']); $file_ext = substr($filename, strrpos($filename, '.') + 1); //Only process if the file is a JPG, PNG or GIF and below the allowed limit if (!empty($_FILES["image"]) && $_FILES['image']['error'] == 0) { foreach ($allowed_image_types as $mime_type => $ext) { //loop through the specified image types and if they match the extension then break out //everything is ok so go and check file size if ($file_ext == $ext && $userfile_type == $mime_type) { $error = ""; break; } else { $error = __("Only", TEMPLATE_DOMAIN) . " <strong>" . $image_ext . "</strong>" . __(" images accepted for upload", TEMPLATE_DOMAIN) . "<br />"; } } //check if the file size is above the allowed limit if ($userfile_size > $max_file) { $error .= __("Images must be under 1 MB in size", TEMPLATE_DOMAIN); } } else { $error = __("Select an image for upload", TEMPLATE_DOMAIN); } //Everything is ok, so we can upload the image. if (strlen($error) == 0) { if (isset($_FILES['image']['name'])) { move_uploaded_file($userfile_tmp, $large_image_location); chmod($large_image_location, 0777); $width = getWidth($large_image_location); $height = getHeight($large_image_location); //Scale the image if it is greater than the width set above if ($width > $max_width) { $scale = $max_width / $width; $uploaded = resizeImage($large_image_location, $width, $height, $scale); } else { $scale = 1; $uploaded = resizeImage($large_image_location, $width, $height, $scale); } //Delete the thumbnail file so the user can create a new one if (file_exists($thumb_image_location)) { unlink($thumb_image_location); } } //Refresh the page to show the new uploaded image print '<meta http-equiv="Pragma" content="no-cache">'; echo "<h4 id=\"loading-bar\">Please wait..Your Image Currently Processing</h4>"; echo '<img src="' . get_template_directory_uri() . '/_inc/admin/loading_bar.gif' . '">'; print "<meta http-equiv=\"refresh\" content=\"5;url={$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php&#tab5\">"; exit; //double refresh to clear cache..its a bit catchy but it get the job done } } // normal upload if (isset($_POST["normal_upload5"])) { //Get the file information $userfile_name = $_FILES['image']['name']; $userfile_tmp = $_FILES['image']['tmp_name']; $userfile_type = $_FILES['image']['type']; $userfile_size = $_FILES['image']['size']; $filename = basename($_FILES['image']['name']); $file_ext = substr($filename, strrpos($filename, '.') + 1); //Only process if the file is a JPG and below the allowed limit if (!empty($_FILES["image"]) && $_FILES['image']['error'] == 0) { foreach ($allowed_image_types as $mime_type => $ext) { //loop through the specified image types and if they match the extension then break out //everything is ok so go and check file size if ($file_ext == $ext && $userfile_type == $mime_type) { $error = ""; break; } else { $error = __("Only", TEMPLATE_DOMAIN) . "<strong>" . $image_ext . "</strong>" . __("images accepted for upload", TEMPLATE_DOMAIN) . "<br />"; } } if ($userfile_size > $max_file) { $error = __("ONLY images under 1MB are accepted for upload", TEMPLATE_DOMAIN); } } else { $error = __("Select an image for upload", TEMPLATE_DOMAIN); } //Everything is ok, so we can upload the image. if (strlen($error) == 0) { if (isset($_FILES['image']['name'])) { move_uploaded_file($userfile_tmp, $normal_image_location); chmod($normal_image_location, 0777); //Delete the thumbnail file so the user can create a new one if (file_exists($thumb_image_location)) { unlink($thumb_image_location); } } //Refresh the page to show the new uploaded image print '<meta http-equiv="Pragma" content="no-cache">'; echo "<h4 id=\"loading-bar\">Please wait..Your Image Currently Processing</h4>"; echo '<img src="' . get_template_directory_uri() . '/_inc/admin/loading_bar.gif' . '">'; print "<meta http-equiv=\"refresh\" content=\"5;url={$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php&#tab5\">"; exit; //double refresh to clear cache..its a bit catchy but it get the job done } } if (isset($_POST['upload_thumbnail5']) && strlen($large_photo_exists) > 0) { //Get the new coordinates to crop the image. $x1 = $_POST["x1"]; $y1 = $_POST["y1"]; $x2 = $_POST["x2"]; $y2 = $_POST["y2"]; $w = $_POST["w"]; $h = $_POST["h"]; //Scale the image to the thumb_width set above $scale = $thumb_width / $w; $cropped = resizeThumbnailImage($thumb_image_location, $large_image_location, $w, $h, $x1, $y1, $scale); //Refresh the page to show the new uploaded image print '<meta http-equiv="Pragma" content="no-cache">'; echo "<h4 id=\"loading-bar\">Please wait..Your Image Currently Processing</h4>"; echo '<img src="' . get_template_directory_uri() . '/_inc/admin/loading_bar.gif' . '">'; print "<meta http-equiv=\"refresh\" content=\"5;url={$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php&#tab5\">"; exit; //double refresh to clear cache..its a bit catchy but it get the job done } ?> <?php //Only display the javacript if an image has been uploaded if (strlen($large_photo_exists) > 0) { $current_large_image_width = getWidth($large_image_location); $current_large_image_height = getHeight($large_image_location); ?> <script type="text/javascript"> function preview(img, selection) { var scaleX = <?php echo $thumb_width; ?> / selection.width; var scaleY = <?php echo $thumb_height; ?> / selection.height; $('#thumbnail + div > img').css({ width: Math.round(scaleX * <?php echo $current_large_image_width; ?> ) + 'px', height: Math.round(scaleY * <?php echo $current_large_image_height; ?> ) + 'px', marginLeft: '-' + Math.round(scaleX * selection.x1) + 'px', marginTop: '-' + Math.round(scaleY * selection.y1) + 'px' }); $('#x1').val(selection.x1); $('#y1').val(selection.y1); $('#x2').val(selection.x2); $('#y2').val(selection.y2); $('#w').val(selection.width); $('#h').val(selection.height); } $(document).ready(function () { $('#save_thumb').click(function() { var x1 = $('#x1').val(); var y1 = $('#y1').val(); var x2 = $('#x2').val(); var y2 = $('#y2').val(); var w = $('#w').val(); var h = $('#h').val(); if(x1=="" || y1=="" || x2=="" || y2=="" || w=="" || h==""){ alert("You must make a selection first"); return false; } else { return true; } }); }); function selectionStart(img, selection) { width:260;height:150 } $(window).load(function () { $('#thumbnail').imgAreaSelect({ onSelectStart: selectionStart, resizable: true, x1: 20, y1: 20, x2: 280, y2: 170, aspectRatio: '28:17', onSelectChange: preview }); }); </script> <?php } ?> <?php if (isset($_POST['delete_thumbnail5'])) { unlink($upload_path . $large_image_name); unlink($upload_path . $thumb_image_name); echo "<h5 id='file-delete'>" . __('File successfully deleted', TEMPLATE_DOMAIN) . "</h4>"; print "<meta http-equiv=\"refresh\" content=\"1;url={$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php&#tab5\">"; exit; } if (isset($_POST["delete_normal_upload5"])) { unlink("{$upload_path}/{$normal_image_name}"); echo "<h5 id='file-delete'>" . __('File successfully deleted', TEMPLATE_DOMAIN) . "</h4>"; print "<meta http-equiv=\"refresh\" content=\"1;url={$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php&#tab5\">"; exit; } ?> <?php //Display error message if there are any if (strlen($error) > 0) { echo "<p class=\"uperror\"><strong>" . __("Error!", TEMPLATE_DOMAIN) . " </strong>" . $error . "</p>"; } if (strlen($large_photo_exists) > 0 && strlen($thumb_photo_exists) > 0) { ?> <img src="<?php echo "{$upload_url}/{$thumb_image_name}"; ?> " class="timg"/><br /><br /> <form id="form-del" name="thumbnail" action="" method="post"> <div class="submit"><input type="submit" name="delete_thumbnail5" class="sbutton button-secondary" value="<?php _e("Delete This Image", TEMPLATE_DOMAIN); ?> " /></div> </form> <?php } else { if (strlen($normal_photo_exists) > 0) { ?> <img src="<?php echo "{$upload_url}/{$normal_image_name}"; ?> " class="timg"/><br /><br /> <form id="form-del" name="thumbnail" action="" method="post"> <input type="submit" name="delete_normal_upload5" class="button-secondary" value="Delete This Image" /> </form> <?php } } ?> <?php if (strlen($large_photo_exists) > 0 && strlen($thumb_photo_exists) > 0) { } else { if (strlen($large_photo_exists) > 0) { ?> <h3><?php _e('Crop And Save Your Thumbnail', TEMPLATE_DOMAIN); ?> </h3> <div> <img src="<?php echo "{$upload_url}/{$large_image_name}"; ?> " style="clear: both; margin-bottom: 10px;" id="thumbnail" alt="Create Thumbnail" /> <br style="clear:both;"/> <form name="thumbnail" action="" method="post"> <input type="hidden" name="x1" value="" id="x1" /> <input type="hidden" name="y1" value="" id="y1" /> <input type="hidden" name="x2" value="" id="x2" /> <input type="hidden" name="y2" value="" id="y2" /> <input type="hidden" name="w" value="" id="w" /> <input type="hidden" name="h" value="" id="h" /> <input type="submit" name="upload_thumbnail5" class="button-secondary" value="Save Thumbnail" id="save_thumb" /> </form> </div> <?php } } ?> <?php if (strlen($large_photo_exists) == 0 && strlen($normal_photo_exists) == 0) { ?> <h3><?php _e("Upload Image", TEMPLATE_DOMAIN); ?> <?php echo $thumb_width . ' X ' . $thumb_height; ?> </h3> <form name="photo" enctype="multipart/form-data" action="<?php echo admin_url('themes.php?page=custom-homepage.php&#tab5'); ?> " method="post"> <input type="file" class="ups" name="image" /> <input type="submit" class="button-secondary" name="upload5" value="Upload and crop»" /> <input type="submit" class="button-secondary" name="normal_upload5" value="Upload »" /> <p class="onlyjpg">* only <?php echo $image_ext; ?> image file are allowed</p> </form> <?php } ?> <br /> <form method="post"> <?php foreach ($options8 as $value) { ?> <?php switch ($value['type']) { case 'text': ?> <div class="description"><?php echo $value['name']; ?> </div> <p><input name="<?php echo $value['id']; ?> " class="myfield" id="<?php echo $value['id']; ?> " type="<?php echo $value['type']; ?> " value="<?php if (get_option($value['id']) != "") { echo get_option($value['id']); } else { echo $value['std']; } ?> " /> </p> <?php break; case 'textarea': ?> <?php $valuex = $value['id']; $valuey = stripslashes($valuex); $video_code = get_option($valuey); ?> <div class="description"><?php echo $value['name']; ?> </div> <p><textarea name="<?php echo $valuey; ?> " class="mytext" cols="40%" rows="8" /><?php if (get_option($valuey) != "") { echo stripslashes($video_code); } else { echo $value['std']; } ?> </textarea></p> <?php break; default: ?> <?php break; } ?> <?php } ?> <p class="submit"> <input name="save" type="submit" class="sbutton button-primary" value="<?php _e("Save setting", TEMPLATE_DOMAIN); ?> " /> <input type="hidden" name="action" value="save8" /> </p> </form> <form method="post"> <p class="submit"> <input name="reset" type="submit" class="sbutton button-primary" value="<?php _e("Reset setting", TEMPLATE_DOMAIN); ?> " /> <input type="hidden" name="action" value="reset8" /> </p> </form> </div> </div> </div> </div><!-- end tabc --> <?php echo "<div id='tab6' class='tabc'>"; $normal_image_name = $image_prefix_name . '6_normal.jpg'; // New name of the large image $large_image_name = $image_prefix_name . '6.jpg'; // New name of the large image $thumb_image_name = $image_prefix_name . '6_thumb.jpg'; // New name of the thumbnail image $max_file = "1000000"; // Approx below 1MB $max_width = "850"; // Max width allowed for the large image $thumb_width = "260"; // Width of thumbnail image $thumb_height = "150"; // Height of thumbnail image //Image Locations $normal_image_location = $upload_path . $normal_image_name; $large_image_location = $upload_path . $large_image_name; $thumb_image_location = $upload_path . $thumb_image_name; //Check to see if any images with the same names already exist if (file_exists($large_image_location)) { if (file_exists($thumb_image_location)) { $thumb_photo_exists = "<img src=\"" . $upload_path . $thumb_image_name . "\" alt=\"Thumbnail Image\"/>"; } else { $thumb_photo_exists = ""; } $large_photo_exists = "<img src=\"" . $upload_path . $large_image_name . "\" alt=\"Large Image\"/>"; } else { $large_photo_exists = ""; $thumb_photo_exists = ""; } //Check normal img if (file_exists($normal_image_location)) { $normal_photo_exists = "<img src=\"" . $upload_path . $normal_image_name . "\" alt=\"Large Image\"/>"; } else { $normal_photo_exists = ""; } ?> <?php global $themename, $shortname, $options9; if ($_REQUEST['saved9']) { echo '<div id="message" class="updated fade"><p><strong>' . $themename . __(' Featured image 6 Settings saved.', TEMPLATE_DOMAIN) . '</strong></p></div>'; } if ($_REQUEST['reset9']) { echo '<div id="message" class="updated fade"><p><strong>' . $themename . __(' Featured image 6 Settings reset.', TEMPLATE_DOMAIN) . '</strong></p></div>'; } ?> <h4><?php _e("Featured image 6 Setting", TEMPLATE_DOMAIN); ?> </h4> <div class="tab-option"> <div class="option-save"> <?php if (isset($_POST['upload6'])) { //Get the file information $userfile_name = $_FILES['image']['name']; $userfile_tmp = $_FILES['image']['tmp_name']; $userfile_type = $_FILES['image']['type']; $userfile_size = $_FILES['image']['size']; $filename = basename($_FILES['image']['name']); $file_ext = substr($filename, strrpos($filename, '.') + 1); //Only process if the file is a JPG, PNG or GIF and below the allowed limit if (!empty($_FILES["image"]) && $_FILES['image']['error'] == 0) { foreach ($allowed_image_types as $mime_type => $ext) { //loop through the specified image types and if they match the extension then break out //everything is ok so go and check file size if ($file_ext == $ext && $userfile_type == $mime_type) { $error = ""; break; } else { $error = __("Only", TEMPLATE_DOMAIN) . " <strong>" . $image_ext . "</strong>" . __(" images accepted for upload", TEMPLATE_DOMAIN) . "<br />"; } } //check if the file size is above the allowed limit if ($userfile_size > $max_file) { $error .= __("Images must be under 1 MB in size", TEMPLATE_DOMAIN); } } else { $error = __("Select an image for upload", TEMPLATE_DOMAIN); } //Everything is ok, so we can upload the image. if (strlen($error) == 0) { if (isset($_FILES['image']['name'])) { move_uploaded_file($userfile_tmp, $large_image_location); chmod($large_image_location, 0777); $width = getWidth($large_image_location); $height = getHeight($large_image_location); //Scale the image if it is greater than the width set above if ($width > $max_width) { $scale = $max_width / $width; $uploaded = resizeImage($large_image_location, $width, $height, $scale); } else { $scale = 1; $uploaded = resizeImage($large_image_location, $width, $height, $scale); } //Delete the thumbnail file so the user can create a new one if (file_exists($thumb_image_location)) { unlink($thumb_image_location); } } //Refresh the page to show the new uploaded image //Refresh the page to show the new uploaded image print '<meta http-equiv="Pragma" content="no-cache">'; echo "<h4 id=\"loading-bar\">Please wait..Your Image Currently Processing</h4>"; echo '<img src="' . get_template_directory_uri() . '/_inc/admin/loading_bar.gif' . '">'; print "<meta http-equiv=\"refresh\" content=\"5;url={$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php&#tab6\">"; exit; //double refresh to clear cache..its a bit catchy but it get the job done } } // normal upload if (isset($_POST["normal_upload6"])) { //Get the file information $userfile_name = $_FILES['image']['name']; $userfile_tmp = $_FILES['image']['tmp_name']; $userfile_type = $_FILES['image']['type']; $userfile_size = $_FILES['image']['size']; $filename = basename($_FILES['image']['name']); $file_ext = substr($filename, strrpos($filename, '.') + 1); //Only process if the file is a JPG and below the allowed limit if (!empty($_FILES["image"]) && $_FILES['image']['error'] == 0) { foreach ($allowed_image_types as $mime_type => $ext) { //loop through the specified image types and if they match the extension then break out //everything is ok so go and check file size if ($file_ext == $ext && $userfile_type == $mime_type) { $error = ""; break; } else { $error = __("Only", TEMPLATE_DOMAIN) . "<strong>" . $image_ext . "</strong>" . __("images accepted for upload", TEMPLATE_DOMAIN) . "<br />"; } } if ($userfile_size > $max_file) { $error = __("ONLY images under 1MB are accepted for upload", TEMPLATE_DOMAIN); } } else { $error = __("Select an image for upload", TEMPLATE_DOMAIN); } //Everything is ok, so we can upload the image. if (strlen($error) == 0) { if (isset($_FILES['image']['name'])) { move_uploaded_file($userfile_tmp, $normal_image_location); chmod($normal_image_location, 0777); //Delete the thumbnail file so the user can create a new one if (file_exists($thumb_image_location)) { unlink($thumb_image_location); } } //Refresh the page to show the new uploaded image print '<meta http-equiv="Pragma" content="no-cache">'; echo "<h4 id=\"loading-bar\">Please wait..Your Image Currently Processing</h4>"; echo '<img src="' . get_template_directory_uri() . '/_inc/admin/loading_bar.gif' . '">'; print "<meta http-equiv=\"refresh\" content=\"5;url={$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php&#tab6\">"; exit; //double refresh to clear cache..its a bit catchy but it get the job done } } if (isset($_POST['upload_thumbnail6']) && strlen($large_photo_exists) > 0) { //Get the new coordinates to crop the image. $x1 = $_POST["x1"]; $y1 = $_POST["y1"]; $x2 = $_POST["x2"]; $y2 = $_POST["y2"]; $w = $_POST["w"]; $h = $_POST["h"]; //Scale the image to the thumb_width set above $scale = $thumb_width / $w; $cropped = resizeThumbnailImage($thumb_image_location, $large_image_location, $w, $h, $x1, $y1, $scale); //Refresh the page to show the new uploaded image print '<meta http-equiv="Pragma" content="no-cache">'; echo "<h4 id=\"loading-bar\">Please wait..Your Image Currently Processing</h4>"; echo '<img src="' . get_template_directory_uri() . '/_inc/admin/loading_bar.gif' . '">'; print "<meta http-equiv=\"refresh\" content=\"5;url={$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php&#tab6\">"; exit; //double refresh to clear cache..its a bit catchy but it get the job done } ?> <?php //Only display the javacript if an image has been uploaded if (strlen($large_photo_exists) > 0) { $current_large_image_width = getWidth($large_image_location); $current_large_image_height = getHeight($large_image_location); ?> <script type="text/javascript"> function preview(img, selection) { var scaleX = <?php echo $thumb_width; ?> / selection.width; var scaleY = <?php echo $thumb_height; ?> / selection.height; $('#thumbnail + div > img').css({ width: Math.round(scaleX * <?php echo $current_large_image_width; ?> ) + 'px', height: Math.round(scaleY * <?php echo $current_large_image_height; ?> ) + 'px', marginLeft: '-' + Math.round(scaleX * selection.x1) + 'px', marginTop: '-' + Math.round(scaleY * selection.y1) + 'px' }); $('#x1').val(selection.x1); $('#y1').val(selection.y1); $('#x2').val(selection.x2); $('#y2').val(selection.y2); $('#w').val(selection.width); $('#h').val(selection.height); } $(document).ready(function () { $('#save_thumb').click(function() { var x1 = $('#x1').val(); var y1 = $('#y1').val(); var x2 = $('#x2').val(); var y2 = $('#y2').val(); var w = $('#w').val(); var h = $('#h').val(); if(x1=="" || y1=="" || x2=="" || y2=="" || w=="" || h==""){ alert("You must make a selection first"); return false; } else { return true; } }); }); function selectionStart(img, selection) { width:260;height:150 } $(window).load(function () { $('#thumbnail').imgAreaSelect({ onSelectStart: selectionStart, resizable: true, x1: 20, y1: 20, x2: 280, y2: 170, aspectRatio: '28:17', onSelectChange: preview }); }); </script> <?php } ?> <?php if (isset($_POST['delete_thumbnail6'])) { unlink($upload_path . $large_image_name); unlink($upload_path . $thumb_image_name); echo "<h5 id='file-delete'>" . __('File successfully deleted', TEMPLATE_DOMAIN) . "</h5>"; print "<meta http-equiv=\"refresh\" content=\"1;url={$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php&#tab6\">"; exit; } if (isset($_POST["delete_normal_upload6"])) { unlink("{$upload_path}/{$normal_image_name}"); echo "<h5 id='file-delete'>" . __('File successfully deleted', TEMPLATE_DOMAIN) . "</h5>"; print "<meta http-equiv=\"refresh\" content=\"1;url={$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php&#tab6\">"; exit; } ?> <?php //Display error message if there are any if (strlen($error) > 0) { echo "<p class=\"uperror\"><strong>" . __("Error!", TEMPLATE_DOMAIN) . " </strong>" . $error . "</p>"; } if (strlen($large_photo_exists) > 0 && strlen($thumb_photo_exists) > 0) { ?> <img src="<?php echo "{$upload_url}/{$thumb_image_name}"; ?> " class="timg"/><br /><br /> <form id="form-del" name="thumbnail" action="" method="post"> <div class="submit"><input type="submit" name="delete_thumbnail6" class="sbutton button-secondary" value="<?php _e("Delete This Image", TEMPLATE_DOMAIN); ?> " /></div> </form> <?php } else { if (strlen($normal_photo_exists) > 0) { ?> <img src="<?php echo "{$upload_url}/{$normal_image_name}"; ?> " class="timg"/><br /><br /> <form id="form-del" name="thumbnail" action="" method="post"> <input type="submit" name="delete_normal_upload6" class="button-secondary" value="Delete This Image" /> </form> <?php } } ?> <?php if (strlen($large_photo_exists) > 0 && strlen($thumb_photo_exists) > 0) { } else { if (strlen($large_photo_exists) > 0) { ?> <h3><?php _e('Crop And Save Your Thumbnail', TEMPLATE_DOMAIN); ?> </h3> <div> <img src="<?php echo "{$upload_url}/{$large_image_name}"; ?> " style="clear: both; margin-bottom: 10px;" id="thumbnail" alt="Create Thumbnail" /> <br style="clear:both;"/> <form name="thumbnail" action="" method="post"> <input type="hidden" name="x1" value="" id="x1" /> <input type="hidden" name="y1" value="" id="y1" /> <input type="hidden" name="x2" value="" id="x2" /> <input type="hidden" name="y2" value="" id="y2" /> <input type="hidden" name="w" value="" id="w" /> <input type="hidden" name="h" value="" id="h" /> <input type="submit" name="upload_thumbnail6" class="button-secondary" value="Save Thumbnail" id="save_thumb" /> </form> </div> <?php } } ?> <?php if (strlen($large_photo_exists) == 0 && strlen($normal_photo_exists) == 0) { ?> <h3><?php _e("Upload Image", TEMPLATE_DOMAIN); ?> <?php echo $thumb_width . ' X ' . $thumb_height; ?> </h3> <form name="photo" enctype="multipart/form-data" action="<?php echo admin_url('themes.php?page=custom-homepage.php&#tab6'); ?> " method="post"> <input type="file" class="ups" name="image" /> <input type="submit" class="button-secondary" name="upload6" value="Upload and crop»" /> <input type="submit" class="button-secondary" name="normal_upload6" value="Upload »" /> <p class="onlyjpg">* <?php _e("only", TEMPLATE_DOMAIN); ?> <?php echo $image_ext; ?> <?php _e("image file are allowed", TEMPLATE_DOMAIN); ?> </p> </form> <?php } ?> <br /> <form method="post"> <?php foreach ($options9 as $value) { ?> <?php switch ($value['type']) { case 'text': ?> <div class="description"><?php echo $value['name']; ?> </div> <p><input name="<?php echo $value['id']; ?> " class="myfield" id="<?php echo $value['id']; ?> " type="<?php echo $value['type']; ?> " value="<?php if (get_option($value['id']) != "") { echo get_option($value['id']); } else { echo $value['std']; } ?> " /> </p> <?php break; case 'textarea': ?> <?php $valuex = $value['id']; $valuey = stripslashes($valuex); $video_code = get_option($valuey); ?> <div class="description"><?php echo $value['name']; ?> </div> <p><textarea name="<?php echo $valuey; ?> " class="mytext" cols="40%" rows="8" /><?php if (get_option($valuey) != "") { echo stripslashes($video_code); } else { echo $value['std']; } ?> </textarea></p> <?php break; default: ?> <?php break; } ?> <?php } ?> <p class="submit"> <input name="save" type="submit" class="sbutton button-primary" value="<?php _e("Save setting", TEMPLATE_DOMAIN); ?> " /> <input type="hidden" name="action" value="save9" /> </p> </form> <form method="post"> <p class="submit"> <input name="reset" type="submit" class="sbutton button-primary" value="<?php _e("Reset setting", TEMPLATE_DOMAIN); ?> " /> <input type="hidden" name="action" value="reset9" /> </p> </form> </div> </div> </div> <?php echo "<div id='tab7' class='tabc'>"; $normal_image_name = $image_prefix_name . '7_normal.jpg'; // New name of the large image $large_image_name = $image_prefix_name . '7.jpg'; // New name of the large image $thumb_image_name = $image_prefix_name . '7_thumb.jpg'; // New name of the thumbnail image $max_file = "1000000"; // Approx below 1MB $max_width = "850"; // Max width allowed for the large image $thumb_width = "260"; // Width of thumbnail image $thumb_height = "150"; // Height of thumbnail image //Image Locations $normal_image_location = $upload_path . $normal_image_name; $large_image_location = $upload_path . $large_image_name; $thumb_image_location = $upload_path . $thumb_image_name; //Check to see if any images with the same names already exist if (file_exists($large_image_location)) { if (file_exists($thumb_image_location)) { $thumb_photo_exists = "<img src=\"" . $upload_path . $thumb_image_name . "\" alt=\"Thumbnail Image\"/>"; } else { $thumb_photo_exists = ""; } $large_photo_exists = "<img src=\"" . $upload_path . $large_image_name . "\" alt=\"Large Image\"/>"; } else { $large_photo_exists = ""; $thumb_photo_exists = ""; } //Check normal img if (file_exists($normal_image_location)) { $normal_photo_exists = "<img src=\"" . $upload_path . $normal_image_name . "\" alt=\"Large Image\"/>"; } else { $normal_photo_exists = ""; } ?> <?php global $themename, $shortname, $options10; if ($_REQUEST['saved10']) { echo '<div id="message" class="updated fade"><p><strong>' . $themename . __(' Featured image 7 Settings saved.', TEMPLATE_DOMAIN) . '</strong></p></div>'; } if ($_REQUEST['reset10']) { echo '<div id="message" class="updated fade"><p><strong>' . $themename . __(' Featured image 7 Settings reset.', TEMPLATE_DOMAIN) . '</strong></p></div>'; } ?> <h4><?php _e("Featured image 7 Setting", TEMPLATE_DOMAIN); ?> </h4> <div class="tab-option"> <div class="option-save"> <?php if (isset($_POST['upload7'])) { //Get the file information $userfile_name = $_FILES['image']['name']; $userfile_tmp = $_FILES['image']['tmp_name']; $userfile_type = $_FILES['image']['type']; $userfile_size = $_FILES['image']['size']; $filename = basename($_FILES['image']['name']); $file_ext = substr($filename, strrpos($filename, '.') + 1); //Only process if the file is a JPG, PNG or GIF and below the allowed limit if (!empty($_FILES["image"]) && $_FILES['image']['error'] == 0) { foreach ($allowed_image_types as $mime_type => $ext) { //loop through the specified image types and if they match the extension then break out //everything is ok so go and check file size if ($file_ext == $ext && $userfile_type == $mime_type) { $error = ""; break; } else { $error = __("Only", TEMPLATE_DOMAIN) . " <strong>" . $image_ext . "</strong>" . __(" images accepted for upload", TEMPLATE_DOMAIN) . "<br />"; } } //check if the file size is above the allowed limit if ($userfile_size > $max_file) { $error .= __("Images must be under 1 MB in size", TEMPLATE_DOMAIN); } } else { $error = __("Select an image for upload", TEMPLATE_DOMAIN); } //Everything is ok, so we can upload the image. if (strlen($error) == 0) { if (isset($_FILES['image']['name'])) { move_uploaded_file($userfile_tmp, $large_image_location); chmod($large_image_location, 0777); $width = getWidth($large_image_location); $height = getHeight($large_image_location); //Scale the image if it is greater than the width set above if ($width > $max_width) { $scale = $max_width / $width; $uploaded = resizeImage($large_image_location, $width, $height, $scale); } else { $scale = 1; $uploaded = resizeImage($large_image_location, $width, $height, $scale); } //Delete the thumbnail file so the user can create a new one if (file_exists($thumb_image_location)) { unlink($thumb_image_location); } } //Refresh the page to show the new uploaded image //Refresh the page to show the new uploaded image print '<meta http-equiv="Pragma" content="no-cache">'; echo "<h4 id=\"loading-bar\">Please wait..Your Image Currently Processing</h4>"; echo '<img src="' . get_template_directory_uri() . '/_inc/admin/loading_bar.gif' . '">'; print "<meta http-equiv=\"refresh\" content=\"5;url={$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php&#tab7\">"; exit; //double refresh to clear cache..its a bit catchy but it get the job done } } // normal upload if (isset($_POST["normal_upload7"])) { //Get the file information $userfile_name = $_FILES['image']['name']; $userfile_tmp = $_FILES['image']['tmp_name']; $userfile_type = $_FILES['image']['type']; $userfile_size = $_FILES['image']['size']; $filename = basename($_FILES['image']['name']); $file_ext = substr($filename, strrpos($filename, '.') + 1); //Only process if the file is a JPG and below the allowed limit if (!empty($_FILES["image"]) && $_FILES['image']['error'] == 0) { foreach ($allowed_image_types as $mime_type => $ext) { //loop through the specified image types and if they match the extension then break out //everything is ok so go and check file size if ($file_ext == $ext && $userfile_type == $mime_type) { $error = ""; break; } else { $error = __("Only", TEMPLATE_DOMAIN) . "<strong>" . $image_ext . "</strong>" . __("images accepted for upload", TEMPLATE_DOMAIN) . "<br />"; } } if ($userfile_size > $max_file) { $error = __("ONLY images under 1MB are accepted for upload", TEMPLATE_DOMAIN); } } else { $error = __("Select an image for upload", TEMPLATE_DOMAIN); } //Everything is ok, so we can upload the image. if (strlen($error) == 0) { if (isset($_FILES['image']['name'])) { move_uploaded_file($userfile_tmp, $normal_image_location); chmod($normal_image_location, 0777); //Delete the thumbnail file so the user can create a new one if (file_exists($thumb_image_location)) { unlink($thumb_image_location); } } //Refresh the page to show the new uploaded image print '<meta http-equiv="Pragma" content="no-cache">'; echo "<h4 id=\"loading-bar\">Please wait..Your Image Currently Processing</h4>"; echo '<img src="' . get_template_directory_uri() . '/_inc/admin/loading_bar.gif' . '">'; print "<meta http-equiv=\"refresh\" content=\"5;url={$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php&#tab7\">"; exit; //double refresh to clear cache..its a bit catchy but it get the job done } } if (isset($_POST['upload_thumbnail7']) && strlen($large_photo_exists) > 0) { //Get the new coordinates to crop the image. $x1 = $_POST["x1"]; $y1 = $_POST["y1"]; $x2 = $_POST["x2"]; $y2 = $_POST["y2"]; $w = $_POST["w"]; $h = $_POST["h"]; //Scale the image to the thumb_width set above $scale = $thumb_width / $w; $cropped = resizeThumbnailImage($thumb_image_location, $large_image_location, $w, $h, $x1, $y1, $scale); //Refresh the page to show the new uploaded image print '<meta http-equiv="Pragma" content="no-cache">'; echo "<h4 id=\"loading-bar\">Please wait..Your Image Currently Processing</h4>"; echo '<img src="' . get_template_directory_uri() . '/_inc/admin/loading_bar.gif' . '">'; print "<meta http-equiv=\"refresh\" content=\"5;url={$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php&#tab7\">"; exit; //double refresh to clear cache..its a bit catchy but it get the job done } ?> <?php //Only display the javacript if an image has been uploaded if (strlen($large_photo_exists) > 0) { $current_large_image_width = getWidth($large_image_location); $current_large_image_height = getHeight($large_image_location); ?> <script type="text/javascript"> function preview(img, selection) { var scaleX = <?php echo $thumb_width; ?> / selection.width; var scaleY = <?php echo $thumb_height; ?> / selection.height; $('#thumbnail + div > img').css({ width: Math.round(scaleX * <?php echo $current_large_image_width; ?> ) + 'px', height: Math.round(scaleY * <?php echo $current_large_image_height; ?> ) + 'px', marginLeft: '-' + Math.round(scaleX * selection.x1) + 'px', marginTop: '-' + Math.round(scaleY * selection.y1) + 'px' }); $('#x1').val(selection.x1); $('#y1').val(selection.y1); $('#x2').val(selection.x2); $('#y2').val(selection.y2); $('#w').val(selection.width); $('#h').val(selection.height); } $(document).ready(function () { $('#save_thumb').click(function() { var x1 = $('#x1').val(); var y1 = $('#y1').val(); var x2 = $('#x2').val(); var y2 = $('#y2').val(); var w = $('#w').val(); var h = $('#h').val(); if(x1=="" || y1=="" || x2=="" || y2=="" || w=="" || h==""){ alert("You must make a selection first"); return false; } else { return true; } }); }); function selectionStart(img, selection) { width:260;height:150 } $(window).load(function () { $('#thumbnail').imgAreaSelect({ onSelectStart: selectionStart, resizable: true, x1: 20, y1: 20, x2: 280, y2: 170, aspectRatio: '28:17', onSelectChange: preview }); }); </script> <?php } ?> <?php if (isset($_POST['delete_thumbnail7'])) { unlink($upload_path . $large_image_name); unlink($upload_path . $thumb_image_name); echo "<h5 id='file-delete'>" . __('File successfully deleted', TEMPLATE_DOMAIN) . "</h5>"; print "<meta http-equiv=\"refresh\" content=\"1;url={$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php&#tab7\">"; exit; } if (isset($_POST["delete_normal_upload7"])) { unlink("{$upload_path}/{$normal_image_name}"); echo "<h5 id='file-delete'>" . __('File successfully deleted', TEMPLATE_DOMAIN) . "</h5>"; print "<meta http-equiv=\"refresh\" content=\"1;url={$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php&#tab7\">"; exit; } ?> <?php //Display error message if there are any if (strlen($error) > 0) { echo "<p class=\"uperror\"><strong>" . __("Error!", TEMPLATE_DOMAIN) . " </strong>" . $error . "</p>"; } if (strlen($large_photo_exists) > 0 && strlen($thumb_photo_exists) > 0) { ?> <img src="<?php echo "{$upload_url}/{$thumb_image_name}"; ?> " class="timg"/><br /><br /> <form id="form-del" name="thumbnail" action="" method="post"> <div class="submit"><input type="submit" name="delete_thumbnail7" class="sbutton button-secondary" value="<?php _e("Delete This Image", TEMPLATE_DOMAIN); ?> " /></div> </form> <?php } else { if (strlen($normal_photo_exists) > 0) { ?> <img src="<?php echo "{$upload_url}/{$normal_image_name}"; ?> " class="timg"/><br /><br /> <form id="form-del" name="thumbnail" action="" method="post"> <input type="submit" name="delete_normal_upload7" class="button-secondary" value="Delete This Image" /> </form> <?php } } ?> <?php if (strlen($large_photo_exists) > 0 && strlen($thumb_photo_exists) > 0) { } else { if (strlen($large_photo_exists) > 0) { ?> <h3><?php _e('Crop And Save Your Thumbnail', TEMPLATE_DOMAIN); ?> </h3> <div> <img src="<?php echo "{$upload_url}/{$large_image_name}"; ?> " style="clear: both; margin-bottom: 10px;" id="thumbnail" alt="Create Thumbnail" /> <br style="clear:both;"/> <form name="thumbnail" action="" method="post"> <input type="hidden" name="x1" value="" id="x1" /> <input type="hidden" name="y1" value="" id="y1" /> <input type="hidden" name="x2" value="" id="x2" /> <input type="hidden" name="y2" value="" id="y2" /> <input type="hidden" name="w" value="" id="w" /> <input type="hidden" name="h" value="" id="h" /> <input type="submit" name="upload_thumbnail7" class="button-secondary" value="Save Thumbnail" id="save_thumb" /> </form> </div> <?php } } ?> <?php if (strlen($large_photo_exists) == 0 && strlen($normal_photo_exists) == 0) { ?> <h3><?php _e("Upload Image", TEMPLATE_DOMAIN); ?> <?php echo $thumb_width . ' X ' . $thumb_height; ?> </h3> <form name="photo" enctype="multipart/form-data" action="<?php echo admin_url('themes.php?page=custom-homepage.php&#tab7'); ?> " method="post"> <input type="file" class="ups" name="image" /> <input type="submit" class="button-secondary" name="upload7" value="Upload and crop»" /> <input type="submit" class="button-secondary" name="normal_upload7" value="Upload »" /> <p class="onlyjpg">* <?php _e("only", TEMPLATE_DOMAIN); ?> <?php echo $image_ext; ?> <?php _e("image file are allowed", TEMPLATE_DOMAIN); ?> </p> </form> <?php } ?> <br /> <form method="post"> <?php foreach ($options10 as $value) { ?> <?php switch ($value['type']) { case 'text': ?> <div class="description"><?php echo $value['name']; ?> </div> <p><input name="<?php echo $value['id']; ?> " class="myfield" id="<?php echo $value['id']; ?> " type="<?php echo $value['type']; ?> " value="<?php if (get_option($value['id']) != "") { echo get_option($value['id']); } else { echo $value['std']; } ?> " /> </p> <?php break; case 'textarea': ?> <?php $valuex = $value['id']; $valuey = stripslashes($valuex); $video_code = get_option($valuey); ?> <div class="description"><?php echo $value['name']; ?> </div> <p><textarea name="<?php echo $valuey; ?> " class="mytext" cols="40%" rows="8" /><?php if (get_option($valuey) != "") { echo stripslashes($video_code); } else { echo $value['std']; } ?> </textarea></p> <?php break; default: ?> <?php break; } ?> <?php } ?> <p class="submit"> <input name="save" type="submit" class="sbutton button-primary" value="<?php _e("Save setting", TEMPLATE_DOMAIN); ?> " /> <input type="hidden" name="action" value="save10" /> </p> </form> <form method="post"> <p class="submit"> <input name="reset" type="submit" class="sbutton button-primary" value="<?php _e("Reset setting", TEMPLATE_DOMAIN); ?> " /> <input type="hidden" name="action" value="reset10" /> </p> </form> </div> </div> </div> <?php echo "<div id='tab8' class='tabc'>"; $normal_image_name = $image_prefix_name . '8_normal.jpg'; // New name of the large image $large_image_name = $image_prefix_name . '8.jpg'; // New name of the large image $thumb_image_name = $image_prefix_name . '8_thumb.jpg'; // New name of the thumbnail image $max_file = "1000000"; // Approx below 1MB $max_width = "850"; // Max width allowed for the large image $thumb_width = "260"; // Width of thumbnail image $thumb_height = "150"; // Height of thumbnail image //Image Locations $normal_image_location = $upload_path . $normal_image_name; $large_image_location = $upload_path . $large_image_name; $thumb_image_location = $upload_path . $thumb_image_name; //Check to see if any images with the same names already exist if (file_exists($large_image_location)) { if (file_exists($thumb_image_location)) { $thumb_photo_exists = "<img src=\"" . $upload_path . $thumb_image_name . "\" alt=\"Thumbnail Image\"/>"; } else { $thumb_photo_exists = ""; } $large_photo_exists = "<img src=\"" . $upload_path . $large_image_name . "\" alt=\"Large Image\"/>"; } else { $large_photo_exists = ""; $thumb_photo_exists = ""; } //Check normal img if (file_exists($normal_image_location)) { $normal_photo_exists = "<img src=\"" . $upload_path . $normal_image_name . "\" alt=\"Large Image\"/>"; } else { $normal_photo_exists = ""; } ?> <?php global $themename, $shortname, $options11; if ($_REQUEST['saved11']) { echo '<div id="message" class="updated fade"><p><strong>' . $themename . __(' Featured image 8 Settings saved.', TEMPLATE_DOMAIN) . '</strong></p></div>'; } if ($_REQUEST['reset11']) { echo '<div id="message" class="updated fade"><p><strong>' . $themename . __(' Featured image 8 Settings reset.', TEMPLATE_DOMAIN) . '</strong></p></div>'; } ?> <h4><?php _e("Featured image 8 Setting", TEMPLATE_DOMAIN); ?> </h4> <div class="tab-option"> <div class="option-save"> <?php if (isset($_POST['upload8'])) { //Get the file information $userfile_name = $_FILES['image']['name']; $userfile_tmp = $_FILES['image']['tmp_name']; $userfile_type = $_FILES['image']['type']; $userfile_size = $_FILES['image']['size']; $filename = basename($_FILES['image']['name']); $file_ext = substr($filename, strrpos($filename, '.') + 1); //Only process if the file is a JPG, PNG or GIF and below the allowed limit if (!empty($_FILES["image"]) && $_FILES['image']['error'] == 0) { foreach ($allowed_image_types as $mime_type => $ext) { //loop through the specified image types and if they match the extension then break out //everything is ok so go and check file size if ($file_ext == $ext && $userfile_type == $mime_type) { $error = ""; break; } else { $error = __("Only", TEMPLATE_DOMAIN) . " <strong>" . $image_ext . "</strong>" . __(" images accepted for upload", TEMPLATE_DOMAIN) . "<br />"; } } //check if the file size is above the allowed limit if ($userfile_size > $max_file) { $error .= __("Images must be under 1 MB in size", TEMPLATE_DOMAIN); } } else { $error = __("Select an image for upload", TEMPLATE_DOMAIN); } //Everything is ok, so we can upload the image. if (strlen($error) == 0) { if (isset($_FILES['image']['name'])) { move_uploaded_file($userfile_tmp, $large_image_location); chmod($large_image_location, 0777); $width = getWidth($large_image_location); $height = getHeight($large_image_location); //Scale the image if it is greater than the width set above if ($width > $max_width) { $scale = $max_width / $width; $uploaded = resizeImage($large_image_location, $width, $height, $scale); } else { $scale = 1; $uploaded = resizeImage($large_image_location, $width, $height, $scale); } //Delete the thumbnail file so the user can create a new one if (file_exists($thumb_image_location)) { unlink($thumb_image_location); } } //Refresh the page to show the new uploaded image //Refresh the page to show the new uploaded image print '<meta http-equiv="Pragma" content="no-cache">'; echo "<h4 id=\"loading-bar\">Please wait..Your Image Currently Processing</h4>"; echo '<img src="' . get_template_directory_uri() . '/_inc/admin/loading_bar.gif' . '">'; print "<meta http-equiv=\"refresh\" content=\"5;url={$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php&#tab8\">"; exit; //double refresh to clear cache..its a bit catchy but it get the job done } } // normal upload if (isset($_POST["normal_upload8"])) { //Get the file information $userfile_name = $_FILES['image']['name']; $userfile_tmp = $_FILES['image']['tmp_name']; $userfile_type = $_FILES['image']['type']; $userfile_size = $_FILES['image']['size']; $filename = basename($_FILES['image']['name']); $file_ext = substr($filename, strrpos($filename, '.') + 1); //Only process if the file is a JPG and below the allowed limit if (!empty($_FILES["image"]) && $_FILES['image']['error'] == 0) { foreach ($allowed_image_types as $mime_type => $ext) { //loop through the specified image types and if they match the extension then break out //everything is ok so go and check file size if ($file_ext == $ext && $userfile_type == $mime_type) { $error = ""; break; } else { $error = __("Only", TEMPLATE_DOMAIN) . "<strong>" . $image_ext . "</strong>" . __("images accepted for upload", TEMPLATE_DOMAIN) . "<br />"; } } if ($userfile_size > $max_file) { $error = __("ONLY images under 1MB are accepted for upload", TEMPLATE_DOMAIN); } } else { $error = __("Select an image for upload", TEMPLATE_DOMAIN); } //Everything is ok, so we can upload the image. if (strlen($error) == 0) { if (isset($_FILES['image']['name'])) { move_uploaded_file($userfile_tmp, $normal_image_location); chmod($normal_image_location, 0777); //Delete the thumbnail file so the user can create a new one if (file_exists($thumb_image_location)) { unlink($thumb_image_location); } } //Refresh the page to show the new uploaded image print '<meta http-equiv="Pragma" content="no-cache">'; echo "<h4 id=\"loading-bar\">Please wait..Your Image Currently Processing</h4>"; echo '<img src="' . get_template_directory_uri() . '/_inc/admin/loading_bar.gif' . '">'; print "<meta http-equiv=\"refresh\" content=\"5;url={$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php&#tab8\">"; exit; //double refresh to clear cache..its a bit catchy but it get the job done } } if (isset($_POST['upload_thumbnail8']) && strlen($large_photo_exists) > 0) { //Get the new coordinates to crop the image. $x1 = $_POST["x1"]; $y1 = $_POST["y1"]; $x2 = $_POST["x2"]; $y2 = $_POST["y2"]; $w = $_POST["w"]; $h = $_POST["h"]; //Scale the image to the thumb_width set above $scale = $thumb_width / $w; $cropped = resizeThumbnailImage($thumb_image_location, $large_image_location, $w, $h, $x1, $y1, $scale); //Refresh the page to show the new uploaded image print '<meta http-equiv="Pragma" content="no-cache">'; echo "<h4 id=\"loading-bar\">Please wait..Your Image Currently Processing</h4>"; echo '<img src="' . get_template_directory_uri() . '/_inc/admin/loading_bar.gif' . '">'; print "<meta http-equiv=\"refresh\" content=\"5;url={$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php&#tab8\">"; exit; //double refresh to clear cache..its a bit catchy but it get the job done } ?> <?php //Only display the javacript if an image has been uploaded if (strlen($large_photo_exists) > 0) { $current_large_image_width = getWidth($large_image_location); $current_large_image_height = getHeight($large_image_location); ?> <script type="text/javascript"> function preview(img, selection) { var scaleX = <?php echo $thumb_width; ?> / selection.width; var scaleY = <?php echo $thumb_height; ?> / selection.height; $('#thumbnail + div > img').css({ width: Math.round(scaleX * <?php echo $current_large_image_width; ?> ) + 'px', height: Math.round(scaleY * <?php echo $current_large_image_height; ?> ) + 'px', marginLeft: '-' + Math.round(scaleX * selection.x1) + 'px', marginTop: '-' + Math.round(scaleY * selection.y1) + 'px' }); $('#x1').val(selection.x1); $('#y1').val(selection.y1); $('#x2').val(selection.x2); $('#y2').val(selection.y2); $('#w').val(selection.width); $('#h').val(selection.height); } $(document).ready(function () { $('#save_thumb').click(function() { var x1 = $('#x1').val(); var y1 = $('#y1').val(); var x2 = $('#x2').val(); var y2 = $('#y2').val(); var w = $('#w').val(); var h = $('#h').val(); if(x1=="" || y1=="" || x2=="" || y2=="" || w=="" || h==""){ alert("You must make a selection first"); return false; } else { return true; } }); }); function selectionStart(img, selection) { width:260;height:150 } $(window).load(function () { $('#thumbnail').imgAreaSelect({ onSelectStart: selectionStart, resizable: true, x1: 20, y1: 20, x2: 280, y2: 170, aspectRatio: '28:17', onSelectChange: preview }); }); </script> <?php } ?> <?php if (isset($_POST['delete_thumbnail8'])) { unlink($upload_path . $large_image_name); unlink($upload_path . $thumb_image_name); echo "<h5 id='file-delete'>" . __('File successfully deleted', TEMPLATE_DOMAIN) . "</h5>"; print "<meta http-equiv=\"refresh\" content=\"1;url={$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php&#tab8\">"; exit; } if (isset($_POST["delete_normal_upload8"])) { unlink("{$upload_path}/{$normal_image_name}"); echo "<h5 id='file-delete'>" . __('File successfully deleted', TEMPLATE_DOMAIN) . "</h5>"; print "<meta http-equiv=\"refresh\" content=\"1;url={$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php&#tab8\">"; exit; } ?> <?php //Display error message if there are any if (strlen($error) > 0) { echo "<p class=\"uperror\"><strong>" . __("Error!", TEMPLATE_DOMAIN) . " </strong>" . $error . "</p>"; } if (strlen($large_photo_exists) > 0 && strlen($thumb_photo_exists) > 0) { ?> <img src="<?php echo "{$upload_url}/{$thumb_image_name}"; ?> " class="timg"/><br /><br /> <form id="form-del" name="thumbnail" action="" method="post"> <div class="submit"><input type="submit" name="delete_thumbnail8" class="sbutton button-secondary" value="<?php _e("Delete This Image", TEMPLATE_DOMAIN); ?> " /></div> </form> <?php } else { if (strlen($normal_photo_exists) > 0) { ?> <img src="<?php echo "{$upload_url}/{$normal_image_name}"; ?> " class="timg"/><br /><br /> <form id="form-del" name="thumbnail" action="" method="post"> <input type="submit" name="delete_normal_upload8" class="button-secondary" value="Delete This Image" /> </form> <?php } } ?> <?php if (strlen($large_photo_exists) > 0 && strlen($thumb_photo_exists) > 0) { } else { if (strlen($large_photo_exists) > 0) { ?> <h3><?php _e('Crop And Save Your Thumbnail', TEMPLATE_DOMAIN); ?> </h3> <div> <img src="<?php echo "{$upload_url}/{$large_image_name}"; ?> " style="clear: both; margin-bottom: 10px;" id="thumbnail" alt="Create Thumbnail" /> <br style="clear:both;"/> <form name="thumbnail" action="" method="post"> <input type="hidden" name="x1" value="" id="x1" /> <input type="hidden" name="y1" value="" id="y1" /> <input type="hidden" name="x2" value="" id="x2" /> <input type="hidden" name="y2" value="" id="y2" /> <input type="hidden" name="w" value="" id="w" /> <input type="hidden" name="h" value="" id="h" /> <input type="submit" name="upload_thumbnail8" class="button-secondary" value="Save Thumbnail" id="save_thumb" /> </form> </div> <?php } } ?> <?php if (strlen($large_photo_exists) == 0 && strlen($normal_photo_exists) == 0) { ?> <h3><?php _e("Upload Image", TEMPLATE_DOMAIN); ?> <?php echo $thumb_width . ' X ' . $thumb_height; ?> </h3> <form name="photo" enctype="multipart/form-data" action="<?php echo admin_url('themes.php?page=custom-homepage.php&#tab8'); ?> " method="post"> <input type="file" class="ups" name="image" /> <input type="submit" class="button-secondary" name="upload8" value="Upload and crop»" /> <input type="submit" class="button-secondary" name="normal_upload8" value="Upload »" /> <p class="onlyjpg">* <?php _e("only", TEMPLATE_DOMAIN); ?> <?php echo $image_ext; ?> <?php _e("image file are allowed", TEMPLATE_DOMAIN); ?> </p> </form> <?php } ?> <br /> <form method="post"> <?php foreach ($options11 as $value) { ?> <?php switch ($value['type']) { case 'text': ?> <div class="description"><?php echo $value['name']; ?> </div> <p><input name="<?php echo $value['id']; ?> " class="myfield" id="<?php echo $value['id']; ?> " type="<?php echo $value['type']; ?> " value="<?php if (get_option($value['id']) != "") { echo get_option($value['id']); } else { echo $value['std']; } ?> " /> </p> <?php break; case 'textarea': ?> <?php $valuex = $value['id']; $valuey = stripslashes($valuex); $video_code = get_option($valuey); ?> <div class="description"><?php echo $value['name']; ?> </div> <p><textarea name="<?php echo $valuey; ?> " class="mytext" cols="40%" rows="8" /><?php if (get_option($valuey) != "") { echo stripslashes($video_code); } else { echo $value['std']; } ?> </textarea></p> <?php break; default: ?> <?php break; } ?> <?php } ?> <p class="submit"> <input name="save" type="submit" class="sbutton button-primary" value="<?php _e("Save setting", TEMPLATE_DOMAIN); ?> " /> <input type="hidden" name="action" value="save11" /> </p> </form> <form method="post"> <p class="submit"> <input name="reset" type="submit" class="sbutton button-primary" value="<?php _e("Reset setting", TEMPLATE_DOMAIN); ?> " /> <input type="hidden" name="action" value="reset11" /> </p> </form> </div> </div> </div> <?php echo "<div id='tab9' class='tabc'>"; $normal_image_name = $image_prefix_name . '9_normal.jpg'; // New name of the large image $large_image_name = $image_prefix_name . '9.jpg'; // New name of the large image $thumb_image_name = $image_prefix_name . '9_thumb.jpg'; // New name of the thumbnail image $max_file = "1000000"; // Approx below 1MB $max_width = "850"; // Max width allowed for the large image $thumb_width = "260"; // Width of thumbnail image $thumb_height = "150"; // Height of thumbnail image //Image Locations $normal_image_location = $upload_path . $normal_image_name; $large_image_location = $upload_path . $large_image_name; $thumb_image_location = $upload_path . $thumb_image_name; //Check to see if any images with the same names already exist if (file_exists($large_image_location)) { if (file_exists($thumb_image_location)) { $thumb_photo_exists = "<img src=\"" . $upload_path . $thumb_image_name . "\" alt=\"Thumbnail Image\"/>"; } else { $thumb_photo_exists = ""; } $large_photo_exists = "<img src=\"" . $upload_path . $large_image_name . "\" alt=\"Large Image\"/>"; } else { $large_photo_exists = ""; $thumb_photo_exists = ""; } //Check normal img if (file_exists($normal_image_location)) { $normal_photo_exists = "<img src=\"" . $upload_path . $normal_image_name . "\" alt=\"Large Image\"/>"; } else { $normal_photo_exists = ""; } ?> <?php global $themename, $shortname, $options12; if ($_REQUEST['saved12']) { echo '<div id="message" class="updated fade"><p><strong>' . $themename . __(' Featured image 9 Settings saved.', TEMPLATE_DOMAIN) . '</strong></p></div>'; } if ($_REQUEST['reset12']) { echo '<div id="message" class="updated fade"><p><strong>' . $themename . __(' Featured image 9 Settings reset.', TEMPLATE_DOMAIN) . '</strong></p></div>'; } ?> <h4><?php _e("Featured image 9 Setting", TEMPLATE_DOMAIN); ?> </h4> <div class="tab-option"> <div class="option-save"> <?php if (isset($_POST['upload9'])) { //Get the file information $userfile_name = $_FILES['image']['name']; $userfile_tmp = $_FILES['image']['tmp_name']; $userfile_type = $_FILES['image']['type']; $userfile_size = $_FILES['image']['size']; $filename = basename($_FILES['image']['name']); $file_ext = substr($filename, strrpos($filename, '.') + 1); //Only process if the file is a JPG, PNG or GIF and below the allowed limit if (!empty($_FILES["image"]) && $_FILES['image']['error'] == 0) { foreach ($allowed_image_types as $mime_type => $ext) { //loop through the specified image types and if they match the extension then break out //everything is ok so go and check file size if ($file_ext == $ext && $userfile_type == $mime_type) { $error = ""; break; } else { $error = __("Only", TEMPLATE_DOMAIN) . " <strong>" . $image_ext . "</strong>" . __(" images accepted for upload", TEMPLATE_DOMAIN) . "<br />"; } } //check if the file size is above the allowed limit if ($userfile_size > $max_file) { $error .= __("Images must be under 1 MB in size", TEMPLATE_DOMAIN); } } else { $error = __("Select an image for upload", TEMPLATE_DOMAIN); } //Everything is ok, so we can upload the image. if (strlen($error) == 0) { if (isset($_FILES['image']['name'])) { move_uploaded_file($userfile_tmp, $large_image_location); chmod($large_image_location, 0777); $width = getWidth($large_image_location); $height = getHeight($large_image_location); //Scale the image if it is greater than the width set above if ($width > $max_width) { $scale = $max_width / $width; $uploaded = resizeImage($large_image_location, $width, $height, $scale); } else { $scale = 1; $uploaded = resizeImage($large_image_location, $width, $height, $scale); } //Delete the thumbnail file so the user can create a new one if (file_exists($thumb_image_location)) { unlink($thumb_image_location); } } //Refresh the page to show the new uploaded image //Refresh the page to show the new uploaded image print '<meta http-equiv="Pragma" content="no-cache">'; echo "<h4 id=\"loading-bar\">Please wait..Your Image Currently Processing</h4>"; echo '<img src="' . get_template_directory_uri() . '/_inc/admin/loading_bar.gif' . '">'; print "<meta http-equiv=\"refresh\" content=\"5;url={$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php&#tab9\">"; exit; //double refresh to clear cache..its a bit catchy but it get the job done } } // normal upload if (isset($_POST["normal_upload9"])) { //Get the file information $userfile_name = $_FILES['image']['name']; $userfile_tmp = $_FILES['image']['tmp_name']; $userfile_type = $_FILES['image']['type']; $userfile_size = $_FILES['image']['size']; $filename = basename($_FILES['image']['name']); $file_ext = substr($filename, strrpos($filename, '.') + 1); //Only process if the file is a JPG and below the allowed limit if (!empty($_FILES["image"]) && $_FILES['image']['error'] == 0) { foreach ($allowed_image_types as $mime_type => $ext) { //loop through the specified image types and if they match the extension then break out //everything is ok so go and check file size if ($file_ext == $ext && $userfile_type == $mime_type) { $error = ""; break; } else { $error = __("Only", TEMPLATE_DOMAIN) . "<strong>" . $image_ext . "</strong>" . __("images accepted for upload", TEMPLATE_DOMAIN) . "<br />"; } } if ($userfile_size > $max_file) { $error = __("ONLY images under 1MB are accepted for upload", TEMPLATE_DOMAIN); } } else { $error = __("Select an image for upload", TEMPLATE_DOMAIN); } //Everything is ok, so we can upload the image. if (strlen($error) == 0) { if (isset($_FILES['image']['name'])) { move_uploaded_file($userfile_tmp, $normal_image_location); chmod($normal_image_location, 0777); //Delete the thumbnail file so the user can create a new one if (file_exists($thumb_image_location)) { unlink($thumb_image_location); } } //Refresh the page to show the new uploaded image print '<meta http-equiv="Pragma" content="no-cache">'; echo "<h4 id=\"loading-bar\">Please wait..Your Image Currently Processing</h4>"; echo '<img src="' . get_template_directory_uri() . '/_inc/admin/loading_bar.gif' . '">'; print "<meta http-equiv=\"refresh\" content=\"5;url={$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php&#tab9\">"; exit; //double refresh to clear cache..its a bit catchy but it get the job done } } if (isset($_POST['upload_thumbnail9']) && strlen($large_photo_exists) > 0) { //Get the new coordinates to crop the image. $x1 = $_POST["x1"]; $y1 = $_POST["y1"]; $x2 = $_POST["x2"]; $y2 = $_POST["y2"]; $w = $_POST["w"]; $h = $_POST["h"]; //Scale the image to the thumb_width set above $scale = $thumb_width / $w; $cropped = resizeThumbnailImage($thumb_image_location, $large_image_location, $w, $h, $x1, $y1, $scale); //Refresh the page to show the new uploaded image print '<meta http-equiv="Pragma" content="no-cache">'; echo "<h4 id=\"loading-bar\">Please wait..Your Image Currently Processing</h4>"; echo '<img src="' . get_template_directory_uri() . '/_inc/admin/loading_bar.gif' . '">'; print "<meta http-equiv=\"refresh\" content=\"5;url={$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php&#tab9\">"; exit; //double refresh to clear cache..its a bit catchy but it get the job done } ?> <?php //Only display the javacript if an image has been uploaded if (strlen($large_photo_exists) > 0) { $current_large_image_width = getWidth($large_image_location); $current_large_image_height = getHeight($large_image_location); ?> <script type="text/javascript"> function preview(img, selection) { var scaleX = <?php echo $thumb_width; ?> / selection.width; var scaleY = <?php echo $thumb_height; ?> / selection.height; $('#thumbnail + div > img').css({ width: Math.round(scaleX * <?php echo $current_large_image_width; ?> ) + 'px', height: Math.round(scaleY * <?php echo $current_large_image_height; ?> ) + 'px', marginLeft: '-' + Math.round(scaleX * selection.x1) + 'px', marginTop: '-' + Math.round(scaleY * selection.y1) + 'px' }); $('#x1').val(selection.x1); $('#y1').val(selection.y1); $('#x2').val(selection.x2); $('#y2').val(selection.y2); $('#w').val(selection.width); $('#h').val(selection.height); } $(document).ready(function () { $('#save_thumb').click(function() { var x1 = $('#x1').val(); var y1 = $('#y1').val(); var x2 = $('#x2').val(); var y2 = $('#y2').val(); var w = $('#w').val(); var h = $('#h').val(); if(x1=="" || y1=="" || x2=="" || y2=="" || w=="" || h==""){ alert("You must make a selection first"); return false; } else { return true; } }); }); function selectionStart(img, selection) { width:260;height:150 } $(window).load(function () { $('#thumbnail').imgAreaSelect({ onSelectStart: selectionStart, resizable: true, x1: 20, y1: 20, x2: 280, y2: 170, aspectRatio: '28:17', onSelectChange: preview }); }); </script> <?php } ?> <?php if (isset($_POST['delete_thumbnail9'])) { unlink($upload_path . $large_image_name); unlink($upload_path . $thumb_image_name); echo "<h5 id='file-delete'>" . __('File successfully deleted', TEMPLATE_DOMAIN) . "</h5>"; print "<meta http-equiv=\"refresh\" content=\"1;url={$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php&#tab9\">"; exit; } if (isset($_POST["delete_normal_upload9"])) { unlink("{$upload_path}/{$normal_image_name}"); echo "<h5 id='file-delete'>" . __('File successfully deleted', TEMPLATE_DOMAIN) . "</h5>"; print "<meta http-equiv=\"refresh\" content=\"1;url={$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php&#tab9\">"; exit; } ?> <?php //Display error message if there are any if (strlen($error) > 0) { echo "<p class=\"uperror\"><strong>" . __("Error!", TEMPLATE_DOMAIN) . " </strong>" . $error . "</p>"; } if (strlen($large_photo_exists) > 0 && strlen($thumb_photo_exists) > 0) { ?> <img src="<?php echo "{$upload_url}/{$thumb_image_name}"; ?> " class="timg"/><br /><br /> <form id="form-del" name="thumbnail" action="" method="post"> <div class="submit"><input type="submit" name="delete_thumbnail9" class="sbutton button-secondary" value="<?php _e("Delete This Image", TEMPLATE_DOMAIN); ?> " /></div> </form> <?php } else { if (strlen($normal_photo_exists) > 0) { ?> <img src="<?php echo "{$upload_url}/{$normal_image_name}"; ?> " class="timg"/><br /><br /> <form id="form-del" name="thumbnail" action="" method="post"> <input type="submit" name="delete_normal_upload9" class="button-secondary" value="Delete This Image" /> </form> <?php } } ?> <?php if (strlen($large_photo_exists) > 0 && strlen($thumb_photo_exists) > 0) { } else { if (strlen($large_photo_exists) > 0) { ?> <h3><?php _e('Crop And Save Your Thumbnail', TEMPLATE_DOMAIN); ?> </h3> <div> <img src="<?php echo "{$upload_url}/{$large_image_name}"; ?> " style="clear: both; margin-bottom: 10px;" id="thumbnail" alt="Create Thumbnail" /> <br style="clear:both;"/> <form name="thumbnail" action="" method="post"> <input type="hidden" name="x1" value="" id="x1" /> <input type="hidden" name="y1" value="" id="y1" /> <input type="hidden" name="x2" value="" id="x2" /> <input type="hidden" name="y2" value="" id="y2" /> <input type="hidden" name="w" value="" id="w" /> <input type="hidden" name="h" value="" id="h" /> <input type="submit" name="upload_thumbnail9" class="button-secondary" value="Save Thumbnail" id="save_thumb" /> </form> </div> <?php } } ?> <?php if (strlen($large_photo_exists) == 0 && strlen($normal_photo_exists) == 0) { ?> <h3><?php _e("Upload Image", TEMPLATE_DOMAIN); ?> <?php echo $thumb_width . ' X ' . $thumb_height; ?> </h3> <form name="photo" enctype="multipart/form-data" action="<?php echo admin_url('themes.php?page=custom-homepage.php&#tab9'); ?> " method="post"> <input type="file" class="ups" name="image" /> <input type="submit" class="button-secondary" name="upload9" value="Upload and crop»" /> <input type="submit" class="button-secondary" name="normal_upload9" value="Upload »" /> <p class="onlyjpg">* <?php _e("only", TEMPLATE_DOMAIN); ?> <?php echo $image_ext; ?> <?php _e("image file are allowed", TEMPLATE_DOMAIN); ?> </p> </form> <?php } ?> <br /> <form method="post"> <?php foreach ($options12 as $value) { ?> <?php switch ($value['type']) { case 'text': ?> <div class="description"><?php echo $value['name']; ?> </div> <p><input name="<?php echo $value['id']; ?> " class="myfield" id="<?php echo $value['id']; ?> " type="<?php echo $value['type']; ?> " value="<?php if (get_option($value['id']) != "") { echo get_option($value['id']); } else { echo $value['std']; } ?> " /> </p> <?php break; case 'textarea': ?> <?php $valuex = $value['id']; $valuey = stripslashes($valuex); $video_code = get_option($valuey); ?> <div class="description"><?php echo $value['name']; ?> </div> <p><textarea name="<?php echo $valuey; ?> " class="mytext" cols="40%" rows="8" /><?php if (get_option($valuey) != "") { echo stripslashes($video_code); } else { echo $value['std']; } ?> </textarea></p> <?php break; default: ?> <?php break; } ?> <?php } ?> <p class="submit"> <input name="save" type="submit" class="sbutton button-primary" value="<?php _e("Save setting", TEMPLATE_DOMAIN); ?> " /> <input type="hidden" name="action" value="save12" /> </p> </form> <form method="post"> <p class="submit"> <input name="reset" type="submit" class="sbutton button-primary" value="<?php _e("Reset setting", TEMPLATE_DOMAIN); ?> " /> <input type="hidden" name="action" value="reset12" /> </p> </form> </div> </div> </div> </div><!-- end tabc --> <div id="reset-box"> <form method="post"> <div class="submit"> <input name="reset" type="submit" class="sbutton button-secondary" onclick="return confirm('Are you sure you want to delete all images and reset all text options?. This action cannot be restore.')" value="Delete all images and reset all text options" /> <input type="hidden" name="action" value="resetall" /> <?php _e("by pressing this reset button, all your uploaded services images and saved text settings will be deleted.", TEMPLATE_DOMAIN); ?> </div> </form> </div> </div> </div> <?php }
public function form_file() { $sub_dir = remove_tags2($_REQUEST['sub_dir']); if (!$sub_dir) { $sub_dir = 'media/member/'; } //어떤 에러페이지가 있어도 해당 값은 계속 넘겨줘야 함(취약점 문제를 계속 확인 하기 위해) $this->assigns['sub_dir'] = $sub_dir; $this->assigns['which'] = $_REQUEST['which']; if (array_key_exists('file', $_FILES)) { //Get the file information $max_width = "300"; if (array_key_exists('r_width', $_REQUEST) && array_key_exists('r_height', $_REQUEST)) { $this->tpl_name = "form_file_300"; $thumb_width = $_REQUEST['r_width']; // Width of thumbnail image $thumb_height = $_REQUEST['r_height']; $resize_width = $_REQUEST['r_width']; $resize_height = $_REQUEST['r_height']; $max_width = $_REQUEST['r_width']; } else { $thumb_width = "200"; // Width of thumbnail image $thumb_height = "200"; $resize_width = "200"; $resize_height = "200"; } // 재업로드를 한다면 다시 삭제해준다. if (array_key_exists('large_image', $_POST)) { $large_image = $this->settings->root_path . $_POST["large_image"]; if (file_exists($large_image)) { unlink($large_image); } } $userfile_name = $_FILES['file']['name']; $userfile_tmp = $_FILES['file']['tmp_name']; $userfile_size = $_FILES['file']['size']; // $userfile_type = $_FILES['file']['type']; $filename = basename($_FILES['file']['name']); $file_ext = strtolower(substr($filename, strrpos($filename, '.') + 1)); $tmp_filename = 'resize_temp' . strtotime(date('Y-m-d H:i:s')) . '.' . $file_ext; //단지 JPG, PNG, GIF 만 허용 가능함 if (!empty($_FILES['file']) && $_FILES['file']['error'] == 0) { //실제 이미지 확인 list($imagewidth, $imageheight, $imageType) = getimagesize($userfile_tmp); $userfile_type = image_type_to_mime_type($imageType); //단지 JPG, PNG, GIF 만 허용 가능함 $ext_loop = false; foreach ($this->settings->allowed_image_types as $mime_type => $ext) { if (is_array($ext)) { for ($i = 0; $i < sizeof($ext); $i++) { //echo $userfile_type.' '.$mime_type.' => '.$file_ext.' '.$ext[$i].'</br>'; if ($userfile_type == $mime_type && $file_ext == $ext[$i]) { $file_type = 0; $ext_loop = true; break; } else { $file_type = 1; } } if ($ext_loop) { break; } } else { if ($userfile_type == $mime_type && $file_ext == $ext) { $file_type = 0; break; } else { $file_type = 1; } } } //JPG, PNG, GIF 가 아니라면 if ($file_type == 1) { $this->assigns['error_str'] = "그림파일이 아닙니다."; return; } //이미지 허용 크기를 벗어남 if ($userfile_size > $this->settings->max_file * 1048576) { $this->assigns['error_str'] = "파일 사이즈 " . $this->settings->max_file . "MB 이하의 파일만 업로드 할 수 있습니다."; return; } } else { //이미지에 에러가 있음 $this->assigns['error_str'] = "이미지 데이터 오류가 났습니다. 다시 업로드해 주세요."; return; } //업로드를 변경 했다면 if (isset($_FILES['file']['name'])) { if ($sub_dir == 'media/member/') { $sub_large_image_location = 'media/temp/' . $tmp_filename; } else { $minus_base_nm = str_replace(basename($sub_dir), '', $sub_dir); if ($minus_base_nm == 'media/startup/') { $sub_large_image_location = $minus_base_nm . $tmp_filename; } else { $sub_large_image_location = 'media/temp/' . $tmp_filename; } } $large_image_location = $this->settings->root_path . $sub_large_image_location; move_uploaded_file($userfile_tmp, $large_image_location); $width = getWidth($large_image_location); $height = getHeight($large_image_location); if ($width > $max_width) { $scale = $max_width / $width; $uploaded = resizeImage($large_image_location, $width, $height, $scale); } else { $scale = 1; $uploaded = resizeImage($large_image_location, $width, $height, $scale); } } //이미지 사이즈가 작으면 선택영역을 최대로 한다. $temp_width = getWidth($uploaded); $temp_height = getHeight($uploaded); if ($thumb_height == $thumb_width) { if ($temp_width < $thumb_width) { $resize_width = $temp_width; } if ($temp_height < $thumb_height) { $resize_height = $temp_height; } if ($resize_width > $resize_height) { $resize_width = $resize_height; } else { $resize_height = $resize_width; } } else { //둘 다 현재 이미지 보다 큰 경우 if ($resize_height > $temp_height && $resize_width > $temp_width) { $resize_width = $temp_width; $resize_height = $temp_height; if ($resize_width > $resize_height) { $resize_width = $resize_height * ($thumb_width / $thumb_height); } else { $resize_height = $resize_width * ($thumb_height / $thumb_width); } } else { if ($resize_height <= $temp_height && $resize_width >= $temp_width) { $resize_width = $temp_width; $resize_height = $temp_width * ($thumb_height / $thumb_width); } else { if ($resize_width <= $temp_width && $resize_height >= $temp_height) { $resize_height = $temp_height; $resize_width = $temp_height * ($thumb_width / $thumb_height); } else { echo "*********" . $resize_width . ' ' . $temp_width . '-----' . $resize_height . ' ' . $temp_height; } } } } if (file_exists($large_image_location)) { $large_photo_exists = $large_image_location; $current_large_image_width = getWidth($large_image_location); $current_large_image_height = getHeight($large_image_location); } else { $large_photo_exists = ""; $thumb_photo_exists = ""; } $this->assigns['current_large_image_width'] = $current_large_image_width; $this->assigns['current_large_image_height'] = $current_large_image_height; $this->assigns['thumb_width'] = $thumb_width; $this->assigns['thumb_height'] = $thumb_height; $this->assigns['resize_width'] = $resize_width; $this->assigns['resize_height'] = $resize_height; $this->assigns['large_photo_exists'] = $large_photo_exists; $this->assigns['sub_large_image_location'] = '/' . $sub_large_image_location; } //업로드를 변경 했다면 if (array_key_exists('thumb_width', $_REQUEST)) { //Get the new coordinates to crop the image. $start = strpos($sub_dir, "/", 6) + 1; $end = strpos($sub_dir, "/", strpos($sub_dir, "/", 6) + 1); $length = $end - $start; $temp_size_str = substr($sub_dir, $start, $length); $x1 = $_POST["x1"]; $y1 = $_POST["y1"]; $x2 = $_POST["x2"]; $y2 = $_POST["y2"]; $w = $_POST["w"]; $h = $_POST["h"]; $thumb_width = $_POST["thumb_width"]; // if($sub_dir == 'media/member/'){ // $tmp_thumbnail = $sub_dir.$_SESSION['s']['id'].".jpg"; // }else{ // // $tmp_thumbnail = $sub_dir; // } $tmp_thumbnail = 'resize_temp' . strtotime(date('Y-m-d H:i:s')) . '.' . jpg; //취약점 보안 if (array_key_exists('large_image', $_POST)) { $low_str = strtolower($_POST["large_image"]); for ($i = 0; $i < sizeof($this->settings->weak_part); $i++) { $pattern = '/^\\/' . $this->settings->weak_part[$i] . '\\/resize_temp[0-9]+.(jpg|gif|jpeg|png)$/'; if (preg_match($pattern, $low_str, $match)) { break; } } } $thumb_image = $this->settings->root_path . 'media/temp/' . $tmp_thumbnail; $large_image = $this->settings->root_path . $_POST["large_image"]; $scale = $thumb_width / $w; resizeThumbnailImage($thumb_image, $large_image, $w, $h, $x1, $y1, $scale); //리사이즈용 임시 이미지 삭제 if (file_exists($large_image)) { unlink($large_image); } $this->assigns['thumbnail'] = '/media/temp/' . $tmp_thumbnail; } $this->assigns['r_width'] = $_REQUEST['r_width']; $this->assigns['r_height'] = $_REQUEST['r_height']; }
$source = imagecreatefromgif($image); break; case "image/pjpeg": case "image/jpeg": case "image/jpg": $source = imagecreatefromjpeg($image); break; case "image/png": case "image/x-png": $source = imagecreatefrompng($image); break; } imagecopyresampled($newImage, $source, 0, 0, 0, 0, $newImageWidth, $newImageHeight, $imagewidth, $imageheight); switch ($imageType) { case "image/gif": imagegif($newImage, $thumb); break; case "image/pjpeg": case "image/jpeg": case "image/jpg": imagejpeg($newImage, $thumb, 100); break; case "image/png": case "image/x-png": imagepng($newImage, $thumb); break; } return $thumb; } resizeThumbnailImage($thumb, $image, $scale, array('width' => 64, 'height' => 64));
function wpmudev_custom_homepage_admin() { global $themename, $blog_id, $allowed_image_types, $allowed_image_ext, $image_ext; ?> <div class="wrap" id="wrap-admin"> <div class="custom-homepage" id="content-admin"> <?php screen_icon('upload'); echo "<h2>" . $themename . __(' Homepage Settings', TEMPLATE_DOMAIN) . "</h2>"; ?> <br /> <?php $gallery_folder = "thumb"; if (is_multisite()) { $check_if_folder = WP_CONTENT_DIR . '/blogs.dir/' . $blog_id . "/" . $gallery_folder; } else { $check_if_folder = WP_CONTENT_DIR . "/" . $gallery_folder; } //echo $check_if_folder; /////////////////////////////////////////////////////You can alter these options/////////////////////////// if (is_dir($check_if_folder)) { if (is_multisite()) { $tpl_url = site_url(); $ptp = get_template(); $upload_dir = "files"; // The directory for the images to be saved in $upload_path = WP_CONTENT_DIR . '/blogs.dir/' . $blog_id . "/" . $gallery_folder . "/"; $upload_path_blogid = WP_CONTENT_DIR . '/blogs.dir/' . $blog_id; $upload_path_check = WP_CONTENT_DIR . '/blogs.dir/' . $blog_id . "/" . $gallery_folder; $ttpl = get_template_directory_uri(); $ttpl_url = site_url(); $upload_url = $ttpl_url . "/wp-content/blogs.dir/" . $blog_id . "/" . $gallery_folder; $ttpl_path = $ttpl_url . "/wp-content/blogs.dir/" . $blog_id . "/" . $gallery_folder; } else { $tpl_url = get_site_url(); $ptp = get_template(); $upload_dir = "files"; // The directory for the images to be saved in $upload_path = WP_CONTENT_DIR . "/" . $gallery_folder . "/"; $upload_path_check = WP_CONTENT_DIR . '/' . $gallery_folder; $ttpl = get_template_directory_uri(); $ttpl_url = site_url(); $upload_url = $ttpl_url . "/wp-content/" . $gallery_folder; $ttpl_path = $ttpl_url . "/wp-content/" . $gallery_folder; } } else { // new path for new versions $uploads = wp_upload_dir(); $upload_files_path = get_option('upload_path'); global $blog_id; $tpl_url = get_site_url(); $ptp = get_template(); $uploads_folder = "thumb"; $upload_path = $uploads['basedir'] . '/' . $uploads_folder . "/"; $upload_path_check = $uploads['basedir'] . '/' . $uploads_folder; $ttpl = get_template_directory_uri(); $ttpl_url = site_url(); //Create the upload directory with the right permissions if it doesn't exist if (!is_dir($upload_path_check)) { mkdir($upload_path_check, 0777); chmod($upload_path_check, 0777); } $upload_url_trim = str_replace(WP_CONTENT_DIR, "", $uploads['basedir']); //echo $upload_url_trim; if (substr($upload_url_trim, -1) == '/') { $upload_url_trim = rtrim($upload_url_trim, '/'); } $ttpl_path = WP_CONTENT_URL . $upload_url_trim . '/' . $uploads_folder; $upload_url = WP_CONTENT_URL . $upload_url_trim . '/' . $uploads_folder; } /////////////////////////////////////////////////////////////////////////////////// // start images upload and crop /////////////////////////////////////////////////////////////////////////////////// $normal_image_name = "top_header_normal.jpg"; $large_image_name = "top_header.jpg"; // New name of the large image $thumb_image_name = "top_header_crop.jpg"; // New name of the thumbnail image $max_file = "1000000"; // Approx 1MB $max_width = "800"; // Max width allowed for the large image $thumb_width = "300"; // Width of thumbnail image $thumb_height = "100"; // Height of thumbnail image //Image Locations $normal_image_location = $upload_path . $normal_image_name; $large_image_location = $upload_path . $large_image_name; $thumb_image_location = $upload_path . $thumb_image_name; //Check to see if any images with the same names already exist if (file_exists($large_image_location)) { if (file_exists($thumb_image_location)) { $thumb_photo_exists = "<img src=\"" . $upload_path . $thumb_image_name . "\" alt=\"Thumbnail Image\"/>"; } else { $thumb_photo_exists = ""; } $large_photo_exists = "<img src=\"" . $upload_path . $large_image_name . "\" alt=\"Large Image\"/>"; } else { $large_photo_exists = ""; $thumb_photo_exists = ""; } // normal photo check if (file_exists($normal_image_location)) { $normal_photo_exists = "<img src=\"" . $upload_path . $normal_image_name . "\" alt=\"Large Image\"/>"; } else { $normal_photo_exists = ""; } /////////////////////////////////////////////////////////////////////////////// // if upload with crop features /////////////////////////////////////////////////////////////////////////////// if (isset($_POST["upload"])) { //Get the file information $userfile_name = $_FILES['image']['name']; $userfile_type = $_FILES['image']['type']; $userfile_tmp = $_FILES['image']['tmp_name']; $userfile_size = $_FILES['image']['size']; $filename = basename($_FILES['image']['name']); $file_ext = substr($filename, strrpos($filename, '.') + 1); //Only process if the file is a JPG and below the allowed limit if (!empty($_FILES["image"]) && $_FILES['image']['error'] == 0) { foreach ($allowed_image_types as $mime_type => $ext) { //loop through the specified image types and if they match the extension then break out //everything is ok so go and check file size if ($file_ext == $ext && $userfile_type == $mime_type) { $error = ""; break; } else { $error = __("Only", TEMPLATE_DOMAIN) . "<strong>" . $image_ext . "</strong>" . __("images accepted for upload", TEMPLATE_DOMAIN) . "<br />"; } } if ($userfile_size > $max_file) { $error = __("ONLY images under 1MB are accepted for upload", TEMPLATE_DOMAIN); } } else { $error = __("Select an image for upload", TEMPLATE_DOMAIN); } //Everything is ok, so we can upload the image. if (strlen($error) == 0) { if (isset($_FILES['image']['name'])) { move_uploaded_file($userfile_tmp, $large_image_location); chmod($large_image_location, 0777); $width = getWidth($large_image_location); $height = getHeight($large_image_location); //Scale the image if it is greater than the width set above if ($width > $max_width) { $scale = $max_width / $width; $uploaded = resizeImage($large_image_location, $width, $height, $scale); } else { $scale = 1; $uploaded = resizeImage($large_image_location, $width, $height, $scale); } //Delete the thumbnail file so the user can create a new one if (file_exists($thumb_image_location)) { unlink($thumb_image_location); } } //Refresh the page to show the new uploaded image print '<meta http-equiv="Pragma" content="no-cache">'; echo "<h4 id=\"loading-bar\">Please wait..Your Image Currently Processing</h4>"; echo '<img src="' . get_template_directory_uri() . '/_inc/admin/loading_bar.gif' . '">'; print "<meta http-equiv=\"refresh\" content=\"1;url={$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php\">"; print "<script>"; print " self.location='{$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php&#tab1';"; print "</script>"; exit; } } //echo admin_url( 'themes.php?page=custom-homepage#tab1' ); /////////////////////////////////////////////////////////////////////////////// // if upload with no crop features /////////////////////////////////////////////////////////////////////////////// if (isset($_POST["normal-upload"])) { //Get the file information $userfile_name = $_FILES['image']['name']; $userfile_type = $_FILES['image']['type']; $userfile_tmp = $_FILES['image']['tmp_name']; $userfile_size = $_FILES['image']['size']; $filename = basename($_FILES['image']['name']); $file_ext = substr($filename, strrpos($filename, '.') + 1); //Only process if the file is a JPG and below the allowed limit if (!empty($_FILES["image"]) && $_FILES['image']['error'] == 0) { foreach ($allowed_image_types as $mime_type => $ext) { //loop through the specified image types and if they match the extension then break out //everything is ok so go and check file size if ($file_ext == $ext && $userfile_type == $mime_type) { $error = ""; break; } else { $error = __("Only", TEMPLATE_DOMAIN) . "<strong>" . $image_ext . "</strong>" . __("images accepted for upload", TEMPLATE_DOMAIN) . "<br />"; } } if ($userfile_size > $max_file) { $error = __("ONLY images under 1MB are accepted for upload", TEMPLATE_DOMAIN); } } else { $error = __("Select an image for upload", TEMPLATE_DOMAIN); } //Everything is ok, so we can upload the image. if (strlen($error) == 0) { if (isset($_FILES['image']['name'])) { move_uploaded_file($userfile_tmp, $normal_image_location); chmod($normal_image_location, 0777); //Delete the thumbnail file so the user can create a new one if (file_exists($thumb_image_location)) { unlink($thumb_image_location); } } //Refresh the page to show the new uploaded image print '<meta http-equiv="Pragma" content="no-cache">'; echo "<h4 id=\"loading-bar\">Please wait..Your Image Currently Processing</h4>"; echo '<img src="' . get_template_directory_uri() . '/_inc/admin/loading_bar.gif' . '">'; print "<meta http-equiv=\"refresh\" content=\"1;url={$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php\">"; print "<script>"; print " self.location='{$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php&#tab1';"; print "</script>"; exit; } } if (isset($_POST["upload_thumbnail"]) && strlen($large_photo_exists) > 0) { //Get the new coordinates to crop the image. $x1 = $_POST["x1"]; $y1 = $_POST["y1"]; $x2 = $_POST["x2"]; $y2 = $_POST["y2"]; $w = $_POST["w"]; $h = $_POST["h"]; //Scale the image to the thumb_width set above $scale = $thumb_width / $w; $cropped = resizeThumbnailImage($thumb_image_location, $large_image_location, $w, $h, $x1, $y1, $scale); //Reload the page again to view the thumbnail //Refresh the page to show the new uploaded image print '<meta http-equiv="Pragma" content="no-cache">'; echo "<h4 id=\"loading-bar\">Please wait..Your Image Currently Processing</h4>"; echo '<img src="' . get_template_directory_uri() . '/_inc/admin/loading_bar.gif' . '">'; print "<meta http-equiv=\"refresh\" content=\"3;url={$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php&#tab1\">"; exit; } ?> <?php //Only display the javacript if an image has been uploaded if (strlen($large_photo_exists) > 0) { $current_large_image_width = getWidth($large_image_location); $current_large_image_height = getHeight($large_image_location); ?> <script type="text/javascript"> function preview(img, selection) { var scaleX = <?php echo $thumb_width; ?> / selection.width; var scaleY = <?php echo $thumb_height; ?> / selection.height; $('#thumbnail + div > img').css({ width: Math.round(scaleX * <?php echo $current_large_image_width; ?> ) + 'px', height: Math.round(scaleY * <?php echo $current_large_image_height; ?> ) + 'px', marginLeft: '-' + Math.round(scaleX * selection.x1) + 'px', marginTop: '-' + Math.round(scaleY * selection.y1) + 'px' }); $('#x1').val(selection.x1); $('#y1').val(selection.y1); $('#x2').val(selection.x2); $('#y2').val(selection.y2); $('#w').val(selection.width); $('#h').val(selection.height); } $(document).ready(function () { $('#save_thumb').click(function() { var x1 = $('#x1').val(); var y1 = $('#y1').val(); var x2 = $('#x2').val(); var y2 = $('#y2').val(); var w = $('#w').val(); var h = $('#h').val(); if(x1=="" || y1=="" || x2=="" || y2=="" || w=="" || h==""){ alert("You must make a selection first"); return false; }else{ return true; } }); }); function selectionStart(img, selection) { width:300;height:100 } $(window).load(function () { $('#thumbnail').imgAreaSelect({ onSelectStart: selectionStart, resizable: true, x1: 20, y1: 20, x2: 320, y2: 120, aspectRatio: '3:1', onSelectChange: preview }); }); </script> <?php } ?> <?php global $themename, $shortname; if (isset($_REQUEST['resetall']) && $_REQUEST['resetall']) { echo '<div id="message" class="updated fade"><p><strong>' . __('All images deleted and settings reset', TEMPLATE_DOMAIN) . '</strong></p></div>'; } ?> <?php global $themename, $shortname, $options1; if (isset($_REQUEST['saved']) && $_REQUEST['saved']) { echo '<div id="message" class="updated fade"><p><strong>' . $themename . __(' settings saved', TEMPLATE_DOMAIN) . '</strong></p></div>'; } if (isset($_REQUEST['reset']) && $_REQUEST['reset']) { echo '<div id="message" class="updated fade"><p><strong>' . $themename . __(' settings reset', TEMPLATE_DOMAIN) . '</strong></p></div>'; } ?> <div id="tab1" class="option-box"> <div id="top-content-admin"> <h5><?php _e('Blog Top Header Image Settings - ' . $thumb_width . ' x ' . $thumb_height, TEMPLATE_DOMAIN); ?> </h5> </div> <?php if (isset($_POST["delete_thumbnail"])) { unlink("{$upload_path}/{$large_image_name}"); unlink("{$upload_path}/{$thumb_image_name}"); print "<script>"; print " self.location='{$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php"; print "</script>"; echo "<h4 id='loading-bar'>" . __('Your Cropped Image Currently Deleting', TEMPLATE_DOMAIN) . "</h4>"; print "<meta http-equiv=\"refresh\" content=\"2;url={$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php\">"; exit; } if (isset($_POST["delete_normal_upload"])) { unlink("{$upload_path}/{$normal_image_name}"); print "<script>"; print " self.location='{$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php"; print "</script>"; echo "<h4 id='loading-bar'>" . __('Your Image Currently Deleting', TEMPLATE_DOMAIN) . "</h4>"; print "<meta http-equiv=\"refresh\" content=\"2;url={$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php\">"; exit; } ?> <?php //Display error message if there are any if (isset($error) && strlen($error) > 0) { echo "<p class=\"uperror\"><strong>" . _('Error! ', TEMPLATE_DOMAIN) . "</strong> " . $error . "</p>"; } if (strlen($large_photo_exists) > 0 && strlen($thumb_photo_exists) > 0) { echo __("<p><strong>NOTE:</strong> Successfully uploaded and cropped thumbnail, if you want to delete or replace the image, just press delete and reupload and recrop the new image</p>", TEMPLATE_DOMAIN); echo "<img src=\"{$upload_url}/{$thumb_image_name}\" class=\"timg\"/>"; echo "<form name='thumbnail' action='' method='post'>\r\n <input type='submit' name='delete_thumbnail' class='button-secondary' value='" . __("Delete This Image", TEMPLATE_DOMAIN) . "' /></form>"; } else { if (strlen($normal_photo_exists) > 0) { echo __("<p><strong>NOTE:</strong> Successfully uploaded the image, if you want to delete or replace the image, just press delete and reupload the new image</p>", TEMPLATE_DOMAIN); echo "<img src=\"{$upload_url}/{$normal_image_name}\" class=\"timg\"/>"; echo "<form name='thumbnail' action='' method='post'>\r\n <input type='submit' name='delete_normal_upload' class='button-secondary' value='" . __("Delete This Image", TEMPLATE_DOMAIN) . "' /></form>"; } } if (strlen($large_photo_exists) > 0 && strlen($thumb_photo_exists) > 0) { } else { if (strlen($large_photo_exists) > 0) { ?> <h4><?php _e('Crop And Save Your Thumbnail', TEMPLATE_DOMAIN); ?> </h4> <div> <img src="<?php echo "{$upload_url}/{$large_image_name}"; ?> " style="clear: both; margin-bottom: 10px;" id="thumbnail" alt="Create Thumbnail" /> <br style="clear:both;"/> <form name="thumbnail" action="" method="post"> <input type="hidden" name="x1" value="" id="x1" /> <input type="hidden" name="y1" value="" id="y1" /> <input type="hidden" name="x2" value="" id="x2" /> <input type="hidden" name="y2" value="" id="y2" /> <input type="hidden" name="w" value="" id="w" /> <input type="hidden" name="h" value="" id="h" /> <input type="submit" name="upload_thumbnail" class='button-secondary' value="<?php _e('Save Thumbnail', TEMPLATE_DOMAIN); ?> " id="save_thumb" /> </form> </div> <?php } } ?> <?php if (strlen($large_photo_exists) == 0 && strlen($normal_photo_exists) == 0) { ?> <h4><strong><?php _e('Upload Photo', TEMPLATE_DOMAIN); ?> </strong></h4> <form name="photo" class="photo" enctype="multipart/form-data" action="<?php echo $_SERVER['REQUEST_URI']; ?> " method="post"> <input type="file" name="image" size="50" class="upz" /> <p><input type="submit" class='button-secondary' name="upload" value="<?php _e('Upload and Crop', TEMPLATE_DOMAIN); ?> " /> <input type="submit" name="normal-upload" class='button-secondary' value="<?php _e('Upload', TEMPLATE_DOMAIN); ?> " /></p> <p class="onlyjpg">* <?php _e("only", TEMPLATE_DOMAIN); ?> <?php echo $image_ext; ?> <?php _e("image file are allowed", TEMPLATE_DOMAIN); ?> </p> </form> <?php } ?> <form method="post" id="option-mz-form"> <h4><?php _e('Homepage Top Header Settings', TEMPLATE_DOMAIN); ?> </h4> <?php foreach ($options1 as $value) { if ($value['inblock'] == "home-top-header" && $value['type'] == "text" && (isset($value['custom']) && $value['custom'] == "colourpicker")) { ?> <div class="pwrap"> <p><?php echo $value['name']; ?> :</p> <p><input name="<?php echo $value['id']; ?> " class="ops-colour" id="vtrColorPicker" type="<?php echo $value['type']; ?> " value="<?php if (get_option($value['id']) != "") { echo get_option($value['id']); } else { echo $value['std']; } ?> " /></p></div> <?php } elseif ($value['inblock'] == "home-top-header" && $value['type'] == "text") { ?> <div class="pwrap"> <p><?php echo $value['name']; ?> :</p> <p><input name="<?php echo $value['id']; ?> " class="ops-text" id="<?php echo $value['id']; ?> " type="<?php echo $value['type']; ?> " value="<?php if (get_option($value['id']) != "") { echo get_option($value['id']); } else { echo $value['std']; } ?> " /></p></div> <?php } elseif ($value['inblock'] == "home-top-header" && $value['type'] == "select") { ?> <div class="pwrap"> <p><?php echo $value['name']; ?> :</p> <p><select name="<?php echo $value['id']; ?> " class="ops-select" id="<?php echo $value['id']; ?> "> <?php foreach ($value['options'] as $option1) { ?> <option<?php if (get_option($value['id']) == $option1) { echo ' selected="selected"'; } elseif ($option1 == $value['std']) { echo ' selected="selected"'; } ?> ><?php echo $option1; ?> </option> <?php } ?> </select> </p></div> <?php } elseif ($value['inblock'] == "home-intro" && $value['type'] == "textarea") { ?> <div class="pwrap"> <p><?php echo $value['name']; ?> :</p> <?php $valuex = $value['id']; $valuey = stripslashes($valuex); $video_code = get_option($valuey); ?> <p><textarea class="ops-area" name="<?php echo $valuey; ?> " cols="40%" rows="8" /><?php if (get_option($valuey) != "") { echo stripslashes($video_code); } else { echo $value['std']; } ?> </textarea> </p></div> <?php } } ?> <input name="save" class='button-primary' type="submit" value="<?php echo esc_attr(__('Save Links', TEMPLATE_DOMAIN)); ?> " /> <input type="hidden" name="action" value="save" /> </form> <form method="post"> <input name="reset" type="submit" class='button-primary' value="<?php echo esc_attr(__('Reset Links', TEMPLATE_DOMAIN)); ?> " /> <input type="hidden" name="action" value="reset" /> </form> </div> <?php $normal_image_name = "intro_normal.jpg"; $large_image_name = "intro.jpg"; // New name of the large image $thumb_image_name = "intro_crop.jpg"; // New name of the thumbnail image $max_file = "1000000"; // Approx 1MB $max_width = "800"; // Max width allowed for the large image $thumb_width = "350"; // Width of thumbnail image $thumb_height = "250"; // Height of thumbnail image //Image Locations $normal_image_location = $upload_path . $normal_image_name; $large_image_location = $upload_path . $large_image_name; $thumb_image_location = $upload_path . $thumb_image_name; //Check to see if any images with the same names already exist if (file_exists($large_image_location)) { if (file_exists($thumb_image_location)) { $thumb_photo_exists = "<img src=\"" . $upload_path . $thumb_image_name . "\" alt=\"Thumbnail Image\"/>"; } else { $thumb_photo_exists = ""; } $large_photo_exists = "<img src=\"" . $upload_path . $large_image_name . "\" alt=\"Large Image\"/>"; } else { $large_photo_exists = ""; $thumb_photo_exists = ""; } //Check normal image if (file_exists($normal_image_location)) { $normal_photo_exists = "<img src=\"" . $upload_path . $normal_image_name . "\" alt=\"Large Image\"/>"; } else { $normal_photo_exists = ""; } //crop image if (isset($_POST["upload2"])) { //Get the file information $userfile_name = $_FILES['image']['name']; $userfile_tmp = $_FILES['image']['tmp_name']; $userfile_type = $_FILES['image']['type']; $userfile_size = $_FILES['image']['size']; $filename = basename($_FILES['image']['name']); $file_ext = substr($filename, strrpos($filename, '.') + 1); //Only process if the file is a JPG and below the allowed limit if (!empty($_FILES["image"]) && $_FILES['image']['error'] == 0) { foreach ($allowed_image_types as $mime_type => $ext) { //loop through the specified image types and if they match the extension then break out //everything is ok so go and check file size if ($file_ext == $ext && $userfile_type == $mime_type) { $error = ""; break; } else { $error = __("Only", TEMPLATE_DOMAIN) . "<strong>" . $image_ext . "</strong>" . __("images accepted for upload", TEMPLATE_DOMAIN) . "<br />"; } } if ($userfile_size > $max_file) { $error = __("ONLY images under 1MB are accepted for upload", TEMPLATE_DOMAIN); } } else { $error = __("Select an image for upload", TEMPLATE_DOMAIN); } //Everything is ok, so we can upload the image. if (strlen($error) == 0) { if (isset($_FILES['image']['name'])) { move_uploaded_file($userfile_tmp, $large_image_location); chmod($large_image_location, 0777); $width = getWidth($large_image_location); $height = getHeight($large_image_location); //Scale the image if it is greater than the width set above if ($width > $max_width) { $scale = $max_width / $width; $uploaded = resizeImage($large_image_location, $width, $height, $scale); } else { $scale = 1; $uploaded = resizeImage($large_image_location, $width, $height, $scale); } //Delete the thumbnail file so the user can create a new one if (file_exists($thumb_image_location)) { unlink($thumb_image_location); } } //Refresh the page to show the new uploaded image print '<meta http-equiv="Pragma" content="no-cache">'; echo "<h4 id=\"loading-bar\">Please wait..Your Image Currently Processing</h4>"; echo '<img src="' . get_template_directory_uri() . '/_inc/admin/loading_bar.gif' . '">'; print "<meta http-equiv=\"refresh\" content=\"1;url={$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php\">"; print "<script>"; print " self.location='{$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php&#tab2';"; print "</script>"; exit; } } //normal image if (isset($_POST["normal-upload2"])) { //Get the file information $userfile_name = $_FILES['image']['name']; $userfile_tmp = $_FILES['image']['tmp_name']; $userfile_type = $_FILES['image']['type']; $userfile_size = $_FILES['image']['size']; $filename = basename($_FILES['image']['name']); $file_ext = substr($filename, strrpos($filename, '.') + 1); //Only process if the file is a JPG and below the allowed limit if (!empty($_FILES["image"]) && $_FILES['image']['error'] == 0) { foreach ($allowed_image_types as $mime_type => $ext) { //loop through the specified image types and if they match the extension then break out //everything is ok so go and check file size if ($file_ext == $ext && $userfile_type == $mime_type) { $error = ""; break; } else { $error = __("Only", TEMPLATE_DOMAIN) . "<strong>" . $image_ext . "</strong>" . __("images accepted for upload", TEMPLATE_DOMAIN) . "<br />"; } } if ($userfile_size > $max_file) { $error = __("ONLY images under 1MB are accepted for upload", TEMPLATE_DOMAIN); } } else { $error = __("Select an image for upload", TEMPLATE_DOMAIN); } //Everything is ok, so we can upload the image. if (strlen($error) == 0) { if (isset($_FILES['image']['name'])) { move_uploaded_file($userfile_tmp, $normal_image_location); chmod($normal_image_location, 0777); //Delete the thumbnail file so the user can create a new one if (file_exists($thumb_image_location)) { unlink($thumb_image_location); } } //Refresh the page to show the new uploaded image print '<meta http-equiv="Pragma" content="no-cache">'; echo "<h4 id=\"loading-bar\">Please wait..Your Image Currently Processing</h4>"; echo '<img src="' . get_template_directory_uri() . '/_inc/admin/loading_bar.gif' . '">'; print "<meta http-equiv=\"refresh\" content=\"1;url={$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php\">"; print "<script>"; print " self.location='{$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php&#tab2';"; print "</script>"; exit; } } if (isset($_POST["upload_thumbnail2"]) && strlen($large_photo_exists) > 0) { //Get the new coordinates to crop the image. $x1 = $_POST["x1"]; $y1 = $_POST["y1"]; $x2 = $_POST["x2"]; $y2 = $_POST["y2"]; $w = $_POST["w"]; $h = $_POST["h"]; //Scale the image to the thumb_width set above $scale = $thumb_width / $w; $cropped = resizeThumbnailImage($thumb_image_location, $large_image_location, $w, $h, $x1, $y1, $scale); //Reload the page again to view the thumbnail //Refresh the page to show the new uploaded image print '<meta http-equiv="Pragma" content="no-cache">'; echo "<h4 id=\"loading-bar\">Please wait..Your Image Currently Processing</h4>"; echo '<img src="' . get_template_directory_uri() . '/_inc/admin/loading_bar.gif' . '">'; print "<meta http-equiv=\"refresh\" content=\"1;url={$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php\">"; print "<script>"; print " self.location='{$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php&#tab2';"; print "</script>"; exit; } ?> <?php //Only display the javacript if an image has been uploaded if (strlen($large_photo_exists) > 0) { $current_large_image_width = getWidth($large_image_location); $current_large_image_height = getHeight($large_image_location); ?> <script type="text/javascript"> function preview(img, selection) { var scaleX = <?php echo $thumb_width; ?> / selection.width; var scaleY = <?php echo $thumb_height; ?> / selection.height; $('#thumbnail2 + div > img').css({ width: Math.round(scaleX * <?php echo $current_large_image_width; ?> ) + 'px', height: Math.round(scaleY * <?php echo $current_large_image_height; ?> ) + 'px', marginLeft: '-' + Math.round(scaleX * selection.x1) + 'px', marginTop: '-' + Math.round(scaleY * selection.y1) + 'px' }); $('#x1').val(selection.x1); $('#y1').val(selection.y1); $('#x2').val(selection.x2); $('#y2').val(selection.y2); $('#w').val(selection.width); $('#h').val(selection.height); } $(document).ready(function () { $('#save_thumb').click(function() { var x1 = $('#x1').val(); var y1 = $('#y1').val(); var x2 = $('#x2').val(); var y2 = $('#y2').val(); var w = $('#w').val(); var h = $('#h').val(); if(x1=="" || y1=="" || x2=="" || y2=="" || w=="" || h==""){ alert("You must make a selection first"); return false; }else{ return true; } }); }); function selectionStart(img, selection) { width:350;height:250 } $(window).load(function () { $('#thumbnail2').imgAreaSelect({ onSelectStart: selectionStart, resizable: true, x1: 20, y1: 20, x2: 370, y2: 270, aspectRatio: '7:5', onSelectChange: preview }); }); </script> <?php } ?> <?php global $themename, $shortname, $options2; if (isset($_REQUEST['saved2']) && $_REQUEST['saved2']) { echo '<div id="message" class="updated fade"><p><strong>' . $themename . __(' settings saved.', TEMPLATE_DOMAIN) . '</strong></p></div>'; } if (isset($_REQUEST['reset2']) && $_REQUEST['reset2']) { echo '<div id="message" class="updated fade"><p><strong>' . $themename . __(' settings reset.', TEMPLATE_DOMAIN) . '</strong></p></div>'; } ?> <div id="tab2" class="option-box"> <div id="top-content-admin"> <h5><?php _e('Blog Intro Header Image Settings - ' . $thumb_width . ' x ' . $thumb_height, TEMPLATE_DOMAIN); ?> </h5> </div> <?php if (isset($_POST["delete_thumbnail2"])) { unlink("{$upload_path}/{$large_image_name}"); unlink("{$upload_path}/{$thumb_image_name}"); print "<script>"; print " self.location='{$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php"; print "</script>"; echo "<h4 id='loading-bar'>" . __('Your Cropped Image Currently Deleting', TEMPLATE_DOMAIN) . "</h4>"; print "<meta http-equiv=\"refresh\" content=\"2;url={$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php\">"; exit; } if (isset($_POST["delete_normal_upload2"])) { unlink("{$upload_path}/{$normal_image_name}"); print "<script>"; print " self.location='{$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php"; print "</script>"; echo "<h4 id='loading-bar'>" . __('Your Image Currently Deleting', TEMPLATE_DOMAIN) . "</h4>"; print "<meta http-equiv=\"refresh\" content=\"2;url={$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php\">"; exit; } ?> <?php //Display error message if there are any if (isset($error) && strlen($error) > 0) { echo "<p class=\"uperror\"><strong>" . __('Error! ', TEMPLATE_DOMAIN) . "</strong>" . $error . "</p>"; } if (strlen($large_photo_exists) > 0 && strlen($thumb_photo_exists) > 0) { echo __("<p><strong>NOTE:</strong> Successfully uploaded and cropped thumbnail, if you want to delete or replace the image, just press delete and reupload and recrop the new image</p>", TEMPLATE_DOMAIN); echo "<img src=\"{$upload_url}/{$thumb_image_name}\" class=\"timg\"/>"; echo "<form name='thumbnail' action='' method='post'>\r\n <input type='submit' name='delete_thumbnail2' class='button-secondary' value='" . __("Delete This Image", TEMPLATE_DOMAIN) . "' /></form>"; } else { if (strlen($normal_photo_exists) > 0) { echo __("<p><strong>NOTE:</strong> Successfully uploaded image, if you want to delete or replace the image, just press delete and reupload the new image</p>", TEMPLATE_DOMAIN); echo "<img src=\"{$upload_url}/{$normal_image_name}\" class=\"timg\"/>"; echo "<form name='thumbnail' action='' method='post'>\r\n <input type='submit' name='delete_normal_upload2' class='button-secondary' value='" . __("Delete This Image", TEMPLATE_DOMAIN) . "' /></form>"; } } if (strlen($large_photo_exists) > 0 && strlen($thumb_photo_exists) > 0) { } else { if (strlen($large_photo_exists) > 0) { ?> <h4><?php _e('Crop And Save Your Thumbnail', TEMPLATE_DOMAIN); ?> </h4> <div> <img src="<?php echo "{$upload_url}/{$large_image_name}"; ?> " style="clear: both; margin-bottom: 10px;" id="thumbnail2" alt="Create Thumbnail" /> <br style="clear:both;"/> <form name="thumbnail" action="" method="post"> <input type="hidden" name="x1" value="" id="x1" /> <input type="hidden" name="y1" value="" id="y1" /> <input type="hidden" name="x2" value="" id="x2" /> <input type="hidden" name="y2" value="" id="y2" /> <input type="hidden" name="w" value="" id="w" /> <input type="hidden" name="h" value="" id="h" /> <input type="submit" class='button-secondary' name="upload_thumbnail2" value="<?php _e('Save Thumbnail', TEMPLATE_DOMAIN); ?> " id="save_thumb" /> </form> </div> <?php } } ?> <?php if (strlen($large_photo_exists) == 0 && strlen($normal_photo_exists) == 0) { ?> <h4><?php _e('Upload Photo', TEMPLATE_DOMAIN); ?> </h4> <form name="photo" class="photo" enctype="multipart/form-data" action="<?php echo $_SERVER['REQUEST_URI']; ?> " method="post"> <input type="file" name="image" class="upz" size="50" /> <p><input type="submit" class='button-secondary' name="upload2" value="<?php _e('Upload and Crop', TEMPLATE_DOMAIN); ?> " /> <input type="submit" name="normal-upload2" class='button-secondary' value="<?php _e('Upload', TEMPLATE_DOMAIN); ?> " /></p> <p class="onlyjpg">* <?php _e("only", TEMPLATE_DOMAIN); ?> <?php echo $image_ext; ?> <?php _e("image file are allowed", TEMPLATE_DOMAIN); ?> </p> </form> <?php } ?> <form method="post" id="option-mz-form"> <h4><?php _e('Homepage Intro Settings', TEMPLATE_DOMAIN); ?> </h4> <?php foreach ($options2 as $value) { if ($value['inblock'] == "home-intro" && $value['type'] == "text" && (isset($value['custom']) && $value['custom'] == "colourpicker")) { ?> <div class="pwrap"> <p><?php echo $value['name']; ?> :</p> <p><input name="<?php echo $value['id']; ?> " class="ops-colour" id="vtrColorPicker" type="<?php echo $value['type']; ?> " value="<?php if (get_option($value['id']) != "") { echo get_option($value['id']); } else { echo $value['std']; } ?> " /></p></div> <?php } elseif ($value['inblock'] == "home-intro" && $value['type'] == "text") { ?> <div class="pwrap"> <p><?php echo $value['name']; ?> :</p> <p><input name="<?php echo $value['id']; ?> " class="ops-text" id="<?php echo $value['id']; ?> " type="<?php echo $value['type']; ?> " value="<?php if (get_option($value['id']) != "") { echo get_option($value['id']); } else { echo $value['std']; } ?> " /></p></div> <?php } elseif ($value['inblock'] == "home-intro" && $value['type'] == "select") { ?> <div class="pwrap"> <p><?php echo $value['name']; ?> :</p> <p><select name="<?php echo $value['id']; ?> " class="ops-select" id="<?php echo $value['id']; ?> "> <?php foreach ($value['options'] as $option2) { ?> <option<?php if (get_option($value['id']) == $option2) { echo ' selected="selected"'; } elseif ($option2 == $value['std']) { echo ' selected="selected"'; } ?> ><?php echo $option2; ?> </option> <?php } ?> </select> </p></div> <?php } elseif ($value['inblock'] == "home-intro" && $value['type'] == "textarea") { ?> <div class="pwrap"> <p><?php echo $value['name']; ?> :</p> <?php $valuex = $value['id']; $valuey = stripslashes($valuex); $video_code = get_option($valuey); ?> <p> <textarea class="ops-area" name="<?php echo $valuey; ?> " cols="40%" rows="8" /><?php if (get_option($valuey) != "") { echo stripslashes($video_code); } else { echo $value['std']; } ?> </textarea> </p> </div> <?php } } ?> <input name="save" type="submit" class='button-primary' value="<?php echo esc_attr(__('Save Text', TEMPLATE_DOMAIN)); ?> " /> <input type="hidden" name="action" value="save2" /> </form> <form method="post"> <input name="reset" type="submit" class='button-primary' value="<?php echo esc_attr(__('Reset Text', TEMPLATE_DOMAIN)); ?> " /> <input type="hidden" name="action" value="reset2" /> </form> </div> <?php $normal_image_name = "box_cat_left_normal.jpg"; $large_image_name = "box_cat_left.jpg"; // New name of the large image $thumb_image_name = "box_cat_left_crop.jpg"; // New name of the thumbnail image $max_file = "1000000"; // Approx 1MB $max_width = "800"; // Max width allowed for the large image $thumb_width = "290"; // Width of thumbnail image $thumb_height = "150"; // Height of thumbnail image //Image Locations $normal_image_location = $upload_path . $normal_image_name; $large_image_location = $upload_path . $large_image_name; $thumb_image_location = $upload_path . $thumb_image_name; //Check to see if any images with the same names already exist if (file_exists($large_image_location)) { if (file_exists($thumb_image_location)) { $thumb_photo_exists = "<img src=\"" . $upload_path . $thumb_image_name . "\" alt=\"Thumbnail Image\"/>"; } else { $thumb_photo_exists = ""; } $large_photo_exists = "<img src=\"" . $upload_path . $large_image_name . "\" alt=\"Large Image\"/>"; } else { $large_photo_exists = ""; $thumb_photo_exists = ""; } //Check normal image if (file_exists($normal_image_location)) { $normal_photo_exists = "<img src=\"" . $upload_path . $normal_image_name . "\" alt=\"Large Image\"/>"; } else { $normal_photo_exists = ""; } if (isset($_POST["upload3"])) { //Get the file information $userfile_name = $_FILES['image']['name']; $userfile_tmp = $_FILES['image']['tmp_name']; $userfile_type = $_FILES['image']['type']; $userfile_size = $_FILES['image']['size']; $filename = basename($_FILES['image']['name']); $file_ext = substr($filename, strrpos($filename, '.') + 1); //Only process if the file is a JPG and below the allowed limit if (!empty($_FILES["image"]) && $_FILES['image']['error'] == 0) { foreach ($allowed_image_types as $mime_type => $ext) { //loop through the specified image types and if they match the extension then break out //everything is ok so go and check file size if ($file_ext == $ext && $userfile_type == $mime_type) { $error = ""; break; } else { $error = __("Only", TEMPLATE_DOMAIN) . "<strong>" . $image_ext . "</strong>" . __("images accepted for upload", TEMPLATE_DOMAIN) . "<br />"; } } if ($userfile_size > $max_file) { $error = __("ONLY images under 1MB are accepted for upload", TEMPLATE_DOMAIN); } } else { $error = __("Select an image for upload", TEMPLATE_DOMAIN); } //Everything is ok, so we can upload the image. if (strlen($error) == 0) { if (isset($_FILES['image']['name'])) { move_uploaded_file($userfile_tmp, $large_image_location); chmod($large_image_location, 0777); $width = getWidth($large_image_location); $height = getHeight($large_image_location); //Scale the image if it is greater than the width set above if ($width > $max_width) { $scale = $max_width / $width; $uploaded = resizeImage($large_image_location, $width, $height, $scale); } else { $scale = 1; $uploaded = resizeImage($large_image_location, $width, $height, $scale); } //Delete the thumbnail file so the user can create a new one if (file_exists($thumb_image_location)) { unlink($thumb_image_location); } } //Refresh the page to show the new uploaded image print '<meta http-equiv="Pragma" content="no-cache">'; echo "<h4 id=\"loading-bar\">Please wait..Your Image Currently Processing</h4>"; echo '<img src="' . get_template_directory_uri() . '/_inc/admin/loading_bar.gif' . '">'; print "<meta http-equiv=\"refresh\" content=\"1;url={$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php\">"; print "<script>"; print " self.location='{$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php&#tab3';"; print "</script>"; exit; } } //normal upload if (isset($_POST["normal-upload3"])) { //Get the file information $userfile_name = $_FILES['image']['name']; $userfile_tmp = $_FILES['image']['tmp_name']; $userfile_type = $_FILES['image']['type']; $userfile_size = $_FILES['image']['size']; $filename = basename($_FILES['image']['name']); $file_ext = substr($filename, strrpos($filename, '.') + 1); //Only process if the file is a JPG and below the allowed limit if (!empty($_FILES["image"]) && $_FILES['image']['error'] == 0) { foreach ($allowed_image_types as $mime_type => $ext) { //loop through the specified image types and if they match the extension then break out //everything is ok so go and check file size if ($file_ext == $ext && $userfile_type == $mime_type) { $error = ""; break; } else { $error = __("Only", TEMPLATE_DOMAIN) . "<strong>" . $image_ext . "</strong>" . __("images accepted for upload", TEMPLATE_DOMAIN) . "<br />"; } } if ($userfile_size > $max_file) { $error = __("ONLY images under 1MB are accepted for upload", TEMPLATE_DOMAIN); } } else { $error = __("Select an image for upload", TEMPLATE_DOMAIN); } //Everything is ok, so we can upload the image. if (strlen($error) == 0) { if (isset($_FILES['image']['name'])) { move_uploaded_file($userfile_tmp, $normal_image_location); chmod($normal_image_location, 0777); //Delete the thumbnail file so the user can create a new one if (file_exists($thumb_image_location)) { unlink($thumb_image_location); } } //Refresh the page to show the new uploaded image print '<meta http-equiv="Pragma" content="no-cache">'; echo "<h4 id=\"loading-bar\">Please wait..Your Image Currently Processing</h4>"; echo '<img src="' . get_template_directory_uri() . '/_inc/admin/loading_bar.gif' . '">'; print "<meta http-equiv=\"refresh\" content=\"1;url={$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php\">"; print "<script>"; print " self.location='{$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php&#tab3';"; print "</script>"; exit; } } if (isset($_POST["upload_thumbnail3"]) && strlen($large_photo_exists) > 0) { //Get the new coordinates to crop the image. $x1 = $_POST["x1"]; $y1 = $_POST["y1"]; $x2 = $_POST["x2"]; $y2 = $_POST["y2"]; $w = $_POST["w"]; $h = $_POST["h"]; //Scale the image to the thumb_width set above $scale = $thumb_width / $w; $cropped = resizeThumbnailImage($thumb_image_location, $large_image_location, $w, $h, $x1, $y1, $scale); //Reload the page again to view the thumbnail //Refresh the page to show the new uploaded image print '<meta http-equiv="Pragma" content="no-cache">'; echo "<h4 id=\"loading-bar\">Please wait..Your Image Currently Processing</h4>"; echo '<img src="' . get_template_directory_uri() . '/_inc/admin/loading_bar.gif' . '">'; print "<meta http-equiv=\"refresh\" content=\"1;url={$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php\">"; print "<script>"; print " self.location='{$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php&#tab3';"; print "</script>"; exit; } ?> <?php //Only display the javacript if an image has been uploaded if (strlen($large_photo_exists) > 0) { $current_large_image_width = getWidth($large_image_location); $current_large_image_height = getHeight($large_image_location); ?> <script type="text/javascript"> function preview(img, selection) { var scaleX = <?php echo $thumb_width; ?> / selection.width; var scaleY = <?php echo $thumb_height; ?> / selection.height; $('#thumbnail3 + div > img').css({ width: Math.round(scaleX * <?php echo $current_large_image_width; ?> ) + 'px', height: Math.round(scaleY * <?php echo $current_large_image_height; ?> ) + 'px', marginLeft: '-' + Math.round(scaleX * selection.x1) + 'px', marginTop: '-' + Math.round(scaleY * selection.y1) + 'px' }); $('#x1').val(selection.x1); $('#y1').val(selection.y1); $('#x2').val(selection.x2); $('#y2').val(selection.y2); $('#w').val(selection.width); $('#h').val(selection.height); } $(document).ready(function () { $('#save_thumb').click(function() { var x1 = $('#x1').val(); var y1 = $('#y1').val(); var x2 = $('#x2').val(); var y2 = $('#y2').val(); var w = $('#w').val(); var h = $('#h').val(); if(x1=="" || y1=="" || x2=="" || y2=="" || w=="" || h==""){ alert("You must make a selection first"); return false; }else{ return true; } }); }); function selectionStart(img, selection) { width:290;height:150 } $(window).load(function () { $('#thumbnail3').imgAreaSelect({ onSelectStart: selectionStart, resizable: true, x1: 20, y1: 20, x2: 310, y2: 170, aspectRatio: '29:15', onSelectChange: preview }); }); </script> <?php } ?> <?php global $themename, $shortname, $options3; if (isset($_REQUEST['saved3']) && $_REQUEST['saved3']) { echo '<div id="message" class="updated fade"><p><strong>' . $themename . __(' settings saved.', TEMPLATE_DOMAIN) . '</strong></p></div>'; } if (isset($_REQUEST['reset3']) && $_REQUEST['reset3']) { echo '<div id="message" class="updated fade"><p><strong>' . $themename . __(' settings reset.', TEMPLATE_DOMAIN) . '</strong></p></div>'; } ?> <div id="tab3" class="option-box"> <div id="top-content-admin"> <h5><?php _e('Blog Box Left Image Settings - ' . $thumb_width . ' x ' . $thumb_height, TEMPLATE_DOMAIN); ?> </h5> </div> <?php if (isset($_POST["delete_thumbnail3"])) { unlink("{$upload_path}/{$large_image_name}"); unlink("{$upload_path}/{$thumb_image_name}"); print "<script>"; print " self.location='{$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php"; print "</script>"; echo "<h4 id='loading-bar'>" . __('Your Cropped Image Currently Deleting', TEMPLATE_DOMAIN) . "</h4>"; print "<meta http-equiv=\"refresh\" content=\"2;url={$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php\">"; exit; } if (isset($_POST["delete_normal_upload3"])) { unlink("{$upload_path}/{$normal_image_name}"); print "<script>"; print " self.location='{$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php"; print "</script>"; echo "<h4 id='loading-bar'>" . __('Your Image Currently Deleting', TEMPLATE_DOMAIN) . "</h4>"; print "<meta http-equiv=\"refresh\" content=\"2;url={$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php\">"; exit; } ?> <?php //Display error message if there are any if (isset($error) && strlen($error) > 0) { echo "<p class=\"uperror\"><strong>" . __('Error! ', TEMPLATE_DOMAIN) . "</strong>" . $error . "</p>"; } if (strlen($large_photo_exists) > 0 && strlen($thumb_photo_exists) > 0) { echo __("<p><strong>NOTE:</strong> Successfully uploaded and cropped thumbnail, if you want to delete or replace the image, just press delete and reupload and recrop the new image</p>", TEMPLATE_DOMAIN); echo "<img src=\"{$upload_url}/{$thumb_image_name}\" class=\"timg\"/>"; echo "<form name='thumbnail' action='' method='post'>\r\n <input type='submit' name='delete_thumbnail3' class='button-secondary' value='" . __("Delete This Image", TEMPLATE_DOMAIN) . "' /></form>"; } else { if (strlen($normal_photo_exists) > 0) { echo __("<p><strong>NOTE:</strong> Successfully uploaded image, if you want to delete or replace the image, just press delete and reupload the new image</p>", TEMPLATE_DOMAIN); echo "<img src=\"{$upload_url}/{$normal_image_name}\" class=\"timg\"/>"; echo "<form name='thumbnail' action='' method='post'>\r\n <input type='submit' name='delete_normal_upload3' class='button-secondary' value='" . __("Delete This Image", TEMPLATE_DOMAIN) . "' /></form>"; } } if (strlen($large_photo_exists) > 0 && strlen($thumb_photo_exists) > 0) { } else { if (strlen($large_photo_exists) > 0) { ?> <h4><?php _e('Crop And Save Your Thumbnail', TEMPLATE_DOMAIN); ?> </h4> <div> <img src="<?php echo "{$upload_url}/{$large_image_name}"; ?> " style="clear: both; margin-bottom: 10px;" id="thumbnail3" alt="Create Thumbnail" /> <br style="clear:both;"/> <form name="thumbnail" action="" method="post"> <input type="hidden" name="x1" value="" id="x1" /> <input type="hidden" name="y1" value="" id="y1" /> <input type="hidden" name="x2" value="" id="x2" /> <input type="hidden" name="y2" value="" id="y2" /> <input type="hidden" name="w" value="" id="w" /> <input type="hidden" name="h" value="" id="h" /> <input type="submit" class='button-secondary' name="upload_thumbnail3" value="<?php _e('Save Thumbnail', TEMPLATE_DOMAIN); ?> " id="save_thumb" /> </form> </div> <hr /> <?php } } ?> <?php if (strlen($large_photo_exists) == 0 && strlen($normal_photo_exists) == 0) { ?> <h4><?php _e('Upload Photo', TEMPLATE_DOMAIN); ?> </h4> <form name="photo" class="photo" enctype="multipart/form-data" action="<?php echo $_SERVER['REQUEST_URI']; ?> " method="post"> <input type="file" name="image" class="upz" size="50" /> <p><input type="submit" class='button-secondary' name="upload3" value="<?php _e('Upload and Crop', TEMPLATE_DOMAIN); ?> " /> <input type="submit" name="normal-upload3" class='button-secondary' value="<?php _e('Upload', TEMPLATE_DOMAIN); ?> " /></p> <p class="onlyjpg">* <?php _e("only", TEMPLATE_DOMAIN); ?> <?php echo $image_ext; ?> <?php _e("image file are allowed", TEMPLATE_DOMAIN); ?> </p> </form> <?php } ?> <form method="post" id="option-mz-form"> <h4><?php _e('Homepage Box Left Settings', TEMPLATE_DOMAIN); ?> </h4> <?php foreach ($options3 as $value) { if ($value['inblock'] == "home-box1" && $value['type'] == "text" && (isset($value['custom']) && $value['custom'] == "colourpicker")) { ?> <div class="pwrap"> <p><?php echo $value['name']; ?> :</p> <p><input name="<?php echo $value['id']; ?> " class="ops-colour" id="vtrColorPicker" type="<?php echo $value['type']; ?> " value="<?php if (get_option($value['id']) != "") { echo get_option($value['id']); } else { echo $value['std']; } ?> " /></p></div> <?php } elseif ($value['inblock'] == "home-box1" && $value['type'] == "text") { ?> <div class="pwrap"> <p><?php echo $value['name']; ?> :</p> <p><input name="<?php echo $value['id']; ?> " class="ops-text" id="<?php echo $value['id']; ?> " type="<?php echo $value['type']; ?> " value="<?php if (get_option($value['id']) != "") { echo get_option($value['id']); } else { echo $value['std']; } ?> " /></p></div> <?php } elseif ($value['inblock'] == "home-box1" && $value['type'] == "select") { ?> <div class="pwrap"> <p><?php echo $value['name']; ?> :</p> <p><select name="<?php echo $value['id']; ?> " class="ops-select" id="<?php echo $value['id']; ?> "> <?php foreach ($value['options'] as $option3) { ?> <option<?php if (get_option($value['id']) == $option3) { echo ' selected="selected"'; } elseif ($option3 == $value['std']) { echo ' selected="selected"'; } ?> ><?php echo $option3; ?> </option> <?php } ?> </select> </p></div> <?php } elseif ($value['inblock'] == "home-box1" && $value['type'] == "textarea") { ?> <div class="pwrap"> <p><?php echo $value['name']; ?> :</p> <?php $valuex = $value['id']; $valuey = stripslashes($valuex); $video_code = get_option($valuey); ?> <p><textarea class="ops-area" name="<?php echo $valuey; ?> " cols="40%" rows="8" /><?php if (get_option($valuey) != "") { echo stripslashes($video_code); } else { echo $value['std']; } ?> </textarea> </p></div> <?php } } ?> <input name="save" type="submit" class='button-primary' value="<?php _e('Save Text', TEMPLATE_DOMAIN); ?> " /> <input type="hidden" name="action" value="save3" /> </form> <form method="post"> <input name="reset" type="submit" class='button-primary' value="<?php _e('Reset Text', TEMPLATE_DOMAIN); ?> " /> <input type="hidden" name="action" value="reset3" /> </form> </div> <?php $normal_image_name = "box_cat_center_normal.jpg"; $large_image_name = "box_cat_center.jpg"; // New name of the large image $thumb_image_name = "box_cat_center_crop.jpg"; // New name of the thumbnail image $max_file = "1000000"; // Approx 1MB $max_width = "800"; // Max width allowed for the large image $thumb_width = "290"; // Width of thumbnail image $thumb_height = "150"; // Height of thumbnail image //Image Locations $normal_image_location = $upload_path . $normal_image_name; $large_image_location = $upload_path . $large_image_name; $thumb_image_location = $upload_path . $thumb_image_name; //Check to see if any images with the same names already exist if (file_exists($large_image_location)) { if (file_exists($thumb_image_location)) { $thumb_photo_exists = "<img src=\"" . $upload_path . $thumb_image_name . "\" alt=\"Thumbnail Image\"/>"; } else { $thumb_photo_exists = ""; } $large_photo_exists = "<img src=\"" . $upload_path . $large_image_name . "\" alt=\"Large Image\"/>"; } else { $large_photo_exists = ""; $thumb_photo_exists = ""; } //Check normal image if (file_exists($normal_image_location)) { $normal_photo_exists = "<img src=\"" . $upload_path . $normal_image_name . "\" alt=\"Large Image\"/>"; } else { $normal_photo_exists = ""; } if (isset($_POST["upload4"])) { //Get the file information $userfile_name = $_FILES['image']['name']; $userfile_tmp = $_FILES['image']['tmp_name']; $userfile_type = $_FILES['image']['type']; $userfile_size = $_FILES['image']['size']; $filename = basename($_FILES['image']['name']); $file_ext = substr($filename, strrpos($filename, '.') + 1); //Only process if the file is a JPG and below the allowed limit if (!empty($_FILES["image"]) && $_FILES['image']['error'] == 0) { foreach ($allowed_image_types as $mime_type => $ext) { //loop through the specified image types and if they match the extension then break out //everything is ok so go and check file size if ($file_ext == $ext && $userfile_type == $mime_type) { $error = ""; break; } else { $error = __("Only", TEMPLATE_DOMAIN) . "<strong>" . $image_ext . "</strong>" . __("images accepted for upload", TEMPLATE_DOMAIN) . "<br />"; } } if ($userfile_size > $max_file) { $error = __("ONLY images under 1MB are accepted for upload", TEMPLATE_DOMAIN); } } else { $error = __("Select an image for upload", TEMPLATE_DOMAIN); } //Everything is ok, so we can upload the image. if (strlen($error) == 0) { if (isset($_FILES['image']['name'])) { move_uploaded_file($userfile_tmp, $large_image_location); chmod($large_image_location, 0777); $width = getWidth($large_image_location); $height = getHeight($large_image_location); //Scale the image if it is greater than the width set above if ($width > $max_width) { $scale = $max_width / $width; $uploaded = resizeImage($large_image_location, $width, $height, $scale); } else { $scale = 1; $uploaded = resizeImage($large_image_location, $width, $height, $scale); } //Delete the thumbnail file so the user can create a new one if (file_exists($thumb_image_location)) { unlink($thumb_image_location); } } //Refresh the page to show the new uploaded image print '<meta http-equiv="Pragma" content="no-cache">'; echo "<h4 id=\"loading-bar\">Please wait..Your Image Currently Processing</h4>"; echo '<img src="' . get_template_directory_uri() . '/_inc/admin/loading_bar.gif' . '">'; print "<meta http-equiv=\"refresh\" content=\"1;url={$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php\">"; print "<script>"; print " self.location='{$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php&#tab4';"; print "</script>"; exit; } } if (isset($_POST["normal-upload4"])) { //Get the file information $userfile_name = $_FILES['image']['name']; $userfile_tmp = $_FILES['image']['tmp_name']; $userfile_type = $_FILES['image']['type']; $userfile_size = $_FILES['image']['size']; $filename = basename($_FILES['image']['name']); $file_ext = substr($filename, strrpos($filename, '.') + 1); //Only process if the file is a JPG and below the allowed limit if (!empty($_FILES["image"]) && $_FILES['image']['error'] == 0) { foreach ($allowed_image_types as $mime_type => $ext) { //loop through the specified image types and if they match the extension then break out //everything is ok so go and check file size if ($file_ext == $ext && $userfile_type == $mime_type) { $error = ""; break; } else { $error = __("Only", TEMPLATE_DOMAIN) . "<strong>" . $image_ext . "</strong>" . __("images accepted for upload", TEMPLATE_DOMAIN) . "<br />"; } } if ($userfile_size > $max_file) { $error = __("ONLY images under 1MB are accepted for upload", TEMPLATE_DOMAIN); } } else { $error = __("Select an image for upload", TEMPLATE_DOMAIN); } //Everything is ok, so we can upload the image. if (strlen($error) == 0) { if (isset($_FILES['image']['name'])) { move_uploaded_file($userfile_tmp, $normal_image_location); chmod($normal_image_location, 0777); //Delete the thumbnail file so the user can create a new one if (file_exists($thumb_image_location)) { unlink($thumb_image_location); } } //Refresh the page to show the new uploaded image print '<meta http-equiv="Pragma" content="no-cache">'; echo "<h4 id=\"loading-bar\">Please wait..Your Image Currently Processing</h4>"; echo '<img src="' . get_template_directory_uri() . '/_inc/admin/loading_bar.gif' . '">'; print "<meta http-equiv=\"refresh\" content=\"1;url={$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php\">"; print "<script>"; print " self.location='{$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php&#tab4';"; print "</script>"; exit; } } if (isset($_POST["upload_thumbnail4"]) && strlen($large_photo_exists) > 0) { //Get the new coordinates to crop the image. $x1 = $_POST["x1"]; $y1 = $_POST["y1"]; $x2 = $_POST["x2"]; $y2 = $_POST["y2"]; $w = $_POST["w"]; $h = $_POST["h"]; //Scale the image to the thumb_width set above $scale = $thumb_width / $w; $cropped = resizeThumbnailImage($thumb_image_location, $large_image_location, $w, $h, $x1, $y1, $scale); //Reload the page again to view the thumbnail //Refresh the page to show the new uploaded image print '<meta http-equiv="Pragma" content="no-cache">'; echo "<h4 id=\"loading-bar\">Please wait..Your Image Currently Processing</h4>"; echo '<img src="' . get_template_directory_uri() . '/_inc/admin/loading_bar.gif' . '">'; print "<meta http-equiv=\"refresh\" content=\"1;url={$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php\">"; print "<script>"; print " self.location='{$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php&#tab4';"; print "</script>"; exit; } ?> <?php //Only display the javacript if an image has been uploaded if (strlen($large_photo_exists) > 0) { $current_large_image_width = getWidth($large_image_location); $current_large_image_height = getHeight($large_image_location); ?> <script type="text/javascript"> function preview(img, selection) { var scaleX = <?php echo $thumb_width; ?> / selection.width; var scaleY = <?php echo $thumb_height; ?> / selection.height; $('#thumbnail4 + div > img').css({ width: Math.round(scaleX * <?php echo $current_large_image_width; ?> ) + 'px', height: Math.round(scaleY * <?php echo $current_large_image_height; ?> ) + 'px', marginLeft: '-' + Math.round(scaleX * selection.x1) + 'px', marginTop: '-' + Math.round(scaleY * selection.y1) + 'px' }); $('#x1').val(selection.x1); $('#y1').val(selection.y1); $('#x2').val(selection.x2); $('#y2').val(selection.y2); $('#w').val(selection.width); $('#h').val(selection.height); } $(document).ready(function () { $('#save_thumb').click(function() { var x1 = $('#x1').val(); var y1 = $('#y1').val(); var x2 = $('#x2').val(); var y2 = $('#y2').val(); var w = $('#w').val(); var h = $('#h').val(); if(x1=="" || y1=="" || x2=="" || y2=="" || w=="" || h==""){ alert("You must make a selection first"); return false; }else{ return true; } }); }); function selectionStart(img, selection) { width:290;height:150 } $(window).load(function () { $('#thumbnail4').imgAreaSelect({ onSelectStart: selectionStart, resizable: true, x1: 20, y1: 20, x2: 310, y2: 170, aspectRatio: '29:15', onSelectChange: preview }); }); </script> <?php } ?> <?php global $themename, $shortname, $options4; if (isset($_REQUEST['saved4']) && $_REQUEST['saved4']) { echo '<div id="message" class="updated fade"><p><strong>' . $themename . __(' settings saved.', TEMPLATE_DOMAIN) . '</strong></p></div>'; } if (isset($_REQUEST['reset4']) && $_REQUEST['reset4']) { echo '<div id="message" class="updated fade"><p><strong>' . $themename . __(' settings reset.', TEMPLATE_DOMAIN) . '</strong></p></div>'; } ?> <div id="tab4" class="option-box"> <div id="top-content-admin"> <h5><?php _e('Blog Box Center Image Settings - ' . $thumb_width . ' x ' . $thumb_height, TEMPLATE_DOMAIN); ?> </h5> </div> <?php if (isset($_POST["delete_thumbnail4"])) { unlink("{$upload_path}/{$large_image_name}"); unlink("{$upload_path}/{$thumb_image_name}"); print "<script>"; print " self.location='{$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php"; print "</script>"; echo "<h4 id='loading-bar'>" . __('Your Cropped Image Currently Deleting', TEMPLATE_DOMAIN) . "</h4>"; print "<meta http-equiv=\"refresh\" content=\"2;url={$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php\">"; exit; } if (isset($_POST["delete_normal_upload4"])) { unlink("{$upload_path}/{$normal_image_name}"); print "<script>"; print " self.location='{$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php"; print "</script>"; echo "<h4 id='loading-bar'>" . __('Your Image Currently Deleting', TEMPLATE_DOMAIN) . "</h4>"; print "<meta http-equiv=\"refresh\" content=\"2;url={$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php\">"; exit; } ?> <?php //Display error message if there are any if (isset($error) && strlen($error) > 0) { echo "<p class=\"uperror\"><strong>" . __('Error! ', TEMPLATE_DOMAIN) . "</strong>" . $error . "</p>"; } if (strlen($large_photo_exists) > 0 && strlen($thumb_photo_exists) > 0) { echo __("<p><strong>NOTE:</strong> Successfully upload and crop thumbnail, if you want to delete or replace the image, just press delete and reupload and recrop the new image</p>", TEMPLATE_DOMAIN); echo "<img src=\"{$upload_url}/{$thumb_image_name}\" class=\"timg\"/>"; echo "<form name='thumbnail' action='' method='post'>\r\n <input type='submit' name='delete_thumbnail4' class='button-secondary' value='" . __("Delete This Image", TEMPLATE_DOMAIN) . "' /></form>"; } else { if (strlen($normal_photo_exists) > 0) { echo __("<p><strong>NOTE:</strong> Successfully uploaded image, if you want to delete or replace the image, just press delete and reupload the new image</p>", TEMPLATE_DOMAIN); echo "<img src=\"{$upload_url}/{$normal_image_name}\" class=\"timg\"/>"; echo "<form name='thumbnail' action='' method='post'>\r\n <input type='submit' name='delete_normal_upload4' class='button-secondary' value='" . __("Delete This Image", TEMPLATE_DOMAIN) . "' /></form>"; } } if (strlen($large_photo_exists) > 0 && strlen($thumb_photo_exists) > 0) { } else { if (strlen($large_photo_exists) > 0) { ?> <h4><?php _e('Crop And Save Your Thumbnail', TEMPLATE_DOMAIN); ?> </h4> <div> <img src="<?php echo "{$upload_url}/{$large_image_name}"; ?> " style="clear: both; margin-bottom: 10px;" id="thumbnail4" alt="Create Thumbnail" /> <br style="clear:both;"/> <form name="thumbnail" action="" method="post"> <input type="hidden" name="x1" value="" id="x1" /> <input type="hidden" name="y1" value="" id="y1" /> <input type="hidden" name="x2" value="" id="x2" /> <input type="hidden" name="y2" value="" id="y2" /> <input type="hidden" name="w" value="" id="w" /> <input type="hidden" name="h" value="" id="h" /> <input type="submit" class='button-secondary' name="upload_thumbnail4" value="<?php _e('Save Thumbnail', TEMPLATE_DOMAIN); ?> " id="save_thumb" /> </form> </div> <hr /> <?php } } ?> <?php if (strlen($large_photo_exists) == 0 && strlen($normal_photo_exists) == 0) { ?> <h4><?php _e('Upload Photo', TEMPLATE_DOMAIN); ?> </h4> <form name="photo" class="photo" enctype="multipart/form-data" action="<?php echo $_SERVER['REQUEST_URI']; ?> " method="post"> <input type="file" name="image" class="upz" size="50" /> <p><input type="submit" class='button-secondary' name="upload4" value="<?php _e('Upload and Crop', TEMPLATE_DOMAIN); ?> " /> <input type="submit" class='button-secondary' name="normal-upload4" value="<?php _e('Upload', TEMPLATE_DOMAIN); ?> " /></p> <p class="onlyjpg">* <?php _e("only", TEMPLATE_DOMAIN); ?> <?php echo $image_ext; ?> <?php _e("image file are allowed", TEMPLATE_DOMAIN); ?> </p> </form> <?php } ?> <form method="post" id="option-mz-form"> <h4><?php _e('Homepage Box Center Settings', TEMPLATE_DOMAIN); ?> </h4> <?php foreach ($options4 as $value) { if ($value['inblock'] == "home-box2" && $value['type'] == "text" && (isset($value['custom']) && $value['custom'] == "colourpicker")) { ?> <div class="pwrap"> <p><?php echo $value['name']; ?> :</p> <p><input name="<?php echo $value['id']; ?> " class="ops-colour" id="vtrColorPicker" type="<?php echo $value['type']; ?> " value="<?php if (get_option($value['id']) != "") { echo get_option($value['id']); } else { echo $value['std']; } ?> " /></p></div> <?php } elseif ($value['inblock'] == "home-box2" && $value['type'] == "text") { ?> <div class="pwrap"> <p><?php echo $value['name']; ?> :</p> <p><input name="<?php echo $value['id']; ?> " class="ops-text" id="<?php echo $value['id']; ?> " type="<?php echo $value['type']; ?> " value="<?php if (get_option($value['id']) != "") { echo get_option($value['id']); } else { echo $value['std']; } ?> " /></p></div> <?php } elseif ($value['inblock'] == "home-box2" && $value['type'] == "select") { ?> <div class="pwrap"> <p><?php echo $value['name']; ?> :</p> <p><select name="<?php echo $value['id']; ?> " class="ops-select" id="<?php echo $value['id']; ?> "> <?php foreach ($value['options'] as $option4) { ?> <option<?php if (get_option($value['id']) == $option4) { echo ' selected="selected"'; } elseif ($option3 == $value['std']) { echo ' selected="selected"'; } ?> ><?php echo $option4; ?> </option> <?php } ?> </select> </p></div> <?php } elseif ($value['inblock'] == "home-box2" && $value['type'] == "textarea") { ?> <div class="pwrap"> <p><?php echo $value['name']; ?> :</p> <?php $valuex = $value['id']; $valuey = stripslashes($valuex); $video_code = get_option($valuey); ?> <p><textarea class="ops-area" name="<?php echo $valuey; ?> " cols="40%" rows="8" /><?php if (get_option($valuey) != "") { echo stripslashes($video_code); } else { echo $value['std']; } ?> </textarea> </p></div> <?php } } ?> <input name="save" type="submit" class='button-primary' value="<?php echo esc_attr(__('Save Text', TEMPLATE_DOMAIN)); ?> " /> <input type="hidden" name="action" value="save4" /> </form> <form method="post"> <input name="reset" type="submit" class='button-primary' value="<?php echo esc_attr(__('Reset Text', TEMPLATE_DOMAIN)); ?> " /> <input type="hidden" name="action" value="reset4" /> </form> </div> <?php $normal_image_name = "box_cat_right_normal.jpg"; $large_image_name = "box_cat_right.jpg"; // New name of the large image $thumb_image_name = "box_cat_right_crop.jpg"; // New name of the thumbnail image $max_file = "1000000"; // Approx 1MB $max_width = "800"; // Max width allowed for the large image $thumb_width = "290"; // Width of thumbnail image $thumb_height = "150"; // Height of thumbnail image //Image Locations $normal_image_location = $upload_path . $normal_image_name; $large_image_location = $upload_path . $large_image_name; $thumb_image_location = $upload_path . $thumb_image_name; //Check to see if any images with the same names already exist if (file_exists($large_image_location)) { if (file_exists($thumb_image_location)) { $thumb_photo_exists = "<img src=\"" . $upload_path . $thumb_image_name . "\" alt=\"Thumbnail Image\"/>"; } else { $thumb_photo_exists = ""; } $large_photo_exists = "<img src=\"" . $upload_path . $large_image_name . "\" alt=\"Large Image\"/>"; } else { $large_photo_exists = ""; $thumb_photo_exists = ""; } //Check normal img if (file_exists($normal_image_location)) { $normal_photo_exists = "<img src=\"" . $upload_path . $normal_image_name . "\" alt=\"Large Image\"/>"; } else { $normal_photo_exists = ""; } if (isset($_POST["upload5"])) { //Get the file information $userfile_name = $_FILES['image']['name']; $userfile_tmp = $_FILES['image']['tmp_name']; $userfile_type = $_FILES['image']['type']; $userfile_size = $_FILES['image']['size']; $filename = basename($_FILES['image']['name']); $file_ext = substr($filename, strrpos($filename, '.') + 1); //Only process if the file is a JPG and below the allowed limit if (!empty($_FILES["image"]) && $_FILES['image']['error'] == 0) { foreach ($allowed_image_types as $mime_type => $ext) { //loop through the specified image types and if they match the extension then break out //everything is ok so go and check file size if ($file_ext == $ext && $userfile_type == $mime_type) { $error = ""; break; } else { $error = __("Only", TEMPLATE_DOMAIN) . "<strong>" . $image_ext . "</strong>" . __("images accepted for upload", TEMPLATE_DOMAIN) . "<br />"; } } if ($userfile_size > $max_file) { $error = __("ONLY images under 1MB are accepted for upload", TEMPLATE_DOMAIN); } } else { $error = __("Select an image for upload", TEMPLATE_DOMAIN); } //Everything is ok, so we can upload the image. if (strlen($error) == 0) { if (isset($_FILES['image']['name'])) { move_uploaded_file($userfile_tmp, $large_image_location); chmod($large_image_location, 0777); $width = getWidth($large_image_location); $height = getHeight($large_image_location); //Scale the image if it is greater than the width set above if ($width > $max_width) { $scale = $max_width / $width; $uploaded = resizeImage($large_image_location, $width, $height, $scale); } else { $scale = 1; $uploaded = resizeImage($large_image_location, $width, $height, $scale); } //Delete the thumbnail file so the user can create a new one if (file_exists($thumb_image_location)) { unlink($thumb_image_location); } } //Refresh the page to show the new uploaded image print '<meta http-equiv="Pragma" content="no-cache">'; echo "<h4 id=\"loading-bar\">Please wait..Your Image Currently Processing</h4>"; echo '<img src="' . get_template_directory_uri() . '/_inc/admin/loading_bar.gif' . '">'; print "<meta http-equiv=\"refresh\" content=\"1;url={$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php\">"; print "<script>"; print " self.location='{$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php&#tab5';"; print "</script>"; exit; } } // normal upload if (isset($_POST["normal-upload5"])) { //Get the file information $userfile_name = $_FILES['image']['name']; $userfile_tmp = $_FILES['image']['tmp_name']; $userfile_type = $_FILES['image']['type']; $userfile_size = $_FILES['image']['size']; $filename = basename($_FILES['image']['name']); $file_ext = substr($filename, strrpos($filename, '.') + 1); //Only process if the file is a JPG and below the allowed limit if (!empty($_FILES["image"]) && $_FILES['image']['error'] == 0) { foreach ($allowed_image_types as $mime_type => $ext) { //loop through the specified image types and if they match the extension then break out //everything is ok so go and check file size if ($file_ext == $ext && $userfile_type == $mime_type) { $error = ""; break; } else { $error = __("Only", TEMPLATE_DOMAIN) . "<strong>" . $image_ext . "</strong>" . __("images accepted for upload", TEMPLATE_DOMAIN) . "<br />"; } } if ($userfile_size > $max_file) { $error = __("ONLY images under 1MB are accepted for upload", TEMPLATE_DOMAIN); } } else { $error = __("Select an image for upload", TEMPLATE_DOMAIN); } //Everything is ok, so we can upload the image. if (strlen($error) == 0) { if (isset($_FILES['image']['name'])) { move_uploaded_file($userfile_tmp, $normal_image_location); chmod($normal_image_location, 0777); //Delete the thumbnail file so the user can create a new one if (file_exists($thumb_image_location)) { unlink($thumb_image_location); } } //Refresh the page to show the new uploaded image print '<meta http-equiv="Pragma" content="no-cache">'; echo "<h4 id=\"loading-bar\">Please wait..Your Image Currently Processing</h4>"; echo '<img src="' . get_template_directory_uri() . '/_inc/admin/loading_bar.gif' . '">'; print "<meta http-equiv=\"refresh\" content=\"1;url={$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php\">"; print "<script>"; print " self.location='{$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php&#tab5';"; print "</script>"; exit; } } if (isset($_POST["upload_thumbnail5"]) && strlen($large_photo_exists) > 0) { //Get the new coordinates to crop the image. $x1 = $_POST["x1"]; $y1 = $_POST["y1"]; $x2 = $_POST["x2"]; $y2 = $_POST["y2"]; $w = $_POST["w"]; $h = $_POST["h"]; //Scale the image to the thumb_width set above $scale = $thumb_width / $w; $cropped = resizeThumbnailImage($thumb_image_location, $large_image_location, $w, $h, $x1, $y1, $scale); //Reload the page again to view the thumbnail //Refresh the page to show the new uploaded image print '<meta http-equiv="Pragma" content="no-cache">'; echo "<h4 id=\"loading-bar\">Please wait..Your Image Currently Processing</h4>"; echo '<img src="' . get_template_directory_uri() . '/_inc/admin/loading_bar.gif' . '">'; print "<meta http-equiv=\"refresh\" content=\"1;url={$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php\">"; print "<script>"; print " self.location='{$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php&#tab5';"; print "</script>"; exit; } ?> <?php //Only display the javacript if an image has been uploaded if (strlen($large_photo_exists) > 0) { $current_large_image_width = getWidth($large_image_location); $current_large_image_height = getHeight($large_image_location); ?> <script type="text/javascript"> function preview(img, selection) { var scaleX = <?php echo $thumb_width; ?> / selection.width; var scaleY = <?php echo $thumb_height; ?> / selection.height; $('#thumbnail5 + div > img').css({ width: Math.round(scaleX * <?php echo $current_large_image_width; ?> ) + 'px', height: Math.round(scaleY * <?php echo $current_large_image_height; ?> ) + 'px', marginLeft: '-' + Math.round(scaleX * selection.x1) + 'px', marginTop: '-' + Math.round(scaleY * selection.y1) + 'px' }); $('#x1').val(selection.x1); $('#y1').val(selection.y1); $('#x2').val(selection.x2); $('#y2').val(selection.y2); $('#w').val(selection.width); $('#h').val(selection.height); } $(document).ready(function () { $('#save_thumb').click(function() { var x1 = $('#x1').val(); var y1 = $('#y1').val(); var x2 = $('#x2').val(); var y2 = $('#y2').val(); var w = $('#w').val(); var h = $('#h').val(); if(x1=="" || y1=="" || x2=="" || y2=="" || w=="" || h==""){ alert("You must make a selection first"); return false; }else{ return true; } }); }); function selectionStart(img, selection) { width:290;height:150 } $(window).load(function () { $('#thumbnail5').imgAreaSelect({ onSelectStart: selectionStart, resizable: true, x1: 20, y1: 20, x2: 310, y2: 170, aspectRatio: '29:15', onSelectChange: preview }); }); </script> <?php } ?> <?php global $themename, $shortname, $options5; if (isset($_REQUEST['saved5']) && $_REQUEST['saved5']) { echo '<div id="message" class="updated fade"><p><strong>' . $themename . __(' settings saved.', TEMPLATE_DOMAIN) . '</strong></p></div>'; } if (isset($_REQUEST['reset5']) && $_REQUEST['reset5']) { echo '<div id="message" class="updated fade"><p><strong>' . $themename . __(' settings reset.', TEMPLATE_DOMAIN) . '</strong></p></div>'; } ?> <div id="tab5" class="option-box"> <div id="top-content-admin"> <h5><?php _e('Blog Box Right Image Settings - ' . $thumb_width . ' x ' . $thumb_height, TEMPLATE_DOMAIN); ?> </h5> </div> <?php if (isset($_POST["delete_thumbnail5"])) { unlink("{$upload_path}/{$large_image_name}"); unlink("{$upload_path}/{$thumb_image_name}"); print "<script>"; print " self.location='{$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php';"; print "</script>"; print "<script>"; print " self.location='{$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php';"; print "</script>"; exit; } if (isset($_POST["delete_normal_upload5"])) { unlink("{$upload_path}/{$normal_image_name}"); print "<script>"; print " self.location='{$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php';"; print "</script>"; print "<script>"; print " self.location='{$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php';"; print "</script>"; exit; } ?> <?php //Display error message if there are any if (isset($error) && strlen($error) > 0) { echo "<p class=\"uperror\"><strong>" . __('Error! ', TEMPLATE_DOMAIN) . "</strong>" . $error . "</p>"; } if (strlen($large_photo_exists) > 0 && strlen($thumb_photo_exists) > 0) { echo __("<p><strong>NOTE:</strong> Successfully uploaded and cropped thumbnail, if you want to delete or replace the image, just press delete and reupload and recrop the new image</p>", TEMPLATE_DOMAIN); echo "<img src=\"{$upload_url}/{$thumb_image_name}\" class=\"timg\"/>"; echo "<form name='thumbnail' action='' method='post'>\r\n <input type='submit' name='delete_thumbnail5' class='button-secondary' value='" . __("Delete This Image", TEMPLATE_DOMAIN) . "' /></form>"; } else { if (strlen($normal_photo_exists) > 0) { echo __("<p><strong>NOTE:</strong> Successfully uploaded images, if you want to delete or replace the image, just press delete and reupload the new image</p>", TEMPLATE_DOMAIN); echo "<img src=\"{$upload_url}/{$normal_image_name}\" class=\"timg\"/>"; echo "<form name='thumbnail' action='' method='post'>\r\n <input type='submit' name='delete_normal_upload5' class='button-secondary' value='" . __("Delete This Image", TEMPLATE_DOMAIN) . "' /></form>"; } } if (strlen($large_photo_exists) > 0 && strlen($thumb_photo_exists) > 0) { } else { if (strlen($large_photo_exists) > 0) { ?> <h4><?php _e('Crop And Save Your Thumbnail', TEMPLATE_DOMAIN); ?> </h4> <div> <img src="<?php echo "{$upload_url}/{$large_image_name}"; ?> " style="clear: both; margin-bottom: 10px;" id="thumbnail5" alt="Create Thumbnail" /> <br style="clear:both;"/> <form name="thumbnail" action="" method="post"> <input type="hidden" name="x1" value="" id="x1" /> <input type="hidden" name="y1" value="" id="y1" /> <input type="hidden" name="x2" value="" id="x2" /> <input type="hidden" name="y2" value="" id="y2" /> <input type="hidden" name="w" value="" id="w" /> <input type="hidden" name="h" value="" id="h" /> <input type="submit" name="upload_thumbnail5" class='button-secondary' value="<?php _e('Save Thumbnail', TEMPLATE_DOMAIN); ?> " id="save_thumb" /> </form> </div> <hr /> <?php } } ?> <?php if (strlen($large_photo_exists) == 0 && strlen($normal_photo_exists) == 0) { ?> <h4><?php _e('Upload Photo', TEMPLATE_DOMAIN); ?> </h4> <form name="photo" class="photo" enctype="multipart/form-data" action="<?php echo $_SERVER['REQUEST_URI']; ?> " method="post"> <input type="file" name="image" class="upz" size="50" /> <p><input type="submit" class='button-secondary' name="upload5" value="<?php _e('Upload and Crop', TEMPLATE_DOMAIN); ?> " /> <input type="submit" class='button-secondary' name="normal-upload5" value="<?php _e('Upload', TEMPLATE_DOMAIN); ?> " /></p> <p class="onlyjpg">* <?php _e("only", TEMPLATE_DOMAIN); ?> <?php echo $image_ext; ?> <?php _e("image file are allowed", TEMPLATE_DOMAIN); ?> </p> </form> <?php } ?> <form method="post" id="option-mz-form"> <h4><?php _e('Homepage Box Right Settings', TEMPLATE_DOMAIN); ?> </h4> <?php foreach ($options5 as $value) { if ($value['inblock'] == "home-box3" && $value['type'] == "text" && (isset($value['custom']) && $value['custom'] == "colourpicker")) { ?> <div class="pwrap"> <p><?php echo $value['name']; ?> :</p> <p><input name="<?php echo $value['id']; ?> " class="ops-colour" id="vtrColorPicker" type="<?php echo $value['type']; ?> " value="<?php if (get_option($value['id']) != "") { echo get_option($value['id']); } else { echo $value['std']; } ?> " /></p></div> <?php } elseif ($value['inblock'] == "home-box3" && $value['type'] == "text") { ?> <div class="pwrap"> <p><?php echo $value['name']; ?> :</p> <p><input name="<?php echo $value['id']; ?> " class="ops-text" id="<?php echo $value['id']; ?> " type="<?php echo $value['type']; ?> " value="<?php if (get_option($value['id']) != "") { echo get_option($value['id']); } else { echo $value['std']; } ?> " /></p></div> <?php } elseif ($value['inblock'] == "home-box3" && $value['type'] == "select") { ?> <div class="pwrap"> <p><?php echo $value['name']; ?> :</p> <p><select name="<?php echo $value['id']; ?> " class="ops-select" id="<?php echo $value['id']; ?> "> <?php foreach ($value['options'] as $option5) { ?> <option<?php if (get_option($value['id']) == $option5) { echo ' selected="selected"'; } elseif ($option3 == $value['std']) { echo ' selected="selected"'; } ?> ><?php echo $option5; ?> </option> <?php } ?> </select> </p></div> <?php } elseif ($value['inblock'] == "home-box3" && $value['type'] == "textarea") { ?> <div class="pwrap"> <p><?php echo $value['name']; ?> :</p> <?php $valuex = $value['id']; $valuey = stripslashes($valuex); $video_code = get_option($valuey); ?> <p><textarea class="ops-area" name="<?php echo $valuey; ?> " cols="40%" rows="8" /><?php if (get_option($valuey) != "") { echo stripslashes($video_code); } else { echo $value['std']; } ?> </textarea> </p></div> <?php } } ?> <input name="save" type="submit" class='button-primary' value="<?php echo esc_attr(__('Save Text', TEMPLATE_DOMAIN)); ?> " /> <input type="hidden" name="action" value="save5" /> </form> <form method="post"> <input name="reset" type="submit" class='button-primary' value="<?php echo esc_attr(__('Reset Text', TEMPLATE_DOMAIN)); ?> " /> <input type="hidden" name="action" value="reset5" /> </form> </div> <p align="center" > <form method="post"> <input name="reset" style="font-size: 13px !important;"type="submit" class='button-secondary' onclick="return confirm('Are you sure you want to delete all images and reset all saved settings?. This action cannot be restore.')" value="<?php _e('Delete all images and reset all text options', TEMPLATE_DOMAIN); ?> " /> <input type="hidden" name="action" value="resetall" /> </form> </p> </div><!-- end content wrap --> </div><!-- end --> <?php }