Beispiel #1
0
 /**
  * 
  * 
  * @param 
  * @access public
  * @return void 
  */
 public function init()
 {
     $this->loadConfig();
     $this->vars = array_merge_recursive($_POST, $_GET);
     $this->template =& template::getInstance($this);
     $this->template->initByFile($this->config['template']);
 }
Beispiel #2
0
 public function init()
 {
     $token = isset($_SESSION['token']) ? $_SESSION['token'] : $_COOKIE['token'];
     $personal_id = isset($_SESSION['person']) ? $_SESSION['person'] : $_COOKIE['person'];
     $user_ip = system::getInstance()->getRealIp();
     // data 1st raw check before sql is used
     if (strlen($token) == 32 && (filter_var($personal_id, FILTER_VALIDATE_EMAIL) || strlen($personal_id) > 0 && system::getInstance()->isLatinOrNumeric($personal_id))) {
         $query = "SELECT * FROM\r\n            " . property::getInstance()->get('db_prefix') . "_user a,\r\n            " . property::getInstance()->get('db_prefix') . "_user_access_level b,\r\n            " . property::getInstance()->get('db_prefix') . "_user_custom c\r\n            WHERE (a.email = ? OR a.login = ?) AND a.token = ? AND a.token_ip = ? AND a.aprove = 0 AND a.access_level = b.group_id AND a.id = c.id";
         $stmt = database::getInstance()->con()->prepare($query);
         $stmt->bindParam(1, $personal_id, \PDO::PARAM_STR);
         $stmt->bindParam(2, $personal_id, \PDO::PARAM_STR);
         $stmt->bindParam(3, $token, \PDO::PARAM_STR, 32);
         $stmt->bindParam(4, $user_ip, \PDO::PARAM_STR);
         $stmt->execute();
         if ($stmt->rowCount() == 1) {
             $result = $stmt->fetchAll(\PDO::FETCH_ASSOC);
             $stmt = null;
             if (time() - $result[0]['token_start'] < property::getInstance()->get('token_time')) {
                 $this->userindex = $result[0]['id'];
                 foreach ($result[0] as $column_index => $column_data) {
                     $this->userdata[$this->userindex][$column_index] = $column_data;
                 }
                 // set template variables
                 template::getInstance()->set(template::TYPE_USER, 'id', $this->userindex);
                 template::getInstance()->set(template::TYPE_USER, 'name', $this->userdata[$this->userindex]['nick']);
                 template::getInstance()->set(template::TYPE_USER, 'admin', permission::getInstance()->have('global/owner'));
                 template::getInstance()->set(template::TYPE_USER, 'admin_panel', permission::getInstance()->have('admin/main'));
                 template::getInstance()->set(template::TYPE_USER, 'news_add', extension::getInstance()->getConfig('enable_useradd', 'news', extension::TYPE_COMPONENT, 'bol'));
                 template::getInstance()->set(template::TYPE_USER, 'balance', $this->userdata[$this->userindex]['balance']);
             }
         }
     }
 }
Beispiel #3
0
 /**
  * Check if user is permament banned in database and display ban.tpl theme
  */
 public function init()
 {
     $ip = system::getInstance()->getRealIp();
     $time = time();
     $userid = user::getInstance()->get('id');
     if ($userid > 0) {
         $stmt = database::getInstance()->con()->prepare("SELECT COUNT(*) FROM " . property::getInstance()->get('db_prefix') . "_user_block WHERE (user_id = ? or ip = ?) AND (express > ? OR express = 0)");
         $stmt->bindParam(1, $userid, \PDO::PARAM_INT);
         $stmt->bindParam(2, $ip, \PDO::PARAM_STR);
         $stmt->bindParam(3, $time, \PDO::PARAM_INT);
         $stmt->execute();
     } else {
         $stmt = database::getInstance()->con()->prepare("SELECT COUNT(*) FROM " . property::getInstance()->get('db_prefix') . "_user_block WHERE ip = ? AND (express > ? OR express = 0)");
         $stmt->bindParam(1, $ip, \PDO::PARAM_STR);
         $stmt->bindParam(2, $time, \PDO::PARAM_INT);
         $stmt->execute();
     }
     $rowFetch = $stmt->fetch();
     $count = $rowFetch[0];
     if ($count > 0) {
         // block founded in db
         $content = template::getInstance()->twigRender('ban.tpl', array('local' => array('admin_email' => property::getInstance()->get('mail_from'))));
         template::getInstance()->justPrint($content);
     }
 }
Beispiel #4
0
 /**
  * Get token for csrf prevention. Token is 32...128 chars. Token automatic add in cookie as 'csrf_token' and in template as {{ system.csrf_token }}
  * @return string
  */
 public function buildToken()
 {
     $now = time();
     if (!isset($_SESSION['csrf_token']) || $_SESSION['csrf_token']['time'] == null || $_SESSION['csrf_token']['data'] == null || $now - $_SESSION['csrf_token']['time'] > self::SESSION_TIME) {
         $_SESSION['csrf_token'] = array('time' => $now, 'data' => system::getInstance()->randomSecureString128());
     }
     template::getInstance()->set(template::TYPE_SYSTEM, 'csrf_token', $_SESSION['csrf_token']['data']);
 }
Beispiel #5
0
 public function initialize()
 {
     $this->template = template::getInstance();
     $this->session = session::getInstance();
     $this->album = album::getInstance();
     $this->template->add(array('album'));
     $this->id = $this->session->getData('album', 'id');
     $this->page = $this->session->getData('album', 'page');
 }
Beispiel #6
0
 public function initialize()
 {
     $this->template = template::getInstance();
     if ($this->ajax) {
         $this->content = ajax::getInstance();
     } else {
         $this->content = index::getInstance();
     }
     $this->content->initialize();
 }
Beispiel #7
0
 public function compile()
 {
     template::getInstance()->set(template::TYPE_META, 'description', system::getInstance()->altimplode('. ', $this->metadata['description']));
     template::getInstance()->set(template::TYPE_META, 'keywords', system::getInstance()->altimplode('. ', $this->metadata['keywords']));
     template::getInstance()->set(template::TYPE_META, 'global_title', $this->metadata['global_title']);
     if (property::getInstance()->get('multi_title')) {
         template::getInstance()->set(template::TYPE_META, 'title', system::getInstance()->altimplode(" - ", array_reverse($this->metadata['title'])));
     } else {
         template::getInstance()->set(template::TYPE_META, 'title', array_pop($this->metadata['title']));
     }
     template::getInstance()->set(template::TYPE_META, 'generator', 'FFCMS engine: ffcms.ru. Version: ' . version);
 }
Beispiel #8
0
 function execute()
 {
     index::execute();
     $tpl = template::getInstance();
     if ($tpl->existValue('index', 'navigator') && $tpl->existValue('index', 'fulltitle')) {
         $this->loadNavInfo();
         $tpl->setVar('fulltitle', $this->getFullTitle());
         $tpl->setVar('navigator', $this->navInfo);
     }
     $tpl->setVar('url', getMyUrlEncode('?mode=album&id=0'));
     $tpl->setVar('content', $this->content->display());
 }
Beispiel #9
0
 public function make()
 {
     if (!property::getInstance()->get('maintenance')) {
         // is not a maintenance mod
         return;
     }
     if (permission::getInstance()->have('admin/main')) {
         // not show for admin
         return;
     }
     $login_form = extension::getInstance()->call(extension::TYPE_COMPONENT, 'user')->viewLogin();
     // call to login view & worker
     $tpl = template::getInstance()->twigRender('maintenance.tpl', array('login_form' => $login_form));
     // render with login form
     template::getInstance()->justPrint($tpl, array());
 }
Beispiel #10
0
 public function __construct()
 {
     session_start();
     $this->load();
     $this->validConfigBase();
     headmgr::addHeaderBeforeInclude('<!--' . chr(10) . chr(9) . 'This website is powered by EYOCMS - inspiring people to share!' . chr(10) . chr(9) . 'EYOCMS is a free open source Content Management Framework initially created by Touzet David and licensed under GNU/GPL.' . chr(10) . chr(9) . 'EYOCMS is copyright 2010-2011 of Touzet David.' . chr(10) . chr(9) . 'Extensions are copyright of their respective owners.' . chr(10) . '-->');
     $this->db = new db();
     $this->db->connect($GLOBALS['SITECONF']['DBCONF']['SERNAME'], $GLOBALS['SITECONF']['DBCONF']['username'], $GLOBALS['SITECONF']['DBCONF']['password'], $GLOBALS['SITECONF']['DBCONF']['db']);
     $this->template =& template::getInstance($this);
     //new template();
     $this->vars = array_merge_recursive($_POST, $_GET);
     if (file_exists(PATH_TEMPLATE . 'index.html')) {
         $templatePath = PATH_TEMPLATE . 'index.html';
     } else {
         $templatePath = PATH_MODULE . 'index.html';
     }
     $this->template->initByFile($templatePath);
 }
Beispiel #11
0
 public function __construct()
 {
     $this->session = session::getInstance();
     $this->engine = engine::getInstance();
     $this->template = template::getInstance();
 }
Beispiel #12
0
 private function viewMain()
 {
     return template::getInstance()->twigRender('switch.tpl', array());
 }
Beispiel #13
0
 public function finalize()
 {
     $cv = cv::getInstance();
     $template = template::getInstance();
     $main = array('header' => $this->getHeader(), 'content' => $template->evaluate('content', array('content' => $cv->html)), 'footer' => $template->evaluate('footer', array()), 'job' => $cv->header['job'], 'subjob' => $cv->header['subjob'], 'fullname' => $cv->header['fullname'], 'theme' => $this->getThemeList(), 'themesel' => $this->getSwitchTheme(), 'cvsel' => $this->getSwitchCV(), 'langue' => $this->getSwitchLang());
     $html = $template->evaluate('main', $main);
     echo $this->translate($html);
 }
Beispiel #14
0
 public function getLogin()
 {
     $session = session::getInstance();
     $template = template::getInstance();
     if ($session->isLogged()) {
         $param = array('username' => $session->getUser('username'), 'admin_update' => '');
         if ($session->getUser('right') == 'admin') {
             //        $param['admin_update'] = $this->template->get('admin_update',array());
         }
         return $template->get('index_logout', $param);
     } else {
         return $template->get('index_login', array());
     }
 }
Beispiel #15
0
 function addDownload($info)
 {
     $engine = engine::getInstance();
     $template = template::getInstance();
     $path = $_SERVER['DOCUMENT_ROOT'] . '/data/' . $engine->cv . '/download/';
     $content = '';
     if (is_dir($path)) {
         $list = scandir($path);
         foreach ($list as $value) {
             if ($value != '..' && $value != '.') {
                 $content .= '<a href="data/' . $engine->cv . '/download/' . $value . '">' . $value . '</a><br/>';
             }
         }
         $array = array('code' => $info['code'], 'title' => $info['title'], 'option' => 'style="display:' . ($info['hide'] ? 'none' : 'block') . '"', 'content' => $content);
         return $template->evaluate('box', $array);
     } else {
         return '';
     }
 }
Beispiel #16
0
 /**
  * Get language value by key
  * @param string $lang
  * @return null|string
  */
 public function get($lang)
 {
     return template::getInstance()->get(template::TYPE_LANGUAGE, $lang);
 }
 protected function varValue($theSettings, $varName)
 {
     // was it specifically set?
     if (isset($theSettings['value'])) {
         $value = $theSettings['value'];
     }
     // is it in the $_POST array?
     if (!isset($value)) {
         if (isset($theSettings['checkpostvars']) && $theSettings['checkpostvars'] == true) {
             if (isset($this->postLikeArray[$varName])) {
                 $value = $this->postLikeArray[$varName];
             }
         }
     }
     // is it in the template array?
     if (!isset($value)) {
         if (isset($theSettings['checktemplatevars']) && $theSettings['checktemplatevars'] == true) {
             if (isset(template::getInstance()->vars[$varName]) == true) {
                 $value = template::getInstance()->vars[$varName];
             }
         }
     }
     // ok... give up and take it from whatever database it was supposed to be in
     if (!isset($value)) {
         $value = $theSettings['table']->{$theSettings}['field_name'];
     }
     return $value;
 }