Exemplo n.º 1
0
 public function before()
 {
     //$this->redirect('http://ehistory.kz/manage');
     parent::before();
     $this->response->headers('cache-control', 'private');
     // creating and attaching page metadata
     $this->metadata = new Model_Metadata();
     $this->metadata->title(__(Application::instance()->get('title')), false);
     $this->set('_metadata', $this->metadata);
     Auth::instance()->auto_login();
     if (!Auth::instance()->logged_in()) {
         $this->redirect('manage/auth/login');
     } else {
         $id = Auth::instance()->get_user()->id;
         $user = ORM::factory('user', $id);
         $input = $user->has('roles', ORM::factory('role', array('name' => 'admin'))) || $user->has('roles', ORM::factory('Role', array('name' => 'moderator')));
         $input_redactor = $user->has('roles', ORM::factory('Role', array('name' => 'redactor')));
         if (!$input && !$input_redactor) {
             $this->redirect('/manage/auth/logout');
         }
         if (!$input && (strtolower($this->request->controller()) != 'ehistory' && strtolower($this->request->controller()) != 'language')) {
             $this->redirect('manage/ehistory');
         }
     }
     $this->user = Auth::instance()->get_user();
     if (Request::$initial === Request::$current) {
         $messages = Notify::instance()->get_all_once();
         $this->set('_notifications', $messages);
     }
     $language = Session::instance()->get('_language', 'ru');
     $this->language = in_array($language, array('ru', 'en', 'kz')) ? $language : 'ru';
     I18n::lang($this->language);
     $rr = Request::initial()->uri() . urlencode(URL::query(null, true));
     $rr = trim($rr, '/');
     //$this->metadata->title('Sharua.kz', false);
     $countcomm = ORM::factory('Comment')->where('status', '=', '0')->count_all();
     //смотрим сколько новых коментов
     $this->set('_user', $this->user)->set('_language', $this->language)->set('_return_url', $rr)->set('_countcomm', $countcomm);
     //вносим в переменную количество новых коментов
     $knigi = ORM::factory('Book')->where('category_id', '=', '0')->find_all();
     //смотрим сколько книг без категории
     if ($knigi) {
         if (count($knigi) > 0) {
             $this->set('_uncatcount', count($knigi));
             //вносим в переменную количество книг без категории
         }
     }
     $this->referrer = Request::initial()->referrer();
     if (Message::get()) {
         $this->set('basic_message', Message::display('/message/basic'));
     }
 }
Exemplo n.º 2
0
 /**
  * The paper action: shows the detail son a paper
  */
 function paperAction()
 {
     if (!$this->config->isPhaseOpen(Config::REVIEWING_PHASE)) {
         $this->view->content = $this->texts->reviewer->review_phase_is_closed;
         echo $this->view->render("layout");
         return;
     }
     $reviewTbl = new Review();
     $paperTbl = new Paper();
     $messageTbl = new Message();
     $this->view->setFile("content", "paper.xml");
     $this->view->setBlock("content", "paper_status_link");
     $this->view->setBlock("content", "message", "messages");
     $this->view->setBlock("content", "review", "show_review");
     $this->view->setBlock("review", "review_mark", "review_marks");
     $this->view->setBlock("review", "review_answer", "review_answers");
     $this->view->initial_message = "";
     // Am I an admin? If yes I want a link to the paper status page
     if (!$this->user->isAdmin()) {
         $this->view->paper_status_link = "";
     }
     $texts = $this->zmax_context->texts;
     if (isset($_REQUEST['id_paper']) and $this->config->discussion_mode != Config::NO_DISCUSSION) {
         $idPaper = $this->getRequest()->getParam("id_paper");
         $review = $reviewTbl->find($idPaper, $this->user->id)->current();
         $paper = $paperTbl->find($idPaper)->current();
         $paper->putInView($this->view);
         // Check that the paper is REALLY assigned to the reviewer (or admin)
         if (is_object($review) or $this->user->isAdmin()) {
             // Show all other SUBMITTED reviews, do not propose to see only my review
             $this->view->show_review = "";
             $reviews = $paper->findReview();
             foreach ($reviews as $otherReview) {
                 if (!empty($otherReview->overall)) {
                     $this->view->show_review .= $otherReview->showReview($this->view);
                 }
             }
             // Message submitted ? Store it in the DB
             if (isset($_REQUEST['form_message'])) {
                 $message = $messageTbl->createRow();
                 $message->id_parent = $this->getRequest()->getParam("id_parent");
                 $message->id_user = $this->user->id;
                 $message->id_paper = $this->getRequest()->getParam("id_paper");
                 $message->message = htmlSpecialChars($this->getRequest()->getParam("message"), ENT_NOQUOTES);
                 $message->date = date("Y-m-d H-i-s");
                 $message->save();
                 // And now, we must send the message to the reviewers and to the PC chair.
                 $mail = new Mail(Mail::SOME_USER, $this->texts->mail->subj_new_message . " " . $paper->id, $this->view->getScriptPaths());
                 $mail->loadTemplate($this->lang, "new_message");
                 $mail->setFormat(Mail::FORMAT_HTML);
                 $mail->getEngine()->base_url = $this->view->base_url;
                 $mail->getEngine()->author_first_name = $this->user->first_name;
                 $mail->getEngine()->author_last_name = $this->user->last_name;
                 $paper->putInView($mail->getEngine());
                 $message->putInView($mail->getEngine());
                 // Send the message to the PC chair.
                 $fakeName = "User" . "->first_name";
                 $mail->getEngine()->setVar($fakeName, $this->config->chair_names);
                 $mail->setTo($this->config->chairMail);
                 $mail->send();
                 // Now, mail to each OTHER reviewer
                 $reviews = $paper->findReview();
                 $mailOthers = $comma = "";
                 foreach ($reviews as $review) {
                     if ($review->id_user != $this->user->id) {
                         $reviewer = $review->findParentUser();
                         $reviewer->putInView($mail->getEngine());
                         $mail->setTo($reviewer->email);
                         $mail->send();
                     }
                 }
             }
             // Show the tree of messages
             $this->view->messages = Message::display($paper->id, 0, $this->view);
         } else {
             $this->view->content = "You do not have access to this paper!<br/>";
         }
     } else {
         $this->view->content = "Invalid action<br/>";
     }
     echo $this->view->render("layout");
 }
Exemplo n.º 3
0
<h2><?php 
echo __('Register');
?>
</h2>

<?php 
echo Message::display();
?>

<?php 
echo form::open(NULL, array('class' => 'register'));
?>

<fieldset>
	<dl>
		<dt>
			<?php 
echo form::label('username', 'Username:'******'Must be between 3 and 20 characters.');
?>
</span>
		</dt>
		<dd><?php 
echo form::input('username', $post['username'], array('maxlength' => 20));
?>
</dd>
	</dl>
	
Exemplo n.º 4
0
/**
 * Exception Handler
 *
 * error:   中断程序,提示信息中出现报告bug的链接以及记录到日志文件
 * warning: 中断程序,提示信息中出现报告bug的链接。
 * notice:  不中断程序,错误信息输出到页面的注释中
 *---------------------------------------
 * 用户级的错误处理方式:
 *
 * error:   中断程序,提示信息中出现报告bug的链接以及记录到日志文件
 * warning: 中断程序,提示信息中不包括出错文件及行号等信息
 * notice:  中断程序,提示信息中不包括出错文件及行号等信息。 如何处理链接地址呢?
 *---------------------------------------
 *
 * @param   number  $errno
 * @param   string  $errstr
 * @param   string  $errfile
 * @param   string  $errline
 *
 * @return  void
 */
function exception_handler($errno, $errstr, $errfile, $errline)
{
    if ($errno == 2048 || ($errno & error_reporting()) != $errno) {
        //不再需要通过_at方法来抵制错误
        //错误被屏蔽时就不抛出异常,该处理就允许你在代码中照常使用error_reporting来控制错误报告
        return true;
    }
    if ($errno != E_NOTICE) {
        $msg = new Message($errstr, $errno);
        $errfile = str_replace(ROOT_PATH, '', $errfile);
        if ($errno != E_USER_WARNING && $errno != E_USER_NOTICE) {
            $msg->err_file = $errfile;
            $msg->err_line = $errline;
        }
        /* add report link */
        if ($errno == E_USER_ERROR || $errno == E_ERROR || $errno == E_PARSE || $errno == E_WARNING) {
            $msg->report_link($errno, $errstr, $errfile, $errline);
            put_log($errno, $errstr, $errfile, $errline);
            // 写入错误日志
            $msg->display();
            exit;
        } else {
            $msg->display();
        }
    } else {
        if ($errno == E_NOTICE && (defined('DEBUG_MODE') && DEBUG_MODE > 0)) {
            echo "<div style='font: 14px verdana'><b>Notice:</b> {$errstr}<br/><b>Error File:</b> {$errfile}: [{$errline}]</div>";
        }
    }
    return true;
}
Exemplo n.º 5
0
 public function before()
 {
     parent::before();
     // detecting language, setting it
     //        $this->detect_language();
     //        $this->set('_language', $this->language);
     $this->set('device', $this->detect_device());
     //var_dump($_COOKIE);
     // creating and attaching page metadata
     $this->metadata = new Model_Metadata();
     $this->metadata->title(__(Application::instance()->get('title')), false);
     $this->set('_metadata', $this->metadata);
     $this->set('_token', Security::token());
     // Handles return urls, cropping language out of it (will be appended by url.site at redirect time)
     //        $rr = Request::initial()->uri();
     //        $rr = trim($rr, '/');
     //        $rr = explode('/', $rr);
     //        if (in_array($rr[0], Application::instance()->get('language.list'))) {
     //            array_shift($rr);
     //        }
     //        $rr = implode('/', $rr);
     //        $this->set('_return', $rr . Url::query());
     View::bind_global('_breadcumbs', $this->breadcumbs);
     // detecting if user is logged in
     if (method_exists(Auth::instance(), 'auto_login')) {
         Auth::instance()->auto_login();
     }
     //
     if (Auth::instance()->logged_in()) {
         $id = Auth::instance()->get_user()->id;
         $user = ORM::factory('user', $id);
         $input = $user->has('roles', ORM::factory('role', array('name' => 'admin')));
         $this->set("admin_mode", $input);
     } else {
         $this->set("admin_mode", false);
     }
     //
     $this->user = Auth::instance()->get_user();
     $this->set('_user', $this->user);
     if (Auth::instance()->logged_in() && $this->user->profile->is_visited != 1 && strtolower($this->request->controller()) == 'profile') {
         $this->redirect('profile/information', 301);
     }
     $sliders = ORM::factory('Slider')->where('is_active', '=', 1)->and_where('type', '=', 'slider')->order_by('order', 'asc')->find_all();
     $this->set('sliders', $sliders);
     $banner = ORM::factory('Slider')->where('is_active', '=', 1)->and_where('type', '=', 'banner')->find_all();
     $this->set('menu_banner', $banner);
     $menu = ORM::factory('Page')->where('key', '=', 'menu')->find();
     //Для SEO (сортировка)
     if ($this->request->controller() == 'Auth' or $this->request->controller() == 'Search' or $this->request->controller() == 'Profile') {
         $this->set('sort', 1);
     }
     //end SEO
     $page_roots = ORM::factory('Page', $menu->id)->children();
     $page_main = array();
     $children_pages = array();
     $children_pages_last = array();
     $children_pages_last_last = array();
     foreach ($page_roots as $p) {
         $page_main[$p->key] = array('id' => $p->id, 'name' => $p->name, 'description' => $p->description);
         $children_pages[$p->key] = $p->children();
         //ORM::factory('Page')->where('parent_id','=',$p->id)->find_all();//только первый уровень детей
         //второй уровень детей.
         foreach ($children_pages[$p->key] as $ch_p) {
             if ($ch_p->id == 232 or $ch_p->id == 159) {
                 continue;
             }
             $children_pages_last[$ch_p->id] = $ch_p->children();
             //третий уровень детей
             foreach ($children_pages_last[$ch_p->id] as $ch_p_l) {
                 $children_pages_last_last[$ch_p_l->id] = $ch_p_l->children();
             }
         }
     }
     $page_halyk_kaharmany = ORM::factory('Page', 319);
     $this->set('page_halyk_kaharmany', $page_halyk_kaharmany);
     $this->set('_pages', $page_main)->set('_children_pages', $children_pages)->set('_children_pages_last', $children_pages_last)->set('_children_pages_last_last', $children_pages_last_last)->set('_return_url', URL::media(Request::initial()->uri()));
     //для вывода сообщения о регистрации восстановления пароля и прочих действий
     //само сообщение выводится в модальном окне, находится в шаблоне footer
     if (Message::get()) {
         $this->set('basic_message', Message::display('/message/basic'));
     }
     $nofollowlink = url::media(Request::initial()->uri());
     $controller = strtolower(Request::initial()->controller());
     $action = strtolower(Request::initial()->action());
     if ($controller == 'books' and $action == 'index') {
         $params = explode('books/', $_SERVER['REQUEST_URI']);
         if (isset($params[1]) and isset($params[0])) {
             $params = explode('?', $params[1]);
             $razdel = $params[0];
         } else {
             $razdel = '';
         }
         if (isset($params[1])) {
             $params = explode('=', $params[1]);
             $idbook = $params[1];
         } else {
             $idbook = '';
         }
         $wherestring = 'books_' . $razdel . '_' . $idbook;
         $page = ORM::factory('Page')->where('key', '=', $wherestring)->find();
         $linkid = $page->id;
         $nofollowlink = URL::site('contents/list/' . $linkid);
     }
     if ($controller == 'biography' and $action == 'index') {
         $params = explode('biography/', $_SERVER['REQUEST_URI']);
         if (isset($params[1])) {
             $idbiography = $params[1];
         } else {
             $idbiography = '';
         }
         $wherestring = 'biography' . '_' . $idbiography;
         $page = ORM::factory('Page')->where('key', 'LIKE', $wherestring . '%')->find();
         $linkid = $page->id;
         $nofollowlink = URL::site('contents/list/' . $linkid);
     }
     if ($controller == 'organization' and $action == 'show') {
         $params = explode('organization/show/', $_SERVER['REQUEST_URI']);
         if (isset($params[1])) {
             $idorganization = $params[1];
         } else {
             $idorganization = '';
         }
         $wherestring = 'organization' . '_' . $idorganization;
         $page = ORM::factory('Page')->where('key', 'LIKE', $wherestring . '%')->find();
         $linkid = $page->id;
         $nofollowlink = URL::site('contents/list/' . $linkid);
     }
     if ($controller == 'expert' and $action == 'index') {
         $nofollowlink = URL::site('contents/list/301');
     }
     //в базе дублируется запись 4 и 301
     if ($controller == 'publications' and $action == 'index') {
         $nofollowlink = URL::site('contents/list/231');
     }
     if ($controller == 'debate' and $action == 'index') {
         $nofollowlink = URL::site('contents/list/335');
     }
     if ($controller == 'debate' and $action == 'index') {
         $nofollowlink = URL::site('contents/list/335');
     }
     $this->set('nofollowlink', $nofollowlink);
     //потому-что SEO.
 }
Exemplo n.º 6
0
Arquivo: App.php Projeto: ignaszak/cms
 /**
  * Validates configuration and displays informations if any error occures
  */
 public function validConf()
 {
     $this->valid->validModRewrite();
     $this->valid->valid();
     $this->message->display();
 }
Exemplo n.º 7
0
 /**
  * If debugging is enabled, append profiler stats for non-production environments.
  *
  * @return  void
  */
 public function after()
 {
     if ($this->auto_render && $this->bare == FALSE) {
         // Controller name as the default page id if none set
         empty($this->_page_id) and $this->_page_id = $this->request->controller();
         // Load left and right sidebars if available
         $this->_set_sidebars();
         // Set appropriate column css class
         $this->_set_column_class();
         // Do some CSS magic to page class
         $classes = array(I18n::$lang, $this->request->controller(), $this->request->action(), $this->request->controller() . '-' . $this->request->action(), $this->template->column_class, $this->_page_class, $this->_auth->logged_in() ? 'logged-in' : 'not-logged-in');
         // Special check for frontpage and frontpage title
         if ($this->is_frontpage()) {
             // Set front variable true for themers
             $this->template->front = TRUE;
             // Don't show title on homepage
             $this->template->title = FALSE;
             // Don't show title on homepage
             $this->title = FALSE;
             $this->template->mission = __($this->_config->get('site_mission', ''));
         }
         View::set_global(array('is_front' => $this->template->front, 'is_admin' => $this->template->_admin));
         $classes[] = $this->template->_admin ? 'backend' : 'frontend';
         $classes[] = $this->template->front ? 'front' : 'not-front';
         $page_class = implode(' ', array_unique(array_map('trim', $classes)));
         // Construct Head Section Page title
         $this->_set_head_title();
         // Allow module and theme developers to override
         Module::event('template', $this);
         // Set primary menu
         $primary_menu = Menu::links('main-menu', array('class' => 'menus nav navbar-nav'));
         // Bind the generic page variables
         $this->template->set('lang', I18n::$lang)->set('page_id', $this->_page_id)->set('page_class', $page_class)->set('primary_menu', $primary_menu)->set('title', $this->title)->set('subtitle', $this->subtitle)->set('icon', $this->icon)->set('schemaType', $this->schemaType)->set('mission', $this->template->mission)->set('content', $this->response->body())->set('messages', Message::display())->set('profiler', FALSE);
         if (count($this->_tabs) > 0) {
             $this->template->tabs = View::factory('tabs')->set('tabs', $this->_tabs);
         }
         if (count($this->_subtabs) > 0) {
             $this->template->subtabs = View::factory('tabs')->set('tabs', $this->_subtabs);
         }
         if (count($this->_actions) > 0) {
             $this->template->actions = View::factory('actions')->set('actions', $this->_actions);
         }
         // And profiler if debug is true
         if (Kohana::$environment !== Kohana::PRODUCTION and $this->debug) {
             $this->template->profiler = View::factory('profiler/stats');
         }
         // And finally the profiler stats
         $this->_set_profiler_stats();
         // Assign the template as the request response and render it
         $this->response->body($this->template);
     } elseif ($this->_ajax && $this->bare == FALSE) {
         $output = $this->response->body();
         $this->process_ajax();
         if ($this->_response_format === 'application/json') {
             // Check for dataTables request
             if ($this->request->query('draw') !== NULL) {
                 return;
             }
             $output = $this->_json['Data'];
         }
         $this->response->body($output);
     } elseif ($this->_internal && $this->bare == FALSE) {
         $output = $this->response->body();
         $this->response->body($output);
     }
     if ($this->bare == FALSE) {
         if (isset($this->_benchmark)) {
             // Stop the benchmark
             Profiler::stop($this->_benchmark);
         }
         // Set header content-type to response format with utf-8
         $this->response->headers('Content-Type', $this->_response_format . '; charset=' . Kohana::$charset);
     }
     parent::after();
 }
Exemplo n.º 8
0
/**
 * Exception Handler
 *
 * error:   中断程序,提示信息中出现报告bug的链接以及记录到日志文件
 * warning: 中断程序,提示信息中出现报告bug的链接。
 * notice:  不中断程序,错误信息输出到页面的注释中
 *---------------------------------------
 * 用户级的错误处理方式:
 *
 * error:   中断程序,提示信息中出现报告bug的链接以及记录到日志文件
 * warning: 中断程序,提示信息中不包括出错文件及行号等信息
 * notice:  中断程序,提示信息中不包括出错文件及行号等信息。 如何处理链接地址呢?
 *---------------------------------------
 *
 * @param   number  $errno
 * @param   string  $errstr
 * @param   string  $errfile
 * @param   string  $errline
 *
 * @return  void
 */
function exception_handler($errno, $errstr, $errfile, $errline)
{
    if ($errno == 2048) {
        return true;
    }
    if ($errno != E_NOTICE) {
        $msg = new Message($errstr, $errno);
        $errfile = str_replace(ROOT_PATH, '', $errfile);
        if ($errno != E_USER_WARNING && $errno != E_USER_NOTICE) {
            $msg->err_file = $errfile;
            $msg->err_line = $errline;
        }
        /* add report link */
        if ($errno == E_USER_ERROR || $errno == E_ERROR || $errno == E_PARSE || $errno == E_WARNING) {
            $msg->report_link($errno, $errstr, $errfile, $errline);
            put_log($errno, $errstr, $errfile, $errline);
            // 写入错误日志
            $msg->display();
            exit;
        } else {
            $msg->display();
        }
    } else {
        if ($errno == E_NOTICE && (defined(DEBUG_MODE) && DEBUGE_MODE > 0)) {
            echo "<div style='font: 14px verdana'><b>Notice:</b> {$errstr}<br/><b>Error File:</b> {$errfile}: [{$errline}]</div>";
        }
    }
    return true;
}
Exemplo n.º 9
0
 /**
  * Shows the info on a submission in a secondary window
  */
 function showinfoAction()
 {
     $paperTbl = new Paper();
     $this->view->setFile("content", "show_info.xml");
     $this->view->setBlock("content", "SECTION", "SECTIONS");
     $this->view->setBlock("content", "DISCUSSION", "SHOW_DISCUSSION");
     $this->view->setBlock("DISCUSSION", "message", "messages");
     $this->view->setFile("review", "show_tbl_review.xml");
     $this->view->setBlock("review", "review_mark", "review_marks");
     $this->view->setBlock("review", "review_answer", "review_answers");
     $idPaper = $this->getRequest()->getParam("id_paper");
     $paper = $paperTbl->find($idPaper)->current();
     if (!is_object($paper)) {
         throw new Zmax_Exception("showinfo: I am waiting for a valid paper id !?");
     }
     // Default: print only the basic informations. Do not show the reviews
     // nor the forum
     $this->view->setBlock("content", "ANSWER", "ANSWERS");
     $this->view->setBlock("content", "REVIEWER", "REVIEWERS");
     $this->view->setBlock("content", "REVIEWS");
     $this->view->setVar("SHOW_DISCUSSION", "");
     // instantiate the template for the paper and its dependent objects
     $paper->putInView($this->view);
     // Check the context to determine what must be printed
     if ($this->user->isAdmin() or isset($_REQUEST['in_forum'])) {
         // It is an administrator. Print everything
         $this->view->setVar("SHOW_REVIEWS", $paper->showReviews($this->view, true));
         // Add the messages if the discussion is opened
         if ($this->config->discussion_mode != Config::NO_DISCUSSION) {
             $this->view->messages = Message::display($idPaper, 0, $this->view);
             $this->view->assign("TMP_DISCUSSION", "DISCUSSION");
             $this->view->assign("SHOW_DISCUSSION", "TMP_DISCUSSION");
         }
     } else {
         if ($paper->hasReviewer($this->user->id)) {
             // It is a reviewer,
             $review = $paper->getReview($this->user->id);
             //check the 'allReviews' parameter
             if (isset($_REQUEST['allReviews'])) {
                 if ($_REQUEST['allReviews']) {
                     $this->view->SHOW_REVIEWS = $review->showReview($this->view, true);
                 } else {
                     $this->view->SHOW_REVIEWS = $paper->showReviews($this->view, true);
                 }
             }
             // Add the messages if the discussion is open
             // if ($config['discussion_mode'] != NO_DISCUSSION)
             //$this->view->set_var("FORUM", DisplayMessages($idPaper, 0, $db, false));
         }
     }
     // Take account of the 'noReview' and 'noForum' parameter
     if (isset($_REQUEST['noReview'])) {
         $this->view->REVIEWS = " ";
     }
     //  if (isSet($_REQUEST['noForum'])) $view->set_var("FORUM", "");
     $this->view->assign("action_result", "content");
     $this->view->assign("action_result2", "action_result");
     echo $this->view->action_result2;
 }