PHP PEAR Examples

PHP PEAR - 30 examples found. These are the top rated real world PHP examples of PEAR extracted from open source projects. You can rate examples to help us improve the quality of examples.
 /**
  * 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);
     }
 }
Example #2
0
 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');
 }
 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']);
             }
         }
     }
 }
Example #4
0
 /**
  * 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;
 }
Example #5
0
  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();
      }
  }
Example #6
0
 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);
         }
     }
 }
Example #7
0
 /**
  * @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;
 }
Example #8
0
 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;
 }
 /**
  * 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();
 }
 /**
  *  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;
 }
Example #11
0
 /**
  * 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;
 }
Example #12
0
 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()));
     }
 }
Example #13
0
 /**
  * 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;
 }
 /**
  * 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;
 }
Example #15
0
 /**
  * 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());
     }
 }
Example #16
0
 function perform(&$page, $actionName)
 {
     // save the form values and validation status to the session
     $page->isFormBuilt() or $page->buildForm();
     $pageName = $page->getAttribute('id');
     $data =& $page->controller->container();
     $data['values'][$pageName] = $page->exportValues();
     if (PEAR::isError($valid = $page->validate())) {
         return $valid;
     }
     $data['valid'][$pageName] = $valid;
     // Modal form and page is invalid: don't go further
     if ($page->controller->isModal() && !$data['valid'][$pageName]) {
         return $page->handle('display');
     }
     // More pages?
     if (null !== ($nextName = $page->controller->getNextName($pageName))) {
         $next =& $page->controller->getPage($nextName);
         return $next->handle('jump');
         // Consider this a 'finish' button, if there is no explicit one
     } elseif ($page->controller->isModal()) {
         if ($page->controller->isValid()) {
             return $page->handle('process');
         } else {
             // this should redirect to the first invalid page
             return $page->handle('jump');
         }
     } else {
         return $page->handle('display');
     }
 }
Example #17
0
 function handle($params)
 {
     $app = Dataface_Application::getInstance();
     $query = $app->getQuery();
     try {
         if (!@$_POST['-table']) {
             throw new Exception("No table was specified");
         }
         $vals = array();
         foreach ($query as $k => $v) {
             if ($k and $k[0] != '-') {
                 $vals[$k] = $v;
             }
         }
         $record = new Dataface_Record($_POST['-table'], array());
         $record->setValues($vals);
         if (!$record->checkPermission('ajax_save')) {
             throw new Exception("Permission Denied", 502);
         }
         $res = $record->save(null, true);
         if (PEAR::isError($res)) {
             error_log($res->getMessage(), $res->getCode());
             throw new Exception("Failed to save record due to a server error.  See log for details.");
         }
         $this->out(array('code' => 200, 'message' => 'Successfully inserted record.', 'recordId' => $record->getId()));
     } catch (Exception $ex) {
         $this->out(array('code' => $ex->getCode(), 'message' => $ex->getMessage()));
     }
 }
Example #18
0
 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 perform(&$page, $actionName)
 {
     $pageName = $page->getAttribute('id');
     // If the original action was 'display' and we have values in container then we load them
     // BTW, if the page was invalid, we should later call validate() to get the errors
     list(, $oldName) = $page->controller->getActionName();
     if ('display' == $oldName) {
         // If the controller is "modal" we should not allow direct access to a page
         // unless all previous pages are valid (see also bug #2323)
         if ($page->controller->isModal() && !$page->controller->isValid($page->getAttribute('id'))) {
             $target =& $page->controller->getPage($page->controller->findInvalid());
             return $target->handle('jump');
         }
         $data =& $page->controller->container();
         if (!empty($data['values'][$pageName])) {
             $page->loadValues($data['values'][$pageName]);
             $validate = false === $data['valid'][$pageName];
         }
     }
     // set "common" defaults and constants
     $page->controller->applyDefaults($pageName);
     $page->isFormBuilt() or $page->buildForm();
     // if we had errors we should show them again
     if (isset($validate) && $validate) {
         if (PEAR::isError($err = $page->validate())) {
             return $err;
         }
     }
     return $this->_renderForm($page);
 }
Example #20
0
 /** pulling in quotes from all avail types and putting into a nice array
  */
 function get_all_quotes(cmCart $cart, $adder = 0)
 {
     $res = array();
     $this->_cart =& $cart;
     /* does this look like a PO Box? if so bail, with an error */
     if ($this->_dest['country'] == 'US' && preg_match('/^(P\\.?O\\.?\\s*)?BOX\\s+[0-9]+/i', $this->_dest['addr'])) {
         return $this->raiseError('FedEx cannot deliver to P.O. Boxes');
     }
     $allquotes = $this->quote();
     if (!is_array($allquotes)) {
         $msg = $this->_name . ": Shipping calculation error >> ";
         $msg .= PEAR::isError($allquotes) ? $allquotes->getMessage() : $allquotes;
         return $this->raiseError($msg);
     }
     asort($allquotes);
     // sort the quotes by cost
     foreach ($allquotes as $type => $q) {
         if (in_array($type, $this->allowed_ship_types)) {
             $q += $adder;
             $opt = sprintf("%s %s (%.02f)", $this->get_name(), $this->ship_types[$type], $q);
             $res[$opt] = $opt;
         }
     }
     if ($this->debug) {
         $log = "\n==> QUOTES: (adder={$adder}) " . join(";", array_keys($res)) . "\n";
         error_log($log, 3, $this->debug_log);
     }
     return $res;
 }
Example #21
0
 /**
  * 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;
 }
 /**
  * @see sfTask
  */
 protected function execute($arguments = array(), $options = array())
 {
     $this->checkPluginExists($arguments['plugin']);
     $this->pluginDir = sfApplicationConfiguration::getActive()->getPluginConfiguration($arguments['plugin'])->getRootDir();
     $this->interactive = !$options['non-interactive'];
     $cleanup = array();
     if (!file_exists($this->pluginDir . '/package.xml')) {
         $cleanup['temp_files'] = array();
         foreach (sfFinder::type('dir')->in($this->pluginDir) as $dir) {
             if (!sfFinder::type('any')->maxdepth(0)->in($dir)) {
                 $this->getFilesystem()->touch($file = $dir . '/.sf');
                 $cleanup['temp_files'][] = $file;
             }
         }
         $cleanup['package_file'] = true;
         $this->generatePackageFile($arguments, $options);
     }
     $cwd = getcwd();
     chdir($this->pluginDir);
     $this->getPluginManager()->configure();
     require_once 'PEAR/Packager.php';
     $packager = new PEAR_Packager();
     $package = $packager->package($this->pluginDir . '/package.xml', !$options['nocompress']);
     chdir($cwd);
     if (PEAR::isError($package)) {
         if (isset($cleanup['package_file'])) {
             $cleanup['package_file'] = '.error';
         }
         $this->cleanup($cleanup);
         throw new sfCommandException($package->getMessage());
     }
     $this->cleanup($cleanup);
 }
 function _initializeDepDB()
 {
     if (!isset($this->_dependencyDB)) {
         static $initializing = false;
         if (!$initializing) {
             $initializing = true;
             if (!$this->_config) {
                 // never used?
                 if (OS_WINDOWS) {
                     $file = 'pear.ini';
                 } else {
                     $file = '.pearrc';
                 }
                 $this->_config =& new PEAR_Config($this->statedir . DIRECTORY_SEPARATOR . $file, '-');
                 // NO SYSTEM INI FILE
                 $this->_config->setRegistry($this);
                 $this->_config->set('php_dir', $this->install_dir);
             }
             $this->_dependencyDB =& PEAR_DependencyDB::singleton($this->_config);
             if (PEAR::isError($this->_dependencyDB)) {
                 // attempt to recover by removing the dep db
                 if (file_exists($this->_config->get('php_dir', null, 'pear.php.net') . DIRECTORY_SEPARATOR . '.depdb')) {
                     @unlink($this->_config->get('php_dir', null, 'pear.php.net') . DIRECTORY_SEPARATOR . '.depdb');
                 }
                 $this->_dependencyDB =& PEAR_DependencyDB::singleton($this->_config);
                 if (PEAR::isError($this->_dependencyDB)) {
                     echo $this->_dependencyDB->getMessage();
                     echo 'Unrecoverable error';
                     exit(1);
                 }
             }
             $initializing = false;
         }
     }
 }
Example #24
0
 function beforeDelete($record)
 {
     $versions = df_get_records_array('webpage_versions', array('webpage_id' => '=' . $record->val('webpage_id')));
     while ($versions) {
         foreach ($versions as $version) {
             $res = $version->delete(true);
             if (PEAR::isError($res)) {
                 return $res;
             }
         }
         $versions = df_get_records_array('webpage_versions', array('webpage_id' => '=' . $record->val('webpage_id')));
     }
     $logs = df_get_records_array('webpage_check_log', array('webpage_id' => '=' . $record->val('webpage_id')));
     while ($logs) {
         foreach ($logs as $log) {
             $res = $log->delete(true);
             if (PEAR::isError($res)) {
                 return $res;
             }
         }
         $logs = df_get_records_array('webpage_check_log', array('webpage_id' => '=' . $record->val('webpage_id')));
     }
     $children = df_get_records_array('webpages', array('parent_id' => '=' . $record->val('webpage_id')));
     while ($children) {
         foreach ($children as $child) {
             $res = $child->delete(true);
             if (PEAR::isError($res)) {
                 return $res;
             }
         }
         $children = df_get_records_array('webpages', array('parent_id' => '=' . $record->val('webpage_id')));
     }
 }
Example #25
0
 function _validateName()
 {
     if (!isset($this->routingCode)) {
         return PEAR::raiseError('Name is required');
     }
     return true;
 }
Example #26
0
 /**
  * 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 HandleAddItem()
{
    define("CMD_ADD_OURITEM", <<<SQL
\t\tINSERT INTO our_items (name, our_category_id, art, mdate)
\t\t\tVALUES (?, ?, ?, NOW())
SQL
);
    define("CMD_SEL_OURITEM_NEWID", <<<SQL
\t\tSELECT id FROM our_items 
\t\t\tWHERE name = ? AND our_category_id = ? AND art = ?
SQL
);
    global $db;
    $newItem = iconv("UTF-8", "windows-1251", urldecode($_REQUEST["itemName"]));
    $art = "art" . $_REQUEST["parentNodeId"] . "_" . time();
    $res =& $db->query(CMD_ADD_OURITEM, array($newItem, $_REQUEST["parentNodeId"], $art));
    if (PEAR::isError($res)) {
        printError($res);
        exit;
    }
    $newId =& $db->getOne(CMD_SEL_OURITEM_NEWID, array($newItem, $_REQUEST["parentNodeId"], $art));
    if (PEAR::isError($newId)) {
        printError($newId);
        exit;
    }
    // ¬озвратить номер добавленой категории
    print trim($newId);
}
Example #28
0
 /**
  * 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));
 }
Example #29
0
 /**
  * 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);
     }
 }
Example #30
0
 /**
  * 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();
 }