Exemple #1
0
 protected static function handler()
 {
     try {
         $found_a_match = false;
         foreach (self::$_urlpatterns as $apps) {
             if (self::patterns($apps[0]) == false) {
                 continue;
             } else {
                 $found_a_match = true;
             }
             return;
         }
         if ($found_a_match === false) {
             throw new PhxException('404');
         }
     } catch (Exception $e) {
         switch ($e->getMessage()) {
             case '404':
                 $v = new Views(new Template('error', '404.phtml'));
                 $v->display();
                 break;
             default:
                 echo "<h3>Error</h3>";
                 echo "<p>{$e->getMessage()}</p>";
                 die;
         }
     }
 }
 public function action_search()
 {
     //var_dump($_POST);
     //Складываем в массив выбранные параметры сортировки
     $arr = [];
     foreach ($_POST as $key => $val) {
         if ($val != '0') {
             $arr[$key] = $val;
         }
     }
     //Если параметры не выбраны - редирект на главную
     if (empty($arr)) {
         header('Location: http://naitidruzei.ru');
     } else {
         // Количество статей на страницу.
         $count = isset($_GET['count']) ? $_GET['count'] : 5;
         // Смещение для БД
         $start = isset($_GET['start']) ? $_GET['start'] : 0;
         $worker = new News();
         //Получаем кол-во строк по нашей выборке
         $all = $worker->getNumRowsSearch($arr);
         // Получаем результат запрса по нашей выборке
         $items = $worker->selectLimitSearch($count, $start, $arr);
         // Создаем блок ссылок с постраничной навигацией:
         $pagenav = new SimPageNav();
         // Формирурем шаблон вывода
         $viewer = new Views();
         $viewer->items = $items;
         $viewer->pagenav = $pagenav->getLinks($all, $count, $start, 10, 'start');
         $viewer->display('all_views');
     }
 }
Exemple #3
0
 function display($view = '')
 {
     if ($view == 'get_presence') {
         $this->{$view}();
     } elseif ($view == 'export_muc_logs') {
         $this->{$view}();
     } else {
         parent::display($view);
     }
 }
 function display($view = '')
 {
     switch ($view) {
         case 'ajax_projects':
             $this->{$view}();
             break;
         case 'browse':
             $this->_searchPlugins();
         default:
             parent::display($view);
     }
 }
Exemple #5
0
 public function run()
 {
     $response = Router::get();
     if (is_array($response)) {
         $Class = $response['class'];
         $method = $response['method'];
         require_once $_SERVER['DOCUMENT_ROOT'] . '/views/' . $Class . '.php';
         $Class = sprintf('\\KeyZ\\%s', $Class);
         Models::connect();
         Session::start();
         // Запускаем обработчик запроса и получаем от него данные для отображения
         // Выводим данные на экран через шаблонизатор
         Views::display($Class::$method($response['params']));
     } else {
         printf("<b>Error 404:</b> Page not found");
         exit;
     }
 }
 public function action_update()
 {
     Controller_admin::check_user();
     $items = News::get_one($_GET['id']);
     $viewer = new Views();
     $viewer->items = $items;
     $viewer->display('edit_views');
     if (!empty($_POST['delete'])) {
         $delete = new Controller_add();
         $delete->deleteNews();
     }
     if (!empty($_POST['title'])) {
         $article = new Add();
         $article->title = $_POST['title'];
         $article->content = $_POST['content'];
         $article->id_article = $_GET['id'];
         $article->save();
     }
 }
 public function action_one()
 {
     // Получаем все комментарии для указанной статьи
     $comments = Comments::getComments($_GET['id']);
     // Получаем статью
     $items = News::get_one($_GET['id']);
     // Формируем шаблон вывода
     $viewer = new Views();
     $viewer->items = $items;
     $viewer->comments = $comments;
     // Если был отправлен комментарий к статье - запускаем функуцию обработчик
     if (!empty($_POST)) {
         $viewer->name = $_POST['name'];
         $viewer->email = $_POST['email'];
         $viewer->text = $_POST['text'];
         $viewer->error = Controller_comment::newComment();
     }
     // Выводим
     $viewer->display('articles_views');
 }
 public function DisplayWordpressPost()
 {
     Phalanx::loadController('LoginController');
     $loginController = new LoginController();
     $this->isLoggedIn = $loginController->isLoggedIn();
     Phalanx::loadClasses('public.Posts', 'public.PostComments');
     $post = Posts::GetWPPostData($this->get->post_id, $this->session->user->id, true);
     $slug = mb_strtolower(preg_replace('/--+/u', '-', preg_replace('/[^\\w\\-]+/u', '-', $post->content->post_title)));
     if ($slug != $this->get->slug) {
         Request::redirect_301(HOST . "site/post/{$this->get->post_id}-{$slug}");
     }
     $v = new Views();
     $v->title = $post->content->post_title;
     $v->content = $post->content->post_content;
     $v->comments = $post->comments;
     $v->comments_array = PostComments::get($post->post_id);
     $v->replies = $post->replies;
     $v->post_id = $post->post_id;
     $v->rating = $post->rating;
     $v->when = Date::RelativeTime($post->content->post_date);
     $v->my_rating = $p->my_rating;
     $v->current_user = $this->session->user->login;
     $v->is_favorite = $p->is_favorite;
     $content = $v->render("post_body_wp.phtml");
     $template = new Template("default");
     $template->og = new stdClass();
     $template->og->title = $v->title;
     $template->og->description = substr(strip_tags($content), 0, 250);
     //$template->og->img = MEDIA_DIR . 'images/avatar/big/' . $profile_data->aditional_info->avatar;
     if (!$this->isLoggedIn) {
         $template->show_login_bar = true;
     }
     $v = new Views($template);
     $v->data = new stdClass();
     $v->data->post = $content;
     $v->display("single_post_display.phtml");
 }
 public function Export()
 {
     Phalanx::loadClasses('Profile', 'Badges');
     $profile = Profile::get_profile($this->session->user->login, 0, 0, 0, 0, 1, 1, 1);
     $profile->badges = Badges::from_user($this->sessio->user->id, false);
     $t = new Template("export");
     $t->show_login_bar = true;
     $userPosts = Posts::exportFromUser($this->session->user->id);
     $postsImages = array();
     $avatarImages = array();
     $posts = array();
     Phalanx::loadExtension('simple_html_dom');
     foreach ($userPosts as $key => $each) {
         $html = str_get_html($each->content);
         /*
          * Em alguns casos o objeto não está sendo criado, gerando um fatal error.
          * Conteúdo vazio? Estranho, ainda não sei o que está rolando.
          * Isso aqui resolve.
          * */
         if (is_object($html)) {
             $images = $html->find('img');
             foreach ($images as &$image) {
                 if (stripos($image, HOST)) {
                     $postsImages[] = basename($image->src);
                     $image->src = "./images/posts/" . basename($image->src);
                 }
             }
             $each->content = $html;
         }
         $avatarImages[] = $each->avatar;
         $v = new Views();
         $v->accept_nsfw = Profile::acceptNSFW($this->session->user->id);
         $v->current_user = $this->session->user->login;
         $v->user = $each->user;
         $v->name = $each->name;
         $v->when = $each->date;
         $v->title = $each->title;
         $v->content = $each->content;
         $v->comments = $each->comments;
         $v->comments_array = $each->comments_array;
         $v->replies = $each->replies;
         $v->post_id = $each->id;
         $v->original_id = $each->original_id;
         $v->is_reblogged = $each->is_reblogged;
         $v->avatar = $each->avatar;
         $v->rating = $each->rating;
         $v->my_rating = $each->my_rating;
         $v->categories = $each->categories;
         $v->its_mine = $profile_data->id == $this->session->user->id ? true : false;
         $v->is_favorite = $each->is_favorite;
         $v->user_points = $each->user_points;
         foreach ($each->comments_array as $eachComment) {
             $avatarImages[] = $eachComment->user->avatar;
             foreach ($eachComment->replies as $eachReply) {
                 $avatarImages[] = $eachReply->user->avatar;
             }
         }
         if (!empty($each->original_id)) {
             //Se o post for um reblog, então o conteúdo dele deve ser o do reblogado, mostrando as ações
             $originalPost = Posts::from_user(false, $v->original_id);
             $originalPost = reset($originalPost);
             $v->content = $originalPost->content;
             $v->title = $originalPost->title;
             $v->reblogged_from = $originalPost->user;
             $v->reblog_avatar = $originalPost->avatar;
             $v->reblog_points = $originalPost->user_points;
             $v->original_date = $originalPost->date;
             $v->comments = $originalPost->comments;
             $v->replies = $originalPost->replies;
             $v->is_favorite = $originalPost->is_favorite;
             $v->categories = $originalPost->categories;
             $v->rating = $originalPost->rating;
             $v->id = $v->post_id;
             $v->post_id = $originalPost->id;
         }
         $content = $v->render("export/post_body.phtml");
         $posts[] = $content;
     }
     $v = new Views($t);
     $v->data = $profile;
     $v->data->timeline = $posts;
     ob_start();
     $v->display("export/profile.phtml");
     $profile_html_data = ob_get_contents();
     ob_end_clean();
     if (!is_dir(TMP_DIR . DIRECTORY_SEPARATOR . 'export')) {
         mkdir(TMP_DIR . DIRECTORY_SEPARATOR . 'export', 0755, true);
     }
     $dirname = TMP_DIR . DIRECTORY_SEPARATOR . 'export' . DIRECTORY_SEPARATOR . $this->session->user->login . DIRECTORY_SEPARATOR;
     if (!is_dir($dirname)) {
         mkdir($dirname, 0755, true);
     }
     $filename = "perfil-{$this->session->user->login}.html";
     file_put_contents($dirname . $filename, $profile_html_data);
     $zip = new ZipArchive();
     if ($zip->open("{$dirname}data.zip", ZipArchive::CREATE) === TRUE) {
         $zip->addEmptyDir('css');
         foreach (glob(TEMPLATE_DIR . '/export/css/*') as $file) {
             $zip->addFile($file, "/css/" . basename($file));
         }
         $zip->addEmptyDir('js');
         foreach (glob(TEMPLATE_DIR . '/export/js/*') as $file) {
             $zip->addFile($file, "/js/" . basename($file));
         }
         $zip->addEmptyDir('fonts');
         $zip->addEmptyDir('fonts/Engschrift');
         foreach (glob(TEMPLATE_DIR . '/export/fonts/Engschrift/*') as $file) {
             $zip->addFile($file, "/fonts/Engschrift/" . basename($file));
         }
         $zip->addEmptyDir('images');
         foreach (glob(TEMPLATE_DIR . '/export/images/*.*') as $file) {
             $zip->addFile($file, "/images/" . basename($file));
         }
         $zip->addEmptyDir('images/socialnetworks');
         foreach (glob(TEMPLATE_DIR . '/export/images/socialnetworks/*') as $file) {
             $zip->addFile($file, "/images/socialnetworks/" . basename($file));
         }
         $zip->addEmptyDir('images/images');
         foreach (glob(TEMPLATE_DIR . '/export/images/images/*') as $file) {
             $zip->addFile($file, "/images/images/" . basename($file));
         }
         $zip->addEmptyDir('images/avatar');
         $zip->addEmptyDir('images/avatar/big');
         $zip->addEmptyDir('images/avatar/small');
         $zip->addEmptyDir('images/avatar/square');
         foreach ($avatarImages as $avatar) {
             $zip->addFile(AVATAR_UPLOAD_DIR . "/big/{$avatar}", "/images/avatar/big/{$avatar}");
             $zip->addFile(AVATAR_UPLOAD_DIR . "/small/{$avatar}", "/images/avatar/small/{$avatar}");
             $zip->addFile(AVATAR_UPLOAD_DIR . "/square/{$avatar}", "/images/avatar/square/{$avatar}");
         }
         $zip->addEmptyDir('images/posts');
         foreach ($postsImages as $image) {
             $zip->addFile(POST_IMAGES_UPLOAD_DIR . "/{$image}", "/images/posts/{$image}");
         }
         $zip->addEmptyDir('images/badges');
         foreach (glob(ROOT . PROJECT_DIR . '/media/images/badges/*') as $file) {
             $zip->addFile($file, "/images/badges/" . basename($file));
         }
         $zip->addFile("{$dirname}{$filename}", "/{$filename}");
     }
     $zip->close();
     header("Content-disposition: attachment; filename={$this->session->user->login}.zip");
     header("Content-type: application/zip");
     readfile("{$dirname}data.zip");
     $t = new Template("export", "thankyou.phtml");
     $v = new Views($t);
     $v->display("");
     $c = new Cookies();
     $c->setExpire(strtotime("+15 days"));
     $c->data_exported = 1;
 }
 public function TimeLimitExceeded()
 {
     $t = new Template("sign");
     $v = new Views($t);
     $v->display('reactivate_account_timelimit_exceeded.phtml');
 }
    public function action_update()
    {
        $items = News::get_one($_GET['id']);
        $viewer = new Views;
        $viewer->items = $items;
        $viewer->display ('edit_views');

        //Обрабатываем нажатие кнопки "удалить"
        if (!empty($_POST['delete']))
        {
            $delete = new Controller_add;
            $delete->deleteNews();
        }

        //Сохраняем изменения
        if (!empty($_POST['title']))
        {
            $article = new Add;
            $article->title = $_POST['title'];
            $article->content = $_POST['content'];
            $article->id_article = $_GET['id'];
            $article->save();
        }
    }