public function loginAction() { $isajax = $this->getRequest()->isXmlHttpRequest(); if (!$isajax) { return false; } //先redis判断IP是否被禁 $ip = $_SERVER['REMOTE_ADDR']; $allow = $this->catmodel->allowiplogin($ip); if (!$allow) { $data = array('status' => 2); } else { $password = $this->getRequest()->getpost("password"); $logininfo = $this->catmodel->siteinfo()['login']; $shadow = md5(md5($password) . $logininfo['name']); if ($shadow == $logininfo['value']) { $data = array('status' => 1); $this->session->admin = true; } else { $this->catmodel->faildlogin($ip); $data = array('status' => 0); } } echojson($data); return false; }
public function ajax_deleteAction() { $id = $this->getRequest()->getpost("id"); $result = $this->linkmodel->deletelink($id); if ($result) { $data = array('status' => 1, 'info' => array('content' => '删除成功')); } else { $data = array('status' => 0, 'info' => array('content' => '删除失败')); } echojson($data); return false; }
public function ajax_deletejoinAction() { $tagid = $this->getRequest()->getpost("tagid"); $blogid = $this->getRequest()->getpost("blogid"); $result = $this->tagmodel->deletejoin($tagid, $blogid); if ($result) { $data = array('status' => 1, 'info' => array('content' => '删除成功')); } else { $data = array('status' => 0, 'info' => array('content' => '删除失败')); } echojson($data); return false; }
public function ajax_updateAction() { $value = $this->getRequest()->getpost("value"); $id = $this->getRequest()->getpost("id"); if ($value && $id > 0) { $result = $this->catmodel->updateinfo($id, $value); if ($result) { $data = array('status' => 1, 'info' => array('content' => '修改成功')); } else { $data = array('status' => 0, 'info' => array('content' => '修改失败')); } } else { $data = array('status' => 0, 'info' => array('content' => '修改失败,参数错误')); } echojson($data); return false; }
public function ajax_addcommentAction() { $isajax = $this->getRequest()->isXmlHttpRequest(); if (!$isajax) { return false; } $ip = $_SERVER['REMOTE_ADDR']; $allow = $this->commentmodel->allowcomment($ip); if (!$allow) { $data = array('status' => 0, 'info' => array('content' => '说话太快,说慢点')); } else { $blogid = (int) $this->getRequest()->getpost("blogid"); $content = $this->getRequest()->getpost("content"); $nickname = $this->getRequest()->getpost("nickname"); if ($blogid >= 0 && $content && $nickname) { $content = htmlspecialchars($content); $nickname = htmlspecialchars($nickname); $result = $this->commentmodel->addcomment($content, $blogid, 0, $nickname); if ($result) { $data = array('status' => 1, 'info' => array('content' => '成功')); } else { $data = array('status' => 0, 'info' => array('content' => '失败')); } } else { $data = array('status' => 0, 'info' => array('content' => '请填写完整信息')); } } echojson($data); return false; }
public function linkaddAction() { $isajax = $this->getRequest()->isXmlHttpRequest(); if (!$isajax) { return false; } $title = $this->getRequest()->getpost("title"); $url = htmlspecialchars($this->getRequest()->getpost("url")); if (strpos($url, "http") === false) { $url = "http://" . $url; } $result = $this->linkmodel->linkadd($title, $url); if ($result) { $data = array('status' => 1, 'info' => array('content' => '申请成功,请等待站长添加')); } else { $data = array('status' => 0, 'info' => array('content' => '申请失败')); } echojson($data); return false; }
function cpjson($obj) { if (ob_get_contents()) { ob_end_clean(); } if (function_exists("json_encode")) { echojson(array2json($obj)); } else { include_once dirname(__FILE__) . "/../pacotes/cpaint/cpaint2.inc.php"; $cp = new cpaint(); $cp->set_data($obj); $cp->return_data(); exit; } }
public function ajax_update_statusACTION() { $blogid = $this->getRequest()->getpost("blogid"); $status = $this->getRequest()->getpost("status"); if ($blogid > 0) { $result = $this->blogmodel->update_status($blogid, $status); } if ($result) { $data = array('status' => 1, 'info' => array('color' => $this->{status}[$status][1], 'content' => '修改成功')); } else { $data = array('status' => 0, 'info' => array('content' => '修改失败')); } echojson($data); return false; }
public function ajax_addtypeAction() { $topid = $this->getRequest()->getpost("topid"); $name = $this->getRequest()->getpost("name"); $result = $this->blogtypemodel->addtype($topid, $name); if ($result > 0) { $data = array('status' => 1, 'info' => array('content' => '添加成功')); } else { if ($result == 0) { $data = array('status' => 0, 'info' => array('content' => '添加失败')); } else { $data = array('status' => 0, 'info' => array('content' => '类型已存在')); } } echojson($data); return false; }
function exe_op($op) { global $real_path, $pathto, $filepath, $fore_md5, $force; switch ($op) { case 'mv': $target_file = $pathto . urldecode($_POST['target']); if (rename($real_path, $target_file)) { echojson($filepath . ' file mv success.'); } else { echojson($filepath . ' file mv failed.', 22001); } break; case 'mkdir': if (is_dir($real_path)) { if (mkdirs($real_path)) { echojson($filepath . ' mkdir success.'); } else { echojson($filepath . ' mkdir failed.', 22001); } } else { echojson($filepath . ' is not a dir.', 22001); } break; case 'delete': case 'del': if (file_exists($real_path) && (is_dir($real_path) || is_file($real_path))) { if (delete_file($real_path)) { echojson($filepath . ' file remove success.'); } else { echojson($filepath . ' file remove failed.', 22001); } } else { echojson($filepath . ' remove file is not exist.', 22001); } break; default: //file change if (is_dir($real_path) || $_FILES["file"]["error"] > 0) { //header("Status: 500 Internal Server Error"); echojson($filepath . ' there is some thing wrong when upload or is dir.', 22001); } else { if (file_exists($real_path)) { $cur_md5 = md5(file_get_contents($real_path)); //echo 'file_get_contents('.$real_path.'):'; //echo file_get_contents($real_path); if ($cur_md5 == $fore_md5 || $force == 'true') { @unlink($real_path); } else { //echojson($filepath.', server md5='.$cur_md5.', local md5='.$fore_md5.', file md5 not match, sync failed.', 22001); echojson($filepath . ', file md5 not match, please check your version and try svn up.', 22001); exit; } } else { $dir = dirname($real_path); if (!file_exists($dir)) { mkdirs($dir); } } //var_dump( $_FILES); if (move_uploaded_file($_FILES["file"]["tmp_name"], $real_path)) { echojson($filepath . ' file change success.'); } else { echojson($filepath . ' file change failed.', 22001); } } //end default => if is dir } //end switch }