( ′∀`)σ≡σ☆))Д′)レ(゚∀゚;)ヘ=З=З=Зε≡(ノ´_ゝ`)ノ
<?php
$PicturePath = "photo/";
if (empty($page)){
$page = 0;
}
$record = 20;
if ($Delslidenews==$admin_yes) {
$db->delslidenews($newsid,$PicturePath);
}
if (!empty($addslidenews)) {
$tempuserfile_name = $_FILES['userfile']['name'];
$tempuserfile = $_FILES['userfile']['tmp_name'];
$file_type = $_FILES['userfile']['type'];
$file_size = $_FILES['userfile']['size'];
if ((!empty($tempuserfile)) && (!empty($tempuserfile_name))) {
$pathinfo = pathinfo($tempuserfile_name, PATHINFO_EXTENSION);
if(!in_array(strtolower($pathinfo), array('jpg','jpeg','png','gif','bmp',)))
{
header('Location: slidecatadmin.php?msg=Invalid File Type!<br>') ;
}
$userfile = $tempuserfile;
$userfile_name = $tempuserfile_name;
}
$newsid = $db->addslidenews($slideid,$title,$description);
//check file extension
$limitedext = array(".gif",".jpg",".png",".jpeg",".bmp");
$ext = strrchr($userfile_name,'.');
$ext = strtolower($ext);
//get the file extension.
$getExt = explode ('.', $userfile_name);
$file_ext = $getExt[count($getExt)-1];
// $videouser = $_SESSION['user_id'];
//get the new width variable.
$thumb_width = 500; // in pixcel
//keep image type
if($file_size){
if($file_type == "image/pjpeg" || $file_type == "image/jpeg"){
$new_img = imagecreatefromjpeg($userfile);
}elseif($file_type == "image/x-png" || $file_type == "image/png"){
$new_img = imagecreatefrompng($userfile);
}elseif($file_type == "image/gif"){
$new_img = imagecreatefromgif($userfile);
}
//list width and height and keep height ratio.
list($width, $height) = getimagesize($userfile);
$imgratio=$width/$height;
if ($imgratio>1){
$newwidth = $thumb_width;
$newheight = $thumb_width/$imgratio;
}else{
$newheight = $thumb_width;
$newwidth = $thumb_width*$imgratio;
}
$videouser = $_SESSION['user_id'];
$userfile_name = preg_replace('/[\ ]/', '-', $userfile_name);
$userfile_name = $videouser.$userfile_name;
$resized_img = imagecreatetruecolor($newwidth,$newheight);
imagecopyresized($resized_img, $new_img, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
//save image
ImageJpeg ($resized_img,"$PicturePath$userfile_name");
ImageDestroy ($resized_img);
ImageDestroy ($new_img);
//print message
echo "<br>Image Thumb: <a href=\"$PicturePath$userfile_name\">$PicturePath$userfile_name</a>";
$db->add_slidePicture($newsid,$userfile_name,$PicturePath);
}
}
if (!empty($editslidenews)) {
$db->editslidenews($slideid,$title,$newsid,$description);
$tempuserfile_name = $_FILES['userfile']['name'];
$tempuserfile = $_FILES['userfile']['tmp_name'];
$file_type = $_FILES['userfile']['type'];
$file_size = $_FILES['userfile']['size'];
if ((!empty($tempuserfile)) && (!empty($tempuserfile_name))) {
$pathinfo = pathinfo($tempuserfile_name, PATHINFO_EXTENSION);
if(!in_array(strtolower($pathinfo), array('jpg','jpeg','png','gif','bmp',)))
{
header('Location: slidecatadmin.php?msg=Invalid File Type!<br>') ;
}
$userfile = $tempuserfile;
$userfile_name = $tempuserfile_name;
}
//check file extension
$limitedext = array(".gif",".jpg",".png",".jpeg",".bmp");
$ext = strrchr($userfile_name,'.');
$ext = strtolower($ext);
//get the file extension.
$getExt = explode ('.', $userfile_name);
$file_ext = $getExt[count($getExt)-1];
// $videouser = $_SESSION['user_id'];
//get the new width variable.
$thumb_width = 500; // in pixcel
//keep image type
if($file_size){
if($file_type == "image/pjpeg" || $file_type == "image/jpeg"){
$new_img = imagecreatefromjpeg($userfile);
}elseif($file_type == "image/x-png" || $file_type == "image/png"){
$new_img = imagecreatefrompng($userfile);
}elseif($file_type == "image/gif"){
$new_img = imagecreatefromgif($userfile);
}
//list width and height and keep height ratio.
list($width, $height) = getimagesize($userfile);
$imgratio=$width/$height;
if ($imgratio>1){
$newwidth = $thumb_width;
$newheight = $thumb_width/$imgratio;
}else{
$newheight = $thumb_width;
$newwidth = $thumb_width*$imgratio;
}
$videouser = $_SESSION['user_id'];
$userfile_name = preg_replace('/[\ ]/', '-', $userfile_name);
$userfile_name = $videouser.$userfile_name;
$resized_img = imagecreatetruecolor($newwidth,$newheight);
imagecopyresized($resized_img, $new_img, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
//save image
ImageJpeg ($resized_img,"$PicturePath$userfile_name");
ImageDestroy ($resized_img);
ImageDestroy ($new_img);
//print message
//echo "<br>Image Thumb: <a href=\"$PicturePath$userfile_name\">$PicturePath$userfile_name</a>";
$db->add_slidePicture($newsid,$userfile_name,$PicturePath);
}
}
if (!empty($DP1)) {
$db->del_slidePicture($newsid,$PicturePath);
}
$result = $db->getslidenews($page,$record,$catid);
?>
<style type="text/css">
<!--
.style6 {font-size: 12px}
-->
</style>
<table width="100%" border="0" cellspacing="10" cellpadding="10">
<tr>
<td width="612" valign="top">
<div style="padding:10px;">
<div class="wa">
<div class="wb">
<div class="wc">
<div class="wd">
<span id="buttoned"><strong>Add Pictures</strong> </span><br />
<br />
<br />
<table width="600" border="0" cellpadding="4" cellspacing="1" class="style6">
<tr>
<td> </td>
<td><strong><?php print "Images"; ?></strong></td>
<td><strong><?php print "Gallery"; ?></strong></td>
<td colspan="2"><strong><?php print "$admin_opreation"; ?></strong></td>
</tr>
<?php
if (!empty($result)) {
foreach ($result as $key => $val) {
$newsid = stripslashes($val["newsid"]);
$picture = stripslashes($val["picture"]);
$slideid = stripslashes($val["slideid"]);
$title = stripslashes($val["title"]);
$cataname = $db->getslidenamebyid($slideid);
?>
<tr>
<td height="107"> </td>
<td><img src="<?php print "$PicturePath$picture"; ?>" width="80"></td>
<td><?php print "$cataname"; ?></td>
<td><?php /*?><a href="editslidenews.php?newsid=<?php print "$newsid"; ?>&catid=<?php print "$catid"; ?>" ><?php print "$admin_edit"; ?><?php */?></a></td>
<td><a class="formbutton5" href="?mode=delslida&newsid=<?php print "$newsid"; ?>&catid=<?php print "$catid"; ?>" ><?php print "$admin_del"; ?></a></td>
</tr>
<?php
}
}
?>
<tr>
<td align="right" colspan="5"><?php
$pagenext = $page+1;
$result1 = $db->getslidenews($pagenext,$record,$catid);
if ($page!=0)
{
$pagepre = $page-1;
print "<a href=\"$PHP_SELF?page=$pagepre&catid=$catid\"><font color=\"#FF0000\">$admin_previouspage</font></a> ";
}
if (!empty($result1))
{
print "<a href=\"$PHP_SELF?page=$pagenext&catid=$catid\"><font color=\"#FF0000\">$admin_nextpage</font></a> ";
}
?> </td>
</tr>
</table>
</div>
</div>
</div></div></div>
<?php
$pagenext = $page+1;
$result1 = $db->getcatalognews($pagenext,$record,$catid);
if ($page!=0)
{
$pagepre = $page-1;
print "<a href=\"$PHP_SELF?page=$pagepre&catid=$catid\"><img src=\"../css/back.gif\"></a> ";
}
if (!empty($result1))
{
print "<a href=\"$PHP_SELF?page=$pagenext&catid=$catid\"><img src=\"../css/more.gif\"></a> ";
}
?>
<br>
<div style="padding:10px;">
<div class="wa">
<div class="wb">
<div class="wc">
<div class="wd">
<form action="?mode=slide" method="POST" ENCTYPE="multipart/form-data">
<input type="hidden" name="slideid" value="<?php print "$catid"; ?>">
<input type="hidden" name="catid" value="<?php print "$catid"; ?>">
<table width="600" height="200" border="0" cellpadding="4" cellspacing="1" class="style6">
<tr>
<td><?php print "$admin_picture"; ?> :</td>
<td><input type="file" name="userfile" class="bigsearch"></td>
</tr> <tr>
<td><?php print "caption"; ?> :</td>
<td><textarea name="description" cols="65" rows="1" class="bigsearch required"></textarea></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="addslidenews" id="buttoned4" style="width:200px; padding:18px; margin:0px; border:0px" value="Add Photo"></td>
</tr>
</table>
</form>
</p>
</div>
</div>
</div>
</div>
</div> <p align="right"> </p></td>
</tr>
</table>