/** * Creates a key value array of the parameters that need to be passed by url. * @return array A key value map. */ protected function getArgumentMap() { $argMap = parent::getArgumentMap(); //add method id... $argMap["methodID"] = $this->parameter->GetRecommendationMethodToUse(); return $argMap; }
/** * Creates a key value array of the parameters that need to be passed by url. * @return array A key value map. */ protected function getArgumentMap() { $argMap = parent::getArgumentMap(); //add click parameter $argMap["clickparameters"] = $this->parameter->getNotificationId(); return $argMap; }
/** * Creates a key value array of the parameters that need to be passed by url. * @return array A key value map. */ protected function getArgumentMap() { $argMap = parent::getArgumentMap(); //add user id... $argMap["userID"] = $this->parameter->GetUserId(); return $argMap; }
/** * Creates a key value array of the parameters that need to be passed by url. * @return array A key value map. */ protected function getArgumentMap() { $argMap = parent::getArgumentMap(); //add category and profile id $argMap["category"] = $this->parameter->getCategory(); $argMap["classID"] = $this->parameter->getProfileMapId(); return $argMap; }
/** * {@inheritdoc} */ protected function getArgumentMap() { $argMap = parent::getArgumentMap(); //add user id... $argMap["queryString"] = $this->parameter->getSearchString(); $argMap["searchRefiningOptions"] = $this->parameter->getSearchRefiningOption(); return $argMap; }
/** * Creates a key value array of the parameters that need to be passed by url. * @return array A key value map. */ protected function getArgumentMap() { $argMap = parent::getArgumentMap(); //autocomplete parameters $argMap["languageCode"] = $this->parameter->getLanguageCode(); $argMap["classID"] = $this->parameter->getProfileMapId(); $argMap["queryString"] = $this->parameter->getInputQuery(); return $argMap; }
public function actionManage($module_id = null) { $model = new Param('search'); $model->unsetAttributes(); if (isset($_GET['Param'])) { $model->attributes = $_GET['Param']; } $params = array('model' => $model); if ($module_id) { $params['module_id'] = $module_id; $params['module_name'] = AppManager::getModuleName($module_id); } $this->render('manage', $params); }
/** * Updating profile, all info details can be retain * Sessions are initial value in view (previous details) */ public function update() { if (!is_logged_in()) { redirect(url('login/index')); } $user_id = User::getId($_SESSION['username']); $user = User::get($user_id); $_SESSION['fname'] = $user->fname; $_SESSION['lname'] = $user->lname; $_SESSION['email'] = $user->email; $status = ""; if ($user_id) { $user->username = Param::get('username'); $user->password = Param::get('password'); $user->fname = Param::get('fname'); $user->lname = Param::get('lname'); $user->email = Param::get('email'); if ($user->username) { try { $user->update($user_id, $_SESSION['username'], $_SESSION['email']); $status = notify("Edit Success"); $_SESSION['username'] = $user->username; } catch (AppException $e) { $status = notify($e->getMessage(), 'error'); } } } $this->set(get_defined_vars()); }
public function create() { $thread = new Thread(); $comment = new Comment(); $page = Param::get('page_next', 'create'); switch ($page) { case 'create': break; case 'create_end': $thread->title = Param::get('title'); $comment->username = Param::get('username'); $comment->body = Param::get('body'); try { $thread->create($comment); } catch (ValidationException $e) { $page = 'create'; } break; default: throw new NotFoundException("{$page} is not found"); break; } $this->set(get_defined_vars()); $this->render($page); }
/** * To register new user * Subject for validations (e.g username length) **/ public function registration() { $username = Param::get('username'); $password = Param::get('pword'); $password_match = Param::get('pword_match'); $fname = Param::get('fname'); $lname = Param::get('lname'); $email = Param::get('email'); $registration = new Registration(); $login_info = array('username' => $username, 'user_password' => $password, 'fname' => $fname, 'lname' => $lname, 'email' => $email); //To check if all keys are null if (!array_filter($login_info)) { $status = ""; } else { try { foreach ($login_info as $key => $value) { if (!is_complete($value)) { throw new ValidationException("Please fill up all fields"); } } if (!is_password_match($password, $password_match)) { throw new ValidationException("Password did not match"); } $info = $registration->userRegistration($login_info); $status = notice("Registration Complete"); } catch (ExistingUserException $e) { $status = notice($e->getMessage(), "error"); } catch (ValidationException $e) { $status = notice($e->getMessage(), "error"); } } $this->set(get_defined_vars()); }
function print_pagination($pagination, $pages) { $page = Param::get('page', 1); echo '<ul class="pagination">'; // previous button if ($pagination->current > 1) { $url = url('', array('page' => $pagination->prev)); echo "<li><a href='{$url}'>«</a></li>"; } else { echo "<li class='disabled'><a>«</a></li>"; } // page numbers for ($i = 1; $i <= $pages; $i++) { if ($i == $page) { echo "<li class='disabled'><a>{$i}</a></li>"; } else { $url = url('', array('page' => $i)); echo "<li><a href='{$url}'>{$i}</a></li>"; } } // next button if ($pagination->is_last_page) { echo "<li class='disabled'><a>»</a></li>"; } else { $url = url('', array('page' => $pagination->next)); echo "<li><a href='{$url}'>»</a></li>"; } echo '</ul>'; }
/** * Delete Comment using Username */ public function delete() { $comment_id = Param::get('comment_id'); $comment = Comment::get(Param::get('comment_id')); $page = Param::get('page_next', 'delete'); $status = ""; switch ($page) { case 'delete': break; case 'delete_end': try { if (Param::get('reply') == 'no') { redirect(url('thread/index')); } else { $comment->delete($_SESSION['username']); } } catch (ValidationException $e) { $status = notify($e->getMessage(), "error"); $page = 'delete'; } break; default: throw new PageNotFoundException("{$page} is not found"); break; } $this->set(get_defined_vars()); $this->render($page); }
/** * To view all comments on a particular thread. **/ public function view() { $thread = Thread::get(Param::get('thread_id')); $comments = $thread->getComments(); $user_name = $_SESSION['username']; $this->set(get_defined_vars()); }
public function index() { $type = Param::get('type', self::TYPE_THREAD); $query = trim_collapse(Param::get('query')); $page = Param::get('page', 1); $pagination = new SimplePagination($page, self::RESULTS_PERPAGE); if (!$query) { redirect(APP_URL); } $results = new stdClass(); switch ($type) { case self::TYPE_THREAD: $results = Thread::search($query, $pagination->start_index - 1, $pagination->count + 1); // Get other info for each thread foreach ($results->result as $thread) { $thread->creator = User::getByID($thread->user_id); $thread->category = Category::getName($thread->category_id); $thread->replies_count = Comment::countAll($thread->id); } break; case self::TYPE_COMMENT: $results = Comment::search($query, $pagination->start_index - 1, $pagination->count + 1); break; case self::TYPE_USER: $results = User::search($query, $pagination->start_index - 1, $pagination->count + 1); break; default: throw new PageNotFoundException(); break; } $pagination->checkLastPage($results->result); $pages = ceil($results->total_result / self::RESULTS_PERPAGE); $title = "Search: '{$query}'"; $this->set(get_defined_vars()); }
public function delete() { redirect_guest_user(LOGIN_URL); $id = Param::get('id'); $comment = Comment::get($id); $auth_user = User::getAuthenticated(); $page = Param::get('page_next', 'delete'); if (!$comment->isAuthor($auth_user)) { throw new PermissionException(); } if ($comment->isThreadBody()) { redirect(DELETE_THREAD_URL, array('id' => $comment->thread_id)); } switch ($page) { case 'delete': break; case 'delete_end': $comment->delete(); redirect(VIEW_THREAD_URL, array('id' => $comment->thread_id)); break; default: throw new PageNotFoundException(); break; } $title = 'Delete comment'; $this->set(get_defined_vars()); }
/** * This function executes the eMobilePlatform operation. Simply supply * the group and method name. Most actions will require an additional * parameter object. See the documentation for more information. * * @param string $groupName The family of functions to access. * @param string $methodName The specific operation to preform. * @param Param $params An optional param object. * @return Result A result object. * @throws \InvalidArgumentException */ public function executeAction($groupName, $methodName, Param $params = null) { if (!is_string($groupName) || !is_string($methodName) || !$params instanceof Param && $params !== null) { throw new \InvalidArgumentException('Invalid Arguments Supplied'); } $xml = $this->generateXML($groupName, $methodName, $params->getArray()); if ($xml === null) { return new Result(Result::ERROR_LEVEL_FATAL, 'XML content could not be generated!'); } $responseXML = $this->sendXML($xml); if ($responseXML === null) { return new Result(Result::ERROR_LEVEL_FATAL, 'A cURL error occured'); } $result = $this->parseResult($responseXML); return $result; }
public function Group($name = null, $id = null) { parent::Param($name, $id); if ($name == null && $id == null) { $this->map = new HashMap(); $this->fontsPerGroup(); } }
public function __construct(callable $subject, callable $decoration) { $this->subject = $subject; $this->decoration = $decoration; $this->subjectParams = $this->getFunctionParams($subject); $this->decorationParams = $this->getFunctionParams($decoration); $this->params = Param::createFromArrays($this->subjectParams, $this->decorationParams); }
public function next() { $q_id = Param::get('id'); $selection_id = Param::get('selection'); $question = Question::get(); $answer = Answer::get($q_id); $this->set(['question' => $question, 'answer' => $answer, 'selection_id' => $selection_id]); $this->render('index'); }
public function insert() { $params = Param::params(); $crud = new Crud(); $crud->insertQuestion($params); $params['q_id'] = $crud->getInsertedId(); $crud->insertAnswer($params); $this->render('index'); }
public function redirect() { $follow = Follow::getOrFail(Param::get('id')); $thread = Thread::get($follow->thread_id); $last_comment_id = Comment::getLastIdInThread($thread); $follow->last_comment = $last_comment_id; $follow->update(); redirect(VIEW_THREAD_URL, array('id' => $thread->id, 'page' => ThreadController::LAST_PAGE)); }
/** * Try to determine all request headers * * @return array */ public function getRequestHeaders() { $headers = array(); foreach ($this->data->getAll() as $key => $value) { if ('HTTP_' === substr($key, 0, 5)) { $headers[substr($key, 5)] = $value; } } return $headers; }
public static function invoke() { list($controller_name, $action_name) = self::parseAction(Param::get(DC_ACTION)); $controller = self::getController($controller_name); $controller->action = $action_name; $controller->beforeFilter(); $controller->dispatchAction(); $controller->afterFilter(); echo $controller->output; }
public function delete() { $thread_id = Param::get('thread_id'); $comment_id = Param::get('comment_id'); authorize_user_request($comment_id, self::AUTH_COMMENT_DELETE); try { Comment::delete($comment_id, $thread_id); } catch (PDOException $e) { $_SESSION['delete_error'] = true; } redirect(VIEW_COMMENT_PAGE, array('thread_id' => $thread_id)); }
/** * 执行 */ public static function run() { // 设定错误和异常处理 set_error_handler('IndexPHP::_error'); set_exception_handler('IndexPHP::_exception'); register_shutdown_function('IndexPHP::_shutdown'); // 定义常量 defined('PATH_APP') or define('PATH_APP', './app/'); defined('PATH_APP_CTRL') or define('PATH_APP_CTRL', PATH_APP . 'ctrl/'); defined('PATH_APP_VIEW') or define('PATH_APP_VIEW', PATH_APP . 'view/'); defined('PATH_APP_LIB') or define('PATH_APP_LIB', PATH_APP . 'lib/'); defined('PATH_APP_LOG') or define('PATH_APP_LOG', PATH_APP . 'log/'); defined('FILE_APP_CONF') or define('FILE_APP_CONF', PATH_APP . '/conf.php'); defined('FILE_APP_COMM') or define('FILE_APP_COMM', PATH_APP . '/common.php'); define('IS_POST', Param::server('REQUEST_METHOD') == 'POST' ? true : false); define('HTTP_HOST', Param::server('HTTP_HOST')); // 初始化框架 self::_init(); // 导入配置 Config::set(self::import(FILE_APP_CONF)); Config::get('ENABLE_SESSION') && session_start(); // 路由处理 $ca = explode('/', trim(Param::server('PATH_INFO', Config::get('DEFAULT_CTRL_ACTION')), '/')); define('CTRL_NAME', strtolower(Param::get(Config::get('PARAM_CTRL', 'c'), !empty($ca[0]) ? $ca[0] : 'index'))); define('ACTION_NAME', strtolower(Param::get(Config::get('PARAM_ACTION', 'a'), !empty($ca[1]) ? $ca[1] : 'index'))); // URL参数按顺序绑定变量 preg_replace_callback('/(\\w+)\\/([^\\/]+)/', function ($match) { $_GET[$match[1]] = strip_tags($match[2]); }, trim(Param::server('PATH_INFO'), '/')); // 导入控制器文件 if (!self::import(PATH_APP_CTRL . CTRL_NAME . Config::get('FILE_EXTENSION_CTRL', '.class.php'))) { throw new Exception('没有控制器:' . CTRL_NAME); } // 控制器、方法名称变换处理 $c = self::camelize(CTRL_NAME) . Config::get('POSTFIX_CTRL', 'Controller'); $a = lcfirst(self::camelize(ACTION_NAME)) . Config::get('POSTFIX_ACTION', ''); // 控制器类判断是否存在 if (class_exists($c)) { // 导入公共函数库 self::import(FILE_APP_COMM); // 自动加载外部库 spl_autoload_register('self::_autoload'); // 调用控制器方法 call_user_func(array(new $c(), $a)); } }
public static function action_vote($id = null) { if (!$id) { if ($_SERVER['REQUEST_METHOD'] !== 'POST') { return Response::error(404); } else { $id = (int) Param::post('id'); $answers = Param::post('answers'); $poll = Poll::get($id); $poll->various_answers = '0' != $poll->various_answers; $cookiename = 'p_' . $poll->id . '_v'; // Si no hay respuestas o hay más de una respuesta if (count($answers) === 0 || !$poll->various_answers && count($answers) > 1) { Redirect::to(Url::get('vote', $id, 'vote_error=true')); } if (Vote::where('voter_ip', '=', CURRENT_USER_IP)->and_where('poll_id', '=', $id)->first() || Cookie::get($cookiename)) { Cookie::set($cookiename, !$poll->various_answers ? (string) $answers[0] : 'true', 360); Redirect::to(Url::get('view', $poll->slug, 'poll_already_voted=true')); } Cookie::set($cookiename, !$poll->various_answers ? (string) $answers[0] : 'true', 360); Vote::create(array('voter_ip' => CURRENT_USER_IP, 'poll_id' => $id, 'answer_id' => !$poll->various_answers ? $answers[0] : 0)); foreach ($answers as $answer_id) { Answer::find($answer_id)->set(array('nofilter:votes' => '`votes` + 1')); } Poll::find($id)->set(array('nofilter:total_votes' => '`total_votes` + 1')); Redirect::to(Url::get('view', $poll->slug, 'voted=true')); } } elseif (!is_numeric($id)) { return Response::error(404); } $id = intval($id, 10); if (!($poll = Poll::get($id))) { return Response::error(404); } $answers = Answer::where('poll_id', '=', $poll->id)->get(); return View::make('vote')->add_var('poll', $poll)->add_var('answers', $answers); }
</div> </div> <?php } ?> <hr> <form id="myform" class="well" method="post" action="<?php eh(url('thread/write')); ?> "> <label>Your name</label> <input type="text" class="span2" name="username" value="<?php eh(Param::get('username')); ?> " required /> <label>Comment</label> <textarea name="body" class="required"><?php eh(Param::get('body')); ?> </textarea> <br /> <input type="hidden" name="thread_id" value="<?php eh($thread->id); ?> "> <input type="hidden" name="page_next" value="write_end"> <button type="submit" class="btn btn-primary">Submit</button> </form> <a class="btn btn-large btn-primary" href="/thread/index">back</a>
function SimpleDirectoryListing() { $this->validateConfig(); // edited in 2.1; if (!SYSTEM_ON || !ADMIN_MODE_ON && !USER_MODE_ON) { if (!(isset($_GET["print"]) || isset($_GET["action"]))) { echo text("SYSTEM HAS BEEN SHUTTED DOWN"); } exit(0); } #----------------------------------------------------------------------- # Service is available #----------------------------------------------------------------------- #----------------------------------------------------------------------- # Anonymous visitor #----------------------------------------------------------------------- Param::filter($_GET); Param::filter($_POST); UserManager::proceedLoginLogout(); $this->user = UserManager::checkPermissionAndGetUser(); if (!$this->user) { if (!(isset($_GET["print"]) || isset($_GET["action"]))) { UserManager::printLogin(); } if (isset($_GET["action"]) || $_GET["print"] === "dirListing") { echo text("PLEASE LOGIN"); } exit(0); } #----------------------------------------------------------------------- # Have rights to access #----------------------------------------------------------------------- // added in 2.1; if ($_GET["system"] === "loginPage" && !$_SESSION["loggedIn"]) { UserManager::printLogin(); exit(0); } $this->moduleManager = new moduleManager($this->user); // The output is static data if ($_GET["print"] === "css") { $this->printCss(); exit(0); } // The output is static data if ($_GET["print"] === "icon") { $this->printIcon(); exit(0); } // The output is static data if ($_GET["print"] === "javascript") { $this->printJavascript(); exit(0); } #----------------------------------------------------------------------- # Needs to have the $_GET['relCwd'] #----------------------------------------------------------------------- #----------------------------------------------------------------------- # Printing of sections and modules # Execution of actions #----------------------------------------------------------------------- $this->fileManager = new fileManager(); $this->fileManager->user = $this->user; $this->moduleManager->setManagersToModules($this->fileManager, $this->user); // The output is static data if ($_GET["print"] === "image") { $this->printImage(); exit(0); } // The output is static data if ($_GET["print"] === "thumbnail") { $this->printThumbnail(); exit(0); } // The output is dynamic if ($_GET["print"] === "dirListing") { $this->printDirListing(); exit(0); } // The output is dynamic if ($_GET["print"] === "rss") { $this->printRss(); exit(0); } // The output is dynamic if ($_GET["print"] === "sfs") { $this->printSfs(); exit(0); } // The output is dynamic if ($_GET["action"] === "module") { $this->actionModule(); exit(0); } $this->printHtml(); exit(0); }
public function edit() { $process = Param::get('process', 'edit'); $user = new User(); switch ($process) { case self::EDIT_ACCOUNT: $user->id = get_authenticated_user_id($_SESSION['userid']); $user->fname = Param::get('firstname'); $user->lname = Param::get('lastname'); $user->new_username = Param::get('username'); $user->new_email = Param::get('email'); try { $user->updateAccount(); $_SESSION['username'] = $user->new_username; $user->editSuccess = true; } catch (ValidationException $e) { } break; case self::EDIT_PROFILE: $user->id = get_authenticated_user_id($_SESSION['userid']); $user->company = Param::get('company'); $user->division = Param::get('division'); $user->specialization = Param::get('specialization'); try { $user->updateProfile(); $user->editSuccess = true; } catch (ValidationException $e) { } break; case self::EDIT_PASSWORD: $user->id = get_authenticated_user_id($_SESSION['userid']); //set username and old password to password //property to authenticate user $user->username = $_SESSION['username']; $user->password = htmlentities(Param::get('oldPassword')); if (!$user->isRegistered()) { $user->validation_errors['notAuthorized']['authenticate'] = true; break; } //Unset username so it won't be included in validation unset($user->username); $user->password = htmlentities(Param::get('password')); $user->confirmpassword = htmlentities(Param::get('confirmPassword')); try { $user->updatePassword(); $user->editSuccess = true; } catch (ValidationException $e) { } break; case self::EDIT_PICTURE: $user = new User(); $target_directory = "bootstrap/img/users/" . $_SESSION['username']; try { if (file_exists($file_tmp = $_FILES['picture']['tmp_name'])) { $finfo = new finfo(FILEINFO_MIME_TYPE); if (false === ($file_extension = array_search($finfo->file($_FILES['picture']['tmp_name']), $this->mime_types, true))) { throw new PictureFormatException("Invalid file format."); } $user_profile = glob("bootstrap/img/users/" . $_SESSION['username'] . ".*"); if ($user_profile) { foreach ($user_profile as $picture) { exec("rm {$picture}"); } } if (!move_uploaded_file($_FILES['picture']['tmp_name'], $target_directory . "." . $file_extension)) { throw new FileNotFound("File not found."); } } else { throw new FileNotFound('File not found.'); } $user->editSuccess = true; } catch (FileNotFound $e) { $_SESSION['upload_error'] = true; } catch (PictureFormatException $e) { $_SESSION['upload_error'] = true; } break; case self::EDIT_PAGE: $user->id = $_SESSION['userid']; break; } $user->getProfile(); $this->set(get_defined_vars()); }
<?php ob_start(); session_name('IDSESSION'); session_start(); if (!isset($_SESSION['log']) || empty($_SESSION['log'])) { header("location: admin/"); } require_once 'php/param.class.php'; $param = new Param(); ?> <!DOCTYPE html> <html lang="fr"> <head> <link href="style/favicon.ico" rel="icon"> <meta name="author" lang="fr" content="Padow"> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title><?php $param->setPageTitle(); ?> </title> <!-- Bootstrap --> <link href="style/bootstrap/css/bootstrap.min.css" rel="stylesheet"> <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries --> <!-- WARNING: Respond.js doesn't work if you view the page via file:// --> <!--[if lt IE 9]> <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>