diff --git a/framework/Framework.php b/framework/Framework.php
index b53bf81..bb7e23e 100644
--- a/framework/Framework.php
+++ b/framework/Framework.php
@@ -129,7 +129,7 @@ class Framework
$path = './runtime/session/';
}
if (!is_dir($path)) {
- mkdir($path, 0775, true);
+ mkdir($path, 0755, true);
}
define('SESSION_PATH', $path);
}
diff --git a/framework/create/create.php b/framework/create/create.php
index 9251eef..99a3add 100644
--- a/framework/create/create.php
+++ b/framework/create/create.php
@@ -56,7 +56,7 @@ class Create
$configPath = $this->projectPath . 'config/';
$configFile = $configPath . 'config.php';
if (!is_dir($configPath)) {
- mkdir($configPath, 0777, true);
+ mkdir($configPath, 0755, true);
}
if (!file_exists($configFile)) {
$content = file_get_contents($this->dir . 'tpl/config/config.tpl');
@@ -78,7 +78,7 @@ class Create
];
for ($i = 0; $i < count($dirArray); $i++) {
if (!is_dir($this->projectPath . $dirArray[$i] . '/')) {
- mkdir($this->projectPath . $dirArray[$i] . '/', 0777, true);
+ mkdir($this->projectPath . $dirArray[$i] . '/', 0755, true);
}
}
$controllerFile = $this->projectPath . 'controller/index.php';
@@ -101,7 +101,7 @@ class Create
if (!file_exists($viewFile)) {
$content = file_get_contents($this->dir . 'tpl/view/index.tpl');
if (!is_dir($this->projectPath . 'view/index/')) {
- mkdir($this->projectPath . 'view/index/', 0777, true);
+ mkdir($this->projectPath . 'view/index/', 0755, true);
}
if (!file_put_contents($this->projectPath . 'view/Index/index.html', $content)) {
exit('error -6');
diff --git a/framework/extend/Page.php b/framework/extend/Page.php
index 472424d..5279fe3 100644
--- a/framework/extend/Page.php
+++ b/framework/extend/Page.php
@@ -1,8 +1,7 @@
listRow = $listRow;
$this->total = $total;
$this->page = (isset($_GET['p']) && $_GET['p']) ? (int)$_GET['p'] : ((isset($_POST['p']) && $_POST['p']) ? (int)$_POST['p'] : 1);
+ $this->totalPage = $this->totalPage();
+ $this->firstRow = $this->firstRow();
}
+ /**
+ * 计算开始记录数
+ * @return float|int
+ */
private function firstRow()
{
return ($this->page - 1) * $this->listRow;
}
+ /**
+ * 计算总页数
+ * @return float
+ */
private function totalPage()
{
return ceil($this->total / $this->listRow);
}
- public function process()
- {
- $this->totalPage = $this->totalPage();
- $this->firstRow = $this->firstRow();
- return $this;
- }
-
+ /**
+ * 获取HTML
+ * @return string
+ */
public function html()
{
- $url = Register::get('Route')->rawUri;
+ $uri = request()->uri(true);
// 链接没有匹配&或?,配置了伪静态也就无所谓了
$html = '
';
for ($i = 1; $i < $this->totalPage + 1; $i++) {
- $html .= '- ' . $i . '
';
+ $html .= '- ' . $i . '
';
}
$html .= '
';
return $html;
diff --git a/framework/extend/Upload.php b/framework/extend/Upload.php
deleted file mode 100644
index f7a4e5f..0000000
--- a/framework/extend/Upload.php
+++ /dev/null
@@ -1,97 +0,0 @@
-error;
- }
-
- public function uploadPicture($fileName = '', $width = 0, $height = 0, $waterFile = '')
- {
- if (!empty($_FILES)) {
- $data = [];
- $picture = Loader::model('Picture');
- foreach ($_FILES as $k => $v) {
- $fileParts = pathinfo($v['name']);
- if (in_array($fileParts['extension'], self::$fileType)) {
- if (!is_dir(self::$dirName))
- mkdir(self::$dirName, 0777, true);
- $targetFile = rtrim(self::$dirName, '/') . '/' . ((!$fileName) ? md5($v['name'] . uniqid()) : $fileName);
- $filePath = $targetFile . '.' . $fileParts['extension'];
- $tempFile = $v['tmp_name'];
- // $type = getimagesize($tempFile)['mime'];
- if (move_uploaded_file($tempFile, $filePath)) {
- if ($width && $height) {
- $filePath = resize_image($filePath, $width, $height);
- }
- $hash = md5_file($filePath);
- $file = $picture->getPictureByHash($hash);
- if ($file) {
- @unlink($filePath);
- $filePath = $file['path'];
- } else {
- if ($waterFile) {
- $water = new Water();
- $water->waterFile($waterFile);
- $filePath = $water->handler($filePath);
- }
- $picture->insert([
- 'path' => ltrim($filePath, '.'),
- 'hash' => $hash
- ]);
- }
- $filePath = ltrim($filePath, '.');
- $data[] = $filePath;
- } else {
- $this->error = '上传失败';
- return false;
- }
- } else {
- $this->error = '文件类型不被允许';
- return false;
- }
- }
- return $data;
- }
- $this->error = '请上传文件';
- return false;
- }
-}
diff --git a/framework/library/Router.php b/framework/library/Router.php
index 4d50df2..86fb91d 100644
--- a/framework/library/Router.php
+++ b/framework/library/Router.php
@@ -17,6 +17,18 @@ class Router
*/
private $driver;
+ /**
+ * 当前URI
+ * @var string
+ */
+ public $uri = '';
+
+ /**
+ * 当前原始URI
+ * @var string
+ */
+ public $rawUri = '';
+
/**
* 模块
* @var string
@@ -87,6 +99,8 @@ class Router
*/
public function handler()
{
+ $this->uri = $this->driver->uri;
+ $this->rawUri = $this->driver->rawUri;
$this->module = $this->driver->module;
$this->class = $this->driver->class;
$this->ctrl = $this->driver->ctrl;
diff --git a/framework/library/cache/driver/File.php b/framework/library/cache/driver/File.php
index 01277cc..946a2a3 100644
--- a/framework/library/cache/driver/File.php
+++ b/framework/library/cache/driver/File.php
@@ -205,7 +205,7 @@ class File implements CacheIfs
private function createCacheDir()
{
if (!is_dir($this->dir)) {
- mkdir($this->dir, 0777, true);
+ mkdir($this->dir, 0755, true);
}
}
diff --git a/framework/library/http/Request.php b/framework/library/http/Request.php
index 96ecbfe..6671916 100644
--- a/framework/library/http/Request.php
+++ b/framework/library/http/Request.php
@@ -177,6 +177,19 @@ class Request
return get_client_ip($type, $client);
}
+ /**
+ * 当前请求的URI
+ * @param bool $raw
+ * @return mixed
+ */
+ public function uri($raw = false)
+ {
+ if ($raw) {
+ return $this->router->rawUri;
+ }
+ return $this->router->uri;
+ }
+
/**
* 模块名称
* @return mixed
@@ -190,7 +203,7 @@ class Request
* 控制器完整类名
* @return mixed
*/
- public function classname()
+ public function className()
{
return $this->router->class;
}
@@ -239,7 +252,7 @@ class Request
/**
* GET数据
- * @param null $name
+ * @param string $name
* @param array $except
* @param string $filter
* @return null
@@ -251,7 +264,7 @@ class Request
/**
* POST数据
- * @param null $name
+ * @param string $name
* @param array $except
* @param string $filter
* @return null
diff --git a/framework/library/template/driver/Top.php b/framework/library/template/driver/Top.php
index bae44eb..68a16e0 100644
--- a/framework/library/template/driver/Top.php
+++ b/framework/library/template/driver/Top.php
@@ -49,7 +49,7 @@ class Top implements TemplateIfs
$compileFileName = $this->config['compileDir'] . md5($filename) . '.php';
if (!file_exists($compileFileName) || DEBUG === true) {
if (!is_dir($this->config['compileDir'])) {
- mkdir($this->config['compileDir'], 0777, true);
+ mkdir($this->config['compileDir'], 0755, true);
}
if (isset($this->config['tagLib']) && !empty($this->config['tagLib'])) {
foreach ($this->config['tagLib'] as $lib) {