function upload($upload, $target = './', $exts = 'jpg,gif,torrent,zip,rar,7z,doc,docx,xls,xlsx,ppt,pptx,mp3,wma,swf,flv,txt', $size = 20, $rename = '') { mk_dir($target); if (is_array($upload['name'])) { $return = array(); foreach ($upload["name"] as $k => $v) { if (!empty($upload['name'][$k])) { $ext = get_ext($upload['name'][$k]); if (strpos($exts, $ext) !== false && $upload['size'][$k] < $size * 1024 * 1024) { $name = empty($rename) ? upload_name($ext) : upload_rename($rename, $ext); if (upload_move($upload['tmp_name'][$k], $target . $name)) { $return[] = $name; } } } } return $return; } else { $return = ''; if (!empty($upload['name'])) { $ext = get_ext($upload['name']); if (strpos($exts, $ext) !== false && $upload['size'] < $size * 1024 * 1024) { $name = empty($rename) ? upload_name($ext) : upload_rename($rename, $ext); if (upload_move($upload['tmp_name'], $target . $name)) { $return = $name; } } } } return $return; }
/** * 文件下载/或输出显示 * @param $filepath 文件路径 * @param $filename 文件名称 */ function download($filepath, $filename = '', $output = 0) { if (!$filename) { $filename = basename($filepath); } if (strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'msie ') !== false) { $filename = rawurlencode($filename); } $filetype = get_ext($filename); if (!file_exists($filepath)) { MSG('文件不存在'); } $filesize = sprintf("%u", filesize($filepath)); if (ob_get_length() !== false) { @ob_end_clean(); } header('Pragma: public'); header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); header('Cache-Control: no-store, no-cache, must-revalidate'); header('Cache-Control: pre-check=0, post-check=0, max-age=0'); header('Content-Transfer-Encoding: binary'); header('Content-Encoding: none'); header('Content-type: ' . $filetype); if (!$output) { header('Content-Disposition: attachment; filename="' . $filename . '"'); } header('Content-length: ' . $filesize); readfile($filepath); exit; }
function caching($comics_id, $zip_path, $image_ext) { $comic = zip_open($zip_path); if (!is_resource($comic)) { die("[ERR]ZIP_OPEN : " . $zip_path); } $inzip_path = ""; $count = 0; $files = null; $db = new SQLite3(DB); $db->exec("BEGIN DEFERRED;"); while (($entry = zip_read($comic)) !== false) { $inzip_path = zip_entry_name($entry); $cache_name = md5($zip_path . "/" . $inzip_path) . '.' . get_ext($inzip_path); // 画像か否か if (!is_image($inzip_path, $image_ext)) { continue; } $data = zip_entry_read($entry, zip_entry_filesize($entry)); $filepath = CACHE . '/' . $cache_name; file_put_contents($filepath, $data); $count++; query("INSERT INTO images (comics_id, page, filepath) VALUES (" . $comics_id . ", " . $count . ", '" . $filepath . "')", $db); } zip_close($comic); query("UPDATE comics SET pages = " . $count . " WHERE id = " . $comics_id, $db); $db->exec("COMMIT;"); }
function code_preprocessor($id, $file, $url_root) { $ext = get_ext($file); $dir = REPOSITORY . DIRECTORY_SEPARATOR . $id . DIRECTORY_SEPARATOR; $relative_path = str_replace($dir, "", $file); $is_new = isset($_GET['t']); include V2_PLUGIN . "/code/preprocessor/{$ext}.php"; }
/** * 文件上传记录入库操作 * * @author tuzwu * @createtime * @modifytime * @param * @return */ public function insert($insert) { $db = load_class('db'); $insert['userkeys'] = get_cookie('userkeys'); $ext = get_ext($insert['path']); if (in_array($ext, array('jpg', 'gif', 'bmp', 'png', 'jpeg'))) { $insert['isimage'] = 1; } return $id = $db->insert('attachment', $insert); }
/** * Загрузка изображений из архива * @param string $name * @return array */ public function loadArchiveImages($name) { $data = array(); $ext = get_ext($_FILES[$name]['name']); $filename = md5(microtime()); if ($_FILES[$name]['type'] != 'application/zip' or $_FILES[$name]['type'] != 0) { return $data; } if (move_uploaded_file($_FILES[$name]['tmp_name'], DOC . 'userfiles/' . $filename . '.' . $ext)) { chmod(DOC . 'userfiles/' . $filename . '.' . $ext, 0644); $zip = new ZipArchive(); $res = $zip->open(DOC . 'userfiles/' . $filename . '.' . $ext); if ($res === TRUE) { // Создаем временную папку if (!is_dir(DOC . 'userfiles/' . $filename)) { mkdir(DOC . 'userfiles/' . $filename, 0777); } // выгружаем изображение во временную папкуж $zip->extractTo(DOC . 'userfiles/' . $filename); $zip->close(); // Проверяем являются ли загруженные файлы изображениями и копируем в основную папку if ($dh = opendir(DOC . 'userfiles/' . $filename)) { while ($d = readdir($dh)) { // определение дочерней директории if (is_file(DOC . 'userfiles/' . $filename . '/' . $d) && $d != '.' && $d != '..') { $image = DOC . 'userfiles/' . $filename . '/' . $d; if (getimagesize($image)) { $copy_image = md5($filename . $d) . '.' . get_ext($image); copy($image, DOC . 'userfiles/original/' . $copy_image); $data[] = array('name' => $d, 'url' => $copy_image); } } } closedir($dh); } } else { echo 'failed, code:' . $res; exit; } } // Удаляем архив unlink(DOC . 'userfiles/' . $filename . '.' . $ext); // Удаляем временную папку $this->removeDir(DOC . 'userfiles/' . $filename); return $data; }
/** * Validate an image * @param $image * @return TRUE if the image is valid */ function validate_image($image) { global $mime, $image_whitelist; // Get the info for the image $info = getimagesize($image['tmp_name']); // Is it invalid? if (empty($info)) { return FALSE; } // Verify the mimetype $mime_type = $info['mime']; if (!isset($mime[$mime_type])) { return FALSE; } // Get the file extension $ext = get_ext($image['name']); // Compare it to the whitelist if (!in_array($ext, $image_whitelist)) { return FALSE; } // It is good return TRUE; }
function wp_get_files($dir) { global $wp_get_files_list, $domain, $site_url, $home_path, $assets_dir; if (is_dir($dir)) { if ($dh = opendir($dir)) { $file_id = 1; while ($file = readdir($dh)) { if ($file != '.' && $file != '..') { if (is_dir($dir . $file)) { wp_get_files($dir . $file . '/'); } else { if (get_ext($file) == 'js' || get_ext($file) == 'css' || get_ext($file) == 'jpg' || get_ext($file) == 'jpeg' || get_ext($file) == 'gif' || get_ext($file) == 'png' || get_ext($file) == 'apng' || get_ext($file) == 'tiff' || get_ext($file) == 'svg' || get_ext($file) == 'pdf' || get_ext($file) == 'css' || get_ext($file) == 'bmp') { $rand_code = rand(99, 999); $wp_get_files_list['html_encode'][str_replace($home_path, $site_url, $dir . $file)] = $site_url . $assets_dir . $file_id . $rand_code . '.' . get_ext($file); $wp_get_files_list['htacess_decode'][$file_id . $rand_code . '.' . get_ext($file)] = str_replace($domain, '', str_replace($home_path, $site_url, $dir . $file)); } } } $file_id++; } } closedir($dh); } }
if ($_GET['type'] === 'experiments') { // Check file id is owned by connected user $sql = "SELECT userid, real_name, long_name, item_id FROM uploads WHERE id = :id"; $req = $bdd->prepare($sql); $req->execute(array('id' => $id)); $data = $req->fetch(); if ($data['userid'] == $_SESSION['userid']) { // Good to go -> DELETE FILE $sql = "DELETE FROM uploads WHERE id = " . $id; $reqdel = $bdd->prepare($sql); $reqdel->execute(); $reqdel->closeCursor(); $filepath = 'uploads/' . $data['long_name']; unlink($filepath); // remove thumbnail $ext = get_ext($data['real_name']); if (file_exists('uploads/' . $data['long_name'] . '_th.' . $ext)) { unlink('uploads/' . $data['long_name'] . '_th.' . $ext); } // Redirect to the viewXP $expid = $data['item_id']; $msg_arr = array(); $msg_arr[] = 'File ' . $data['real_name'] . ' deleted successfully'; $_SESSION['infos'] = $msg_arr; header("location: experiments.php?mode=edit&id={$expid}"); } else { die; } // DATABASE ITEM } elseif ($_GET['type'] === 'database') { // Get realname
if (stripos($file, '.php') !== false) { continue; } ?> <li> <div class="task-title"> <span class="task-title-sp"> <?php echo "<img src='" . R . "images/icon/file.png' class='pull-left'> "; echo "<span class='col-lg-2 col-sm-4'>" . $file . "</span>"; echo "修改时间:" . time_format(filemtime(TPL_ROOT . $dir . '/' . $file)); ?> </span> <div class="pull-right hidden-phone"> <?php $extent = get_ext($file); if (in_array($extent, array('js', 'css'))) { ?> <a href="?m=template&f=res&v=history&dir=<?php echo $dir; ?> &file=<?php echo $file . $this->su(); ?> " class="btn btn-default btn-xs">历史版本</a> <a href="?m=template&f=res&v=edit&dir=<?php echo $dir; ?> &file=<?php echo $file . $this->su(); ?>
if (isset($_POST['phconc'])) { if ($_POST['phconc'] == true) { if (is_array($_POST['concurs']) && count($_POST['concurs']) > 0) { $concurs = serialize($_POST['concurs']); $i = 0; foreach ($_POST['concurs'] as $con) { if (count($con['img']) < 3) { for ($a = 0; $a < count($con['img']); $a++) { if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/img/uploads/news/fb/" . date('Y-m') . "/" . get_ext($con['img'][$a], '/'))) { resizeCopy($_SERVER['DOCUMENT_ROOT'] . str_replace('http://funtime.ge:80', '', generate_unknown($con['img'][$a])), get_ext($con['img'][$a], '/'), 485, $_SERVER['DOCUMENT_ROOT'] . "/img/uploads/news/fb/" . date('Y-m'), false); } } } else { for ($a = 0; $a < count($con['img']); $a++) { if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/img/uploads/news/fb/" . date('Y-m') . "/" . get_ext($con['img'][$a], '/'))) { resizeCopy($_SERVER['DOCUMENT_ROOT'] . str_replace('http://funtime.ge:80', '', generate_unknown($con['img'][$a])), get_ext($con['img'][$a], '/'), 285, $_SERVER['DOCUMENT_ROOT'] . "/img/uploads/news/fb/" . date('Y-m'), 3); } } } $i++; } $check_concurs = $DB->getOne("SELECT id FROM #__news_gallery_com WHERE news_id=" . intval($_GET['edit'])); if ($check_concurs > 0) { $DB->execute("UPDATE #__news_gallery_com SET gallery='{$concurs}',updated_at='" . date('Y-m-d H:i:s') . "' WHERE news_id=" . intval($_GET['edit'])); } else { $DB->execute("INSERT INTO #__news_gallery_com (news_id,gallery,date,updated_at) VALUES ('" . intval($_GET['edit']) . "','" . $concurs . "','" . date('Y-m-d H:i:s') . "','" . date('Y-m-d H:i:s') . "')"); } } else { $concurs = ""; $check_concurs = $DB->getOne("SELECT id FROM #__news_gallery_com WHERE news_id=" . intval($_GET['edit'])); if ($check_concurs > 0) {
die('0'); //返回命令 0 = 开始上传文件, 2 = 不上传文件,前台直接显示上传完成 } if (getGet('access2008_cmd') == '3') { //提交文件信息进行验证 getGet("access2008_File_name"); // '文件名 getGet("access2008_File_size"); // '文件大小,单位字节 getGet("access2008_File_type"); // '文件类型 例如.gif .png die('0'); //返回命令 0 = 开始上传文件,1 = 提交MD5验证后的文件信息进行验证, 2 = 不上传文件,前台直接显示上传完成 } //--------------------------------------------------------------------------------------------- $type = get_ext($_FILES["Filedata"]["name"]); $uploadfile = @iconv('UTF-8', 'GB2312//IGNORE', trim(urldecode($_REQUEST['path']), '/') . '/' . $_FILES["Filedata"]["name"]); if ((in_array('*', C('UPLOAD_CONF.UPLOAD_ALLOW_TYPE')) || in_array($type, C('UPLOAD_CONF.UPLOAD_ALLOW_TYPE'))) && $_FILES["Filedata"]["size"] < C('UPLOAD_CONF.UPLOAD_MAX_SIZE')) { if ($_FILES["Filedata"]["error"] > 0) { echo '<div class="notification attention png_bg"><div><span style="float:left;">上传失败: </span>' . $_FILES["Filedata"]["name"] . '!</div></div>'; echo '<div class="notification error png_bg"><div><span style="float:left;">错误信息: </span>' . $_FILES["Filedata"]["error"] . '!</div></div>'; exit; } else { $file = array(); $file['msg_attention'] = '<div class="notification attention png_bg"><div><span style="float:left;">上传失败: </span>' . $_FILES["Filedata"]["name"] . '</div></div>'; $file['msg_success_normal'] = '<div class="notification success png_bg"><div><span style="float:left;">上传成功: </span>' . $_FILES["Filedata"]["name"] . '</div></div>'; $file['msg_success_cover'] = '<div class="notification attention png_bg"><div><span style="float:left;">上传成功: </span>' . $_FILES["Filedata"]["name"] . ' 已覆盖</div></div>'; $file['file_type'] = '<span style="float:left;">文件类型: </span>' . $type . '<br />'; $file['file_size'] = '<span style="float:left;">文件大小: </span>' . dealsize($_FILES["Filedata"]["size"]) . '<br />'; $file['file_md5'] = '<span style="float:left;">MD5 校验 : </span>' . getGet("access2008_File_md5") . '<br />'; $file['info'] = '<div class="notification information png_bg"><div>' . $file['file_type'] . $file['file_size'] . $file['file_md5'] . '</div></div>';
/** * Load the current page * @return null */ public function _remap() { try { // URI segment $uri = explode('.', implode('/', array_slice($this->uri->segments, 1))); $slug = $uri[0]; $slug_first_segment = strpos($slug, '/') ? substr($slug, 0, strpos($slug, '/')) : $slug; if (empty($slug)) { header('Location: ' . $this->data['base_uri'] . $this->fallback_page); exit; } // Ajax login check if ('login_status' == $slug_first_segment) { return $this->login_status(); } // Load page based on slug $page = $this->pages->get_by_slug($this->data['book']->book_id, $slug); if (!empty($page)) { // Protect if (!$page->is_live) { $this->protect_book('Reader'); } // Version being asked for $version_num = (int) get_version($this->uri->uri_string()); $this->data['version_datetime'] = null; if (!empty($version_num)) { $version = $this->versions->get_by_version_num($page->content_id, $version_num); if (!empty($version)) { $this->data['version_datetime'] = $version->created; } } // Build (hierarchical) RDF object for the page's version(s) $settings = array('book' => $this->data['book'], 'content' => $page, 'base_uri' => $this->data['base_uri'], 'versions' => !empty($this->data['version_datetime']) ? $this->data['version_datetime'] : RDF_Object::VERSIONS_MOST_RECENT, 'ref' => RDF_Object::REFERENCES_ALL, 'prov' => RDF_Object::PROVENANCE_ALL, 'max_recurses' => $this->max_recursions); $index = $this->rdf_object->index($settings); if (!count($index)) { throw new Exception('Problem getting page index'); } $this->data['page'] = $index[0]; unset($index); // Paywall if (isset($page->paywall) && $page->paywall) { $this->paywall(); } // If a media page, overwrite the views with the media_views if applicable if ('media' == $this->data['page']->type && !empty($this->data['media_views'])) { $this->data['views'] = $this->data['media_views']; } // Set the view based on the page's default view $default_view = $this->data['page']->versions[$this->data['page']->version_index]->default_view; if (array_key_exists($default_view, $this->data['views'])) { $this->data['view'] = $default_view; } } else { $this->data['slug'] = $slug; } // View and view-specific method (outside of the if/page context above, in case the page hasn't been created yet if (array_key_exists(get_ext($this->uri->uri_string()), $this->data['views'])) { $this->data['view'] = get_ext($this->uri->uri_string()); } if (in_array($this->data['view'], $this->vis_views)) { $this->data['viz_view'] = $this->data['view']; // Keep a record of the specific viz view being asked for $this->data['view'] = $this->vis_views[0]; // There's only one viz page (Javascript handles the specific viz types) } // View-specific method $method_name = $this->data['view'] . '_view'; if (method_exists($this, $method_name)) { $this->{$method_name}(); } // URI segment method if (method_exists($this, $slug_first_segment)) { $this->{$slug_first_segment}(); } } catch (Exception $e) { header($e->getMessage()); exit; } if ($this->template_has_rendered) { return; } // Template might be rendered in one of the methods below $this->template->set_template($this->config->item('arbor')); foreach ($this->template->template['regions'] as $region) { $this->template->write_view($region, 'melons/' . $this->data['melon'] . '/' . $region, $this->data); } $this->template->render(); }
function is_image($filename, $image_ext) { $filename = trim($filename); $ext = get_ext($filename); return in_array($ext, $image_ext); }
<?php include_once $_SERVER['DOCUMENT_ROOT'] . "/common/lib/common.php"; $db = new DbMySqli(); $name = addslashes($_POST['name']); $title = addslashes($_POST['title']); $content = addslashes($_POST['content']); //첨부파일 업로드 if (is_uploaded_file($_FILES["filename"]["tmp_name"])) { $filename = $_FILES["filename"]["name"]; $filesize = $_FILES["filename"]["size"]; $origin_filename = $filename; $ext = strtolower(get_ext($filename)); new_check_ext($ext); //금지파일 체크 $filename = get_filename($filepath1, $ext); move_uploaded_file($_FILES["filename"]["tmp_name"], get_real_filepath($filepath1) . "/" . $filename); } else { $filesize = 0; } $userip = $_SERVER['REMOTE_ADDR']; $sql = "select ifnull(max(idx), 0) + 1 from tbl_qna"; $result = $db->query($sql); $rows = mysqli_fetch_row($result); $f_idx = $rows[0]; $table = "tbl_qna"; $idx_field = "idx"; $db['f_idx'] = $f_idx; $db['thread'] = "a"; $db['name'] = $name; $db['title'] = $title;
function file_upload($field = '', $file_type = '', $dest_dir = '') { $uploadtempdir = $_ENV["TEMP"] . "\\"; ini_set('upload_tmp_dir', $uploadtempdir); $tmp_name = $_FILES[$field]["tmp_name"]; $file_name = $_FILES[$field]["name"]; $file_type = $_FILES[$field]["type"]; $file_size = $_FILES[$field]["size"]; $file_ext = get_ext($file_name); $file_name_orig = $file_name; $file_name_base = substr($file_name, 0, strlen($file_name) - (strlen($file_ext) + 1)); //$dest_dir = '/tmp'; if ($file_size == 0) { return; } if (!is_dir($dest_dir)) { echo "dest_dir not found<br />\n"; return; } //check if allowed file type if ($file_type == "img") { switch (strtolower($file_ext)) { case "jpg": break; case "png": break; case "gif": break; case "bmp": break; case "psd": break; case "tif": break; default: return false; } } if ($file_type == "file") { switch (strtolower($file_ext)) { case "doc": break; case "pdf": break; case "ppt": break; case "xls": break; case "zip": break; case "exe": break; default: return false; } } //find unique filename: check if file exists if it does then increment the filename $i = 1; while (file_exists($dest_dir . '/' . $file_name)) { if (strlen($file_ext) > 0) { $file_name = $file_name_base . $i . '.' . $file_ext; } else { $file_name = $file_name_orig . $i; } $i++; } //echo "file_type: ".$file_type."<br />\n"; //echo "tmp_name: ".$tmp_name."<br />\n"; //echo "file_name: ".$file_name."<br />\n"; //echo "file_ext: ".$file_ext."<br />\n"; //echo "file_name_orig: ".$file_name_orig."<br />\n"; //echo "file_name_base: ".$file_name_base."<br />\n"; //echo "dest_dir: ".$dest_dir."<br />\n"; //move the file to upload directory //bool move_uploaded_file ( string $filename, string $destination ) if (move_uploaded_file($tmp_name, $dest_dir . '/' . $file_name)) { return $file_name; } else { echo "File upload failed! Here's some debugging info:\n"; return false; } exit; }
<?php include 'data/function.php'; //$a = array('1','2','3'); //$b = array('odin','dva','tri'); //$c = str_replace($a, $b, '1234'); //print_r($c); //echo generate_page_fname('buy viagra online'); //$d = preg_replace("/\[noan\]/","TAGG",'asjasasnas[noan]mkmkmk'); //echo $d; //$patterns = array ("/(19|20)(\d{2})-(\d{1,2})-(\d{1,2})/","/^\s*{(\w+)}\s*=/"); //$replace = array ("\\3/\\4/\\1\\2", "$\\1 ="); //echo preg_replace($patterns, $replace, "{startDate} = 1999-5-27"); //$string = "The quick brown fox jumped over the lazy dog."; //$patterns[0] = "/quick/"; //$patterns[1] = "/brown/"; //$patterns[2] = "/fox/"; //$replacements[2] = "bear"; //$replacements[1] = "black"; //$replacements[0] = "slow"; //echo preg_replace($patterns, $replacements, $string); print get_ext('asasa.txt');
/** * URL information and load the current book */ public function __construct() { parent::__construct(); $this->load->model('book_model', 'books'); $this->load->model('page_model', 'pages'); $this->load->model('version_model', 'versions'); $this->load->model('reference_model', 'references'); $this->load->model('annotation_model', 'annotations'); $this->load->model('path_model', 'paths'); $this->load->model('tag_model', 'tags'); $this->load->model('reply_model', 'replies'); $this->load->library('RDF_Object', 'rdf_object'); $this->load->library('statusCodes'); $this->load->helper('inflector'); $this->models = $this->config->item('rel'); // Determine the current book being asked for (if applicable) $this->scope = strtolower(get_class($this)) == strtolower($this->uri->segment('1')) ? null : strtolower($this->uri->segment('1')); // Load book beind asked for (if applicable) $this->data['book'] = !empty($this->scope) ? $this->books->get_by_slug($this->scope) : null; if (empty($this->data['book'])) { // Book couldn't be found $this->data['base_uri'] = confirm_slash(base_url()); } else { // Book was found $this->data['base_uri'] = confirm_slash(base_url()) . confirm_slash($this->data['book']->slug); // Protect book; TODO: provide api_key authentication like api.php $this->set_user_book_perms(); if (!$this->data['book']->url_is_public && !$this->login_is_book_admin('reader')) { header(StatusCodes::httpHeaderFor(StatusCodes::HTTP_NOT_FOUND)); exit; } } // Format (e.g., 'xml', 'json') $allowable_formats = array('xml' => 'xml', 'json' => 'json', 'rdfxml' => 'xml', 'rdfjson' => 'json', 'turtle' => 'turtle'); $this->data['format'] = isset($_REQUEST['format']) && array_key_exists($_REQUEST['format'], $allowable_formats) ? $allowable_formats[$_REQUEST['format']] : $allowable_formats[key($allowable_formats)]; $ext = get_ext($this->uri->uri_string()); $this->data['format'] = !empty($ext) && array_key_exists($ext, $allowable_formats) ? $allowable_formats[$ext] : $this->data['format']; // Recursion level $this->data['recursion'] = isset($_REQUEST['rec']) && is_numeric($_REQUEST['rec']) ? (int) $_REQUEST['rec'] : 0; // Display references? $this->data['references'] = isset($_REQUEST['ref']) && $_REQUEST['ref'] ? true : false; // Restrict relationships to a certain relationship or set of relationships (seperated by a comma)? $this->data['restrict'] = array(); $restrict = isset($_REQUEST['res']) && !empty($_REQUEST['res']) ? explode(',', $_REQUEST['res']) : array(); foreach ($restrict as $res) { if (!in_array(plural(strtolower($res)), $this->models)) { continue; } $this->data['restrict'][] = (string) plural(strtolower($res)); } // Display all versions? $this->data['versions'] = isset($_REQUEST['versions']) && $_REQUEST['versions'] ? true : false; // Search terms $this->data['sq'] = isset($_REQUEST['sq']) && !empty($_REQUEST['sq']) ? search_split_terms($_REQUEST['sq']) : null; // Provenance $this->data['provenance'] = isset($_REQUEST['prov']) && !empty($_REQUEST['prov']) ? 1 : null; // Show hidden content $this->data['hidden'] = isset($_REQUEST['hidden']) && !empty($_REQUEST['hidden']) ? (int) $_REQUEST['hidden'] : 0; $this->set_user_book_perms(); if (!$this->data['login'] || !$this->login_is_book_admin()) { $this->data['hidden'] = 0; } // Pagination $start = isset($_REQUEST['start']) ? (int) $_REQUEST['start'] : null; $results = isset($_REQUEST['results']) && !empty($_REQUEST['results']) ? (int) $_REQUEST['results'] : null; if (empty($results)) { $start = $results = null; } $this->data['pagination'] = array(); if (!empty($start) || $start === 0) { $this->data['pagination']['start'] = $start; } if (!empty($results)) { $this->data['pagination']['results'] = $results; } }
$sql = "DELETE FROM items WHERE id = :id"; $req = $pdo->prepare($sql); $result[] = $req->execute(array('id' => $id)); // delete associated tags $sql = "DELETE FROM items_tags WHERE item_id = :id"; $req = $pdo->prepare($sql); $result[] = $req->execute(array('id' => $id)); // delete associated files $sql = "SELECT real_name, long_name FROM uploads WHERE item_id = :id AND type = :type"; $req = $pdo->prepare($sql); $req->execute(array('id' => $id, 'type' => 'items')); while ($uploads = $req->fetch()) { $filepath = ELAB_ROOT . 'uploads/' . $uploads['long_name']; unlink($filepath); // remove thumbnail $ext = get_ext($uploads['real_name']); if (file_exists(ELAB_ROOT . 'uploads/' . $uploads['long_name'] . '_th.' . $ext)) { unlink(ELAB_ROOT . 'uploads/' . $uploads['long_name'] . '_th.' . $ext); } } // now remove them from the database $sql = "DELETE FROM uploads WHERE item_id = :id AND type = :type"; $req = $pdo->prepare($sql); $result[] = $req->execute(array('id' => $id, 'type' => 'items')); // delete links of this item in experiments with this item linked // get all experiments with that item linked $sql = "SELECT id FROM experiments_links WHERE link_id = :link_id"; $req = $pdo->prepare($sql); $result[] = $req->execute(array('link_id' => $id)); while ($links = $req->fetch()) { $delete_sql = "DELETE FROM experiments_links WHERE id=" . $links['id'];
$count = 1; while (($entry = zip_read($comic)) !== false) { $file_name = zip_entry_name($entry); $file_name = mb_convert_encoding($file_name, "UTF-8", $enc); // もう走査しなくていい if ($count > FORCOVER) { break; } // 画像か否か if (!is_image($file_name, $image_ext)) { continue; } // サムネイルを作るべき画像か if ($count == FORCOVER) { $data = zip_entry_read($entry, zip_entry_filesize($entry)); $ext = get_ext($file_name); $thumb = array("id" => $i + 1, "zip" => $zip_file, "filepath" => CACHE . "/thumb." . $ext, "ext" => $ext); file_put_contents($thumb["filepath"], $data); $r = make_thumbnail($thumb); if ($r) { save_thumbnail($thumb); } } $count++; } } else { //die("[ERR]ZIP_OPEN : ".$zip_file); // ここに代替画像 } zip_close($comic); }
$error .= __('Неправильный адрес электронной почты') . '<br />'; } if (trim($emailsubject) == "") { $emailsubject = $defaultsubject; } if (trim($yourmessage) == "") { $error .= __('Вы не ввели сообщение') . '<br />'; } if (!$captcha) { $error .= __('Каптча введена не правильно') . '<br />'; } if ($allowattach > 0) { //Loopish for ($i = 0; $i <= $allowattach - 1; $i++) { if ($_FILES['attachment']['name'][$i]) { $ext = get_ext($_FILES['attachment']['name'][$i]); $size = $_FILES['attachment']['size'][$i]; $max_bytes = $max_file_size * 1024; //Check if the file type uploaded is a valid file type. if (!in_array($ext, $allowtypes)) { $error .= __('Недопустимое расширение для вашего файла') . ': ' . $_FILES['attachment']['name'][$i] . ", only " . $types . " are allowed.<br />"; //Check the size of each file } elseif ($size > $max_bytes) { $error .= __('Ваш файл') . ': ' . $_FILES['attachment']['name'][$i] . ' ' . __('большой. Максимальный допустимый размер файла') . ' ' . $max_file_size . 'kb.<br />'; } } } //Tally the size of all the files uploaded, check if it's over the ammount. $total_size = array_sum($_FILES['attachment']['size']); $max_file_total_bytes = $max_file_total * 1024; if ($total_size > $max_file_total_bytes) {
$t_users = $tablePreStr . 'users'; $t_mypals = $tablePreStr . "pals_mine"; $t_pals_req = $tablePreStr . "pals_request"; $user_ico = "user_ico"; $u_field_id = "user_id"; $pals_ico = "pals_ico"; $p_field_id = "pals_id"; $req_ico = "req_ico"; $q_field_id = "req_id"; if ($ico_url == '') { action_return(0, $u_langpackage->u_save_false, '-1'); exit; } //生成70px缩略图 if (function_exists('imagecopyresampled')) { $img_ext = get_ext($ico_url); if ($img_ext == 'jpg' || $img_ext == 'jpeg') { $temp_img = imagecreatefromjpeg($ico_url); } if ($img_ext == 'gif') { $temp_img = imagecreatefromgif($ico_url); } if ($img_ext == 'png') { $temp_img = imagecreatefrompng($ico_url); } $s_ico = str_replace('.' . $img_ext, '_small.' . $img_ext, $ico_url); $small_ico = imagecreatetruecolor(70, 70); imagecopyresampled($small_ico, $temp_img, 0, 0, 0, 0, 70, 70, 200, 200); imagejpeg($small_ico, $s_ico); } else { $s_ico = $ico_url;
if (isset($_GET['action']) && $_GET['action'] == 'index') { resize_img($dir['images'] . $img_file, $thumb_size, './' . $dir['thumbs'] . '_' . $img_file); } $f_lines .= $i . DELIMITER . $img_info['filename'] . DELIMITER . $img_info['extension'] . DELIMITER . $img_size . DELIMITER . $img_time . DELIMITER . 'images' . DELIMITER . $img_width . DELIMITER . $img_height . DELIMITER . '1' . DELIMITER . '' . DELIMITER . '' . DELIMITER . '' . DELIMITER . '' . DELIMITER . '' . DELIMITER . '' . DELIMITER . '' . DELIMITER . '' . DELIMITER . '' . "\n"; $i++; } } $f_content = SAFETY_LINE . DELIMITER . $i . "\n" . $f_lines; mn_put_contents($file['files'], $f_content); header('Location: ./mn-files.php?back=indexed'); exit; } elseif (isset($_POST['action']) && ($_POST['action'] == 'quick-upload' || $_POST['action'] == 'multiupload') && isset($_FILES['file']['name']) && !empty($_FILES['file']['name'])) { $multiupload = $_POST['action'] == 'multiupload' ? true : false; $file_folder = isset($_POST['f']) && !empty($_POST['f']) && is_numeric($_POST['f']) ? $_POST['f'] : ''; $file_gallery = isset($_POST['g']) && !empty($_POST['g']) && is_numeric($_POST['g']) ? $_POST['g'] : ''; $file_ext = get_ext($_FILES['file']['name']); // if file is too big, cancel upload if (isset($_FILES['file']['size']) && !empty($_FILES['file']['size']) && $_FILES['file']['size'] > $max_upload_size * 1024 * 1024) { if ($multiupload) { echo '0'; } else { header('location: ./mn-files.php?back=toobig'); exit; } } elseif (is_image($_FILES['file']['name'])) { $source_file = pathinfo_utf($_FILES['file']['name']); $clean_file_name = friendly_url($source_file['filename']); $clean_file_ext = strtolower($source_file['extension']); $clean_file = $clean_file_name . '.' . $clean_file_ext; $target_file = './' . $dir['images'] . $clean_file; if (file_exists($target_file)) {
} if ($count > 0) { echo "<div class='box'>"; echo "<img src='img/attached.png' class='bot5px'> <h3 style='display:inline'>" . ngettext('Attached file', 'Attached files', $count) . "</h3>"; echo "<div class='row'>"; while ($uploads_data = $req->fetch()) { echo "<div class='col-md-4 col-sm-6'>"; echo "<div class='thumbnail'>"; // show the delete button only in edit mode, not in view mode if ($_GET['mode'] === 'edit') { echo "<a class='align_right' href='app/delete_file.php?id=" . $uploads_data['id'] . "&type=" . $uploads_data['type'] . "&item_id=" . $uploads_data['item_id'] . "' onClick=\"return confirm('Delete this file ?');\">"; echo "<img src='img/small-trash.png' title='delete' alt='delete' /></a>"; } // end if it is in edit mode // get file extension $ext = filter_var(get_ext($uploads_data['real_name']), FILTER_SANITIZE_STRING); $filepath = 'uploads/' . $uploads_data['long_name']; $filesize = filesize('uploads/' . $uploads_data['long_name']); $thumbpath = 'uploads/' . $uploads_data['long_name'] . '_th.' . $ext; // list of image type we can deal with the GD lib $image_extensions = array('jpg', 'jpeg', 'JPG', 'JPEG', 'png', 'PNG', 'gif', 'GIF'); // list of extensions with a corresponding img/thumb-*.png image $common_extensions = array('avi', 'csv', 'doc', 'docx', 'mov', 'pdf', 'ppt', 'rar', 'xls', 'xlsx', 'zip'); // Make thumbnail only if it isn't done already and if size < 2 Mbytes and if it's an image if (!file_exists($thumbpath) && $filesize <= 2000000 && in_array($ext, $image_extensions)) { make_thumb($filepath, $ext, $thumbpath, 100); } // only display the thumbnail if the file is here if (file_exists($thumbpath) && in_array($ext, $image_extensions)) { // we add rel='gallery' to the images for fancybox to display it as an album (possibility to go next/previous) echo "<a href='uploads/" . $uploads_data['long_name'] . "' class='fancybox' rel='gallery' ";
//on crée une boucle pour rentrer tous les résultats dans un tableau if (is_array($fileUpload)) { foreach ($fileUpload as $key => $fichier) { foreach ($fichier as $keyF => $vFichier) { if (!array_key_exists($keyF, $files)) { $files[$keyF] = array(); } $files[$keyF][$key] = $vFichier; } } } //on prépare un tableau d'extensions valide $extensions_valides = array('jpg', 'jpeg', 'gif', 'png', 'JPG'); foreach ($files as $file) { $document = new Upload($file); $extension_fichier = get_ext($file); //extension du fichier if (in_array($extension_fichier, $extensions_valides)) { //on compare l'extension du fichier avec les extensions autorisées $miniature = $document; $favoris = $document; if ($document->uploaded) { //on crée la miniature en noir et blanc avec le texte qui sera affiché dans la gallerie $miniature->image_resize = true; $miniature->image_ratio_crop = true; $miniature->image_y = 300; $miniature->image_ratio_x = true; $miniature->image_ratio_y = true; $miniature->image_greyscale = true; $miniature->image_text = $_POST['texto']; $miniature->image_text_font = "font/test4.gdf";
/** * 保存图像 * @param int $fileNameType 文件名类型 0使用原文件名,1使用指定的文件名,2在原文件名加上后缀,3产生随机文件名 * @param string $folder 文件夹路径 为空为与原文件相同 * @param string $param 参数$fileNameType为1时为文件名2时为后缀 * @return void */ public function save($fileNameType = 0, $folder = NULL, $param = '_miniature') { if ($folder == NULL) { $folder = dirname($this->fileName) . DIRECTORY_SEPARATOR; } $fileExtName = '.' . get_ext($this->fileName); $fileBesicName = basename($this->fileName); switch ($fileNameType) { case 1: $newFileName = $folder . $param; break; case 2: $newFileName = $folder . $fileBesicName . $param . $fileExtName; break; case 3: $tmp = date('YmdHis'); $fileBesicName = $tmp; $i = 0; while (file_exists($folder . $fileBesicName . $fileExtName)) { $fileBesicName = $tmp . $i; $i++; } $newFileName = $folder . $fileBesicName . $fileExtName; break; default: $newFileName = $this->fileName; break; } $this->display($newFileName); return $newFileName; }
<?php define('puush', ''); require_once 'config.php'; require_once 'func.php'; // ? $k = get_post_var('k'); // ? $c = get_post_var('c'); // Check for the file if (!isset($_FILES['f'])) { exit('ERR No file provided.'); } // The file they are uploading $file = $_FILES['f']; // Check the size, max 250 MB if ($file['size'] > MAX_FILE_SIZE) { exit('ERR File is too big.'); } // Ensure the image is actually a file and not a friendly virus if (validate_image($file) === FALSE) { exit('ERR Invalid image.'); } // Generate a new file name $ext = get_ext($file['name']); $generated_name = generate_upload_name($ext); // Move the file move_uploaded_file($file['tmp_name'], UPLOAD_DIR . $generated_name . '.' . $ext); // ahem echo '0,' . sprintf(FORMATTED_URL, $generated_name) . ',-1,-1';
$data['statusCode'] = 300; $data['message'] = '<font color="blue">操作失败:</font><font color="red">未知操作指令</font><br />'; } $data['message'] .= '<font color="green">执行耗时:</font><font color="red">' . G('_run_start', '_run_end', 6) . ' 秒</font><br />'; exit(json_encode($data)); } elseif ('imageview' == $action) { $file = u2g(trim($_REQUEST['file'])); require INC_ROOT . 'Image.class.php'; $Image = new Image(); $thumbFile = DATA_CACHE_PATH . substr(md5($file), 2, 12) . '.' . get_ext($file); if (false !== strpos($file, 'data/Cache/')) { $Image->showImg(DATA_CACHE_PATH . basename($file), '', 120, 100); //die(); } else { if (!is_file($thumbFile)) { $Image->thumb($file, $thumbFile, get_ext($file), 120, 100, true); } if (!$Image->showImg($thumbFile, '', 120, 100)) { $Image->showImg(DATA_PUBLIC_PATH . 'nothumb.png', '', 120, 100); } if (C('CACHE_DATA_DEL')) { unlink($thumbFile); } } } elseif ('codeExplorer' == $action) { //批量上传文件 require ROOT . 'static/template/upload.tpl.php'; } else { $data['statusCode'] = 300; $data['message'] = '<font color="green">错误命令:</font><font color="red">未知API</font><br />'; $data['message'] .= '<font color="green">执行耗时:</font><font color="red">' . G('_run_start', '_run_end', 6) . ' 秒</font><br />';
$language = $lan; break 2; } } } return $language; } $file = array(); $file['file_utf'] = trim($_REQUEST['file']); $file['file'] = u2g($file['file_utf']); $file['content'] = file($file['file']); $file['encode'] = get_encode($file['file']); $file['line'] = count($file['content']); $file['size'] = dealsize(filesize($file['file'])); $file['chmod'] = substr(sprintf('%o', @fileperms($file['file'])), -4); $file['language'] = get_language(get_ext($file['file'])); if ('GB2312' == $file['encode']) { $file['encode_selected']['UTF-8'] = ''; $file['encode_selected']['GB2312'] = 'selected="selected"'; } else { $file['encode_selected']['UTF-8'] = 'selected="selected"'; $file['encode_selected']['GB2312'] = ''; } // $textarea = array(); $textarea['main']['width'] = C('EDIT_CONF.EDITOR_CONF.WIDTH') - 35; $textarea['main']['height'] = C('EDIT_CONF.EDITOR_CONF.HEIGHT') - 250; $textarea['edit']['width'] = $textarea['main']['width'] - 10; $textarea['edit']['height'] = $textarea['main']['height'] - 10; $textarea['language'] = $file['language'] ? $file['language'] : 'text'; $textarea['content'] = '';
function create_thumb($src_file, $thumb_file, $t_width, $t_height) { if (!file_exists($src_file)) { return false; } $src_info = getImageSize($src_file); //如果来源图像小于或等于缩略图则拷贝源图像作为缩略图 if ($src_info[0] <= $t_width && $src_info[1] <= $t_height) { if (!copy($src_file, $thumb_file)) { return false; } return true; } //按比例计算缩略图大小 if ($src_info[0] - $t_width > $src_info[1] - $t_height) { $t_height = $t_width / $src_info[0] * $src_info[1]; } else { $t_width = $t_height / $src_info[1] * $src_info[0]; } //取得文件扩展名 $fileext = get_ext($src_file); switch ($fileext) { case 'jpg': $src_img = ImageCreateFromJPEG($src_file); break; case 'png': $src_img = ImageCreateFromPNG($src_file); break; case 'gif': $src_img = ImageCreateFromGIF($src_file); break; } //创建一个真彩色的缩略图像 $thumb_img = @ImageCreateTrueColor($t_width, $t_height); //ImageCopyResampled函数拷贝的图像平滑度较好,优先考虑 if (function_exists('imagecopyresampled')) { @ImageCopyResampled($thumb_img, $src_img, 0, 0, 0, 0, $t_width, $t_height, $src_info[0], $src_info[1]); } else { @ImageCopyResized($thumb_img, $src_img, 0, 0, 0, 0, $t_width, $t_height, $src_info[0], $src_info[1]); } //生成缩略图 switch ($fileext) { case 'jpg': ImageJPEG($thumb_img, $thumb_file); break; case 'gif': ImageGIF($thumb_img, $thumb_file); break; case 'png': ImagePNG($thumb_img, $thumb_file); break; } //销毁临时图像 @ImageDestroy($src_img); @ImageDestroy($thumb_img); return true; }