function parseConfig() { $options =& PEAR::getStaticProperty('DB_DataObject', 'options'); if (isset($options['modtables'])) { $this->modtables = $options['modtables']; $this->modmap = $options['modmap']; $this->modsql = $options['modsql']; } $ff = HTML_Flexyframework::get(); $dirs = array($ff->page->rootDir . '/Pman/DataObjects'); // not used anymore! foreach ($this->modtables as $m => $ts) { $dirs[] = $ff->page->rootDir . '/Pman/' . $m . '/DataObjects'; } $ini = array('database__render' => array()); foreach ($dirs as $d) { if (!file_exists($d . '/pman.links.ini')) { continue; } $in = parse_ini_file($d . '/pman.links.ini', true); $r = array(); if (isset($in['database__render'])) { $r = $in['database__render']; unset($in['database__render']); } $ini = array_merge($ini, $in); $ini['database__render'] = array_merge($ini['database__render'], $r); } //echo '<PRE>';print_R($ini);//exit; if (!isset($ini['database__render'])) { die("database__render not available in links files."); return; } $this->mapcols = array(); foreach ($ini as $tab => $conf) { if ($tab == 'database__render') { continue; } $this->mergeConfig($tab, $conf, $ini['database__render']); } $this->renderMap = $ini['database__render']; }
function runExtensions() { $ff = HTML_Flexyframework::get(); $dburl = parse_url($ff->DB_DataObject['database']); $dbtype = $dburl['scheme']; foreach ($this->extensions as $ext) { $scls = ucfirst($dbtype) . $ext; $cls = __CLASS__ . '_' . $scls; $fn = implode('/', explode('_', $cls)) . '.php'; if (!file_exists(__DIR__ . '/UpdateDatabase/' . $scls . '.php')) { return; } require_once $fn; $c = new $cls(); } }
function parseConfig() { $options =& PEAR::getStaticProperty('DB_DataObject', 'options'); if (isset($options['modtables'])) { $this->modtables = $options['modtables']; $this->modmap = $options['modmap']; $this->modsql = $options['modsql']; } $ff = HTML_Flexyframework::get(); $dirs = array($ff->page->rootDir . '/Pman/DataObjects'); // not used anymore! foreach ($this->modtables as $m => $ts) { $dirs[] = $ff->page->rootDir . '/Pman/' . $m . '/DataObjects'; } //echo '<PRE>';print_R($ini);//exit; }
/** * The default page handler * by default relays to get(), or post() methods depending on the request. * * Override this if you do not handle get or post differently. * * * @param string request, the remainder of the request not handled by the object. * * @return none|string none = handled, string = redirect to another page = eg. data/list * @access public */ function start($request, $isRedirect = false, $args = array()) { $cli = HTML_Flexyframework::get()->cli; if (!$cli && !$isRedirect && !empty($_SERVER["REQUEST_METHOD"]) && $_SERVER["REQUEST_METHOD"] == "POST") { return $this->post($request, $args); } else { return $this->get($request, $args, $isRedirect); } }
function prune($inM) { // 40 seconds ? to delete 100K records.. // DB_DataObject::debugLevel(1); $f = DB_DataObject::Factory('reader_article'); $f->query("\n DELETE FROM Events where \n event_when < NOW() - INTERVAL {$inM} MONTH\n AND\n action != 'NOTIFY'\n LIMIT 100000\n "); // notificication events occur alot - so we should trash them more frequently.. /* $f = DB_DataObject::Factory('reader_article'); $f->query(" DELETE FROM Events where event_when < NOW() - INTERVAL 1 MONTH AND action IN ('NOTIFY') LIMIT 100000 "); */ // rather than deleting them all, it's probably best to just delete notify events that occured to often. // eg. when we tried to deliver multiple times without success... /* * SELECT on_id, on_table, min(id) as min_id, max(id) as max_id, count(*) as mm FROM Events WHERE action = 'NOTIFY' and event_when < NOW() - INTERVAL 1 WEEK GROUP BY on_id, on_table HAVING mm > 2 ORDER BY mm desc; */ //DB_DataObject::debugLevel(1); $f = DB_DataObject::Factory('Events'); $f->selectAdd(); $f->selectAdd("on_id, on_table, min(id) as min_id, max(id) as max_id, count(*) as mm"); $f->whereAdd("action = 'NOTIFY' and event_when < NOW() - INTERVAL 1 WEEK"); $f->groupBy('on_id, on_table'); $f->having("mm > 2"); $f->orderBy('mm desc'); $f->limit(10000); $ar = $f->fetchAll(); foreach ($ar as $f) { $q = DB_DataObject::Factory('Events'); $q->query("DELETE FROM Events where \n action = 'NOTIFY'\n AND\n on_id = {$f->on_id}\n AND\n on_table = '{$q->escape($f->on_table)}'\n AND\n id > {$f->min_id}\n AND\n id < {$f->max_id}\n "); } // pruning is for our press project - so we do not clean up dependant tables at present.. if (function_exists('posix_getpwuid')) { $uinfo = posix_getpwuid(posix_getuid()); $user = $uinfo['name']; } else { $user = getenv('USERNAME'); // windows. } $ff = HTML_Flexyframework::get()->Pman; $y = date("Y"); $m = date("m"); $rootDir = $ff['storedir'] . '/_events_/' . $user; $dirs = array_filter(glob($rootDir . "/*"), 'is_dir'); foreach ($dirs as $d) { $mdirs = array_filter(glob($d . "/*"), 'is_dir'); foreach ($mdirs as $md) { $dirDate = str_replace($rootDir . "/", '', $md); if (strtotime($dirDate . "/01") < strtotime("now - {$inM} months")) { //echo "remove $md\n"; $this->delTree($md); // echo $md . " is removed. \n"; } } } exit; }