当前位置: 首页>>代码示例>>PHP>>正文


PHP DevblocksPlatform::getDatabaseService方法代码示例

本文整理汇总了PHP中DevblocksPlatform::getDatabaseService方法的典型用法代码示例。如果您正苦于以下问题:PHP DevblocksPlatform::getDatabaseService方法的具体用法?PHP DevblocksPlatform::getDatabaseService怎么用?PHP DevblocksPlatform::getDatabaseService使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DevblocksPlatform的用法示例。


在下文中一共展示了DevblocksPlatform::getDatabaseService方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: isDatabaseEmpty

 public static function isDatabaseEmpty()
 {
     $db = DevblocksPlatform::getDatabaseService();
     if (is_null($db)) {
         return true;
     }
     $tables = $db->MetaTables('TABLE', true);
     return empty($tables);
 }
开发者ID:sluther,项目名称:portsensor,代码行数:9,代码来源:classes.php

示例2: handleRequest

 function handleRequest(DevblocksHttpRequest $request)
 {
     $stack = $request->path;
     $db = DevblocksPlatform::getDatabaseService();
     // **** BEGIN AUTH
     @($verb = $_SERVER['REQUEST_METHOD']);
     @($header_date = $_SERVER['HTTP_DATE']);
     @($header_signature = $_SERVER['HTTP_PORTSENSOR_AUTH']);
     @($this->_payload = $this->_getRawPost());
     @(list($auth_worker_email, $auth_signature) = explode(":", $header_signature, 2));
     $url_parts = parse_url(DevblocksPlatform::getWebPath());
     $url_path = $url_parts['path'];
     $url_query = $this->_sortQueryString($_SERVER['QUERY_STRING']);
     $string_to_sign_prefix = "{$verb}\n{$header_date}\n{$url_path}\n{$url_query}\n{$this->_payload}";
     if (!$this->_validateRfcDate($header_date)) {
         $this->_error("Access denied! (Invalid timestamp)");
     }
     //		if(strpos($auth_access_key,'@')) { // WORKER-LEVEL AUTH
     $results = DAO_Worker::getWhere(sprintf("%s = %s", DAO_Worker::EMAIL, $db->qstr($auth_worker_email)));
     if (empty($results)) {
         $this->_error("Access denied! (Invalid authentication)");
     } else {
         $worker = array_shift($results);
         $this->setActiveWorker($worker);
     }
     if (null == $this->getActiveWorker()) {
         $this->_error("Access denied! (Invalid worker)");
     }
     if (!$worker->hasPriv('plugin.usermeet.webapi')) {
         $this->_error("Access denied! (No permission)");
     }
     $pass = $this->getActiveWorker()->pass;
     $string_to_sign = "{$string_to_sign_prefix}\n{$pass}\n";
     $compare_hash = base64_encode(sha1($string_to_sign, true));
     if (0 != strcmp($auth_signature, $compare_hash)) {
         $this->_error("Access denied! (Invalid password)");
     }
     // **** END APP AUTH
     // Figure out our format by looking at the last path argument
     @(list($command, $format) = explode('.', array_pop($stack)));
     array_push($stack, $command);
     $this->_format = $format;
     // Call the verb as an action
     $method = strtolower($verb) . 'Action';
     if (method_exists($this, $method)) {
         call_user_func(array(&$this, $method), $stack);
     } else {
         $this->_error("Invalid action.");
     }
 }
开发者ID:rmiddle,项目名称:usermeet,代码行数:50,代码来源:App.php

示例3: getValue

 static function getValue($context, $context_values)
 {
     $total_time_all = -1;
     if ($context_values['id']) {
         // Adds total time worked per ticket to the token list.
         $db = DevblocksPlatform::getDatabaseService();
         $sql = "SELECT sum(tte.time_actual_mins) mins ";
         $sql .= "FROM timetracking_entry tte ";
         $sql .= sprintf("WHERE tte.source_id =  %d ", $context_values['id']);
         $sql .= "AND tte.source_extension_id = 'timetracking.source.ticket' ";
         $sql .= "GROUP BY tte.source_id ";
         $rs = $db->Execute($sql) or die(__CLASS__ . '(' . __LINE__ . ')' . ':' . $db->ErrorMsg());
         if ($row = mysql_fetch_assoc($rs)) {
             $total_time_all = intval($row['mins']);
         } else {
             $total_time_all = 0;
         }
         mysql_free_result($rs);
     }
     return $total_time_all;
 }
开发者ID:rmiddle,项目名称:cerb5_plugins,代码行数:21,代码来源:App.php

示例4: handleEvent

 /**
  * @param Model_DevblocksEvent $event
  */
 function handleEvent(Model_DevblocksEvent $event)
 {
     switch ($event->id) {
         case 'cron.maint':
             $records_removed = 0;
             $logger = DevblocksPlatform::getConsoleLog();
             $logger->info("[Answernet.com Maint] Starting Purging Contact Addresses task");
             @set_time_limit(0);
             // Unlimited (if possible)
             @ini_set('memory_limit', '128M');
             $logger->info("[Answernet.com Maint] Overloaded memory_limit to: " . ini_get('memory_limit'));
             $logger->info("[Answernet.com Maint] Overloaded max_execution_time to: " . ini_get('max_execution_time'));
             $runtime = microtime(true);
             //Do something
             $db = DevblocksPlatform::getDatabaseService();
             $sql = "SELECT a.id ";
             $sql .= "FROM address a ";
             $sql .= "LEFT JOIN message m ON a.id = m.address_id ";
             $sql .= "LEFT JOIN requester r ON a.id = r.address_id ";
             $sql .= "LEFT JOIN ticket_comment tc ON a.id = tc.address_id ";
             $sql .= "WHERE a.contact_org_id = 0 ";
             $sql .= "AND m.address_id IS NULL ";
             $sql .= "AND r.address_id IS NULL ";
             $sql .= "AND tc.address_id IS NULL ";
             $sql .= "ORDER BY a.id ASC ";
             $rs = $db->Execute($sql);
             while (!$rs->EOF) {
                 // Loop though the records.
                 DAO_Address::delete($rs->fields['id']);
                 // Increament the records removed connecter
                 $records_removed++;
                 $rs->MoveNext();
             }
             $logger->info("[Answernet.com Maint] Total Records Removed: " . $records_removed);
             $logger->info("[Answernet.com Maint] Total Runtime: " . (microtime(true) - $runtime) * 1000 . " ms");
             break;
     }
 }
开发者ID:rmiddle,项目名称:cerb4_plugins,代码行数:41,代码来源:App.php

示例5: _getParams

 /**
  * Loads parameters unique to this extension instance.  Returns an 
  * associative array indexed by parameter key.
  *
  * @private
  * @return array
  */
 private function _getParams()
 {
     //		static $params = null;
     if (empty($this->id)) {
         return null;
     }
     //		if(null != $params)
     //			return $params;
     $params = $this->manifest->params;
     $db = DevblocksPlatform::getDatabaseService();
     $prefix = APP_DB_PREFIX != '' ? APP_DB_PREFIX . '_' : '';
     // [TODO] Cleanup
     $sql = sprintf("SELECT property,value " . "FROM %sproperty_store " . "WHERE extension_id=%s ", $prefix, $db->qstr($this->id));
     $rs = $db->Execute($sql) or die(__CLASS__ . ':' . $db->ErrorMsg());
     /* @var $rs ADORecordSet */
     if (is_a($rs, 'ADORecordSet')) {
         while (!$rs->EOF) {
             $params[$rs->fields['property']] = $rs->fields['value'];
             $rs->MoveNext();
         }
     }
     return $params;
 }
开发者ID:Hildy,项目名称:devblocks,代码行数:30,代码来源:Extension.php

示例6: run

 function run()
 {
     $logger = DevblocksPlatform::getConsoleLog();
     $logger->info("[Maint] Starting Maintenance Task");
     @ini_set('memory_limit', '64M');
     $db = DevblocksPlatform::getDatabaseService();
     // Give plugins a chance to run maintenance (nuke NULL rows, etc.)
     $eventMgr = DevblocksPlatform::getEventService();
     $eventMgr->trigger(new Model_DevblocksEvent('cron.maint', array()));
     //		// [JAS] Remove any empty directories inside storage/import/new
     //		$importNewDir = APP_STORAGE_PATH . '/import/new' . DIRECTORY_SEPARATOR;
     //		$subdirs = glob($importNewDir . '*', GLOB_ONLYDIR);
     //		if ($subdirs !== false) {
     //			foreach($subdirs as $subdir) {
     //				$directory_empty = count(glob($subdir. DIRECTORY_SEPARATOR . '*')) === 0;
     //				if($directory_empty && is_writeable($subdir)) {
     //					rmdir($subdir);
     //				}
     //			}
     //		}
     //
     //		$logger->info('[Maint] Cleaned up import directories.');
 }
开发者ID:rmiddle,项目名称:usermeet,代码行数:23,代码来源:cron.classes.php

示例7: setCustomerAccountNumberAction

 function setCustomerAccountNumberAction()
 {
     $db = DevblocksPlatform::getDatabaseService();
     @($account_number = DevblocksPlatform::importGPC($_REQUEST['acc_num'], 'string', ''));
     @($m_id = DevblocksPlatform::importGPC($_REQUEST['m_id'], 'string', ''));
     // Now Confirm the account exists and is active
     $account = array_shift(DAO_CustomerAccount::getWhere(sprintf("%s = %d AND %s = '0' ", DAO_CustomerAccount::ACCOUNT_NUMBER, $account_number, DAO_CustomerAccount::IS_DISABLED)));
     if (!isset($account)) {
         return;
     }
     $message_obj = DAO_Message::get($m_id);
     if (!isset($message_obj)) {
         return;
     }
     $fields = get_object_vars($message_obj);
     $fields[DAO_Message::ACCOUNT_ID] = $account->id;
     $fields[DAO_Message::IMPORT_STATUS] = 0;
     // Requeue
     $m_status = DAO_Message::update($m_id, $fields);
     // Give plugins a chance to note a message is assigned
     $eventMgr = DevblocksPlatform::getEventService();
     $eventMgr->trigger(new Model_DevblocksEvent('message.account.assign', array('account_id' => $account->id, 'message_id' => $m_id)));
     echo json_encode($fields);
 }
开发者ID:rmiddle,项目名称:feg,代码行数:24,代码来源:customer_accounts.php

示例8: getTemplatesAction

 function getTemplatesAction()
 {
     @($txt_name = DevblocksPlatform::importGPC($_REQUEST['txt_name'], 'string', ''));
     @($reply_id = DevblocksPlatform::importGPC($_REQUEST['reply_id'], 'integer'));
     @($folder = DevblocksPlatform::importGPC($_REQUEST['folder'], 'string', ''));
     @($type = DevblocksPlatform::importGPC($_REQUEST['type'], 'integer', 0));
     $db = DevblocksPlatform::getDatabaseService();
     $tpl = DevblocksPlatform::getTemplateService();
     $tpl->assign('path', $this->_TPL_PATH);
     $tpl->assign('reply_id', $reply_id);
     $tpl->assign('txt_name', $txt_name);
     if (empty($folder)) {
         $where = sprintf("%s = %d", DAO_MailTemplate::TEMPLATE_TYPE, $type);
     } else {
         $where = sprintf("%s = %s AND %s = %d ", DAO_MailTemplate::FOLDER, $db->qstr($folder), DAO_MailTemplate::TEMPLATE_TYPE, $type);
     }
     $templates = DAO_MailTemplate::getWhere($where);
     $tpl->assign('templates', $templates);
     $tpl->display('file:' . $this->_TPL_PATH . 'display/rpc/email_templates/template_results.tpl');
 }
开发者ID:jsjohnst,项目名称:cerb4,代码行数:20,代码来源:display.php

示例9: getPluginRegistry

 /**
  * Returns an array of all contributed plugin manifests.
  *
  * @static
  * @return DevblocksPluginManifest[]
  */
 static function getPluginRegistry()
 {
     $cache = self::getCacheService();
     if (false !== ($plugins = $cache->load(self::CACHE_PLUGINS))) {
         return $plugins;
     }
     $db = DevblocksPlatform::getDatabaseService();
     if (is_null($db)) {
         return;
     }
     $prefix = APP_DB_PREFIX != '' ? APP_DB_PREFIX . '_' : '';
     // [TODO] Cleanup
     $sql = sprintf("SELECT * " . "FROM %splugin p " . "ORDER BY p.enabled DESC, p.name ASC ", $prefix);
     $rs = $db->Execute($sql) or die(__CLASS__ . ':' . $db->ErrorMsg());
     /* @var $rs ADORecordSet */
     while (!$rs->EOF) {
         $plugin = new DevblocksPluginManifest();
         @($plugin->id = $rs->fields['id']);
         @($plugin->enabled = intval($rs->fields['enabled']));
         @($plugin->name = $rs->fields['name']);
         @($plugin->description = $rs->fields['description']);
         @($plugin->author = $rs->fields['author']);
         @($plugin->revision = intval($rs->fields['revision']));
         @($plugin->link = $rs->fields['link']);
         @($plugin->is_configurable = intval($rs->fields['is_configurable']));
         @($plugin->file = $rs->fields['file']);
         @($plugin->class = $rs->fields['class']);
         @($plugin->dir = $rs->fields['dir']);
         if (file_exists(DEVBLOCKS_PLUGIN_PATH . $plugin->dir)) {
             $plugins[$plugin->id] = $plugin;
         }
         $rs->MoveNext();
     }
     $sql = sprintf("SELECT p.id, p.name, p.params, p.plugin_id " . "FROM %sevent_point p ", $prefix);
     $rs = $db->Execute($sql) or die(__CLASS__ . ':' . $db->ErrorMsg() . var_dump(debug_backtrace()));
     /* @var $rs ADORecordSet */
     while (!$rs->EOF) {
         $point = new DevblocksEventPoint();
         $point->id = $rs->fields['id'];
         $point->name = $rs->fields['name'];
         $point->plugin_id = $rs->fields['plugin_id'];
         $params = $rs->fields['params'];
         $point->params = !empty($params) ? unserialize($params) : array();
         if (isset($plugins[$point->plugin_id])) {
             $plugins[$point->plugin_id]->event_points[$point->id] = $point;
         }
         $rs->MoveNext();
     }
     //			$extensions = DevblocksPlatform::getExtensionRegistry();
     //			foreach($extensions as $extension_id => $extension) { /* @var $extension DevblocksExtensionManifest */
     //			    $plugin_id = $extension->plugin_id;
     //			    if(isset($plugin_id)) {
     //			        $plugins[$plugin_id]->extensions[$extension_id] = $extension;
     //			    }
     //			}
     $cache->save($plugins, self::CACHE_PLUGINS);
     return $plugins;
 }
开发者ID:sluther,项目名称:portsensor,代码行数:64,代码来源:Devblocks.class.php

示例10: die

 * A legitimate license entitles you to support, access to the developer 
 * mailing list, the ability to participate in betas and the warm fuzzy 
 * feeling of feeding a couple obsessed developers who want to help you get 
 * more done than 'the other guy'.
 *
 * - Jeff Standen, Mike Fogg, Brenan Cavish, Darren Sugita, Dan Hildebrandt
 * 		and Joe Geck.
 *   WEBGROUP MEDIA LLC. - Developers of Cerberus Helpdesk
 */
if (version_compare(PHP_VERSION, "5.2", "<")) {
    die("Cerberus Helpdesk 5.x requires PHP 5.2 or later.");
}
require getcwd() . '/framework.config.php';
require DEVBLOCKS_PATH . 'Devblocks.class.php';
// If this is our first run, redirect to the installer
if ('' == APP_DB_DRIVER || '' == APP_DB_HOST || '' == APP_DB_DATABASE || null == ($db = DevblocksPlatform::getDatabaseService()) || DevblocksPlatform::isDatabaseEmpty()) {
    header('Location: ' . dirname($_SERVER['PHP_SELF']) . '/install/index.php');
    // [TODO] change this to a meta redirect
    exit;
}
require APP_PATH . '/api/Application.class.php';
DevblocksPlatform::init();
DevblocksPlatform::setExtensionDelegate('C4_DevblocksExtensionDelegate');
// Request
$request = DevblocksPlatform::readRequest();
// Patches (if not on the patch page)
if (@0 != strcasecmp(@$request->path[0], "update") && !DevblocksPlatform::versionConsistencyCheck()) {
    DevblocksPlatform::redirect(new DevblocksHttpResponse(array('update', 'locked')));
}
//DevblocksPlatform::readPlugins();
$session = DevblocksPlatform::getSessionService();
开发者ID:Hildy,项目名称:cerb5,代码行数:31,代码来源:index.php

示例11: get_timestamp

 static function get_timestamp($tpl_name, &$tpl_timestamp, $smarty_obj)
 {
     /* @var $smarty_obj Smarty */
     list($plugin_id, $tag, $tpl_path) = explode(':', $tpl_name, 3);
     if (empty($plugin_id) || empty($tpl_path)) {
         return false;
     }
     $plugins = DevblocksPlatform::getPluginRegistry();
     $db = DevblocksPlatform::getDatabaseService();
     if (null == ($plugin = @$plugins[$plugin_id])) {
         /* @var $plugin DevblocksPluginManifest */
         return false;
     }
     // Check if template is overloaded in DB/cache
     $matches = DAO_DevblocksTemplate::getWhere(sprintf("plugin_id = %s AND path = %s %s", $db->qstr($plugin_id), $db->qstr($tpl_path), !empty($tag) ? sprintf("AND tag = %s ", $db->qstr($tag)) : ""));
     if (!empty($matches)) {
         $match = array_shift($matches);
         /* @var $match Model_DevblocksTemplate */
         //			echo time(),"==(DB)",$match->last_updated,"<BR>";
         $tpl_timestamp = $match->last_updated;
         return true;
     }
     // If not in DB, check plugin's relative path on disk
     $path = APP_PATH . '/' . $plugin->dir . '/templates/' . $tpl_path;
     if (!file_exists($path)) {
         return false;
     }
     $stat = stat($path);
     $tpl_timestamp = $stat['mtime'];
     //		echo time(),"==(DISK)",$stat['mtime'],"<BR>";
     return true;
 }
开发者ID:jstanden,项目名称:devblocks,代码行数:32,代码来源:Devblocks.class.php

示例12: search

 /**
  * Enter description here...
  *
  * @param DevblocksSearchCriteria[] $params
  * @param integer $limit
  * @param integer $page
  * @param string $sortBy
  * @param boolean $sortAsc
  * @param boolean $withCounts
  * @return array
  */
 static function search($params, $limit = 10, $page = 0, $sortBy = null, $sortAsc = null, $withCounts = true)
 {
     $db = DevblocksPlatform::getDatabaseService();
     $fields = SearchFields_TicketAuditLog::getFields();
     // Sanitize
     if (!isset($fields[$sortBy])) {
         $sortBy = null;
     }
     list($tables, $wheres) = parent::_parseSearchParams($params, array(), $fields, $sortBy);
     $start = $page * $limit;
     // [JAS]: 1-based [TODO] clean up + document
     $total = -1;
     $sql = sprintf("SELECT " . "l.id as %s, " . "l.ticket_id as %s, " . "l.worker_id as %s, " . "l.change_date as %s, " . "l.change_field as %s, " . "l.change_value as %s " . "FROM ticket_audit_log l ", SearchFields_TicketAuditLog::ID, SearchFields_TicketAuditLog::TICKET_ID, SearchFields_TicketAuditLog::WORKER_ID, SearchFields_TicketAuditLog::CHANGE_DATE, SearchFields_TicketAuditLog::CHANGE_FIELD, SearchFields_TicketAuditLog::CHANGE_VALUE) . (!empty($wheres) ? sprintf("WHERE %s ", implode(' AND ', $wheres)) : "") . (!empty($sortBy) ? sprintf("ORDER BY %s %s", $sortBy, $sortAsc || is_null($sortAsc) ? "ASC" : "DESC") : "");
     // [TODO] Could push the select logic down a level too
     if ($limit > 0) {
         $rs = $db->SelectLimit($sql, $limit, $start) or die(__CLASS__ . '(' . __LINE__ . ')' . ':' . $db->ErrorMsg());
         /* @var $rs ADORecordSet */
     } else {
         $rs = $db->Execute($sql) or die(__CLASS__ . '(' . __LINE__ . ')' . ':' . $db->ErrorMsg());
         /* @var $rs ADORecordSet */
         $total = $rs->RecordCount();
     }
     $results = array();
     if (is_a($rs, 'ADORecordSet')) {
         while (!$rs->EOF) {
             $result = array();
             foreach ($rs->fields as $f => $v) {
                 $result[$f] = $v;
             }
             $id = intval($rs->fields[SearchFields_TicketAuditLog::ID]);
             $results[$id] = $result;
             $rs->MoveNext();
         }
     }
     // [JAS]: Count all
     if ($withCounts) {
         $rs = $db->Execute($sql);
         $total = $rs->RecordCount();
     }
     return array($results, $total);
 }
开发者ID:jsjohnst,项目名称:cerb4,代码行数:52,代码来源:App.php

示例13: handleRequest

 function handleRequest(DevblocksHttpRequest $request)
 {
     $stack = $request->path;
     $db = DevblocksPlatform::getDatabaseService();
     // **** BEGIN AUTH
     @($verb = $_SERVER['REQUEST_METHOD']);
     @($header_date = $_SERVER['HTTP_DATE']);
     @($header_signature = $_SERVER['HTTP_CERB4_AUTH']);
     @($this->_payload = $this->_getRawPost());
     @(list($auth_access_key, $auth_signature) = explode(":", $header_signature, 2));
     $url_parts = parse_url(DevblocksPlatform::getWebPath());
     $url_path = $url_parts['path'];
     $url_query = $this->_sortQueryString($_SERVER['QUERY_STRING']);
     $string_to_sign_prefix = "{$verb}\n{$header_date}\n{$url_path}\n{$url_query}\n{$this->_payload}";
     if (!$this->_validateRfcDate($header_date)) {
         $this->_error("Access denied! (Invalid timestamp)");
     }
     if (strpos($auth_access_key, '@')) {
         // WORKER-LEVEL AUTH
         $workers = DAO_Worker::getAll();
         foreach ($workers as $worker) {
             /* @var $worker CerberusWorker */
             if ($worker->email == $auth_access_key) {
                 $this->setActiveWorker($worker);
                 break;
             }
         }
         if (null == $this->getActiveWorker()) {
             $this->_error("Access denied! (Invalid worker)");
         }
         $pass = $this->getActiveWorker()->pass;
         $string_to_sign = "{$string_to_sign_prefix}\n{$pass}\n";
         $compare_hash = base64_encode(sha1($string_to_sign, true));
         if (0 != strcmp($auth_signature, $compare_hash)) {
             $this->_error("Access denied! (Invalid password)");
         }
     } else {
         // APP-LEVEL AUTH
         $stored_keychains = DAO_WebapiKey::getWhere(sprintf("%s = %s", DAO_WebapiKey::ACCESS_KEY, $db->qstr(str_replace(' ', '', $auth_access_key))));
         /* @var $stored_keychain Model_WebApiKey */
         if (!empty($stored_keychains)) {
             @($stored_keychain = array_shift($stored_keychains));
             @($auth_secret_key = $stored_keychain->secret_key);
             @($auth_rights = $stored_keychain->rights);
             $string_to_sign = "{$string_to_sign_prefix}\n{$auth_secret_key}\n";
             $compare_hash = base64_encode(sha1($string_to_sign, true));
             if (0 != strcmp($auth_signature, $compare_hash)) {
                 $this->_error("Access denied! (Invalid signature)");
             }
             // Check that this IP is allowed to perform the VERB
             if (!$stored_keychain->isValidIp($_SERVER['REMOTE_ADDR'])) {
                 $this->_error(sprintf("Access denied! (IP %s not authorized)", $_SERVER['REMOTE_ADDR']));
             }
         } else {
             $this->_error("Access denied! (Unknown access key)");
         }
     }
     // **** END APP AUTH
     // Figure out our format by looking at the last path argument
     @(list($command, $format) = explode('.', array_pop($stack)));
     array_push($stack, $command);
     $this->_format = $format;
     if (null != $this->getActiveWorker()) {
         $method = strtolower($verb) . 'WorkerAction';
         if (method_exists($this, $method)) {
             call_user_func(array(&$this, $method), $stack);
         }
     } else {
         $method = strtolower($verb) . 'Action';
         if (method_exists($this, $method)) {
             call_user_func(array(&$this, $method), $stack, $stored_keychain);
         }
     }
 }
开发者ID:rmiddle,项目名称:cerb4,代码行数:74,代码来源:App.php

示例14: run

 function run()
 {
     $logger = DevblocksPlatform::getConsoleLog();
     $logger->info("[Maint] Starting Maintenance Task");
     @ini_set('memory_limit', '64M');
     $db = DevblocksPlatform::getDatabaseService();
     // Purge Deleted Content
     $purge_waitdays = intval($this->getParam('purge_waitdays', 7));
     $purge_waitsecs = time() - intval($purge_waitdays) * 86400;
     $sql = sprintf("DELETE QUICK FROM ticket " . "WHERE is_deleted = 1 " . "AND updated_date < %d ", $purge_waitsecs);
     $db->Execute($sql);
     $logger->info("[Maint] Purged " . $db->Affected_Rows() . " ticket records.");
     // Give plugins a chance to run maintenance (nuke NULL rows, etc.)
     $eventMgr = DevblocksPlatform::getEventService();
     $eventMgr->trigger(new Model_DevblocksEvent('cron.maint', array()));
     // Nuke orphaned words from the Bayes index
     // [TODO] Make this configurable from job
     $sql = "DELETE FROM bayes_words WHERE nonspam + spam < 2";
     // only 1 occurrence
     $db->Execute($sql);
     $logger->info('[Maint] Purged ' . $db->Affected_Rows() . ' obscure spam words.');
     // [mdf] Remove any empty directories inside storage/mail/new
     $mailDir = APP_MAIL_PATH . 'new' . DIRECTORY_SEPARATOR;
     $subdirs = glob($mailDir . '*', GLOB_ONLYDIR);
     if ($subdirs !== false) {
         foreach ($subdirs as $subdir) {
             $directory_empty = count(glob($subdir . DIRECTORY_SEPARATOR . '*')) === 0;
             if ($directory_empty && is_writeable($subdir)) {
                 rmdir($subdir);
             }
         }
     }
     $logger->info('[Maint] Cleaned up mail directories.');
     // [JAS] Remove any empty directories inside storage/import/new
     $importNewDir = APP_STORAGE_PATH . '/import/new' . DIRECTORY_SEPARATOR;
     $subdirs = glob($importNewDir . '*', GLOB_ONLYDIR);
     if ($subdirs !== false) {
         foreach ($subdirs as $subdir) {
             $directory_empty = count(glob($subdir . DIRECTORY_SEPARATOR . '*')) === 0;
             if ($directory_empty && is_writeable($subdir)) {
                 rmdir($subdir);
             }
         }
     }
     $logger->info('[Maint] Cleaned up import directories.');
 }
开发者ID:rmiddle,项目名称:cerb4,代码行数:46,代码来源:cron.classes.php

示例15: showTabSettingsAction

 function showTabSettingsAction()
 {
     $tpl = DevblocksPlatform::getTemplateService();
     $tpl->assign('path', $this->_TPL_PATH);
     $license = FegLicense::getInstance();
     $tpl->assign('license', $license);
     $db = DevblocksPlatform::getDatabaseService();
     $rs = $db->Execute("SHOW TABLE STATUS");
     $total_db_size = 0;
     $total_db_data = 0;
     $total_db_indexes = 0;
     $total_db_slack = 0;
     $total_file_size = 0;
     // [TODO] This would likely be helpful to the /debug controller
     if (null != ($row = mysql_fetch_assoc($rs))) {
         $table_name = $row['Name'];
         $table_size_data = intval($row['Data_length']);
         $table_size_indexes = intval($row['Index_length']);
         $table_size_slack = intval($row['Data_free']);
         $total_db_size += $table_size_data + $table_size_indexes;
         $total_db_data += $table_size_data;
         $total_db_indexes += $table_size_indexes;
         $total_db_slack += $table_size_slack;
     }
     mysql_free_result($rs);
     //		$sql = "SELECT SUM(file_size) FROM attachment";
     //		$total_file_size = intval($db->GetOne($sql));
     $tpl->assign('total_db_size', number_format($total_db_size / 1048576, 2));
     $tpl->assign('total_db_data', number_format($total_db_data / 1048576, 2));
     $tpl->assign('total_db_indexes', number_format($total_db_indexes / 1048576, 2));
     $tpl->assign('total_db_slack', number_format($total_db_slack / 1048576, 2));
     //		$tpl->assign('total_file_size', number_format($total_file_size/1048576,2));
     $tpl->display('file:' . $this->_TPL_PATH . 'setup/tabs/settings/index.tpl');
 }
开发者ID:rmiddle,项目名称:feg,代码行数:34,代码来源:setup.php


注:本文中的DevblocksPlatform::getDatabaseService方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。