Ejemplo n.º 1
0
 public function render()
 {
     $this->user_count = $this->getUserCount();
     $this->money_count = $this->getMoneyCount();
     $this->current = Fw_Request::get('controller', 'index');
     parent::render(__CLASS__);
 }
Ejemplo n.º 2
0
 public function __construct($message, $code)
 {
     Log::add($message . 'URI: ' . $_SERVER['REQUEST_URI'], $code);
     if (!DEV) {
         switch ($code) {
             case 500:
                 Fw_Request::setGet('hard_controller', 'err');
                 Fw_Request::setGet('hard_action', 'error' . $code);
                 $error_app = new Application();
                 $error_app->run();
                 die;
                 break;
             case 404:
             default:
                 Fw_Request::setGet('hard_controller', 'err');
                 Fw_Request::setGet('hard_action', 'error' . $code);
                 $error_app = new Application();
                 $error_app->run();
                 die;
                 break;
         }
     }
     $code = 0;
     parent::__construct($message);
 }
Ejemplo n.º 3
0
 public function indexAction()
 {
     $id = Fw_Request::get('id', null);
     $alias = Fw_Request::get('alias', null);
     if (!is_null($id)) {
         $this->view->setLayout('done', 'project');
         $this->view->data = $this->model->getProject($id, true);
         if (!isset($this->view->data['pl_alias']) || $this->view->data['pl_alias'] !== $alias) {
             throw new Fw_Exception('[f:"' . __FILE__ . '", l:"' . __LINE__ . '"] Страница не найдена', 404);
         }
         $this->view->ru_lang_url = '/ru/done/' . $this->view->data['p_id'] . '-' . $this->view->data['ru_alias'] . '/';
         $this->view->ua_lang_url = '/ua/done/' . $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, true);
         $this->view->setBlocks(array('breadcrumbs'));
     }
     $this->view->render();
 }
Ejemplo n.º 4
0
 public function getMenuItems()
 {
     $model = Fw_Model::getInstance();
     $model->setQuery("\n                SELECT \n                    m_id, \n                    m_name_" . Fw_Request::get('language') . " AS m_name,\n                    m_url\n                FROM menu \n                WHERE m_state = 1");
     $model->sendQuery(true, 3600 * 24, array('blocks', 'menu'));
     return $model->fetchObjects();
 }
Ejemplo n.º 5
0
 public function loadStaticPage($controller = null, $action = null)
 {
     $lang = Fw_Request::get('language', 'ua');
     $this->sql->setQuery("\n            SELECT \n                sp.sp_body\n            FROM static_page AS sp\n            LEFT JOIN meta_data_cotrollers AS mdc ON mdc.mdc_id = sp.sp_mdc_id \n            LEFT JOIN meta_data_action AS mda ON mda.mda_id = sp.sp_mda_id AND mda.mda_mdc_id = mdc.mdc_id \n            WHERE\n                sp.sp_lang = '{$lang}'\n                AND mdc.mdc_controller = '{$controller}'\n                AND mda.mda_action = '{$action}'\n            LIMIT 1\n        ");
     $this->sql->sendQuery(true, 24 * 3600, array('default', 'custom_page'));
     $result = $this->sql->fetchObjects();
     return isset($result[0]) ? $result[0]->sp_body : NULL;
 }
Ejemplo n.º 6
0
 public function indexAction()
 {
     $this->view->error = Fw_Request::get('error', null);
     $this->view->query = Fw_Request::get('search_query', null);
     if (!$this->view->error) {
         $this->view->data = $this->model->searchByQuery($this->view->query);
     }
     $this->view->render();
 }
Ejemplo n.º 7
0
 public function setAction()
 {
     $param_0 = Fw_Request::get(0, 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)) {
         return false;
     }
 }
Ejemplo n.º 8
0
 public function getOrderDonors($order_by = 'new', $offset = 0, $limit = 10)
 {
     if ($order_by == 'new') {
         $order_query_part = 'date_reg';
     } elseif ($order_by == 'project') {
         $order_query_part = 'count_pays';
     } elseif ($order_by == 'count') {
         $order_query_part = 'money_sum';
     }
     $lang = Fw_Request::get('language', 'ua');
     $query = "\n            SELECT\n                u.u_id AS id,\n                u.u_name AS name,\n                u.u_surname AS surname,\n                u.u_date_reg AS date_reg,\n                u.u_img AS img,\n                SUM(pp.pp_sum) AS money_sum,\n                COUNT(DISTINCT pp.pp_p_id) AS count_pays,\n                ( SELECT MAX(pp.pp_data) ) AS last_pay_date,\n                GROUP_CONCAT(DISTINCT pp.pp_sum ORDER BY pp.pp_data DESC) AS last_pay_sum\n            FROM users AS u\n            LEFT JOIN projects_pays AS pp ON pp.pp_u_id = u.u_id\n            WHERE \n                u.u_activate = 1\n            GROUP BY u.u_id\n            HAVING money_sum IS NOT NULL\n            ORDER BY {$order_query_part} DESC\n            LIMIT {$offset}, {$limit}\n        ";
     $this->sql->setQuery($query);
     $this->sql->sendQuery(true, 600, array('donors', 'list'));
     return $this->sql->fetchObjects();
 }
Ejemplo n.º 9
0
 public function getOrderProjects($order_by = 'new', $offset = 0, $limit = 10, $only_ended = false)
 {
     if ($order_by == 'new') {
         $order_query_part = 'p.p_date_create';
     } elseif ($order_by == 'vote') {
         $order_query_part = 'p.p_count_vote';
     } elseif ($order_by == 'need') {
         $order_query_part = '( (p.p_current / p.p_need) * 100 )';
     }
     $lang = Fw_Request::get('language', 'ua');
     $query = "\n            SELECT \n                p.p_id AS id,\n                p.p_date_create AS date_start,\n                p.p_need AS money_need,\n                p.p_current AS money_now,\n                p.p_count_vote AS count_vote,\n                p.p_avg_vote AS avg_vote,\n                pl.pl_title AS title,\n                pl.pl_text AS text,\n                pl.pl_description AS description,\n                pl.pl_alias AS alias,\n                GROUP_CONCAT(DISTINCT pp.pp_src ORDER BY pp.pp_ord SEPARATOR ',') AS images\n            FROM projects AS p\n            LEFT JOIN projects_lang AS pl ON pl.pl_p_id = p.p_id AND pl.pl_lang = '{$lang}'\n            LEFT JOIN projects_photos AS pp ON pp.pp_p_id = p.p_id\n            WHERE \n                p.p_state = 1\n                AND p.p_current " . ($only_ended ? " >= " : " < ") . " p.p_need\n            GROUP BY p.p_id\n            ORDER BY {$order_query_part} DESC\n            LIMIT {$offset}, {$limit}\n        ";
     $this->sql->setQuery($query);
     $this->sql->sendQuery(true, 1200, array('done', 'list', $lang));
     return $this->sql->fetchObjects();
 }
Ejemplo n.º 10
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();
 }
Ejemplo n.º 11
0
 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);
 }
Ejemplo n.º 12
0
 public function init()
 {
     $res = true;
     $this->img_conf = C::getConfig('img');
     $this->_def_width = 25;
     $this->_def_height = 25;
     $this->_def_img_name = 'default.jpg';
     $this->_def_img_directory = 'images';
     $this->_operation_arr = array('res', 'crop', 'cropr', 'cropg');
     $this->_pic_path = realpath(APPLICATION_PATH . '/../' . C::pub_dir . '/images');
     $params = array();
     $params['name'] = Fw_Request::get('name', '');
     $params['size'] = Fw_Request::get('size', '');
     if (!empty($params['name'])) {
         $this->_img_name = $params['name'];
     } else {
         $res = false;
     }
     if (!empty($params['size'])) {
         $p_arr = explode('_', $params['size']);
         if (!empty($p_arr[0]) && in_array($p_arr[0], $this->_operation_arr)) {
             $this->_operation = $p_arr[0];
             if (!empty($p_arr[1]) && in_array($p_arr[1], $this->img_conf['size'])) {
                 $size_arr = explode('x', $p_arr[1]);
                 if (is_numeric($size_arr[0]) && is_numeric($size_arr[1])) {
                     $this->_size[0] = (int) $size_arr[0];
                     $this->_size[1] = (int) $size_arr[1];
                 }
             } else {
                 $res = false;
             }
         } else {
             $res = false;
         }
     } else {
         $res = false;
     }
     if (!$res) {
         header("Status: 404 Not Found");
         exit;
     }
 }
Ejemplo n.º 13
0
 public function confirmAction()
 {
     $key = base64_decode(Fw_Request::get('key', NULL));
     if (strpos($key, '_') === false) {
         throw new Fw_Exception('[f:"' . __FILE__ . '", l:"' . __LINE__ . '"] Ошибка подтверждения регистрации type 1', 404);
     }
     list($email, $hash) = explode("_", $key);
     if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
         throw new Fw_Exception('[f:"' . __FILE__ . '", l:"' . __LINE__ . '"] Ошибка подтверждения регистрации type 2 - ' . $email, 404);
     }
     $user_data = $this->model->getUserByEmail($email);
     if (empty($user_data)) {
         throw new Fw_Exception('[f:"' . __FILE__ . '", l:"' . __LINE__ . '"] Ошибка подтверждения регистрации type 3 - ' . $email, 404);
     }
     if ($user_data['u_activate']) {
         throw new Fw_Exception('[f:"' . __FILE__ . '", l:"' . __LINE__ . '"] Попытка повторного подтверждения регистрации ' . $email, 404);
     }
     if ($hash !== sha1($user_data['u_email'] . $user_data['u_login'] . C::site_host)) {
         throw new Fw_Exception('[f:"' . __FILE__ . '", l:"' . __LINE__ . '"] Ошибка подтверждения регистрации type 4 - ' . $email, 404);
     }
     if (!$this->model->activateUser($user_data['u_id'])) {
         throw new Fw_Exception('[f:"' . __FILE__ . '", l:"' . __LINE__ . '"] Ошибка активации пользователя u_id = ' . $user_data['u_id'], 500);
     }
     $this->view->setBlocks(array('breadcrumbs'));
     $this->view->render();
 }
Ejemplo n.º 14
0
if (Fw_Request::get('language') == 'ua') {
    ?>
                                УКР 
                            <?php 
} else {
    ?>
                                <a href="<?php 
    echo isset($this->ua_lang_url) ? $this->ua_lang_url : C::getCurrentUriByLang();
    ?>
" title="Українська версія">УКР</a>
                            <?php 
}
?>
                            <img alt="" src="/img/rus_flag.png" width="20" height="20" /> 
                            <?php 
if (Fw_Request::get('language') == 'ru') {
    ?>
                                РУС 
                            <?php 
} else {
    ?>
                                <a href="<?php 
    echo isset($this->ru_lang_url) ? $this->ru_lang_url : C::getCurrentUriByLang('ru');
    ?>
" title="Российская версия сайта">РУС</a>
                            <?php 
}
?>
                        </div>   
                    </div>
                    <div id="right_top" class="grid-50 mobile-grid-50 tablet-grid-50">
Ejemplo n.º 15
0
 public function donorsAction()
 {
     $id = Fw_Request::get('id', NULL);
     $offset = Fw_Request::get('offset', 0);
     $this->view->donors_data = $this->model->getDonorsByProject($id, $offset);
     $this->view->render(false);
 }
Ejemplo n.º 16
0
 public function langAction()
 {
     $this->view->const = array();
     if (Fw_Request::post('save', false)) {
         $data = Fw_Request::post('data', NULL);
         $html = array();
         foreach ($data as $lang => $consts) {
             $html[] = '[' . $lang . ']';
             foreach ($consts as $const => $value) {
                 $html[] = $const . ' = "' . stripslashes(str_replace(array('"'), array("'"), html_entity_decode($value, ENT_QUOTES, "UTF-8"))) . '"';
             }
         }
         C::saveConfig('language', implode("\n", $html));
     }
     $langs = C::getConfig('language', false);
     foreach ($langs as $lang => $value) {
         foreach ($value as $const => $translate) {
             $this->view->const[$const][$lang] = htmlentities($translate, ENT_QUOTES, "UTF-8");
         }
         if (!in_array($lang, $this->view->langs)) {
             $this->view->langs[] = $lang;
         }
     }
     $this->view->render();
 }
Ejemplo n.º 17
0
 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();
 }