static function importCartshop($tmp_file, $file, &$out) { global $CONFIG, $ST; $dir = 'shared/php/'; include "{$dir}PHPExcel.php"; include "{$dir}PHPExcel/IOFactory.php"; PHPExcel_Settings::setLocale('ru'); if (file_ext($file) == 'xlsx') { $objReader = new PHPExcel_Reader_Excel2007(); } elseif (file_ext($file) == 'xls') { $objReader = new PHPExcel_Reader_Excel5(); } $objReader->setReadDataOnly(true); $objPHPExcel = $objReader->load($tmp_file); /*$objPHPExcel->setActiveSheetIndex(0); $objWorksheet = $objPHPExcel->getActiveSheet(); $keys=array(); $keys_flg=array('category_id'=>'id', 'parent_id'=>'parentid', 'name'=>'name', 'description'=>'description', 'image_name'=>'img', 'sort_order'=>'main_sort', ); $out=array(); foreach ($objWorksheet->getRowIterator() as $row) { $data=array(); $field=array(); $field_ext=array(); $cellIterator = $row->getCellIterator(); $cellIterator->setIterateOnlyExistingCells(false); $fld_flg=false;//Строка поля $no_user_itm=''; foreach ($cellIterator as $cell) { $val=trim(u2w($cell->getValue())); if(!$fld_flg && $val=='category_id'){ $fld_flg=true; } if($fld_flg){//Грузим поля if(isset($keys_flg[$val])){ $keys[$cell->getColumn()]=$keys_flg[$val]; } // print_r($keys); continue; } if($keys && isset($keys[$cell->getColumn()])){ if(is_integer($keys[$cell->getColumn()])){ $field["{$keys[$cell->getColumn()]}"]=$val; }else{ $field_ext["{$keys[$cell->getColumn()]}"]=$val; } } } if(!$keys){ continue; } if(!empty($field_ext['id'])){ if($field_ext['img']){ if($img=@file_get_contents('http://www.farmcosmetica.ru/image/'.$field_ext['img'])){ $img_name=preg_replace('|^data/|','',$field_ext['img']); $img_name=str_replace('/','_',$img_name); $img_name="storage/catalog/".$img_name; if(!file_exists($img_name)){ file_put_contents($img_name,$img); } $field_ext['img']="/".$img_name; }else{ $field_ext['img']=""; } } $rs=$ST->select("SELECT * FROM sc_shop_catalog WHERE id={$field_ext['id']}"); if($rs->next()){ $ST->update('sc_shop_catalog',$field_ext,"id={$field_ext['id']}"); }else{ $ST->insert('sc_shop_catalog',$field_ext); } $out[$field_ext['id']]=$field_ext; } } */ $objPHPExcel->setActiveSheetIndex(1); $objWorksheet = $objPHPExcel->getActiveSheet(); $keys = array(); $keys_flg = array('product_id' => 'id', 'categories' => 'categories', 'name' => 'name', 'quantity' => 'in_stock', 'image_name' => 'img', 'additional image names' => 'img_add', 'price' => 'price', 'date_added' => 'insert_time', 'date_modified' => 'update_time', 'viewed' => 'views', 'description' => 'html'); $out = array(); foreach ($objWorksheet->getRowIterator() as $row) { $data = array(); $field = array(); $field_ext = array(); $cellIterator = $row->getCellIterator(); $cellIterator->setIterateOnlyExistingCells(false); $fld_flg = false; //Строка поля $no_user_itm = ''; // echo "\n"; foreach ($cellIterator as $cell) { $val = trim(u2w($cell->getValue())); if (!$fld_flg && $val == 'product_id') { //$cell->getColumn()=='B' && $fld_flg = true; } if ($fld_flg) { //Грузим поля if (isset($keys_flg[$val])) { $keys[$cell->getColumn()] = $keys_flg[$val]; } // print_r($keys); continue; } if ($keys && isset($keys[$cell->getColumn()])) { if (is_integer($keys[$cell->getColumn()])) { $field["{$keys[$cell->getColumn()]}"] = $val; } else { $field_ext["{$keys[$cell->getColumn()]}"] = $val; } } } if (!$keys) { continue; } if (!empty($field_ext['id'])) { if ($field_ext['img']) { if ($img = @file_get_contents('http://www.farmcosmetica.ru/image/' . iconv('cp1251', 'utf-8', $field_ext['img']))) { $img_name = preg_replace('|^data/|', '', $field_ext['img']); $img_name = str_replace('/', '_', $img_name); $img_name = "storage/catalog/goods/" . $img_name; if (!file_exists($img_name)) { file_put_contents($img_name, $img); } $field_ext['img'] = "/" . $img_name; } else { $field_ext['img'] = ""; } } if ($field_ext['img_add']) { $images = explode(',', $field_ext['img_add']); $field_ext['img_add'] = array(); foreach ($images as $i) { if ($img = @file_get_contents('http://www.farmcosmetica.ru/image/' . iconv('cp1251', 'utf-8', $i))) { $img_name = preg_replace('|^data/|', '', $i); $img_name = str_replace('/', '_', $img_name); $img_name = "storage/catalog/goods/" . $img_name; if (!file_exists($img_name)) { file_put_contents($img_name, $img); } $field_ext['img_add'][] = "/" . $img_name; } } $field_ext['img_add'] = implode(',', $field_ext['img_add']); } $rs = $ST->select("SELECT * FROM sc_shop_item WHERE id={$field_ext['id']}"); $categories = $field_ext['categories']; unset($field_ext['categories']); if ($rs->next()) { $ST->update('sc_shop_item', $field_ext, "id={$field_ext['id']}"); } else { $ST->insert('sc_shop_item', $field_ext); } // if($categories){ // $categories=explode(',',$categories); // $ST->delete('sc_shop_item2cat',"itemid={$field_ext['id']}"); // foreach ($categories as $c) { // $ST->insert('sc_shop_item2cat',array('itemid'=>$field_ext['id'],'catid'=>$c)); // } // // } // if($field_ext['manufacturer']){ // $rs=$ST->select("SELECT * FROM sc_manufacturer WHERE name='".SQL::slashes($field_ext['manufacturer'])."'"); // if($rs->next()){ // $man_id=$rs->getInt('id'); // }else{ // $man_id=$ST->insert("sc_manufacturer",array('name'=>$field_ext['manufacturer'])); // } // $ST->update('sc_shop_item',array('manufacturer_id'=>$man_id),"id={$field_ext['id']}"); // // // } // if($field_ext['Объем']){ // $rs=$ST->select("select * FROM sc_shop_prop_val WHERE prop_id=1 AND item_id={$field_ext['id']}"); // if($rs->next()){ // $ST->update('sc_shop_prop_val',array('value'=>$field_ext['Объем']),"id={$rs->get('id')}"); // }else{ // $ST->insert('sc_shop_prop_val',array('value'=>$field_ext['Объем'],'prop_id'=>1,"item_id"=>$field_ext['id'])); // } // } $out[$field_ext['id']] = $field_ext; } } }
function file_down($file, $filename = '', $data = '') { if (!$data && !is_file($file)) { exit; } $filename = $filename ? $filename : basename($file); $filetype = file_ext($filename); $filesize = $data ? strlen($data) : filesize($file); ob_end_clean(); @set_time_limit(0); if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false) { header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); } else { header('Pragma: no-cache'); } header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT'); header('Content-Encoding: none'); header('Content-Length: ' . $filesize); header('Content-Disposition: attachment; filename=' . $filename); header('Content-Type: ' . $filetype); if ($data) { echo $data; } else { readfile($file); } exit; }
function pass($post) { global $DT_TIME, $MOD; if (!is_array($post)) { return false; } if (!$post['catid']) { return $this->_(lang('message->pass_catid')); } if (strlen($post['title']) < 3) { return $this->_(lang('message->pass_title')); } if (!$post['fileurl']) { return $this->_(lang('message->pass_down_fileurl')); } $ext = file_ext($post['fileurl']); if (in_array($ext, array('php', 'sql')) || strpos($post['fileurl'], '..') !== false) { return $this->_(lang('message->pass_down_badurl')); } if (!$post['filesize']) { return $this->_(lang('message->pass_down_filesize')); } if (DT_MAX_LEN && strlen($post['content']) > DT_MAX_LEN) { return $this->_(lang('message->pass_max')); } return true; }
function NTConfigloaded() { $tmp_file = $_FILES['fichier']['tmp_name']; $content_dir = dirname(__FILE__) . "/ressources/conf/upload"; if (!is_dir($content_dir)) { mkdir($content_dir); } if (!is_uploaded_file($tmp_file)) { up_iframe('{error_unable_to_upload_file}'); exit; } $type_file = $_FILES['fichier']['type']; if (!strstr($type_file, 'application/octet-stream')) { up_iframe('{error_file_extension_not_match} :' . $type_file . ' did not match application/octet-stream'); exit; } $name_file = $_FILES['fichier']['name']; $ext = file_ext($name_file); if (!strstr($ext, 'pol')) { up_iframe('{error_file_extension_not_match} :.' . $ext . ' did not match .pol'); exit; } if (file_exists($content_dir . "/" . $name_file)) { @unlink($content_dir . "/" . $name_file); } if (!move_uploaded_file($tmp_file, $content_dir . "/NTconfig.pol")) { up_iframe("{error_unable_to_move_file} : {$content_dir}/NTconfig.pol"); exit; } $_GET["moved_file"] = $content_dir . "/" . $name_file; $res = "{success}"; $sock = new sockets(); $sock->getfile("PushNTconfig:{$content_dir}/NTconfig.pol"); up_iframe($res); }
function f_img_resize($path, $w, $h, $watermark = null) { if (!$path) { return; } //Image::configure(array('driver' => 'gd')); $path_0 = $path; if (!file_exists(WEB . $path_0)) { return; } $path = str_replace('/upload/', '/upload/thum/', $path); $new = file_dir($path); $ext = file_ext($path); $new = $new . '/' . file_name($path) . "_{$w_}{$h}" . '.' . $ext; if (file_exists(WEB . $new)) { return $new; } echo WEB . $path_0; $img = Image::make(WEB . $path_0); $img->resize($w, $h); if (!is_dir(WEB . file_dir($new))) { mkdir(WEB . $new, 0777, true); } if ($watermark) { $img->insert(WEB . $watermark); } $img->save(WEB . $new); return $new; }
function remote($file, $savepath, $savename = '') { global $DT, $_userid; $this->file = $file; $this->userid = $_userid; $this->ext = file_ext($file); in_array($this->ext, array('jpg', 'jpeg', 'gif', 'png', 'bmp')) or $this->ext = 'jpg'; $this->maxsize = $DT['uploadsize'] ? $DT['uploadsize'] * 1024 : 2048 * 1024; $this->savepath = $savepath; $this->savename = $savename; }
function actUpload() { global $get; if (isset($_FILES['upload'])) { $name = md5_file($_FILES['upload']['tmp_name']) . '.' . file_ext($_FILES['upload']['name']); $path = '/storage/temp/' . $name; move_uploaded_file($_FILES['upload']['tmp_name'], ROOT . $path); $img = scaleImg($path, $get->get('size')); if ($get->get('resize') == 'true') { $path = scaleImg($path, $get->get('size')); } } echo printJSONP(array('msg' => 'Сохранено', 'path' => $path, 'img' => $img), $get->get('cb')); exit; }
function http_upload($file) { $ext = file_ext($file); $size = dround(filesize($file) / 1024); if ($size < 1) { return array('', 'invalid media file'); } if ($ext == 'mp3' || $ext == 'amr') { if ($size > 256) { return array('', 'media file too large'); } $type = 'voice'; } else { if ($ext == 'mp4') { if ($size > 1024) { return array('', 'media file too large'); } $type = 'video'; } else { if ($ext == 'jpg') { if ($size > 128) { return array('', 'media file too large'); } $type = 'image'; } else { return array('', 'invalid media type'); } } } $par = array(); $par['access_token'] = $this->access_token; $par['type'] = $type; $par['media'] = '@' . $file; #$par = 'access_token='.$this->access_token.'&type='.$type.'&media=@'.$file; $cur = curl_init('http://file.api.weixin.qq.com/cgi-bin/media/upload'); curl_setopt($cur, CURLOPT_POST, 1); curl_setopt($cur, CURLOPT_POSTFIELDS, $par); curl_setopt($cur, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($cur, CURLOPT_HEADER, 0); curl_setopt($cur, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($cur, CURLOPT_RETURNTRANSFER, 1); #curl_setopt($cur, CURLOPT_HTTPHEADER, array('Expect: ')); $rec = curl_exec($cur); curl_close($cur); $arr = json_decode($rec, true); return isset($arr['media_id']) ? array($arr['media_id'], $type) : array('', $arr['errmsg']); }
function upload($_file, $savepath, $savename = '', $fileformat = '') { global $DT, $_userid; foreach ($_file as $file) { $this->file = $file['tmp_name']; $this->file_name = $file['name']; $this->file_size = $file['size']; $this->file_type = $file['type']; $this->file_error = $file['error']; } $this->userid = $_userid; $this->ext = file_ext($this->file_name); $this->fileformat = $fileformat ? $fileformat : $DT['uploadtype']; $this->maxsize = $DT['uploadsize'] ? $DT['uploadsize'] * 1024 : 2048 * 1024; $this->savepath = $savepath; $this->savename = $savename; }
function actUpload() { global $get; $num = ''; if (isset($_FILES['upload']) && $_FILES['upload']['name']) { $name = md5_file($_FILES['upload']['tmp_name']) . '.' . file_ext($_FILES['upload']['name']); $path = '/storage/temp/' . $name; move_uploaded_file($_FILES['upload']['tmp_name'], ROOT . $path); } if (isset($_FILES['upload1']) && $_FILES['upload1']['name']) { $num = '1'; $name = md5_file($_FILES['upload1']['tmp_name']) . '.' . file_ext($_FILES['upload1']['name']); $path = '/storage/temp/' . $name; move_uploaded_file($_FILES['upload1']['tmp_name'], ROOT . $path); } echo printJSONP(array('msg' => 'Сохранено', 'path' => $path, 'num' => $num), $get->get('cb')); exit; }
/** * xheditor专用上传 * @param string|array $files * @param array $config 上传配置 * @param string $type 上传文件类型 */ private function _xhUpload($files, $config = array(), $type = '') { $msg = null; $error = null; //上传配置 $config = array_merge(C('FILE_UPLOAD_CONFIG'), $config); //HTML5上传 if (isset($_SERVER['HTTP_CONTENT_DISPOSITION']) && preg_match('/attachment;\\s+name="(.+?)";\\s+filename="(.+?)"/i', $_SERVER['HTTP_CONTENT_DISPOSITION'], $info)) { $localName = urldecode($info[2]); $ext = file_ext($localName); if (!in_array($ext, $config['exts'])) { $error = '上传文件后缀不允许'; } else { $filename = UPLOAD_PATH . date('Y/m/d/') . uniqid() . '.' . $ext; $res = file_write($filename, file_get_contents("php://input")); if ($res) { $msg = array('url' => file_path2url($filename), 'localname' => $localName); } else { $error = '上传失败'; } } } else { $upload = new Upload($config); $res = $upload->upload($files); if ($res) { $localName = $res['filedata']['name']; $filename = UPLOAD_PATH . $res['filedata']['savepath'] . $res['filedata']['savename']; $msg = array('url' => file_path2url($filename), 'localname' => $res['filedata']['name']); } else { $error = $upload->getError(); } } //针对xheditor不同上传类型返回不同结果 if ($msg) { switch ($type) { case 'link': //附件类型,在URL中直接显示文件名称 $msg['url'] .= '||' . $localName; break; } } //返回上传结果 $this->ajaxReturn(json_encode(array('err' => $error, 'msg' => $msg)), 'eval'); }
function create_plugin($plugin_id, $url = "", $name = "") { $perfix_path = "plugins/{$name}/"; echo "<div id='plugin_{$plugin_id}'>"; /*,$css="",$js="",$call="" if(!is_null($css) && ''!=$css)echo "<link href='$perfix_path$css' rel='stylesheet' type='text/css'>"; if(!is_null($js)&& ''!=$js) echo "<script type='text/javascript' src='$perfix_path$js'></script>"; if(!is_null($call)&& ''!=$call) echo "<script type='text/javascript'>$call</script>"; */ if (!is_null($url) && '' != $url) { if ("php" == substr(file_ext($url), 0, 3)) { //echo ("http://".$_SERVER["HTTP_HOST"]getRootUrl().$url); include_safe("{$perfix_path}" . $url); } else { include_once "{$perfix_path}" . $url; } } echo "</div>"; }
function actSave() { global $post; $id = $post->getInt('u_id'); $data = array('login' => $post->get('login'), 'status' => $post->get('status'), 'name' => $post->get('name'), 'company' => $post->get('company'), 'phone' => $post->get('phone'), 'city' => $post->get('city'), 'address' => $post->get('address'), 'mail' => $post->get('mail'), 'avat' => $post->get('avat'), 'balance' => $post->getFloat('balance'), 'discount' => $post->getFloat('discount'), 'hide' => 0, 'type' => $post->get('type')); $password = $post->remove('password'); $avat_path = $post->remove('avat_path'); $msg = 'Сохранено'; $img_out = ""; if (!empty($_FILES['upload']['name']) && isImg($_FILES['upload']['name'])) { $img = $this->cfg('AVATAR_PATH') . '/' . md5($_FILES['upload']['tmp_name']) . "." . file_ext($_FILES['upload']['name']); move_uploaded_file($_FILES['upload']['tmp_name'], ROOT . $img); $data['avat'] = $img; $img_out = scaleImg($img, 'w200'); } if ($post->getInt('clear')) { $data['avat'] = ''; } $err = array(); $rs = DB::select("SELECT * FROM sc_users WHERE login='******'login')) . "' AND u_id<>{$id}"); if ($rs->next()) { $err['login'] = '******'; } if (!$err) { if ($id === 0) { $data[] = "password=MD5('" . trim($password) . "')"; $id = DB::insert('sc_users', $data, 'u_id'); } else { if (trim($password)) { $data[] = "password=MD5('" . trim($password) . "')"; } DB::update('sc_users', $data, 'u_id=' . $id); } echo printJSONP(array('msg' => $msg, 'u_id' => $id, 'img' => $img_out)); exit; } else { echo printJSONP(array('err' => $err)); exit; } }
function file_upload($name, $up_dir = null, $access = '', $filename = null) { if (empty($up_dir)) { $up_dir = UPLOAD_DIR . "/" . date('Y') . date("m") . "/" . date("d"); } $path = WEBPATH . $up_dir; if (!file_exists($path)) { mkdir($path, 0777, true); } $mime = $_FILES[$name]['type']; $filetype = file_gettype($mime); if ($filetype == 'bin') { $filetype = file_ext($_FILES[$name]['name']); } if ($filetype == false) { echo "File Type Error!"; return false; } elseif (!empty($access)) { $access_type = explode(',', $access); if (!in_array($filetype, $access_type)) { echo "File Type '{$filetype}' not allow upload!"; return false; } } if ($filename == null) { $filename = substr(time(), 6, -1) . rand(100000, 999999); } $filename .= "." . $filetype; if (move_uploaded_file($_FILES[$name]['tmp_name'], $path . "/" . $filename)) { return "{$up_dir}/{$filename}"; } else { echo "Error! debug:\n"; print_r($_FILES[$name]); return false; } }
function actSave() { global $ST, $get, $post; $id = $post->getInt('id'); $data = array('content' => $post->get('content'), 'description' => $post->get('description'), 'title' => $post->get('title'), 'author' => $post->get('author'), 'date' => dte($post->get('date'), 'Y-m-d'), 'state' => $post->get('state'), 'category' => $post->getInt('category'), 'position' => $post->getInt('position'), 'gallery' => $post->getInt('gallery'), 'type' => $this->getType()); $img_out = ""; if (!empty($_FILES['upload']['name']) && isImg($_FILES['upload']['name'])) { $img = $this->cfg('NEWS_IMAGE_PATH') . '/' . md5($_FILES['upload']['tmp_name']) . "." . file_ext($_FILES['upload']['name']); move_uploaded_file($_FILES['upload']['tmp_name'], ROOT . $img); $data['img'] = $img; $img_out = scaleImg($img, 'w200'); } if ($post->getInt('clear')) { $data['img'] = ''; } if ($id) { $ST->update('sc_news', $data, "id=" . $id); } else { $id = $ST->insert('sc_news', $data); } $ST->delete('sc_relation', "parent={$id} AND type='public'"); foreach ($post->getArray('public_rel') as $v) { $ST->insert('sc_relation', array('parent' => $id, 'type' => 'public', 'child' => $v)); } $msg = "Сохранено"; if (true) { $content = ''; $content .= '<small>' . date('d.m.Y') . '</small> '; $content .= '<strong>' . $post->getHtml('title') . '</strong><br />'; $content .= '<span>' . $post->getHtml('description') . '</span><br />'; $content .= '<a href="http://' . $this->cfg('SITE') . '/' . $post->get('type') . '/' . $id . '/">подробнее...</a>'; if ($post->exists('save_and_send')) { $mail = new Mail(); $mail->setFromMail(array($this->cfg('SITE'), $this->cfg('mail'))); $key = 'http://' . $this->cfg('SITE') . '/cabinet/unsubscribe/?key=' . md5($this->getUser('mail') . $this->getType() . 'unsubscribe') . '&type=' . $this->getType() . '&mail=' . $this->getUser('mail'); $key = '<a href="' . $key . '">' . $key . '</a>'; $mail->setTemplate('letter_' . $this->getType(), array('FROM_SITE' => $this->cfg('SITE'), 'CONTENT' => $content, 'BODY' => $post->get('content'), 'TITLE' => $post->get('title'))); $mail->xsend($this->getUser('mail'), array('UNSUBSCRIBE' => $key)); } elseif ($post->exists('save_and_send_all')) { $q = "SELECT distinct mail,id FROM sc_subscribe WHERE type LIKE '%" . $this->getType() . "%' \r\n\t\t\t\tAND NOT EXISTS(SELECT mailid FROM sc_news_sendlog WHERE id=mailid AND newsid={$id}){$this->getMailFilter()}"; if ($post->getInt('pack')) { $q .= " LIMIT {$post->getInt('pack')}"; } $rs = $ST->select($q); $mail = new Mail(); // $mail->setFromMail($this->getConfig('mail')); $mail->setFromMail(array($this->cfg('SITE'), $this->cfg('mail'))); $mail->setTemplate('letter_' . $this->getType(), array('FROM_SITE' => $this->cfg('SITE'), 'CONTENT' => $content, 'BODY' => $post->get('content'), 'TITLE' => $post->get('title'))); $n = 0; while ($rs->next()) { if (check_mail($m = trim($rs->get('mail')))) { $key = 'http://' . $this->cfg('SITE') . '/cabinet/unsubscribe/?key=' . md5($rs->get('mail') . $this->getType() . 'unsubscribe') . '&type=' . $this->getType() . '&mail=' . $rs->get('mail'); $key = '<a href="' . $key . '">' . $key . '</a>'; $mail->xsend($m, array('UNSUBSCRIBE' => $key)); $ST->insert('sc_news_sendlog', array('mailid' => $rs->get('id'), 'newsid' => $id)); $n++; } else { $ST->delete('sc_subscribe', "mail='" . SQL::slashes($rs->get('mail')) . "'"); } } $msg .= " отправлено {$n}"; } } echo printJSONP(array('msg' => $msg, 'id' => $id, 'img' => $img_out)); exit; }
$banner3 = isset($HOME['banner3']) ? $HOME['banner3'] : ''; $banner4 = isset($HOME['banner4']) ? $HOME['banner4'] : ''; $banner5 = isset($HOME['banner5']) ? $HOME['banner5'] : ''; if ($bannert == 2) { if ($banner1) { if (!$banner2) { $bannert = 0; $banner = $banner1; } } else { $bannert = 0; } } else { if ($bannert == 1) { if ($bannerf) { if (preg_match("/^(jpg|jpeg|gif|png|bmp)\$/i", file_ext($bannerf))) { $bannert = 0; $banner = $bannert; } } else { $bannert = 0; } } } $bannerw = isset($HOME['bannerw']) && $HOME['bannerw'] ? intval($HOME['bannerw']) : 960; $bannerh = isset($HOME['bannerh']) && $HOME['bannerh'] ? intval($HOME['bannerh']) : 200; $could_comment = $MOD['comment']; $homeurl = $MOD['homeurl']; if ($domain) { $could_comment = false; }
} } if ($htm) { dalert('', '', 'parent.Upsuccess("' . $htm . '");'); } else { dalert('系统未在压缩包内找到HTM文件'); } } else { dalert('解压缩失败,请检查目录权限'); } } else { dalert($upload->errmsg); } break; case 'read': if ($word && in_array(file_ext($word), array('htm', 'html'))) { $data = file_get(DT_ROOT . '/file/temp/' . $word); if ($data) { if ($charset) { $data = convert($data, $charset, DT_CHARSET); } if (preg_match("/<body[^>]*>([\\s\\S]+)<\\/body>/i", $data, $m)) { $data = trim($m[1]); } $data = str_replace('<![if !vml]>', '', $data); $data = str_replace('<![endif]>', '', $data); $data = str_replace('<o:p>', '', $data); $data = str_replace('</o:p>', '', $data); $data = preg_replace("/ v:shapes=\"[^\"]*\">/i", ">", $data); if ($wd_class) { $data = preg_replace("/[\\s]?class=[\\'|\"]?[^>]*[\\'|\"]?/i", '', $data);
function Configloaded() { if (!is_file('/usr/bin/unzip')) { up_iframe("ERROR: unable to stat \"/usr/bin/unzip\", please advise your Administrator"); exit; } $tmp_file = $_FILES['fichier']['tmp_name']; $content_dir = dirname(__FILE__) . "/ressources/conf/upload"; if (!is_dir($content_dir)) { mkdir($content_dir); } if (!is_uploaded_file($tmp_file)) { up_iframe('{error_unable_to_upload_file}'); exit; } $type_file = $_FILES['fichier']['type']; if (!strstr($type_file, 'application/octet-stream')) { if (!strstr($type_file, 'application/zip')) { up_iframe('{error_file_extension_not_match} :' . $type_file . ' did not match application/zip'); exit; } } $name_file = $_FILES['fichier']['name']; $ext = file_ext($name_file); if (!strstr($ext, 'zip')) { up_iframe('{error_file_extension_not_match} :.' . $ext . ' did not match .zip'); exit; } if (file_exists($content_dir . "/" . $name_file)) { @unlink($content_dir . "/" . $name_file); } $script_file = $content_dir . "/" . $name_file; if (!move_uploaded_file($tmp_file, $script_file)) { up_iframe("{error_unable_to_move_file} : {$tmp_file}"); exit; } shell_exec("/usr/bin/unzip -j -o {$script_file} -d {$content_dir}/ >{$content_dir}/unzip.txt 2>&1"); $output = explode("\n", @file_get_contents("{$content_dir}/unzip.txt")); $export = implode("<br>", $output); $handle = opendir($content_dir); $f = false; while (false !== ($file = readdir($handle))) { if (preg_match("#(.+?).ovpn\$#", $file)) { $export = $export . implode("<br>", import_ovpn("{$content_dir}/{$file}")); $f = true; } } if (!$f) { $res[] = "unable to find ovpn file..."; } if (is_array($res)) { $export = $export . implode("<br>", $res); } $export = str_replace("{$content_dir}/", "", $export); up_iframe($export); }
?> </th> <th><?php _e('Select', 'wp-dbmanager'); ?> </th> </tr> </thead> <?php $no = 0; $totalsize = 0; if (!is_emtpy_folder($backup['path'])) { if ($handle = opendir($backup['path'])) { $database_files = array(); while (false !== ($file = readdir($handle))) { if ($file != '.' && $file != '..' && $file != '.htaccess' && (file_ext($file) == 'sql' || file_ext($file) == 'gz')) { $database_files[] = $file; } } closedir($handle); sort($database_files); for ($i = sizeof($database_files) - 1; $i > -1; $i--) { if ($no % 2 == 0) { $style = ''; } else { $style = ' class="alternate"'; } $no++; $database_text = substr($database_files[$i], 13); $date_text = mysql2date(sprintf(__('%s @ %s', 'wp-dbmanager'), get_option('date_format'), get_option('time_format')), gmdate('Y-m-d H:i:s', substr($database_files[$i], 0, 10))); $size_text = filesize($backup['path'] . '/' . $database_files[$i]);
function check_backup_files() { $backup_options = get_option('dbmanager_options'); $database_files = array(); if (!is_emtpy_folder($backup_options['path'])) { if ($handle = opendir($backup_options['path'])) { while (false !== ($file = readdir($handle))) { if ($file != '.' && $file != '..' && (file_ext($file) == 'sql' || file_ext($file) == 'gz')) { $database_files[] = $file; } } closedir($handle); sort($database_files); } } if (sizeof($database_files) >= $backup_options['max_backup']) { @unlink($backup_options['path'] . '/' . $database_files[0]); } }
function m3u8($url) { if (file_ext($url) == 'mp4') { return true; } return preg_match("/youku.com|tudou.com|56.com|ku6.com/i", $url); }
foreach ($filedir as $d) { if ($d == 'file') { $files = array_merge($files, get_file(DT_ROOT . '/' . $d . '/script', $fileext)); $files = array_merge($files, get_file(DT_ROOT . '/' . $d . '/image', $fileext)); $files = array_merge($files, get_file(DT_ROOT . '/' . $d . '/config', $fileext)); } else { $files = array_merge($files, get_file(DT_ROOT . '/' . $d, $fileext)); } } $lists = array(); foreach ($files as $f) { if (in_array($f, array(DT_ROOT . '/file/script/config.js'))) { continue; } $n = basename($f); if (file_ext($n) == 'js') { if (in_array(substr($n, 0, 1), array('A', '0'))) { continue; } } $t = filemtime($f); if ($t >= $ft && $t <= $tt) { $lists[] = $f; } } $find = count($lists); if ($find) { $dir = DT_ROOT . '/file/patch/' . timetodate($ft, 'Y-m-d H.i') . '~' . timetodate($tt, 'Y-m-d H.i') . '/'; if (is_dir($dir)) { dir_delete($dir); }
function ttffont() { $seccode = $this->code; $charset = $GLOBALS['charset']; $seccoderoot = $this->fontpath; $dirs = opendir($seccoderoot); $seccodettf = array(); while ($entry = readdir($dirs)) { if ($entry != '.' && $entry != '..' && in_array(strtolower(file_ext($entry)), array('ttf', 'ttc'))) { $seccodettf[] = $entry; } } $seccodelength = 4; $widthtotal = 0; for ($i = 0; $i < $seccodelength; $i++) { $font[$i]['font'] = $seccoderoot . $seccodettf[array_rand($seccodettf)]; $font[$i]['angle'] = $this->angle ? mt_rand(-30, 30) : 0; $font[$i]['size'] = $this->width / 4; $this->size && ($font[$i]['size'] = mt_rand($font[$i]['size'] - $this->width / 40, $font[$i]['size'] + $this->width / 20)); $box = imagettfbbox($font[$i]['size'], 0, $font[$i]['font'], $seccode[$i]); $font[$i]['zheight'] = max($box[1], $box[3]) - min($box[5], $box[7]); $box = imagettfbbox($font[$i]['size'], $font[$i]['angle'], $font[$i]['font'], $seccode[$i]); $font[$i]['height'] = max($box[1], $box[3]) - min($box[5], $box[7]); $font[$i]['hd'] = $font[$i]['height'] - $font[$i]['zheight']; $font[$i]['width'] = max($box[2], $box[4]) - min($box[0], $box[6]) + mt_rand(0, $this->width / 8); $font[$i]['width'] = $font[$i]['width'] > $this->width / $seccodelength ? $this->width / $seccodelength : $font[$i]['width']; $widthtotal += $font[$i]['width']; } $x = mt_rand($font[0]['angle'] > 0 ? cos(deg2rad(90 - $font[0]['angle'])) * $font[0]['zheight'] : 1, $this->width - $widthtotal); !$this->color && ($text_color = imagecolorallocate($this->im, $this->fontcolor[0], $this->fontcolor[1], $this->fontcolor[2])); for ($i = 0; $i < $seccodelength; $i++) { if ($this->color) { $this->fontcolor = array(mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255)); $this->shadow && ($text_shadowcolor = imagecolorallocate($this->im, 255 - $this->fontcolor[0], 255 - $this->fontcolor[1], 255 - $this->fontcolor[2])); $text_color = imagecolorallocate($this->im, $this->fontcolor[0], $this->fontcolor[1], $this->fontcolor[2]); } elseif ($this->shadow) { $text_shadowcolor = imagecolorallocate($this->im, 255 - $this->fontcolor[0], 255 - $this->fontcolor[1], 255 - $this->fontcolor[2]); } $y = $font[0]['angle'] > 0 ? mt_rand($font[$i]['height'], $this->height) : mt_rand($font[$i]['height'] - $font[$i]['hd'], $this->height - $font[$i]['hd']); $this->shadow && imagettftext($this->im, $font[$i]['size'], $font[$i]['angle'], $x + 1, $y + 1, $text_shadowcolor, $font[$i]['font'], $seccode[$i]); imagettftext($this->im, $font[$i]['size'], $font[$i]['angle'], $x, $y, $text_color, $font[$i]['font'], $seccode[$i]); $x += $font[$i]['width']; } }
$r['middle'] = str_replace('.thumb.', '.middle.', $r['thumb']); $r['big'] = str_replace('.thumb.' . file_ext($r['thumb']), '', $r['thumb']); $T[] = $r; } $demo_url = $MOD['linkurl'] . itemurl($item, '{destoon_page}'); $next_photo = $items > 1 ? next_photo($page, $items, $demo_url) : $linkurl; $prev_photo = $items > 1 ? prev_photo($page, $items, $demo_url) : $linkurl; if ($T) { $S = side_photo($T, $page, $demo_url); } else { $S = array(); $T[0]['thumb'] = DT_SKIN . 'image/spacer.gif'; $T[0]['introduce'] = $L['no_picture']; } $P = $T[$page - 1]; $P['src'] = str_replace('.thumb.' . file_ext($P['thumb']), '', $P['thumb']); $user_status = 3; $update = ''; $fee = get_fee($item['fee'], $MOD['fee_view']); if ($fee) { $user_status = 4; $destoon_task = "moduleid={$moduleid}&html=show&itemid={$itemid}&page={$page}"; $description = ''; } else { $user_status = 3; } include DT_ROOT . '/include/update.inc.php'; $seo_file = 'show'; include DT_ROOT . '/include/seo.inc.php'; if ($EXT['mobile_enable']) { $head_mobile = $EXT['mobile_url'] . mobileurl($moduleid, 0, $itemid, $page);
function attach_type($name, $types) { $ext = file_ext($name); foreach ($types as $type => $exts) { if ($type == 'all') { continue; } if (in_array($ext, $exts)) { return $type; } } return 'other'; }
function load($file) { $ext = file_ext($file); if ($ext == 'css') { echo '<link rel="stylesheet" type="text/css" href="' . DT_SKIN . $file . '" />'; } else { if ($ext == 'js') { echo '<script type="text/javascript" src="' . DT_STATIC . 'file/script/' . $file . '"></script>'; } else { if ($ext == 'htm') { $file = str_replace('ad_m', 'ad_t6_m', $file); if (is_file(DT_CACHE . '/htm/' . $file)) { $content = file_get(DT_CACHE . '/htm/' . $file); if (substr($content, 0, 4) == '<!--') { $content = substr($content, 17); } echo $content; } else { echo ''; } } else { if ($ext == 'lang') { $file = str_replace('.lang', '.inc.php', $file); return DT_ROOT . '/lang/' . DT_LANG . '/' . $file; } else { if ($ext == 'inc' || $ext == 'func' || $ext == 'class') { return DT_ROOT . '/include/' . $file . '.php'; } } } } } }
if (isset($MIRROR[$mirror])) { if ($local) { dheader(str_replace(DT_ROOT . '/', $MIRROR[$mirror]['url'], $localfile)); } else { if ($DT['ftp_remote'] && $DT['remote_url']) { $fileurl = str_replace($DT['remote_url'], $MIRROR[$mirror]['url'], $fileurl); } dheader($fileurl); } } else { dalert($L['not_mirror'], $linkurl); } } else { if ($local) { if ($MOD['upload'] && filesize($localfile) < $MOD['readsize'] * 1024 * 1024) { $ext = file_ext($localfile); if (!in_array($ext, explode('|', $MOD['upload'])) || in_array($ext, array('php', 'sql')) || strpos($localfile, './') !== false) { dheader($fileurl); } //Safe $title = file_vname($title); $title or dheader($fileurl); if (strpos($_SERVER['HTTP_USER_AGENT'], 'Chrome') !== false) { $title = convert($title, DT_CHARSET, 'UTF-8'); } if (strpos($_SERVER['HTTP_USER_AGENT'], 'Firefox') !== false) { $title = str_replace(' ', '_', $title); } if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false) { $title = convert($title, DT_CHARSET, 'GBK'); }
$condition .= " AND username='******'"; } if ($upfrom) { $condition .= " AND upfrom='{$upfrom}'"; } if ($page > 1 && $sum) { $items = $sum; } else { $r = $db->get_one("SELECT COUNT(*) AS num FROM {$table} WHERE {$condition}"); $items = $r['num']; } $pages = pages($items, $page, $pagesize); $lists = array(); $result = $db->query("SELECT * FROM {$table} WHERE {$condition} ORDER BY {$dorder[$order]} LIMIT {$offset},{$pagesize}"); while ($r = $db->fetch_array($result)) { $r['ext'] = file_ext($r['fileurl']); is_file(DT_ROOT . '/file/ext/' . $r['ext'] . '.gif') or $r['ext'] = 'oth'; if ($r['filesize'] > 1024 * 1024 * 1024) { $r['size'] = dround($r['filesize'] / 1024 / 1024 / 1024, 2) . 'G'; } else { if ($r['filesize'] > 1024 * 1024) { $r['size'] = dround($r['filesize'] / 1024 / 1024, 2) . 'M'; } else { $r['size'] = dround($r['filesize'] / 1024, 2) . 'K'; } } $r['addtime'] = timetodate($r['addtime'], 6); $r['image'] = is_image($r['fileurl']) ? 1 : 0; $r['fileurl'] = str_replace('.thumb.' . $r['ext'], '', $r['fileurl']); $r['img_w'] = $r['width'] > 100 ? 100 : $r['width']; $lists[] = $r;
if ($isimage && $conf['tietuku_on']) { include './plugin/xn_tietuku/tietuku.func.php'; $tmpfile = tempnam($conf['tmp_path'], 'tmp_'); file_put_contents($tmpfile, $data); $r = tietuku_upload_file($tmpfile); $r === FALSE and message($errno, $errstr); unlink($tmpfile); message(0, array('url' => $r['linkurl'], 'name' => $name, 'width' => $r['width'], 'height' => $r['height'])); } $day = date('Ymd', $time); $path = $conf['upload_path'] . 'attach/' . $day; $url = $conf['upload_url'] . 'attach/' . $day; !IN_SAE and !is_dir($path) and (mkdir($path, 0777, TRUE) or message(-2, '目录创建失败')); $savename = $uid . '_' . attach_safe_name($name, $allowtypes); $destfile = $path . '/' . $savename; $desturl = $url . '/' . $savename; attach_create(array('tid' => $tid, 'pid' => 0, 'uid' => $uid, 'filesize' => $size, 'width' => $width, 'height' => $height, 'filename' => $day . '/' . $savename, 'filetype' => $type, 'orgfilename' => $name, 'create_date' => $time, 'comment' => '', 'downloads' => '0', 'isimage' => $isimage)) or message(-1, '保存附件数据失败'); file_put_contents($destfile, $data) or message(-1, '写入文件失败'); $ext = file_ext($destfile); if ($width > 0 && $ext != 'gif') { image_thumb($destfile, $destfile, $width, $height); } $conf['ipaccess_on'] and ipaccess_inc($longip, 'attachs'); $conf['ipaccess_on'] and ipaccess_inc($longip, 'attachsizes', $size); if ($ext == 'gif') { list($width, $height, $type, $attr) = getimagesize($destfile); } message(0, array('url' => $desturl, 'name' => $name, 'width' => $width, 'height' => $height)); } else { message(-1, '没有此功能'); }
echo $itemid; ?> "/> <table cellpadding="2" cellspacing="1" class="tb"> <tr> <td class="tl">请选择</td> <td> <select name="name"> <option>请选择目录或者zip文件</option> <?php foreach (glob(DT_ROOT . '/file/temp/*') as $v) { if (is_dir($v)) { $v = basename($v); echo '<option value="' . $v . '">/' . $v . '/</option>'; } else { if (file_ext($v) == 'zip') { $v = basename($v); echo '<option value="' . $v . '">/' . $v . '</option>'; } } } ?> </select> <input type="button" value=" 刷 新 " class="btn" onclick="window.location.reload();"/> <input type="submit" value=" 读 取 " class="btn"/> </td> </tr> <tr> <td class="tl">提示信息</td> <td class="f_gray"> 可以创建目录存放图片,并FTP上传目录至 file/temp/ 目录,或者直接打包为zip格式上传至 file/temp/ 目录</td>