Exemplo n.º 1
0
 function __CONSTRUCT()
 {
     $this->load_outer_template('template');
     load_helper('errors');
     load_helper('navigation');
     load_helper('members');
 }
Exemplo n.º 2
0
 public function __construct()
 {
     $this->load_library('auth_lib', 'auth');
     $this->auth->force_authentication();
     $this->load_model('contest_model', 'model');
     load_helper('validations');
 }
 function __CONSTRUCT ()
 {
     $this->load_outer_template('main');
     load_helper('relations');
     load_helper('errors');
     load_helper('messages');
 }
 function __CONSTRUCT ()
 {
     $this->load_outer_template('main');
     load_helper('relations');
     load_helper('users');
     load_helper('errors');
     load_helper('crypto');
 }
Exemplo n.º 5
0
 function index()
 {
     $this->load_model("hello_model", "hello_model");
     $name = $this->hello_model->whoami();
     $this->load_library('some_lib');
     load_helper("dummy");
     echo example_helper_function();
     $this->load_view("hello", ["from" => $name, "hint" => $this->some_lib->get_hint()]);
 }
Exemplo n.º 6
0
    function __CONSTRUCT()
    {
        $this->load_outer_template('template');
        load_helper('errors');

    // Require login
        if(!isset($_SESSION['active_user']))
            redirect_to('/');
    }
Exemplo n.º 7
0
 function Controller()
 {
     $this->validate = Inspekt::makeSuperCage();
     $this->db = Database::getInstance(array('conn_id' => Config::item('LINK_ID')));
     $this->view = new View();
     // auto load helper
     load_helper(array('php', 'time', 'html', 'form', 'table', 'forum'));
     // load forum model
     load_model('forum', FALSE);
     load_model('check', FALSE);
     $this->forum = forum_model::getInstance();
 }
Exemplo n.º 8
0
 function __construct()
 {
     global $cfg;
     if ($cfg['i18n']['gettext']) {
         $domain = $cfg['i18n']['gettext']['domain'];
         $directory = $cfg['i18n']['gettext']['directory'];
         bindtextdomain($domain, $directory);
         textdomain($domain);
         load_helper('gettext');
         $client_locale = $this->get_client_locale();
         if ($client_locale) {
             $this->set_locale($client_locale);
         }
         setcookie('locale_path_prefix', '', 0, '/');
     }
 }
Exemplo n.º 9
0
 /**
  * Construct a new App object
  *
  * @param String $uri an optional relative URI (e.g. "/folder/file")
  */
 public function __construct($uri = NULL)
 {
     if (is_null($uri)) {
         $uri = $_SERVER['REQUEST_URI'];
     }
     // Setup the config, prefix and assert checks
     $config = AppConfig::configure();
     load_helper('HTML', 'Text');
     load_tools('Log', 'Translate');
     $this->error_messages = array();
     $this->assert_checking($config);
     // Set the content type, folder and file
     $uri = preg_replace('/[\\?#].*/', '', $uri);
     $content_type = preg_match('/\\.(\\w+)$/', $uri, $matches) ? $matches[1] : DEFAULT_CONTENT_TYPE;
     if ($content_type === Symbol::TEST && !Config::get('TESTING_ENABLED')) {
         $content_type = DEFAULT_CONTENT_TYPE;
     }
     $uri = $this->set_lang_and_remove_prefix($uri);
     $this->parts = explode('/', $uri);
     $folder = $this->get_part(0, TRUE);
     // remove any extension
     $file = $this->get_part(1, TRUE);
     // remove any extension
     // Setup the application request environment
     $this->content_type = strtolower($content_type);
     // e.g. "html", "test"
     $this->folder = strlen($folder) > 0 ? $folder : DEFAULT_FOLDER;
     $this->file = strlen($file) > 0 ? $file : DEFAULT_FILE;
     $this->is_testing = $this->is_testing || array_key($_REQUEST, Symbol::TEST) || $content_type === Symbol::TEST;
     if ($this->is_testing) {
         Log::type(Symbol::TEST);
     }
     // If we're testing then use a test database
     require_once 'lib/Model.php';
     $model = new Model();
     $db_test = Config::get('DB_DATABASE_TEST', TRUE);
     $db_live = Config::get('DB_DATABASE_LIVE', TRUE);
     $database = $this->is_testing ? $db_test : $db_live;
     $model->set_database($database);
     // Setup the language translations
     Translate::add_translations(Config::load('validate'));
     Translate::add_translations(Config::load('translate'));
     // Register this app as a prop
     YAWF::prop(Symbol::APP, $this);
 }
function makeDynamicThumbnail()
{
    global $clerk;
    if (isset($_GET['dynamic_thumbnail']) == false) {
        return;
    }
    load_helper("ThumbLib.inc");
    $file = $_GET['file'];
    $width = $_GET['width'];
    $height = $_GET['height'];
    $adaptive = $_GET['adaptive'];
    $file_extension = substr($file, strrpos($file, '.'));
    $cache_dir = $clerk->getSetting("cache_path", 1);
    $cache_file_name = str_replace($file_extension, "", basename($file)) . "." . $width . "x" . $height . "_" . $adaptive . ".jpg";
    $path = $cache_dir . "/" . $cache_file_name;
    if (!is_dir($cache_dir)) {
        mkdir($cache_dir);
    }
    $thumb = PhpThumbFactory::create($file, array('resizeUp' => true));
    $thumb->setFormat("JPG");
    if ($adaptive == 0 || ($width == 0 || $height == 0)) {
        $thumb->resize($width, $height);
    } else {
        $thumb->adaptiveResize($width, $height);
    }
    $thumb->save($path);
    $data = call_anchor("modifyDynamicThumbnail", array("path" => $path, "filename" => $cache_file_name, "orig_filename" => basename($file), "thumb" => $thumb));
    // Sharpen filter
    // for nicer thumbnails
    $path = $data['path'];
    $i = imagecreatefromjpeg($path);
    $sharpen_matrix = array(array(0.0, -0.8, 0.0), array(-0.8, 6.5, -0.8), array(0.0, -0.8, 0.0));
    $divisor = array_sum(array_map('array_sum', $sharpen_matrix));
    imageconvolution($i, $sharpen_matrix, $divisor, 0);
    imagejpeg($i, $path, 100);
    $path = $data['path'];
    header('Content-type: image/jpeg');
    $image = imagecreatefromjpeg($path);
    imagejpeg($image, null, 100);
    imagedestroy($image);
    exit;
}
Exemplo n.º 11
0
<?php

/* Everything you need is here */
include_once 'config.php';
include_once 'helpers/loaders.php';
load_helper('dirs');
load_interface('cachable');
$journal = new \handling\log\journal(LOG_DIRECTORY, LOG);
//set_error_handler(function($error,$message,$file,$line,$context){
//  \handling\log\journal::write_error_message($error,$message,$file,$line,$context);}); // using this function to write errors
Exemplo n.º 12
0
/**
 * Load multiple helpers
 * @param array<string>
 **/
function load_helpers($files)
{
    if (empty($files)) {
        throw new RuntimeException('what helper files?');
        return;
    }
    foreach ($files as $file) {
        load_helper($file);
    }
}
Exemplo n.º 13
0
 public function before()
 {
     load_helper('Twitter');
     load_plugin('Twitter/OAuth');
     parent::before();
 }
Exemplo n.º 14
0
?>
</label>
            <input type="text" name="location" id="location"value="<?php 
echo htmlentities($user_data['location']);
?>
" required>
        </div>

        <div class="pure-control-group">
            <label for="country"><?php 
echo __('Country:');
?>
</label>
            <select name="country" required style="padding: 2px;">
            <?php 
load_helper('country_list');
$countries = get_country_list();
foreach ($countries as $code => $name) {
    if ($user_data['country'] == $code) {
        $selected = 'selected';
    } else {
        $selected = '';
    }
    ?>
                <option value="<?php 
    echo $code;
    ?>
" <?php 
    echo $selected;
    ?>
><?php 
Exemplo n.º 15
0
<?php

// Copyright (c) 2010 Guanoo, Inc.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation; either version 3
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
load_helper('Text');
/**
 * The Relating_model adds relationships to models via methods
 * "belongs_to", "has_a" and "has_many". Unlike other "sexier"
 * frameworks, this class doesn't support many-to-many relations.
 *
 * @author Kevin Hutchinson <*****@*****.**>
 */
class Relating_model extends SQL_model implements Modelled, Persisted, Validated
{
    const BELONGS_TO = 'belongs_to';
    const HAS_A = 'has_a';
    const HAS_MANY = 'has_many';
    private static $relations = array();
    private static $renamings = array();
    /**
     * Setup a relationship whereby this model belongs to some other models
     *
Exemplo n.º 16
0
        <div class="container">
            <h2 class="text-center"><?php 
echo __('Final Scoreboard');
?>
</h2>
            <div style="margin: 2em;" class="text-center">
                <span class="my-bg msg inline-block">
                    <?php 
echo __('Congratulations to all the winners!');
?>
                    <?php 
if (!empty($explanations_link)) {
    ?>
                        <br>
                        <a target="_blank" href="<?php 
    load_helper('validations');
    if (is_valid_url($explanations_link)) {
        echo $explanations_link;
    } else {
        echo base_url() . $explanations_link;
    }
    ?>
"><?php 
    echo __('Link to explanations');
    ?>
</a>
                    <?php 
}
?>
                </span>
            </div>
Exemplo n.º 17
0
 function sbmt_upd_jxtext()
 {
     global $go;
     header('Content-type: text/html; charset=utf-8');
     load_module_helper('files', $go['a']);
     $clean['id'] = (int) $_POST['id'];
     $_POST['content'] = $_POST['v'] === '' ? '' : utf8Urldecode($_POST['v']);
     //$_POST['content'] = ($_POST['v'] === '') ? '' : $_POST['v'];
     //echo $_POST['content']; exit;
     // we need $clean['id'] on processing
     $rs = $this->db->fetchRecord("SELECT process\n            FROM " . PX . "objects\n            WHERE id = '{$clean['id']}'");
     $processor =& load_class('processor', true, 'lib');
     load_helper('textprocess');
     $clean['content'] = $processor->process('content', array('nophp'));
     $clean['content'] = textProcess($clean['content'], $rs['process']);
     $clean['udate'] = getNow();
     $clean['object'] = OBJECT;
     $this->db->updateArray('object', $clean, "id={$clean['id']}");
     header('Content-type: text/html; charset=utf-8');
     echo "<span class='notify'>" . $this->lang->word('updating') . "</span>";
     exit;
 }
Exemplo n.º 18
0
 public function review_mission($mission_id, $type = null)
 {
     if (!$this->sap_auth->is_current_user_admin()) {
         $this->http_lib->response_code(403);
     }
     if ($type && $type !== 'approved') {
         $this->http_lib->response_code(404);
     }
     $approved = $type == 'approved';
     $mission = $this->sap_model->get_mission($mission_id);
     $submissions = $this->sap_model->get_task_submissions_for_review($mission_id, $approved);
     $view = $approved ? 'sap/view_approved_submissions' : 'sap/review_mission';
     load_helper('linkify');
     $this->load_view($view, ['submissions' => $submissions, 'mission' => $mission, 'result' => $this->session_lib->flash_get('result'), 'success' => $this->session_lib->flash_get('success')]);
 }
Exemplo n.º 19
0
<?
load_model('Message');
load_helper('Spam');

class Contact_controller extends App_controller
{
    public function form()
    {
        $this->render->title = 'Contact form';
        $message = $this->render->message = new Message($this->params->message);
        if (Spam::is_spam($this->params)) return;
        $message->status = 'P'; // Pending
        if ($message->save())
        {
            $this->flash->sent = $this->send($message);
            $this->redirect('default/index', array('notice' => 'Thank you for your interest. Please expect a friendly email from us in the next few days.'));
        }
    }

    private function send($message)
    {
        return $this->send_mail('message', array(
                                    'to'       => CONTACT_EMAIL,
                                    'from'     => $message->email,
                                    'subject'  => 'Plumline website message',
                                    'message'  => $message,
                                ));
    }
}
Exemplo n.º 20
0
/*
 * Helper implementation
 */
function load_helper($helper)
{
    $helper_file = APPPATH . 'helpers/' . $helper . '.php';
    if (is_file($helper_file)) {
        include_once $helper_file;
    } else {
        include_once SYSPATH . 'helpers/' . $helper . '.php';
    }
}
/*
 * Load common helpers
 */
load_helper('base_url');
/*
 * Load system
 */
require SYSPATH . 'router.php';
require SYSPATH . 'loader.php';
require SYSPATH . 'controller.php';
require SYSPATH . 'model.php';
require SYSPATH . 'library.php';
require SYSPATH . 'i18n.php';
/*
 * Understand URL and decompose route
 */
$router = new Router(empty($_SERVER['PATH_INFO']) ? '' : $_SERVER['PATH_INFO']);
$controller = $router->get_controller();
$method = $router->get_method();
Exemplo n.º 21
0
 private function handle_user_update($action, $user)
 {
     if ($user === false) {
         return;
     }
     if ($action == "update_mail" && isset($_POST["mail"])) {
         $mail = $_POST["mail"];
         $error = [];
         if (!$mail) {
             // TODO: email verification
             $error[] = __("Please enter a valid email address");
         } elseif ($mail != $user["mail"]) {
             if (!$this->auth_model->is_good_email($mail)) {
                 $error[] = __("The email id you gave is not valid");
             } else {
                 $already_registered = $this->auth_model->get_user_by_mail($mail);
                 if ($already_registered && $already_registered["id"] != $user["id"]) {
                     $error[] = __("The email id you gave is already registered");
                 } else {
                     $updated = $this->auth_model->update_user($user["id"], ["mail" => $mail, "email_verified" => "0", "resitration_status" => "incomplete"]);
                     if ($updated) {
                         $sent = $this->send_verification_mail($mail, "verify_email");
                         if (!$sent) {
                             $error[] = __("Could not send mail");
                         }
                     }
                     if (!$updated) {
                         $error[] = __("Could not update email");
                     }
                 }
             }
         } else {
             $updated = $this->auth_model->update_user($user["id"], ["resitration_status" => "incomplete"]);
             if (!$updated) {
                 $error[] = __("Could not update email");
             }
         }
         $this->session_lib->flash_set("auth_last_error", implode("\n", $error));
         $this->http->redirect(locale_base_url() . "auth/register/");
     } elseif ($action == "update_profile") {
         if ($user["resitration_status"] == "complete") {
             return;
         }
         $user_data = ["nick" => strtolower($_POST["nick"]), "name" => $_POST["name"], "gender" => $_POST["gender"], "location" => $_POST["location"], "country" => $_POST["country"], "dob" => $_POST["dob"], "organization" => $_POST["organization"]];
         $complete = true;
         $error = [];
         foreach ($user_data as $key => $value) {
             if (empty($value)) {
                 $error[] = __("Please fill all the required fields");
                 $complete = false;
             }
         }
         if (!preg_match('/^[a-z0-9_]+$/i', $user_data["nick"])) {
             unset($user_data["nick"]);
             $complete = false;
             $error[] = __("You can use only alphanumeric characters and underscore in nick");
         } elseif (strlen($user_data["nick"]) < 6) {
             unset($user_data["nick"]);
             $complete = false;
             $error[] = __("Nick must be at least 6 characters long");
         } elseif ($user["nick"] != $user_data["nick"] && $this->auth_model->get_user_by_nick($user_data["nick"])) {
             unset($user_data["nick"]);
             $complete = false;
             $error[] = __("Nick is already taken");
         }
         if (!in_array($user_data["gender"], ["male", "female", "other"])) {
             $user_data["gender"] = "";
             $error[] = __("Enter valid gender");
             $complete = false;
         }
         if ($user_data["dob"]) {
             if (date_parse($user_data["dob"])["error_count"]) {
                 $user_data["dob"] = "";
                 $error[] = __("Enter valid birthdate");
                 $complete = false;
             }
         }
         if ($user_data["country"]) {
             load_helper("country_list");
             $country_list = get_country_list();
             if (!in_array($user_data["country"], array_keys($country_list))) {
                 $user_data["country"] = "";
                 $error[] = __("Enter valid country");
                 $complete = false;
             }
         }
         if ($complete) {
             $user_data["resitration_status"] = "complete";
         }
         $updated = $this->auth_model->update_user($user["id"], $user_data);
         if (!$updated) {
             $error[] = __("Could not update profile");
         }
         if (count($error)) {
             $this->session_lib->flash_set("auth_last_error", implode("\n", $error));
         }
         $this->http->redirect(locale_base_url() . "auth/register");
     }
 }