break; case "gd2": if ($imginfo[2] == GIS_JPG) { $src_img = imagecreatefromjpeg($src_file); } else { $src_img = imagecreatefrompng($src_file); } $dst_img = imagecreatetruecolor($destWidth, $destHeight); imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $destWidth, (int) $destHeight, $srcWidth, $srcHeight); header("Content-type: image/jpeg"); imagejpeg($dst_img); imagedestroy($src_img); imagedestroy($dst_img); break; default: if ($imginfo[2] == GIS_JPG) { $src_img = imagecreatefromjpeg($src_file); } else { $src_img = imagecreatefrompng($src_file); } $dst_img = imagecreate($destWidth, $destHeight); imagecopyresized($dst_img, $src_img, 0, 0, 0, 0, $destWidth, (int) $destHeight, $srcWidth, $srcHeight); header("Content-type: image/jpeg"); imagejpeg($dst_img); imagedestroy($src_img); imagedestroy($dst_img); break; } } makethumbnail($xoopsModuleConfig['fullpath'] . $_GET['picfile'], $_GET['size'], $xoopsModuleConfig['thumb_method']);
} else { $src_img = imagecreatefrompng($src_file); } if ($imginfo[2] == GIS_GIF) { $dst_img = imagecreate($destWidth, $destHeight); } else { $dst_img = imagecreatetruecolor($destWidth, $destHeight); } imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $destWidth, (int) $destHeight, $srcWidth, $srcHeight); header("Content-type: image/jpeg"); imagejpeg($dst_img); imagedestroy($src_img); imagedestroy($dst_img); break; default: if ($imginfo[2] == GIS_JPG) { $src_img = imagecreatefromjpeg($src_file); } else { $src_img = imagecreatefrompng($src_file); } $dst_img = imagecreate($destWidth, $destHeight); imagecopyresized($dst_img, $src_img, 0, 0, 0, 0, $destWidth, (int) $destHeight, $srcWidth, $srcHeight); header("Content-type: image/jpeg"); imagejpeg($dst_img); imagedestroy($src_img); imagedestroy($dst_img); break; } } makethumbnail($CONFIG['fullpath'] . $_GET['picfile'], $_GET['size'], $CONFIG['thumb_method']);
$src_file = '"' . $cur_dir . '\\' . strtr($src_file, '/', '\\') . '"'; } else { $src_file = escapeshellarg($src_file); } header("Content-type: image/" . $content_type[$imginfo[2]]); passthru("{$CONFIG['impath']}convert -quality {$CONFIG['jpeg_qual']} -antialias -geometry {$destWidth}x{$destHeight} {$src_file} -"); break; case "gd2": if ($imginfo[2] == GIS_GIF && $CONFIG['GIF_support'] == 1) { $src_img = imagecreatefromgif($src_file); } elseif ($imginfo[2] == GIS_JPG) { $src_img = imagecreatefromjpeg($src_file); } else { $src_img = imagecreatefrompng($src_file); } if ($imginfo[2] == GIS_GIF) { $dst_img = imagecreate($destWidth, $destHeight); } else { $dst_img = imagecreatetruecolor($destWidth, $destHeight); } imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $destWidth, (int) $destHeight, $srcWidth, $srcHeight); header("Content-type: image/jpeg"); imagejpeg($dst_img); imagedestroy($src_img); imagedestroy($dst_img); break; } } $matches = $superCage->get->getMatched('picfile', '/^[0-9A-Za-z~\\/\\\\_.-\\s]+$/'); makethumbnail($CONFIG['fullpath'] . $matches[0], $superCage->get->getInt('size'), $CONFIG['thumb_method']);
function uploadMashup() { $obj = new obj(); $lectype = $_POST['lecture_type']; $lecture_name = $_POST['lectureName']; $intro_data = $_POST['intro_data']; $lecture_movie = $_POST['lectureMovie']; $movie_time = $_POST['movieTime']; $movie_time = gmdate("H:i:s", $movie_time); $lecture_pdf = $_POST['lecturePdf']; $cid = $_POST['cid']; //MOVIE AND PDF if (isset($_FILES["lcMovie"]["type"]) && isset($_FILES["lcPdf"]["type"])) { //MOVIE $validextensions = array("flv", "mov", "mp4"); $temporary = explode(".", $_FILES["lcMovie"]["name"]); $file_extension = end($temporary); $lecture_movie = md5(rand(1, 9999999999.0)) . '.' . $file_extension; //RANDOM FILENAME //PDF $validextensions_pdf = array("pdf"); $temporary_pdf = explode(".", $_FILES["lcPdf"]["name"]); $file_extension_pdf = end($temporary_pdf); $lecture_pdf = md5(rand(1, 9999999999.0)) . '.' . $file_extension_pdf; //RANDOM FILENAME if ($_FILES["lcMovie"]["size"] < 100000000 && in_array($file_extension, $validextensions) && ($_FILES["lcPdf"]["size"] < 100000000 && in_array($file_extension_pdf, $validextensions_pdf))) { if (file_exists("../media/movie/" . $lecture_movie) && file_exists("../media/pdf/" . $lecture_pdf)) { echo "Movie Already Exists!"; } else { //MOVE MOVIE TO MEDIA FOLDER $sourcePath = $_FILES['lcMovie']['tmp_name']; // Storing source path of the file in a variable $targetPath = "../media/video/" . $lecture_movie; move_uploaded_file($sourcePath, $targetPath); // Moving Uploaded file chmod($targetPath, 0777); //PDF $sourcePath2 = $_FILES['lcPdf']['tmp_name']; // Storing source path of the file in a variable $targetPath2 = "../media/pdf/" . $lecture_pdf; move_uploaded_file($sourcePath2, $targetPath2); // Moving Uploaded file chmod($targetPath2, 0777); //GET TOTAL NUMBER OF PAGES - PDF $file = $targetPath2; $page_num = exec("pdfinfo {$file} | grep Pages: | awk '{print \$2}'"); $_SESSION['page_num'] = $page_num; //RANDOM NAME FOR FOLDER $thumb_random_foldername = time() . '' . rand(1, 10000); $_SESSION['thumb_foldername'] = $thumb_random_foldername; $thumb_path = '../img/thumbnails/' . $thumb_random_foldername; mkdir($thumb_path, true); chmod($thumb_path, 0777); //GENERATE THUMBNAIL for ($i = 0; $i < $page_num; $i++) { //$targetPath2 IS WHERE THE UPLOADED PDF FILE LOCATED //$thumb_path IS WHERE THE THUMBNAIL IMAGES WILL BE LOCATED makethumbnail($i, $targetPath2, $thumb_path); } //SAVE TO DB $form_data = array("lname" => $lecture_name, "intro_data" => $intro_data, "cid" => $cid, "ltype" => $lectype, "folder_name" => $thumb_random_foldername, "ldata1" => $lecture_movie, "prg_time" => $movie_time, "ldata2" => $lecture_pdf); $obj->insert("tbl_lc_lecture", $form_data); //RETURN MOVIE AND PDF FILE NAME ON SUCCESS $data[0] = "Success"; $data[1] = $lecture_movie; $data[2] = $lecture_pdf; echo json_encode($data); } } else { echo "Invalid movie file Size or Type!"; } } else { echo "Invalid"; } }
case 6: // bmp // convert bmp to jpg using shell command $command = sprintf($_CONFQUIZ['bmpconvertcmd'], $src, $dest); exec($command); // remove original gif file and rename converted png unlink($src); $chmod = @chmod($dest, 0755); $newfile = $filenameonly . ".jpg"; DB_query("UPDATE {$_TABLES['quiz_images']} SET filename='{$newfile}' WHERE qid={$qid}"); $filename = $newfile; break; default: break; } makethumbnail($filename); $imageinfo = getimagesize($questionDir . $filename); if ($imageinfo['0'] > $_CONFQUIZ['image_width']) { //COM_errorLOG("Resize $questionDir$filename"); resize_image($questionDir . $filename, $_CONFQUIZ['image_quality'], $_CONFQUIZ['image_width'], $resize_type = 1); } } function makethumbnail($image_name) { global $_CONF, $_CONFQUIZ, $questionDir; $src = $questionDir . $image_name; $dest = $src . "_tmp"; $do_create = false; if ($image_info = @getimagesize($src)) { if ($image_info[2] == 1 || $image_info[2] == 2 || $image_info[2] == 3) { $do_create = true;
function updatePage($mode, $type) { global $_CONF, $_TABLES, $_FILES, $_POST, $CONF_SE, $LANG_SE_ERR; global $_DB_name, $catid, $pageid; include_once $_CONF['path_system'] . 'classes/upload.class.php'; $name = substr(htmlentities($_POST['name']), 0, 32); $pid = ppPrepareForDB($_POST['category']); $old_sid = ppPrepareForDB($_POST['old_sid']); $sid = ppPrepareForDB($_POST['sid'], true, 40); $pageorder = COM_applyFilter($_POST['pageorder'], true); if ($type == 'link') { $menutype = 3; } else { $menutype = COM_applyFilter($_POST['menu_type'], true); } $blkformat = ppPrepareForDB($_POST['blk_format']); $heading = substr(htmlentities($_POST['heading']), 0, 255); $grp_access = ppPrepareForDB($_POST['grp_access']); $imgdelete = $_POST['imgdelete']; $chkscale = $_POST['chkscale']; $submenutype = COM_applyFilter($_POST['rad_submenu'], true); $blockmenutype = COM_applyFilter($_POST['rad_blockmenu'], true); $is_menu_newpage = $_POST['chknewwindow'] == 1 ? 1 : 0; $is_draft = $_POST['chkdraft'] == 1 ? 1 : 0; $show_breadcrumbs = $_POST['chkbreadcrumbs'] == 1 ? 1 : 0; $owner_id = ppPrepareForDB($_POST['owner_id']); $group_id = ppPrepareForDB($_POST['group_id']); $perm_owner = $_POST['perm_owner']; $perm_group = $_POST['perm_group']; $perm_members = $_POST['perm_members']; $perm_anon = $_POST['perm_anon']; $pagetitle = substr(htmlentities($_POST['pagetitle']), 0, 255); $metadesc = ppPrepareForDB($_POST['metadesc']); $metakeywords = ppPrepareForDB($_POST['metakeywords']); // Convert array values to numeric permission values list($perm_owner, $perm_group, $perm_members, $perm_anon) = SEC_getPermissionValues($perm_owner, $perm_group, $perm_members, $perm_anon); // Allow full HTML in the introtext field if (!get_magic_quotes_gpc()) { $content = addslashes($_POST['sitecontent']); $help = addslashes($_POST['help']); } else { $content = $_POST['sitecontent']; $help = $_POST['help']; } if ($sid != '') { $sid = COM_sanitizeID($sid); } if ($sid != '' and DB_count($_TABLES['nexcontent_pages'], 'sid', $sid) > 0) { if ($sid != $old_sid) { $duplicate_sid = true; if ($old_sid == '') { $sid = "{$sid}_{$pid}"; $dupmsg = ' - Duplicate Page ID'; } else { $sid = $old_sid; $dupmsg = ' - Duplicate Page ID, Page ID not changed.'; } } } else { $duplicate_sid = false; } if ($mode == 'add') { $gid = uniqid($_DB_name, FALSE); $category = COM_applyFilter($category, true); if ($type == 'category') { // Create a new record - set the category value to 0 DB_query("INSERT INTO {$_TABLES['nexcontent_pages']} (pid,gid,type) values ({$category},'{$gid}','category')"); $pageid = DB_insertID(); $GLOBALS['statusmsg'] = 'New Category Added'; $query = DB_query("SELECT max(pageorder) FROM {$_TABLES['nexcontent_pages']} WHERE type='category'"); list($maxorder) = DB_fetchArray($query); $order = $maxorder + 10; DB_query("UPDATE {$_TABLES['nexcontent_pages']} SET pageorder='{$order}' WHERE id='{$pageid}'"); } else { // Create a new record - need to get the record id for the category DB_query("INSERT INTO {$_TABLES['nexcontent_pages']} (pid,gid,type) values ('{$category}','{$gid}','{$type}')"); $pageid = DB_insertID(); $GLOBALS['statusmsg'] = 'New Page Added'; $query = DB_query("SELECT max(pageorder) FROM {$_TABLES['nexcontent_pages']} WHERE pid='category'"); list($maxorder) = DB_fetchArray($query); $order = $maxorder + 10; DB_query("UPDATE {$_TABLES['nexcontent_pages']} SET pageorder='{$order}' WHERE id='{$pageid}'"); } } else { if ($type == 'category') { $GLOBALS['statusmsg'] = "{$name} Updated"; } else { $GLOBALS['statusmsg'] = "{$name} Updated"; } if ($duplicate_sid) { $GLOBALS['statusmsg'] .= $dupmsg; } } DB_query("UPDATE {$_TABLES['nexcontent_pages']} SET name='{$name}', blockformat='{$blkformat}', pid='{$pid}', sid='{$sid}', heading='{$heading}',content='{$content}', menutype='{$menutype}', is_menu_newpage='{$is_menu_newpage}', show_submenu='{$submenutype}', show_blockmenu='{$blockmenutype}', show_breadcrumbs='{$show_breadcrumbs}', is_draft='{$is_draft}', owner_id='{$owner_id}', group_id='{$group_id}', perm_owner='{$perm_owner}', perm_group='{$perm_group}', perm_members='{$perm_members}', perm_anon='{$perm_anon}' , pagetitle='{$pagetitle}', meta_description='{$metadesc}', meta_keywords='{$metakeywords}' WHERE id='{$pageid}'"); DB_query("UPDATE {$_TABLES['nexcontent']} SET help='{$help}'"); //update the page order if ($pageorder != '' and $pageid != '') { DB_query("UPDATE {$_TABLES['nexcontent_pages']} SET pageorder={$pageorder} WHERE id={$pageid};"); $porder = DB_query("SELECT id FROM {$_TABLES['nexcontent_pages']} WHERE pid={$pid} ORDER BY pageorder ASC;"); $i = 0; while ($ORDER = DB_fetchArray($porder)) { $i += 10; DB_query("UPDATE {$_TABLES['nexcontent_pages']} SET pageorder={$i} WHERE id={$ORDER['id']};"); } } $pageImageDir = $CONF_SE['uploadpath'] . "/{$pageid}/"; // Check and see if directories exist if (!file_exists($pageImageDir)) { $mkdir = @mkdir($pageImageDir); $chmod = @chmod($pageImageDir, $CONF_SE['imagedir_perms']); } // Delete any images if needed for ($i = 0; $i < count($imgdelete); $i++) { $curimage = DB_getitem($_TABLES['nexcontent_images'], "imagefile", "page_id='{$pageid}' AND imagenum='{$imgdelete[$i]}'"); $fullimage = $pageImageDir . $curimage; if (!is_dir($fullimage) and file_exists($fullimage)) { if (!unlink($fullimage)) { echo COM_errorLog("Unable to delete image {$fullimage}. Please check file permissions"); $GLOBALS['statusmsg'] = "Unable to delete image {$fullimage}. Please check file permissions"; } } $pos = strrpos($curimage, '.'); $origimage = strtolower(substr($curimage, 0, $pos)); $ext = strtolower(substr($curimage, $pos)); $origimage .= "_original{$ext}"; $fullimage = $pageImageDir . $origimage; if (!is_dir($fullimage) and file_exists($fullimage)) { if (!unlink($fullimage)) { echo COM_errorLog("Unable to delete image {$fullimage}. Please check file permissions"); $GLOBALS['statusmsg'] = "Unable to delete image {$fullimage}. Please check file permissions"; } } $curthumbnail = $pageImageDir . 'tn' . $curimage; if (!is_dir($curthumbnail) and file_exists($curthumbnail)) { if (!unlink($curthumbnail)) { echo COM_errorLog("Unable to delete thumbnail for {$curthumbnail}. Please check file permissions"); $GLOBALS['statusmsg'] = "Unable to delete thumbnail for {$curthumbnail}. Please check file permissions"; } } DB_query("DELETE FROM {$_TABLES['nexcontent_images']} WHERE page_id='{$pageid}' and imagenum='{$imgdelete[$i]}'"); next($imgdelete); } $upload = new upload(); $upload->setLogging(false); $upload->setDebug(false); $upload->setLogFile($_CONF['path_log'] . 'error.log'); $upload->setMaxFileUploads($CONF_SE['max_num_images']); if ($_CONF['image_lib'] == 'imagemagick') { $upload->setMogrifyPath($_CONF['path_to_mogrify']); } else { $upload->setGDLib(); } $upload->setAllowedMimeTypes($CONF_SE['allowableImageTypes']); $upload->setMaxDimensions($CONF_SE['max_upload_width'], $CONF_SE['max_upload_height']); $upload->setMaxFileSize($CONF_SE['max_uploadfile_size']); $upload->setAutomaticResize(true); $upload->keepOriginalImage(true); $upload->setPerms($CONF_SE['image_perms']); if (!$upload->setPath($pageImageDir)) { $GLOBALS['statusmsg'] = $LANG_SE_ERR['upload1'] . ': ' . $upload->printErrors(false); } // OK, let's upload any pictures with this page if (DB_count($_TABLES['nexcontent_images'], 'page_id', $pageid) > 0) { $index_start = DB_getItem($_TABLES['nexcontent_images'], 'max(imagenum)', "page_id = '{$pageid}'") + 1; } else { $index_start = 1; } $index_start = 1; $uniquename = time(); $filenames = array(); $imagenum = array(); for ($z = 1; $z <= $CONF_SE['max_num_images']; $z++) { $curfile = current($_FILES); if (!empty($curfile['name'])) { $filenames[] = $uniquename . $z . '.jpg'; $imagenum[] = substr(key($_FILES), 9, 1); } next($_FILES); } $upload->setFileNames($filenames); reset($_FILES); $upload->setDebug(false); $upload->uploadFiles(); if ($upload->areErrors()) { $GLOBALS['statusmsg'] = $LANG_SE_ERR['upload1'] . ': ' . $upload->printErrors(false); return false; } reset($filenames); reset($imagenum); if (DB_count($_TABLES['nexcontent_pages'], "id", $pageid) > 0) { foreach ($filenames as $pageImage) { $index = current($imagenum); if (file_exists($pageImageDir . $pageImage)) { $src = $pageImageDir . $pageImage; $dest = $pageImageDir . 'tn' . $pageImage; makethumbnail($pageImage, $src, $dest); $iquery = DB_query("SELECT imagefile from {$_TABLES['nexcontent_images']} WHERE page_id='{$pageid}' AND imagenum='{$index}'"); if (DB_numRows($iquery) == 0) { DB_query("INSERT INTO {$_TABLES['nexcontent_images']} (page_id,imagenum,imagefile) values ('{$pageid}', '{$index}','{$pageImage}')"); } elseif (DB_numRows($iquery) == 1) { DB_query("UPDATE {$_TABLES['nexcontent_images']} SET imagefile='{$pageImage}' WHERE page_id='{$pageid}' and imagenum='{$index}'"); } } next($imagenum); } } else { $GLOBALS['statusmsg'] = 'Error saving category'; } // Update the image autoscale option for any images $query = DB_query("SELECT id,imagenum from {$_TABLES['nexcontent_images']} WHERE page_id='{$pageid}'"); while (list($imageid, $imagenum) = DB_fetchArray($query)) { if ($chkscale[$imagenum] == '1') { DB_query("UPDATE {$_TABLES['nexcontent_images']} SET autoscale = '1' WHERE id='{$imageid}' AND imagenum='{$imagenum}'"); } else { DB_query("UPDATE {$_TABLES['nexcontent_images']} SET autoscale = '0' WHERE id='{$imageid}' AND imagenum='{$imagenum}'"); } } }
break; case "gd2": if ($imginfo[2] == GIS_JPG) { $src_img = imagecreatefromjpeg($src_file); } else { $src_img = imagecreatefrompng($src_file); } $dst_img = imagecreatetruecolor($destWidth, $destHeight); imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $destWidth, (int) $destHeight, $srcWidth, $srcHeight); header("Content-type: image/jpeg"); imagejpeg($dst_img); imagedestroy($src_img); imagedestroy($dst_img); break; default: if ($imginfo[2] == GIS_JPG) { $src_img = imagecreatefromjpeg($src_file); } else { $src_img = imagecreatefrompng($src_file); } $dst_img = imagecreate($destWidth, $destHeight); imagecopyresized($dst_img, $src_img, 0, 0, 0, 0, $destWidth, (int) $destHeight, $srcWidth, $srcHeight); header("Content-type: image/jpeg"); imagejpeg($dst_img); imagedestroy($src_img); imagedestroy($dst_img); break; } } makethumbnail($CONFIG['fullpath'] . $HTTP_GET_VARS['picfile'], $HTTP_GET_VARS['size'], $CONFIG['thumb_method']);