예제 #1
0
파일: search.php 프로젝트: roket007/bicycle
 public function setAction()
 {
     $query = Fw_Request::post('query', null);
     if (!is_null($query)) {
         Fw_Request::redirect(C::uri(array('search', urlencode($query))));
     }
     $param_0 = Fw_Request::get(0, null);
     $param_1 = Fw_Request::get(1, null);
     if (is_null($param_0)) {
         return true;
     }
     if (method_exists($this, $param_0 . 'Action')) {
         $this->actionName = $param_0;
         return true;
     }
     if (!is_null($param_0) && !method_exists($this, $param_0 . 'Action')) {
         if (!is_null($param_1) && $param_1 !== 'error') {
             throw new Fw_Exception('[f:"' . __FILE__ . '", l:"' . __LINE__ . '"] Страница не найдена', 404);
         }
         $search_query = urldecode($param_0);
         if (preg_match("/^[\\p{L}\\d\\-_\\.\\,\\?\\!\\s]+\$/Sui", $search_query)) {
             Fw_Request::setGet('search_query', $search_query);
             Fw_Request::setGet('error', false);
             return true;
         } else {
             Fw_Request::setGet('search_query', $search_query);
             Fw_Request::setGet('error', true);
             if ($param_1 !== 'error') {
                 Fw_Request::redirect(C::uri(array('search', urlencode($search_query), 'error')));
                 die;
             }
             return true;
         }
     }
 }
예제 #2
0
 public function indexAction()
 {
     $data['name'] = Fw_Request::post('name', NULL);
     $data['email'] = Fw_Request::post('email', NULL);
     $data['subject'] = Fw_Request::post('subject', NULL);
     $data['text'] = trim(strip_tags(Fw_Request::post('text', NULL)));
     $data['antispam'] = Fw_Request::post('antispam', NULL);
     $error = false;
     $this->view->enable = C::getConfig('application');
     if (!is_null($data['antispam'])) {
         if (!$this->checkAntispam($data['antispam'])) {
             $this->errors['antispam'] = true;
             $error = true;
         }
         if (!preg_match("/^[a-zA-Zа-яА-Я\\s\\d\\-_]{3,50}\$/ui", $data['name'])) {
             $this->errors['name'] = true;
             $error = true;
         }
         if (!filter_var($data['email'], FILTER_VALIDATE_EMAIL)) {
             $this->errors['email'] = true;
             $error = true;
         }
         if (!preg_match("/^[a-zA-Zа-яА-Я\\s\\d\\-_]{3,255}\$/ui", $data['subject'])) {
             $this->errors['subject'] = true;
             $error = true;
         }
         if (empty($data['text'])) {
             $this->errors['text'] = true;
             $error = true;
         }
         if ($error) {
             $this->view->errors = $this->errors;
             $this->view->data = $data;
         } else {
             $this->model->saveMessage($data);
             $this->sendMessage($data);
             Fw_Request::redirect((C::$lang == 'ru' ? '/ru' : '') . '/contacts/send/');
         }
     }
     //Olala antispam
     $time = time();
     $this->view->data = $data;
     $super_secure = substr($time, -5) . substr($time, 0, -5) . $time;
     $this->view->text = Fw_Model::getInstance()->getModel('default')->loadStaticPage($this->name, $this->actionName);
     $this->view->antispam = base64_encode($super_secure);
     $this->view->setBlocks(array('breadcrumbs'));
     $this->view->render();
 }
예제 #3
0
파일: router.php 프로젝트: roket007/bicycle
 public function parse()
 {
     $true_counter = 0;
     $parsed_source = array();
     $exploded = explode('/', trim($this->_source_uri));
     foreach ($exploded as $key => $value) {
         if (!is_null($value) && strlen($value) >= 1) {
             $parsed_source[$true_counter] = $value;
             $true_counter++;
         }
     }
     Fw_Request::setGet('language', 'ua');
     $first = array_shift($parsed_source);
     if (strlen($first) == 2) {
         if ($first == 'ru') {
             Fw_Request::setGet('language', $first);
         } else {
             if (empty($parsed_source)) {
                 Fw_Request::redirect(C::ds, 301);
             } else {
                 Fw_Request::redirect(C::ds . implode("/", $parsed_source) . C::ds, 301);
             }
         }
         Fw_Request::setGet('controller', array_shift($parsed_source));
     } else {
         //Fw_Request::redirect('/ua/');
         Fw_Request::setGet('controller', $first);
     }
     $hard_controller = Fw_Request::get('hard_controller', null);
     if (!is_null($hard_controller)) {
         Fw_Request::setGet('controller', $hard_controller);
     }
     if (empty($parsed_source)) {
         return;
     }
     $counter = 0;
     foreach ($parsed_source as $key => $value) {
         Fw_Request::setGet($counter, $value);
         $counter++;
         unset($parsed_source[$key]);
     }
     unset($counter);
     unset($this->_source_uri);
     unset($parsed_source);
 }
예제 #4
0
파일: admin.php 프로젝트: roket007/bicycle
 public function dropprojectphotoAction()
 {
     $img = Fw_Request::post('pp_src', NULL);
     $id = Fw_Request::post('pp_id', NULL);
     $p_id = Fw_Request::post('pp_p_id', NULL);
     if (!$this->model->dropProjectPhoto($id)) {
         return;
     }
     if (!empty($img)) {
         $config = C::getConfig('img');
         $del_file = realpath(APPLICATION_PATH . '/../' . C::pub_dir . '/images') . C::ds . $img;
         if (is_file($del_file)) {
             unlink($del_file);
         }
         foreach ($config['size'] as $sizes) {
             $del_file = realpath(APPLICATION_PATH . '/../' . C::pub_dir . '/images/cropr_' . $sizes) . C::ds . $img;
             if (is_file($del_file)) {
                 unlink($del_file);
             }
         }
     }
     $this->rmCache(APPLICATION_PATH . C::ds . 'cache' . C::ds . 'project');
     $this->rmCache(APPLICATION_PATH . C::ds . 'cache' . C::ds . 'done');
     Fw_Request::redirect('/admin/projectphotos/' . $p_id . DS);
     $this->view->render(false);
 }
예제 #5
0
 public function indexAction()
 {
     $id = Fw_Request::get('id', null);
     $alias = Fw_Request::get('alias', null);
     if (!is_null($id)) {
         $this->view->setLayout('projects', 'project');
         $this->view->data = $this->model->getProject($id);
         if (!isset($this->view->data['pl_alias']) || $this->view->data['pl_alias'] !== $alias) {
             throw new Fw_Exception('[f:"' . __FILE__ . '", l:"' . __LINE__ . '"] Страница не найдена', 404);
         }
         if ($this->view->data['p_current'] >= $this->view->data['p_need']) {
             Fw_Request::redirect(C::uri(array('done', $this->view->data['p_id'] . '-' . $this->view->data['pl_alias'])), 301);
         }
         $this->view->ru_lang_url = '/ru/projects/' . $this->view->data['p_id'] . '-' . $this->view->data['ru_alias'] . '/';
         $this->view->ua_lang_url = '/projects/' . $this->view->data['p_id'] . '-' . $this->view->data['ua_alias'] . '/';
         $this->view->donors_data = $this->model->getDonorsByProject($id, 0);
         $this->view->setHead('title', array(), $this->view->data['pl_title'], true);
         $this->view->setHead('meta', array('name' => 'description', 'content' => $this->view->data['pl_description']), '', false);
         $this->view->setHead('meta', array('name' => 'keywords', 'content' => $this->view->data['pl_keywords']), '', false);
         $breadcrumb = unserialize(Fw_Model::getInstance()->getModel('blocks')->getBreadCrumbs($this->name, $this->actionName));
         array_push($breadcrumb, array('name' => $this->view->data['pl_title']));
         $this->view->setBlocks(array('breadcrumbs' => array('data' => serialize($breadcrumb))));
     } else {
         $this->view->data = $this->model->getOrderProjects('new', 0, 10);
         $this->view->setBlocks(array('breadcrumbs'));
     }
     $this->view->render();
 }
예제 #6
0
파일: user.php 프로젝트: roket007/bicycle
 public function registrationAction()
 {
     if (Fw_Auth::isValid()) {
         Fw_Request::redirect(C::uri(array('donors', Fw_Auth::get('id'))));
     }
     $antispam = Fw_Request::post('antispam', NULL);
     $data = array();
     $error = array();
     if (!is_null($antispam)) {
         if ($this->checkSecureKey($antispam)) {
             $data['name'] = Fw_Request::post('name', NULL);
             $data['surname'] = Fw_Request::post('surname', NULL);
             $data['email'] = Fw_Request::post('email', NULL);
             $data['login'] = Fw_Request::post('login', NULL);
             $data['password'] = Fw_Request::post('password', NULL);
             $data['repassword'] = Fw_Request::post('repassword', NULL);
             if (!preg_match("/^[\\p{L}]{2,50}\$/ui", $data['name'])) {
                 $error['name'] = C::getLanguageString('registration_only_chars_name');
             }
             if (!preg_match("/^[\\p{L}]{2,50}\$/ui", $data['surname'])) {
                 $error['surname'] = C::getLanguageString('registration_only_chars_surname');
             }
             if (!preg_match("/^[-a-z0-9!#\$%&'*+\\/=?^_`{|}~]+(?:\\.[-a-z0-9!#\$%&'*+\\/=?^_`{|}~]+)*@(?:[a-z0-9]([-a-z0-9]{0,61}[a-z0-9])?\\.)*(?:aero|arpa|asia|biz|cat|com|coop|edu|gov|info|int|jobs|mil|mobi|museum|name|net|org|pro|tel|travel|[a-z][a-z])\$/ui", $data['email'])) {
                 $error['email'] = C::getLanguageString('contact_error_email');
             } elseif ($this->model->chekEmailRepeat($data['email'])) {
                 $error['email'] = C::getLanguageString('registration_repeat_email');
             }
             if (!preg_match("/^[a-z\\d_\\-]{2,50}\$/ui", $data['login'])) {
                 $error['login'] = C::getLanguageString('contact_error_login');
             } elseif ($this->model->chekLoginRepeat($data['login'])) {
                 $error['login'] = C::getLanguageString('registration_repeat_login');
             }
             if (!preg_match("/^.{8,64}\$/ui", $data['password'])) {
                 $error['password'] = C::getLanguageString('registration_password_error');
             }
             if (sha1($data['password']) !== sha1($data['repassword'])) {
                 $error['repassword'] = C::getLanguageString('registration_repassword_error');
             }
             if (empty($error)) {
                 if (!$this->model->registrationNewUser($data)) {
                     throw new Fw_Exception('[f:"' . __FILE__ . '", l:"' . __LINE__ . '"] Ошибка сохранения пользователя', 500);
                 }
                 $this->sendConfirmationMail($data);
                 Fw_Request::redirect(C::uri(array('user', 'success')));
             } else {
                 $this->view->error = $error;
                 $this->view->data = $data;
             }
         } else {
             die('You\'r bot');
         }
     }
     $this->view->setBlocks(array('breadcrumbs'));
     $this->view->antispam = $this->createSecureKey();
     $this->view->render();
 }
예제 #7
0
파일: donors.php 프로젝트: roket007/bicycle
 public function indexAction()
 {
     $id = Fw_Request::get('id', null);
     if (!is_null($id)) {
         $this->view->setLayout('donors', 'donor');
         $this->view->data = $this->model->getDonor($id);
         if (!isset($this->view->data['u_id']) || !is_numeric($this->view->data['u_id'])) {
             throw new Fw_Exception('[f:"' . __FILE__ . '", l:"' . __LINE__ . '"] Страница не найдена', 404);
         }
         $name_bread = $this->view->data['u_surname'] . ' ' . $this->view->data['u_name'];
         if (Fw_Auth::isValid() && Fw_Auth::get('id') == $id) {
             $this->view->error = array();
             $data = array();
             $name = Fw_Request::post('u_name', null);
             $antispam = Fw_Request::post('antispam', null);
             $surname = Fw_Request::post('u_surname', null);
             $address = Fw_Request::post('u_address', null);
             $img = Fw_Request::getFile('u_img', null);
             $information = Fw_Request::postNoHtml('u_information', 0, 1500);
             if (!is_null($antispam)) {
                 if (!preg_match("/^[\\p{L}]{2,100}\$/ui", $name)) {
                     $this->view->error['u_name'] = C::getLanguageString('registration_only_chars_name');
                 }
                 $data['u_name'] = $name;
                 if (!preg_match("/^[\\p{L}]{2,100}\$/ui", $surname)) {
                     $this->view->error['u_surname'] = C::getLanguageString('registration_only_chars_surname');
                 }
                 $data['u_surname'] = $surname;
                 if (!empty($address)) {
                     if (!preg_match("/^[^\\s][\\.\\p{L}\\d\\,\\-\\s]{0,100}\$/ui", $address)) {
                         $this->view->error['u_address'] = C::getLanguageString('registration_only_chars_name');
                     }
                     $data['u_address'] = $address;
                 } else {
                     $data['u_address'] = '';
                 }
                 $data['u_information'] = !is_null($information) ? $information : '';
                 if (!is_null($img) && isset($img['name']) && !empty($img['name'])) {
                     $type = array_pop(explode(".", $img['name']));
                     if (in_array(strtolower($type), array('png', 'jpeg', 'jpg', 'gif'))) {
                         if ($img['size'] > 1024 * 1024 * 2) {
                             $this->view->error['u_img'] = C::getLanguageString('wrong_file_size');
                         } else {
                             $new_file_name = $data['u_img'] = sha1($img['name'] . time()) . '.' . $type;
                             $to_path = realpath(APPLICATION_PATH . '/../' . C::pub_dir . '/images') . C::ds . $new_file_name;
                             if (move_uploaded_file($img['tmp_name'], $to_path) === false) {
                                 throw new Fw_Exception('[f:"' . __FILE__ . '", l:"' . __LINE__ . '"] Ошибка загрузки аватара', 500);
                             }
                             if (!empty($this->view->data['u_img']) && $this->view->data['u_img'] !== 'anonim_donor.jpg') {
                                 $config = C::getConfig('img');
                                 $del_file = realpath(APPLICATION_PATH . '/../' . C::pub_dir . '/images') . C::ds . $this->view->data['u_img'];
                                 if (is_file($del_file)) {
                                     unlink($del_file);
                                 }
                                 foreach ($config['size'] as $sizes) {
                                     $del_file = realpath(APPLICATION_PATH . '/../' . C::pub_dir . '/images/cropr_' . $sizes) . C::ds . $this->view->data['u_img'];
                                     if (is_file($del_file)) {
                                         unlink($del_file);
                                     }
                                 }
                             }
                         }
                     } else {
                         $this->view->error['u_img'] = C::getLanguageString('wrong_file_format');
                     }
                 }
                 if (empty($this->view->error)) {
                     if (!Fw_Model::getInstance()->getModel('user')->updateUserData($data)) {
                         throw new Fw_Exception('[f:"' . __FILE__ . '", l:"' . __LINE__ . '"] Ошибка обновления данных пользователя', 500);
                     }
                     Fw_Request::redirect(C::uri(array('donors', $id)));
                 }
             }
             $this->view->antispam = base64_encode(time());
         }
         if (!empty($this->view->data['pl_description'])) {
             $description = strip_tags($this->view->data['pl_description']);
             $description = trim($description);
             if (!empty($description)) {
                 if (mb_strlen($description, 'UTF-8') > 240) {
                     $description = substr($description, 0, 240) . '...';
                 }
                 $this->view->setHead('meta', array('name' => 'description', 'content' => $description), '', false);
             }
         }
         $this->view->ru_lang_url = '/ru/donors/' . $this->view->data['u_id'] . DS;
         $this->view->ua_lang_url = '/ua/donors/' . $this->view->data['u_id'] . DS;
         $this->view->projects_data = $this->model->getProjectsByDonor($id);
         $this->view->setHead('title', array(), $name_bread . ' ' . C::getLanguageString('donor_h1'), true);
         $this->view->setHead('meta', array('name' => 'keywords', 'content' => strtolower(C::getLanguageString('donor')) . ', ' . $name_bread), '', false);
         $breadcrumb = unserialize(Fw_Model::getInstance()->getModel('blocks')->getBreadCrumbs($this->name, $this->actionName));
         if ($breadcrumb) {
             array_push($breadcrumb, array('name' => $name_bread));
             $this->view->setBlocks(array('breadcrumbs' => array('data' => serialize($breadcrumb))));
         }
     } else {
         $this->view->data = $this->model->getOrderDonors('new', 0, 10);
         $this->view->setBlocks(array('breadcrumbs'));
     }
     $this->view->render();
 }