public static function getInstance()
 {
     if (!self::$instance) {
         self::$instance = new self();
     }
     return self::$instance;
 }
Example #2
0
 function error($f3)
 {
     $log = new Log('error.log');
     $log->write($f3->get('ERROR.text'));
     foreach ($f3->get('ERROR.trace') as $frame) {
         if (isset($frame['file'])) {
             // Parse each backtrace stack frame
             $line = '';
             $addr = $f3->fixslashes($frame['file']) . ':' . $frame['line'];
             if (isset($frame['class'])) {
                 $line .= $frame['class'] . $frame['type'];
             }
             if (isset($frame['function'])) {
                 $line .= $frame['function'];
                 if (!preg_match('/{.+}/', $frame['function'])) {
                     $line .= '(';
                     if (isset($frame['args']) && $frame['args']) {
                         $line .= $f3->csv($frame['args']);
                     }
                     $line .= ')';
                 }
             }
             // Write to custom log
             $log->write($addr . ' ' . $line);
         }
     }
     Template::instance()->render('error.html');
 }
Example #3
0
 public function post()
 {
     $f3 = \Base::instance();
     //        $f3->reroute('/beta');
     // Exit immediately if public registrations are disabled
     if (!DbConfig::getOpt('openRegister')) {
         $f3->error(400);
         return;
     }
     if ($f3->get('POST.register-password') != $f3->get('POST.register-password-verify')) {
         $f3->set('errors', ['Password verify must match the first password.']);
     } else {
         $user = User::createUser(array('name' => $f3->get("POST.register-name"), 'username' => $f3->get("POST.register-username"), 'email' => $f3->get("POST.register-email"), 'password' => $f3->get("POST.register-password")));
         // Data missing
         if ($user == false) {
             $f3->set('errors', ['Some information has not been entered correctly or is not long enough.']);
         } elseif (is_array($user)) {
             $f3->set('errors', $user);
         } else {
             $f3->set('SESSION.id', $user->id);
             $f3->set('tplData', ['name' => $f3->get("POST.register-username")]);
             SendingAPI::send(['mailTo' => $f3->get("POST.register-email"), 'mailSubject' => 'Thank you for registering on SquareMS !', 'mailContents' => ['html' => \Template::instance()->render('mails/register.html'), 'text' => "Thank you for registering on SquareMS ! \n" . "You can access your account now on https://squarems.net/ ! \n\n" . "Please do not respond to this email, it is sent by an automated system."]]);
             $f3->reroute("/dashboard");
             return;
         }
     }
     $f3->set('css', array('/static/css/auth.css'));
     $f3->set('target', 'auth/register.html');
     $this->_render('base.html');
 }
Example #4
0
 static function getInstance()
 {
     if (!Template::$instance) {
         Template::$instance = new Template();
     }
     return Template::$instance;
 }
Example #5
0
 function license()
 {
     $this->view->set('title', 'License');
     $out = Template::instance()->render('basic/sub_license.html');
     $this->view->set('sub_out_put', $out);
     echo Template::instance()->render('basic/main.html');
 }
Example #6
0
 public function afterroute($f3)
 {
     // js view (file)
     $f3->set('jsView', 'setup');
     // render view
     echo \Template::instance()->render($f3->get('PATHFINDER.VIEW.INDEX'));
 }
Example #7
0
 public static function getInstance($path = '')
 {
     if (!isset(self::$instance)) {
         self::$instance = new Template($path);
     }
     return self::$instance;
 }
Example #8
0
 public function index(\Base $f3, $params)
 {
     $this->response->addTitle($f3->get('LN__AdminMenu_Home'));
     $f3->set('title_h1', $f3->get('LN__AdminMenu_Home'));
     switch ($this->moduleInit(@$params['module'])) {
         case "manual":
             $this->buffer(\View\Base::stub());
             break;
         case "custompages":
             $this->custompages($f3, $params);
             break;
         case "news":
             $this->news($f3, $params);
             break;
         case "modules":
             $this->buffer(\View\Base::stub());
             break;
         case "shoutbox":
             $this->shoutbox($f3, $params);
             break;
         case "home":
             $this->home($f3);
             break;
         default:
             $this->buffer(\Template::instance()->render('access.html'));
     }
 }
 public function index(\Base $f3, $params)
 {
     $this->response->addTitle($f3->get('LN__AdminMenu_Members'));
     switch ($this->moduleInit(@$params['module'])) {
         case "search":
             $this->buffer(\View\Base::stub());
             break;
         case "pending":
             $this->buffer(\View\Base::stub());
             break;
         case "groups":
             $this->buffer(\View\Base::stub());
             break;
         case "profile":
             $this->profile($f3, $params);
             break;
         case "team":
             $this->team($f3);
             break;
         case "home":
             $this->home($f3);
             break;
         default:
             $this->buffer(\Template::instance()->render('access.html'));
     }
 }
Example #10
0
 public function upcoming()
 {
     $upcoming = new Upcoming($this->db);
     $this->f3->set('decks', $upcoming->all());
     $this->f3->set('content', 'app/views/cards-upcoming.htm');
     echo Template::instance()->render('app/templates/default.htm');
 }
Example #11
0
 public static function libraryBookFavMenu(array $menu, array $counter, $sub)
 {
     \Base::instance()->set('menu_upper', $menu);
     \Base::instance()->set('counter', $counter);
     \Base::instance()->set('sub', $sub);
     return \Template::instance()->render('usercp/menu_upper.html');
 }
Example #12
0
 function htmlResponse($title, $html)
 {
     $f3 = Base::instance();
     $f3->set('title', $title);
     $f3->set('view', $html);
     echo Template::instance()->render("layout.html");
 }
Example #13
0
 function Get($f3)
 {
     $f3->set('PHP', version_compare(PHP_VERSION, "5.3.4", "<"));
     $f3->set('message', $f3->get('SESSION.flash'));
     $f3->clear('SESSION.flash');
     echo Template::instance()->render('install.html');
 }
Example #14
0
 function index($f3)
 {
     if ($f3->exists("GET.sesi_lenyap")) {
         \Flash::instance()->addMessage('Yoo bang! Selamat jalan~', 'success');
     }
     echo \Template::instance()->render("admin/auth/login.php");
 }
Example #15
0
 function scriptUpload($f3)
 {
     $this->ensureAdmin($f3);
     $db = $f3->get('db');
     Logger::Info($f3, "AdminPost.scriptUpload", "Starting import...");
     $dummy = $f3->get('FILES');
     $uploadedFile = $dummy["sqlFile"];
     if ($uploadedFile["error"] > 0) {
         Logger::Error($f3, "AdminPost.scriptUpload", $uploadedFile["error"]);
         echo "Error: " . $uploadedFile["error"] . "<br>";
     } else {
         try {
             $db->beginTransaction();
             $importFileName = $f3->get('ROOT') . '/imports/import_' . date('Y-m-d_H\\hi\\m') . '.xlsx';
             copy($uploadedFile["tmp_name"], $importFileName);
             Logger::Info($f3, "AdminPost.scriptUpload", "Import file: " . $importFileName);
             $importResult = ExcelImportExport::importFromExcel2007($db, $uploadedFile["tmp_name"]);
             $db->commit();
             $f3->set('scriptResult', $importResult);
             Logger::Info($f3, "AdminPost.scriptUpload", "Import finished");
         } catch (Exception $e) {
             $db->rollBack();
             $err = ExcelImportExport::$lastExecutedStatement . ' :: ' . $e->getMessage();
             Logger::Error($f3, "AdminPost.scriptUpload", "Import failed: " . $err);
             $f3->set('scriptResult', $err);
         }
         echo Template::instance()->render('adminIndex.htm');
     }
 }
Example #16
0
 private function process()
 {
     $this->f3->scrub($_POST);
     $audit = \Audit::instance();
     $this->f3->set('SESSION.flash', array());
     // validate form
     if (!preg_match("/^[\\w\\- ]{2,30}\$/", $this->f3->get('POST.name'))) {
         $this->f3->push('SESSION.flash', array('type' => 'warning', 'msg' => 'Invalid name.'));
     }
     if (!$audit->email($this->f3->get('POST.email'), FALSE)) {
         $this->f3->push('SESSION.flash', array('type' => 'warning', 'msg' => 'Invalid email address'));
     }
     if (!empty($this->f3->get('POST.url')) && !$audit->url($this->f3->get('POST.url'))) {
         $this->f3->push('SESSION.flash', array('type' => 'warning', 'msg' => 'Invalid URL.'));
     }
     if (empty($this->f3->get('POST.message'))) {
         $this->f3->push('SESSION.flash', array('type' => 'warning', 'msg' => 'Please include a message!'));
     }
     // honey pot
     if ($this->f3->get('POST.username') !== '') {
         $this->f3->push('SESSION.flash', array('type' => 'warning', 'msg' => 'Please do not use autofill or similar tools!'));
     }
     // if there are no errors, process the form
     if (count($this->f3->get('SESSION.flash')) === 0) {
         $this->f3->set('POST.level', $this->f3->get('member')->level + 1);
         $mailer = new Mailer();
         $message = $mailer->message()->setSubject($this->f3->get('tcgname') . ': Contact Form')->setFrom(array($this->f3->get('noreplyemail') => 'MyTCG'))->setTo(array($this->f3->get('tcgemail')))->setReplyTo(array($this->f3->get('POST.email')))->setBody(Template::instance()->render('app/templates/emails/contact.htm'), 'text/html');
         if ($mailer->send($message)) {
             $this->f3->push('SESSION.flash', array('type' => 'success', 'msg' => 'Your form has been sent. Thanks for contacting us!'));
         } else {
             $this->f3->push('SESSION.flash', array('type' => 'danger', 'msg' => 'There was a problem processing your request. Please try again or contact us for assistance!'));
         }
     }
 }
Example #17
0
 function beforeRoute($f3)
 {
     if ($f3->get("VERB") == "GET") {
         echo Template::instance()->render('get_redirect.htm');
         die;
     }
 }
    public function signin() {
        $email = $this->f3->get('POST.email');
        $password = $this->f3->get('POST.password');

        $v = new Valitron\Validator(array('Email' => $email, 'Password' => $password));
        $v->rule('required', ['Email', 'Password']);
        $v->rule('email', 'Email');

        if ($v->validate()) {
            $account = new Account($this->db);
            $pwd = md5($password);
            $acc = $account->select("*", "email='$email' and password='******'");
            if ($acc) {
                $this->f3->set('SESSION.acc', $acc);
                $acc = $acc[0];
                $acc['lastlogin'] = date('Y-m-d H:i:s');
                $account->update($acc,'id='.$acc['id']);
                $this->f3->reroute('/dashboard');
            } else {
                $this->f3->set('email', $email);
                $this->f3->set('errors', array(array('Login fail, wrong username or password')));
                echo Template::instance()->render('index.html');
            }
        } else {
            $this->f3->set('email', $email);
            $this->f3->set('errors', $v->errors());
            echo Template::instance()->render('index.html');
        }
    }
 public function setLogin($f3)
 {
     global $db;
     $login_error = null;
     if ($f3->exists('POST.username')) {
         $rows = $db->exec('SELECT * FROM users ' . 'WHERE username="******"');
         if (!empty($rows)) {
             if ($this->validatePassword($rows[0])) {
                 $f3->set("SESSION.username", $rows[0]["username"]);
                 $f3->set("SESSION.isAdmin", $rows[0]["isAdmin"]);
                 $f3->reroute('/page/aboutme');
             } else {
                 $login_error = "Invalid password";
             }
         } else {
             $login_error = "Invalid username";
         }
     }
     $f3->set("loign_error", $login_error);
     $f3->set('content', 'templates/login.html');
     $f3->set("loggedIn", false);
     $f3->set("isLightbox", false);
     $f3->set('page', "login");
     echo Template::instance()->render('templates/template.html');
 }
Example #20
0
 function afterroute()
 {
     if ($this->audit->isMobile()) {
         $this->f3->set('isMobile', true);
     }
     echo Template::instance()->render('layout.html');
 }
Example #21
0
 /**
  * 去得模板引擎的实例
  * @return object
  * @access public
  * @static
  */
 public static function getInstance()
 {
     if (self::$instance == null) {
         self::$instance = new Template();
     }
     return self::$instance;
 }
Example #22
0
 function render()
 {
     // Clean all output given first
     while (ob_get_level()) {
         ob_end_clean();
     }
     $f3 = \Base::instance();
     $f3->set('headline', 'Error ' . $f3->get('ERROR.code'));
     $f3->set('text', $f3->get('ERROR.text'));
     $f3->set('ESCAPE', false);
     if ($f3->get('AJAX')) {
         die(json_encode(array('error' => $f3->get('ERROR.text'))));
     }
     if ($f3->get('ERROR.code') == 400) {
         \Flash::instance()->addMessage($f3->get('ERROR.text'), 'warning');
         $f3->set('HALT', false);
         return;
     } elseif ($f3->get('ERROR.code') == 404) {
         $f3->set('headline', 'Page not found');
     } elseif ($f3->get('ERROR.code') == 405) {
         $f3->set('headline', 'This action is not allowed');
     } elseif ($f3->get('ERROR.code') == 500) {
         $f3->set('headline', 'Internal Server Error');
         if ($f3->get('DEV')) {
             $f3->set('trace', $f3->highlight($f3->get('ERROR.trace')));
         }
         @mail($f3->get('error_mail'), 'Mth3l3m3nt Framework Error', $f3->get('ERROR.text') . "\n\n" . $f3->get('ERROR.trace'));
     }
     $f3->set('LAYOUT', 'error.html');
     $f3->set('HALT', true);
     echo \Template::instance()->render('themes/default/layout.html');
 }
Example #23
0
 function pull_data()
 {
     $this->view->set('title', 'PostBox - Instagram Data Pull');
     $instagram_api_clinet_id = 'b9d4b604105648168c671293d10cc67e';
     $instagram_api_url = 'https://api.instagram.com/v1/tags/openpostboxindia/media/recent?client_id=' . $instagram_api_clinet_id;
     $data_pull_messages = array();
     $ch = curl_init($instagram_api_url);
     curl_setopt($ch, CURLOPT_HEADER, 0);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
     $json = curl_exec($ch);
     curl_close($ch);
     $data = json_decode($json, true);
     //var_dump($data);
     if ($data['meta']['code'] == 200) {
         //echo 'sucess';
         $picture_dicts = $data['data'];
         foreach ($picture_dicts as $pic) {
             $tags = implode(', ', $pic['tags']);
             $pincode = 0;
             foreach ($pic['tags'] as $tag) {
                 if ($this->startswith4($tag, 'pin')) {
                     $pincode = substr($tag, 3, 10);
                 }
             }
             $lat = $pic['location']['latitude'];
             $lan = $pic['location']['longitude'];
             $created_time = $pic['created_time'];
             $picture_url = $pic['images']['standard_resolution']['url'];
             $post_id = $pic['id'];
             $username = '******' . $pic["user"]["username"];
             $website = '';
             //$pic["user"]["website"];
             $caption = $pic["caption"]["text"];
             //check if post_id exists, if yes then go to next one. else insert
             $data_pull_messages[] = "Processing the post_id=" . $post_id;
             $q = 'select count(*) as count_posts from post_box where post_id="' . $post_id . '"';
             $POSTBOX_DB = \F3::get('POSTBOX_DB');
             $result = $POSTBOX_DB->exec($q);
             //print '\n'.$q;
             $count_posts = 0;
             foreach ($result as $row) {
                 $count_posts = $row['count_posts'];
             }
             if ($count_posts == 0) {
                 $data_pull_messages[] = "Lets INSERT.";
                 $i = 'insert into post_box( post_id , picture_url , tags , lat , lan , created_time , username , website,pincode, caption, provider) values(' . '"' . $post_id . '","' . $picture_url . '","' . $tags . '","' . $lat . '","' . $lan . '","' . $created_time . '","' . $username . '","' . $website . '","' . $pincode . '","' . $caption . '"' . ',"Instagram")';
                 //print $i;
                 $POSTBOX_DB->exec($i);
             } else {
                 $data_pull_messages[] = "Already exists.";
             }
         }
     }
     $this->view->set('data_pull_messages', $data_pull_messages);
     $out = Template::instance()->render('basic/sub_data_pull.html');
     $this->view->set('sub_out_put', $out);
     echo Template::instance()->render('basic/main.html');
 }
Example #24
0
 /**
  * Render a view
  * @param string  $file
  * @param string  $mime
  * @param array   $hive
  * @param integer $ttl
  */
 protected function _render($file, $mime = 'text/html', array $hive = null, $ttl = 0)
 {
     if (!headers_sent() && $mime == 'text/html') {
         $fw = \Base::instance();
         header("Content-Security-Policy: default-src: 'self'; " . "script-src 'self' 'unsafe-inline'; " . "style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; " . "font-src 'self' https://fonts.gstatic.com; " . "base-uri 'none'; " . "form-action 'self'; " . "frame-ancestors 'none'; " . "plugin-types 'none'; " . "report-uri " . $fw->get("BASE") . "/cspreport");
     }
     echo \Template::instance()->render($file, $mime, $hive, $ttl);
 }
Example #25
0
 public static function render_panel($f3)
 {
     $allergy = $f3->get('allergy_orm');
     $results = $allergy->find();
     $f3->set('allergies', $results);
     $f3->set('content', 'allergy_panel.htm');
     echo Template::instance()->render('layout.htm');
 }
Example #26
0
 public function crotypedia()
 {
     $RSS = new RSS($this->db);
     $this->f3->set('feed_url', $this->f3->get('site') . $this->f3->get('ALIASES')['rss_all']);
     $this->f3->set('feed_title', 'CR');
     $this->f3->set('feeds', $RSS->crotypedia());
     echo Template::instance()->render('rss/feed.xml', 'application/xml');
 }
Example #27
0
 public static function showNews($data)
 {
     if ($_SESSION['userID'] == 0) {
         \Registry::get('VIEW')->javascript('body', FALSE, "\$( document ).ready(function() {\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tgetCaptchaImage();\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\$('#captchaBox').click(getCaptchaImage);\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t}); ");
     }
     \Base::instance()->set('news', $data);
     return \Template::instance()->render('news/single.html');
 }
Example #28
0
 function editForm($f3)
 {
     $video = new DB\SQL\Mapper($f3->get('db'), 'videos');
     $video = $video->load(array('id=?', $f3->get('PARAMS.videoID')));
     $f3->set('video', $video);
     echo Template::instance()->render('templates/header.html');
     echo Template::instance()->render('templates/video.edit.html');
 }
Example #29
0
 public static function instance()
 {
     if (empty(self::$instance)) {
         self::$class = class_exists(self::$class, false) ? self::$class : __CLASS__;
         self::$instance = new self::$class();
     }
     return self::$instance;
 }
Example #30
0
 private function _show($base, $data, $error = false)
 {
     $base->set('data', $data);
     if ($error) {
         //            \Template::instance()->
     }
     //send json ouput
     echo \Template::instance()->render('json.php', 'application/json');
 }