/** * 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; }
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'); }
/** * 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; }
/** * Extract a ZIP compressed file to a given path * * @access public * @param string $archive Path to ZIP archive to extract * @param string $destination Path to extract archive into * @param array $options Extraction options [unused] * @return boolean True if successful * @since 1.5 */ function extract($archive, $destination, $options = array()) { // Initialize variables $this->_data = null; $this->_metadata = null; if (!($this->_data = file_get_contents($archive))) { return PEAR::raiseError('Unable to read archive'); } if (!$this->_getTarInfo($this->_data)) { return PEAR::raiseError('Unable to decompress data'); } for ($i = 0, $n = count($this->_metadata); $i < $n; $i++) { $type = strtolower($this->_metadata[$i]['type']); if ($type == 'file' || $type == 'unix file') { $buffer = $this->_metadata[$i]['data']; $path = extPath::clean($destination . DS . $this->_metadata[$i]['name']); // Make sure the destination folder exists if (!extMkdirR(dirname($path))) { return PEAR::raiseError('Unable to create destination'); } if (file_put_contents($path, $buffer) === false) { return PEAR::raiseError('Unable to write entry'); } } } return true; }
/** * 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()); } }
/** * A method to launch and display the widget * * @param array $aParams The parameters array, usually $_REQUEST */ function display() { if (!$this->oTpl->is_cached()) { RV::disableErrorHandling(); $oRss = new XML_RSS($this->url); $result = $oRss->parse(); RV::enableErrorHandling(); // ignore bad character error which could appear if rss is using invalid characters if (PEAR::isError($result)) { if (!strstr($result->getMessage(), 'Invalid character')) { PEAR::raiseError($result); // rethrow $this->oTpl->caching = false; } } $aPost = array_slice($oRss->getItems(), 0, $this->posts); foreach ($aPost as $key => $aValue) { $aPost[$key]['origTitle'] = $aValue['title']; if (strlen($aValue['title']) > 38) { $aPost[$key]['title'] = substr($aValue['title'], 0, 38) . '...'; } } $this->oTpl->assign('title', $this->title); $this->oTpl->assign('feed', $aPost); $this->oTpl->assign('siteTitle', $this->siteTitle); $this->oTpl->assign('siteUrl', $this->siteUrl); } $this->oTpl->display(); }
function _validateName() { if (!isset($this->routingCode)) { return PEAR::raiseError('Name is required'); } return true; }
/** * 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; }
/** * initSearchObject * * This constructs a search object for the specified engine. * * @param array $record The fields retrieved from the Solr index. * * @return object The record driver for handling the record. * @access public */ static function initRecordDriver($record) { global $configArray; // Determine driver path based on record type and try a Local version first: $driver = ucwords($record['recordtype']) . 'RecordLocal'; $path = "RecordDrivers/{$driver}.php"; // Then the regular version: if (!is_readable($path)) { $driver = ucwords($record['recordtype']) . 'Record'; $path = "RecordDrivers/{$driver}.php"; } // If we can't load the driver, fall back to the default, index-based one: if (!is_readable($path)) { $driver = 'IndexRecord'; $path = "RecordDrivers/{$driver}.php"; } // Build the object: include_once $path; if (class_exists($driver)) { $obj = new $driver($record); return $obj; } // If we got here, something went very wrong: PEAR::raiseError(new PEAR_Error("Problem loading record driver: {$driver}")); }
function handle(&$params) { $app =& Dataface_Application::getInstance(); $query = $app->getQuery(); $query['-skip'] = 0; $query['-limit'] = 999999999; $at = Dataface_ActionTool::getInstance(); $emailAction = $at->getAction(array('name' => 'email')); if (!isset($emailAction) or !isset($emailAction['email_column'])) { return PEAR::raiseError("No email column specified"); } $col = $emailAction['email_column']; $qb = new Dataface_QueryBuilder($query['-table'], $query); $sql = "select `" . $col . "` " . $qb->_from() . $qb->_secure($qb->_where()); $res = mysql_query($sql, df_db()); if (!$res) { trigger_error(mysql_error(df_db()), E_USER_ERROR); } $addresses = array(); while ($row = mysql_fetch_row($res)) { $addresses[] = $row[0]; } @mysql_free_result($res); header("Content-type: text/plain"); echo implode(', ', $addresses); exit; }
/** * Take care of getting rid of any active resources. */ function close() { if (is_null($this->fh)) { return PEAR::raiseError(_kt('Not open')); } return fclose($this->fh); }
/** * format a file or URL * * @access public * @param string $file filename * @param mixed $newFile filename for beautified XML file (if none is given, the XML string will be returned.) * if you want overwrite the original file, use XML_BEAUTIFIER_OVERWRITE * @param string $renderer Renderer to use, default is the plain xml renderer * @return mixed XML string of no file should be written, true if file could be written * @throws PEAR_Error * @uses _loadRenderer() to load the desired renderer */ function formatFile($file, $newFile = null, $renderer = "Plain") { if ($this->apiVersion() != '1.0') { return $this->raiseError('API version must be 1.0'); } /** * Split the document into tokens * using the XML_Tokenizer */ require_once dirname(__FILE__) . '/Tokenizer.php'; $tokenizer = new phpDocumentor_XML_Beautifier_Tokenizer(); $tokens = $tokenizer->tokenize($file, true); if (PEAR::isError($tokens)) { return $tokens; } include_once dirname(__FILE__) . '/Plain.php'; $renderer = new PHPDoc_XML_Beautifier_Renderer_Plain($this->_options); $xml = $renderer->serialize($tokens); if ($newFile == null) { return $xml; } $fp = @fopen($newFile, "w"); if (!$fp) { return PEAR::raiseError("Could not write to output file", XML_BEAUTIFIER_ERROR_NO_OUTPUT_FILE); } flock($fp, LOCK_EX); fwrite($fp, $xml); flock($fp, LOCK_UN); fclose($fp); return true; }
/** * Constructor * * @access public */ public function __construct() { global $interface; global $configArray; // Call parent constructor parent::__construct(); // Fetch Record $config = getExtraConfigArray('MetaLib'); $metalib = new MetaLib(); $this->record = $metalib->getRecord($_REQUEST['id']); if (PEAR::isError($this->record)) { PEAR::raiseError($this->record); } // Get record driver $this->recordDriver = RecordDriverFactory::initRecordDriver($this->record); // Set Proxy URL $interface->assign('proxy', isset($configArray['EZproxy']['host']) ? $configArray['EZproxy']['host'] : false); // Whether RSI is enabled if (isset($configArray['OpenURL']['use_rsi']) && $configArray['OpenURL']['use_rsi']) { $interface->assign('rsi', true); } // Whether embedded openurl autocheck is enabled if (isset($configArray['OpenURL']['autocheck']) && $configArray['OpenURL']['autocheck']) { $interface->assign('openUrlAutoCheck', true); } // Send record ID to template $interface->assign('id', $_REQUEST['id']); // Send down legal export formats (if any): $interface->assign('exportFormats', array('RefWorks', 'EndNote')); // Set AddThis User $interface->assign('addThis', isset($configArray['AddThis']['key']) ? $configArray['AddThis']['key'] : false); // Get core metadata $interface->assign('coreMetadata', $this->recordDriver->getCoreMetadata()); }
function processInstallation($pkg, $atts, $file, $tmp_path, $layer = null) { $test = parent::processInstallation($pkg, $atts, $file, $tmp_path, $layer); if (@file_exists($test[2])) { // configuration has already been installed, check for mods if (md5_file($test[2]) !== md5_file($test[3])) { // configuration has been modified, so save our version as // configfile-version $old = $test[2]; $test[2] .= '.new-' . $pkg->getVersion(); // backup original and re-install it PEAR::pushErrorHandling(PEAR_ERROR_RETURN); $tmpcfg = $this->config->get('temp_dir'); $newloc = System::mkdir(array('-p', $tmpcfg)); if (!$newloc) { // try temp_dir $newloc = System::mktemp(array('-d')); if (!$newloc || PEAR::isError($newloc)) { PEAR::popErrorHandling(); return PEAR::raiseError('Could not save existing configuration file ' . $old . ', unable to install. Please set temp_dir ' . 'configuration variable to a writeable location and try again'); } } else { $newloc = $tmpcfg; } if (!@copy($old, $newloc . DIRECTORY_SEPARATOR . 'savefile')) { PEAR::popErrorHandling(); return PEAR::raiseError('Could not save existing configuration file ' . $old . ', unable to install. Please set temp_dir ' . 'configuration variable to a writeable location and try again'); } PEAR::popErrorHandling(); $this->installer->addFileOperation('rename', array($newloc . DIRECTORY_SEPARATOR . 'savefile', $old, false)); $this->installer->addFileOperation('delete', array($newloc . DIRECTORY_SEPARATOR . 'savefile')); } } return $test; }
/** * 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 = 'lib/pear/SASL/Anonymous.php'; $classname = 'Auth_SASL_Anonymous'; break; case 'login': $filename = 'lib/pear/SASL/Login.php'; $classname = 'Auth_SASL_Login'; break; case 'plain': $filename = 'lib/pear/SASL/Plain.php'; $classname = 'Auth_SASL_Plain'; break; case 'external': $filename = 'lib/pear/SASL/External.php'; $classname = 'Auth_SASL_External'; break; case 'crammd5': $filename = 'lib/pear/SASL/CramMD5.php'; $classname = 'Auth_SASL_CramMD5'; break; case 'digestmd5': $filename = 'lib/pear/SASL/DigestMD5.php'; $classname = 'Auth_SASL_DigestMD5'; break; default: return PEAR::raiseError('Invalid SASL mechanism type'); break; } require_once $filename; $obj = new $classname(); return $obj; }
/** * Loads File * * @access public * @param string $cache_file * @return mixed data array or PEAR Error on Failure */ function loadFile($cache_file) { if (false === ($data = @file_get_contents($cache_file))) { return PEAR::raiseError("Fail to open '{$cache_file}', not found"); } return unserialize($data); }
/** * 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 <*****@*****.**> * @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; }
function update(&$subject, $event, $data = null) { switch ($event) { case 'sentRequest': $this->_target = basename($subject->_url->path); break; case 'gotHeaders': if (isset($data['content-disposition']) && preg_match('/filename="([^"]+)"/', $data['content-disposition'], $matches)) { $this->setTarget(basename($matches[1])); } else { $this->setTarget($this->_target); } $this->_bar =& new Console_ProgressBar('* ' . $this->_target . ' %fraction% KB [%bar%] %percent%', '=>', '-', 79, isset($data['content-length']) ? round($data['content-length'] / 1024) : 100); $this->_size = 0; break; case 'tick': $this->_size += strlen($data); $this->_bar->update(round($this->_size / 1024)); fwrite($this->_fp, $data); break; case 'gotBody': fclose($this->_fp); break; default: PEAR::raiseError("Unhandled event '{$event}'"); } // switch }
/** * Constructor of the container class. * * $options can have these keys: * 'servers' an array containing an array: servername, port, * sharedsecret, timeout, maxtries * 'configfile' The filename of the configuration file * 'authtype' The type of authentication, one of: PAP, CHAP_MD5, * MSCHAPv1, MSCHAPv2, default is PAP * * @param $options associative array * @return object Returns an error object if something went wrong */ function Auth_Container_RADIUS($options) { $this->authtype = 'PAP'; if (isset($options['authtype'])) { $this->authtype = $options['authtype']; } $classname = 'Auth_RADIUS_' . $this->authtype; if (!class_exists($classname)) { PEAR::raiseError("Unknown Authtype, please use on of: PAP, CHAP_MD5, MSCHAPv1, MSCHAPv2!", 41, PEAR_ERROR_DIE); } $this->radius = new $classname(); if (isset($options['configfile'])) { $this->radius->setConfigfile($options['configfile']); } $servers = $options['servers']; if (is_array($servers)) { foreach ($servers as $server) { $servername = $server[0]; $port = isset($server[1]) ? $server[1] : 0; $sharedsecret = isset($server[2]) ? $server[2] : 'testing123'; $timeout = isset($server[3]) ? $server[3] : 3; $maxtries = isset($server[4]) ? $server[4] : 3; $this->radius->addServer($servername, $port, $sharedsecret, $timeout, $maxtries); } } if (!$this->radius->start()) { PEAR::raiseError($this->radius->getError(), 41, PEAR_ERROR_DIE); } }
/** * Called by HTML_QuickForm whenever form event is made on this element * * @param string Name of event * @param mixed event arguments * @param object calling object * @since 1.0 * @access public * @return bool */ function onQuickFormEvent($event, $arg, &$caller) { switch ($event) { case 'updateValue': if ($caller->getAttribute('method') == 'get') { return PEAR::raiseError('Cannot add a file upload field to a GET method form'); } $value = $this->_findValue($caller->_constantValues); if (null === $value) { $value = $this->_findValue($caller->_submitValues); if (null === $value) { $value = $this->_findValue($caller->_defaultValues); } } if (null !== $value) { $this->setValue($value); } $caller->updateAttributes(array('enctype' => 'multipart/form-data')); $caller->setMaxFileSize(); break; case 'addElement': $this->onQuickFormEvent('createElement', $arg, $caller); return $this->onQuickFormEvent('updateValue', null, $caller); break; case 'createElement': $className = get_class($this); $this->{$className}($arg[0], $arg[1], $arg[2], $arg[3]); break; } return true; }
function printFax($fax_id) { $data = $GLOBALS['hylax_storage']->getFaxData($fax_id); $command = $GLOBALS['conf']['fax']['print']; $descriptorspec = array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => array("pipe", "w")); /* Set up the process. */ $process = proc_open($command, $descriptorspec, $pipes); if (!is_resource($process)) { return PEAR::raiseError('fail'); } fwrite($pipes[0], $data); fclose($pipes[0]); $output = ''; while (!feof($pipes[1])) { $output .= fgets($pipes[1], 1024); } fclose($pipes[1]); $stderr = ''; while (!feof($pipes[2])) { $stderr .= fgets($pipes[2], 1024); } fclose($pipes[2]); proc_close($process); if ($stderr) { return PEAR::raiseError($stderr); } return true; }
function &setFrontendClass($uiclass) { if (is_object($GLOBALS['_PEAR_FRONTEND_SINGLETON']) && is_a($GLOBALS['_PEAR_FRONTEND_SINGLETON'], $uiclass)) { return $GLOBALS['_PEAR_FRONTEND_SINGLETON']; } if (!class_exists($uiclass)) { $file = str_replace('_', '/', $uiclass) . '.php'; if (PEAR_Frontend::isIncludeable($file)) { include_once $file; } } if (class_exists($uiclass)) { $obj =& new $uiclass(); // quick test to see if this class implements a few of the most // important frontend methods if (method_exists($obj, 'userConfirm')) { $GLOBALS['_PEAR_FRONTEND_SINGLETON'] =& $obj; $GLOBALS['_PEAR_FRONTEND_CLASS'] = $uiclass; return $obj; } else { $err = PEAR::raiseError("not a frontend class: {$uiclass}"); return $err; } } $err = PEAR::raiseError("no such class: {$uiclass}"); return $err; }
/** * Add user to a blacklist list * * @param string $user Usersame */ public function removeBlacklisted($user) { if (!$GLOBALS['registry']->hasMethod('removeBlacklisted', $this->_params['app'])) { return PEAR::raiseError(_("Unsupported")); } return $GLOBALS['registry']->callByPackage($this->_params['app'], 'removeBlacklisted', array($user)); }
/** * Retrieve configuration information about a file role from its XML info * * @param string $role Role Classname, as in "PEAR_Installer_Role_Data" * @return array */ function getInfo($role) { if (empty($GLOBALS['_PEAR_INSTALLER_ROLES'][$role])) { return PEAR::raiseError('Unknown Role class: "' . $role . '"'); } return $GLOBALS['_PEAR_INSTALLER_ROLES'][$role]; }
/** * Returns the dump in XML format without printing it out * * @param object $value the XML_RPC_Value object to dump * @param int $nLevel the level of indentation * * @return string the dump */ function generateDump($value, $nLevel = 0) { if (!is_object($value) && get_class($value) != 'xml_rpc_value') { require_once 'lib/pear/PEAR.php'; PEAR::raiseError('Tried to dump non-XML_RPC_Value variable' . "\r\n", 0, PEAR_ERROR_PRINT); if (is_object($value)) { $strType = get_class($value); } else { $strType = gettype($value); } return $this->getIndent($nLevel) . 'NOT A XML_RPC_Value: ' . $strType . "\r\n"; } switch ($value->kindOf()) { case 'struct': $ret = $this->genStruct($value, $nLevel); break; case 'array': $ret = $this->genArray($value, $nLevel); break; case 'scalar': $ret = $this->genScalar($value->scalarval(), $nLevel); break; default: require_once 'lib/pear/PEAR.php'; PEAR::raiseError('Illegal type "' . $value->kindOf() . '" in XML_RPC_Value' . "\r\n", 0, PEAR_ERROR_PRINT); } return $ret; }
function GetXMLTree($xmldata) { // we want to know if an error occurs ini_set('track_errors', '1'); $xmlreaderror = false; $parser = xml_parser_create('ISO-8859-1'); xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); if (!xml_parse_into_struct($parser, $xmldata, $vals, $index)) { $xmlreaderror = true; $err = PEAR::raiseError("XML Read error", 1, E_USER_WARNING, null, "Could not parse xml into structure."); return $err; } xml_parser_free($parser); if (!$xmlreaderror) { $result = array(); $i = 0; $attributes = array(); if (isset($vals[$i]['attributes'])) { foreach (array_keys($vals[$i]['attributes']) as $attkey) { $attributes[$attkey] = $vals[$i]['attributes'][$attkey]; } } $result[$vals[$i]['tag']] = array_merge($attributes, GetChildren($vals, $i, 'open')); } ini_set('track_errors', '0'); return $result; }
/** * Load FB content */ private function _loadFB() { if ($this->_fb) { return true; } if (!$conf['facebook']['enabled']) { $this->_fb = PEAR::raiseError(_("No Facebook integration exists.")); return false; } // Check FB user config $fbp = unserialize($prefs->getValue('facebook')); if (!$fbp || empty($fbp['uid'])) { $this->_fb = PEAR::raiseError(_("User has no link.")); return false; } try { $facebook = $GLOBALS['injector']->getInstance('Horde_Service_Facebook'); } catch (Horde_Exception $e) { $error = PEAR::raiseError($e->getMessage(), $e->getCode()); Horde::log($error, 'ERR'); return $error; } $this->_fb->auth->setUser($fbp['uid'], $fbp['sid'], 0); return true; }
function process() { if (strlen($this->email)) { $email =& new JxEmail(JX_BASE_PATH . '/system/tpl'); if (!JxEmail::isError($email)) { $to = $this->email; $subject = 'Payment Process (OrderID: ' . $this->orderID . ')'; $h = array(); $h['From'] = $_SERVER['SERVER_NAME'] . ' <*****@*****.**>'; $h['Reply-To'] = $h['Return-Path'] = $h['From']; $email->template->assign('ccNumber', substr($this->card->number, 8)); $email->template->assign('orderID', $this->orderID); $result = $email->send($to, $subject, 'JxPaymentProcess_email.tpl', $h); if (JxEmail::isError($result)) { $this->log->log($result->getMessage()); return PEAR::raiseError('Could not send email'); } else { return new JxPaymentProcess_result('All good'); } } else { return $email; } } return PEAR::raiseError('Invalid email address: ' . $this->email); }
/** * Parses a unified or context diff. * * First param contains the whole diff and the second can be used to force * a specific diff type. If the second parameter is 'autodetect', the * diff will be examined to find out which type of diff this is. * * @param string $diff The diff content. * @param string $mode The diff mode of the content in $diff. One of * 'context', 'unified', or 'autodetect'. * * @return array List of all diff operations. */ function diff($diff, $mode = 'autodetect') { if ($mode != 'autodetect' && $mode != 'context' && $mode != 'unified') { return PEAR::raiseError('Type of diff is unsupported'); } if ($mode == 'autodetect') { $context = strpos($diff, '***'); $unified = strpos($diff, '---'); if ($context === $unified) { return PEAR::raiseError('Type of diff could not be detected'); } elseif ($context === false || $context === false) { $mode = $context !== false ? 'context' : 'unified'; } else { $mode = $context < $unified ? 'context' : 'unified'; } } // split by new line and remove the diff header $diff = explode("\n", $diff); array_shift($diff); array_shift($diff); if ($mode == 'context') { return $this->parseContextDiff($diff); } else { return $this->parseUnifiedDiff($diff); } }
/** * createDB * * @access private * @return reference */ private static function &createDB() { if (is_null(self::$dbDriver)) { $dsn = null; $class = 'Framework_DB'; $file = null; if (isset(Framework::$site->config->dbClass)) { $class = 'Framework_DB_' . (string) Framework::$site->config->dbClass; $file = 'Framework/DB/' . Framework::$site->config->dbClass . '.php'; } if (isset(Framework::$site->config->dsn)) { $dsn = (string) Framework::$site->config->dsn; } else { $class = 'Framework_DB_None'; } if (!is_null($file)) { if (!(include_once $file)) { return PEAR::raiseError('Could not load class file: ' . $file); } } self::$dbDriver = new $class(); } if (is_null(Framework::$db)) { self::$dbDriver->start($dsn); } return Framework::$db; }