public function __construct(Request $request)
 {
     $this->name = $request->post('name');
     $this->email = $request->post('email');
     $this->message = $request->post('message');
     $this->date = $request->post('date');
 }
Example #2
0
 public function __construct(Request $_request)
 {
     $this->login = $_request->post('login');
     $this->email = $_request->post('email');
     $this->password = $_request->post('password');
     $this->password_confirm = $_request->post('password_confirm');
 }
 public function addRSSStreamAction(Request $request)
 {
     $categoryTitle = $request->post('category');
     $firstUpdate = $request->post('firstUpdate');
     $url = $request->post('url_flux');
     var_dump($categoryTitle);
     var_dump($firstUpdate);
     var_dump($url);
     $this->loadModel('CategoryModel');
     $this->loadModel('RssModel');
     $url = $this->rssmodel->resolveFile($url);
     $userId = $request->getSession()->get('id');
     $rssEntity = $this->rssmodel->createStream($url, $firstUpdate);
     if ($rssEntity) {
         $categoryEntity = $this->categorymodel->createCategory($userId, $categoryTitle);
         $streamCategoryEntity = new StreamCategoryEntity();
         $streamCategoryEntity->setCategory($categoryEntity->getId());
         $streamCategoryEntity->setStream($rssEntity->getId());
         $streamCategoryEntity->setStreamType(ArticleModel::RSS);
         $streamCategoryEntity->persist();
         $this->rssmodel->streamCron($rssEntity);
         $this->redirectToRoute('index');
     } else {
         $this->render('layouts/addStream', array('errors' => array('Une erreur est survenue dans la connexion au flux rss. Veuillez réssayer ! ')));
     }
 }
 function addTwitterStreamAction(Request $request)
 {
     $categoryTitle = $request->post('category');
     $firstUpdate = $request->post('firstUpdate');
     $channel = $request->post('channel');
     $userId = $request->getSession()->get('id');
     $channel = str_replace('@', '', $channel);
     $this->loadModel('CategoryModel');
     $this->loadModel('TwitterModel');
     if (!$this->twittermodel->isValidChannel($channel)) {
         $data = array('errors' => array('La chaine n\'existe pas, veuillez spécifier une chaine existante'));
         $this->render('layouts/addStream', $data);
         return;
     }
     $twitterEntity = $this->twittermodel->createStream($channel, $firstUpdate);
     if ($twitterEntity) {
         $categoryEntity = $this->categorymodel->createCategory($userId, $categoryTitle);
         $streamCategoryEntity = new StreamCategoryEntity();
         $streamCategoryEntity->setCategory($categoryEntity->getId());
         $streamCategoryEntity->setStream($twitterEntity->getId());
         $streamCategoryEntity->setStreamType(ArticleModel::TWITTER);
         $streamCategoryEntity->persist();
         $this->twittermodel->streamCron($twitterEntity);
         $this->redirectToRoute('index');
     } else {
         $this->render('layouts/addStream', array('errors' => array('Une erreur est survenue dans la connexion au flux twitter. Veuillez réssayer ! ')));
     }
 }
Example #5
0
 public function validateRequest(Request $request, Response $response)
 {
     $this->request = $request;
     $this->response = $response;
     if (!$request->post('code')) {
         throw Oauth2_Exception::factory(400, 'invalid_request', 'Missing parameter: "code" is required');
         return false;
     }
     $code = $request->post('code');
     if (!($authCode = $this->getAuthorizationCode($code))) {
         throw Oauth2_Exception::factory(400, 'invalid_grant', 'Authorization code doesn\'t exist or is invalid for the client');
         return false;
     }
     /*
      * 4.1.3 - ensure that the "redirect_uri" parameter is present if the "redirect_uri" parameter was included in the initial authorization request
      * @uri - http://tools.ietf.org/html/rfc6749#section-4.1.3
      */
     if (isset($authCode['redirect_uri']) && $authCode['redirect_uri']) {
         if (!$request->post('redirect_uri') || urldecode($request->post('redirect_uri')) != $authCode['redirect_uri']) {
             throw Oauth2_Exception::factory(400, 'redirect_uri_mismatch', "The redirect URI is missing or do not match");
             return false;
         }
     }
     if ($authCode["expires"] < time()) {
         throw Oauth2_Exception::factory(400, 'invalid_grant', "The authorization code has expired");
         //throw new Oauth2_Exception(400, 'invalid_grant', "The authorization code has expired");
         return false;
     }
     if (!isset($authCode['code'])) {
         $authCode['code'] = $code;
         // used to expire the code after the access token is granted
     }
     $this->authCode = $authCode;
     return true;
 }
 public function __construct(Request $request)
 {
     $this->email = $request->post('email');
     $this->username = $request->post('username');
     $this->password = $request->post('password');
     $this->passwordConfirm = $request->post('passwordConfirm');
 }
 public function __construct(Request $request)
 {
     $this->name = Session::has('user') ? Session::get('user')['user'] : $request->post('name');
     $this->email = Session::has('user') ? $this->regUserData()['email'] : $request->post('email');
     $this->message_subject = $request->get('message_subject');
     $this->message = $request->post('message');
     $this->date = $request->post('date');
     $this->id_reg_user = Session::has('user') ? Session::get('user')['id'] : null;
 }
 public function updateStaticTranslation(Request $request)
 {
     $dbc = Connect::getConnection();
     $text_en = str_replace("'", " ", $request->post('text_en'));
     $text_uk = str_replace("'", " ", $request->post('text_uk'));
     $text_en = $request->post('text_en');
     $text_uk = $request->post('text_uk');
     $placeholders = array('key' => $request->post('key'), 'text_en' => $text_en, 'text_uk' => $text_uk);
     Debugger::PrintR($placeholders);
     $sql = "UPDATE `static_translation` SET `text_en`= :text_en,`text_uk`= :text_uk WHERE `key`= :key";
     $sth = $dbc->getPDO()->prepare($sql);
     $sth->execute($placeholders);
 }
 public function __construct(Request $request)
 {
     for ($i = 1; $i <= Config::get('basic_page_in_block'); $i++) {
         $id = $request->post("id_{$i}");
         if ($id) {
             $this->id_array[$i] = $id;
         }
         $delete = $request->post("delete_{$i}");
         if (isset($delete)) {
             $this->delete_array[$i] = $delete;
         }
     }
 }
 public function __construct(Request $request, $material_type)
 {
     $this->title = $request->post('title');
     $this->menu_name = $request->post('menu_name');
     $this->menu_data = $request->post('menu');
     $this->without_menu = $request->post('without_menu');
     $this->publication = $request->post('publication');
     $this->title_or_menu_name = $this->menu_name ? $this->menu_name : $this->title;
     $alias_data = $this->createAlias($this->title_or_menu_name, $this->menu_data);
     $this->new_alias = $alias_data['new_alias'];
     $this->date = $request->post('date');
     $this->translit = $alias_data['translit'];
     $this->id_parent = $alias_data['id_parent'];
     $this->material_type = $material_type;
     $img_name_local = $request->files('name');
     $this->img_name_local = isset($img_name_local) ? $img_name_local : '';
     $img_name_server = $request->post('file_server');
     $this->img_name_server = isset($img_name_server) ? $img_name_server : '';
     if ($this->img_name_server && $this->img_name_local) {
         $this->img_name = $this->img_name_local;
     }
     if ($this->img_name_server) {
         $this->img_name = $this->img_name_server;
     }
     if ($this->img_name_local) {
         $this->img_name = $this->img_name_local;
     }
     if (!$this->img_name_server && !$this->img_name_local) {
         $this->img_name = Config::get('default_img');
     }
     // $name = $request->files('name');
     $this->img = isset($this->img_name) ? "Webroot/uploads/images/{$this->img_name}" : "Webroot/uploads/images/" . Config::get('default_img');
     $fields_model = new FieldsModel($material_type);
     $fields = $fields_model->getFields();
     $additional_fields_list = array();
     $additional_fields_value = '';
     $additional_fields_key_value = '';
     $additional_fields_value_arr = array();
     foreach ($fields as $v) {
         if ($v != 'id' && $v != 'alias' && $v != 'id_' . $material_type . '' && $v != 'title') {
             $additional_fields_list[] = $v;
             $additional_fields_value .= ", '" . $request->post($v) . "'";
             $additional_fields_value_arr[$v] = $request->post($v);
             $additional_fields_key_value .= ", `" . $v . "` = '" . $request->post($v) . "'";
         }
     }
     $this->additional_fields_arr = $additional_fields_list;
     $this->additional_fields_value = $additional_fields_value;
     $this->additional_fields_value_arr = $additional_fields_value_arr;
     $this->additional_fields_key_value = $additional_fields_key_value;
 }
Example #11
0
 /**
  * @function 
  * @public
  * @static
  * @returns NONE
  * @desc
  * @param {string} foo Use the 'foo' param for bar.
  * @example NONE
  */
 public static function table_num_setup()
 {
     $tbl_no = Request::post('input_text_field');
     // if all of the characters are not numbers, return false
     if (!ctype_digit($tbl_no)) {
         return false;
     }
     $database = DatabaseFactory::getFactory()->getConnection();
     $query = $database->prepare("SELECT * FROM qscDeviceTables.tblDevices WHERE number = :table_number_input");
     $query->execute(array(':table_number_input' => $tbl_no));
     if ($query->rowCount() == 0) {
         $n = intval($tbl_no);
         if ($n < 0) {
             return false;
         }
         Session::set('table_number', $n);
         //      apc_store('table_number', $n);
         /**
               $m = session_id();
               $database->query("INSERT INTO qscDeviceTables.tblDevices (id, number) VALUES (".$m.", ".$n.")";
         */
         $database->query("INSERT INTO qscDeviceTables.tblDevices (number) VALUES (" . $n . ")");
         return true;
     } else {
         // failure, table number exists!
         //      $exists_already = apc_fetch('table_number');
         //      if ($exists_already) {
         //        Session::set('table_number');
         //        return true;
         //      }
         return false;
     }
 }
 public function IndexAction()
 {
     if (!Request::isPosted('email')) {
         $this->Render();
     } else {
         $email = Request::post('email', '', 'mail');
         $pass1 = Request::post('pass1', '', 'safe');
         $pass2 = Request::post('pass2', '', 'safe');
         if ($email == '') {
             Site::Message('Вы не указали Ваш e-mail, или такого адреса не существует');
             $this->Render();
         } elseif (UserModel::isExists($email, 'login')) {
             Site::Message('Похоже пользователь с таким почтовым ящиком уже существует.<br>Возможно Вы регистрировались раньше, если вы забыли пароль, Вы можете восстановить его.');
             $this->Render();
         } elseif ($pass1 == '') {
             Site::Message('Вы забыли придумать пароль');
             $this->Render();
         } elseif (strlen($pass1) < 6) {
             Site::Message('Пароль короче 6-ти символов =(');
             $this->Render();
         } elseif ($pass1 != $pass2) {
             Site::Message('Введенные Вами пароли не совпадают, где-то ошиблись, попробуйте ещё раз');
             $this->Render();
         } else {
             UserModel::Registration($email, $pass1);
             User::LoginByPass($email, $pass1);
             Site::Message('Ваш профиль успешно создан!');
             $this->Route('newcompany');
         }
     }
 }
Example #13
0
 public function init()
 {
     $this->session = new Session();
     $this->get = Request::get();
     $this->post = Request::post();
     $this->views = new Views(new Template("admin"));
 }
Example #14
0
 /**
  * Get object history
  */
 public function listAction()
 {
     $object = Request::post('object', 'string', false);
     if (!$object) {
         Response::jsonSuccess(array());
     }
     $pager = Request::post('pager', 'array', array());
     $filter = Request::post('filter', 'array', array());
     if (!isset($filter['record_id']) || empty($filter['record_id'])) {
         Response::jsonSuccess(array());
     }
     try {
         $o = new Db_Object($object);
     } catch (Exception $e) {
         Response::jsonSuccess(array());
     }
     $filter['table_name'] = $o->getTable();
     $history = Model::factory('Historylog');
     $data = $history->getListVc($pager, $filter, false, array('date', 'type', 'id'), 'user_name');
     if (!empty($data)) {
         foreach ($data as $k => &$v) {
             if (isset(Model_Historylog::$actions[$v['type']])) {
                 $v['type'] = Model_Historylog::$actions[$v['type']];
             }
         }
         unset($v);
     }
     Response::jsonSuccess($data, array('count' => $history->getCount($filter)));
 }
Example #15
0
 public static function CreateNewAccount()
 {
     // validate input
     if (!self::validateUserName(Request::post('new_account_name'))) {
         return false;
     }
     if (!self::validateUserPassword(Request::post('new_account_password'), Request::post('new_account_password_repeat'))) {
         return false;
     }
     // connect to database
     $db = Database::getFactory()->getConnection();
     if (!$db) {
         Session::add('feedback_negative', 'Critical error. Can\'t connect to database.');
         return false;
     }
     // get a password hash
     $passwordHash = password_hash(Request::post('new_account_password'), PASSWORD_DEFAULT);
     // write new users data into database
     $sql = "INSERT INTO users ( user_id,  user_name,  user_password,  user_registration_time)\n                       VALUES (:user_id, :user_name, :user_password, :user_registration_time)";
     $query = $db->prepare($sql);
     $query->execute(array(':user_id' => null, ':user_name' => Request::post('new_account_name'), ':user_password' => $passwordHash, ':user_registration_time' => time('c')));
     $count = $query->rowCount();
     if ($count == 1) {
         Session::add('feedback_positive', 'New account created successfully.');
         return true;
     }
     // if it gets to this point, something went wrong
     Session::add('feedback_negative', 'Something went wrong.');
     return false;
 }
Example #16
0
 public function init()
 {
     $this->session = new Session();
     $this->get = Request::get();
     $this->post = Request::post();
     Phalanx::loadClasses('Profile', 'Badges');
 }
 function execute()
 {
     $id = Request::post('id');
     $this->frame = false;
     $model = new connectionFeedbackModel();
     $this->smarty->assign('ticket', $model->getTicket($id));
 }
Example #18
0
 public function init()
 {
     $this->post = Request::post();
     $this->get = Request::get();
     $this->session = new Session();
     $this->cookies = new Cookies();
 }
Example #19
0
 /**
  * 根据密码获取密钥与加密后的密码数据及确认密码
  *
  * @return array
  */
 public function getPasswordAndSecurity()
 {
     $data = [];
     $data['security'] = substr(md5(time()), 0, 10);
     $data['password'] = md5(Request::post('password') . $data['security']);
     return $data;
 }
 function execute()
 {
     if (!Request::post('id')) {
         return;
     }
     connectionFaqPartModel::create()->where(array('id' => (int) Request::post('id')))->delete();
 }
Example #21
0
 function _edit($newsItem)
 {
     /* @var $newsItem NewsItem */
     $data = array('date' => Request::post('date'), 'update_time' => time(), 'image' => $image, 'title' => Request::post('title'), 'anons' => Request::post('anons'), 'html' => Request::post('html'), 'enabled' => 1);
     $data['image'] = $this->uploadImage();
     $newsItem->_update($data);
 }
 public function pagereorder_redux__reorder()
 {
     $response = array('linkage' => null, 'message' => 'No order data received. Please try again.', 'status' => 'error');
     // Get current user, to check if we're logged in.
     if (!Auth::isLoggedIn()) {
         exit('Invalid Request');
     }
     // Get POST data from request.
     $order = Request::post('order', false);
     $entry_folder = Request::post('entry_folder', false);
     // Make sure we've got a response.
     if (!$order || !$entry_folder) {
         Log::error($response['message'], 'pagereorder_redux');
         echo json_encode($response);
         return false;
     }
     // Array of page order objects.
     $page_order = json_decode($order);
     if (isset($page_order[0]->url) && $page_order[0]->url != '') {
         $response = $this->order_set($page_order, $entry_folder);
     } else {
         $response['message'] = "The data submitted was invalid";
     }
     echo json_encode($response);
     return true;
 }
    function process()
    {
        global $current_user;
        /* @var $current_user CurrentUser */
        $current_user->can_throw('add_comments');
        /*
         [writemodule] => CommentsWriteModule
         [reply_to] => 1
         [doc_id] => 440
         [comment] => ghjkhjk
        */
        $document_id = max(0, (int) Request::post('doc_id'));
        $table = Request::post('table');
        $comment = Request::post('comment');
        $reply_to = max(0, (int) Request::post('reply_to'));
        Database::query('START TRANSACTION');
        $query = 'SELECT max(`id`) as `id` FROM `comments` WHERE `doc_id` = ' . $document_id . ' AND `table`=' . Database::escape($table) . '';
        $maxid = 1 + max(0, Database::sql2single($query));
        $query = 'INSERT INTO `comments` SET 
		`id`=' . $maxid . ',
		`table`=' . Database::escape($table) . ', 
		`comment`=' . Database::escape($comment) . ',
		`parent`=' . $reply_to . ',
		`doc_id`=' . $document_id . ',
		`id_author`=' . $current_user->id . ',
		`time`=' . time();
        Database::query($query);
        Database::query('COMMIT');
    }
 public function get_incorrect_words()
 {
     $texts = (array) Request::post('text');
     $callback = array($this, '_get_incorred_words');
     $response = array_map($callback, $texts);
     $this->send_data('success', $response);
 }
 function execute()
 {
     $app = strtolower(Request::get('app_local'));
     $locale = new Locales($app);
     $locale->deleteTranslate(Request::get('local_iso'), Request::post('var'));
     return false;
 }
 function execute()
 {
     $slideID = (int) Request::post('id');
     if ($slideID > 0) {
         connectionSliderModel::create()->where(array('id' => $slideID))->delete();
     }
 }
Example #27
0
 function exeCheck()
 {
     $id = Session::get('user')['id'];
     $userId = (int) Request::post('userId');
     $status = (int) Request::post('status');
     if ($id > 0 && $userId > 0) {
         $array = array();
         switch ($status) {
             case '-1':
                 if ($this->exeInsert($id, $userId) > 0) {
                     $array = array('status' => 1, 'text' => 'Đang gửi yêu cầu');
                 }
                 break;
             case '0':
                 if ($this->exeHandling($userId, $id, 1) > 0) {
                     $array = array('status' => 2, 'text' => 'Bạn bè');
                 }
                 break;
             case '1':
                 if ($this->exeDelete($userId, $id) > 0) {
                     $array = array('status' => -1, 'text' => 'Kết bạn');
                 }
                 break;
             case '2':
                 if ($this->exeDelete($userId, $id) > 0) {
                     $array = array('status' => -1, 'text' => 'Kết bạn');
                 }
                 break;
         }
         echo json_encode($array);
     } else {
         exit;
     }
 }
Example #28
0
 function exeLoadType()
 {
     $userId = (int) Request::post('userId');
     if ($userId > 0) {
         $data = $this->model->loadType($userId);
         $type = array('0' => 'Khoá', '2' => 'Thành viên');
         if (Session::get('user')['user_type'] == 7) {
             $type['4'] = 'Mod';
         }
         if (Session::get('user')['user_type'] > $data['user_type']) {
             echo '<form name="editType" method="post"><p>';
             echo '<p>Nhóm thành viên</p>';
             foreach ($type as $key => $value) {
                 if ($key == $data['user_type']) {
                     echo '<label class="label_radio"><input type="radio"  name="editType" value="' . $key . '" checked="checked" />' . $value . '</label>';
                 } else {
                     echo '<label class="label_radio"><input type="radio" name="editType" value="' . $key . '" />' . $value . '</label>';
                 }
             }
             echo '<input type="hidden" name="id" value="' . $userId . '" />';
             echo '</p><p><label class="label_text"></label><input class="input_submit" type="button" name="submitType" value="Thay đổi"></p>';
             echo '</form>';
         } else {
             echo '<p class="error">Bạn không có quyền với user này</p>';
         }
     } else {
         Until::redirectTo();
     }
 }
Example #29
0
 public function updateAction()
 {
     $this->_checkCanEdit();
     $data = Request::post('data', 'raw', false);
     if ($data === false) {
         Response::jsonError($this->_lang->INVALID_VALUE);
     }
     $data = json_decode($data, true);
     if (!isset($data[0])) {
         $data = array($data);
     }
     $manager = new Backend_Fmodules_Manager();
     $manager->removeAll();
     if (!empty($data)) {
         foreach ($data as $v) {
             if (empty($v)) {
                 continue;
             }
             $name = $v['name'];
             unset($v['name']);
             $manager->addModule($name, $v);
         }
     }
     if ($manager->save()) {
         Response::jsonSuccess();
     } else {
         Response::jsonError($this->_lang->CANT_WRITE_FS);
     }
 }
Example #30
0
 function translate($lang = 'ru')
 {
     $config = App;
     $content = ob_get_contents();
     ob_end_clean();
     if (self::$active) {
         self::$locale = self::getAppLocale($lang);
         preg_match_all(LOCALE_TEMPLATE, $content, $mathes);
         if (sizeof($mathes[1]) > 0) {
             foreach ($mathes[1] as $word) {
                 if (array_key_exists($word, self::$locale)) {
                     $content = str_replace(sprintf(LOCALE_TEMPLATE_CHANGE, $word), self::$locale[$word], $content);
                 }
             }
         }
     }
     if (($selector = Request::post('html_element')) || ($selector = Request::get('html_element'))) {
         Load::dependence('simple_html_dom');
         $html = str_get_html($content);
         $elements = $html->find($selector);
         if (sizeof($elements) > 0) {
             echo $elements[0]->innertext;
         } else {
             echo $content;
         }
     } else {
         echo $content;
     }
 }