Пример #1
0
 /**
 	Sets the widget and complete data passed to the weeForm object.
 	Usually either $_POST or $_GET.
 
 	@param	$oWidget				The widget to validate.
 	@param	$aData					The data to check, if applicable.
 	@throw	IllegalStateException	The validator has already been attached to a form widget.
 */
 public function setFormData(SimpleXMLElement $oWidget, array $aData)
 {
     $this->oWidget === null or burn('IllegalStateException', _WT('The validator has already been attached to a form widget.'));
     $oWidget->getName() === 'widget' or burn('InvalidArgumentException', _WT('The $oWidget argument must be a widget element.'));
     $this->aData = $aData;
     $this->oWidget = $oWidget;
 }
Пример #2
0
 /**
 	Returns a table of a given name in the database.
 
 	@param	$sName						The name of the table.
 	@return	weeMySQLDbMetaTable			The table.
 	@throw	UnexpectedValueException	The tables does not exist.
 */
 public function table($sName)
 {
     $oQuery = $this->db()->query("\n\t\t\tSELECT TABLE_NAME AS name, TABLE_COMMENT AS comment\n\t\t\t\tFROM\tinformation_schema.tables\n\t\t\t\tWHERE\tTABLE_NAME\t\t= ?\n\t\t\t\t\tAND\tTABLE_SCHEMA\t= DATABASE()\n\t\t\t\t\tAND\tTABLE_TYPE\t\t= 'BASE TABLE'\n\t\t\t\tLIMIT\t1\n\t\t", $sName);
     count($oQuery) == 1 or burn('UnexpectedValueException', sprintf(_WT('Table "%s" does not exist.'), $sName));
     $sClass = $this->getTableClass();
     return new $sClass($this, $oQuery->fetch());
 }
Пример #3
0
 /**
 	Return the default value of the column.
 
 	@return	string	The default value of the column.
 	@throw	IllegalStateException	The column does not have a default value.
 */
 public function defaultValue()
 {
     $this->hasDefault() or burn('IllegalStateException', _WT('The column does not have a default value.'));
     // Strip wrapping parenthesis.
     $i = strspn($this->aData['default'], '(');
     return substr($this->aData['default'], $i, -$i);
 }
Пример #4
0
 /**
 	Returns a table of a given name in the schema.
 
 	@param	$sName						The name of the table.
 	@return	weePgSQLDbMetaTable			The table.
 	@throw	UnexpectedValueException	The table does not exist in the schema.
 */
 public function table($sName)
 {
     $oQuery = $this->meta()->db()->query("\n\t\t\tSELECT\t\tn.nspname AS schema, c.relname AS name, r.rolname AS owner,\n\t\t\t\t\t\tpg_catalog.obj_description(c.oid, 'pg_class') AS comment,\n\t\t\t\t\t\tpg_catalog.pg_has_role(r.rolname, 'USAGE') AS alterable\n\t\t\t    FROM\tpg_catalog.pg_class c\n\t\t\t\t\t\tJOIN pg_catalog.pg_namespace\tn ON n.oid = c.relnamespace\n\t\t\t\t\t\tJOIN pg_catalog.pg_roles\t\tr ON r.oid = c.relowner\n\t\t\t\tWHERE\t\tc.relname = :table\n\t\t\t\t\t\tAND\tc.relkind = 'r'\n\t\t\t\t\t\tAND\tn.nspname = :name\n\t\t\t\tLIMIT\t1\n\t\t", array('table' => $sName) + $this->aData);
     count($oQuery) == 1 or burn('UnexpectedValueException', sprintf(_WT('Table "%s" does not exist in the schema.'), $sName));
     $sClass = $this->meta()->getTableClass();
     return new $sClass($this->meta(), $oQuery->fetch());
 }
Пример #5
0
 /**
 	Configure the filename and the data for this template.
 
 	@param $sTemplate	The template name.
 	@param $aData		Data to be used in the template.
 */
 public function __construct($sTemplate, array $aData = array())
 {
     $this->sFilename = TPL_PATH . $sTemplate . TPL_EXT;
     file_exists($this->sFilename) or burn('FileNotFoundException', sprintf(_WT('The file "%s" does not exist.'), $this->sFilename));
     parent::__construct($aData);
     $this->setMIMEType('text/html');
 }
Пример #6
0
 /**
 	Define an additional header for this email.
 	This method can be called directly from the template itself.
 
 	@param $sName The header name.
 	@param $sValue New value for that header.
 */
 public function header($sName, $sValue)
 {
     empty($sName) and burn('UnexpectedValueException', _WT('The argument $sName must not be empty.'));
     empty($sValue) and burn('UnexpectedValueException', _WT('The argument $sValue must not be empty.'));
     strpos($sName, "\r") !== false || strpos($sName, "\n") !== false || strpos($sValue, "\r") !== false || strpos($sValue, "\n") !== false and burn('UnexpectedValueException', _WT('Line breaks are not allowed in headers to prevent HTTP Response Splitting.'));
     strpos($sName, "") !== false || strpos($sValue, "") !== false and burn('UnexpectedValueException', _WT('NUL characters are not allowed in headers.'));
     $this->aHeaders[$sName] = $sValue;
 }
Пример #7
0
 /**
 	Executes the prepared statement.
 
 	@return	mixed	An instance of weeDatabaseDummyResult if the query returned rows or null.
 */
 public function execute()
 {
     $this->oStatement->execute();
     $a = $this->oStatement->errorInfo();
     $a[0] == '0000' or burn('DatabaseException', sprintf(_WT("Failed to execute the query with the following error:\n%s"), $a[2]));
     $this->iNumAffectedRows = $this->oDb->doRowCount($this->oStatement, true);
     if ($this->oStatement->columnCount()) {
         return new weeDatabaseDummyResult($this->oStatement->fetchAll(PDO::FETCH_ASSOC));
     }
 }
Пример #8
0
    /**
    	Returns the default value of the column.
    
    	@return	string					The default value of the column.
    	@throw	IllegalStateException	The column does not have a default value.
    */
    public function defaultValue()
    {
        $this->hasDefault() or burn('IllegalStateException', _WT('The column does not have a default value.'));
        return $this->db()->queryValue('
			SELECT		pg_catalog.pg_get_expr(adbin, adrelid)
				FROM	pg_catalog.pg_attrdef
				WHERE	adrelid	= ?::regclass
					AND	adnum	= ?
		', $this->oTable->quotedName(), $this->num());
    }
Пример #9
0
 /**
 	Executes the prepared statement.
 
 	@return	mixed	An instance of weeDatabaseDummyResult if the query returned rows or null.
 */
 public function execute()
 {
     // oci_execute triggers a warning when the statement could not be executed.
     @oci_execute($this->rStatement, OCI_DEFAULT) or burn('DatabaseException', sprintf(_WT("Failed to execute the query with the following error:\n%s"), array_value(oci_error($this->rStatement), 'message')));
     $this->iNumAffectedRows = oci_num_rows($this->rStatement);
     if (oci_num_fields($this->rStatement) > 0) {
         // TODO: Check whether the silence operator is really required here.
         @oci_fetch_all($this->rStatement, $aRows, 0, -1, OCI_ASSOC | OCI_FETCHSTATEMENT_BY_ROW);
         return new weeDatabaseDummyResult($aRows);
     }
 }
Пример #10
0
 /**
 	Binds parameters to the statement.
 
 	If the query is not using interrogation marks placeholders,
 	you can call this method with a parameter name and its value.
 
 	@overload	bind($sName, $mValue)		Example of query call with one argument instead of an array.
 	@param		$aParameters				The parameters to bind to the statement.
 	@return		$this						Used to chain methods.
 	@throw		InvalidArgumentException	The bind method has been called with one argument but it's not an array.
 	@throw		InvalidArgumentException	The bind method has been called with two arguments but its first is not a string.
 	@throw		BadMethodCallException		The bind method has been called with more than 2 arguments.
 */
 public function bind($aParameters)
 {
     if (func_num_args() > 1) {
         is_string($aParameters) or burn('InvalidArgumentException', _WT('The first argument of the bind method should be a string when called with two parameters.'));
         $aParameters = array($aParameters => func_get_arg(1));
     } else {
         is_array($aParameters) or burn('InvalidArgumentException', _WT('The given argument of the bind method is not an array.'));
     }
     $this->doBind($aParameters);
     return $this;
 }
Пример #11
0
 /**
 	Does the mssql-dependent work of the execute method.
 
 	@param	$sQuery			The query to execute.
 	@return	weeSQLiteResult	A result set for SELECT queries.
 */
 protected function doQuery($sQuery)
 {
     // mssql_query triggers a warning when the query could not be executed.
     $m = @mssql_query($sQuery, $this->rLink);
     $m === false and burn('DatabaseException', sprintf(_WT("Failed to execute the query with the following error:\n%s"), mssql_get_last_message()));
     // Get it now since it can be wrong if numAffectedRows is called after getPKId
     $this->iNumAffectedRows = mssql_rows_affected($this->rLink);
     if ($m !== true) {
         return new weeMSSQLResult($m);
     }
 }
Пример #12
0
 /**
 	Attachs a value to the validator.
 
 	$mValue must be either a string, an integer, a float, an instance of Printable or an object castable to string.
 
 	@param	$mValue						The value to attach.
 	@return	$this						Used to chain methods.
 	@throw	DomainException				$mValue is not of a correct type.
 */
 public function setValue($mValue)
 {
     if (is_object($mValue)) {
         if ($mValue instanceof Printable) {
             $mValue = $mValue->toString();
         } elseif (method_exists($mValue, '__toString')) {
             $mValue = (string) $mValue;
         }
     }
     is_null($mValue) || is_string($mValue) || is_int($mValue) || is_float($mValue) or burn('DomainException', _WT('$mValue is not of a correct type.'));
     return parent::setValue($mValue);
 }
Пример #13
0
    /**
    	Return a table of a given name in the schema.
    
    	@param	$sName	The name of the table.
    	@return	weeOracleDbMetaTable		The table.
    	@throw	UnexpectedValueException	The table does not exist in the schema.
    */
    public function table($sName)
    {
        $oQuery = $this->meta()->db()->query('
			SELECT	OWNER AS "schema", TABLE_NAME AS "name", t.NUM_ROWS, c.COMMENTS AS "comment"
			FROM	SYS.ALL_TABLES t LEFT JOIN SYS.ALL_TAB_COMMENTS c USING (OWNER, TABLE_NAME)
			WHERE	TABLE_NAME	= :table
				AND	OWNER		= :name
				AND	t.DURATION IS NULL
		', array('table' => $sName) + $this->aData);
        count($oQuery) == 1 or burn('UnexpectedValueException', sprintf(_WT('Table "%s" does not exist in the schema.'), $sName));
        $sClass = $this->meta()->getTableClass();
        return new $sClass($this->meta(), $oQuery->fetch());
    }
Пример #14
0
 /**
 	Does the sqlite-dependent work of the execute method.
 
 	@param	$sQuery			The query to execute.
 	@return	weeSQLiteResult	A result set for SELECT queries.
 */
 protected function doQuery($sQuery)
 {
     // SQLiteDatabase::query triggers a warning when the query could not be executed.
     $m = @$this->oSQLiteDb->query($sQuery, SQLITE_ASSOC, $sLastError);
     if ($m === false) {
         if ($sLastError === null) {
             $sLastError = sqlite_error_string($this->oSQLiteDb->lastError());
         }
         burn('DatabaseException', sprintf(_WT("Failed to execute the query with the following error:\n%s"), $sLastError));
     }
     $this->iNumAffectedRows = $this->oSQLiteDb->changes();
     if ($m->numFields()) {
         return new weeSQLiteResult($m);
     }
 }
Пример #15
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);
 }
Пример #16
0
 /**
 	Encode an array.
 
 	@param	$a		The array to encode.
 	@return	array	The encoded array.
 	@throw	IllegalStateException This source does not have an encoder.
 */
 protected function encodeArray($a)
 {
     $this->getEncoder() !== null or burn('IllegalStateException', _WT('This data source does not have an encoder.'));
     foreach ($a as $mName => $mValue) {
         if ($mValue instanceof weeDataSource) {
             $mValue->setEncoder($this->oEncoder);
         } elseif (is_object($mValue)) {
             continue;
         } elseif (is_array($mValue)) {
             $a[$mName] = $this->encodeArray($mValue);
         } else {
             $a[$mName] = $this->getEncoder()->encode($mValue);
         }
     }
     return $a;
 }
Пример #17
0
 /**
 	Process the pipe.
 
 	This method should be called after the input of the pipe has been
 	sent into the output buffer.
 */
 public function process()
 {
     // Store LaTeX output in a temporary file
     $sTmpFilename = tempnam(null, null);
     file_put_contents($sTmpFilename, ob_get_clean());
     // Convert it to PDF
     $sTmpDir = sys_get_temp_dir();
     $sPdfLatex = 'cd ' . $sTmpDir . ' && pdflatex ' . array_value($this->aParams, 'options') . ' ' . $sTmpFilename;
     exec($sPdfLatex . ' > ' . $sTmpDir . '/pdflatex1.log');
     exec($sPdfLatex . ' > ' . $sTmpDir . '/pdflatex2.log');
     // filesize will trigger a warning if the file couldn't be stat'd (usually because it doesn't exist).
     $iSize = @filesize($sTmpFilename . '.pdf');
     $iSize === false and burn('UnexpectedValueException', _WT(sprintf('The conversion of file "%s" from LaTeX to PDF failed.', $sTmpFilename)));
     // Send the PDF to the browser
     safe_header('Content-Length: ' . $iSize);
     readfile($sTmpFilename . '.pdf');
     // Cleanup the temporary directory
     exec('rm ' . $sTmpFilename . '*');
 }
Пример #18
0
 /**
 	Initialize the mailbox connection.
 
 	The mailbox connection parameters are as follow:
 	* host:		Host name of the server hosting the mailbox. Default: localhost.
 	* port:		Port of the imap service. Default: 143.
 	* mailbox:	Mailbox name. Default: INBOX.
 	* flags:	Connection flags. Optionnal.
 	* user:		User name.
 	* password:	User password.
 
 	For a detailed list of available flags, please see the PHP documentation
 	for imap_open.
 
 	The connection to the mailbox is read-only until tested enough.
 
 	@param $aParams Mailbox connection parameters.
 	@see http://php.net/imap_open
 */
 public function __construct($aParams)
 {
     function_exists('imap_open') or burn('ConfigurationException', _WT('The IMAP PHP extension is required by the weeFetchMail class.'));
     empty($aParams['user']) and burn('InvalidParameterException', _WT('The user name was not provided in the connection parameters.'));
     empty($aParams['password']) and burn('InvalidParameterException', _WT('The user password was not provided in the connection parameters.'));
     // Fill in the default values
     $aParams = $aParams + array('host' => 'localhost', 'port' => 143, 'mailbox' => 'INBOX');
     $sConnection = '{' . $aParams['host'] . ':' . $aParams['port'];
     if (!empty($aParams['flags'])) {
         $sConnection .= $aParams['flags'];
     }
     $sConnection .= '}' . $aParams['mailbox'];
     $this->rLink = @imap_open($sConnection, $aParams['user'], $aParams['password'], OP_READONLY, 1);
     // We must clear the errors and alerts or they'll be thrown separately, possibly multiple times.
     // Despite their names, those functions also clear the errors buffer.
     imap_alerts();
     $a = imap_errors();
     // Then we only output the first error from the array we retrieved (usually good enough).
     $this->rLink === false and burn('UnexpectedValueException', _WT("Couldn't open stream \"%s\" with the following error:\n%s", $sConnection, $a[0]));
 }
Пример #19
0
 /**
 	Saves the data stored in this model to the database.
 
 	@throw IllegalStateException The data was empty or the table has no primary key.
 */
 public function update()
 {
     empty($this->aData) and burn('IllegalStateException', _WT('The model does not contain any data.'));
     $oDb = $this->getDb();
     if (empty($this->aMeta)) {
         $oSet = new $this->sSet();
         $oSet->setDb($oDb);
         $this->aMeta = $oSet->getMeta();
     }
     empty($this->aMeta['primary']) and burn('IllegalStateException', _WT('The table has no primary key defined.'));
     $sQuery = 'UPDATE ' . $this->aMeta['table'] . ' SET ';
     foreach ($this->aData as $sName => $mValue) {
         if (in_array($sName, $this->aMeta['columns']) && !in_array($sName, $this->aMeta['primary'])) {
             $sQuery .= $oDb->escapeIdent($sName) . '=' . $oDb->escape($this->aData[$sName]) . ', ';
         }
     }
     $sQuery = substr($sQuery, 0, -2) . ' WHERE';
     $sAnd = '';
     foreach ($this->aMeta['primary'] as $sName) {
         $sQuery .= $sAnd . $oDb->escapeIdent($sName) . '=' . $oDb->escape($this->aData[$sName]);
         $sAnd = ' AND ';
     }
     $this->query($sQuery);
 }
Пример #20
0
 /**
 	Returns the names of the columns of the primary key of the table.
 
 	As the columns taking part in the primary key are known by the table instance,
 	we provide a shortcut method to access these informations without
 	creating a new weeSQLiteDbMetaPrimaryKey instance. This shortcut is used
 	by the weeSQLiteDbMetaColumn::getValidator to check if the column is
 	"INTEGER PRIMARY KEY".
 
 	@return	array(string)			The names of the columns of the primary key of the table.
 	@throw	IllegalStateException	The table does not have a primary key.
 */
 public function primaryKeyColumnsNames()
 {
     $this->queryColumns();
     !empty($this->aPrimaryKey) or burn('IllegalStateException', _WT('The table does not have a primary key.'));
     return $this->aPrimaryKey;
 }
Пример #21
0
 /**
 	Hash a password in order to store it client-side.
 
 	@param $sPassword Password to be hashed.
 	@return string Hashed password.
 */
 public function hash($sPassword)
 {
     defined('MAGIC_STRING') or burn('IllegalStateException', _WT('You cannot hash a password without defining the MAGIC_STRING constant first.'));
     $sFunc = $this->aParams['hash_treatment'];
     return $sFunc($sFunc($sPassword) . MAGIC_STRING);
 }
Пример #22
0
 /**
 	Moves the file to the specified folder, and rename it if needed.
 
 	@param	$sDestination	The path of the destination file.
 	@param	$sNewFilename	The destination filename. If null, it is the same filename as the source file.
 */
 public function moveTo($sDestination, $sNewFilename = null)
 {
     clearstatcache();
     is_dir($sDestination) or burn('InvalidArgumentException', sprintf(_WT('Destination "%s" is not a directory.'), $sDestination));
     is_uploaded_file($this->sTmpName) or burn('UnexpectedValueException', sprintf(_WT('PHP reported that "%s" is not an uploaded file.'), $this->sTmpName));
     if (empty($sNewFilename)) {
         $sNewFilename = $this->getFilename();
     }
     move_uploaded_file($this->sTmpName, $sDestination . '/' . $sNewFilename);
 }
Пример #23
0
<?php

define('ALLOW_INCLUSION', 1);
define('DEBUG', 1);
define('ROOT_PATH', '../../../');
require ROOT_PATH . 'wee/wee.php';
$iStep = array_value($_GET, 'step', 1);
try {
    $o = new weeSession(array('check.token' => true));
    if ($iStep == 1) {
        isset($o['session_token']) or burn('UnitTestException', _WT('The session token was not found.'));
    } elseif ($iStep == 2) {
        isset($o['session_token']) or burn('UnitTestException', _WT('The session token was not found.'));
        setcookie('session_token', 'wrong token');
    } else {
        isset($o['session_token']) and burn('UnitTestException', _WT('The session should have been reinitialized.'));
    }
} catch (Exception $e) {
    echo $e->getMessage();
    exit;
}
echo 'success';
Пример #24
0
$aTranslation = array('Wrong password' => 'Mot de passe incorrect');
$sPoContents = '#default domain "messages.mo"
msgid ""
msgstr ""
"Content-Type: text/plain; charset=UTF-8\\n"
"Plural-Forms: nplurals=2; plural=(n>1);\\n"

msgid "Wrong password"
msgstr "Mot de passe incorrect"

msgid "Wrong number"
msgid_plural "Wrong numbers"
msgstr[0] "Mauvais chiffre"
msgstr[1] "Mauvais chiffres"';
$iWrote = file_put_contents($sPoFilename, $sPoContents);
$iWrote === false and burn('UnexpectedValueException', sprintf(_WT('Cannot write the file %s.'), $sPoFilename));
exec(sprintf('msgfmt -o %s %s', $sMoFilename, $sPoFilename));
if (!is_file($sMoFilename)) {
    $this->skip();
}
$o = new weeGetTextDictionary($sMoFilename);
// weeGetTextDictionary::getHeaders
$this->isEqual($aHeaders, $o->getHeaders(), _WT('weeGetTextDictionary::getHeaders does not return the expected headers.'));
// weeGetTextDictionary::getCharset
$this->isEqual('UTF-8', $o->getCharset(), _WT('weeGetTextDictionary::getCharset does not return the expected charset.'));
// weeGetTextDictionary::getTranslation
$this->isEqual('Mot de passe incorrect', $o->getTranslation('Wrong password'), _WT('weeGetTextDictionary::getTranslation does not return the expected translation.'));
$this->isEqual('foobar', $o->getTranslation('foobar'), _WT('weeGetTextDictionary::getTranslation does not return the expected native sentence when there is no translation available.'));
// weeGetTextDictionary::getPluralTranslation
$this->isEqual('Mauvais chiffres', $o->getPluralTranslation('Wrong number', 'Wrong numbers', 0), sprintf(_WT('weeGetTextDictionary::getTranslation does not return the expected translation when n is %d.'), 0));
$this->isEqual('Mauvais chiffre', $o->getPluralTranslation('Wrong number', 'Wrong numbers', 1), sprintf(_WT('weeGetTextDictionary::getTranslation does not return the expected translation when n is %d.'), 1));
Пример #25
0
 /**
 	Return the XML node at the specified XPath.
 	There must be only ONE result returned.
 
 	@param	$sDestXPath			XPath statement
 	@return	weeSimpleXMLHack	XML node found at the specified path
 */
 protected function translateDestXPath($sDestXPath)
 {
     if (empty($sDestXPath)) {
         return $this->oXML->options;
     }
     $aDest = $this->oXML->options->xpath($sDestXPath);
     $aDest === false || count($aDest) != 1 and burn('BadXMLException', sprintf(_WT('The XPath statement "%s" must return exactly 1 result, %d were returned.'), $sDestXPath, count($aDest)));
     return $aDest[0];
 }
Пример #26
0
 /**
 	Returns the model name associated with this set.
 
 	@return string The model class name.
 */
 public function getModelName()
 {
     empty($this->sModel) and burn('IllegalStateException', sprintf(_WT('The property $%s must not be empty.'), 'sModel'));
     return $this->sModel;
 }
Пример #27
0
 /**
 	Fetches a row from the database.
 
 	This method executes a given SQL query and returns an instance of the model of this set.
 
 	@overload	queryRow($mQueryString, $mArg1, $mArg2, ...)	Example of query call with multiple unnamed parameters.
 	@overload	queryRow($mQueryString, $aNamedParameters)		Example of query call with named parameters.
 	@param		$mQueryString									The query string.
 	@param		...												The additional arguments that will be inserted into the query.
 	@return		object											An instance of the model of this set.
 	@throw		UnexpectedValueException						The SQL query did not return a result set.
 	@throw		DatabaseException								The result set does not contain exactly one row.
 	@see		weeDatabase::query
 */
 protected function queryRow($mQueryString)
 {
     $a = func_get_args();
     $m = call_user_func_array(array($this, 'query'), $a);
     $m instanceof weeDatabaseResult or burn('UnexpectedValueException', _WT('The SQL query did not return a result set.'));
     return $m->fetch();
 }
Пример #28
0
 public function __construct(array $aArgs = array())
 {
     array_key_exists('prime', $aArgs) && is_bool($aArgs['prime']) or burn('DomainException', 'The `prime` argument should be a boolean.');
     parent::__construct($aArgs);
 }
Пример #29
0
 /**
 	Change the locale used by the application.
 
 	@param $sLocale The new locale.
 */
 public function set($sLocale, $sCodeSet = 'UTF-8', $sModifier = null)
 {
     if (strlen($sLocale) == 2) {
         $sLocale = array_value($this->aLocaleMap, $sLocale, $sLocale);
     }
     if (strlen($sLocale) > 1) {
         if (!is_null($sCodeSet)) {
             $sLocale .= '.' . $sCodeSet;
         }
         if (!is_null($sModifier)) {
             $sLocale .= '@' . $sModifier;
         }
     }
     setlocale(LC_ALL, $sLocale) or burn('UnexpectedValueException', _WT('An error occurred while trying to set the locale.'));
 }
Пример #30
0
<?php

// Instead of this...
throw new Exception('Oops!');
// Do this!
burn('Exception', 'Oops!');
// You can also use it this way:
$r = fopen('/path/to/file', 'r') or burn('FileNotFoundException', 'The file /path/to/file does not exist.');