public function __construct()
 {
     parent::__construct();
     $this->From = weeApp()->cnf('mail.from');
     $this->FromName = weeApp()->cnf('mail.from.name');
     $this->Mailer = weeApp()->cnf('mail.method');
     $this->Sender = weeApp()->cnf('mail.from');
 }
Beispiel #2
0
 protected function runSQLScript($sFilename)
 {
     $aQueries = explode(';', file_get_contents($sFilename));
     $iCount = count($aQueries) - 1;
     try {
         for ($i = 0; $i < $iCount; $i++) {
             weeApp()->db->query($aQueries[$i]);
         }
     } catch (DatabaseException $e) {
     }
 }
Beispiel #3
0
 /**
 	This event sends the requested pastebin as a text file instead of outputting it to the browser.
 */
 protected function eventDownload($aEvent)
 {
     ctype_digit($aEvent['get']['id']) or burn('UnexpectedValueException', _T('The requested pastebin ID is invalid.'));
     // After checking that the ID is a number, we fetch the pastebin.
     $oSet = new pastebinSet();
     $oPastebin = $oSet->fetch($aEvent['get']['id']);
     // Then we change the template to one that will only output the pastebin text.
     $this->sBaseTemplate = 'pastebin_download';
     // We also change the encoding settings from XHTML (defaults) to plain text.
     $this->getRenderer()->setEncoder(new weeTextEncoder());
     // Then we tell the application object to serve this output as a file.
     weeApp()->serveAsFile(sprintf('pastebin_%d.txt', $aEvent['get']['id']));
     // Let's not forget to send the pastebin data to the template, of course.
     $this->set('pastebin', $oPastebin);
 }
Beispiel #4
0
 /**
 	Create a new weeAuthDbTable object and stores the paramters.
 
 	Parameters:
 		* db:					The weeDatabase object to authenticate against.
 		* table:				The table containing the credentials to authenticate against.
 		* identifier_field:		The field containing the identifiers.
 		* password_field:		The field containing the passwords hashed with 'password_treatment'.
 		* password_treatment:	The callback applied to each passwords stored in the 'password_field' field. Defaults to 'sha1'.
 		* hash_treatment:		The callback to use to hash passwords stored client-side. Defaults to 'sha1'.
 
 	@param $aParams List of parameters to authenticate against.
 */
 public function __construct($aParams = array())
 {
     if (empty($aParams['db'])) {
         $aParams['db'] = weeApp()->db;
     }
     is_object($aParams['db']) && $aParams['db'] instanceof weeDatabase or burn('InvalidArgumentException', sprintf(_WT('Parameter "%s" must be an instance of "%s".'), 'db', 'weeDatabase'));
     empty($aParams['table']) and burn('InvalidArgumentException', _WT('You must provide a parameter "table" containing the name of the credentials table in your database.'));
     empty($aParams['identifier_field']) and burn('InvalidArgumentException', _WT('You must provide a parameter "identifier_field" containing the name of the field for the identifiers.'));
     empty($aParams['password_field']) and burn('InvalidArgumentException', _WT('You must provide a parameter "password_field" containing the name of the field for the passwords.'));
     if (empty($aParams['password_treatment'])) {
         $aParams['password_treatment'] = 'sha1';
     } else {
         is_callable($aParams['password_treatment']) or burn('InvalidArgumentException', sprintf(_WT('The "%s" parameter must be a valid callback.'), 'password_treatment'));
     }
     parent::__construct($aParams);
 }
Beispiel #5
0
 /**
 	Creates a new ACL driver.
 
 	Parameters:
 		* db:				The weeDatabase object to be used. Defaults to weeApp()->db.
 		* sr_table:			The table containing the subject-role relationship.
 		* rp_table:			The table containing the role-permissions relationship.
 		* subject_fields:	Field names forming the primary key identifying subjects. Defaults to 'user_id'.
 		* role_field:		Field name for the role ID. Usually an integer. Defaults to 'role_id'.
 		* operation_field:	Field name for the operation. Usually a string. Defaults to 'perm_operation'.
 		* resource_fields:	Field names to define the resources. Defaults to array('perm_resource').
 
 	@param $aParams List of parameters to use for the database.
 */
 public function __construct($aParams)
 {
     if (empty($aParams['db'])) {
         $aParams['db'] = weeApp()->db;
     }
     is_object($aParams['db']) && $aParams['db'] instanceof weeDatabase or burn('InvalidArgumentException', sprintf(_WT('Parameter "%s" must be an instance of "%s".'), 'db', 'weeDatabase'));
     empty($aParams['sr_table']) and burn('InvalidArgumentException', _WT('You must provide a parameter "sr_table" containing the name of the subject-role table in your database.'));
     empty($aParams['rp_table']) and burn('InvalidArgumentException', _WT('You must provide a parameter "rp_table" containing the name of the role-permission table in your database.'));
     if (empty($aParams['subject_fields'])) {
         $aParams['subject_fields'] = 'user_id';
     }
     if (empty($aParams['role_field'])) {
         $aParams['role_field'] = 'role_id';
     }
     if (empty($aParams['operation_field'])) {
         $aParams['operation_field'] = 'perm_operation';
     }
     if (empty($aParams['resource_fields'])) {
         $aParams['resource_fields'] = array('perm_resource');
     } elseif (is_string($aParams['resource_fields'])) {
         $aParams['resource_fields'] = explode(',', $aParams['resource_fields']);
     }
     $this->aParams = $aParams;
 }
Beispiel #6
0
<?php

weeApp()->locale->set('fr_FR');
// locale fr_FR.UTF-8
Beispiel #7
0
<?php

weeApp()->mydriver->myMethod();
Beispiel #8
0
 /**
 	Returns the database associated to this model.
 
 	@return	weeDatabase				The database associated to this model.
 	@throw	IllegalStateException	No database has been associated to this model.
 */
 public function getDb()
 {
     $this->oDatabase !== null or is_callable('weeApp') or burn('IllegalStateException', _WT('No database has been associated to this model.'));
     return $this->oDatabase === null ? weeApp()->db : $this->oDatabase;
 }
Beispiel #9
0
<?php

weeApp()->locale->set('it', '8859-1', 'euro');
// locale it_IT.8859-1@euro
Beispiel #10
0
<?php

weeApp()->session['my_str'] = 'egg';
weeApp()->session['my_int'] = 42;
echo weeApp()->session['my_str'];
Beispiel #11
0
<?php

$oResults = weeApp()->db->query('SELECT * FROM articles ORDER BY art_date DESC LIMIT 5');
Beispiel #12
0
<?php

// Note: It is highly recommended to filter the input first
$sQuery = 'SELECT * FROM wee_articles WHERE art_id=' . weeApp()->db->escape($_GET['id']);
$oResults = weeApp()->db->query($sQuery);
Beispiel #13
0
<?php

$oResults = weeApp()->db->query('SELECT * FROM wee_articles WHERE art_id=:id', array('id' => 3));
Beispiel #14
0
<?php

$o = weeApp()->session;
$o['my_str'] = 'egg';
$o['my_int'] = 42;
$o['my_float'] = 42.4242;
// put more variables here
Beispiel #15
0
 /**
 	Returns the database associated to this set.
 
 	@return weeDatabase The database associated to this set.
 */
 public function getDb()
 {
     empty($this->oDatabase) && !is_callable('weeApp') and burn('IllegalStateException', _WT('No database has been associated to this set.'));
     return empty($this->oDatabase) ? weeApp()->db : $this->oDatabase;
 }
Beispiel #16
0
<?php

$oResults = weeApp()->db->query('SELECT * FROM wee_articles WHERE art_id=? AND art_date=?', 3, '2008-02-15');
Beispiel #17
0
<?php

// Note: Always filter the data first
// Insert a random row
$oResults = weeApp()->db->query('INSERT INTO wee_articles (art_contents) VALUES (:art_contents)', $_POST);
// Retrieve the number of affected rows and display it
echo weeApp()->db->numAffectedRows();
Beispiel #18
0
<?php

// echo the value of the cookie my_cookie
echo weeApp()->cookies['my_cookie'];
Beispiel #19
0
<?php

$aDbParams = weeApp()->cnfArray('db');
echo $aDbParams['host'];
// echoes localhost
Beispiel #20
0
<?php

// Retrieve the number of rows in a table
$iCount = weeApp()->db->queryValue('SELECT COUNT(*) FROM example_table');
Beispiel #21
0
<?php

// Note: It is highly recommended to filter the input first
$oResults = weeApp()->db->query('SELECT * FROM wee_articles WHERE art_id=:id', $_GET);
Beispiel #22
0
<?php

// Note: Always filter the data first
// Insert a random row
$oResults = weeApp()->db->query('INSERT INTO wee_articles (art_contents) VALUES (:art_contents)', $_POST);
// Retrieve the id and display it
echo weeApp()->db->getPKId('art_id_seq');
Beispiel #23
0
<?php

weeApp()->locale->set('fr');
// locale fr_FR.UTF-8
Beispiel #24
0
<?php

echo weeApp()->cnf('db.host');
// echoes localhost
Beispiel #25
0
<?php

weeApp()->locale->set('zh', 'UTF-16');
// locale zh_CN.UTF-16
Beispiel #26
0
<?php

// If you are using the application module
$oMeta = weeApp()->db->meta();
// Otherwise
$oMeta = $oDb->meta();
Beispiel #27
0
<?php

weeApp()->cookies['my_str'] = 'egg';
weeApp()->cookies['my_int'] = 42;
if (isset(weeApp()->cookies['my_str'])) {
    echo weeApp()->cookies['my_str'];
}
Beispiel #28
0
 /**
 	Create the frame and set the controller associated with it.
 	The controller is used to dispatch events. It is usually a weeApplication object.
 
 	@param $oController Controller associated with this frame, defaults to weeApp()
 */
 public function __construct($oController = null)
 {
     is_null($oController) && !is_callable('weeApp') and burn('InvalidArgumentException', _WT('You need to specify a controller that weeFrame can use to dispatch events.'));
     $this->oController = is_null($oController) ? weeApp() : $oController;
 }
Beispiel #29
0
<?php

$oStatement = weeApp()->db->prepare('INSERT INTO table VALUES(1, 2, 3)');
$oStatement->execute();
Beispiel #30
0
 protected function setup($aEvent)
 {
     weeApp()->session['is_admin'] or burn('UnauthorizedAccessException', _T('You are not permitted to access this page.'));
 }