📄 index.php
字号:
<?php
//检查是否安装及安装后是否将setup.php改名
if(file_exists("config.php")) {
if(file_exists("setup.php")){
echo "请删除 setup.php";
exit;
}
}
else {
header("location:setup.php");
exit;
}
//检查结束
require("config.php");
/* Class 分类设置 */
Class neatpic {
var $configTilte;
var $configWantedPass;
var $configAdminPass;
var $configOpenGzip;
var $icp;
var $weburl;
var $statcode;
var $configShowPicSize;
var $configExt = array();
var $strLenMax;
var $configEachPageMax;
var $configPageWidth;
var $configDivHeight;
var $configDivWidth;
var $configPageMax;
var $ThisPicLogined;
var $dirOptionList;
var $rightdirkey;
var $timer;
var $usedTime;
var $pathLevelNum;
var $nowDirNmae;
var $dirNum;
var $picNum;
var $pageTotal;
var $start;
var $offSet;
var $pageStart;
var $pageMiddle;
var $pageEnd;
var $temp;
var $picID;
var $picRealSizeWidth;
var $picRealSizeHeight;
var $picArray = array();
var $picFileArray = array();
var $dirArray = array();
var $dirNameArray = array();
var $pathArray = array();
var $pathError = false;
var $page;
var $path;
var $style;
var $c;
/* Constructor 构造函数 */
function neatpic($configWantedPass, $configAdminPass, $configDirPWFile, $configOpenGzip, $configShowPicSize, $configExt, $strLenMax, $configEachPageMax, $configPageWidth, $configDivHeight, $configDivWidth, $configPageMax, $configTilte, $ThisPicLogined, $icp, $weburl, $statcode) {
$this->configWantedPass = & $configWantedPass;
$this->configAdminPass = & $configAdminPass;
$this->configDirPWFile = & $configDirPWFile;
$this->configOpenGzip = & $configOpenGzip;
$this->configShowPicSize = & $configShowPicSize;
$this->configExt = & $configExt;
$this->strLenMax = & $strLenMax;
$this->configEachPageMax = & $configEachPageMax;
$this->configPageWidth = & $configPageWidth;
$this->configDivHeight = & $configDivHeight ;
$this->configDivWidth = & $configDivWidth;
$this->configPageMax = & $configPageMax;
$this->configTilte = & $configTilte;
$this->icp = & $icp;
$this->weburl = & $weburl;
$this->statcode = & $statcode;
$this->ThisPicLogined = & $ThisPicLogined;
}
/* gzip 打开压缩 */
function gzip() {
if ($this->configOpenGzip == true)
ob_start("ob_gzhandler");
}
/* Get the querystring 查询字串 */
function getVars() {
$this->page = rawurldecode($_GET['page']);
$this->path = rawurldecode($_GET['path']);
$this->style = $_GET['style'];
if (!$this->style) $this->style = "small";
if (!$this->path) $this->path = ".";
}
/* Check error 错误 */
function checkError() {
if (preg_match("/\.\./", $this->path)) $pathError = true;
if (!is_dir($this->path)) $pathError = true;
if ($pathError == true) {
header("location:".$_SERVER['PHP_SELF']);
exit;
}
}
/* Path array initialize 路径初始化 */
function pathArrayInitialize() {
if (!$this->path) $this->path = ".";
$this->pathArray = explode("/", $this->path);
$this->pathLevelNum = count($this->pathArray);
$this->nowDirName = $this->pathArray[$this->pathLevelNum - 1];
if ($this->nowDirName == ".") $this->nowDirName = "相册首页";
}
/* Timer 时间 */
function timer() {
$time = explode( " ", microtime());
$usec = (double)$time[0];
$sec = (double)$time[1];
$this->timer = $usec + $sec;
}
/* 显示使用时间 */
function usedTime() {
$startTime = $this->timer;
$this->timer();
$endTime = $this->timer;
$usedTime = $endTime - $startTime;
$this->usedTime = sprintf("%0.4f", $usedTime);
}
/* Make over direct 结束指令 */
function makeOverdirect() {
$overPath = ".";
for($i = 1; $i < $this->pathLevelNum - 1; $i++) {
$overPath = $overPath."/".$this->pathArray[$i];
}
$this->dirArray[] = $overPath;
$this->dirNameArray[] = "上一页";
for($i = 1; $i < $this->pathLevelNum; $i++) {
$this->encodePath .= rawurlencode($this->pathArray[$i])."/";
}
}
/* GetFileExt */
function getFileExt($fileName) {
$pos = strrpos($fileName, '.');
return strtolower(substr($fileName, $pos+1, (strlen($fileName)-$pos-1)));
}
/* 得到目录列表 */
function makeDirList() {
$dir = dir($this->path);
while($file = $dir->read()) {
if ($file <> "." and $file <> ".." and $file != "highslide") {
$fileName = $file;
$file = $this->path."/".$file;
if (is_dir($file)) {
$this->dirArray[] = $file;
$this->dirNameArray[] = $fileName;
}
if (in_array($this->getFileExt($file), $this->configExt)) {
$this->picEncodeArray[] = "./".$this->encodePath.rawurlencode($fileName);
$this->picArray[] = $file;
$this->picFileArray[] = $fileName;
}
}
}
}
/* 得到每组图片数 */
function getEachArrayNum() {
$this->dirNum = count($this->dirArray);
$this->picNum = count($this->picArray);
}
/* 分页设置 */
function makePageBar() {
$this->pageTotal = ceil($this->picNum / $this->configEachPageMax);
if (!$this->page or $this->page < 0) $this->page = 1;
if ($this->page > $this->pageTotal) $this->page = $this->pageTotal;
$this->offSet = $this->configEachPageMax * $this->page;
$this->start = $this->offSet - $this->configEachPageMax;
if ($this->start < 0) $this->start = 0;
if ($this->offSet > $this->picNum) $this->offSet = $this->picNum;
$this->pageStart = $this->page - $this->configPageMax;
if ($this->pageStart <= 0) $this->pageStart = 1;
$this->pageMiddle = $this->page + 1;
$this->pageEnd = $this->pageMiddle + $this->configPageMax;
if ($this->page <= $this->configPageMax) $this->pageEnd = $this->configPageMax * 2 + 1;
if ($this->pageEnd > $this->pageTotal) $this->pageEnd = $this->pageTotal + 1;
}
/* 显示分页 */
function showPageBar() {
print("<div style=\"height:48px;line-height:48px;\">\n");
print(" <span style=\"font-family:Webdings;\">\n");
print(" <a href=\"".$_SERVER['PHP_SELF']."?path=".rawurlencode($this->path)."&style=".$this->style."&page=1\" title=\"首页\">7</a>\n");
print(" <a href=\"".$_SERVER['PHP_SELF']."?path=".rawurlencode($this->path)."&style=".$this->style."&page=".($this->page - 1)."\" title=\"上一页\">3</a>\n");
print(" </span>\n");
for ($i = $this->pageStart; $i < $this->page; $i++)
print(" <a href=\"".$_SERVER['PHP_SELF']."?path=".rawurlencode($this->path)."&style=".$this->style."&page=".$i."\" title=\"第 ".$i." 页\">[".$i."]</a>\n");
printf(" [<font color=\"red\"><b>%s</b></font>]\n", $this->page);
for ($i = $this->pageMiddle; $i < $this->pageEnd; $i++)
print(" <a href=\"".$_SERVER['PHP_SELF']."?path=".rawurlencode($this->path)."&style=".$this->style."&page=".$i."\" title=\"第 ".$i." 页\">[".$i."]</a>\n");
print(" <span style=\"font-family:Webdings;\">\n");
print(" <a href=\"".$_SERVER['PHP_SELF']."?path=".rawurlencode($this->path)."&style=".$this->style."&page=".($this->page + 1)."\" title=\"下一页\">4</a>\n");
print(" <a href=\"".$_SERVER['PHP_SELF']."?path=".rawurlencode($this->path)."&style=".$this->style."&page=".$this->pageTotal."\" title=\"尾页\">8</a>\n");
print(" </span>\n");
print(" 页次 <b><font color=\"red\">".$this->page."</font>/".$this->pageTotal."</b>\n");
print(" <a href=\"#top\">返回顶部</a>\n");
print("</div>\n");
}
/* 设置图片ID */
function setPicID($id) {
$this->picID = $id;
}
/* 得到图片尺寸 */
function getPicDim(){
$picSize = GetImageSize($this->picArray[$this->picID]);
preg_match("!width=\"(.*)\" height=\"(.*)\"!", $picSize['3'], $tempSize);
$this->picRealSizeWidth = $tempSize['1'];
$this->picRealSizeHeight = $tempSize['2'];
$tWidth = $this->picRealSizeWidth / $this->configDivWidth;
$tHeight = $this->picRealSizeHeight / $this->configDivHeight;
if ($this->picRealSizeWidth > $this->configDivWidth OR $this->picRealSizeHeight > $this->configDivHeight) {
if ($tWidth > $tHeight) {
$this->temp['Width'] = $this->configDivWidth-2;
$this->temp['Height'] = number_format($this->picRealSizeHeight / $tWidth);
}
elseif ($tWidth < $tHeight) {
$this->temp['Height'] = $this->configDivHeight-2;
$this->temp['Width'] = number_format($this->picRealSizeWidth / $tHeight);
}
else {
$this->temp['Width'] = $this->configDivWidth-2;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -