public function index() { global $Hardy_config; // Retrieve user name if (isset($_COOKIE[$Hardy_config['project_name']])) { $this->model = Hardy_get_class('user', 'model'); $this->model->connect(); $user_info = $this->model->get_user($_COOKIE[$Hardy_config['project_name']]); $this->data['user'] = $user_info['username']; $this->model->close(); } // File uploading $file_pic = ''; $file_audio = ''; // New post $this->model = Hardy_get_class('post', 'model'); $this->model->connect(); if (isset($_POST['content'])) { $this->model->new_post($_POST['subject'], $file_pic, $file_audio, $_POST['content'], isset($this->data['user']) ? $this->data['user'] : '******', isset($this->data['user']) ? $_COOKIE[$Hardy_config['project_name']] : 0); } // Retrieve posts $this->data['data'] = $this->model->get_posts(); $this->data['rootUrl'] = $Hardy_config['base_url']; $this->model->close(); // Rendering require $Hardy_config['view_dir'] . 'main_view.php'; }
public function index() { global $Hardy_config; // Retrieve comments on that post $post_id = $_GET['pid']; $this->model = Hardy_get_class('post', 'model'); $this->data['post'] = $this->model->get_post_by_id($post_id); $this->data['data'] = $this->model->get_comments($post_id); $this->data['post_id'] = $post_id; $this->data['rootUrl'] = $Hardy_config['base_url']; // Rendering require $Hardy_config['view_dir'] . 'comment_view.php'; }
function __construct() { global $Hardy_config; $this->data = array(); $this->data['user_info'] = null; // Check session if (isset($_COOKIE[$Hardy_config['project_name']])) { $user_model = Hardy_get_class('user', 'model'); $this->data['user_info'] = $user_model->get_user($_COOKIE[$Hardy_config['project_name']]); if (null == $this->data['user_info'] || $_COOKIE[$Hardy_config['project_name'] . '_session'] != $this->data['user_info']['sid']) { // Session ID mismatch Hardy_message('警告: 会话ID不匹配, 有可能账号在其他地方登录, 请重新登录', $Hardy_config['base_url']); setcookie($Hardy_config['project_name'], null); setcookie($Hardy_config['project_name'] . '_session', null); ob_end_flush(); die; } // For login view $this->data['user'] = $this->data['user_info']['username']; } }
public function register() { global $Hardy_config; if (isset($_POST['register_name'])) { $this->model = Hardy_get_class('user', 'model'); if ($this->model->check_existence($_POST['register_name'])) { $this->data['message'] = '该用户名已存在!'; $this->data['retUrl'] = 'http://' . $_SERVER['HTTP_HOST'] . $_POST['retUrl']; } elseif ($_POST['register_password'] !== $_POST['register_password_again']) { $this->data['message'] = '两次输入的密码不一致!'; $this->data['retUrl'] = 'http://' . $_SERVER['HTTP_HOST'] . $_POST['retUrl']; } else { $this->model->register($_POST['register_name'], $_POST['register_password'], $_POST['register_password_again'], 1, '', '', '', ''); $this->data['message'] = '感谢你的注册,你现在可以使用注册的用户名登录BBS!'; $this->data['retUrl'] = 'http://' . $_SERVER['HTTP_HOST'] . $_POST['retUrl']; } require $Hardy_config['view_dir'] . 'message_view.php'; return; } $this->data['rootUrl'] = $Hardy_config['base_url']; require $Hardy_config['view_dir'] . 'register_view.php'; }
public function exec() { global $Hardy_config; if (@$_COOKIE['HardyBBS'] === $Hardy_config['admin']) { $this->model = Hardy_get_class('usermgr', 'model'); $this->model->connect(); if (isset($_GET['delete'])) { $this->model->delete($_GET['delete']); } $this->data['users'] = $this->model->find_all(); $this->model->close(); $this->data['rootUrl'] = $Hardy_config['base_url']; $this->data['admin'] = $Hardy_config['admin']; $this->view = new Hardy_view('admin'); $this->view->render($this->data); } else { $this->data['message'] = '你无权进行此操作!'; $this->data['retUrl'] = $Hardy_config['base_url']; $this->view = new Hardy_view('message'); $this->view->render($this->data); } }
public function postComment() { global $Hardy_config; $this->data['rootUrl'] = $Hardy_config['base_url']; $this->model = Hardy_get_class('post', 'model'); $this->model->connect(); $pid = $_GET['pid']; $comment_id = ''; if (!isset($_POST['subject'])) { if (isset($_GET['parent_comment_id'])) { $comment_id = $_GET['parent_comment_id']; } require $Hardy_config['view_dir'] . 'comment.php'; } else { if (!isset($_GET['parent_comment_id'])) { $this->model->postComment($pid, $_POST['subject'], $_POST['content'], "Anonymous"); echo '<script type="text/javascript">', 'parent.$.fancybox.close();', '</script>'; } else { $comment_id = $_GET['parent_comment_id']; $this->model->postReply($pid, $_POST['subject'], $_POST['content'], "Anonymous", $comment_id); echo '<script type="text/javascript">', 'parent.$.fancybox.close();', '</script>'; } } }
public function register() { global $Hardy_config; if (isset($_POST['register_name'])) { $this->model = Hardy_get_class('user', 'model'); $this->model->connect(); if ($this->model->check_existence($_POST['register_name'])) { $this->data['message'] = '该用户名已存在!'; $this->data['retUrl'] = $Hardy_config['base_url'] . '?r=user/register'; } elseif ($_POST['register_password'] !== $_POST['register_password_again']) { $this->data['message'] = '两次输入的密码不一致!'; $this->data['retUrl'] = $Hardy_config['base_url'] . '?r=user/register'; } else { $this->model->register($_POST['register_name'], $_POST['register_password'], $_POST['register_password_again'], 1, '', '', '', ''); $this->data['message'] = '感谢你的注册,你现在可以使用注册的用户名登录Eigentunes了!'; $this->data['retUrl'] = $Hardy_config['base_url']; } $this->model->close(); require $Hardy_config['view_dir'] . 'box_message_view.php'; return; } $this->data['rootUrl'] = $Hardy_config['base_url']; require $Hardy_config['view_dir'] . 'register_view.php'; }
public function post() { global $Hardy_config; if (empty($_POST['content']) && !isset($_FILES['file-audio']) && !isset($_FILES['file-pic'])) { echo '请输入内容'; return; } if (empty($_POST['subject']) && !isset($_GET['pid']) && !isset($_GET['cid'])) { echo '请输入标题'; return; } $arr = array('msg' => '提交成功'); $file_pic = ''; $file_audio = ''; // Retrieve user info if (isset($_COOKIE[$Hardy_config['project_name']])) { // File uploading $audioname = ''; $picname = ''; isset($_FILES['file-audio']) && ($audioname = $_FILES['file-audio']['name']); isset($_FILES['file-pic']) && ($picname = $_FILES['file-pic']['name']); if ($audioname != "") { $type = strstr($audioname, '.'); if ($type != ".wav" && $type != ".ogg" && $type != ".mp3") { $arr['msg'] = '不支持的音频格式(只支持.wav/.ogg/.mp3)'; echo $arr['msg']; //echo json_encode ($arr); return; } $file = substr($audioname, 0, strlen($audioname) - strlen($type)) . '_' . date("YmdHis") . '_' . mt_rand(0, 9999) . $type; $file_audio = "public/upload/" . $file; move_uploaded_file($_FILES['file-audio']['tmp_name'], $file_audio); } if ($picname != "") { $type = strstr($picname, '.'); if ($type != ".jpg" && $type != ".jpeg" && $type != ".png" && $type != ".gif") { $arr['msg'] = '不支持的图片格式(只支持.jpg/.png/.gif)'; echo $arr['msg']; //echo json_encode ($arr); return; } $file = substr($picname, 0, strlen($picname) - strlen($type)) . '_' . date("YmdHis") . '_' . mt_rand(0, 9999) . $type; $file_pic = "public/upload/" . $file; move_uploaded_file($_FILES['file-pic']['tmp_name'], $file_pic); } } // New post $this->model = Hardy_get_class('post', 'model'); if (!isset($_GET['pid']) && !isset($_GET['cid'])) { if (isset($_POST['content'])) { $this->model->new_post($_POST['subject'], $file_pic, $file_audio, $_POST['content'], null !== $this->data['user_info'] ? $this->data['user_info']['username'] : '******', null !== $this->data['user_info'] ? $this->data['user_info']['id'] : 0); } } else { $post_id = isset($_GET['pid']) ? $_GET['pid'] : 0; $comment_id = isset($_GET['cid']) ? $_GET['cid'] : 0; if (isset($_POST['content'])) { $this->model->new_comment($post_id, $comment_id, $_POST['subject'], $file_pic, $file_audio, $_POST['content'], null !== $this->data['user_info'] ? $this->data['user_info']['username'] : '******', null !== $this->data['user_info'] ? $this->data['user_info']['id'] : 0); } } // Return json result echo $arr['msg']; //echo json_encode ($arr); }
ob_start(); error_reporting(E_ALL); require './config.php'; require './Hardy/functions.php'; $Hardy_database_handler = $Hardy_config['database'] . '_handler'; require './Hardy/database/' . $Hardy_database_handler . '.php'; require './Hardy/base_controller.php'; // Routing if (isset($_GET['r']) && 0 === preg_match('/[^a-zA-Z0-9\\/]/', $_GET['r'])) { $r = explode('/', $_GET['r']); if (1 == count($r)) { $c = $r[0]; $a = 'index'; } else { if (2 == count($r)) { $c = $r[0]; $a = $r[1]; } else { $c = 'index'; $a = 'index'; } } } else { $c = 'index'; $a = 'index'; } // Execution & Rendering $controller = Hardy_get_class($c, 'controller'); $controller->{$a}(); ob_end_flush();