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(); } }
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']); } } } }
/** * @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; }
/** * Read menu file. Parse xml and initializate menu. * * @param menu string Configuration file * @param cacheFile string Name of file where parsed config will be stored for faster loading * @return void */ public function parseFile(RM_Account_iUser $obUser) { PROFILER_IN('Menu'); $cacheFile = $this->_filepath . '.' . L(NULL) . '.cached'; if ($this->_cache_enabled and file_exists($cacheFile) and filemtime($cacheFile) > filemtime($this->_filepath)) { $this->_rootArray = unserialize(file_get_contents($cacheFile)); } else { # # Initializing PEAR config engine... # $old = error_reporting(); error_reporting($old & ~E_STRICT); require_once 'Config.php'; $conf = new Config(); $this->_root = $conf->parseConfig($this->_filepath, 'XML'); if (PEAR::isError($this->_root)) { error_reporting($old); throw new Exception(__METHOD__ . '(): Error while reading menu configuration: ' . $this->_root->getMessage()); } $this->_rootArray = $this->_root->toArray(); if ($this->_cache_enabled) { file_put_contents($cacheFile, serialize($this->_rootArray)); } } $arr = array_shift($this->_rootArray); $arr = $arr['menu']; $this->_menuData['index'] = array(); // index for branches $this->_menuData['default'] = array(); // default selected block of menu $this->_menuData['tree'] = $this->formMenuArray($obUser, $arr['node']); $this->_menuData['branches'] = array(); // tmp array, dont cached PROFILER_OUT('Menu'); }
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; }
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); } } }
/** * @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); }
/** 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; }
/** * The constructor of the generic module * class, ModulePage (Page.Module.class.php) * <br> * Takes global variables like TrEng and GlobalDatabase * and sets the variables that will be used throughout * the class * @access public * @param string $group * @param string $modulecode * @return ModulePage */ function ModulePage($modulecode) { global $GlobalDatabase; global $treng; _filter_var($group); if (isset($GlobalDatabase)) { $this->Database = $GlobalDatabase; } else { include 'configs/globals.php'; $dsn = array('phptype' => $db_type, 'username' => $db_username, 'password' => $db_password, 'hostspec' => $db_host, 'database' => $db_name); $options = array('debug' => 2, 'portability' => DB_PORTABILITY_ALL); $this->Database =& DB::connect($dsn, $options); if (PEAR::isError($this->Database)) { die($this->Database->getMessage()); } $q =& $this->Database->query("SET NAMES utf8;"); if (PEAR::isError($q)) { die($q->getMessage()); } } if (isset($treng)) { $this->TrEng = $treng; } else { $this->TrEng = new TranslationEngine(); } $this->ModuleCode = $modulecode; }
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; } } }
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'); } }
function testAddUser() { if ($this->skip_tests) { $this->fail($this->skip_tests_message . ''); return false; } $cb = count($this->container->listUsers()); $res = $this->container->addUser($this->user, $this->pass, $this->opt); if (AUTH_METHOD_NOT_SUPPORTED === $res) { $this->fail("This operation is not supported by " . get_class($this->container)); return false; } if (PEAR::isError($res)) { $error = $res->getMessage() . ' [' . $res->getUserInfo() . ']'; } else { $error = ''; } $this->assertTrue(!PEAR::isError($res), 'error:' . $error); $ca = count($this->container->listUsers()); $users = $this->container->listUsers(); $last_username = $users[$ca - 1]['username']; $this->assertTrue($cb === $ca - 1, sprintf('Count of users before (%s) and after (%s) does not differ by one', $cb, $ca)); $this->assertTrue($this->container->fetchData($this->user, $this->pass), sprintf('Could not verify with the newly created user %s', $this->user)); // Remove the user we just added, assumes removeUser works $this->container->removeUser($this->user); }
function _logActualConstructive() { $aExistingTables = $this->oDBUpgrade->_listTables(); $prefix = $this->oDBUpgrade->prefix; if (in_array($prefix . 'astro', $aExistingTables)) { $msg = $this->_testName('A'); $aDef = $this->oDBUpgrade->_getDefinitionFromDatabase('astro'); if (isset($aDef['tables']['astro']['fields']['id_changed_field'])) { $this->_log($msg . ' added (as part of rename) field to table ' . $prefix . 'astro defined as: [id_changed_field]'); $this->_log(print_r($aDef['tables']['astro']['fields']['id_changed_field'], true)); } else { $this->_log($msg . 'failed to add (as part of rename) field to table ' . $prefix . 'astro defined as: [id_changed_field]'); } $msg = $this->_testName('B'); if (isset($aDef['tables']['astro']['fields']['text_field'])) { $this->_log($msg . ' add field to table ' . $prefix . 'astro defined as: [text_field]'); $this->_log(print_r($aDef['tables']['astro']['fields']['text_field'], true)); } else { $this->_log($msg . ' failed to add field to table ' . $prefix . 'astro defined as: [text_field]'); } $msg = $this->_testName('C'); $query = 'SELECT * FROM ' . $prefix . 'astro'; $result = $this->oDbh->queryAll($query); if (PEAR::isError($result)) { $this->_log($msg . 'failed to migrate data 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_changed_field , desc_field, text_field'); foreach ($result as $k => $v) { $this->_log('row ' . $k . ' = ' . $v['id_changed_field'] . ' , ' . $v['desc_field'] . ' , ' . $v['text_field']); } } } }
function check_db_result(&$res) { if (PEAR::isError($res)) { trigger_error("Database Error: " . print_r($res->userinfo, 1), E_USER_ERROR); exit; } }
/** * Process incoming parameters and display the page. * * @return void * @access public */ public function launch() { global $interface; global $configArray; if (isset($_POST['submit'])) { $result = $this->sendEmail($_POST['to'], $_POST['from'], $_POST['message']); if (!PEAR::isError($result)) { include_once 'Home.php'; Home::launch(); exit; } else { $interface->assign('errorMsg', $result->getMessage()); } } // Display Page $interface->assign('formTargetPath', '/MetaLib/' . urlencode($_GET['id']) . '/Email'); $interface->assign('recordId', urlencode($_GET['id'])); if (isset($_GET['lightbox'])) { $interface->assign('title', $_GET['message']); return $interface->fetch('MetaLib/email.tpl'); } else { $interface->setPageTitle('Email Record'); $interface->assign('subTemplate', 'email.tpl'); $interface->setTemplate('view-alt.tpl'); $interface->display('layout.tpl', 'RecordEmail' . $_GET['id']); } }
function extractText($sourceFile, $extension, $mimeType) { static $extractors = array(); // get extractor $query = "select me.id, me.name from mime_types mt\n INNER JOIN mime_extractors me ON mt.extractor_id = me.id\n WHERE filetypes = '{$extension}'"; $res = DBUtil::getOneResult($query); // On first run the mime_extractors table is empty - populate it for the tests if (empty($res) || PEAR::isError($res)) { $this->indexer->registerTypes(true); $query = "select me.id, me.name from mime_types mt\n INNER JOIN mime_extractors me ON mt.extractor_id = me.id\n WHERE filetypes = '{$extension}'"; $res = DBUtil::getOneResult($query); } // Instantiate extractor if (array_key_exists($res['name'], $extractors)) { $extractor = $extractors[$res['name']]; } else { $extractor = $this->indexer->getExtractor($res['name']); $extractors[$res['name']] = $extractor; } $this->assertNotNull($extractor); if (empty($extractor)) { return ''; } // Extract content $targetFile = tempnam($this->tempPath, 'ktindexer'); $extractor->setSourceFile($this->path . $sourceFile); $extractor->setTargetFile($targetFile); $extractor->setMimeType($mimeType); $extractor->setExtension($extension); $extractor->extractTextContent(); $text = file_get_contents($targetFile); $text = $this->filterText($text); @unlink($targetFile); return $text; }
function fill_category_tree(&$categories, $ccid, $level) { global $db; $qs = "SELECT category_id, category_name FROM phph_categories "; if (!empty($ccid)) { $qs .= "WHERE category_parent = {$ccid} "; } else { $qs .= "WHERE category_parent IS NULL "; } $qs .= "ORDER BY category_order"; $q = $db->prepare($qs); $res = $db->execute($q); if (PEAR::isError($res)) { die($res->getMessage()); } while ($res->fetchInto($row)) { $name = ""; if ($level > 0) { for ($i = 0; $i < $level; $i++) { $name .= "---"; } $name .= " "; } $name .= $row['category_name']; $categories[$row['category_id']] = $name; fill_category_tree(&$categories, $row['category_id'], $level + 1); } }
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'))); } }
/** * 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(); }
private function get($folderId) { $object = $this->ktapi->get_folder_by_id((int) $folderId); // error? if (PEAR::isError($object)) { // throw an exception? return $object; } // static $allowedChildObjectTypeIds; $objectProperties = $object->get_detail(); $this->_setPropertyInternal('ObjectId', CMISUtil::encodeObjectId($this->typeId, $objectProperties['id'])); // prevent doubled '/' chars $uri = preg_replace_callback('/([^:]\\/)\\//', create_function('$matches', 'return $matches[1];'), $this->uri . '/browse.php?fFolderId=' . $objectProperties['id']); // TODO this url is probably incorrect...needs to be checked // $this->_setPropertyInternal('Uri', $uri); $this->_setPropertyInternal('Uri', ''); // TODO what is this? Assuming it is the object type id, and not OUR document type? $this->_setPropertyInternal('ObjectTypeId', $this->getAttribute('typeId')); // Needed to distinguish type $this->_setPropertyInternal('BaseType', strtolower($this->getAttribute('typeId'))); $this->_setPropertyInternal('CreatedBy', $objectProperties['created_by']); // TODO cannot currently retrieve via ktapi or regular folder code - add as with created by $this->_setPropertyInternal('CreationDate', $objectProperties['created_date']); // TODO cannot currently retrieve via ktapi or regular folder code - add as with created by $this->_setPropertyInternal('LastModifiedBy', $objectProperties['modified_by']); // TODO cannot currently retrieve via ktapi or regular folder code - add as with created by $this->_setPropertyInternal('LastModificationDate', $objectProperties['modified_date']); $this->_setPropertyInternal('ChangeToken', null); $this->_setPropertyInternal('Name', $objectProperties['folder_name']); $this->_setPropertyInternal('ParentId', $objectProperties['parent_id']); $this->_setPropertyInternal('AllowedChildObjectTypeIds', array('Document', 'Folder')); $this->_setPropertyInternal('Author', $objectProperties['created_by']); }
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())); } }
/** * 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()); } }
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); }
/** * 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; }
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); }
public function test_authentication_with_missing_username() { unset($_SERVER['persistent-id']); $_SERVER['entitlement'] = 'urn:mace:dir:entitlement:common-lib-terms'; $_SERVER['unscoped-affiliation'] = 'member'; $this->assertTrue(PEAR::isError($this->authN->authenticate())); }
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())); } }
function onAuthenticate($credentials, $options = null) { $ftp_login = $credentials['username']; $ftp_pass = $credentials['password']; if ($ftp_login != '' || $ftp_pass != '') { $ftp_host = empty($_SESSION['ftp_host']) ? extGetParam($_POST, 'ftp_host', 'localhost:21') : $_SESSION['ftp_host']; $url = @parse_url('ftp://' . $ftp_host); if (empty($url)) { ext_Result::sendResult('ftp_authentication', false, 'Unable to parse the specified Host Name. Please use a hostname in this format: hostname:21'); } $port = empty($url['port']) ? 21 : $url['port']; $GLOBALS['FTPCONNECTION'] = new Net_FTP($url['host'], $port, 20); $res = $GLOBALS['FTPCONNECTION']->connect(); if (PEAR::isError($res)) { ext_Result::sendResult('ftp_authentication', false, ext_Lang::msg('ftp_connection_failed') . ' (' . $url['host'] . ')'); } else { $res = $GLOBALS['FTPCONNECTION']->login($ftp_login, $ftp_pass); if (PEAR::isError($res)) { ext_Result::sendResult('ftp_authentication', false, ext_Lang::msg('ftp_login_failed')); } $_SESSION['credentials_ftp']['username'] = $ftp_login; $_SESSION['credentials_ftp']['password'] = $ftp_pass; $_SESSION['ftp_host'] = $ftp_host; $_SESSION['file_mode'] = 'ftp'; $_SESSION['ftp_login'] = $ftp_login; return true; } } return false; }
/** * Draws a image barcode * * @param string $text A text that should be in the image barcode * @param string $type The barcode type. Supported types: * code39 - Code 3 of 9 * int25 - 2 Interleaved 5 * ean13 - EAN 13 * upca - UPC-A * @param string $imgtype The image type that will be generated * @param boolean $bSendToBrowser if the image shall be outputted to the * browser, or be returned. * * @return image The corresponding gd image object; * PEAR_Error on failure * * @access public * * @author Marcelo Subtil Marcal <*****@*****.**> * @since Image_Barcode 0.3 */ function &draw($text, $dest_file, $type = 'int25', $imgtype = 'png', $height = 60) { //Make sure no bad files are included if (!preg_match('/^[a-zA-Z0-9_-]+$/', $type)) { return PEAR::raiseError('Invalid barcode type ' . $type); } if (!(include_once __CA_LIB_DIR__ . '/core/Print/Barcode/' . $type . '.php')) { return PEAR::raiseError($type . ' barcode is not supported'); } $classname = 'Barcode_' . $type; if (!in_array('draw', get_class_methods($classname))) { $classname = 'code39'; } @($obj = new $classname()); $obj->_barcodeheight = $height; $img =& $obj->draw($text, $imgtype); if (PEAR::isError($img)) { return null; } switch ($imgtype) { case 'gif': imagegif($img, $dest_file); break; case 'jpg': imagejpeg($img, $dest_file); break; default: imagepng($img, $dest_file); break; } $va_dimensions = array('width' => imagesx($img), 'height' => imagesy($img), 0 => imagesx($img), 1 => imagesy($img)); imagedestroy($img); return $va_dimensions; }
public function execute() { PHPWS_Core::initModClass('hms', 'StudentFactory.php'); if (!isset($this->term) || is_null($this->term)) { throw new InvalidArgumentException('Missing term.'); } $db = new PHPWS_DB('hms_new_application'); $db->addColumn('banner_id'); $db->addColumn('username'); $db->addWhere('term', $this->term); $results = $db->select(); if (empty($results)) { return; } elseif (PEAR::isError($results)) { throw new DatabaseException($results->toString()); } $twentyFiveYearsAgo = strtotime("-25 years"); foreach ($results as $student) { try { $sf = StudentFactory::getStudentByBannerId($student['banner_id'], $this->term); $dob = $sf->getDOB(); if (strtotime($dob) > $twentyFiveYearsAgo) { continue; } $student['dob'] = $dob; $student['full_name'] = $sf->getFullName(); $this->all_rows[] = $student; } catch (Exception $e) { $student['dob'] = $student['full_name'] = null; $this->problems[] = $student['banner_id']; } } }