Esempio n. 1
0
 public function setFramework(Framework $framework)
 {
     $this->_framework = $framework;
     $this->_router = $framework->getRouter();
     $this->_dispatcher = $framework->getDispatcher();
     return $this;
 }
 public static function get_instance()
 {
     if (null == self::$instance) {
         self::$instance = new self();
     }
     return self::$instance;
 }
Esempio n. 3
0
function escapeString($string)
{
    if (Framework::getDb() != null) {
        return mysql_real_escape_string($string, Framework::getDb()->getLink());
    }
    return mysql_escape_string($string);
}
Esempio n. 4
0
 public static function utilities()
 {
     if (is_null(self::$utilities)) {
         self::$utilities = new Utilities();
     }
     return self::$utilities;
 }
function __autoload_modules($class)
{
    $class_file = Framework::classLocate($class);
    if (file_exists($class_file)) {
        require_once $class_file;
    }
}
Esempio n. 6
0
 /**
  * undocumented
  * @author Joshua Davey
  */
 public function testUrl()
 {
     Framework::$uriPathDynamic = '/madeam/';
     Framework::$uriPathStatic = '/madeam/public/';
     $this->assertEquals('/madeam/test', Framework::url('test'));
     $this->assertEquals('/madeam/public/test', Framework::url('/test'));
 }
 public function init()
 {
     // check if logged in session is valid, if not redir to main page
     if (!isset($_SESSION['loginHash'])) {
         Framework::Redir("site/index");
         die;
     }
     $activeSession = R::findOne('session', ' hash = ? AND ip = ? AND expires > ?', array($_SESSION['loginHash'], $_SERVER['REMOTE_ADDR'], time()));
     if (!$activeSession) {
         unset($_SESSION['loginHash']);
         Framework::Redir("site/index/main/session_expired");
         die;
     }
     $activeSession->expires = time() + SESSION_MAX_AGE * 2;
     R::store($activeSession);
     $this->session = $activeSession;
     $this->user = R::load('user', $this->session->user->getId());
     Framework::TPL()->assign('user_premium', $this->user->hasPremium());
     // check needed rights if any
     foreach ($this->_rights as $r) {
         if (!$this->user->hasRight($r)) {
             Framework::Redir("game/index");
             die;
         }
     }
 }
 protected function setUrlParams($url_params)
 {
     $utilities = \Framework::utilities();
     $this->controller = isset($url_params[0]) ? $utilities->formater($url_params[0], Utilities::FORMAT_CAMELCASE) : 'Index';
     $this->action = isset($url_params[1]) ? $utilities->formater($url_params[1], Utilities::FORMAT_CAMELCASE_2) : 'index';
     $this->parameters = isset($url_params[2]) ? array_slice($url_params, 2) : [];
 }
 /**
  * @return array<list_Item>
  */
 public final function getItems()
 {
     $request = Controller::getInstance()->getContext()->getRequest();
     $form = null;
     $conditionOn = null;
     try {
         $conditionOnId = intval($request->getParameter('documentId', 0));
         if ($conditionOnId > 0) {
             $conditionOn = DocumentHelper::getDocumentInstance($conditionOnId);
             $form = $conditionOn->getForm();
         } else {
             $parent = DocumentHelper::getDocumentInstance(intval($request->getParameter('parentId', 0)));
             if ($parent instanceof form_persistentdocument_baseform) {
                 $form = $parent;
             } else {
                 if ($parent instanceof form_persistentdocument_group) {
                     $form = $parent->getForm();
                 }
             }
         }
     } catch (Exception $e) {
         Framework::exception($e);
     }
     if (!$form instanceof form_persistentdocument_baseform) {
         return array();
     }
     $results = array();
     $excludeIds = $this->getExcludeIds($conditionOn);
     foreach ($form->getDocumentService()->getValidActivationFields($form, $excludeIds) as $field) {
         $results[] = new list_Item($field->getLabel(), $field->getId());
     }
     return $results;
 }
Esempio n. 10
0
 public function addError()
 {
     if (func_num_args() < 1) {
         \Framework::debug("Need at least 1 parameter");
     }
     $args = func_get_args();
     switch (count($args)) {
         case 1:
             if (is_object($args[0])) {
                 $this->errors->add($args[0]);
             } elseif (is_string($args[0])) {
                 $this->errors->add(new ErrorGlobal($args[0]));
             } else {
                 \Framework::debug("Wrong argument passed to add errors");
             }
             break;
         case 2:
             $this->errors->add(new ErrorForm($args[0], $args[1]));
             break;
         case 3:
             $this->errors->add(new ErrorForm($args[0], $args[1], $args[2]));
             break;
         default:
             \Framework::debug("This function can't has " . count($args) . " arguments");
             break;
     }
 }
Esempio n. 11
0
 /**
  * Create a new MailManager and set all the relevant header flags for
  * sending a message from $sender to $pers->getEmail
  *
  * @param $pers Person A person object containing recipient information
  * @param $sender string The sender, as to be defined in the mail's
  *                       envelope
  * @param $senderName string The name that should appear in the sender
  *                           field
  * @param $sendHeader string The sender, as to be defined in the mail's
  *                           header
  */
 public function __construct($pers, $sender, $senderName, $sendHeader, $alternateAddress = null)
 {
     if (!$pers instanceof Person) {
         throw new ConfusaGenException("Error: First argument to the " . "MailManager constructor is not a " . "valid person object!");
     }
     $this->mailer = new PHPMailer();
     if (is_null($this->mailer)) {
         Framework::error_output("Could not create mailer. Aborting");
         return;
     }
     $this->mailer->CharSet = "UTF-8";
     $this->mailer->Mailer = "sendmail";
     /* set the envelope "from" address using the sendmail option -f, and
      * the return-path header */
     $this->mailer->Sender = $sender;
     /* set the header "from" address */
     $this->mailer->From = $sendHeader;
     $this->mailer->FromName = $senderName;
     $this->mailer->WordWrap = 80;
     $this->toAddr = $pers->getEmail();
     if (!is_null($alternateAddress)) {
         $this->toAddr = $alternateAddress;
     }
     $this->mailer->AddAddress($this->toAddr, $pers->getName());
     $help_desk = $pers->getSubscriber()->getHelpEmail();
     /* add a reply-to to the helpdesk, if a helpdesk is defined */
     if (isset($help_desk)) {
         $support_name = $pers->getSubscriber()->getOrgName() . " support";
         $this->mailer->AddReplyTo($help_desk, $support_name);
     }
 }
 /**
  * @return array<list_Item>
  */
 public final function getItems()
 {
     try {
         $request = Controller::getInstance()->getContext()->getRequest();
         $questionId = intval($request->getParameter('questionId', 0));
         $question = DocumentHelper::getDocumentInstance($questionId);
     } catch (Exception $e) {
         if (Framework::isDebugEnabled()) {
             Framework::debug(__METHOD__ . ' EXCEPTION: ' . $e->getMessage());
         }
         return array();
     }
     // Here we must use instanceof and not getDocumentModelName to work with injection.
     $results = array();
     if ($question instanceof form_persistentdocument_boolean) {
         $trueLabel = $question->getTruelabel();
         $falseLabel = $question->getFalselabel();
         $results[$trueLabel] = new list_Item($trueLabel, $trueLabel);
         $results[$falseLabel] = new list_Item($falseLabel, $falseLabel);
     } else {
         if ($question instanceof form_persistentdocument_list) {
             $results = $question->getDataSource()->getItems();
         }
     }
     return $results;
 }
 /**
  * @param form_persistentdocument_mail $document
  * @param Integer $parentNodeId Parent node ID where to save the document (optionnal => can be null !).
  * @throws form_ReplyToFieldAlreadyExistsException
  * @return void
  */
 protected function preSave($document, $parentNodeId = null)
 {
     if ($document->getMultiline()) {
         $document->setValidators('emails:true');
     } else {
         $document->setValidators('email:true');
     }
     if ($parentNodeId !== NULL) {
         $form = DocumentHelper::getDocumentInstance($parentNodeId);
     } else {
         $form = $this->getFormOf($document);
     }
     if ($form === null) {
         if (Framework::isWarnEnabled()) {
             Framework::warn(__METHOD__ . ' the mail field document (' . $document->__toString() . ')is not in a form');
         }
     } else {
         if ($document->getUseAsReply()) {
             $oldReplyField = form_BaseFormService::getInstance()->getReplyToField($form);
             if ($oldReplyField !== null && $oldReplyField !== $document) {
                 Framework::error(__METHOD__ . ' Old reply field :' . $oldReplyField->__toString());
                 throw new form_ReplyToFieldAlreadyExistsException(f_Locale::translate('&modules.form.bo.errors.Mail-field-for-replyto-exists'));
             }
         }
     }
     parent::preSave($document, $parentNodeId);
 }
 public function show_Main()
 {
     $charImg = array();
     for ($i = 1; $i <= HIGHEST_CHAR_IMG; $i++) {
         $charImg[] = array("id" => $i, "name" => $i < 10 ? "0" . $i : $i);
     }
     Framework::TPL()->assign('charImg', $charImg);
 }
Esempio n. 15
0
function sendFile_Rangable($filename, $contentType = "binary/octet")
{
    if (!file_exists($filename)) {
        return Framework::debug(DEBUG_FATAL, "sendFile_Ranagable() - Unknown file {$filename}");
    }
    header("Content-Type: {$contentType}");
    $fp = @fopen($filename, 'rb');
    header("Accept-Ranges: bytes");
    $size = filesize($filename);
    // File size
    $length = $size;
    // Content length
    $start = 0;
    // Start byte
    $end = $size - 1;
    // End byte
    if (isset($_SERVER['HTTP_RANGE'])) {
        $c_start = $start;
        $c_end = $end;
        list(, $range) = explode('=', $_SERVER['HTTP_RANGE'], 2);
        if (strpos($range, ',') !== false) {
            header('HTTP/1.1 416 Requested Range Not Satisfiable');
            header("Content-Range: bytes {$start}-{$end}/{$size}");
            exit;
        }
        if ($range == '-') {
            $c_start = $size - substr($range, 1);
        } else {
            $range = explode('-', $range);
            $c_start = $range[0];
            $c_end = isset($range[1]) && is_numeric($range[1]) ? $range[1] : $size;
        }
        $c_end = $c_end > $end ? $end : $c_end;
        if ($c_start > $c_end || $c_start > $size - 1 || $c_end >= $size) {
            header('HTTP/1.1 416 Requested Range Not Satisfiable');
            header("Content-Range: bytes {$start}-{$end}/{$size}");
            exit;
        }
        $start = $c_start;
        $end = $c_end;
        $length = $end - $start + 1;
        fseek($fp, $start);
        header('HTTP/1.1 206 Partial Content');
    }
    header("Content-Range: bytes {$start}-{$end}/{$size}");
    header("Content-Length: " . $length);
    $buffer = 1024 * 8;
    while (!feof($fp) && ($p = ftell($fp)) <= $end) {
        if ($p + $buffer > $end) {
            $buffer = $end - $p + 1;
        }
        set_time_limit(0);
        echo fread($fp, $buffer);
        flush();
    }
    fclose($fp);
    exit;
}
Esempio n. 16
0
 public function loadHits()
 {
     $page = $_SERVER['REQUEST_URI'];
     $rowAll = Framework::getDb()->getFirstRow("SELECT SUM(hits) AS hits FROM page_hits WHERE page = '" . esc($page) . "'");
     $rowToday = Framework::getDb()->getFirstRow("SELECT SUM(hits) AS hits FROM page_hits WHERE page = '" . esc($page) . "' AND added >= DATE_FORMAT('Y-m-d', NOW())");
     $rowMonth = Framework::getDb()->getFirstRow("SELECT SUM(hits) AS hits FROM page_hits WHERE page = '" . esc($page) . "' AND added >= DATE_FORMAT('Y-m', NOW())");
     $rowYear = Framework::getDb()->getFirstRow("SELECT SUM(hits) AS hits FROM page_hits WHERE page = '" . esc($page) . "' AND added >= DATE_FORMAT('Y', NOW())");
     $this->PageHits = array('all' => $rowAll ? $rowAll['hits'] : 0, 'today' => $rowToday ? $rowToday['hits'] : 0, 'month' => $rowMonth ? $rowMonth['hits'] : 0, 'hits' => $rowYear ? $rowYear['hits'] : 0);
 }
Esempio n. 17
0
 /**
  * start 
  * 
  * @param mixed $dsn 
  * @access public
  * @return void
  */
 public function start($dsn)
 {
     Framework::$db = DB::connect($dsn);
     if (!PEAR::isError(Framework::$db)) {
         Framework::$db->setFetchMode(DB_FETCHMODE_ASSOC);
     } else {
         throw new Framework_Exception(Framework::$db);
     }
 }
Esempio n. 18
0
 public function write($id, $data)
 {
     #Todo lo almacenado en la sesion se codifica para mayor seguridad
     if (strlen(trim($data)) > 0) {
         $consulta = "REPLACE INTO __sesiones\r\n                        SET id = :id, fecha = NOW(), data = :data;";
         $valores = array("id" => $id, "data" => Framework::Encrypt($data));
         return $this->_db->query($consulta, $valores);
     }
 }
Esempio n. 19
0
 public function show_Error()
 {
     Framework::TPL()->assign('status', 'error');
     if (is_numeric($this->get(1))) {
         $id = $this->get(1);
     } else {
         $id = -1;
     }
     Framework::TPL()->assign('error', $id);
 }
Esempio n. 20
0
 private function handleMaintText()
 {
     if (array_key_exists("nren_maint_msg", $_POST)) {
         if ($this->person->getNREN()->setMaintMsg($this->person, $_POST['nren_maint_msg'])) {
             Framework::success_output($this->translateTag("l10n_nren_maint_msg_success", 'portal_config'));
         } else {
             Framework::error_output($this->translateTag("l10n_nren_maint_msg_failure", 'portal_config'));
         }
     }
 }
Esempio n. 21
0
 public function install()
 {
     try {
         $scriptReader = import_ScriptReader::getInstance();
         $scriptReader->executeModuleScript('form', 'init.xml');
     } catch (Exception $e) {
         echo "ERROR: " . $e->getMessage() . "\n";
         Framework::exception($e);
     }
 }
Esempio n. 22
0
 public function show_deleteUser()
 {
     if ($this->user->password != Framework::hash($_POST['password'])) {
         $this->error('Das Passwort war falsch!');
     }
     R::trash($this->user);
     $this->show_Logoff();
     $this->output('deleted', true);
     $this->output('message', 'Der Account wurde gelöscht.');
 }
Esempio n. 23
0
 /**
  * Gets the service object of the specified type.
  * @param  string service name
  * @param  array  options in case service is not singleton
  * @return mixed
  */
 public static function getService($name, array $options = NULL)
 {
     if (!is_string($name) || $name === '') {
         throw new InvalidArgumentException("Service name must be a non-empty string, " . gettype($name) . " given.");
     }
     $session = Environment::getSession('MokujiServiceLocator');
     $lower = strtolower($name);
     if (isset($session->{$lower})) {
         // instantiated singleton
         if ($options) {
             throw new InvalidArgumentException("Service named '{$name}' is singleton and therefore can not have options.");
         }
         return $session->{$lower};
     } elseif (isset($session->factories[$lower])) {
         list($factory, $singleton, $defOptions) = $session->factories[$lower];
         if ($singleton && $options) {
             throw new InvalidArgumentException("Service named '{$name}' is singleton and therefore can not have options.");
         } elseif ($defOptions) {
             $options = $options ? $options + $defOptions : $defOptions;
         }
         if (is_string($factory) && strpos($factory, ':') === FALSE) {
             // class name
             Framework::fixNamespace($factory);
             if (!class_exists($factory)) {
                 throw new AmbiguousServiceException("Cannot instantiate service '{$name}', class '{$factory}' not found.");
             }
             $service = new $factory();
             if ($options && method_exists($service, 'setOptions')) {
                 $service->setOptions($options);
                 // TODO: better!
             }
         } else {
             // factory callback
             $factory = callback($factory);
             if (!$factory->isCallable()) {
                 throw new InvalidStateException("Cannot instantiate service '{$name}', handler '{$factory}' is not callable.");
             }
             $service = $factory->invoke($options);
             if (!is_object($service)) {
                 throw new AmbiguousServiceException("Cannot instantiate service '{$name}', value returned by '{$factory}' is not object.");
             }
         }
         if ($singleton) {
             $session->{$lower} = $service;
             unset($session->factories[$lower]);
         }
         return $service;
     }
     if ($this->parent !== NULL) {
         return $this->parent->getService($name, $options);
     } else {
         throw new InvalidStateException("Service '{$name}' not found.");
     }
 }
 public function __destruct()
 {
     $this->_use_scripts[] = "game";
     $this->_use_scripts = Framework::bundleJavaScripts($this->_use_scripts);
     $this->regenerateSecureHash();
     Framework::TPL()->assign("fSecureHash", $this->_secureHash);
     Framework::TPL()->assign("User", $this->user);
     Framework::TPL()->assign("js_scripts", $this->_use_scripts);
     Framework::TPL()->assign("template", $this->_use_tpl);
     Framework::TPL()->display("game.html");
 }
Esempio n. 25
0
 public function listAction()
 {
     $page = Framework::getNullRequrest('page', 1);
     $pagesize = Framework::getNullRequrest('pagesize', 10);
     $goods_model = new GoodsModel();
     $list = $goods_model->getList($page, $pagesize);
     $this->view->assign('list', $list);
     $page_html = PageTool::show($page, $pagesize, $goods_model->autoTotalCount());
     $this->view->assign('page_html', $page_html);
     $this->view->display('list.tpl');
 }
Esempio n. 26
0
 function process()
 {
     if (CS::getSessionKey('hasAcceptedAUP') !== true) {
         Framework::error_output($this->translateTag("l10n_err_aupagreement", "processcsr"));
         return;
     }
     $user_cert_enabled = $this->person->testEntitlementAttribute(Config::get_config('entitlement_user'));
     $this->tpl->assign('email_status', $this->person->getNREN()->getEnableEmail());
     $this->tpl->assign('user_cert_enabled', $user_cert_enabled);
     $this->tpl->assign('content', $this->tpl->fetch('select_email.tpl'));
 }
Esempio n. 27
0
 function boot()
 {
     if (!defined('APP_ROOT')) {
         define('APP_ROOT', dirname(dirname(__FILE__)));
     }
     self::$tmp_path = APP_ROOT . '/tmp';
     // initialize preference system
     include APP_ROOT . '/framework/lib/preferences.php';
     self::$prefs = new PreferenceCollection(array(self::$tmp_path));
     self::$prefs->read('cache', true, self::$tmp_path);
     Timer::start();
 }
Esempio n. 28
0
 /**
  * createDB
  *
  * @access  private
  * @return  reference
  * @static
  */
 private static function &createDB()
 {
     if (is_null(Framework::$db)) {
         if (!isset(Framework::$site->config->db)) {
             Framework::$db = null;
         } else {
             $gen = Framework_DB::factory(Framework::$site->config->db);
             Framework::$db = $gen->singleton();
         }
     }
     return Framework::$db;
 }
 /**
  * Creates a Module and sets up the path and class name
  * @return Module
  */
 public function __construct($class = null)
 {
     if (!$class) {
         $class = get_class($this);
     }
     $this->class = $class;
     if ($this->class === __CLASS__) {
         $this->path = SERVER_DIR . '/core/';
     } else {
         $this->path = dirname(Framework::classLocate($this->class));
     }
 }
Esempio n. 30
0
 function dispatch()
 {
     require_once 'framework.php';
     try {
         session_start();
         Framework::boot();
         Framework::$controller = new Controller();
         Framework::$controller->process_route();
     } catch (Exception $e) {
         Framework::$controller->process_exception($e);
     }
 }