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 active($active_string) { $name = file_name(); if ($active_string == "private" and isset($_GET['private'])) { echo ' class="active"'; } elseif ($active_string == $name) { echo ' class="active"'; } elseif (($name == "project.php" or $name == "task.php" or $name == "file.php" or $name == "directory.php" or $name == "project_list.php") and $active_string == "project") { echo ' class="active"'; } }
function file_sister($filename, $ext) { global $_josh; //this will tell you if there's a 'sister file' in the same directory, eg picture.jpg && picture.html if (file_exists($filename)) { list($file, $extension, $path) = file_name($filename); $sister = $path . $_josh["folder"] . $file . "." . $ext; if (file_exists($sister)) { error_debug("file sister file exists"); return $sister; } else { error_debug("file sister {$sister} does not exist"); } } return false; }
<?php //start session session_start(); //if user session exist if (!empty($_SESSION["user"]["uid"])) { } elseif (!empty($_COOKIE['id'])) { $_SESSION["system"]["login_from"] = $_SERVER["REQUEST_URI"]; header("Location: login_check.php?cookie=1&"); } elseif (file_name() != "login.php") { header("Location: login.php"); }
} // print_r($_FILES); //判断上传的文件格式 $filename = $_FILES['upload_file']['name']; if (pathinfo($filename, PATHINFO_EXTENSION) != "csv") { echo 'ce ne est pas la bonne forme de ficher (csv demanded)'; exit; } //将上传到临时目录下的文件存放到指定目录upload //1.判断指定目录是否存在 if (!is_dir('./upload')) { //目录不存在,创建目录 mkdir('./upload', 0777); } //2.将缓存csv文件复制到指定目录 $file_name = file_name($_FILES['upload_file']['name']); //调用file_name函数 copy($_FILES['upload_file']['tmp_name'], './upload/' . $file_name); //读取csv文件内容 // $str = file_get_contents('./upload/'.$file_name); // echo $str; if (($file = fopen('./upload/' . $file_name, 'r')) != false) { while ($data = fgetcsv($file)) { // $list[] = $data; $titre = $data[0]; $prenom = $data[1]; $firstInitial = $data[2]; $nom = $data[3]; $sex = $data[4]; $revue = $data[5]; $source = $data[6];
function delete_file($id, $key) { $conf = configurations(); $con = new Mongo(); $db = $con->{$conf}['base']->{$conf}['project']; $project = check_projects(array('_id' => new MongoId($id))); if (isset($project['files'][$key])) { try { $db->update(array('_id' => new MongoID($id)), array('$unset' => array('files.' . $key => array())), array('safe' => true, 'upsert' => true)); } catch (MongoCursorException $e) { trigger_error("Remove failed " . $e->getMessage() . $sha1); return 'db_error'; } //remove file rrmdir('files/' . file_name($project['name']) . '/' . file_name($project['version'])); return 'filedeleted'; } }
</div> </div> </div> </div> <div style="" class="container-fluid container" > <form id='choiceTheme' action="" method="get"> <small>选择主题颜色 </small> <select name="AdminThemeTryChangeCSS" id="AdminThemeTryChangeCSS"> <?php $list = file_find(__DIR__ . '/../css'); foreach ($list['file'] as $v) { $v = file_name($v); if (strpos($v, '.css') !== false && $v != 'style.css') { $v = str_replace('.bootstrap.min.css', '', $v); $css[] = $v; } } ?> <?php foreach ($css as $v) { ?> <option <?php if ($v == Comm::config('admin_bootstrap_css')) { ?> selected<?php } ?>
<?php /* type: bootstrap location: libraries/init/require.php Nạp file này vào phần đầu của ứng dụng để sử dụng thư viện chung. Note: file này được nạp sau khi đã cấu hình biến, hằng cho ứng dụng. */ //which is important for start all. if (!defined('app_libs')) { exit("Ứng dụng của bạn chưa được cấu hình (không tồn tại hằng app_libs) ?"); } /*base: /libs */ define('lib_dir', substr(app_libs, -1) != '/' ? app_libs . '/' : app_libs); //define('prefix_libs','hphp.'); include lib_dir . 'hphp.constants.php'; include lib_dir . 'hphp.php'; include lib_dir . 'hphp.file.php'; include lib_dir . 'hphp.plugin_file.php'; /* tạo hằng đường dẫn các thư viện khác, với tên trùng tên của file. */ $list_class_dir = package(lib_dir, null, false); foreach ($list_class_dir as $name) { $file = file_name(file_name($name, true)); $const = str_replace('hphp.', '', $file); define($const, $name); }