/** * function used to get video files only3 */ function get_video_files($with_path = false) { $exts = get_vid_extensions($with_path); $vid_files = array(); $files = $this->get_files(); if (is_array($files)) { foreach ($files as $file) { $ext = getext($file['file']); if (in_array($ext, $exts)) { $vid_files[] = $file; } } } return $vid_files; }
function template_rm_dir($dir) { if (getext(substr($dir, 0, -1)) == 'js') { return; } if (is_file(substr($dir, 0, -1))) { @unlink(substr($dir, 0, -1)); return; } if ($d = opendir($dir)) { while (($f = readdir($d)) !== false) { if ($f != '.' && $f != '..') { template_rm_dir($dir . $f . DIRECTORY_SEPARATOR, $object); } } @rmdir($dir . $f); } }
function del_dir($path, &$info, &$err) { global $user; $info = array(); $info["file"] = 0; $info["dir"] = 0; if (!is_dir($path)) { return false; } if ($this->get_perm($path) != "0777") { $this->ftp_cmode($path, "0777"); } $this->my_list($path, $dirs, $files); foreach ($files as $f) { $ftype = getext($f); if ($user["limit"]["{$ftype}"] && !$user["only"]) { $err .= "文件{$f}删除失败:不能删除{$user["limittype"]}类型的文件!"; } else { if (!$user["limit"]["{$ftype}"] && $user["only"]) { $err .= "文件{$f}删除失败:不能删除除{$user["limittype"]}类型以外的文件!"; } else { if (@unlink($f)) { $info["file"]++; } else { $err .= "文件{$f}删除失败!\n"; } } } } for ($i = count($dirs) - 1; $i >= 0; $i--) { $f = $dirs[$i]; if (!@rmdir($f)) { $err .= "目录{$f}删除失败!\n"; } else { $info["dir"]++; } } if (@rmdir($path)) { $info["dir"]++; } return $info["dir"]; }
function encrypt_project($project, $new_project) { $project = rtrim($project, '/'); $new_project = rtrim($new_project, '/'); if (!file_exists($new_project)) { if (!mkdir($new_project)) { printf("[failed] failed to call `mkdir()' function\n"); return false; } } $hdl_o = opendir($project); $hdl_n = opendir($new_project); if (!$hdl_o || !$hdl_n) { if ($hdl_o) { closedir($hdl_o); } if ($hdl_n) { closedir($hdl_n); } printf("[failed] failed to call `opendir()' function\n"); return false; } while (($file = readdir($hdl_o)) !== false) { if ($file == '.' || $file == '..') { continue; } $path = $project . '/' . $file; if (is_dir($path)) { encrypt_project($path, $new_project . '/' . $file); } elseif (is_file($path) && getext($file) == 'php') { beast_encode_file($path, $new_project . '/' . $file); } else { copy($path, $new_project . '/' . $file); } } closedir($hdl_o); closedir($hdl_n); return true; }
} $dir = $config_vars['default_upload_dir']; if ($HTTP_POST_VARS['moveup'] == "up") { $temp = $HTTP_SESSION_VARS['files'][$HTTP_POST_VARS['id'] - 1]; $HTTP_SESSION_VARS['files'][$HTTP_POST_VARS['id'] - 1] = $HTTP_SESSION_VARS['files'][$HTTP_POST_VARS['id']]; $HTTP_SESSION_VARS['files'][$HTTP_POST_VARS['id']] = $temp; } else { if ($HTTP_POST_VARS['movedown'] == "down") { $temp = $HTTP_SESSION_VARS['files'][$id + 1]; $HTTP_SESSION_VARS['files'][$id + 1] = $HTTP_SESSION_VARS['files'][$id]; $HTTP_SESSION_VARS['files'][$id] = $temp; } elseif (isset($dir)) { unset($HTTP_SESSION_VARS['files']); $dir_handle = opendir($dir); while ($file = readdir($dir_handle)) { if ($file != "." && $file != ".." and isset($filetypes[getext($file)])) { $f['filesize'] = round(filesize($dir . '/' . $file) / 1024, 1); $f['size'] = getimagesize($dir . '/' . $file); $f['url'] = $dir . '/' . $file; $f['name'] = basename($file); $HTTP_SESSION_VARS['files'][] = $f; } } } } $smarty->assign('files', $HTTP_SESSION_VARS['files']); $smarty->assign('files_size', sizeof($HTTP_SESSION_VARS['files'])); $smarty->assign('dir', $dir); if (!isset($HTTP_POST_VARS['thumbsize'])) { $HTTP_POST_VARS['thumbsize'] = 50; }
/** * Function used to create group thumbnail * @param = $gpid {ID of group for which thumbnail is being created } * @param = $file { Source of image file $_FILES } */ function create_group_image($gpid, $file) { global $imgObj; $file_ext = strtolower(getext($file['name'])); $exts = array('jpg', 'png', 'gif', 'jpeg'); foreach ($exts as $ext) { if ($ext == $file_ext) { $thumb_name = $gpid . '.' . $ext; $small_thumb_name = $gpid . '-small.' . $ext; $path = GP_THUMB_DIR . '/' . $thumb_name; $small_path = GP_THUMB_DIR . '/' . $small_thumb_name; foreach ($exts as $unlink_ext) { if (file_exists(GP_THUMB_DIR . '/' . $gpid . '.' . $unlink_ext)) { unlink(GP_THUMB_DIR . '/' . $gpid . '.' . $unlink_ext); } } move_uploaded_file($file['tmp_name'], $path); if (!$imgObj->ValidateImage($path, $ext)) { e(lang('pic_upload_vali_err')); } else { $imgObj->CreateThumb($path, $path, $this->gp_thumb_width, $ext, $this->gp_thumb_height, true); $imgObj->CreateThumb($path, $small_path, $this->gp_small_thumb_width, $ext, $this->gp_small_thumb_height, true); } } } }
/** * Function used to add category thumbnail * @param $Cid and Array */ function add_category_thumb($cid, $file) { global $imgObj; if ($this->category_exists($cid)) { //Checking for category thumbs direcotry if (isset($this->thumb_dir)) { $dir = $this->thumb_dir; } else { $dir = $this->section_tbl; } //Checking File Extension $ext = strtolower(getext($file['name'])); if ($ext == 'jpg' || $ext == 'png' || $ext == 'gif') { $dir_path = CAT_THUMB_DIR . '/' . $dir; if (!is_dir($dir_path)) { @mkdir($dir_path, 0777); } if (is_dir($dir_path)) { $path = $dir_path . '/' . $cid . '.' . $ext; //Removing File if already exists if (file_exists($path)) { unlink($path); } move_uploaded_file($file['tmp_name'], $path); //Now checking if file is really an image if (!@$imgObj->ValidateImage($path, $ext)) { e(lang("pic_upload_vali_err")); unlink($path); } else { $imgObj->CreateThumb($path, $path, $this->cat_thumb_width, $ext, $this->cat_thumb_height, true); } } else { e(lang("cat_dir_make_err")); } } else { e(lang("cat_img_error")); } } }
if ($_FILES["ext2"]["tmp_name"] != "" && $_POST["ext2_chk"] != 1) { $myext2 = savefile("ext2", __racinebd__ . "list_images2_"); } else { if ($_POST["ext2"] != "" && $_POST["ext2_chk"] != 1) { $filename2 = preg_replace('/[^a-z0-9_\\-\\.]/i', '_', $_FILES["ext2"]["name"]); $myext2 = ",ext2='" . getext($_FILES["ext2"]["name"]) . "',nom_fichier2='" . $filename2 . "'"; } else { if ($_POST["ext2_chk"] == 1) { $myext2 = ",ext1=null"; } } } //if(move_uploaded_file($_FILES["ext"]["tmp_name"],$_SERVER["DOCUMENT_ROOT"].__uploaddir__."u".$_SESSION['users_id']."/".$filename)===false){ //sauvegarde en base $ext1 = getext($_FILES["ext1"]["name"]); $ext2 = getext($_FILES["ext2"]["name"]); $sql = "update " . __racinebd__ . "list_images \r\n set titre1='" . addquote($_POST["titre_fichier1"]) . "',\r\n titre2='" . addquote($_POST["titre_fichier2"]) . "',\r\n lightbox='" . addquote($_POST["lightbox"]) . "',\r\n contenulightbox='" . addquote($_POST["contenu"]) . "'\r\n {$myext1}\r\n {$myext2}\r\n where images_id=" . $_POST["images_id"]; /* ext1,nom_fichier1,titre2,ext2,nom_fichier2,lightbox,contenulightbox) value(,'".$ext1."','".$filename1."','".addquote($_POST["titre_fichier2"])."','".$ext2."','".$filename2."','".$_POST["lightbox"]."','".$_POST["contenu"]."')"; */ $link = query($sql); //$images_id=insert_id(); $sql = "select * from " . __racinebd__ . "list_images where images_id=" . $_POST["images_id"]; $link = query($sql); $tbl_info = fetch($link); ?> <script> //parent. //content='<table width="100%" style="border-bottom:1px solid black" id="table_image_<?php
<?php require "../../require/function.php"; require "../../require/back_include.php"; set_time_limit(3600); if ($_POST["prix"] != "") { //creation du repertoire tmp //@mkdir ($_SERVER["DOCUMENT_ROOT"].__uploaddir__."u".$_SESSION['users_id'], 0775); //deplacement du fichier //move_uploaded_file($_FILES[ext]["tmp_name"],$_SERVER["DOCUMENT_ROOT"].__uploaddir__."u".$_SESSION['users_id']."/".$_FILES["ext"]["name"]); $filename = preg_replace('/[^a-z0-9_\\-\\.]/i', '_', $_FILES["ext"]["name"]); //if(move_uploaded_file($_FILES["ext"]["tmp_name"],$_SERVER["DOCUMENT_ROOT"].__uploaddir__."u".$_SESSION['users_id']."/".$filename)===false){ //sauvegarde en base $ext = getext($_FILES["ext"]["name"]); $sql = "insert into " . __racinebd__ . "prix (montant,quantite,ref) value('" . addquote($_POST["prix"]) . "','" . addquote($_POST["quantite"]) . "','" . addquote($_POST["ref"]) . "')"; $link = query($sql); $prix_id = insert_id(); $querystring = "select * from " . __racinebd__ . "attribut where supprimer=0 order by libelle"; $link = query($querystring); while ($tbl = fetch($link)) { //print "attr_".$tbl["attribut_id"]."<br>"; //print $_POST["attr_".$tbl["attribut_id"]]; if ($_POST["attr_" . $tbl["attribut_id"]] != "" && $_POST["attr_" . $tbl["attribut_id"]] != -1) { $sql = "insert into " . __racinebd__ . "valeur_prix (valeur_id,prix_id,attribut_id) value('" . addquote($_POST["attr_" . $tbl["attribut_id"]]) . "','" . $prix_id . "','" . $tbl["attribut_id"] . "')"; query($sql); } } ?> <script> content='<table width="100%" style="border-bottom:1px solid black" id="table_prix_<?php echo $prix_id;
function testext($name, $listext) { return array_search(getext($_FILES[$name]["name"]), $listext) === false ? false : true; }
function end_upload_file($name, $file, $attr) { global $errors, $config; $ftype = getext($file['name']); //echo $ftype; //var_dump($config); var_dump($attr); die(); //如果是图片,那么只能上传这几种文件类型 if ($attr['type'] == 'image' || $attr['type'] == 'imagelist') { $attr['filetype'] = array('jpg', 'jpeg', 'png', 'gif'); } //验证文件类型 if (!$config['upload_file_types']) { $errors[$name] = lang('need_config_upload_file_types'); } else { if (!$attr['filetype']) { $errors[$name] = lang('file_type_not_configed'); } else { if (!preg_match("/\\*\\.{$ftype};/i", $config['upload_file_types']) && !in_array($ftype, $attr['filetype'])) { $errors[$name] = lang('not_allowed_file_type'); } else { $file_url = $file['name']; //如果文件名是一般的字母数字和-_,则不改变文件名 if (preg_match('/^[a-z0-9\\_\\-\\s\\.]+$/i', $file_url)) { $file_url = preg_replace('/\\s+/', '_', $file_url); } else { //否则改成时间和随机数 $file_url = date('Y_m_d_H_i_s_') . rand(1111, 9999) . '.' . $ftype; } if (!$file_url) { $errors[$name] = 'error'; } //保存到什么地方 if (!$attr['saveto']) { end_mkdir(END_ROOT . END_UPLOAD_DIR); $file_url = END_UPLOAD_DIR . $file_url; } else { end_mkdir(END_ROOT . $attr['saveto']); $file_url = $attr['saveto'] . $file_url; } //避免重名 while (file_exists(END_ROOT . $file_url)) { $file_url = dirname($file_url) . '/' . preg_replace('/\\.[a-z0-9]+$/i', '', basename($file_url)) . rand(1111, 9999) . '.' . $ftype; } //保存文件 if (@move_uploaded_file($file["tmp_name"], END_ROOT . $file_url)) { if ($attr['filter']) { $file_url = $attr['filter']($file_url); } //$data[$name] = $file_url; //更改图片尺寸 if ($attr['type'] == 'image' && is_array($attr['resize'])) { foreach ($attr['resize'] as $_r) { if (is_array($_r) && $_r['width'] && $_r['height']) { //调整图片尺寸,保存为 $__re = thumb($file_url, $_r['width'], $_r['height']); if ($_r['saveas']) { $data[$_r['saveas']] = $__re; } } } } if (($attr['type'] == 'image' || $attr['type'] == 'imagelist') && $attr['max_width']) { include_once END_ROOT . 'end_system/library/image.php'; $img = new Image(); $img->filepath = END_ROOT . $file_url; $img->resize_width($attr['max_width']); } } if (!file_exists(END_ROOT . $file_url)) { $errors[$name] = lang('upload_error'); } if (!is_writable(END_ROOT . dirname($file_url))) { $errors[$name] = dirname($file_url) . ' ' . lang('is not writable'); } return $file_url; } } } }
/** * function used to upload user avatar and or background */ function upload_user_file($type = 'a', $file, $uid) { global $db, $userquery, $cbphoto, $imgObj; $avatar_dir = BASEDIR . '/images/avatars/'; $bg_dir = BASEDIR . '/images/backgrounds/'; if ($userquery->user_exists($uid)) { switch ($type) { case 'a': case 'avatar': if ($file['size'] / 1024 > config('max_profile_pic_size')) { e(sprintf(lang('file_size_exceeds'), config('max_profile_pic_size'))); } elseif (file_exists($file['tmp_name'])) { $ext = getext($file['name']); $file_name = $uid . '.' . $ext; $file_path = $avatar_dir . $file_name; if (move_uploaded_file($file['tmp_name'], $file_path)) { if (!$imgObj->ValidateImage($file_path, $ext)) { e(lang("Invalid file type")); @unlink($file_path); } else { $small_size = $avatar_dir . $uid . '-small.' . $ext; $cbphoto->CreateThumb($file_path, $file_path, $ext, AVATAR_SIZE, AVATAR_SIZE); $cbphoto->CreateThumb($file_path, $small_size, $ext, AVATAR_SMALL_SIZE, AVATAR_SMALL_SIZE); } } else { e(lang("class_error_occured")); } } break; case 'b': case 'bg': case 'background': if ($file['size'] / 1024 > config('max_bg_size')) { e(sprintf(lang('file_size_exceeds'), config('max_bg_size'))); } elseif (file_exists($file['tmp_name'])) { $ext = getext($file['name']); $file_name = $uid . '.' . $ext; $file_path = $bg_dir . $file_name; if (move_uploaded_file($file['tmp_name'], $file_path)) { if (!$imgObj->ValidateImage($file_path, $ext)) { e(lang("Invalid file type")); @unlink($file_path); } else { $imgObj->CreateThumb($file_path, $file_path, BG_SIZE, $ext); } } else { e(lang("An error occured While Uploading File!")); } } break; } return $file_name; } else { e(lang('user_doesnt_exist')); } }
/** * Function used to check weather video has Mp4 file or not */ function has_hq($vdetails, $is_file = false) { if (!$is_file) { $file = get_hq_video_file($vdetails); } else { $file = $vdetails; } if (getext($file) == 'mp4') { return $file; } else { return false; } }
function generate_filename() { global $config_vars; //check if content is already in a cat if (!isset($this->cat_ids)) { $this->generate_content_in_cat_data(); } if (sizeof($this->cat_ids) > 0) { $cat_obj = new categorie(); $cat_obj->generate_from_id($this->cat_ids[0]); $path = $cat_obj->get_name(); while ($cat_obj->get_parent_id() != $config_vars['root_categorie']) { $old_cat_id = $cat_obj->get_parent_id(); $cat_obj = new categorie(); $cat_obj->generate_from_id($old_cat_id); $path = $cat_obj->get_name() . '/' . $path; } // make $path is it doesnt exists if (!is_dir($config_vars['content_path_prefix'] . '/' . $path)) { makedir($config_vars['content_path_prefix'] . '/' . $path); } $path = $path . '/' . basename($this->name) . '.' . getext($this->file); $filename = $config_vars['content_path_prefix'] . '/' . $path; // if filename has changed check if such a file does not already exists is so add a number behind till its a new file if ($this->file != $filename) { $newfilename = $filename; $i = 0; while (is_file($newfilename)) { $newfilename = getfile($filename) . "-{$i}." . getext($filename); $i++; } $filename = $newfilename; } return $filename; } else { return OP_CONTENT_NOT_IN_CAT; } }
function checktype($filename) { global $user; $ftype = getext($filename); if ($user["limit"]["{$ftype}"] && !$user["only"]) { exitme("notice(lang.cannot_types)", "eval"); } else { if (!$user["limit"]["{$ftype}"] && $user["only"]) { exitme("notice(lang.only_types);", "eval"); } } }
////////////文件上传////////////// if ($action == "upsave" && $user["upfile"]) { if (substr($path, -1) != "/") { $path .= "/"; } $tt = 0; $error = ''; $tsize = 0; if (!is_writable($path)) { exit3("上传失败:目录 {$path} 不可写!", 0); } foreach ($_FILES as $file) { if ($file['tmp_name']) { $myfile = $file["tmp_name"]; $myfile_name = checkfilename($file["name"]); $ftype = getext($myfile_name); if ($myfile_name != $file["name"] || !$myfile_name) { $error .= "{$myfile_name}上传失败:文件名有错误\\n"; } else { if ($user["limit"]["{$ftype}"] && !$user["only"]) { $error .= "{$myfile_name}上传失败:不能能上传 " . $user["limittype"] . " 类型的文件\\n"; } else { if (!$user["limit"]["{$ftype}"] && $user["only"]) { $error .= "{$myfile_name}上传失败:不能能上传除 " . $user["limittype"] . " 类型以外的文件\\n"; } else { if (file_exists($path . $myfile_name)) { $error .= $myfile_name . "上传失败:有同名文件存在!\\n"; continue; } else { if (@move_uploaded_file($myfile, $path . $myfile_name)) { $tt++;
{ global $config, $a_vlans; $iflist = get_configured_interface_list(false, true); foreach ($iflist as $if) { if ($config['interfaces'][$if]['if'] == $a_vlans[$num]['vlanif']) { return true; } } return false; } if ($_GET['act'] == "del") { if (!isset($_GET['id'])) { $input_errors[] = getext("Wrong parameters supplied"); } else { if (empty($a_vlans[$_GET['id']])) { $input_errors[] = getext("Wrong index supplied"); } else { if (vlan_inuse($_GET['id'])) { $input_errors[] = gettext("This VLAN cannot be deleted because it is still being used as an interface."); } else { if (does_interface_exist($a_vlans[$_GET['id']]['vlanif'])) { legacy_interface_destroy($a_vlans[$_GET['id']]['vlanif']); } unset($a_vlans[$_GET['id']]); write_config(); header("Location: interfaces_vlan.php"); exit; } } } }
$add_to_contentgroups = get_contentgroups_data_where_perm('id,name', 'add_to_group'); if (is_array($add_to_contentgroups)) { $smarty->assign('add_to_contentgroups', $add_to_contentgroups); } } if (check_cat_action_allowed($category->get_catgroup_id(), $userdata['user_id'], 'comment_edit')) { $smarty->assign('allow_comment_edit', true); } // check if user is allowed to add content if (check_cat_action_allowed($category->get_catgroup_id(), $userdata['user_id'], 'content_add')) { $smarty->assign('allow_content_add', true); // get catgroups where add_to_group is allowed $add_to_contentgroups = get_contentgroups_data_where_perm('id,name', 'add_to_group'); $smarty->assign('add_to_contentgroups', $add_to_contentgroups); if (isset($HTTP_POST_VARS['newcontent'])) { $objtyp = $filetypes[getext($HTTP_POST_FILES['new_content_file']['name'])]; if (isset($objtyp)) { add_content($HTTP_POST_FILES['new_content_file']['name'], $HTTP_POST_FILES['new_content_file']['tmp_name'], $HTTP_POST_VARS['new_content_name'], $HTTP_GET_VARS['cat_id'], $HTTP_POST_VARS['new_content_place_in_cat'], $HTTP_POST_VARS['new_content_group']); } elseif (eregi("zip\$", $HTTP_POST_FILES['new_content_file']['name'])) { // its a zip file $zip = new PclZip($HTTP_POST_FILES['new_content_file']['tmp_name']); $folder = $config_vars['default_upload_dir'] . "/zip_" . $userdata['username']; makedir($folder); $zip->extract(PCLZIP_OPT_PATH, $folder); add_dir_parsed($folder, $HTTP_POST_VARS['new_content_group'], $HTTP_GET_VARS['cat_id']); // remove directory; unlink($folder . "/index.html"); rmdir($folder); } } }
function gethumb($sfp, $w = '', $h = '', $scale = false, $callback = false) { global $iCMS; if (strpos($sfp, 'thumb/') !== false || strpos($sfp, 'http://') !== false) { return $sfp; } $sfn = substr($sfp, 0, strrpos($sfp, '.')); $sfn = substr($sfn, strrpos($sfn, '/')); $tpf = substr($sfp, 0, strrpos($sfp, '/')) . '/thumb' . $sfn . '_'; $rootpf = getfilepath($tpf, iPATH, '+'); if ($callback) { $tfArray = glob($rootpf . "*"); if ($tfArray) { foreach ($tfArray as $filename) { if (file_exists($filename)) { $fn = substr($filename, 0, strrpos($filename, '.')); $per = substr($fn, strrpos($fn, '_') + 1); $tfpList[$per] = $filename; } } } return $tfpList; } else { $srfp = getfilepath($sfp, iPATH, '+'); if (file_exists($srfp)) { empty($w) && ($w = $iCMS->config['thumbwidth']); empty($h) && ($h = $iCMS->config['thumbhight']); $twh = $rootpf . $w . 'x' . $h . '.' . getext($sfp); if (!file_exists($twh)) { $Thumb = MakeThumbnail(substr($srfp, 0, strrpos($srfp, '/')) . '/', $srfp, substr($sfn, strrpos($sfn, '/') + 1), $w, $h, $scale); $twh = $Thumb['src']; } $src = $iCMS->dir . getfilepath($twh, iPATH, '-'); } else { $src = $iCMS->dir . 'include/nopic.gif'; } return $src; } }
$myext3 = "'" . $_POST["ext3"] . "'"; } else { $myext3 = "null"; } } if ($_FILES["ext4"]["tmp_name"] != "") { $myext4 = "'" . getext($_FILES["ext4"]["name"]) . "'"; } else { if ($_POST["ext4"] != "") { $myext4 = "'" . $_POST["ext4"] . "'"; } else { $myext4 = "null"; } } if ($_FILES["ext5"]["tmp_name"] != "") { $myext5 = "'" . getext($_FILES["ext5"]["name"]) . "'"; } else { if ($_POST["ext5"] != "") { $myext5 = "'" . $_POST["ext5"] . "'"; } else { $myext5 = "null"; } } $szQuery = "insert into {$table} (titre1,titre2,titre3,titre4,titre5,abstract,contenu,date_actu,date_fin,ext,version_id,contenu_id,ext2,note,abstratc2,abstract3,abstract4,abstract5,ext3,ext4,twitter,tva_id,fournisseur_id,note1,note2,note3,note4,archive,envoye,titleseo,abstractseo,robotseo,ext5)\r\n values ('" . addquote($_POST["titre1"]) . "','" . addquote($_POST["titre2"]) . "','" . addquote($_POST["titre3"]) . "','" . addquote($_POST["titre4"]) . "','" . addquote($_POST["titre5"]) . "',\r\n '" . addquote($_POST["abstract"]) . "','" . addquote($_POST["contenu"]) . "','" . datetimebdd($_POST["date_actu"]) . "','" . datetimebdd($_POST["date_fin"]) . "',{$myext}," . $_POST["version_id"] . ",\r\n " . $contenu_id . ",{$myext2},'" . $_POST["note"] . "','" . addquote($_POST["abstract2"]) . "','" . addquote($_POST["abstract3"]) . "','" . addquote($_POST["abstract4"]) . "','" . addquote($_POST["abstract5"]) . "',{$myext3},{$myext4},\r\n '" . addquote($_POST["twitter"]) . "','" . addquote($_POST["tva_id"]) . "','" . addquote($_POST["fournisseur_id"]) . "','" . addquote($_POST["note1"]) . "','" . addquote($_POST["note2"]) . "',\r\n '" . addquote($_POST["note3"]) . "','" . addquote($_POST["note4"]) . "','" . addquote($_POST["archive"]) . "','" . addquote($_POST["envoye"]) . "','" . addquote($_POST["titleseo"]) . "','" . addquote($_POST["abstractseo"]) . "','" . addquote($_POST["robotseo"]) . "',{$myext5})"; $link = query($szQuery); $id = insert_id(); $content_id = $id; $_GET['id'] = $id; createdefault("ext", $table, $id); createdefault("ext2", $table . "2_", $id); createdefault("ext3", $table . "3_", $id);
function GetSFileList($dir, $content, $re = 0) { global $filedata, $j, $nowpath, $writabledb; !$j && ($j = 1); if ($dh = opendir($dir)) { while ($file = readdir($dh)) { $ext = getext($file); $f = str_replace('//', '/', $dir . '/' . $file); if ($file != '.' && $file != '..' && is_dir($f)) { GetSFileList($f, $content, $re = 0); } elseif ($file != '.' && $file != '..' && is_file($f) && in_array($ext, explode(',', $writabledb))) { $find = 0; if ($re) { if (preg_match('@' . $content . '@', $file) || preg_match('@' . $content . '@', @file_get_contents($f))) { $find = 1; } } else { if (strstr($file, $content) || strstr(@file_get_contents($f), $content)) { $find = 1; } } if ($find) { $filedata[$j]['filename'] = str_replace($nowpath, '', $f); $filedata[$j]['size'] = sizecount(@filesize($f)); $filedata[$j]['mtime'] = @date('Y-m-d H:i:s', filemtime($f)); $filedata[$j]['filechmod'] = getChmod($f); $filedata[$j]['fileperm'] = getPerms($f); $filedata[$j]['fileowner'] = getUser($f); $filedata[$j]['dirlink'] = $dir; $filedata[$j]['server_link'] = $f; $j++; } } } closedir($dh); clearstatcache(); return $filedata; } else { return array(); } }
$img->resize_width($config['max_image_width']); } } $view_data['file_url'] = $file_url; $view_data['filename'] = $file['name']; $view_data['err'] = $err; $view_data['msg'] = $msg; } $handler = @opendir(END_ROOT . END_UPLOAD_DIR); $recent = array(); while (($val = readdir($handler)) !== false) { if ($val == '.' || $val == '..' || !is_file(END_ROOT . END_UPLOAD_DIR . $val)) { continue; } $fname = $val; $ftype = strtolower(getext($val)); $encode = preg_replace('/[a-zA-Z0-9_\\.\\{\\}\\[\\]\\(\\)]*/i', '', $val) != ''; $recent[] = array('name' => $fname, 'filepath' => END_UPLOAD_DIR . $val, 'mtime' => filemtime(END_ROOT . END_UPLOAD_DIR . $val), 'ftype' => $ftype, 'encode' => $encode ? 'yes' : 'no', 'isimg' => strpos(',jpg,jpeg,gif,png,bmp', ',' . $ftype . ',') === false ? 'no' : 'yes'); } closedir($handler); usort($recent, "cmp_time"); $view_data['recent'] = array(); $view_data['for'] = $_GET['for']; foreach ($recent as $arr) { $view_data['recent'][] = $arr; if (count($view_data['recent']) > 20) { break; } } unset($recent); function cmp_time($a, $b)
function upload_new_avatar($file, $uid) { global $userquery, $cbphoto, $cbcollection, $db; $size = $file['size']; $user = $userquery->get_user_details($uid); $avatar_dir = BASEDIR . '/images/avatars/'; if ($user) { if ($file['size'] / 1024 > config('max_profile_pic_size')) { e(sprintf(lang('file_size_exceeds'), config('max_profile_pic_size'))); } elseif (file_exists($file['tmp_name'])) { $ext = getext($file['name']); $filename = cb_filename(); $photopath = PHOTOS_DIR . '/' . createDataFolders(PHOTOS_DIR) . '/'; if (validate_image_file($file['tmp_name'], $ext)) { $cid = cb_create_user_avatar_collection($user); if (move_uploaded_file($file['tmp_name'], $photopath . $filename . '.' . $ext)) { $fields = array('photo_title' => 'Avatar', 'photo_description' => ' ', 'photo_tags' => ' ', 'filename' => $filename, 'userid' => $uid, 'ext' => $ext, 'is_avatar' => true, 'collection_id' => $cid); $photo_id = $cbphoto->insert_photo($fields); $avatar = $uid . '_' . $filename . '.' . $ext; $avatarpath = $avatar_dir . $avatar; /* Resizing starts here */ $r = new CB_Resizer($photopath . $filename . '.' . $ext); /* Big Thumb */ $r->target = USER_THUMBS_DIR . '/' . $avatar; $r->_resize(AVATAR_SIZE, AVATAR_SIZE); $r->save(); /* Small Thumb */ $r->target = USER_THUMBS_DIR . '/' . $uid . '_' . $filename . '-small.' . $ext; $r->_resize(AVATAR_SMALL_SIZE, AVATAR_SMALL_SIZE); $r->save(); /* Resizing ends here */ /* Update user avatar field */ $db->update(tbl('users'), array('avatar'), array($avatar), " userid = '" . $uid . "' "); /* Update cover photo of collection */ $cbcollection->set_cover_photo($photo_id, $cid); return $avatar; } else { e(lang('Unable to upload file. Please try again')); if (file_exists($file['tmp_name'])) { unlink($file['tmp_name']); } return false; } } else { e(lang('Invalid File Type')); return false; } } } else { e(lang('user_doesnt_exist')); return false; } }
function add_dir_parsed($dir, $group_id, $parent_id = -1) { // Add all pictures under the Directory $dir to categories and series depending on the relativ path to $dir global $db, $config_vars, $filetypes; if ($parent_id == -1) { $parent_id = $config_vars['root_categorie']; } $dir_handle = opendir($dir); while ($file = readdir($dir_handle)) { if ($file != "." && $file != "..") { $dir_and_file = $dir . '/' . $file; if (isset($filetypes[getext($file)])) { // $file is content // generate a new album_content obj add_content($file, $dir_and_file, getfile($file), $parent_id, 0, $group_id); } elseif (is_dir($dir_and_file)) { //file is a sub dir $cat = new categorie(); $cat->set_name($file); $cat->set_parent_id($parent_id); $cat->fill_up(); $cat->set_catgroup_id($group_id); if (!isset($cat->id)) { $cat->commit(); } add_dir_parsed($dir . '/' . $file, $group_id, $cat->get_id()); } } } closedir($dir_handle); }
/** * Function used to create collection preview */ function upload_thumb($cid, $file) { global $imgObj, $cbphoto; $file_ext = strtolower(getext($file['name'])); $exts = array("jpg", "gif", "jpeg", "png"); foreach ($exts as $ext) { if ($ext == $file_ext) { $thumb = COLLECT_THUMBS_DIR . "/" . $cid . "." . $ext; $sThumb = COLLECT_THUMBS_DIR . "/" . $cid . "-small." . $ext; foreach ($exts as $un_ext) { if (file_exists(COLLECT_THUMBS_DIR . "/" . $cid . "." . $un_ext) && file_exists(COLLECT_THUMBS_DIR . "/" . $cid . "-small." . $un_ext)) { unlink(COLLECT_THUMBS_DIR . "/" . $cid . "." . $un_ext); unlink(COLLECT_THUMBS_DIR . "/" . $cid . "-small." . $un_ext); } } move_uploaded_file($file['tmp_name'], $thumb); if (!$imgObj->ValidateImage($thumb, $ext)) { e("pic_upload_vali_err"); } else { $imgObj->createThumb($thumb, $thumb, $this->collect_thumb_width, $ext, $this->collect_thumb_height); $imgObj->createThumb($thumb, $sThumb, $this->collect_small_thumb_width, $ext, $this->collect_small_thumb_height); } } } }
function updateContent($content_id, $arbre_id, $langue_id) { //recherche du contenu_id $requete_select_contenu = "select contenu_id,shortlib from " . __racinebd__ . "contenu c inner join " . __racinebd__ . "langue l on c.langue_id=l.langue_id where arbre_id = " . $arbre_id . " and l.langue_id!=" . $langue_id; $link_select_contenu = query($requete_select_contenu); $requete_select_content = "select * from " . __racinebd__ . "content where content_id = " . $content_id; $link_select_content = query($requete_select_content); $ligne_select_content = fetch($link_select_content); //print_r($_POST); //$result = mysql_query("select * from table"); $listfile = array(); while ($ligne_select_contenu = fetch($link_select_contenu)) { //$requete="insert into ".__racinebd__."content "; $listchamps = array(); $listvalue = array(); $listext = array(); //$listchamps[]="contenu_id"; //$listvalue[]=$ligne_select_contenu["contenu_id"]; for ($i = 0; $i < mysql_num_fields($link_select_content); $i++) { if (mysql_field_name($link_select_content, $i) != "content_id" && mysql_field_name($link_select_content, $i) != "contenu_id") { $champs = mysql_field_name($link_select_content, $i); if (strpos($champs, "ext") === false) { if ($_POST[$champs . "___" . $ligne_select_contenu["shortlib"]] != "") { $value = "'" . addslashes($_POST[$champs . "___" . $ligne_select_contenu["shortlib"]]) . "'"; } else { $value = "'" . addslashes($ligne_select_content[$champs]) . "'"; } $listchamps[] = $champs . "=" . $value; } else { //print $champs."___".$ligne_select_contenu["shortlib"]." : ".$_FILES[$champs."___".$ligne_select_contenu["shortlib"]]; //print_r($_FILES); if (isset($_FILES[$champs . "___" . $ligne_select_contenu["shortlib"]])) { //$numext=explode("___",$champs); //sauvegarde du fichier /* if(strlen($numext[0])>3){ $numext=substr($numext[0],-1); */ //print "ici"; if (strlen($champs) > 3) { $numext = substr($champs, -1); //print $numext; $listfile[] = array($champs . "___" . $ligne_select_contenu["shortlib"], __racinebd__ . "content" . $numext . "_"); } else { $listfile[] = array($champs . "___" . $ligne_select_contenu["shortlib"], __racinebd__ . "content"); } //$value=($_POST[$champs."___".$ligne_select_contenu["shortlib"]]=="")?"null":"'".$_POST[$champs."___".$ligne_select_contenu["shortlib"]]."'"; $value = $_FILES[$champs . "___" . $ligne_select_contenu["shortlib"]]["name"] != "" ? "'" . getext($_FILES[$champs . "___" . $ligne_select_contenu["shortlib"]]["name"]) . "'" : "null"; } else { $value = $ligne_select_content[$champs] == "" ? "null" : "'" . $ligne_select_content[$champs] . "'"; $listext[] = $champs; } if ($_POST[$champs . "___" . $ligne_select_contenu["shortlib"] . "_chk"] == 1) { $listchamps[] = $champs . "=null"; } else { if ($value != "null") { $listchamps[] = $champs . "=" . $value; } } } } } $requete_update_content = "update " . __racinebd__ . "content set " . implode(",", $listchamps) . " where contenu_id=" . $ligne_select_contenu["contenu_id"]; //print $requete_insert_content; //echo $requete_insert_content; $link = query($requete_update_content); //verification que la mise ajour a été effectué sinon on crée un enregistrement $sql = "select * from " . __racinebd__ . "content where contenu_id=" . $ligne_select_contenu["contenu_id"]; $link = query($sql); if (num_rows($link) == 0) { copyContent($content_id, $arbre_id, $langue_id, $ligne_select_contenu["langue_id"]); } else { $tbl = fetch($link); /* print_r($listfile); print_r($listext); */ //sauvegarde des fichiers différents for ($j = 0; $j < count($listfile); $j++) { savefile($listfile[$j][0], $listfile[$j][1], $tbl["content_id"]); } $dernier_ajout_content = $tbl["content_id"]; //a faire pour l'update //print_r($listext); for ($listextindice = 0; $listextindice < count($listext); $listextindice++) { $suffixe = strlen($listext[$listextindice]) > 3 ? substr($listext[$listextindice], -1) . "_" : ""; //$suffixe=($listextindice==0)?"":($listextindice+1)."_"; //print $_SERVER["DOCUMENT_ROOT"].__uploaddir__.__racinebd__.'content'.$suffixe.$ligne_select_content['content_id'].'.'.$ligne_select_content[$listext[$listextindice]]."<br>"; @copy($_SERVER["DOCUMENT_ROOT"] . __uploaddir__ . __racinebd__ . 'content' . $suffixe . $ligne_select_content['content_id'] . '.' . $ligne_select_content[$listext[$listextindice]], $_SERVER["DOCUMENT_ROOT"] . __uploaddir__ . __racinebd__ . 'content' . $suffixe . $dernier_ajout_content . '.' . $ligne_select_content[$listext[$listextindice]]); @copy($_SERVER["DOCUMENT_ROOT"] . __uploaddir__ . 'tbl_' . __racinebd__ . 'content' . $suffixe . $ligne_select_content['content_id'] . '.' . $ligne_select_content[$listext[$listextindice]], $_SERVER["DOCUMENT_ROOT"] . __uploaddir__ . 'tbl_' . __racinebd__ . 'content' . $suffixe . $dernier_ajout_content . '.' . $ligne_select_content[$listext[$listextindice]]); for ($i = 0; $i < 5; $i++) { @copy($_SERVER["DOCUMENT_ROOT"] . __uploaddir__ . 'tbl_' . $i . __racinebd__ . 'content' . $suffixe . $ligne_select_content['content_id'] . '.' . $ligne_select_content[$listext[$listextindice]], $_SERVER["DOCUMENT_ROOT"] . __uploaddir__ . 'tbl_' . $i . __racinebd__ . 'content' . $suffixe . $dernier_ajout_content . '.' . $ligne_select_content[$listext[$listextindice]]); } } $requete_select_fichier = "select * from " . __racinebd__ . "fichiers where content_id = " . $ligne_select_content['content_id'] . " and supprimer=0"; $link_select_fichier = query($requete_select_fichier); while ($ligne_select_fichier = fetch($link_select_fichier)) { $requete_insert_fichier = "insert into " . __racinebd__ . "fichiers (content_id,titre,abstract,ext,nom_fichier,supprimer,contenu) values (\r\n " . $dernier_ajout_content . ",\r\n '" . addslashes($ligne_select_fichier['titre']) . "',\r\n '" . addslashes($ligne_select_fichier['abstract']) . "',\r\n " . ($ligne_select_fichier['ext'] == "" ? "null" : "'" . $ligne_select_fichier['ext'] . "'") . ",\r\n '" . addslashes($ligne_select_fichier['nom_fichier']) . "',\r\n " . $ligne_select_fichier['supprimer'] . ",\r\n '" . addslashes($ligne_select_fichier['contenu']) . "'\r\n )"; $link_insert_fichier = query($requete_insert_fichier); $dernier_ajout_fichier = insert_id(); copy($_SERVER["DOCUMENT_ROOT"] . __uploaddir__ . __racinebd__ . 'fichiers' . $ligne_select_fichier['fichiers_id'] . '.' . $ligne_select_fichier['ext'], $_SERVER["DOCUMENT_ROOT"] . __uploaddir__ . __racinebd__ . 'fichiers' . $dernier_ajout_fichier . '.' . $ligne_select_fichier['ext']); } } } }
if ($tmp_tab_path_info[3] == 1) { $url = __uploaddirfront__ . __racinebd__ . "content" . $tmp_tab_path_info[2] . "." . $ext; } else { $url = __uploaddirfront__ . __racinebd__ . "content" . $tmp_tab_path_info[3] . "_" . $tmp_tab_path_info[2] . "." . $ext; } readfile($_SERVER["DOCUMENT_ROOT"] . $url); die; } if (trim($tmp_tab_path_info[1]) == "image") { //vérification si il y a un resize a faire $resize = false; if (count($tmp_tab_path_info) > 7) { $ext = getext($tmp_tab_path_info[7]); $resize = true; } else { $ext = getext($tmp_tab_path_info[6]); } $table = $tmp_tab_path_info[5]; // Determine Content Type switch ($ext) { case "gif": $ctype = "image/gif"; break; case "png": $ctype = "image/png"; break; case "jpeg": case "jpg": $ctype = "image/jpg"; break; default:
function uploadFileB($max,$nfile,$folder,$width=0,$height=0){ if($_FILES['gambarB']['size']>$max and $max>0){ $this->pesan = "Catatan : Gambar gagal diupload ! <br><u>File gambar tidak boleh lebih dari ".floor($max/1024)." Kb</u> !<br><br>"; return false; }else{ $uploaddir = FTP_PATH."$folder"; $file = $nfile; $remote_file = $_FILES['gambarB']['tmp_name']; $result_array = getimagesize($remote_file); if ($result_array !== false) { list($w, $h, $t, $attr) = $result_array; #print_r($result_array); if($width>0){ if($width!=$w){ $this->pesan = "Lebar Gambar [ width ] harus : $width px !"; return false; } } if($height>0){ if($height!=$h){ $this->pesan = "Tinggi Gambar [ height ] harus : $height px !"; return false; } } // nothing } else { $this->pesan = "Catatan : Gambar gagal diupload ! <br><u>File harus berbentuk gambar</u> !<br><br>"; return false; } // set up basic connection $conn_id = ftp_connect("127.0.0.1"); // login with username and password $login_result = ftp_login($conn_id, ftp_user_name, ftp_user_pass); // change dir ftp_chdir($conn_id,$uploaddir); // upload a file $ftpRes = ftp_put($conn_id, $file, $remote_file, FTP_ASCII); if ($ftpRes) { $thumbName = $nfile . getext($tfile); $this->pesan = "Gambar telah diupdate !"; return true; } else { $this->pesan = "Catatan : Gambar gagal diupload ! <br><u>Silakan coba kembali</u> !<br><br>"; return false; } // close the connection ftp_close($conn_id); } }
function uploadFile($max,$nfile){ if($_FILES['gambar']['size']>$max){ $this->pesan = "Catatan : Gambar gagal diupload ! <br><u>File gambar tidak boleh lebih dari ".floor($max/1024)." Kb</u> !<br><br>"; return false; }else{ $uploaddir = FTP_PATH.'/images/tips'; $tfile = basename($_FILES['gambar']['name']); $uploadfile = $uploaddir . $nfile . getext($tfile); $result_array = getimagesize($_FILES['gambar']['tmp_name']); if ($result_array !== false) { // nothing } else { $this->pesan = "Catatan : Gambar gagal diupload ! <br><u>File harus berbentuk gambar</u> !<br><br>"; return false; } $file = $nfile . getext($tfile); $remote_file = $_FILES['gambar']['tmp_name']; // set up basic connection $conn_id = ftp_connect(FTP_HOME); // login with username and password $login_result = ftp_login($conn_id, ftp_user_name, ftp_user_pass); ftp_chdir($conn_id,$uploaddir); // upload a file $ftpRes = ftp_put($conn_id, $file, $remote_file, FTP_BINARY); if ($ftpRes){ $this->thumbName = $nfile . getext($tfile); $this->pesan = "Gambar telah diupload !"; return true; } else { $this->pesan = "<br><u><b>Catatan</b></u> : Gambar gagal diupload. Anda dapat mencoba meng-upload-nya kembali dengan memilih <i><b>edit</b></i> pada berita yang bersangkutan."; return false; } } }
ignore_user_abort(true); include 'func.php'; $rootdir = getbase($_GET['base']); if (($file = safepath($rootdir, $_GET['file'])) === false) { die; } $hash = mkhash($rootdir . $file); $thash = $_GET['base'] . '-' . $hash; $hash = $_GET['base'] . '/' . $hash; if (preg_match('/^[0-9]+x[0-9]+$/', $_GET['size'])) { $size = $_GET['size']; } else { $size = $CFG['thumb_size']; } $extmap = array('zip' => 'archive.gif', 'rar' => 'archive.gif', '7z' => 'archive.gif', '7zip' => 'archive.gif', 'txz' => 'archive.gif', 'xz' => 'archive.gif', 'tgz' => 'archive.gif', 'gz' => 'archive.gif', 'tar' => 'archive.gif', 'xls' => 'xls.gif', 'doc' => 'doc.gif', 'ppt' => 'ppt.gif', 'txt' => 'txt.gif', 'kmz' => 'ge.gif', 'kml' => 'ge.gif', 'htm' => 'html.gif', 'html' => 'html.gif', 'mht' => 'html.gif', 'wav' => 'audio.gif', 'mp3' => 'audio.gif', 'wma' => 'audio.gif', 'mid' => 'audio.gif', 'ogg' => 'audio.gif', 'flac' => 'audio.gif', 'swf' => 'swf.gif', 'fla' => 'fla.gif', 'aac' => 'aac.gif', 'ace' => 'ace.gif', 'aiff' => 'aiff.gif', 'arj' => 'arj.gif', 'cab' => 'cab.gif', 'mpc' => 'mpc.gif', 'pdf' => 'pdf.gif', 'vqf' => 'vqf.gif', 'xml' => 'xml.gif'); if (thumb_able($file)) { if (!newer($rootdir . $file, $CFG['cachedir'] . $hash . '_' . $size . '.jpg')) { echo $CFG['cacheurl'] . $hash . '_' . $size . '.jpg'; exit; } $job = array('base' => $_GET['base'], 'file' => $file, 'size' => $size); $gmc = new Gearmanclient(); $gmc->addServer(); $gmc->doBackground("webnautilus", serialize($job)); header('HTTP/1.1 491'); exit; } elseif (isset($extmap[getext($file)])) { echo 'images/' . $extmap[getext($file)]; } else { echo 'images/noimage.gif'; }