Example #1
0
function getTemplateSize($type, $width, $height, $type)
{
    global $nativeTeamplateConfig;
    echo $type . ' ' . $width . ' ' . $height . '<br>';
    $teamplateNum = getTemplatePath($type, $width, $height);
    //echo $teamplateNum.' |';
    $size = array('w' => '0', 'h' => '0');
    $config = $nativeTeamplateConfig[$teamplateNum];
    $size['w'] = getWidth($width, $config['minWidth'], $config['padding'], $height, $type);
    //var_dump($config);
    $size['h'] = $height + $config['addHeight'];
    //var_dump($size);
    return $size;
}
Example #2
0
function changeAvatar()
{
    $post = isset($_POST) ? $_POST : array();
    $max_width = "500";
    $userId = isset($post['hdn-profile-id']) ? intval($post['hdn-profile-id']) : 0;
    $path = 'images/tmp';
    $valid_formats = array("jpg", "png", "gif", "bmp", "jpeg");
    $name = $_FILES['photoimg']['name'];
    $size = $_FILES['photoimg']['size'];
    if (strlen($name)) {
        list($txt, $ext) = explode(".", $name);
        if (in_array($ext, $valid_formats)) {
            if ($size < 1024 * 1024) {
                $actual_image_name = 'avatar' . '_' . $userId . '.' . $ext;
                $filePath = $path . '/' . $actual_image_name;
                $tmp = $_FILES['photoimg']['tmp_name'];
                if (move_uploaded_file($tmp, $filePath)) {
                    $width = getWidth($filePath);
                    $height = getHeight($filePath);
                    //Scale the image if it is greater than the width set above
                    if ($width > $max_width) {
                        $scale = $max_width / $width;
                        $uploaded = resizeImage($filePath, $width, $height, $scale);
                    } else {
                        $scale = 1;
                        $uploaded = resizeImage($filePath, $width, $height, $scale);
                    }
                    /*$res = saveAvatar(array(
                      'userId' => isset($userId) ? intval($userId) : 0,
                                              'avatar' => isset($actual_image_name) ? $actual_image_name : '',
                      ));*/
                    //mysql_query("UPDATE users SET profile_image='$actual_image_name' WHERE uid='$session_id'");
                    echo "<img id='photo' file-name='" . $actual_image_name . "' class='' src='" . $filePath . '?' . time() . "' class='preview'/>";
                } else {
                    echo "failed";
                }
            } else {
                echo "Image file size max 1 MB";
            }
        } else {
            echo "Invalid file format..";
        }
    } else {
        echo "Please select image..!";
    }
    exit;
}
            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);
            		}*/
            echo "success|" . str_replace(JPATH_ROOT . '/', JURI::root(), $large_image_location) . "|" . getWidth($large_image_location) . "|" . getHeight($large_image_location);
        }
    } else {
        echo "error|" . $error;
    }
}
########################################################
#	CREATE THE THUMBNAIL							   #
########################################################
if (JRequest::getVar('save_thumb') == "Save Thumbnail") {
    //Get the new coordinates to crop the image.
    $x1 = $_POST["x1"];
    $y1 = $_POST["y1"];
    $x2 = $_POST["x2"];
    $y2 = $_POST["y2"];
    $w = $_POST["w"];
Example #4
0
     $pdf->cMargin = $prop['padding'];
     $pdf->SetFont('Arial', 'B', 10);
     $pdf->Cell(getWidth(21, $prop['width']), 6, "Total", 'LBR', 0, 'C', false);
     $pdf->Cell(getWidth(7, $prop['width']), 6, number_format($totals['total']), 'LBR', 0, 'R', false);
     $pdf->Cell(getWidth(6, $prop['width']), 6, number_format($totals['jan']), 'LBR', 0, 'R', false);
     $pdf->Cell(getWidth(6, $prop['width']), 6, number_format($totals['feb']), 'LBR', 0, 'R', false);
     $pdf->Cell(getWidth(6, $prop['width']), 6, number_format($totals['mar']), 'LBR', 0, 'R', false);
     $pdf->Cell(getWidth(6, $prop['width']), 6, number_format($totals['apr']), 'LBR', 0, 'R', false);
     $pdf->Cell(getWidth(6, $prop['width']), 6, number_format($totals['may']), 'LBR', 0, 'R', false);
     $pdf->Cell(getWidth(6, $prop['width']), 6, number_format($totals['jun']), 'LBR', 0, 'R', false);
     $pdf->Cell(getWidth(6, $prop['width']), 6, number_format($totals['jul']), 'LBR', 0, 'R', false);
     $pdf->Cell(getWidth(6, $prop['width']), 6, number_format($totals['aug']), 'LBR', 0, 'R', false);
     $pdf->Cell(getWidth(6, $prop['width']), 6, number_format($totals['sep']), 'LBR', 0, 'R', false);
     $pdf->Cell(getWidth(6, $prop['width']), 6, number_format($totals['oct']), 'LBR', 0, 'R', false);
     $pdf->Cell(getWidth(6, $prop['width']), 6, number_format($totals['nov']), 'LBR', 0, 'R', false);
     $pdf->Cell(getWidth(6, $prop['width']), 6, number_format($totals['dec']), 'LBR', 0, 'R', false);
     $pdf->cMargin = $_cMargin;
     $pdf->Ln();
     $pdf->Output("monthly_exp.pdf", "D");
 } else {
     if ($_GET['report'] == 'xls') {
         require_once '../includes/Classes/PHPExcel.php';
         $padding = 0.71;
         $objPHPExcel = new PHPExcel();
         $objPHPExcel->getProperties()->setCreator("*****@*****.**")->setLastModifiedBy("Imran Zahid")->setTitle("Monthly Expenses")->setSubject("Monthly Expenses")->setDescription("Monthly Expenses")->setKeywords("Monthly Expenses")->setCategory("Reports");
         $rtitle = "{$title} ({$startDate} to {$endDate})";
         $objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddHeader('&C&18&B' . $rtitle . '&R&U&D');
         $objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddFooter('&C&IPage &P/&N');
         $objPHPExcel->getActiveSheet()->getPageSetup()->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE);
         $objPHPExcel->getActiveSheet()->getPageSetup()->setPaperSize(PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4);
         $objPHPExcel->getActiveSheet()->getPageSetup()->setRowsToRepeatAtTopByStartAndEnd(1, 1);
Example #5
0
<table border="1" align="center" cellpadding="0" cellspacing="0" style=" color:#4c391b;">
	<tr>
		<td align="center" valign="middle"><div id="showpic"><img id = "bigimg" src="<?php 
        echo 'uppics/' . $picarr[0]['picpath'];
        ?>
" width="<?php 
        echo getWidth('uppics/' . $picarr[0]['picpath'], 640, 480);
        ?>
" height="<?php 
        echo getHeight('uppics/' . $picarr[0]['picpath'], 640, 480);
        ?>
" style="cursor:hand;" onclick="lookpic()" /><div style="line-height:25px;">ͼƬÃû³Æ£º&nbsp;<?php 
        echo $picarr[0]['picname'];
        ?>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ͼƬ¸ñʽ£º<?php 
        echo getWidth('uppics/' . $picarr[0]['picpath']);
        ?>
 * <?php 
        echo getHeight('uppics/' . $picarr[0]['picpath']);
        ?>
&nbsp;&nbsp;</div><div align="left" style="line-height:25px; text-indent:20px;">ͼƬÃèÊö£º&nbsp;<?php 
        echo $picarr[0]['bewrite'];
        ?>
</div></div></td>
	</tr>
	<tr>
		<td height="25" align="center" valign="middle">&nbsp;<?php 
        $albumsql = "select * from tb_album where typename = " . $smallact;
        $num = $conne->getRowsNum($albumsql);
        if ($num == 1) {
            ?>
</option>
                                <?php 
        }
        ?>
                            </select>
                        </div>
                        <div class="col-sm-offset-4 col-sm-3">
                            <div class="alert alert-info" style="width: auto;">
                                <label class="control-label">
                                    <?php 
        echo getUebersetzung("vorheriger Wert", $sprache, $link);
        ?>
:
                                </label>
                                <?php 
        echo getWidth($style);
        ?>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <hr>
                    </div>
                <?php 
    }
    ?>

                <div class="row">
                    <div class="col-sm-offset-9 col-sm-3" style="text-align: right;">

                        <button name="submit4" type="submit" class="btn btn-success" id="submit4">
Example #7
0
<form name="photo" enctype="multipart/form-data" action="<?php 
    echo $_SERVER["PHP_SELF"];
    ?>
" method="post">
Photo (jpg o gif) <input type="file" name="image" size="30" /> <input type="submit" name="upload" value="Carica" />
</form>

<?php 
}
//Display error message if there are any
if (isset($error) && strlen($error) > 0) {
    echo "<ul style=\"margin:4px 0px 14px 0px;\"><li><strong>Errore!</strong></li><li>" . $error . "</li></ul>";
}
if (isset($immagineDaUsare) and strlen($immagineDaUsare) > 0 and (!isset($_POST["nStep"]) or $_POST["nStep"] != "3")) {
    // controllo se l'immagine caricata è più piccola della thumb
    $width_caricata = getWidth($immagineDaUsare);
    $height_caricata = getHeight($immagineDaUsare);
    if ($width_caricata <= $thumb_width && $height_caricata <= $thumb_height) {
        $x1_value = 0;
        $y1_value = 0;
        $x2_value = $x1_value + $width_caricata;
        $y2_value = $y1_value + $height_caricata;
        $w_value = $width_caricata;
        $h_value = $height_caricata;
        ?>
			<h2><u>Step <?php 
        print $nStep;
        ?>
</u>: <?php 
        print $creaImg;
        ?>
Example #8
0
header("Content-Type:text/html;charset=gb2312");
include_once 'conn/conn.php';
include_once 'admin/inc/func.php';
$picpath = $_GET['picpath'];
$smallact = $_GET['smallact'];
$tmppath = substr(strrchr($picpath, '/'), 1);
$psql = "select id,picname,bewrite,upname from tb_photo where picpath = '" . $tmppath . "'";
$parr = $conne->getRowsRst($psql);
?>
<img id = "bigimg" src="<?php 
echo $picpath;
?>
" width="<?php 
echo getWidth($picpath, 640, 480);
?>
" height="<?php 
echo getHeight($picpath, 640, 480);
?>
" style="cursor:hand;" onclick="lookpic()" /><div style="line-height:25px;">ͼƬ���ƣ�&nbsp;<?php 
echo $parr['picname'];
?>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ͼƬ��ʽ��<?php 
echo getWidth($picpath);
?>
 * <?php 
echo getHeight($picpath);
?>
&nbsp;&nbsp;</div><div align="left" style="line-height:25px; text-indent:20px;">ͼƬ������&nbsp;<?php 
echo $parr['bewrite'];
?>
</div>
Example #9
0
 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'];
 }
Example #10
0
}else if(way == 'left'){
	setInterval(fromrighttoleft,30);
}
</script>
<table border="0" cellpadding="0" cellspacing="0" align="center">
<tr>
	<td height="600">&nbsp;</td>
	<td style="width:800px;"><div id="zero" style="width:800px; height:600px; top:100px; position:absolute;">
<?php 
foreach ($tmparr as $key => $value) {
    ?>
<div id="num<?php 
    echo $key;
    ?>
" style="position:absolute; vertical-align:middle; visibility:hidden; top:0px;"><img src="../uppics/<?php 
    echo $value;
    ?>
" width="<?php 
    echo getWidth('../uppics/' . $value, 800, 600);
    ?>
" height="<?php 
    echo getHeight('../uppics/' . $value, 800, 600);
    ?>
" border="0" /></div>
<?php 
}
?>
</div></td>
	<td>&nbsp;</td>
</tr>
</table>
Example #11
0
        ?>
		<a href="pics.php?smallact=<?php 
        echo $typevalue['id'];
        ?>
" target="showpic">
<?php 
    }
    ?>
		<img id = "indexpic<?php 
    echo $key;
    ?>
" src="<?php 
    echo $typevalue['level'] == 0 ? '../uppics/' . $typevalue['indexpic'] : '../images/mimi.jpg';
    ?>
 " width="<?php 
    echo getWidth($typevalue['level'] == 0 ? '../uppics/' . $typevalue['indexpic'] : '../images/mimi.jpg', 150, 100);
    ?>
" height="<?php 
    echo getHeight($typevalue['level'] == 0 ? '../uppics/' . $typevalue['indexpic'] : '../images/mimi.jpg', 150, 100);
    ?>
" border="0"/>
<?php 
    if ($num != 0) {
        ?>
	
		</a>
<?php 
    }
    ?>
		</td>
	</tr>
Example #12
0
        if ($file_ext != "jpg" && $file_ext != "gif") {
            $err .= "ONLY jpg images are accepted for upload";
        }
    } else {
        $err .= "Select a jpg image for upload";
    }
    echo $err;
    if ($err == "") {
        $image_loc = $upload_dir . $user_filename;
        if (isset($_FILES["image"]["name"])) {
            if (file_exists($upload_dir . $user_filename)) {
                echo $user_filename . " already exists. ";
            } else {
                move_uploaded_file($user_filename_temp, $image_loc);
                chmod($image_loc, 0777);
                $width = getWidth($image_loc);
                $height = getHeight($image_loc);
                echo "<img src='{$image_loc}' />";
                if ($width > $max_width) {
                    $scale = $max_width / $width;
                    $uploaded = resizeImage($image_loc, $width, $height, $scale);
                } else {
                    $scale = 1;
                    $uploaded = resizeImage($image_loc, $width, $height, $scale);
                }
            }
        }
    }
}
function getWidth($image)
{
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!&nbsp;', 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);
        ?>
" />&nbsp;&nbsp;&nbsp;&nbsp;<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!&nbsp;', 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);
        ?>
" />&nbsp;&nbsp;&nbsp;&nbsp;
    <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!&nbsp;', 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);
        ?>
" />&nbsp;&nbsp;&nbsp;&nbsp;<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!&nbsp;', 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);
        ?>
" />&nbsp;&nbsp;&nbsp;&nbsp;<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!&nbsp;', 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);
        ?>
" />&nbsp;&nbsp;&nbsp;&nbsp;<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 
}
Example #14
0
                imagickCrop($image, '50%', '50%', $width, $height);
            }
        } else {
            $image->thumbnailImage($width, $height, $width && $height);
        }
    }
    $image->writeImage($newFilename);
}
// ------------------------ program -----------------------------------
$file = getFile();
if (isLocalFile($file)) {
    checkFilename($file);
    existsFile($file);
}
$height = getHeight();
$width = getWidth();
$exact = getExact();
$topCut = getTopCut();
if (isLocalFile($file)) {
    $newFilename = getResizedFilename($file, $height, $width, $exact, $topCut);
} else {
    $newFilename = getRemoteResizedFilename($file, $height, $width, $exact, $topCut);
}
if (!existsFile($newFilename, false)) {
    try {
        if (shouldSendOriginal($file, $height, $width, $exact || $topCut)) {
            sendFile($file);
        }
        requireImageClass();
        if (false && isLocalFile($file) && extension_loaded('imagick')) {
            processImagick($file, $newFilename, $height, $width, $exact, $topCut);
function getPlanning($dotd, $h1begin, $h1end, $h2begin, $h2end, $epn, $salle)
{
    if ($h1begin == 0 and $h2begin > 0) {
        $h1begin = $h2begin;
    }
    if ($h2end == 0 and $h1begin > 0) {
        $h2end = $h1end;
    }
    if ($h1begin == 0 and $h2end == 0) {
        return FALSE;
        exit;
    }
    // Initialisation des variables
    $graf = "";
    $unit = getConfig("unit_config", "unit_default_config", $epn);
    // unité dans la table config
    $unitLabel = 30;
    // echelle de division du temps pour les labels des heures
    $h1begin = floor($h1begin / 60) * 60;
    // on recupere l"heure de debut ex : 9h15 =>9h => 540mn
    if ($h2end != floor($h2end / 60) * 60) {
        $h2end = floor($h2end / 60) * 60 + 60;
    }
    // on recupere l"heure de fin ex : 19h15 =>20h
    $nbTotM = $h2end - $h1begin;
    // nombre total de minute d'ouverture
    $widthPause = getWidth($h2begin - $h1end, $nbTotM, $unit) * (60 / $unit);
    $positionPause = getPosition($h1end, $h1begin, getWidthPerUnit($nbTotM, $unit)) * (60 / $unit);
    // selection des machines par salle
    $result = getAllMaterielDispo($salle);
    // affichage du resultat
    if (mysqli_num_rows($result) < 1) {
        $graf = "Aucun ordinateur dans la salle s&eacute;lection&eacute;e, veuillez choisir une autre salle";
    } else {
        // Creation du tableau
        $graf .= "<table  class=\"table table-condensed\">";
        // ligne des horaires - echelle au dessus des reservations
        $graf .= "<tr><td></td><td >";
        for ($i = 0; $i < $nbTotM / $unitLabel; $i++) {
            if ($i == $nbTotM / $unitLabel - 1) {
                $largeur = getWidth(60, $nbTotM, $unitLabel) - 2;
                if (strlen(getTime($h1begin + $i * $unitLabel)) <= 3) {
                    $graf .= "<div class=\"labelHor\" style=\"width:" . $largeur . "%;\">|" . getTime($h1begin + $i * $unitLabel) . "</div>";
                } else {
                    $graf .= "<div class=\"labelHor1\" style=\"width:" . $largeur . "%;\">|30</div>";
                }
            } else {
                $time = getTime($h1begin + $i * $unitLabel);
                if (strlen(getTime($h1begin + $i * $unitLabel)) <= 3) {
                    $graf .= "<div class=\"labelHor\" style=\"width:" . getWidth(60, $nbTotM, $unitLabel) . "%;\">|" . $time . "</div>";
                } else {
                    $graf .= "<div class=\"labelHor1\" style=\"width:" . getWidth(60, $nbTotM, $unitLabel) . "%;\">|30</div>";
                }
            }
        }
        $graf .= "</td></tr>";
        //affichage des machines + liste des reservations
        while ($row = mysqli_fetch_array($result)) {
            //old function affichage par usage//
            if ($row['NB'] == "") {
                $nbCritere = '';
            } else {
                $nbCritere = ' (' . $row['NB'] . ')';
            }
            ///
            if (strtotime($dotd) < strtotime(date("Y-m-d"))) {
                $graf .= "<tr><td class=\"computer\" >" . $row["nom_computer"] . "</td>\n                        <td class=\"horaire\">";
            } else {
                /*if(COUNT($usage)==$row['NB']) // si la recherche est exacte
                  {
                    $graf .= "<tr><td class=\"computer2\"><a href=\"index.php?m=7&idepn=".$epn."&idcomp=".$row["id_computer"]."&nomcomp=".$row["nom_computer"]."&date=".$dotd."\">".$row["nom_computer"]."".$nbCritere."</a></td>
                                <td class=\"horaire\">" ;
                    $lineExist = TRUE ;         
                                
                  }
                  else // sinon on affiche les resultats avec les autres criteres de recherche
                  {*/
                if (FALSE == checkInter($row["id_computer"])) {
                    //si pas d'intervention
                    $graf .= "<tr><td class=\"computer\"><a href=\"index.php?m=7&idepn=" . $epn . "&idcomp=" . $row["id_computer"] . "&nomcomp=" . $row["nom_computer"] . "&date=" . $dotd . "\">" . $row["nom_computer"] . "" . $nbCritere . "</a></td>\n                            <td class=\"horaire\">";
                } else {
                    $graf .= "<tr><td class=\"computer\"><span data-toggle=\"tooltip\" title=\"Une intervention est en cours sur ce poste, pas de réservation possible !\" class=\"text-red\">" . $row["nom_computer"] . "</span></td>\n                            <td class=\"horaire\">";
                }
                //  }
            }
            // affichage des horaires et des occupations
            $result2 = getResa($row["id_computer"], $dotd);
            $width = 0;
            $position = 0;
            $widthTmp = 0;
            $widthTmp2 = 0;
            $i = 0;
            while ($row2 = mysqli_fetch_array($result2)) {
                $i = 0;
                // largeur en % du div representant la resa
                $width = getWidth($row2["duree_resa"], $nbTotM, $unit) * (60 / $unit);
                // recupere la position absolue dans le tableau
                $positionTmp = getPosition($row2["debut_resa"], $h1begin, getWidthPerUnit($nbTotM, $unit));
                // position en % du div en cours (represente l'ecart avec celui de devant)
                $position = ($positionTmp - $widthTmp2) * (60 / $unit) - $unit / 60 * $i;
                if ($position < 0) {
                    $position = 0;
                }
                // Affichage de la ligne d'une machine;
                $urlGraf = "#p" . $row2["id_user_resa"];
                //Ajout lien vers ancre dans la liste//$_SERVER['REQUEST_URI'] ; //."&idResa=".$row2['id_resa'];
                if ($_SESSION['status'] == 3 or $_SESSION['status'] == 4) {
                    // comment d'admin et d'anim
                    $altGraf = "(" . getUserName($row2["id_user_resa"]) . " - " . getTime($row2["debut_resa"]) . " &agrave; " . getTime($row2["debut_resa"] + $row2["duree_resa"]) . ")";
                } else {
                    // comment d'utilisateur
                    $altGraf = "(" . getTime($row2["debut_resa"]) . " &agrave; " . getTime($row2["debut_resa"] + $row2["duree_resa"]) . ")";
                }
                $graf .= "<div class=\"unitbusy\" style=\"width:" . $width . "%;left:" . $position . "%;\">\n                                <a href=\"" . $urlGraf . "\" alt=\"" . $altGraf . "\" title=\"" . $altGraf . "\">" . getTime($row2["duree_resa"]) . "</a>\n                            </div>";
                $widthTmp = $widthTmp + $width;
                $widthTmp2 = $widthTmp / (60 / $unit);
                ++$i;
                //echo $position.'% = (PA:'.$positionTmp.'-W'.$widthTmp.')*(60/'.$unit.') -- width:'.$width.'% -- nbTotM:'.$nbTotM.'<br/>';
            }
            // fin de l'affichage des horaires et des occupations
            $graf .= "</td></tr>";
        }
        // ligne des horaires - echelle en dessous du tableau de reservation 2
        $graf .= "<tr><td></td><td >";
        for ($i = 0; $i < $nbTotM / $unitLabel; $i++) {
            if ($i == $nbTotM / $unitLabel - 1) {
                if (strlen(getTime($h1begin + $i * $unitLabel)) <= 3) {
                    $graf .= "<div class=\"labelHor\" style=\"width:" . (getWidth(60, $nbTotM, $unitLabel) - 2) . "%;\">|" . getTime($h1begin + $i * $unitLabel) . "</div>";
                } else {
                    $graf .= "<div class=\"labelHor1\" style=\"width:" . (getWidth(60, $nbTotM, $unitLabel) - 2) . "%;\">|30</div>";
                }
            } else {
                if (strlen(getTime($h1begin + $i * $unitLabel)) <= 3) {
                    $graf .= "<div class=\"labelHor\" style=\"width:" . getWidth(60, $nbTotM, $unitLabel) . "%;\">|" . getTime($h1begin + $i * $unitLabel) . "</div>";
                } else {
                    $graf .= "<div class=\"labelHor1\" style=\"width:" . getWidth(60, $nbTotM, $unitLabel) . "%;\">|30</div>";
                }
            }
        }
        $graf .= "</td></tr>";
        $graf .= "</table>";
    }
    return $graf;
}
Example #16
0
for ($i = 0; $i < $last; $i++) {
    $tmp = getInfo("creative/" . $i);
    if ($tmp != false) {
        $caption[$i] = $tmp;
    }
}
$side = ($thumbs - 1) / 2;
$start = $id - $side;
$end = $id + $side;
echo '<table cellpadding="0" cellspacing="16" border="0" align="center"><tr>';
echo '<td width="200" align="right">';
if ($id > 0) {
    echo '<a href="creative.php?p=' . (string) ($id - 1) . '" style="font-size: 36px; text-decoration: none;"><img src="images/back.jpg"></a>';
}
echo '</td>';
echo '<td align="center"><a href="image.php?p=creative/' . $id . '&h=768"><img src="image.php?p=creative/' . $id . '&h=320" border="1" style="border-color: #CCCCFF" width="' . getWidth('images/creative/' . $id . '.jpg', 320) . '" height="320"></a></td>';
echo '<td width="200" align="left">';
if ($id < $last) {
    echo '<a href="creative.php?p=' . (string) ($id + 1) . '" style="font-size: 36px; text-decoration: none;"><img src="images/next.jpg"></a>';
}
echo '</td>';
echo '</tr>';
if (!empty($caption[$id])) {
    echo '<tr><td align="center" colspan="3">' . $caption[$id] . '</td></tr>';
}
echo '</table>';
if ($_SESSION['user'] == 'jrizzle') {
    echo '<form name="main" action="creative.php?p=' . $id . '" method="post" enctype="multipart/form-data">';
    echo '<input type="hidden" name="edit" value="">';
    echo '<table align="center" cellpadding="0" cellspacing="0" border="0"><tr>';
    echo '<td colspan="9" align="center"><i><u>Admin Tools</u></i></td>';
Example #17
0
         $error .= "Images must be under " . $max_file . "MB in size";
     }
 } else {
     $error = "Select an image for upload";
 }
 //Everything is ok, so we can upload the image.
 if (strlen($error) == 0) {
     if (isset($_FILES['image']['name'])) {
         //this file could now has an unknown file extension (we hope it's one of the ones set above!)
         $large_image_location = $large_image_location . "." . $file_ext;
         $thumb_image_location = $thumb_image_location . "." . $file_ext;
         //put the file ext in the session so we know what file to look for once its uploaded
         $_SESSION['user_file_ext'] = "." . $file_ext;
         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
Example #18
0
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) . "&nbsp;</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 &raquo;", TEMPLATE_DOMAIN);
        ?>
" />&nbsp;&nbsp;<input type="submit" name="normal_upload1" class="sbutton button-secondary" value="<?php 
        _e("Upload &raquo;", 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) . "&nbsp;</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 &raquo;" />&nbsp;&nbsp;&nbsp;<input type="submit" class="button-secondary" name="normal_upload2" value="Upload &raquo;" />
<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) . "&nbsp;</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 &raquo;" />&nbsp;&nbsp;&nbsp;<input type="submit" class="button-secondary" name="normal_upload3" value="Upload &raquo;" />
<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) . "&nbsp;</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 &raquo;" />&nbsp;&nbsp;&nbsp;<input type="submit" class="button-secondary" name="normal_upload4" value="Upload &raquo;" />
<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) . "&nbsp;</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&raquo;" />&nbsp;&nbsp;&nbsp;<input type="submit" class="button-secondary" name="normal_upload5" value="Upload &raquo;" />
<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) . "&nbsp;</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&raquo;" />&nbsp;&nbsp;&nbsp;<input type="submit" class="button-secondary" name="normal_upload6" value="Upload &raquo;" />
<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) . "&nbsp;</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&raquo;" />&nbsp;&nbsp;&nbsp;<input type="submit" class="button-secondary" name="normal_upload7" value="Upload &raquo;" />
<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) . "&nbsp;</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&raquo;" />&nbsp;&nbsp;&nbsp;<input type="submit" class="button-secondary" name="normal_upload8" value="Upload &raquo;" />
<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) . "&nbsp;</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&raquo;" />&nbsp;&nbsp;&nbsp;<input type="submit" class="button-secondary" name="normal_upload9" value="Upload &raquo;" />
<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" />&nbsp;&nbsp;<?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 
}
Example #19
0
    }
    ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>WeMakeScholars - Upload Profile Picture</title>
    <link href="/css/custom.css" rel="stylesheet" type="text/css">
	<script type="text/javascript" src="/cropjs/jquery-pack.js"></script>
	<script type="text/javascript" src="/cropjs/jquery.imgareaselect.min.js"></script>
</head>
<body>

<?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 
Example #20
0
        ?>
		<a href="pics.php?smallact=<?php 
        echo $typevalue['id'];
        ?>
" target="showpic">
<?php 
    }
    ?>
		<img id = "indexpic<?php 
    echo $key;
    ?>
" src="<?php 
    echo $num != 0 ? 'uppics/' . $typevalue['indexpic'] : 'images/null.jpg';
    ?>
 " width="<?php 
    echo getWidth($num != 0 ? 'uppics/' . $typevalue['indexpic'] : 'images/null.jpg', 130, 100);
    ?>
" height="<?php 
    echo getHeight($num != 0 ? 'uppics/' . $typevalue['indexpic'] : 'images/null.jpg', 130, 100);
    ?>
" border="0"/>
<?php 
    if ($num != 0) {
        ?>
	
		</a>
<?php 
    }
    ?>
		</td>
	</tr>