private function AddComment(sfWebRequest $request) { $text = $request->getParameter('comment_text'); if ($request->isMethod("GET")) { $text = urldecode($text); } if ($this->getRequestParameter('comment_picture_url')) { $filename = jrFileUploader::UploadRemote($request->getParameter('comment_picture_url')); if ($text) { $text .= "<br/>"; } $text .= "<img src='http://" . $request->getHost() . "/uploads/" . $filename . "' />"; } if (!trim($text)) { return; } sfApplicationConfiguration::getActive()->loadHelpers(array('Parse', 'Text', 'Tag', 'I18N', 'Url')); $user = $this->getUser()->getGuardUser(); $comment = new PostComment(); $comment->setUser($user); $comment->setPost($this->post); if ($this->parent) { $comment->setParent($this->parent); } $comment->setComment(parsetext($text)); $comment->setCommentOriginal($text); $comment->save(); $this->curUser = $this->getUser()->getGuardUser(); if ($this->curUser) { Cookie::setCookie($this->curUser, "comments" . $this->post->getId(), $this->post->getAllComments('count'), time() + 24 * 60 * 60); Cookie::setCookie($this->curUser, "comments" . $this->post->getId() . "Time", date("Y-m-d H:i:s"), time() + 24 * 60 * 60); } }
/** * @param $key * @param $value * @return $this */ public function setCookie($key, $value) { if (!$this->cookie) { $this->cookie = new Cookie(); } $this->cookie->setCookie($key, $value); return $this; }
/** * 变脸项目-根据浏览器是否开启了js来展现不同的页面 * @return boolean */ public static function parseNojs(&$arrData) { $arrData['uiData']['queryInfo']['noscript'] = intval($_GET['nojs']); $arrData['uiData']['queryInfo']['cookieNoscript'] = intval($_COOKIE['NOJS']); if ($arrData['uiData']['queryInfo']['noscript'] == 1 && $arrData['uiData']['queryInfo']['cookieNoscript'] != 1) { Cookie::setCookie('NOJS', '1'); } }
/** * * function: register * Register a new user * @access public * @param string $username * @param string $password * @param boolean $sticky (optional) * @return [boolean,User] */ public function register($username, $password, $info = false) { $sql = 'INSERT INTO ' . $this->table . ' (username,password) VALUES (?,?);'; $userId = $this->insert($sql, array($username, $this->bcrypt->hash(md5($password)))); if (empty($userId)) { return false; } else { if (!empty($info)) { Users::updateUser($info, $userId); } Session::setUser($userId); if (!empty($sticky)) { Cookie::setCookie('user', $userId); } return $userId; } }
/** * Expire the rememberme cookie, unset $_COOKIE[$this->cookieName] value and * remove current login triplet from storage. * @param boolean $clearFromStorage * @return boolean */ public function clearCookie($clearFromStorage = true) { if (empty($_COOKIE[$this->cookieName])) { return false; } $cookieValues = explode("|", $_COOKIE[$this->cookieName], 3); $this->cookie->setCookie($this->cookieName, "", time() - $this->expireTime); unset($_COOKIE[$this->cookieName]); if (!$clearFromStorage) { return true; } if (count($cookieValues) < 3) { return false; } $this->storage->cleanTriplet($cookieValues[0], $cookieValues[2] . $this->salt); return true; }
function actions() { if (array_key_exists('writeLocalLog', $this->parameters)) { Log::writeLocalLog(); } if (array_key_exists('deletePhpErrorLog', $this->parameters)) { Log::deletePhpErrorLog(); } if (array_key_exists('deleteLocalLog', $this->parameters)) { Log::deleteLocalLog(); } if (array_key_exists('addCookie', $this->parameters)) { Cookie::setCookie(); } if (array_key_exists('deleteAllCookies', $this->parameters)) { Cookie::deleteAllCookies(); } }
public function login() { if (isset($_POST['send'])) { parent::__construct($this->_tpl, new UserModel()); $this->_model->user = $_POST['user']; $this->_model->pass = md5($_POST['pass']); if (!!($_user = $this->_model->checkLogin())) { $_cookie = new Cookie('user', $_user->user, $_POST['time']); $_cookie->setCookie(); $_cookie = new Cookie('face', $_user->face, $_POST['time']); $_cookie->setCookie(); $this->_model->id = $_user->id; $this->_model->time = time(); $this->_model->setLaterUser(); Tool::alertLocation(null, './'); } else { Tool::alertBack('wrong username or password'); } } $this->_tpl->assign('login', true); }
<?php echo link_to_function(__('Написать комментарий'), '$j(".addcomment").hide("fast");if($j("#addcomment' . $post->getId() . '").is(":visible"))$j("#addcomment' . $post->getId() . '").hide("fast"); else $j("#addcomment' . $post->getId() . '").show("fast")'); ?> </div> <div id='addcomment<?php echo $post->getId(); ?> ' <?php if (isset($showAddComment) && $showAddComment) { ?> class='addcommentInline'<?php } else { ?> class='addcomment'<?php } ?> > <?php include_partial('post_comment/addComment', array('post' => $post)); ?> </div> <?php } else { ?> <?php echo __('Только зарегистрированные пользователи могут добавлять комментарии.'); } if ($sf_user->isAuthenticated()) { Cookie::setCookie($sf_user->getGuardUser(), "comments" . $post->getId(), $post->getAllComments('count'), time() + 24 * 60 * 60); Cookie::setCookie($sf_user->getGuardUser(), "comments" . $post->getId() . "Time", date("Y-m-d H:i:s"), time() + 24 * 60 * 60); }
public function login() { if (isset($_POST['send'])) { parent::__construct($this->_tpl, new UserModel()); if (Validate::checkNull($_POST['user'])) { Tool::alertBack('警告:用户名不得为空!'); } if (Validate::checkLength($_POST['user'], 2, 'min')) { Tool::alertBack('警告:用户名长度不得小于两位!'); } if (Validate::checkLength($_POST['user'], 20, 'max')) { Tool::alertBack('警告:用户名长度不得大于二十位!'); } if (Validate::checkLength($_POST['pass'], 6, 'min')) { Tool::alertBack('警告:密码不得小于六位!'); } if (Validate::checkLength($_POST['code'], 4, 'equals')) { Tool::alertBack('警告:验证码必须是四位!'); } if (Validate::checkEquals(strtolower($_POST['code']), $_SESSION['code'])) { Tool::alertBack('警告:验证码不正确!'); } $this->_model->user = $_POST['user']; $this->_model->pass = sha1($_POST['pass']); if (!!($_user = $this->_model->checkLogin())) { $_cookie = new Cookie('user', $_user->user, $_POST['time']); $_cookie->setCookie(); $_cookie = new Cookie('face', $_user->face, $_POST['time']); $_cookie->setCookie(); $this->_model->id = $_user->id; $this->_model->time = time(); $this->_model->setLaterUser(); Tool::alertLocation(null, './'); } else { Tool::alertBack('警告:用户名或密码错误!'); } } $this->_tpl->assign('login', true); }
public function executePersonal(sfWebRequest $request) { sfApplicationConfiguration::getActive()->loadHelpers(array('I18N', 'Parse')); $this->user = sfGuardUser::getUserByUsername($request->getParameter('username')); $this->curUser = $this->getUser()->getGuardUser(); if ($this->curUser && $this->user) { Cookie::setCookie($this->curUser, "personal" . $this->user->getId(), $this->user->getPersonalLine('count'), time() + 24 * 60 * 60); Cookie::setCookie($this->curUser, "personal" . $this->user->getId() . "Time", date("Y-m-d H:i:s"), time() + 24 * 60 * 60); } $this->forward404Unless($this->user); $this->getResponse()->setTitle("Лента / " . $this->user->getUsername() . " / " . __("JoyReactor – твое хорошее настроние. Картинки, приколы, видео, демотиваторы.")); }