function sitepath_constructor() { $urlpath = "{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"; $sitepath = ''; $pieces = explode("=", $urlpath); if (strpos($pieces[1], '&') !== FALSE) { // if the url string contains & then trim the pieces[1] $pieces_inside = explode("&", $pieces[1]); //Now pieces_inside[0] contains the desired path $page = $pieces_inside[0]; } else { // if the url string does not contain &, just create the desired path $page = $pieces[1]; } switch ($page) { case "resultsPage": $page = 'Αποτελέσματα Αναζήτησης'; $href = '?page=resultsPage'; break; case "confirmLoan": $page = 'Επιβεβαίωση Δανεισμού'; $href = '?page=confirmLoan'; break; case "advancedSearch": $page = 'Σύνθετη Αναζήτηση'; $href = '?page=advancedSearch'; break; case "history": $page = 'Ιστορικό Χρήστη'; $href = '?page=history'; break; case "under_construction": $page = 'Υπο Κατασκευή'; $href = get_basename(); break; default: $page = 'no path'; $href = get_basename(); } if (!array_key_exists($page, $_SESSION['sitepath'])) { // echo $page . ' and ' . $href . ' do not exist'; $_SESSION['sitepath'][$page] = $href; } foreach ($_SESSION['sitepath'] as $key => $value) { if ($key == 'Αρχική') { $sitepath = '<a href="" style="position:relative;top:10px;left:14px;text-decoration:underline;color:#FFFAF0;">' . $key . '</a>'; } else { // If the requested URI is already in the path, then add it to the path and stop construction. $current = "{$_SERVER['REQUEST_URI']}"; if (strpos($current, $value) !== FALSE) { $sitepath = $sitepath . ' <span class="glyphicon glyphicon-chevron-right" style="color: gray;position:relative;top:12px;left:14px;" aria-hidden="true"></span> ' . "<a href='{$value}' style=position:relative;top:10px;left:14px;text-decoration:underline;color:#FFFAF0;>" . $key . '</a>'; break; } else { $sitepath = $sitepath . ' <span class="glyphicon glyphicon-chevron-right" style="color: gray;position:relative;top:12px;left:14px;" aria-hidden="true"></span> ' . "<a href='{$value}' style=position:relative;top:10px;left:14px;text-decoration:underline;color:#FFFAF0;>" . $key . '</a>'; } } } return $sitepath; }
function convert_to_IMG($attachment, $options) { $path = get_path($attachment); $dir = get_dir($attachment); $basename = get_basename($attachment); $converted_images = array(); $max_width = $options['max_width'] ? (int) $options['max_width'] : 0; $max_height = $options['max_height'] ? (int) $options['max_height'] : 0; $img_extension = $options['img_extension'] ? $options['img_extension'] : 'jpg'; $pages_to_convert = $options["pages_to_convert"] ? (int) $options["pages_to_convert"] : 0; if ($pages_to_convert > 5) { $pages_to_convert = 5; } $pages_to_convert = $pages_to_convert - 1; $quality = $options['quality'] ? (int) $options['quality'] : 80; if ($quality > 100) { $quality = 100; } try { $imagick = new Imagick(); $imagick->clear(); $imagick->destroy(); if ($options) { $imagick->setResolution(150, 150); $imagick->readimage($path); $imagick->setCompressionQuality($quality); } else { $imagick->setResolution(72, 72); $imagick->readimage($path); } foreach ($imagick as $c => $_page) { if ($pages_to_convert == -1 || $c <= $pages_to_convert) { $_page->setImageBackgroundColor('white'); $_page->setImageFormat($img_extension); if ($max_width && $max_height) { $_page->adaptiveResizeImage($max_width, $max_height, true); } $blankPage = new \Imagick(); $blankPage->newPseudoImage($_page->getImageWidth(), $_page->getImageHeight(), "canvas:white"); $blankPage->compositeImage($_page, \Imagick::COMPOSITE_OVER, 0, 0); if ($blankPage->writeImage($dir . "/" . $basename . '-' . $c . '.' . $img_extension)) { array_push($converted_images, $dir . "/" . $basename . '-' . $c . '.' . $img_extension); } $blankPage->clear(); $blankPage->destroy(); } } } catch (ImagickException $e) { $converted_images = false; } catch (Exception $e) { $converted_images = false; } return $converted_images; }
function renewData($type, $classes, $list, $table) { if (is_array($classes)) { foreach ($classes as $value) { $files = files($type, $value); foreach ($files as $item) { $size = getimagesize($item); if (!$size) { $size[0] = 0; $size[1] = 0; } $data = array('img_url' => $item, 'img_date' => date('Y-m-d H:i:s', filectime($item)), 'img_caption' => get_basename($item), 'img_class' => $value, 'img_type' => $type, 'img_size' => filesize($item), 'img_width' => $size[0], 'img_height' => $size[1]); $index = array_search($item, $list); if ($index !== false) { array_splice($list, $index, 1); } else { $table->add($data); } } } } }
function get_basefile($path) { $basename = get_basename($path); preg_match("#(.+)\\?(.+)#", $basename, $regs); return isset($regs[1]) ? $regs[1] : $basename; }
header("location:login.php"); } require_once '../common.php'; require_once ROOT_PATH . '/include/FileUploader.class.php'; $exptimes = array('2592000' => '一个月', '5184000' => '两个月', '7776000' => '三个月', '10368000' => '四个月', '12960000' => '五个月', '15552000' => '六个月', '18144000' => '七个月', '20736000' => '八个月', '23328000' => '九个月', '25920000' => '十个月', '28512000' => '十一个月', '31104000' => '十二个月'); $adlocations = array('A' => '首页顶部A(680*70)', 'B' => '首页头部B(430*220)', 'C' => '首页头部C(210*220)', 'D' => '首页中间D(920*120)', 'E' => '首页中间E(655*120)', 'F' => '首页中间F(257*120)', 'G' => '首页中间G(655*50)', 'H' => '首页底部H(257*120)', 'T' => '首页头部T(文字广告)'); if ($action == 'save' && !empty($title) && !empty($url)) { $name = m_addslashes($title); $url = trim($url); $file = $_FILES['img']; //文件上传时注意enctype="multipart/form-data" //Array ( [name] => a002d.gif [type] => image/gif [tmp_name] => d:/webserver/Server/TEMP\php8E.tmp [error] => 0 [size] => 19675 ) if (!empty($file['name'])) { $uf = new FileUploader($_FILE['img']); $pic = $uf->move(ROOT_PATH . '/adsimg', 2); $img = $pic[0] ? get_basename($pic[0]) : 'NULL'; } elseif ($isimgad) { refer('您选择的是图片广告,但您未选择上传图片!'); } $db->query("INSERT INTO `advertising` VALUES (NULL,'{$adlocation}','{$title}','{$img}','{$isimgad}','{$url}',now(),'{$exptime}')") or error('Unable to add advertising', __FILE__, __LINE__, $db->error()); updateAdsCache(); refer('添加成功'); } if ($action == 'del' && isset($id)) { $query_id = $db->query("SELECT img FROM `advertising` WHERE id = {$id}"); $result = $db->fetch_array($query_id); $img = $result['img']; if ($img) { @unlink(ROOT_PATH . '/adsimg/' . $img); } $db->query("DELETE FROM `advertising` WHERE id = {$id}") or error('Unable to delete advertising', __FILE__, __LINE__, $db->error());
/** * @todo pathinfo() * @param string $path * @return string */ function get_pathinfo($path) { $info = array('dirname' => get_dirname($path), 'basename' => get_basename($path), 'filename' => get_filename($path), 'extension' => get_fileext($path)); return $info; }
header("location:login.php"); } include '../common.php'; require_once ROOT_PATH . '/include/FileUploader.class.php'; require_once ROOT_PATH . 'include/Image.class.php'; if ($action == 'save' && !empty($title) && !empty($url)) { $title = m_addslashes($title); $intro = m_addslashes($content); $url = trim($url); $file = $_FILES['uploadpic']; //文件上传时注意enctype="multipart/form-data" //Array ( [name] => a002d.gif [type] => image/gif [tmp_name] => d:/webserver/Server/TEMP\php8E.tmp [error] => 0 [size] => 19675 ) if (!empty($file['name'])) { $uf = new FileUploader($_FILE['uploadpic']); $pic = $uf->move(ROOT_PATH . '/video-upimg', 2); $uppic = $pic[0] ? get_basename($pic[0]) : 'NULL'; $img = new image(ROOT_PATH . 'video-upimg/' . $uppic); $img->thumbnail(128, 72, ROOT_PATH . 'video-upimg/' . $uppic); } $db->query("INSERT INTO `video` VALUES (NULL,'{$title}','{$intro}','{$uppic}','{$url}',now())") or error('Unable to add advertising', __FILE__, __LINE__, $db->error()); refer('添加视频成功'); } if ($action == 'del' && isset($id)) { $query_id = $db->query("SELECT img FROM `video` WHERE id = {$id}"); $result = $db->fetch_array($query_id); $img = $result['img']; if ($img) { @unlink(ROOT_PATH . '/video-upimg/' . $img); } $db->query("DELETE FROM `video` WHERE id = {$id}") or error('Unable to delete advertising', __FILE__, __LINE__, $db->error()); refer('删除视频成功!');
if (isset($show_result) && $show_result) { $self_url .= preg_match("/\\?/", $self_url) ? "&" : "?"; $self_url .= "show_result=1"; } if ($page && $page != 1) { $self_url .= preg_match("/\\?/", $self_url) ? "&" : "?"; $self_url .= URL_PAGE . "=" . $page; } //} if (isset($HTTP_GET_VARS['url']) || isset($HTTP_POST_VARS['url'])) { $url = isset($HTTP_GET_VARS['url']) ? trim($HTTP_GET_VARS['url']) : trim($HTTP_POST_VARS['url']); } else { $url = ""; } if (empty($url)) { $url = get_basename(getenv("HTTP_REFERER")); } else { if ($url == getenv("HTTP_REFERER")) { $url = "index.php"; } } $url = preg_replace(array("/[?|&]action=[^?|&]*/", "/[?|&]mode=[^?|&]*/", "/[?|&]" . URL_ID . "=[^?|&]*/", "/[?|&]l=[^?|&]*/", "/[&?]+\$/"), array("", "", "", "", ""), $url); if ($url == $self_url || $url == "" || !preg_match("/\\.php/", $url)) { $url = "index.php"; } if (defined("SCRIPT_URL") && SCRIPT_URL != "") { $script_url = SCRIPT_URL; } else { $port = !preg_match("/^(80|443)\$/", getenv("SERVER_PORT"), $port_match) ? ":" . getenv("SERVER_PORT") : ""; $script_url = isset($port_match[1]) && $port_match[1] == 443 ? "https://" : "http://"; $script_url .= !empty($HTTP_SERVER_VARS['HTTP_HOST']) ? $HTTP_SERVER_VARS['HTTP_HOST'] : getenv("SERVER_NAME");
/** * 文件属性 * * @param string $type * @param array $objs * @return array */ public function pathinfo($path, &$info = array()) { $path = $this->get_gpath($path); if (!is_readable($path)) { $this->error = '文件系统错误,目录不存在或者没有访问权限'; return false; } $info = stat($path); $info['dnums'] = $info['fnums'] = $info['size'] = 0; $list = $this->get_golblist($path); foreach ($list as $val) { if ('/' == substr($val, -1, 1)) { $info['dnums'] += 1; } else { $info['fnums'] += 1; $info['size'] += filesize($val); } } $info['name'] = get_basename($path); $info['path'] = $this->get_upath($path); $info['fsize'] = get_deal_size($info['size']); $info['chmod'] = get_deal_chmod($path, 0); $info['fchmod'] = get_deal_chmod($path, 1); $info['fatime'] = date('Y年m月d日 H:i:s', $info['atime']); $info['fctime'] = date('Y年m月d日 H:i:s', $info['ctime']); $info['fmtime'] = date('Y年m月d日 H:i:s', $info['mtime']); $info['fmtime'] = date('Y年m月d日 H:i:s', $info['mtime']); return true; }
<script src="js/jquery/jquery-ui.js"></script> <title><?php echo get_title(); ?> </title> </head> <body> <div class="container"> <div class="row" style="margin:0px;"> <div class="col-xs-6 col-sm-6 col-md-6 col-lg-6" id="logo-bg"> <header> <div class="logo-container"> <div class="logo-img"> <a href="<?php echo get_basename(); ?> "> <img class="img-responsive" src="images/Drawing.png" alt="Smiley face"></a> </div> <div class="logo-title"> <h3 style="color:#FFFAF0;">Βιβλιοθήκες Πανεπιστημίου ΕΚΠΑ</h3> </div> </div> </header> </div> <?php if (isset($_GET['page']) && $_GET['page'] == 'login_signup') { getPage('pages', $_GET['page'], 'main'); } else { ?>
$message = $user->Login($username, $password); if ($message == "User found") { $_SESSION['username'] = $username; $base = get_basename(); header('Location: ' . $base); } } if (isset($_POST['register-form-btn']) && !empty($_POST['register-form-btn'])) { $reg_array = array(); array_push($reg_array, $_POST['username'], $_POST['password'], $_POST['firstName'], $_POST['lastName'], $_POST['phonenumber'], $_POST['email'], $_POST['academicID'], $_POST['academicPass']); $user = new User(); $username = $_POST['username']; $message = $user->RegisterUser($reg_array); if ($message == "registered") { $_SESSION['username'] = $username; $base = get_basename(); header('Location: ' . $base); } else { $message_error = "Η εγγραφη σας δεν ολοκληρώθηκε σωστά"; echo "<script>error_messages('{$message_error}');</script>"; } } ?> <div class="row"> <div class="col-md-6 col-md-offset-3"> <div class="panel panel-login"> <div class="panel-heading"> <div class="row"> <div class="col-xs-6"> <a href="#" class="active" id="login-form-link">Είσοδος</a>
<?php setlocale(LC_ALL, 'zh_CN.UTF8'); function get_basename($filename) { return preg_replace('/^.+[\\\\\\/]/', '', $filename); } function checkIllegal() { $pre = strtolower(@$_SERVER['HTTP_REFERER']); $should = strtolower(@$_SERVER['HTTP_HOST']); $check = strpos($pre, $should); if (!$check) { die("貌似您的提交是非法的哟!"); } } checkIllegal(); $file_path = 'uploads/'; $file_up = $file_path . get_basename($_FILES['upload']['name']); if (move_uploaded_file($_FILES['upload']['tmp_name'], $file_up)) { echo 'success'; mkdice($file_up); } else { echo 'fail'; }