public function img() { $c = D('class'); $a = D('article'); if ($_POST['action'] == 'add') { //判断是否有上传多文件 if ($_POST['imgs']) { $_POST['img'] = ''; foreach ($_POST['imgs'] as $v) { $_POST['img'] .= $v . ','; } } //加载上传类 $file = static::get_file(2097152); //判断是否上传文件 $_POST['simg'] = $file ? $file : ''; $_POST['addtime'] = exec_time(); //dump($_POST);die(); //过滤数据并添加 $a->create(); if ($a->add()) { static::success('添加成功', 3000, 1, 0); } } //获取所有分类信息 $data = $c->order('nos asc')->select(); //格式化无线分类 $data = static::get_class($data); $this->assign('data', $data); //时间输出 $this->assign('time', date('Y-m-d', time())); $this->display(); }
// Include System Module // ******************************************************************************** //name of mod //access $system_modules = array('addnews' => 'user', 'editnews' => 'user', 'main' => 'user', 'options' => 'user', 'images' => 'user', 'editusers' => 'admin', 'editcomments' => 'admin', 'tools' => 'admin', 'ipban' => 'admin', 'about' => 'user', 'categories' => 'admin', 'massactions' => 'user', 'help' => 'user', 'debug' => 'admin', 'wizards' => 'admin', 'update' => 'user', 'rating' => 'user'); list($system_modules, $mod, $stop) = hook('system_modules_expand', array($system_modules, $mod, false)); // Plugin tells us: don't show anything, stop if ($stop == false) { if ($mod == false) { require SERVDIR . "/inc/main.php"; } elseif ($system_modules[$mod]) { if ($mod == 'rating') { require SERVDIR . "/inc/ratings.php"; } elseif ($member_db[UDB_ACL] == ACL_LEVEL_COMMENTER and $mod != 'options' and $mod != 'update') { relocation($config_http_script_dir . "/index.php?mod=options&action=personal"); } elseif ($system_modules[$mod] == "user") { require SERVDIR . "/inc/" . $mod . ".php"; } elseif ($system_modules[$mod] == "admin" and $member_db[UDB_ACL] == ACL_LEVEL_ADMIN) { require SERVDIR . "/inc/" . $mod . ".php"; } elseif ($system_modules[$mod] == "admin" and $member_db[UDB_ACL] != ACL_LEVEL_ADMIN) { msg("error", lang("Access denied"), "Only admin can access this module"); } else { die("Module access must be set to <b>user</b> or <b>admin</b>"); } } else { add_to_log($username, 'Module ' . htmlspecialchars($mod) . ' not valid'); die_stat(false, htmlspecialchars($mod) . " is NOT a valid module"); } } } exec_time();
private function resizeImages($path, $filename) { // generate image paths $medium = escapeshellarg($path . '/medium.jpg'); $small = escapeshellarg($path . '/small.jpg'); $thumbnail = escapeshellarg($path . '/thumbnail.jpg'); $square = escapeshellarg($path . '/square.jpg'); $is = getimagesize($filename); if ($is[2] == 3 || $is[2] == 1) { $tmpfile = $path . '/tmpfile.png'; $tmpfile_x = escapeshellarg($tmpfile); copy($filename, $tmpfile); $cmd = 'convert ' . $tmpfile_x . ' -background white -flatten ' . $tmpfile_x . ' 2>&1'; exec_time($cmd, 8); $cmd = 'convert ' . $tmpfile_x . ' -resize \'500x500>\' +profile \'*\' ' . $medium . ' 2>&1'; } else { $cmd = 'convert ' . escapeshellarg($filename . '[0]') . ' -resize \'500x500>\' +profile \'*\' ' . $medium . ' 2>&1'; } exec_time($cmd, 8); if (file_exists($tmpfile)) { unlink($tmpfile); } $cmd = 'convert ' . $medium . ' -resize \'240x240>\' -unsharp 0x1.0+1.0+0.10 ' . $small . ''; exec_time($cmd, 8); $cmd = 'convert ' . $small . ' -resize \'100x100>\' -unsharp 0x1.0+1.0+0.10 ' . $thumbnail . ''; exec_time($cmd, 8); // get dimension if (!file_exists($path . '/small.jpg')) { return false; } $size = getimagesize($path . '/small.jpg'); $w = $size[0]; $h = $size[1]; if ($h > $w) { $ns = '75x' . $h * 75.0 / $w; } else { $ns = $w * 75.0 / $h . 'x75'; } $cmd = 'convert ' . $small . ' -resize ' . $ns . ' ' . $square . ''; exec_time($cmd, 8); // and crop it! $cmd = 'convert ' . $square . ' -gravity Center -crop 75x75+0+0 +repage ' . $square . ''; exec_time($cmd, 8); return true; }