本文整理汇总了PHP中PEAR类的典型用法代码示例。如果您正苦于以下问题:PHP PEAR类的具体用法?PHP PEAR怎么用?PHP PEAR使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PEAR类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Constructeur de bbCodeObject
*
* @param array $params Param�tres
*
* @return void
* */
function __construct($params = array())
{
parent::__construct();
if (!in_array('noPEAR', $params)) {
$config = parse_ini_file('BBCodeParser.ini', true);
$pear = new PEAR();
$options = $pear->getStaticProperty('HTML_BBCodeParser', '_options');
$options = $config['HTML_BBCodeParser'];
$this->parserBB = new HTML_BBCodeParser2($options);
}
}
示例2: handle
function handle(&$params)
{
if (!@$_REQUEST['email']) {
return PEAR::raiseError("No email address specified");
}
import('HTML/QuickForm.php');
$form = new HTML_QuickForm('opt_out_form', 'post');
$form->addElement('hidden', 'email', $_REQUEST['email']);
$form->addElement('hidden', '-action', 'email_opt_out');
$form->addElement('submit', 'submit', 'Cancel Subscription');
if ($form->validate()) {
$res = mysql_query("replace into dataface__email_blacklist (email) values ('" . addslashes($_REQUEST['email']) . "')", df_db());
if (!$res) {
trigger_error(mysql_error(df_db()), E_USER_ERROR);
}
header('Location: ' . DATAFACE_SITE_HREF . '?--msg=' . urlencode('You have successfully opted out of our mail list. You will no longer receive emails from us.'));
exit;
}
ob_start();
$form->display();
$html = ob_get_contents();
ob_end_clean();
$context = array();
$context['form'] = $html;
df_register_skin('email', DATAFACE_PATH . '/modules/Email/templates');
df_display($context, 'email/opt_out_form.html');
}
示例3: _logExpectedConstructive
function _logExpectedConstructive()
{
$aExistingTables = $this->oDBUpgrade->_listTables();
$prefix = $this->oDBUpgrade->prefix;
$msg = $this->_testName('A');
if (!in_array($prefix . 'astro', $aExistingTables)) {
$this->_log($msg . ' table ' . $prefix . 'astro does not exist in database therefore changes_tables_core_999200 will not be able to alter fields for table ' . $prefix . 'astro');
} else {
$this->_log($msg . ' add (as part of rename) field to table ' . $prefix . 'astro defined as: [id_changed_field]');
$aDef = $this->oDBUpgrade->aDefinitionNew['tables']['astro']['fields']['id_changed_field'];
$this->_log(print_r($aDef, true));
$msg = $this->_testName('B');
$this->_log($msg . ' add field to table ' . $prefix . 'astro defined as: [text_field]');
$aDef = $this->oDBUpgrade->aDefinitionNew['tables']['astro']['fields']['text_field'];
$this->_log(print_r($aDef, true));
$msg = $this->_testName('C');
$query = 'SELECT * FROM ' . $prefix . 'astro';
$result = $this->oDbh->queryAll($query);
if (PEAR::isError($result)) {
$this->_log($msg . ' failed to locate data to migrate from [id_field, desc_field] to [id_changed_field, text_field]');
} else {
$this->_log($msg . ' migrate data from [id_field, desc_field] to [id_changed_field, text_field] :');
$this->_log('row = id_field , desc_field');
foreach ($result as $k => $v) {
$this->_log('row ' . $k . ' = ' . $v['id_field'] . ' , ' . $v['desc_field']);
}
}
}
}
示例4: switch
/**
* Factory class. Returns an object of the request
* type.
*
* @param string $type One of: Anonymous
* Plain
* CramMD5
* DigestMD5
* Types are not case sensitive
*/
function &factory($type)
{
switch (strtolower($type)) {
case 'anonymous':
$filename = 'Auth/SASL/Anonymous.php';
$classname = 'Auth_SASL_Anonymous';
break;
case 'login':
$filename = 'Auth/SASL/Login.php';
$classname = 'Auth_SASL_Login';
break;
case 'plain':
$filename = 'Auth/SASL/Plain.php';
$classname = 'Auth_SASL_Plain';
break;
case 'crammd5':
$filename = 'Auth/SASL/CramMD5.php';
$classname = 'Auth_SASL_CramMD5';
break;
case 'digestmd5':
$filename = 'Auth/SASL/DigestMD5.php';
$classname = 'Auth_SASL_DigestMD5';
break;
default:
return PEAR::raiseError('Mecanismo do tipo SASL inválido');
break;
}
require_once $filename;
$obj = new $classname();
return $obj;
}
示例5: com_install
function com_install($mypath = '')
{
error_reporting(E_ALL ^ E_NOTICE);
global $database;
if (is_callable(array('JFactory', 'getDBO'))) {
$database = JFactory::getDBO();
}
if ($mypath == '') {
$mypath = dirname(__FILE__);
}
require_once $mypath . "/include/functions.php";
require_once $mypath . "/libraries/Archive/archive.php";
ext_RaiseMemoryLimit('50M');
$archive_name = $mypath . '/scripts.tar.gz';
$extract_dir = $mypath . '/';
$result = extArchive::extract($archive_name, $extract_dir);
if (!@PEAR::isError($result)) {
unlink($archive_name);
} else {
echo '<pre style="color:white; font-weight:bold; background-color:red;">Error!
' . $result->getMessage() . '
</pre>';
}
if (!is_callable(array($database, 'loadNextRow'))) {
$database->setQuery("SELECT id FROM #__components WHERE admin_menu_link = 'option=com_extplorer'");
$id = $database->loadResult();
//add new admin menu images
$database->setQuery("UPDATE #__components SET admin_menu_img = '../administrator/components/com_extplorer/images/x_icon.png', admin_menu_link = 'option=com_extplorer' WHERE id={$id}");
$database->query();
}
}
示例6: __construct
function __construct($cmid = 0)
{
global $db;
$this->_cmid = $cmid;
if ($this->_cmid != 0) {
$this->_dbo = DB_DataObject::Factory("phph_comments");
if (PEAR::isError($this->_dbo)) {
throw new Exception2("Bd wewn�rzny", $this->_dbo->getMessage());
}
$r = $this->_dbo->get($cmid);
if (PEAR::isError($r)) {
throw new Exception2("Bd wewn�rzny", $r->getMessage());
}
if ($r == 0) {
throw new Exception2("Bd", "Komentarz nie istnieje", COMMENT_NOT_FOUND);
}
$this->_user = DB_DataObject::Factory("phph_users");
if (PEAR::isError($this->_user)) {
throw new Exception2("Bd wewn�rzny", $this->_user->getMessage());
}
$r = $this->_user->get($this->_dbo->user_id);
if (PEAR::isError($r)) {
throw new Exception2("Bd wewn�rzny", $r->getMessage());
}
if ($r == 0) {
throw new Exception2("Bd sp�noci danych", "Uytkownik do kt�ego nalezy komentarz nie istnieje.<br />Skontakuj si�z administratorem, podajc numer komentarza ({$cmid}).", COMMENT_USER_NOT_FOUND);
}
}
}
示例7: getPage
/**
* @brief lifepod 페이지 정보 가져오기
* @remarks 한해씩 끊어서 페이지를 가져옵니다. 아직 50개 이상의 calendar info가 있는 경우 앞에 것만 가져오는 문제가 있습니다.
**/
function getPage($address, $year, $pageNumber)
{
if ($year == null) {
$year = date("Y");
}
$start = sprintf("%s-01-01", $year);
$end = sprintf("%s-01-01", $year + 1);
$url = $this->getURL($address, $start, $end, $pageNumber);
$oReqeust = $this->getRequest($url);
$oResponse = $oReqeust->sendRequest();
if (PEAR::isError($oResponse)) {
return null;
}
$body = $oReqeust->getResponseBody();
$oXmlParser = new GeneralXmlParser();
$xmldoc = $oXmlParser->parse($body);
if (!$xmldoc->childNodes["feed"]->childNodes["entry"]) {
$data = array();
} else {
$data =& $xmldoc->childNodes["feed"]->childNodes["entry"]->childNodes["data"];
}
$page->title = $xmldoc->childNodes["feed"]->childNodes["title"]->body;
if (is_array($data)) {
$page->data = $data;
} else {
$page->data = array();
$page->data[] = $data;
}
$page->color = $xmldoc->childNodes["feed"]->childNodes["color"]->body;
$page->total = intval($xmldoc->childNodes["feed"]->childNodes["opensearch:totalresults"]->body);
$page->start = intval($xmldoc->childNodes["feed"]->childNodes["opensearch:startindex"]->body);
$page->perpage = intval($xmldoc->childNodes["feed"]->childNodes["opensearch:itemsperpage"]->body);
return $page;
}
示例8: checkDownloads
public function checkDownloads()
{
$pear = new Varien_Pear();
$pkg = new PEAR_PackageFile($pear->getConfig(), false);
$result = true;
foreach ($this->getPackages() as $package) {
$obj = $pkg->fromAnyFile($package, PEAR_VALIDATE_NORMAL);
if (PEAR::isError($obj)) {
$uinfo = $obj->getUserInfo();
if (is_array($uinfo)) {
foreach ($uinfo as $message) {
if (is_array($message)) {
$message = $message['message'];
}
Mage::getSingleton('Mage_Install_Model_Session')->addError($message);
}
} else {
print_r($obj->getUserInfo());
#Mage::getSingleton('Mage_Install_Model_Session')->addError($message);
}
$result = false;
}
}
return $result;
}
示例9: testDeliveryBlocked
/**
* A method to test the deliveryBlocked() method.
*
* Tests that the method in the class returns a PEAR::Error, as method is abstract.
*/
function testDeliveryBlocked()
{
$oCommon = new OA_Maintenance_Priority_DeliveryLimitation_Common(array());
PEAR::pushErrorHandling(null);
$this->assertTrue($oCommon->deliveryBlocked(new Date()) instanceof PEAR_Error);
PEAR::popErrorHandling();
}
示例10: enable_domain
/**
* Enable or disable domain
*
* Possible options:
*
* did (int) default: null
* id of domain which will be en/disabled
* this option is REQUIRED
*
* disable (bool) default: false
* if true domain will be disabled, otherwise wil be enabled
*
* @param array $opt associative array of options
* @return bool TRUE on success, FALSE on failure
*/
function enable_domain($opt)
{
global $config;
$errors = array();
if (!$this->connect_to_db($errors)) {
ErrorHandler::add_error($errors);
return false;
}
/* table's name */
$td_name =& $config->data_sql->domain->table_name;
/* col names */
$cd =& $config->data_sql->domain->cols;
/* flags */
$fd =& $config->data_sql->domain->flag_values;
$o_did = isset($opt['did']) ? $opt['did'] : null;
$o_disable = isset($opt['disable']) ? $opt['disable'] : false;
if (is_null($o_did)) {
ErrorHandler::log_errors(PEAR::raiseError('domain for en/disable is not specified'));
return false;
}
$q = "update " . $td_name . " set ";
if ($o_disable) {
$q .= $cd->flags . " = " . $cd->flags . " | " . $fd['DB_DISABLED'];
} else {
$q .= $cd->flags . " = " . $cd->flags . " & ~" . $fd['DB_DISABLED'];
}
$q .= " where " . $cd->did . " = " . $this->sql_format($o_did, "s");
$res = $this->db->query($q);
if (DB::isError($res)) {
ErrorHandler::log_errors($res);
return false;
}
return true;
}
示例11: switch
/**
* Draws a image barcode
*
* @param string $text A text that should be in the image barcode
* @param string $type The barcode type. Supported types:
* code39 - Code 3 of 9
* int25 - 2 Interleaved 5
* ean13 - EAN 13
* upca - UPC-A
* @param string $imgtype The image type that will be generated
* @param boolean $bSendToBrowser if the image shall be outputted to the
* browser, or be returned.
*
* @return image The corresponding gd image object;
* PEAR_Error on failure
*
* @access public
*
* @author Marcelo Subtil Marcal <msmarcal@php.net>
* @since Image_Barcode 0.3
*/
function &draw($text, $dest_file, $type = 'int25', $imgtype = 'png', $height = 60)
{
//Make sure no bad files are included
if (!preg_match('/^[a-zA-Z0-9_-]+$/', $type)) {
return PEAR::raiseError('Invalid barcode type ' . $type);
}
if (!(include_once __CA_LIB_DIR__ . '/core/Print/Barcode/' . $type . '.php')) {
return PEAR::raiseError($type . ' barcode is not supported');
}
$classname = 'Barcode_' . $type;
if (!in_array('draw', get_class_methods($classname))) {
$classname = 'code39';
}
@($obj = new $classname());
$obj->_barcodeheight = $height;
$img =& $obj->draw($text, $imgtype);
if (PEAR::isError($img)) {
return null;
}
switch ($imgtype) {
case 'gif':
imagegif($img, $dest_file);
break;
case 'jpg':
imagejpeg($img, $dest_file);
break;
default:
imagepng($img, $dest_file);
break;
}
$va_dimensions = array('width' => imagesx($img), 'height' => imagesy($img), 0 => imagesx($img), 1 => imagesy($img));
imagedestroy($img);
return $va_dimensions;
}
示例12: sendEmail
public function sendEmail($to, $from, $subject, $body, $username, $password, $is_body_html = true)
{
$smtp = array();
$smtp['host'] = "ssl://smtp.gmail.com";
$smtp['port'] = 465;
$smtp['auth'] = true;
$smtp['username'] = $username;
$smtp['password'] = $password;
$mailer = Mail::factory('smtp', $smtp);
if (PEAR::isError($mailer)) {
throw new Exception('Khong the tao mot mail moi!');
}
$recipients = array();
$recipients[] = $to;
$header = array();
$header['From'] = $from;
$header['To'] = $to;
$header['Subject'] = $subject;
if ($is_body_html) {
$header['Content-Type'] = 'text/html';
}
$result = $mailer->send($recipients, $header, $body);
if (PEAR::isError($result)) {
throw new Exception('Loi khong the gui mail: ' . htmlspecialchars($result->getMessage()));
}
}
示例13: parse_ini_file
/**
* Parses the data of the given configuration file
*
* @access public
* @param string $datasrc path to the configuration file
* @param object $obj reference to a config object
* @return mixed returns a PEAR_ERROR, if error occurs or true if ok
*/
function &parseDatasrc($datasrc, &$obj)
{
if (!file_exists($datasrc)) {
return PEAR::raiseError("Datasource file does not exist.", null, PEAR_ERROR_RETURN);
}
$currentSection =& $obj->container;
$confArray = parse_ini_file($datasrc, true);
if (!$confArray) {
return PEAR::raiseError("File '{$datasrc}' does not contain configuration data.", null, PEAR_ERROR_RETURN);
}
foreach ($confArray as $key => $value) {
if (is_array($value)) {
$currentSection =& $obj->container->createSection($key);
foreach ($value as $directive => $content) {
// try to split the value if comma found
if (strpos($content, '"') === false) {
$values = preg_split('/\\s*,\\s+/', $content);
if (count($values) > 1) {
foreach ($values as $k => $v) {
$currentSection->createDirective($directive, $v);
}
} else {
$currentSection->createDirective($directive, $content);
}
} else {
$currentSection->createDirective($directive, $content);
}
}
} else {
$currentSection->createDirective($key, $value);
}
}
return true;
}
示例14: performJob
/**
* performJob
*
* @rdbms-specific
* @return void
**/
public function performJob()
{
switch ($this->db->phptype) {
case 'oci8':
throw new ArgumentError('Not implemented for oci8.');
break;
// end oci8
// end oci8
case 'pgsql':
$result = $this->db->query("DELETE FROM user_online WHERE datetime_last_active + interval '5 minutes' < NOW()");
break;
// end pgsql
// end pgsql
case 'mysql':
case 'mysqli':
$result = $this->db->query("DELETE FROM user_online WHERE (UNIX_TIMESTAMP(datetime_last_active) + (60 * 5)) < UNIX_TIMESTAMP(NOW())");
break;
// end mysql
}
// end rdbms type switch
if (PEAR::isError($result)) {
throw new SQLError($result->getDebugInfo(), $result->userinfo, 10);
}
// end sql error
return true;
}
示例15: Structures_DataGrid_Record_DataObject
/**
* Constructor
*
* Builds the record if specified. The data must be of type DB_DataObject.
*
* @access public
* @see DB::DB_DataObject
*/
function Structures_DataGrid_Record_DataObject($data = null)
{
$result = $this->setRecord($data);
if (PEAR::isError($result)) {
PEAR::raiseError($result->toString());
}
}