コード例 #1
0
ファイル: pearweb_pepr.php プロジェクト: stof/pearweb
 function run($answers, $phase)
 {
     switch ($phase) {
         case 'askdb':
             if ($answers['yesno'] != 'y') {
                 $this->_ui->skipParamgroup('init');
             }
             return true;
             break;
         case 'init':
             PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
             if (PEAR::isError($err = MDB2::loadFile('Driver' . DIRECTORY_SEPARATOR . $answers['driver']))) {
                 PEAR::popErrorHandling();
                 $this->_ui->outputData('ERROR: Unknown MDB2 driver "' . $answers['driver'] . '": ' . $err->getUserInfo() . '. Be sure you have installed ' . 'MDB2_Driver_' . $answers['driver']);
                 return false;
             }
             PEAR::popErrorHandling();
             if ($answers['driver'] !== 'mysqli') {
                 $this->_ui->outputData('pearweb only supports mysqli, ' . 'not ' . $answers['driver']);
                 return false;
             }
             return $this->initializeDatabase($answers);
             break;
         case 'askhttpd':
             if ($answers['yesno'] != 'y') {
                 $this->_ui->skipParamgroup('httpdconf');
             }
             return true;
             break;
         case 'httpdconf':
             return $this->setupHttpdconf($answers);
             break;
     }
     return true;
 }
コード例 #2
0
 function sendEmail()
 {
     if (!$this->handle) {
         throw new Exception('Internal fault: user was not set when sending email,
                             please report to ' . PEAR_DEV_EMAIL);
     }
     $sql = 'SELECT salt FROM bug_account_request WHERE handle = ?';
     $salt = $this->dbh->getOne($sql, array($this->handle));
     if (!$salt) {
         throw new Exception('No such handle ' . $this->handle . ' found, cannot send confirmation email');
     }
     $sql = 'SELECT email FROM bug_account_request WHERE salt = ?';
     $email = $this->dbh->getOne($sql, array($salt));
     if (!$email) {
         throw new Exception('No such salt found, cannot send confirmation email');
     }
     $mailData = array('salt' => $salt);
     require_once 'Damblan/Mailer.php';
     $mailer = Damblan_Mailer::create('pearweb_account_request_bug', $mailData);
     $additionalHeaders['To'] = $email;
     PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
     if (!DEVBOX) {
         $e = $mailer->send($additionalHeaders);
     }
     PEAR::popErrorHandling();
     if (!DEVBOX && PEAR::isError($e)) {
         throw new Exception('Cannot send confirmation email: ' . $e->getMessage());
     }
     return true;
 }
コード例 #3
0
 /**
  * A method to test the deliveryBlocked() method.
  *
  * Tests that the method in the class returns a PEAR::Error, as method is abstract.
  */
 function testDeliveryBlocked()
 {
     $oDate = new Date();
     PEAR::pushErrorHandling(null);
     $this->assertTrue(is_a(OA_Maintenance_Priority_DeliveryLimitation_Common::deliveryBlocked($oDate), 'pear_error'));
     PEAR::popErrorHandling();
 }
コード例 #4
0
 function test_instantiateController()
 {
     $file = MAX_PATH . '/lib/OA/Admin/Statistics/Delivery/Common.php';
     $aParams = array();
     $class = 'OA_Admin_Statistics_Delivery_Common';
     $oObject =& OA_Admin_Statistics_Factory::_instantiateController($file, $class, $aParams);
     $this->assertIsA($oObject, $class);
     $this->assertEqual(count($oObject->aPlugins), 2);
     $this->assertTrue(isset($oObject->aPlugins['default']));
     $this->assertTrue(isset($oObject->aPlugins['affiliates']));
     $file = MAX_PATH . '/lib/OA/Admin/Statistics/tests/data/TestStatisticsController.php';
     $aParams = array();
     $class = 'OA_Admin_Statistics_Test';
     $oObject =& OA_Admin_Statistics_Factory::_instantiateController($file, $class, $aParams);
     $this->assertIsA($oObject, $class);
     // Disable default error handling
     PEAR::pushErrorHandling(null);
     // Test _instantiateController for not existing controller
     $file = MAX_PATH . '/lib/OA/Admin/Statistics/tests/data/TestNotExists.php';
     $aParams = array();
     $class = 'OA_Admin_Statistics_Test';
     $oObject =& OA_Admin_Statistics_Factory::_instantiateController($file, $class, $aParams);
     $this->assertTrue(PEAR::isError($oObject));
     $this->assertEqual($oObject->getMessage(), 'OA_Admin_Statistics_Factory::_instantiateController() Unable to locate ' . basename($file));
     // Test _instantiateController for not existing class
     $file = MAX_PATH . '/lib/OA/Admin/Statistics/tests/data/TestStatisticsController.php';
     $aParams = array();
     $class = 'OA_Admin_not_exists';
     $oObject =& OA_Admin_Statistics_Factory::_instantiateController($file, $class, $aParams);
     $this->assertTrue(PEAR::isError($oObject));
     $this->assertEqual($oObject->getMessage(), 'OA_Admin_Statistics_Factory::_instantiateController() Class ' . $class . ' doesn\'t exist');
     // Restore default error handling
     PEAR::popErrorHandling();
 }
コード例 #5
0
ファイル: Cfg.php プロジェクト: arkosoft/S-Admin
 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;
 }
コード例 #6
0
 /**
  * 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();
 }
コード例 #7
0
ファイル: RV.php プロジェクト: akirsch/revive-adserver
 /**
  * A method to re-enable PEAR error handling by popping
  * a null error handler off the top of the stack.
  *
  * @static
  */
 static function enableErrorHandling()
 {
     // Ensure this method only acts when a null error handler exists
     $stack =& $GLOBALS['_PEAR_error_handler_stack'];
     list($mode, $options) = $stack[sizeof($stack) - 1];
     if (is_null($mode) && is_null($options)) {
         PEAR::popErrorHandling();
     }
 }
コード例 #8
0
ファイル: Factory.php プロジェクト: villos/tree_admin
 /**
  *  Create a new object of the appropriate OA_Admin_Statistics_Common subclass.
  *
  * @static
  * @param string $controllerType The controller type (e.g. "global-advertiser").
  * @param array  $aParams        An array of parameters to be passed as the parameter
  *                               to the constructor of the class instantiated.
  * @return OA_Admin_Statistics_Common The instantiated class that inherits from
  *                                    OA_Admin_Statistics_Common.
  */
 function &getController($controllerType = '', $aParams = null)
 {
     // Instantiate & return the required statistics class
     $result = OA_Admin_Statistics_Factory::_getControllerClass($controllerType, $aParams, $class, $file);
     if (PEAR::isError($result)) {
         return $result;
     }
     // To allow catch errors and pass it out without calling error handler
     PEAR::pushErrorHandling(null);
     $oStatsController = OA_Admin_Statistics_Factory::_instantiateController($file, $class, $aParams);
     PEAR::popErrorHandling();
     return $oStatsController;
 }
コード例 #9
0
    /**
     * Attach a pull request to this bug
     */
    function attach($bugid, $repo, $pull_id, $developer)
    {
        $data = $this->getDataFromGithub($repo, $pull_id);
        if (!$data) {
            return PEAR::raiseError('Failed to retrieve pull request from GitHub');
        }
        PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
        $e = $this->_dbh->prepare('INSERT INTO bugdb_pulls
			(bugdb_id, github_repo, github_pull_id, github_title, github_html_url, developer) VALUES (?, ?, ?, ?, ?, ?)')->execute(array($bugid, $repo, $pull_id, $data->title, $data->html_url, $developer));
        PEAR::popErrorHandling();
        if (PEAR::isError($e)) {
            return $e;
        }
        return $data;
    }
コード例 #10
0
ファイル: patchtracker.php プロジェクト: stof/pearweb
 /**
  * Retrieve a unique, ordered patch filename
  *
  * @param int $bugid
  * @param string $patch
  * @return array array(revision, patch file name)
  */
 function newPatchFileName($bugid, $patch, $handle)
 {
     $id = time();
     PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
     $e = $this->_dbh->query('INSERT INTO bugdb_patchtracker
         (bugdb_id, patch, revision, developer) VALUES(?, ?, ?, ?)', array($bugid, $patch, $id, $handle));
     if (PEAR::isError($e)) {
         // try with another timestamp
         $id++;
         $e = $this->_dbh->query('INSERT INTO bugdb_patchtracker
             (bugdb_id, patch, revision, developer) VALUES(?, ?, ?, ?)', array($bugid, $patch, $id, $handle));
     }
     PEAR::popErrorHandling();
     if (PEAR::isError($e)) {
         return PEAR::raiseError('Could not get unique patch file name for bug #' . $bugid . ', patch "' . $patch . '"');
     }
     return array($id, $this->getPatchFileName($id));
 }
コード例 #11
0
    /**
     * Retrieve a unique, ordered patch filename
     *
     * @param int $bugid
     * @param string $patch
     * @return array array(revision, patch file name)
     */
    function newPatchFileName($bugid, $patch, $handle)
    {
        $id = time();
        PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
        $e = $this->_dbh->prepare('INSERT INTO bugdb_patchtracker
			(bugdb_id, patch, revision, developer) VALUES(?, ?, ?, ?)')->execute(array($bugid, $patch, $id, $handle));
        if (PEAR::isError($e)) {
            // try with another timestamp
            $id++;
            $e = $this->_dbh->prepare('INSERT INTO bugdb_patchtracker
				(bugdb_id, patch, revision, developer) VALUES(?, ?, ?, ?)')->execute(array($bugid, $patch, $id, $handle));
        }
        PEAR::popErrorHandling();
        if (PEAR::isError($e)) {
            return PEAR::raiseError("Could not get unique patch file name for bug #{$bugid}, patch \"{$patch}\"");
        }
        return array($id, $this->getPatchFileName($id));
    }
コード例 #12
0
 public function __construct($oUpgrader)
 {
     if ($oUpgrader->isRecoveryRequired()) {
         $this->isRecovery = true;
     } else {
         if ($oUpgrader->isFreshInstall()) {
             $this->isInstall = true;
         } else {
             PEAR::pushErrorHandling(null);
             $oUpgrader->canUpgradeOrInstall();
             PEAR::popErrorHandling();
             if ($oUpgrader->existing_installation_status == OA_STATUS_CURRENT_VERSION) {
                 $this->isUpToDate = true;
             } else {
                 $this->isUpgrade = true;
             }
         }
     }
 }
コード例 #13
0
 /**
  * Unlike other tasks, the installed file name is passed in instead of the file contents,
  * because this task is handled post-installation
  * @param PEAR_PackageFile_v1|PEAR_PackageFile_v2
  * @param string file name
  * @return bool|PEAR_Error false to skip this file, PEAR_Error to fail
  *         (use $this->throwError)
  */
 function startSession($pkg, $contents)
 {
     if ($this->installphase != PEAR_TASK_INSTALL) {
         return false;
     }
     // remove the tasks: namespace if present
     $this->_pkg = $pkg;
     $this->_stripNamespace();
     $this->logger->log(0, 'Including external post-installation script "' . $contents . '" - any errors are in this script');
     include_once $contents;
     if (class_exists($this->_class)) {
         $this->logger->log(0, 'Inclusion succeeded');
     } else {
         return $this->throwError('init of post-install script class "' . $this->_class . '" failed');
     }
     $this->_obj = new $this->_class();
     $this->logger->log(1, 'running post-install script "' . $this->_class . '->init()"');
     PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
     $res = $this->_obj->init($this->config, $pkg, $this->_lastversion);
     PEAR::popErrorHandling();
     if ($res) {
         $this->logger->log(0, 'init succeeded');
     } else {
         return $this->throwError('init of post-install script "' . $this->_class . '->init()" failed');
     }
     $this->_contents = $contents;
     return true;
 }
コード例 #14
0
ファイル: 10.php プロジェクト: Spark-Eleven/revive-adserver
 function packageInfo($base, $package)
 {
     PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
     $pinfo = $this->_rest->retrieveData($base . 'p/' . strtolower($package) . '/info.xml');
     if (PEAR::isError($pinfo)) {
         PEAR::popErrorHandling();
         return PEAR::raiseError('Unknown package: "' . $package . '" (Debug: ' . $pinfo->getMessage() . ')');
     }
     $releases = array();
     $allreleases = $this->_rest->retrieveData($base . 'r/' . strtolower($package) . '/allreleases.xml');
     if (!PEAR::isError($allreleases)) {
         if (!class_exists('PEAR_PackageFile_v2')) {
             require_once 'PEAR/PackageFile/v2.php';
         }
         if (!is_array($allreleases['r']) || !isset($allreleases['r'][0])) {
             $allreleases['r'] = array($allreleases['r']);
         }
         $pf = new PEAR_PackageFile_v2();
         foreach ($allreleases['r'] as $release) {
             $ds = $this->_rest->retrieveCacheFirst($base . 'r/' . strtolower($package) . '/deps.' . $release['v'] . '.txt');
             if (PEAR::isError($ds)) {
                 continue;
             }
             if (!isset($latest)) {
                 $latest = $release['v'];
             }
             $pf->setDeps(unserialize($ds));
             $ds = $pf->getDeps();
             $info = $this->_rest->retrieveCacheFirst($base . 'r/' . strtolower($package) . '/' . $release['v'] . '.xml');
             if (PEAR::isError($info)) {
                 continue;
             }
             $releases[$release['v']] = array('doneby' => $info['m'], 'license' => $info['l'], 'summary' => $info['s'], 'description' => $info['d'], 'releasedate' => $info['da'], 'releasenotes' => $info['n'], 'state' => $release['s'], 'deps' => $ds ? $ds : array());
         }
     } else {
         $latest = '';
     }
     PEAR::popErrorHandling();
     if (isset($pinfo['dc']) && isset($pinfo['dp'])) {
         if (is_array($pinfo['dp'])) {
             $deprecated = array('channel' => (string) $pinfo['dc'], 'package' => trim($pinfo['dp']['_content']));
         } else {
             $deprecated = array('channel' => (string) $pinfo['dc'], 'package' => trim($pinfo['dp']));
         }
     } else {
         $deprecated = false;
     }
     return array('name' => $pinfo['n'], 'channel' => $pinfo['c'], 'category' => $pinfo['ca']['_content'], 'stable' => $latest, 'license' => $pinfo['l'], 'summary' => $pinfo['s'], 'description' => $pinfo['d'], 'releases' => $releases, 'deprecated' => $deprecated);
 }
コード例 #15
0
ファイル: Downloader.php プロジェクト: soar-team/kloxo
 function &download($params)
 {
     if (!count($params)) {
         $a = array();
         return $a;
     }
     if (!isset($this->_registry)) {
         $this->_registry =& $this->config->getRegistry();
     }
     if (!isset($this->_remote)) {
         $this->_remote =& $this->config->getRemote();
     }
     $channelschecked = array();
     // convert all parameters into PEAR_Downloader_Package objects
     foreach ($params as $i => $param) {
         $params[$i] =& $this->newDownloaderPackage($this);
         PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
         $err = $params[$i]->initialize($param);
         PEAR::staticPopErrorHandling();
         if (!$err) {
             // skip parameters that were missed by preferred_state
             continue;
         }
         if (PEAR::isError($err)) {
             if (!isset($this->_options['soft'])) {
                 $this->log(0, $err->getMessage());
             }
             $params[$i] = false;
             if (is_object($param)) {
                 $param = $param->getChannel() . '/' . $param->getPackage();
             }
             $this->pushError('Package "' . $param . '" is not valid', PEAR_INSTALLER_SKIPPED);
         } else {
             if ($params[$i] && !isset($channelschecked[$params[$i]->getChannel()]) && !isset($this->_options['offline'])) {
                 $channelschecked[$params[$i]->getChannel()] = true;
                 PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
                 if (!class_exists('System')) {
                     require_once 'System.php';
                 }
                 $curchannel =& $this->_registry->getChannel($params[$i]->getChannel());
                 if (PEAR::isError($curchannel)) {
                     PEAR::staticPopErrorHandling();
                     return $this->raiseError($curchannel);
                 }
                 $a = $this->downloadHttp('http://' . $params[$i]->getChannel() . '/channel.xml', $this->ui, System::mktemp(array('-d')), null, $curchannel->lastModified());
                 PEAR::staticPopErrorHandling();
                 if (PEAR::isError($a) || !$a) {
                     continue;
                 }
                 $this->log(0, 'WARNING: channel "' . $params[$i]->getChannel() . '" has ' . 'updated its protocols, use "channel-update ' . $params[$i]->getChannel() . '" to update');
             }
             if ($params[$i] && !isset($this->_options['downloadonly'])) {
                 if (isset($this->_options['packagingroot'])) {
                     $checkdir = $this->_prependPath($this->config->get('php_dir', null, $params[$i]->getChannel()), $this->_options['packagingroot']);
                 } else {
                     $checkdir = $this->config->get('php_dir', null, $params[$i]->getChannel());
                 }
                 while ($checkdir && $checkdir != '/' && !file_exists($checkdir)) {
                     $checkdir = dirname($checkdir);
                 }
                 if ($checkdir == '.') {
                     $checkdir = '/';
                 }
                 if (!@is_writeable($checkdir)) {
                     return PEAR::raiseError('Cannot install, php_dir for channel "' . $params[$i]->getChannel() . '" is not writeable by the current user');
                 }
             }
         }
     }
     unset($channelschecked);
     PEAR_Downloader_Package::removeDuplicates($params);
     if (!count($params)) {
         $a = array();
         return $a;
     }
     if (!isset($this->_options['nodeps']) && !isset($this->_options['offline'])) {
         $reverify = true;
         while ($reverify) {
             $reverify = false;
             foreach ($params as $i => $param) {
                 $ret = $params[$i]->detectDependencies($params);
                 if (PEAR::isError($ret)) {
                     $reverify = true;
                     $params[$i] = false;
                     PEAR_Downloader_Package::removeDuplicates($params);
                     if (!isset($this->_options['soft'])) {
                         $this->log(0, $ret->getMessage());
                     }
                     continue 2;
                 }
             }
         }
     }
     if (isset($this->_options['offline'])) {
         $this->log(3, 'Skipping dependency download check, --offline specified');
     }
     if (!count($params)) {
         $a = array();
         return $a;
     }
     while (PEAR_Downloader_Package::mergeDependencies($params)) {
     }
     PEAR_Downloader_Package::removeInstalled($params);
     if (!count($params)) {
         $this->pushError('No valid packages found', PEAR_INSTALLER_FAILED);
         $a = array();
         return $a;
     }
     PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
     $err = $this->analyzeDependencies($params);
     PEAR::popErrorHandling();
     if (!count($params)) {
         $this->pushError('No valid packages found', PEAR_INSTALLER_FAILED);
         $a = array();
         return $a;
     }
     $ret = array();
     $newparams = array();
     if (isset($this->_options['pretend'])) {
         return $params;
     }
     foreach ($params as $i => $package) {
         PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
         $pf =& $params[$i]->download();
         PEAR::staticPopErrorHandling();
         if (PEAR::isError($pf)) {
             if (!isset($this->_options['soft'])) {
                 $this->log(1, $pf->getMessage());
                 $this->log(0, 'Error: cannot download "' . $this->_registry->parsedPackageNameToString($package->getParsedPackage(), true) . '"');
             }
             continue;
         }
         $newparams[] =& $params[$i];
         $ret[] = array('file' => $pf->getArchiveFile(), 'info' => &$pf, 'pkg' => $pf->getPackage());
     }
     $this->_downloadedPackages = $ret;
     return $newparams;
 }
コード例 #16
0
 /**
  * Add a new user account
  *
  * During most of this method's operation, PEAR's error handling
  * is set to PEAR_ERROR_RETURN.
  *
  * But, during the DB_storage::set() phase error handling is set to
  * PEAR_ERROR_CALLBACK the report_warning() function.  So, if an
  * error happens a warning message is printed AND the incomplete
  * user information is removed.
  *
  * @param array $data  Information about the user
  *
  * @return mixed  true if there are no problems, false if sending the
  *                email failed, 'set error' if DB_storage::set() failed
  *                or an array of error messages for other problems
  *
  * @access public
  */
 function add(&$data)
 {
     global $dbh;
     PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
     $errors = array();
     $required = array('handle' => 'Username', 'firstname' => 'First Name', 'lastname' => 'Last Name', 'email' => 'Email address', 'purpose' => 'Intended purpose');
     $name = $data['firstname'] . " " . $data['lastname'];
     foreach ($required as $field => $desc) {
         if (empty($data[$field])) {
             $data['jumpto'] = $field;
             $errors[] = 'Please enter ' . $desc;
         }
     }
     if (!preg_match(PEAR_COMMON_USER_NAME_REGEX, $data['handle'])) {
         $errors[] = 'Username must start with a letter and contain' . ' only letters and digits';
     }
     // Basic name validation
     // First- and lastname must be longer than 1 character
     if (strlen($data['firstname']) == 1) {
         $errors[] = 'Your firstname appears to be too short.';
     }
     if (strlen($data['lastname']) == 1) {
         $errors[] = 'Your lastname appears to be too short.';
     }
     // Firstname and lastname must start with an uppercase letter
     if (!preg_match("/^[A-Z]/", $data['firstname'])) {
         $errors[] = 'Your firstname must begin with an uppercase letter';
     }
     if (!preg_match("/^[A-Z]/", $data['lastname'])) {
         $errors[] = 'Your lastname must begin with an uppercase letter';
     }
     // No names with only uppercase letters
     if ($data['firstname'] === strtoupper($data['firstname'])) {
         $errors[] = 'Your firstname must not consist of only uppercase letters.';
     }
     if ($data['lastname'] === strtoupper($data['lastname'])) {
         $errors[] = 'Your lastname must not consist of only uppercase letters.';
     }
     if ($data['password'] != $data['password2']) {
         $data['password'] = $data['password2'] = "";
         $data['jumpto'] = "password";
         $errors[] = 'Passwords did not match';
     }
     if (!$data['password']) {
         $data['jumpto'] = "password";
         $errors[] = 'Empty passwords not allowed';
     }
     $handle = strtolower($data['handle']);
     $obj =& new PEAR_User($dbh, $handle);
     if (isset($obj->created)) {
         $data['jumpto'] = "handle";
         $errors[] = 'Sorry, that username is already taken';
     }
     if ($errors) {
         $data['display_form'] = true;
         return $errors;
     }
     $err = $obj->insert($handle);
     if (DB::isError($err)) {
         if ($err->getCode() == DB_ERROR_CONSTRAINT) {
             $data['display_form'] = true;
             $data['jumpto'] = 'handle';
             $errors[] = 'Sorry, that username is already taken';
         } else {
             $data['display_form'] = false;
             $errors[] = $err;
         }
         return $errors;
     }
     $data['display_form'] = false;
     $md5pw = md5($data['password']);
     $showemail = @(bool) $data['showemail'];
     // hack to temporarily embed the "purpose" in
     // the user's "userinfo" column
     $userinfo = serialize(array($data['purpose'], $data['moreinfo']));
     $set_vars = array('name' => $name, 'email' => $data['email'], 'homepage' => $data['homepage'], 'showemail' => $showemail, 'password' => $md5pw, 'registered' => 0, 'userinfo' => $userinfo);
     PEAR::pushErrorHandling(PEAR_ERROR_CALLBACK, 'report_warning');
     foreach ($set_vars as $var => $value) {
         $err = $obj->set($var, $value);
         if (PEAR::isError($err)) {
             user::remove($data['handle']);
             return 'set error';
         }
     }
     PEAR::popErrorHandling();
     $msg = "Requested from:   {$_SERVER['REMOTE_ADDR']}\n" . "Username:         {$handle}\n" . "Real Name:        {$name}\n" . (isset($data['showemail']) ? "Email:            {$data['email']}\n" : "") . "Purpose:\n" . "{$data['purpose']}\n\n" . "To handle: http://{$_SERVER['SERVER_NAME']}/admin/?acreq={$handle}\n";
     if ($data['moreinfo']) {
         $msg .= "\nMore info:\n{$data['moreinfo']}\n";
     }
     $xhdr = "From: {$name} <{$data['email']}>\nMessage-Id: <account-request-{$handle}@" . PEAR_CHANNELNAME . ">\n";
     // $xhdr .= "\nBCC: pear-group@php.net";
     $subject = "PEAR Account Request: {$handle}";
     if (DEVBOX == false) {
         if (PEAR_CHANNELNAME == 'pear.php.net') {
             $ok = @mail('*****@*****.**', $subject, $msg, $xhdr, '-f noreply@php.net');
         }
     } else {
         $ok = true;
     }
     PEAR::popErrorHandling();
     return $ok;
 }
コード例 #17
0
ファイル: Package.php プロジェクト: hbustun/agilebill
 /**
  *
  * @param string|array pass in an array of format
  *                     array(
  *                      'package' => 'pname',
  *                     ['channel' => 'channame',]
  *                     ['version' => 'version',]
  *                     ['state' => 'state',])
  *                     or a string of format [channame/]pname[-version|-state]
  */
 function _fromString($param)
 {
     $options = $this->_downloader->getOptions();
     PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
     $pname = $this->_registry->parsePackageName($param, $this->_config->get('default_channel'));
     PEAR::popErrorHandling();
     if (PEAR::isError($pname)) {
         if ($pname->getCode() == 'invalid') {
             $this->_valid = false;
             return false;
         }
         if ($pname->getCode() == 'channel') {
             $parsed = $pname->getUserInfo();
             if ($this->_downloader->discover($parsed['channel'])) {
                 if ($this->_config->get('auto_discover')) {
                     PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
                     $pname = $this->_registry->parsePackageName($param, $this->_config->get('default_channel'));
                     PEAR::popErrorHandling();
                 } else {
                     if (!isset($options['soft'])) {
                         $this->_downloader->log(0, 'Channel "' . $parsed['channel'] . '" is not initialized, use ' . '"pear channel-discover ' . $parsed['channel'] . '" to initialize' . 'or pear config-set auto_discover 1');
                     }
                 }
             }
             if (PEAR::isError($pname)) {
                 if (!isset($options['soft'])) {
                     $this->_downloader->log(0, $pname->getMessage());
                 }
                 if (is_array($param)) {
                     $param = $this->_registry->parsedPackageNameToString($param);
                 }
                 $err = PEAR::raiseError('invalid package name/package file "' . $param . '"');
                 $this->_valid = false;
                 return $err;
             }
         } else {
             if (!isset($options['soft'])) {
                 $this->_downloader->log(0, $pname->getMessage());
             }
             $err = PEAR::raiseError('invalid package name/package file "' . $param . '"');
             $this->_valid = false;
             return $err;
         }
     }
     if (!isset($this->_type)) {
         $this->_type = 'xmlrpc';
     }
     $this->_parsedname = $pname;
     if (isset($pname['state'])) {
         $this->_explicitState = $pname['state'];
     } else {
         $this->_explicitState = false;
     }
     if (isset($pname['group'])) {
         $this->_explicitGroup = true;
     } else {
         $this->_explicitGroup = false;
     }
     $info = $this->_downloader->_getPackageDownloadUrl($pname);
     if (PEAR::isError($info)) {
         if ($pname['channel'] == 'pear.php.net') {
             // try pecl
             $pname['channel'] = 'pecl.php.net';
             if ($test = $this->_downloader->_getPackageDownloadUrl($pname)) {
                 if (!PEAR::isError($test)) {
                     $info = PEAR::raiseError($info->getMessage() . ' - package ' . $this->_registry->parsedPackageNameToString($pname, true) . ' can be installed with "pecl install ' . $pname['package'] . '"');
                 }
             }
         }
         return $info;
     }
     $this->_rawpackagefile = $info['raw'];
     $ret = $this->_analyzeDownloadURL($info, $param, $pname);
     if (PEAR::isError($ret)) {
         return $ret;
     }
     if ($ret) {
         $this->_downloadURL = $ret;
         return $this->_valid = (bool) $ret;
     }
 }
コード例 #18
0
 /**
  * Tests that the MDB2::factory() method correctly connects to a
  * database.
  */
 function test_factory()
 {
     $db =& MDB2::factory($this->dsn);
     $this->assertTrue(MDB2::isConnection($db), 'factory');
     // Suppress handling of PEAR errors while preparing the
     // next test case database connection
     PEAR::pushErrorHandling(null);
     $db =& MDB2::factory(null);
     PEAR::popErrorHandling();
     $this->assertFalse(MDB2::isConnection($db), 'factory');
 }
コード例 #19
0
ファイル: Downloader.php プロジェクト: shen0834/util
 function &download($params)
 {
     if (!count($params)) {
         $a = array();
         return $a;
     }
     if (!isset($this->_registry)) {
         $this->_registry =& $this->config->getRegistry();
     }
     $channelschecked = array();
     // convert all parameters into PEAR_Downloader_Package objects
     foreach ($params as $i => $param) {
         $params[$i] =& $this->newDownloaderPackage($this);
         PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
         $err = $params[$i]->initialize($param);
         PEAR::staticPopErrorHandling();
         if (!$err) {
             // skip parameters that were missed by preferred_state
             continue;
         }
         if (PEAR::isError($err)) {
             if (!isset($this->_options['soft']) && $err->getMessage() !== '') {
                 $this->log(0, $err->getMessage());
             }
             $params[$i] = false;
             if (is_object($param)) {
                 $param = $param->getChannel() . '/' . $param->getPackage();
             }
             if (!isset($this->_options['soft'])) {
                 $this->log(2, 'Package "' . $param . '" is not valid');
             }
             // Message logged above in a specific verbose mode, passing null to not show up on CLI
             $this->pushError(null, PEAR_INSTALLER_SKIPPED);
         } else {
             do {
                 if ($params[$i] && $params[$i]->getType() == 'local') {
                     // bug #7090 skip channel.xml check for local packages
                     break;
                 }
                 if ($params[$i] && !isset($channelschecked[$params[$i]->getChannel()]) && !isset($this->_options['offline'])) {
                     $channelschecked[$params[$i]->getChannel()] = true;
                     PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
                     if (!class_exists('System')) {
                         require_once 'System.php';
                     }
                     $curchannel =& $this->_registry->getChannel($params[$i]->getChannel());
                     if (PEAR::isError($curchannel)) {
                         PEAR::staticPopErrorHandling();
                         return $this->raiseError($curchannel);
                     }
                     if (PEAR::isError($dir = $this->getDownloadDir())) {
                         PEAR::staticPopErrorHandling();
                         break;
                     }
                     $mirror = $this->config->get('preferred_mirror', null, $params[$i]->getChannel());
                     $url = 'http://' . $mirror . '/channel.xml';
                     $a = $this->downloadHttp($url, $this->ui, $dir, null, $curchannel->lastModified());
                     PEAR::staticPopErrorHandling();
                     if (PEAR::isError($a) || !$a) {
                         // Attempt fallback to https automatically
                         PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
                         $a = $this->downloadHttp('https://' . $mirror . '/channel.xml', $this->ui, $dir, null, $curchannel->lastModified());
                         PEAR::staticPopErrorHandling();
                         if (PEAR::isError($a) || !$a) {
                             break;
                         }
                     }
                     $this->log(0, 'WARNING: channel "' . $params[$i]->getChannel() . '" has ' . 'updated its protocols, use "' . PEAR_RUNTYPE . ' channel-update ' . $params[$i]->getChannel() . '" to update');
                 }
             } while (false);
             if ($params[$i] && !isset($this->_options['downloadonly'])) {
                 if (isset($this->_options['packagingroot'])) {
                     $checkdir = $this->_prependPath($this->config->get('php_dir', null, $params[$i]->getChannel()), $this->_options['packagingroot']);
                 } else {
                     $checkdir = $this->config->get('php_dir', null, $params[$i]->getChannel());
                 }
                 while ($checkdir && $checkdir != '/' && !file_exists($checkdir)) {
                     $checkdir = dirname($checkdir);
                 }
                 if ($checkdir == '.') {
                     $checkdir = '/';
                 }
                 if (!is_writeable($checkdir)) {
                     return PEAR::raiseError('Cannot install, php_dir for channel "' . $params[$i]->getChannel() . '" is not writeable by the current user');
                 }
             }
         }
     }
     unset($channelschecked);
     PEAR_Downloader_Package::removeDuplicates($params);
     if (!count($params)) {
         $a = array();
         return $a;
     }
     if (!isset($this->_options['nodeps']) && !isset($this->_options['offline'])) {
         $reverify = true;
         while ($reverify) {
             $reverify = false;
             foreach ($params as $i => $param) {
                 //PHP Bug 40768 / PEAR Bug #10944
                 //Nested foreaches fail in PHP 5.2.1
                 key($params);
                 $ret = $params[$i]->detectDependencies($params);
                 if (PEAR::isError($ret)) {
                     $reverify = true;
                     $params[$i] = false;
                     PEAR_Downloader_Package::removeDuplicates($params);
                     if (!isset($this->_options['soft'])) {
                         $this->log(0, $ret->getMessage());
                     }
                     continue 2;
                 }
             }
         }
     }
     if (isset($this->_options['offline'])) {
         $this->log(3, 'Skipping dependency download check, --offline specified');
     }
     if (!count($params)) {
         $a = array();
         return $a;
     }
     while (PEAR_Downloader_Package::mergeDependencies($params)) {
     }
     PEAR_Downloader_Package::removeDuplicates($params, true);
     $errorparams = array();
     if (PEAR_Downloader_Package::detectStupidDuplicates($params, $errorparams)) {
         if (count($errorparams)) {
             foreach ($errorparams as $param) {
                 $name = $this->_registry->parsedPackageNameToString($param->getParsedPackage());
                 $this->pushError('Duplicate package ' . $name . ' found', PEAR_INSTALLER_FAILED);
             }
             $a = array();
             return $a;
         }
     }
     PEAR_Downloader_Package::removeInstalled($params);
     if (!count($params)) {
         $this->pushError('No valid packages found', PEAR_INSTALLER_FAILED);
         $a = array();
         return $a;
     }
     PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
     $err = $this->analyzeDependencies($params);
     PEAR::popErrorHandling();
     if (!count($params)) {
         $this->pushError('No valid packages found', PEAR_INSTALLER_FAILED);
         $a = array();
         return $a;
     }
     $ret = array();
     $newparams = array();
     if (isset($this->_options['pretend'])) {
         return $params;
     }
     $somefailed = false;
     foreach ($params as $i => $package) {
         PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
         $pf =& $params[$i]->download();
         PEAR::staticPopErrorHandling();
         if (PEAR::isError($pf)) {
             if (!isset($this->_options['soft'])) {
                 $this->log(1, $pf->getMessage());
                 $this->log(0, 'Error: cannot download "' . $this->_registry->parsedPackageNameToString($package->getParsedPackage(), true) . '"');
             }
             $somefailed = true;
             continue;
         }
         $newparams[] =& $params[$i];
         $ret[] = array('file' => $pf->getArchiveFile(), 'info' => &$pf, 'pkg' => $pf->getPackage());
     }
     if ($somefailed) {
         // remove params that did not download successfully
         PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
         $err = $this->analyzeDependencies($newparams, true);
         PEAR::popErrorHandling();
         if (!count($newparams)) {
             $this->pushError('Download failed', PEAR_INSTALLER_FAILED);
             $a = array();
             return $a;
         }
     }
     $this->_downloadedPackages = $ret;
     return $newparams;
 }
コード例 #20
0
if ($fetype == 'Gtk' || $fetype == 'Gtk2') {
    if (!$config->validConfiguration()) {
        PEAR::raiseError('CRITICAL ERROR: no existing valid configuration files found in files ' . "'{$pear_user_config}' or '{$pear_system_config}', please copy an existing configuration" . 'file to one of these locations, or use the -c and -s options to create one');
    }
    Gtk::main();
} else {
    do {
        if ($command == 'help') {
            usage(null, @$options[1][1]);
        }
        if (!$config->validConfiguration()) {
            PEAR::raiseError('CRITICAL ERROR: no existing valid configuration files found in files ' . "'{$pear_user_config}' or '{$pear_system_config}', please copy an existing configuration" . 'file to one of these locations, or use the -c and -s options to create one');
        }
        PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
        $cmd = PEAR_Command::factory($command, $config);
        PEAR::popErrorHandling();
        if (PEAR::isError($cmd)) {
            usage(null, @$options[1][0]);
        }
        $short_args = $long_args = null;
        PEAR_Command::getGetoptArgs($command, $short_args, $long_args);
        if (in_array('getopt2', get_class_methods('Console_Getopt'))) {
            array_shift($options[1]);
            $tmp = Console_Getopt::getopt2($options[1], $short_args, $long_args);
        } else {
            $tmp = Console_Getopt::getopt($options[1], $short_args, $long_args);
        }
        if (PEAR::isError($tmp)) {
            break;
        }
        list($tmpopt, $params) = $tmp;
コード例 #21
0
function phpAds_getBannerCache($banner)
{
    $aConf = $GLOBALS['_MAX']['CONF'];
    $aPref = $GLOBALS['_MAX']['PREF'];
    $buffer = $banner['htmltemplate'];
    // Strip slashes from urls
    $banner['url'] = stripslashes($banner['url']);
    $banner['imageurl'] = stripslashes($banner['imageurl']);
    // The following properties depend on data from the invocation process
    // and can't yet be determined: {zoneid}, {bannerid}
    // These properties will be set during invocation
    if ($banner['adserver'] == 'none') {
        $buffer = php_Ads_wrapBannerHtmlInClickUrl($banner, $buffer);
        return $buffer;
    }
    if ($banner['storagetype'] != 'html') {
        return $buffer;
    }
    // Auto change HTML banner
    if ($buffer != '') {
        // Put our click URL and our target parameter in all anchors...
        // The regexp should handle ", ', \", \' as delimiters
        if (preg_match_all('#<a(\\s[^>]*?)href\\s*=\\s*(\\\\?[\'"])http(.*?)\\2(.*?) *>#is', $buffer, $m)) {
            foreach ($m[0] as $k => $v) {
                // Remove target parameters
                $m[1][$k] = ' ' . trim(preg_replace('#target\\s*=\\s*(\\\\?[\'"]).*?\\1#i', '', $m[1][$k]));
                $m[4][$k] = ' ' . trim(preg_replace('#target\\s*=\\s*(\\\\?[\'"]).*?\\1#i', '', $m[4][$k]));
                $m[3][$k] = html_entity_decode($m[3][$k], null, 'UTF-8');
                $urlDest = preg_replace('/%7B(.*?)%7D/', '{$1}', urlencode("http" . $m[3][$k]));
                $buffer = str_replace($v, "<a{$m[1][$k]}href={$m[2][$k]}{clickurl}{$urlDest}{$m[2][$k]}{$m[4][$k]}target={$m[2][$k]}{target}{$m[2][$k]}>", $buffer);
            }
        }
        // Search: <\s*form (.*?)action\s*=\s*['"](.*?)['"](.*?)>
        // Replace:<form\1 action="{url_prefix}/{$aConf['file']['click']}" \3><input type='hidden' name='{clickurlparams}\2'>
        $target = !empty($banner['target']) ? $banner['target'] : "_self";
        // strip out the method from any <forms> these will be changed to GET
        $buffer = preg_replace('#<\\s*form (.*?)method\\s*=\\s*[\\\\]?[\'"](.*?)[\'"]#is', "<form \$1 method='GET'", $buffer);
        if (preg_match_all('#<\\s*form (.*?)action\\s*=\\s*[\\\\]?[\'"](.*?)[\'\\\\"][\'\\\\"]?(.*?)>(.*?)</form>#is', $buffer, $m)) {
            foreach ($m[0] as $k => $v) {
                // Remove target parameters
                $m[3][$k] = trim(preg_replace('#target\\s*=\\s*(\\\\?[\'"]).*?\\1#i', '', $m[3][$k]));
                $buffer = str_replace($v, "<form {$m[1][$k]} action='{url_prefix}/{$aConf['file']['click']}' {$m[3][$k]} target='{$target}'>{$m[4][$k]}<input type='hidden' name='{$aConf['var']['params']}' value='{clickurlparams}{$m[2][$k]}'></form>", $buffer);
            }
        }
        //$buffer = preg_replace("#<form*action='*'*>#i","<form target='{target}' $1action='{url_prefix}/{}$aConf['file']['click']'$3><input type='hidden' name='{clickurlparams}$2'>", $buffer);
        //$buffer = preg_replace("#<form*action=\"*\"*>#i","<form target=\"{target}\" $1action=\"{url_prefix}/{$aConf['file']['click']}\"$3><input type=\"hidden\" name=\"{clickurlparams}$2\">", $buffer);
        // In addition, we need to add our clickURL to the clickTAG parameter if present, for 3rd party flash ads
        // the clickTag is case insentive match, as it is correct to use clicktag, CLICKTAG, etc.
        preg_match('/^(.*)(clickTAG)\\s?=\\s?(.*?)([\'"])(.*)$/is', $buffer, $matches);
        if (count($matches) > 0) {
            $matches[3] = html_entity_decode($matches[3], null, 'UTF-8');
            $buffer = $matches[1] . $matches[2] . "={clickurl}" . urlencode($matches[3]) . $matches[4] . $matches[5];
        }
        // Detect any JavaScript window.open() functions, and prepend the opened URL with our logurl
        $buffer = preg_replace('#window.open\\s?\\((.*?)\\)#i', "window.open(\\\\'{logurl}&maxdest=\\\\'+\$1)", $buffer);
    }
    // Since we don't want to replace adserver noscript and iframe content with click tracking etc
    $noScript = array();
    //Capture noscript content into $noScript[0], for seperate translations
    preg_match("#<noscript>(.*?)</noscript>#is", $buffer, $noScript);
    $buffer = preg_replace("#<noscript>(.*?)</noscript>#is", '{noscript}', $buffer);
    // run 3rd party component
    if (!empty($banner['adserver'])) {
        require_once LIB_PATH . '/Plugin/Component.php';
        /**
         * @todo This entire function should be relocated to the DLL and should be object-ified
         *
         */
        PEAR::pushErrorHandling(null);
        $adServerComponent = OX_Component::factoryByComponentIdentifier($banner['adserver']);
        PEAR::popErrorHandling();
        if ($adServerComponent) {
            $buffer = $adServerComponent->getBannerCache($buffer, $noScript);
        } else {
            $GLOBALS['_MAX']['bannerrebuild']['errors'] = true;
        }
    }
    $buffer = php_Ads_wrapBannerHtmlInClickUrl($banner, $buffer);
    // Adserver processing complete, now replace the noscript values back:
    //$buffer = preg_replace("#{noframe}#", $noFrame[2], $buffer);
    if (isset($noScript[0])) {
        $buffer = preg_replace("#{noscript}#", $noScript[0], $buffer);
    }
    // Allow custom banner types to alter the banner cache.
    $bannerTypeComponent = OX_Component::factoryByComponentIdentifier($banner['ext_bannertype']);
    if ($bannerTypeComponent) {
        $buffer = $bannerTypeComponent->getBannerCache($buffer, $noScript, $banner);
    }
    return $buffer;
}
コード例 #22
0
ファイル: Validator.php プロジェクト: racontemoi/mamp
 function _analyzeBundledPackages()
 {
     if (!$this->_isValid) {
         return false;
     }
     if (!$this->_pf->getPackageType() == 'bundle') {
         return false;
     }
     if (!isset($this->_pf->_packageFile)) {
         return false;
     }
     $dir_prefix = dirname($this->_pf->_packageFile);
     $common = new PEAR_Common();
     $log = isset($this->_pf->_logger) ? array(&$this->_pf->_logger, 'log') : array($common, 'log');
     $info = $this->_pf->getContents();
     $info = $info['bundledpackage'];
     if (!is_array($info)) {
         $info = array($info);
     }
     $pkg =& new PEAR_PackageFile($this->_pf->_config);
     foreach ($info as $package) {
         if (!file_exists($dir_prefix . DIRECTORY_SEPARATOR . $package)) {
             $this->_fileNotFound($dir_prefix . DIRECTORY_SEPARATOR . $package);
             $this->_isValid = 0;
             continue;
         }
         call_user_func_array($log, array(1, "Analyzing bundled package {$package}"));
         PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
         $ret = $pkg->fromAnyFile($dir_prefix . DIRECTORY_SEPARATOR . $package, PEAR_VALIDATE_NORMAL);
         PEAR::popErrorHandling();
         if (PEAR::isError($ret)) {
             call_user_func_array($log, array(0, "ERROR: package {$package} is not a valid " . 'package'));
             $inf = $ret->getUserInfo();
             if (is_array($inf)) {
                 foreach ($inf as $err) {
                     call_user_func_array($log, array(1, $err['message']));
                 }
             }
             return false;
         }
     }
     return true;
 }
コード例 #23
0
ファイル: Installer.php プロジェクト: zseand/kloxo
 /**
  * Uninstall a package
  *
  * This method removes all files installed by the application, and then
  * removes any empty directories.
  * @param string package name
  * @param array Command-line options.  Possibilities include:
  *
  *              - installroot: base installation dir, if not the default
  *              - nodeps: do not process dependencies of other packages to ensure
  *                        uninstallation does not break things
  */
 function uninstall($package, $options = array())
 {
     if (isset($options['installroot'])) {
         $this->config->setInstallRoot($options['installroot']);
         $this->installroot = '';
     } else {
         $this->config->setInstallRoot('');
         $this->installroot = '';
     }
     $this->_registry =& $this->config->getRegistry();
     if (is_object($package)) {
         $channel = $package->getChannel();
         $pkg = $package;
         $package = $pkg->getPackage();
     } else {
         $pkg = false;
         $info = $this->_registry->parsePackageName($package, $this->config->get('default_channel'));
         $channel = $info['channel'];
         $package = $info['package'];
     }
     $savechannel = $this->config->get('default_channel');
     $this->configSet('default_channel', $channel);
     if (!is_object($pkg)) {
         $pkg = $this->_registry->getPackage($package, $channel);
     }
     if (!$pkg) {
         $this->configSet('default_channel', $savechannel);
         return $this->raiseError($this->_registry->parsedPackageNameToString(array('channel' => $channel, 'package' => $package), true) . ' not installed');
     }
     if ($pkg->getInstalledBinary()) {
         // this is just an alias for a binary package
         return $this->_registry->deletePackage($package, $channel);
     }
     $filelist = $pkg->getFilelist();
     PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
     if (!class_exists('PEAR_Dependency2')) {
         require_once 'PEAR/Dependency2.php';
     }
     $depchecker =& new PEAR_Dependency2($this->config, $options, array('channel' => $channel, 'package' => $package), PEAR_VALIDATE_UNINSTALLING);
     $e = $depchecker->validatePackageUninstall($this);
     PEAR::staticPopErrorHandling();
     if (PEAR::isError($e)) {
         if (!isset($options['ignore-errors'])) {
             return $this->raiseError($e);
         } else {
             if (!isset($options['soft'])) {
                 $this->log(0, 'WARNING: ' . $e->getMessage());
             }
         }
     } elseif (is_array($e)) {
         if (!isset($options['soft'])) {
             $this->log(0, $e[0]);
         }
     }
     // {{{ Delete the files
     $this->startFileTransaction();
     PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
     if (PEAR::isError($err = $this->_deletePackageFiles($package, $channel))) {
         PEAR::popErrorHandling();
         $this->rollbackFileTransaction();
         $this->configSet('default_channel', $savechannel);
         if (!isset($options['ignore-errors'])) {
             return $this->raiseError($err);
         } else {
             if (!isset($options['soft'])) {
                 $this->log(0, 'WARNING: ' . $err->getMessage());
             }
         }
     } else {
         PEAR::popErrorHandling();
     }
     if (!$this->commitFileTransaction()) {
         $this->rollbackFileTransaction();
         if (!isset($options['ignore-errors'])) {
             return $this->raiseError("uninstall failed");
         } elseif (!isset($options['soft'])) {
             $this->log(0, 'WARNING: uninstall failed');
         }
     } else {
         $this->startFileTransaction();
         if ($dirtree = $pkg->getDirTree()) {
             // attempt to delete empty directories
             uksort($dirtree, array($this, '_sortDirs'));
             foreach ($dirtree as $dir => $notused) {
                 $this->addFileOperation('rmdir', array($dir));
             }
         } else {
             $this->configSet('default_channel', $savechannel);
             return $this->_registry->deletePackage($package, $channel);
         }
         if (!$this->commitFileTransaction()) {
             $this->rollbackFileTransaction();
         }
     }
     // }}}
     $this->configSet('default_channel', $savechannel);
     // Register that the package is no longer installed
     return $this->_registry->deletePackage($package, $channel);
 }
コード例 #24
0
ファイル: CSV.php プロジェクト: BackupTheBerlios/smart-svn
 /**
  * Return or create the file descriptor associated with a file
  *
  * @param string $file The name of the file
  * @param array  &$conf The configuration
  * @param string $mode The open node (ex: FILE_MODE_READ or FILE_MODE_WRITE)
  *
  * @return mixed A file resource or false
  */
 function getPointer($file, &$conf, $mode = FILE_MODE_READ)
 {
     static $resources = array();
     static $config;
     if (isset($resources[$file])) {
         $conf = $config;
         return $resources[$file];
     }
     File_CSV::_conf($conf, $error);
     if ($error) {
         return File_CSV::raiseError($error);
     }
     $config = $conf;
     PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
     $fp =& File::_getFilePointer($file, $mode);
     PEAR::popErrorHandling();
     if (PEAR::isError($fp)) {
         return File_CSV::raiseError($fp);
     }
     $resources[$file] = $fp;
     if ($mode == FILE_MODE_READ && !empty($conf['header'])) {
         if (!File_CSV::read($file, $conf)) {
             return false;
         }
     }
     return $fp;
 }
コード例 #25
0
ファイル: REST.php プロジェクト: kractos26/orfeo
 /**
  * Retrieve a remote REST resource
  * @param string full URL to this resource
  * @param array|false contents of the accept-encoding header
  * @param boolean     if true, xml will be returned as a string, otherwise, xml will be
  *                    parsed using PEAR_XMLParser
  * @return string|array
  */
 function retrieveData($url, $accept = false, $forcestring = false)
 {
     $cacheId = $this->getCacheId($url);
     if ($ret = $this->useLocalCache($url, $cacheId)) {
         return $ret;
     }
     if (!isset($this->_options['offline'])) {
         $trieddownload = true;
         $file = $this->downloadHttp($url, $cacheId ? $cacheId['lastChange'] : false, $accept);
     } else {
         $trieddownload = false;
         $file = false;
     }
     if (PEAR::isError($file)) {
         if ($file->getCode() == -9276) {
             $trieddownload = false;
             $file = false;
             // use local copy if available on socket connect error
         } else {
             return $file;
         }
     }
     if (!$file) {
         $ret = $this->getCache($url);
         if (!PEAR::isError($ret) && $trieddownload) {
             // reset the age of the cache if the server says it was unmodified
             $this->saveCache($url, $ret, null, true, $cacheId);
         }
         return $ret;
     }
     if (is_array($file)) {
         $headers = $file[2];
         $lastmodified = $file[1];
         $content = $file[0];
     } else {
         $content = $file;
         $lastmodified = false;
         $headers = array();
     }
     if ($forcestring) {
         $this->saveCache($url, $content, $lastmodified, false, $cacheId);
         return $content;
     }
     if (isset($headers['content-type'])) {
         switch ($headers['content-type']) {
             case 'text/xml':
             case 'application/xml':
                 $parser = new PEAR_XMLParser();
                 PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
                 $err = $parser->parse($content);
                 PEAR::popErrorHandling();
                 if (PEAR::isError($err)) {
                     return PEAR::raiseError('Invalid xml downloaded from "' . $url . '": ' . $err->getMessage());
                 }
                 $content = $parser->getData();
             case 'text/html':
             default:
                 // use it as a string
         }
     } else {
         // assume XML
         $parser = new PEAR_XMLParser();
         $parser->parse($content);
         $content = $parser->getData();
     }
     $this->saveCache($url, $content, $lastmodified, false, $cacheId);
     return $content;
 }
コード例 #26
0
ファイル: Upgrade.php プロジェクト: villos/tree_admin
 /**
  * test if the database username has necessary permissions
  *
  * @return boolean
  */
 function checkPermissionToCreateTable()
 {
     $prefix = $GLOBALS['_MAX']['CONF']['table']['prefix'];
     // If prefix is not lowercase, check for DB case sensitivity
     if ($prefix != strtolower($prefix)) {
         $result = $this->oDbh->isDBCaseSensitive();
         if (PEAR::isError($result)) {
             $this->oLogger->logError('Unable to retrieve database case sensitivity info');
             return false;
         }
         if (!$result) {
             $this->oLogger->logError('OpenX requires database case sensitivity to work with uppercase prefixes');
             return false;
         }
     }
     $aExistingTables = OA_DB_Table::listOATablesCaseSensitive();
     if (PEAR::isError($aExistingTables)) {
         $this->oLogger->logError('Unable to SHOW TABLES - check your database permissions');
         return false;
     }
     $tblTmp = $prefix . 'tmp_dbpriviligecheck';
     $tblTmpQuoted = $this->oDbh->quoteIdentifier($tblTmp, true);
     if (in_array($tblTmp, $aExistingTables)) {
         $result = $this->oDbh->exec("DROP TABLE {$tblTmpQuoted}");
     }
     if (PEAR::isError($result)) {
         $this->oLogger->logError('Test privileges table already exists and you don\'t have permissions to remove it');
         return false;
     }
     $result = $this->oDbh->exec("CREATE TABLE {$tblTmpQuoted} (tmp int)");
     if (PEAR::isError($result)) {
         $this->oLogger->logError('Failed to CREATE TABLE - check your database permissions');
         return false;
     }
     $result = $this->oDbh->manager->listTableFields($tblTmp);
     PEAR::popErrorHandling();
     if (PEAR::isError($result)) {
         $this->oDbh->exec("DROP TABLE {$tblTmpQuoted}");
         $this->oLogger->logError('Failed to SHOW FIELDS - check your database permissions');
         return false;
     }
     $result = $this->oDbh->exec("ALTER TABLE {$tblTmpQuoted} ADD test_desc TEXT");
     if (PEAR::isError($result)) {
         $this->oDbh->exec("DROP TABLE {$tblTmpQuoted}");
         $this->oLogger->logError('Failed to ALTER TABLE - check your database permissions');
         return false;
     }
     $result = $this->oDbh->manager->createIndex($tblTmp, $tblTmp . '_idx', array('fields' => array('tmp' => array('sorting' => 'ascending'))));
     if (PEAR::isError($result)) {
         $this->oDbh->exec("DROP TABLE {$tblTmpQuoted}");
         $this->oLogger->logError('Failed to CREATE INDEX - check your database permissions');
         return false;
     }
     $result = $this->oDbh->manager->dropIndex($tblTmp, $tblTmp . '_idx');
     if (PEAR::isError($result)) {
         $this->oDbh->exec("DROP TABLE {$tblTmpQuoted}");
         $this->oLogger->logError('Failed to DROP INDEX - check your database permissions');
         return false;
     }
     $result = $this->oDbh->exec("DROP TABLE {$tblTmpQuoted}");
     if (PEAR::isError($result)) {
         $this->oLogger->logError('Failed to DROP TABLE - check your database permissions');
         return false;
     }
     //$tblTmp = $prefix.'tmp_tmp_dbpriviligecheck';
     $result = $this->oDbh->exec("CREATE TEMPORARY TABLE {$tblTmpQuoted} (tmp int)");
     if (PEAR::isError($result)) {
         $this->oLogger->logError('Failed to CREATE TEMPORARY TABLE - check your database permissions');
         return false;
     }
     $result = $this->oDbh->exec("DROP TABLE {$tblTmpQuoted}");
     if (PEAR::isError($result)) {
         $this->oLogger->logError('Failed to DROP TEMPORARY TABLE - check your database permissions');
         return false;
     }
     $this->oLogger->log('Database settings and permissions are OK');
     return true;
 }
コード例 #27
0
ファイル: 11.php プロジェクト: rjsmelo/tiki
 function listAll($base, $dostable, $basic = true, $searchpackage = false, $searchsummary = false, $channel = false)
 {
     $categorylist = $this->_rest->retrieveData($base . 'c/categories.xml', false, false, $channel);
     if (PEAR::isError($categorylist)) {
         return $categorylist;
     }
     $ret = array();
     if (!is_array($categorylist['c']) || !isset($categorylist['c'][0])) {
         $categorylist['c'] = array($categorylist['c']);
     }
     PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
     foreach ($categorylist['c'] as $progress => $category) {
         $category = $category['_content'];
         $packagesinfo = $this->_rest->retrieveData($base . 'c/' . urlencode($category) . '/packagesinfo.xml', false, false, $channel);
         if (PEAR::isError($packagesinfo)) {
             continue;
         }
         if (!is_array($packagesinfo) || !isset($packagesinfo['pi'])) {
             continue;
         }
         if (!is_array($packagesinfo['pi']) || !isset($packagesinfo['pi'][0])) {
             $packagesinfo['pi'] = array($packagesinfo['pi']);
         }
         foreach ($packagesinfo['pi'] as $packageinfo) {
             $info = $packageinfo['p'];
             $package = $info['n'];
             $releases = isset($packageinfo['a']) ? $packageinfo['a'] : false;
             unset($latest);
             unset($unstable);
             unset($stable);
             unset($state);
             if ($releases) {
                 if (!isset($releases['r'][0])) {
                     $releases['r'] = array($releases['r']);
                 }
                 foreach ($releases['r'] as $release) {
                     if (!isset($latest)) {
                         if ($dostable && $release['s'] == 'stable') {
                             $latest = $release['v'];
                             $state = 'stable';
                         }
                         if (!$dostable) {
                             $latest = $release['v'];
                             $state = $release['s'];
                         }
                     }
                     if (!isset($stable) && $release['s'] == 'stable') {
                         $stable = $release['v'];
                         if (!isset($unstable)) {
                             $unstable = $stable;
                         }
                     }
                     if (!isset($unstable) && $release['s'] != 'stable') {
                         $unstable = $release['v'];
                         $state = $release['s'];
                     }
                     if (isset($latest) && !isset($state)) {
                         $state = $release['s'];
                     }
                     if (isset($latest) && isset($stable) && isset($unstable)) {
                         break;
                     }
                 }
             }
             if ($basic) {
                 // remote-list command
                 if (!isset($latest)) {
                     $latest = false;
                 }
                 if ($dostable) {
                     // $state is not set if there are no releases
                     if (isset($state) && $state == 'stable') {
                         $ret[$package] = array('stable' => $latest);
                     } else {
                         $ret[$package] = array('stable' => '-n/a-');
                     }
                 } else {
                     $ret[$package] = array('stable' => $latest);
                 }
                 continue;
             }
             // list-all command
             $deps = array();
             if (!isset($unstable)) {
                 $unstable = false;
                 $state = 'stable';
                 if (isset($stable)) {
                     $latest = $unstable = $stable;
                 }
             } else {
                 $latest = $unstable;
             }
             if (!isset($latest)) {
                 $latest = false;
             }
             if ($latest && isset($packageinfo['deps'])) {
                 if (!is_array($packageinfo['deps']) || !isset($packageinfo['deps'][0])) {
                     $packageinfo['deps'] = array($packageinfo['deps']);
                 }
                 $d = false;
                 foreach ($packageinfo['deps'] as $dep) {
                     if ($dep['v'] == $latest) {
                         $d = unserialize($dep['d']);
                     }
                 }
                 if ($d) {
                     if (isset($d['required'])) {
                         if (!isset($pf)) {
                             $pf = new PEAR_PackageFile_v2();
                         }
                         $pf->setDeps($d);
                         $tdeps = $pf->getDeps();
                     } else {
                         $tdeps = $d;
                     }
                     foreach ($tdeps as $dep) {
                         if ($dep['type'] !== 'pkg') {
                             continue;
                         }
                         $deps[] = $dep;
                     }
                 }
             }
             $info = array('stable' => $latest, 'summary' => $info['s'], 'description' => $info['d'], 'deps' => $deps, 'category' => $info['ca']['_content'], 'unstable' => $unstable, 'state' => $state);
             $ret[$package] = $info;
         }
     }
     PEAR::popErrorHandling();
     return $ret;
 }
コード例 #28
0
ファイル: Beanstream.php プロジェクト: alachaum/timetrex
 /**
  * Processes the transaction.
  *
  * Success here doesn't mean the transaction was approved. It means
  * the transaction was sent and processed without technical difficulties.
  *
  * @return mixed Payment_Process_Result on success, PEAR_Error on failure
  * @access public
  */
 function &process()
 {
     // Sanity check
     $result = $this->validate();
     if (PEAR::isError($result)) {
         return $result;
     }
     // Prepare the data
     $result = $this->_prepare();
     if (PEAR::isError($result)) {
         return $result;
     }
     $fields = $this->_prepareQueryString();
     if (PEAR::isError($fields)) {
         return $fields;
     }
     // Don't die partway through
     PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
     $curl = new Net_Curl($this->_options['authorizeUri']);
     if (PEAR::isError($curl)) {
         PEAR::popErrorHandling();
         return $curl;
     }
     $curl->type = 'post';
     $curl->fields = $fields;
     $curl->userAgent = 'PEAR Payment_Process_Beanstream 0.1';
     //$curl->verboseAll();
     $result = $curl->execute();
     if (PEAR::isError($result)) {
         PEAR::popErrorHandling();
         return $result;
     } else {
         $curl->close();
     }
     $this->_responseBody = trim($result);
     $this->_processed = true;
     // Restore error handling
     PEAR::popErrorHandling();
     $response = Payment_Process_Result::factory($this->_driver, $this->_responseBody, $this);
     if (!PEAR::isError($response)) {
         $response->parse();
     }
     $response->action = $this->action;
     return $response;
 }
コード例 #29
0
ファイル: CSV.php プロジェクト: villos/tree_admin
 /**
  * Return or create the file descriptor associated with a file
  *
  * @param string $file The name of the file
  * @param array  &$conf The configuration
  * @param string $mode The open node (ex: FILE_MODE_READ or FILE_MODE_WRITE)
  * @param boolean $reset if passed as true and resource for the file exists
  *                       than the file pointer will be moved to the beginning
  *
  * @return mixed A file resource or false
  */
 function getPointer($file, &$conf, $mode = FILE_MODE_READ, $reset = false)
 {
     static $resources = array();
     static $config;
     if (isset($resources[$file][$mode])) {
         $conf = $config;
         if ($reset) {
             fseek($resources[$file][$mode], 0);
         }
         return $resources[$file][$mode];
     }
     File_CSV::_conf($error, $conf);
     if ($error) {
         return File_CSV::raiseError($error);
     }
     $config = $conf;
     PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
     $fp = File::_getFilePointer($file, $mode);
     PEAR::popErrorHandling();
     if (PEAR::isError($fp)) {
         return File_CSV::raiseError($fp);
     }
     $resources[$file][$mode] = $fp;
     return $fp;
 }
コード例 #30
0
ファイル: Dependency2.php プロジェクト: upmunspel/abiturient
 /**
  * validate a downloaded package against installed packages
  *
  * As of PEAR 1.4.3, this will only validate
  *
  * @param array|PEAR_Downloader_Package|PEAR_PackageFile_v1|PEAR_PackageFile_v2
  *              $pkg package identifier (either
  *                   array('package' => blah, 'channel' => blah) or an array with
  *                   index 'info' referencing an object)
  * @param PEAR_Downloader $dl
  * @param array $params full list of packages to install
  * @return true|PEAR_Error
  */
 function validatePackage($pkg, &$dl, $params = array())
 {
     if (is_array($pkg) && isset($pkg['info'])) {
         $deps = $this->_dependencydb->getDependentPackageDependencies($pkg['info']);
     } else {
         $deps = $this->_dependencydb->getDependentPackageDependencies($pkg);
     }
     $fail = false;
     if ($deps) {
         if (!class_exists('PEAR_Downloader_Package')) {
             require_once 'PEAR/Downloader/Package.php';
         }
         $dp =& new PEAR_Downloader_Package($dl);
         if (is_object($pkg)) {
             $dp->setPackageFile($pkg);
         } else {
             $dp->setDownloadURL($pkg);
         }
         PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
         foreach ($deps as $channel => $info) {
             foreach ($info as $package => $ds) {
                 foreach ($params as $packd) {
                     if (strtolower($packd->getPackage()) == strtolower($package) && $packd->getChannel() == $channel) {
                         $dl->log(3, 'skipping installed package check of "' . $this->_registry->parsedPackageNameToString(array('channel' => $channel, 'package' => $package), true) . '", version "' . $packd->getVersion() . '" will be ' . 'downloaded and installed');
                         continue 2;
                         // jump to next package
                     }
                 }
                 foreach ($ds as $d) {
                     $checker =& new PEAR_Dependency2($this->_config, $this->_options, array('channel' => $channel, 'package' => $package), $this->_state);
                     $dep = $d['dep'];
                     $required = $d['type'] == 'required';
                     $ret = $checker->_validatePackageDownload($dep, $required, array(&$dp));
                     if (is_array($ret)) {
                         $dl->log(0, $ret[0]);
                     } elseif (PEAR::isError($ret)) {
                         $dl->log(0, $ret->getMessage());
                         $fail = true;
                     }
                 }
             }
         }
         PEAR::popErrorHandling();
     }
     if ($fail) {
         return $this->raiseError('%s cannot be installed, conflicts with installed packages');
     }
     return true;
 }