public static function debugLevel($v = null) { // avoid those annoying PEAR::DB strict standards warnings it causes $old = error_reporting(); error_reporting(error_reporting() & ~E_STRICT); $res = parent::debugLevel($v); // reset error_reporting($old); return $res; }
function parseArgs(&$opts) { if ($opts['debug']) { DB_DataObject::debugLevel($opts['debug']); print_r($opts); } $this->opts = $opts; if (!empty($opts['poolsize'])) { $this->max_pool_size = $opts['poolsize']; } if (empty($opts['limit'])) { $opts['limit'] = '1000'; // not sure why it's not picking up the defautl.. } if (!empty($opts['old'])) { $opts['list'] = 1; // force listing.. } $this->force = empty($opts['force']) ? 0 : 1; if (!empty($opts['send-to'])) { $this->send_to = $opts['send-to']; } }
/** * DB_DataObject_FormBuilder::debug() * * Outputs a debug message, if the debug setting in the DataObject.ini file is * set to 1 or higher. * * @param string $message The message to printed to the browser * @access public * @see DB_DataObject::debugLevel() */ function debug($message) { if (DB_DataObject::debugLevel() > 0) { echo '<pre><b>FormBuilder:</b> ' . $message . "</pre>\n"; } }
// // $Id: createTables.php 277015 2009-03-12 05:51:03Z alan_k $ // // since this version doesnt use overload, // and I assume anyone using custom generators should add this.. define('DB_DATAOBJECT_NO_OVERLOAD', 1); //require_once 'DB/DataObject/Generator.php'; require_once 'DB/DataObject/Generator.php'; if (!ini_get('register_argc_argv')) { PEAR::raiseError("\nERROR: You must turn register_argc_argv On in you php.ini file for this to work\neg.\n\nregister_argc_argv = On\n\n", null, PEAR_ERROR_DIE); exit; } if (!@$_SERVER['argv'][1]) { PEAR::raiseError("\nERROR: createTable.php usage:\n\nC:\\php\\pear\\DB\\DataObjects\\createTable.php example.ini\n\n", null, PEAR_ERROR_DIE); exit; } $config = parse_ini_file($_SERVER['argv'][1], true); foreach ($config as $class => $values) { $options = PEAR::getStaticProperty($class, 'options'); $options = $values; } $options = PEAR::getStaticProperty('DB_DataObject', 'options'); if (empty($options)) { PEAR::raiseError("\nERROR: could not read ini file\n\n", null, PEAR_ERROR_DIE); exit; } set_time_limit(0); // use debug level from file if set.. DB_DataObject::debugLevel(isset($options['debug']) ? $options['debug'] : 1); $generator = new DB_DataObject_Generator(); $generator->start();
<?php // -*- C++ -*- error_reporting(E_ALL); // Test for: DB::parseDSN() require_once '../DataObject.php'; require_once '../DataObject/Generator.php'; require_once 'PEAR.php'; $options =& PEAR::getStaticProperty('DB_DataObject', 'options'); //$options['schema_location'] = dirname(__FILE__); $options['database'] = 'mysql://alan@localhost/test'; $options['debug_force_updates'] = TRUE; $options['proxy'] = 'light'; $options['class_prefix'] = ''; DB_DataObject::debugLevel(1);
public function run() { $this->ajaxAuth = true; if ($this->getOption('auth')) { $this->ajaxAuth = false; $subController = new M_Office_Auth($_REQUEST['database']); if (!key_exists('adminPrivileges', $_SESSION) || key_exists('logout', $_REQUEST)) { $this->assign('username', User::getInstance('office')->getProperty('username')); $this->ajaxAuth = true; } elseif (!User::getInstance('office')->isLoggedIn()) { $this->ajaxAuth = false; } else { $subController->initOptions(); $this->assign('username', User::getInstance('office')->getProperty('username')); } } $not = Notifier::getInstance(); $not->addListener($this); if ($this->getOption('auth') && !User::getInstance('office')->isLoggedIn()) { if (self::isAjaxRequest()) { $this->assign('__action', 'ajaxlogin'); } return; } if (key_exists('updateSuccess', $_REQUEST)) { $this->say(__('Record was successfully updated')); M_Office_Util::clearRequest(array('updateSuccess' => 1)); } if (isset($_REQUEST['module'])) { $info = M_Office_Util::getModuleInfo($_REQUEST['module']); $module = $_REQUEST['module']; if (!$info) { if (strpos($_REQUEST['module'], ':')) { $info = array('type' => 'dyn', 'title' => 'Plugin'); $module = $tab[1]; } elseif (preg_match('`^(.+)helper$`', $_REQUEST['module'], $tab)) { $info = array('type' => 'dyn', 'title' => __("modules.{$tab[1]}helper.title")); $module = $_REQUEST['module']; } else { throw new NotFoundException(__('error.module_not_found', array($_REQUEST['module']))); } } } if ($this->isAjaxRequest() && $this->ajaxAuth && $info['type'] != 'dyn') { $this->output = ''; unset($this->localOutput); } if (isset($_REQUEST['debug']) && MODE == 'development') { $debug = (int) $_REQUEST['debug'] % 3; DB_DataObject::debugLevel($debug); ini_set('display_errors', 1); } if ($_REQUEST['livesearch']) { $aj = new M_Office_livesearch($_REQUEST['searchtext'], $_REQUEST['expand']); $this->output = $aj->processRequest(); return; } elseif ($_REQUEST['treesort']) { $aj = new M_Office_treesort(); $this->output = $aj->processRequest(); return; } elseif ($_REQUEST['liveedit']) { $aj = new M_Office_liveedit($_REQUEST['liveedit']); $this->output = $aj->processRequest(); return; } elseif (key_exists('ajaxfromtable', $_REQUEST)) { $table = $_REQUEST['module']; $do = DB_DataObject::factory($table); $do->get($_REQUEST['filterField'], $_REQUEST['filterValue']); $aj = new M_Office_ajaxFromTable($do, $_REQUEST['module'], $_REQUEST['module'], $_REQUEST['filterField'], $_REQUEST['filterValue']); $this->output = $aj->processRequest(); return; } if (isset($_REQUEST['module'])) { if (!$info) { $info = M_Office_Util::getModuleInfo($_REQUEST['module']); } switch ($info['type']) { case 'db': // TODO ajouter ce path en avant-dernier et non en dernier Mreg::get('tpl')->addPath(APP_ROOT . 'app/' . APP_NAME . '/templates/' . $info['table'] . '/', 'after'); Mreg::get('tpl')->addPath(APP_ROOT . 'app/' . APP_NAME . '/templates/' . $_REQUEST['module'] . '/', 'after'); $subController = new M_Office_ShowTable($_REQUEST['module'], $filter); break; case 'dyn': // home module = available for everyone $allowAccess = $_REQUEST['module'] == 'home' || M_Office_Util::getGlobalOption('view', 'showtable', $_REQUEST['module']); if (!$allowAccess) { Log::warn('User is NOT allowed to access ' . $_REQUEST['module']); M_Office_Util::refresh(M_Office::URL(array(), array_keys($_REQUEST))); } else { Log::info('User is allowed to access ' . $_REQUEST['module']); } $subController = Module::factory($_REQUEST['module'], M::getPaths('module')); $subController->executeAction($_REQUEST['action'] ? $_REQUEST['action'] : 'index'); $this->assign('__action', 'dyn'); $layout = $subController->getConfig('layout', $_REQUEST['action'] ? $_REQUEST['action'] : 'index'); if ($layout == '__self') { M_Office::$dsp = '__defaut/ajaxindex'; } elseif ($layout) { M_Office::$dsp = $layout; } $this->assign('output', $subController->output(null, '__self')); break; } $this->assign('currentmodule', $_REQUEST['module']); } else { $subController = new M_Office_FrontEndHome(); } }
function get($s = '') { $this->sessionState(0); $lbits = $this->guessUsersLanguage(); if ($this->authUser && !empty($_REQUEST['_debug'])) { DB_DataObject::debugLevel(1); } $i = DB_DataObject::Factory('I18n'); switch ($s) { case 'Lang': $i->ltype = 'l'; $i->applyFilters($_REQUEST, $this->authUser, $this); $this->jdata($i->toTransList('l', implode('_', $lbits))); break; case 'Country': $i->ltype = 'c'; $i->applyFilters($_REQUEST, $this->authUser, $this); $this->jdata($i->toTransList('c', implode('_', $lbits))); break; case 'Currency': $i->ltype = 'm'; $i->applyFilters($_REQUEST, $this->authUser, $this); $this->jdata($i->toTransList('m', implode('_', $lbits))); break; case 'Timezone': $ar = DateTimeZone::listAbbreviations(); $ret = array(); $tza = array(); foreach ($ar as $tl => $sar) { foreach ($sar as $tz) { $tza[] = $tz['timezone_id']; } } $tza = array_unique($tza); sort($tza); foreach ($tza as $tz) { //filtering.. if (empty($_REQUEST['q']) || 0 === strcasecmp(substr($tz, 0, strlen($_REQUEST['q'])), $_REQUEST['q'])) { $ret[] = array('tz' => $tz); } } $this->jdata($ret); } if (!empty($_REQUEST['debug'])) { DB_DataObject::debugLevel(1); } $i = DB_DataObject::Factory('I18n'); $i->buildDB(); $i = DB_DataObject::Factory('I18n'); $cfg = $i->cfg(); $langs = $cfg['t']; // var_dump($langs);exit; $ar = array(); foreach ($langs as $lang) { //$rlang = array_shift(explode('_', strtoupper($lang))); $rlang = array_shift(explode('_', $lang)); $ar[$lang] = array(); $i = DB_DataObject::Factory('I18n'); $ar[$lang]['l'] = $i->toTransList('l', $rlang); $i = DB_DataObject::Factory('I18n'); $ar[$lang]['c'] = $i->toTransList('c', $rlang); $i = DB_DataObject::Factory('I18n'); $ar[$lang]['m'] = $i->toTransList('m', $rlang); } //echo '<PRE>';print_r($ar); header('Content-type: text/javascript'); echo 'Pman.I18n.Data = ' . json_encode($ar); exit; }
function get($args, $opts) { $this->opts = $opts; if (!empty($this->opts['debug'])) { DB_DataObject::debugLevel(1); } if (!empty($this->opts['list'])) { $this->listTypes(); } if (empty($this->opts['group'])) { $this->jerr('Missing group - try add [-t {group name}]'); } $min = 0; if ($this->opts['uid'] != 'STD') { $events = DB_DataObject::factory('Events'); $events->action = 'ERROR-REPORT-' . $this->opts['uid']; $events->orderBy('id DESC'); $events->limit(1); if ($events->find(true)) { $min = $events->id; } } $events = DB_DataObject::factory('Events'); $events->selectAdd(); $events->selectAdd("\n DISTINCT(Events.action) AS action,\n COUNT(Events.id) AS total\n "); $events->whereAdd('Events.id > ' . $min); $events->whereAdd("Events.action NOT LIKE 'ERROR-REPORT-%'"); $events->whereAdd("Events.event_when > NOW() - INTERVAL 1 DAY"); if (!empty($this->opts['exclude'])) { $exclude = array_unique(array_filter(array_map('trim', explode(',', $this->opts['exclude'])))); if (!empty($exclude)) { $events->whereAddIn('!Events.action', $exclude, 'string'); } } if (!empty($this->opts['only'])) { $only = array_unique(array_filter(array_map('trim', explode(',', $this->opts['only'])))); if (!empty($only)) { $events->whereAddIn('Events.action', $only, 'string'); } } $events->groupBy('Events.action'); $events->orderBy('Events.action ASC'); $summary = $events->fetchAll('action', 'total'); if (empty($summary)) { $this->jerror('ERROR-REPORT-' . $this->opts['uid'], 'Nothing to be sent'); } $subject = array(); foreach ($summary as $k => $v) { $subject[] = "{$v} {$k}"; } $subject = implode(', ', $subject); if (!empty($this->opts['subject'])) { $subject = "{$this->opts['subject']} {$subject}"; } $events = DB_DataObject::factory('Events'); $events->autoJoin(); $events->selectAdd(); $events->selectAdd("\n Events.id AS id,\n Events.event_when AS event_when,\n Events.action AS action,\n Events.remarks AS remarks\n \n "); $events->selectAddPersonEmail(); $events->whereAdd("Events.action NOT LIKE 'ERROR-REPORT-%'"); $events->whereAdd('Events.id > ' . $min); $events->whereAdd("Events.event_when > NOW() - INTERVAL 1 DAY"); $exclude = array_unique(array_filter(array_map('trim', explode(',', $this->opts['exclude'])))); if (!empty($exclude)) { $events->whereAddIn('!Events.action', $exclude, 'string'); } if (!empty($only)) { $events->whereAddIn('Events.action', $only, 'string'); } if (!$events->count()) { // this is the second count we are doing... $this->jerr('Nothing to be sent'); } $this->addEvent('ERROR-REPORT-' . $this->opts['uid'], false, $subject); $errors = $events->fetchAll(); if (!empty($this->opts['host'])) { // reset the mail settings.. HTML_FlexyFramework::get()->Mail = array('host' => $this->opts['host']); } if (!empty($this->opts['helo'])) { HTML_FlexyFramework::get()->Mail['helo'] = $this->opts['helo']; } $content = array('template' => 'EVENT_ERRORS_REPORT', 'rcpts_group' => $this->opts['group'], 'errors' => $errors, 'subject' => $subject); $sent = DB_DataObject::factory('core_email')->send($content); if (!is_object($sent)) { $this->jok("Done"); } $this->jerr($sent); }
function get($id, $opts) { //print_r($opts); if (!empty($opts['DB_DataObject-debug'])) { DB_DataObject::debugLevel($opts['DB_DataObject-debug']); } //DB_DataObject::debugLevel(1); //date_default_timezone_set('UTC'); // phpinfo();exit; $force = empty($opts['force']) ? 0 : 1; $w = DB_DataObject::factory($this->table); if (!$w->get($id)) { $this->errorHandler("invalid id\n"); } if (!$force && strtotime($w->act_when) < strtotime($w->sent)) { $this->errorHandler("send repeat to early\n"); } if (!empty($opts['debug'])) { print_r($w); $ff = HTML_FlexyFramework::get(); if (!isset($ff->Core_Mailer)) { $ff->Core_Mailer = array(); } HTML_FlexyFramework::get()->Core_Mailer['debug'] = true; } $sent = empty($w->sent) || preg_match('/^0000/', $w->sent) ? false : true; if (!$force && (!empty($w->msgid) || $sent)) { $ww = clone $w; if (!$sent) { $w->sent = $w->sqlValue("NOW()"); $w->update($ww); } $this->errorHandler("message has been sent already.\n"); } $o = $w->object(); if ($o === false) { $ev = $this->addEvent('NOTIFY', $w, "Notification event cleared (underlying object does not exist)"); $ww = clone $w; $w->sent = date('Y-m-d H:i:s'); $w->msgid = ''; $w->event_id = $ev->id; $w->update($ww); $this->errorHandler(date('Y-m-d h:i:s ') . "Notification event cleared (underlying object does not exist)" . "\n"); } $p = $w->person(); if (isset($p->active) && empty($p->active)) { $ev = $this->addEvent('NOTIFY', $w, "Notification event cleared (not user not active any more)"); $ww = clone $w; $w->sent = date('Y-m-d H:i:s'); $w->msgid = ''; $w->event_id = $ev->id; $w->update($ww); $this->errorHandler(date('Y-m-d h:i:s ') . "Notification event cleared (not user not active any more)" . "\n"); $this->errorHandler("message has been sent already.\n"); } // let's work out the last notification sent to this user.. $l = DB_DataObject::factory($this->table); $lar = array('ontable' => $w->ontable, 'onid' => $w->onid); // only newer version of the database us this.. $personid_col = strtolower($w->person_table) . '_id'; if (isset($w->{$personid_col})) { $lar[$personid_col] = $w->{$personid_col}; } $l->setFrom($lar); $l->whereAdd('id != ' . $w->id); $l->orderBy('sent DESC'); $l->limit(1); $ar = $l->fetchAll('sent'); $last = empty($ar) ? date('Y-m-d H:i:s', 0) : $ar[0]; // find last event.. $ev = DB_DataObject::factory('Events'); $ev->on_id = $w->id; // int(11) $ev->on_table = $this->table; $ev->limit(1); $ev->orderBy('event_when DESC'); $ar = $ev->fetchAll('event_when'); $last_event = empty($ar) ? 0 : $ar[0]; $next_try_min = 5; if ($last_event) { $next_try_min = floor((time() - strtotime($last_event)) / 60) * 2; } $next_try = $next_try_min . ' MINUTES'; // this may modify $p->email. (it will not update it though) $email = $this->makeEmail($o, $p, $last, $w, $force); if ($email === true) { $ev = $this->addEvent('NOTIFY', $w, "Notification event cleared (not required any more)"); $ww = clone $w; $w->sent = date('Y-m-d H:i:s'); $w->msgid = ''; $w->event_id = $ev->id; $w->update($ww); $this->errorHandler(date('Y-m-d h:i:s ') . "Notification event cleared (not required any more)" . "\n"); } if (is_a($email, 'PEAR_Error')) { $email = array('error' => $email->toString()); } if (empty($p) && !empty($email['recipients'])) { // make a fake person.. $p = (object) array('email' => $email['recipients']); } if ($email === false || isset($email['error']) || empty($p)) { // object returned 'false' - it does not know how to send it.. $ev = $this->addEvent('NOTIFY', $w, isset($email['error']) ? $email['error'] : "INTERNAL ERROR - We can not handle " . $w->ontable); $ww = clone $w; $w->sent = date('Y-m-d H:i:s'); $w->msgid = ''; $w->event_id = $ev->id; $w->update($ww); $this->errorHandler(date('Y-m-d h:i:s ') . (isset($email['error']) ? $email['error'] : "INTERNAL ERROR - We can not handle " . $w->ontable) . "\n"); } if (isset($email['later'])) { $old = clone $w; $w->act_when = $email['later']; $w->update($old); $this->errorHandler(date('Y-m-d h:i:s ') . " Delivery postponed by email creator to {$email['later']}"); } if (empty($email['headers']['Message-Id'])) { $HOST = gethostname(); $email['headers']['Message-Id'] = "<{$this->table}-{$id}@{$HOST}>"; } //$p->email = '*****@*****.**'; //for testing.. //print_r($email);exit; // should we fetch the watch that caused it.. - which should contain the method to call.. // --send-to=test@xxx.com if (!empty($email['send-to'])) { $p->email = $email['send-to']; } if (!empty($opts['send-to'])) { $p->email = $opts['send-to']; } // since some of them have spaces?!?! $p->email = trim($p->email); require_once 'Validate.php'; if (!Validate::email($p->email, true)) { $ev = $this->addEvent('NOTIFY', $w, "INVALID ADDRESS: " . $p->email); $ww = clone $w; $w->sent = date('Y-m-d H:i:s'); $w->msgid = ''; $w->event_id = $ev->id; $w->update($ww); $this->errorHandler(date('Y-m-d h:i:s ') . "INVALID ADDRESS: " . $p->email . "\n"); } $ff = HTML_FlexyFramework::get(); $dom = array_pop(explode('@', $p->email)); $mxs = $this->mxs($dom); $ww = clone $w; // we might fail doing this... // need to handle temporary failure.. // we try for 3 days.. $retry = 5; if (strtotime($w->act_start) < strtotime('NOW - 1 HOUR')) { // older that 1 hour. $retry = 15; } if (strtotime($w->act_start) < strtotime('NOW - 1 DAY')) { // older that 1 day. $retry = 60; } if (strtotime($w->act_start) < strtotime('NOW - 2 DAY')) { // older that 1 day. $retry = 120; } if ($mxs === false) { // only retry for 2 day son the MX issue.. if ($retry < 120) { $this->addEvent('NOTIFY', $w, 'MX LOOKUP FAILED ' . $dom); $w->act_when = date('Y-m-d H:i:s', strtotime('NOW + ' . $retry . ' MINUTES')); $w->update($ww); $this->errorHandler(date('Y-m-d h:i:s') . " - MX LOOKUP FAILED\n"); } $ev = $this->addEvent('NOTIFY', $w, "BAD ADDRESS - BAD DOMAIN - " . $p->email); $w->sent = date('Y-m-d H:i:s'); $w->msgid = ''; $w->event_id = $ev->id; $w->update($ww); $this->errorHandler(date('Y-m-d h:i:s') . " - FAILED - BAD EMAIL - {$p->email} \n"); } if (!$force && strtotime($w->act_start) < strtotime('NOW - 14 DAY')) { $ev = $this->addEvent('NOTIFY', $w, "BAD ADDRESS - GIVE UP - " . $p->email); $w->sent = date('Y-m-d H:i:s'); $w->msgid = ''; $w->event_id = $ev->id; $w->update($ww); $this->errorHandler(date('Y-m-d h:i:s') . " - FAILED - GAVE UP TO OLD - {$p->email} \n"); } $w->to_email = $p->email; //$this->addEvent('NOTIFY', $w, 'GREYLISTED ' . $p->email . ' ' . $res->toString()); $w->act_when = date('Y-m-d H:i:s', strtotime('NOW + ' . $retry . ' MINUTES')); $w->update($ww); $ww = clone $w; $fail = false; require_once 'Mail.php'; $core_domain = DB_DataObject::factory('core_domain'); if (!$core_domain->get('domain', $dom)) { $core_domain = DB_DataObject::factory('core_domain'); $core_domain->setFrom(array('domain' => $dom)); $core_domain->insert(); } foreach ($mxs as $mx) { if (!isset($ff->Mail['helo'])) { $this->errorHandler("config Mail[helo] is not set"); } $this->debug_str = ''; $this->debug("Trying SMTP: {$mx} / HELO {$ff->Mail['helo']}"); $mailer = Mail::factory('smtp', array('host' => $mx, 'localhost' => $ff->Mail['helo'], 'timeout' => 15, 'socket_options' => isset($ff->Mail['socket_options']) ? $ff->Mail['socket_options'] : null, 'debug' => 1, 'debug_handler' => array($this, 'debugHandler'))); // if the host is the mail host + it's authenticated add auth details // this normally will happen if you sent Pman_Core_NotifySend['host'] if (isset($ff->Mail['host']) && $ff->Mail['host'] == $mx && !empty($ff->Mail['auth'])) { $username = $ff->Mail['username']; $password = $ff->Mail['password']; if (!empty($ff->Core_Notify) && !empty($ff->Core_Notify['routes'])) { foreach ($ff->Core_Notify['routes'] as $server => $settings) { if (!in_array($dom, $settings['domains'])) { continue; } // what's the minimum timespan.. - if we have 60/hour.. that's 1 every minute. // if it's newer that '1' minute... // then shunt it.. $seconds = floor(60 * 60 / $settings['rate']); $core_notify = DB_DataObject::factory($this->table); $core_notify->domain_id = $core_domain->id; $core_notify->whereAdd("\n sent >= NOW() - INTERVAL {$seconds} SECONDS\n "); if ($core_notify->count()) { $old = clone $w; $w->act_when = date("Y-m-d H:i:s", time() + $seconds); $w->update($old); $this->errorHandler(date('Y-m-d h:i:s ') . " Too many emails sent by {$dom}"); } // that make's this test obsolete... /* $core_notify = DB_DataObject::factory($this->table); $core_notify->domain_id = $core_domain->id; $core_notify->whereAdd(" sent >= NOW() - INTERVAL 1 HOUR "); if($core_notify->count() >= $settings['rate']){ $old = clone($w); $w->act_when = date("Y-m-d H:i:s", strtotime('+1 HOUR')); $w->update($old); $this->errorHandler(date('Y-m-d h:i:s ') . " Too many emails sent by {$dom}"); } */ $mailer->host = $server; $username = $settings['username']; $password = $settings['password']; break; } } $mailer->auth = true; $mailer->username = $username; $mailer->password = $password; } $res = $mailer->send($p->email, $email['headers'], $email['body']); if ($res === true) { // success.... $successEventName = empty($email['successEventName']) ? 'NOTIFYSENT' : $email['successEventName']; $ev = $this->addEvent($successEventName, $w, "{$w->to_email} - {$email['headers']['Subject']}"); $ev->writeEventLog($this->debug_str); if (strtotime($w->act_when) > strtotime("NOW")) { $w->act_when = date('Y-m-d H:i:s'); } $w->sent = date('Y-m-d H:i:s'); $w->msgid = $email['headers']['Message-Id']; $w->event_id = $ev->id; // sent ok.. - no need to record it.. $w->domain_id = $core_domain->id; $w->update($ww); // enable cc in notify.. if (!empty($email['headers']['Cc'])) { $cmailer = Mail::factory('smtp', isset($ff->Mail) ? $ff->Mail : array()); $email['headers']['Subject'] = "(CC): " . $email['headers']['Subject']; $cmailer->send($email['headers']['Cc'], $email['headers'], $email['body']); } if (!empty($email['bcc'])) { $cmailer = Mail::factory('smtp', isset($ff->Mail) ? $ff->Mail : array()); $email['headers']['Subject'] = "(CC): " . $email['headers']['Subject']; $res = $cmailer->send($email['bcc'], $email['headers'], $email['body']); if (!$res || is_a($res, 'PEAR_Error')) { echo "could not send bcc..\n"; } else { echo "Sent BCC to {$email['bcc']}\n"; } } $this->errorHandler(date('Y-m-d h:i:s') . " - SENT {$w->id} - {$w->to_email} \n", true); } // what type of error.. $code = empty($res->userinfo['smtpcode']) ? -1 : $res->userinfo['smtpcode']; if (!empty($res->code) && $res->code == 10001) { // fake greylist if timed out. $code = 421; } if ($code < 0) { $this->debug($res->message); continue; // try next mx... ??? should we wait??? - nope we did not even connect.. } // give up after 2 days.. if (in_array($code, array(421, 450, 451, 452)) && $next_try_min < 2 * 24 * 60) { // try again later.. // check last event for this item.. //$errmsg= $fail ? ($res->userinfo['smtpcode'] . ': ' .$res->toString()) : " - UNKNOWN ERROR"; $errmsg = $res->userinfo['smtpcode'] . ': ' . $res->message; if (!empty($res->userinfo['smtptext'])) { $errmsg = $res->userinfo['smtpcode'] . ':' . $res->userinfo['smtptext']; } //print_r($res); $this->addEvent('NOTIFY', $w, 'GREYLISTED - ' . $errmsg); $w->act_when = date('Y-m-d H:i:s', strtotime('NOW + ' . $retry . ' MINUTES')); $w->domain_id = $core_domain->id; $w->update($ww); $this->errorHandler(date('Y-m-d h:i:s') . " - GREYLISTED - {$errmsg} \n"); } $fail = true; break; } if ($fail || $next_try_min > 2 * 24 * 60) { // fail.. = log and give up.. $errmsg = $fail ? $res->userinfo['smtpcode'] . ': ' . $res->toString() : " - UNKNOWN ERROR"; if (isset($res->userinfo['smtptext'])) { $errmsg = $res->userinfo['smtpcode'] . ':' . $res->userinfo['smtptext']; } $ev = $this->addEvent('NOTIFY', $w, ($fail ? "FAILED - " : "RETRY TIME EXCEEDED - ") . $errmsg); $w->sent = date('Y-m-d H:i:s'); $w->msgid = ''; $w->event_id = $ev->id; $w->domain_id = $core_domain->id; $w->update($ww); $this->errorHandler(date('Y-m-d h:i:s') . ' - FAILED - ' . ($fail ? $res->toString() : "RETRY TIME EXCEEDED\n")); } // handle no host availalbe forever... if (strtotime($w->act_start) < strtotime('NOW - 3 DAYS')) { $ev = $this->addEvent('NOTIFY', $w, "RETRY TIME EXCEEDED - " . $p->email); $w->sent = date('Y-m-d H:i:s'); $w->msgid = ''; $w->event_id = $ev->id; $w->domain_id = $core_domain->id; $w->update($ww); $this->errorHandler(date('Y-m-d h:i:s') . " - FAILED - RETRY TIME EXCEEDED\n"); } $this->addEvent('NOTIFY', $w, 'NO HOST CAN BE CONTACTED:' . $p->email); $w->act_when = date('Y-m-d H:i:s', strtotime('NOW + 5 MINUTES')); $w->domain_id = $core_domain->id; $w->update($ww); $this->errorHandler(date('Y-m-d h:i:s') . " - NO HOST AVAILABLE\n"); }
function get($path) { ini_set('memory_limit', '256M'); // we need alot of memory set_time_limit(0); $argv = $_SERVER['argv']; array_shift($argv); array_shift($argv); $opts = explode(',', 'table==,where==,dump-dir==,debug='); require_once 'Console/Getopt.php'; $go = Console_Getopt::getopt2($argv, '', $opts); if (is_object($go)) { die($go->toString()); } foreach ($go[0] as $ar) { $args[substr($ar[0], 2)] = $ar[1]; } $errs = array(); foreach ($opts as $req) { if (substr($req, -2, 2) != '==') { // skip optional arguments continue; } if (empty($args[substr($req, 0, -2)])) { $errs[] = "--" . substr($req, 0, -2) . ' is required'; } } if (!empty($errs)) { die(print_R($errs, true)); } if (!empty($args['debug'])) { DB_DataObject::debugLevel($args['debug']); } $this->args = $args; $this->out = array(); $this->discoverChildren($this->args['table'], $this->args['where'], true); //print_R($this->deletes); //print_r($this->dumps); //exit; $this->discover($this->args['table'], $this->args['where'], true); if (!file_exists($args['dump-dir'])) { mkdir($args['dump-dir'], 0777, true); } $this->generateInsert(); $this->generateDelete(); $this->generateShell(); echo "DELETING:\n"; foreach ($this->deletes as $tbl => $ar) { if (empty($ar)) { continue; } echo " " . $tbl . ' -> ' . count(array_keys($ar)) . " Records\n"; } echo "DUMPING:\n"; foreach ($this->dumps as $tbl => $ar) { if (empty($ar)) { continue; } echo " " . $tbl . ' -> ' . count(array_keys($ar)) . " Records\n"; } echo "FILES:\n"; echo " Total : " . $this->filetotal . " files using " . floor($this->filesize / 1000000) . "Mb\n"; echo "GENERATED FILES:\n"; // summary echo " " . implode("\n ", $this->out) . "\n"; exit; }
public function picture($marca) { $obj = DB_DataObject::Factory('MpBrand'); DB_DataObject::debugLevel(1); printVar($obj); $obj->name = $marca; $find = $obj->find(); if ($find < 0) { while ($obj->fetch()) { echo $obj->picture; } } else { echo 'ni mir..'; } $obj->free(); }
/** * Debugger. - use this in your extended classes to output debugging information. * * Uses DB_DataObject::DebugLevel(x) to turn it on * * @param string $message - message to output * @param string $logtype - bold at start * @param string $level - output level * @access public * @return none */ function debug($message, $logtype = 0, $level = 1) { global $_DB_DATAOBJECT; if (DB_DataObject::debugLevel() < $level) { return; } if (!ini_get('html_errors')) { echo "{$logtype} : {$message}\n"; flush(); return; } echo "<PRE><B>{$logtype}</B> {$message}</PRE>\n"; flush(); }
function get($path) { ini_set('memory_limit', '256M'); // we need alot of memory set_time_limit(0); $argv = $_SERVER['argv']; array_shift($argv); array_shift($argv); $opts = explode(',', 'table==,where==,dump-dir==,debug='); require_once 'Console/Getopt.php'; $go = Console_Getopt::getopt2($argv, '', $opts); if (is_object($go)) { die($go->toString()); } foreach ($go[0] as $ar) { $args[substr($ar[0], 2)] = $ar[1]; } $errs = array(); foreach ($opts as $req) { if (substr($req, -2, 2) != '==') { // skip optional arguments continue; } if (empty($args[substr($req, 0, -2)])) { $errs[] = "--" . substr($req, 0, -2) . ' is required'; } } if (!empty($errs)) { die(print_R($errs, true)); } if (!empty($args['debug'])) { DB_DataObject::debugLevel($args['debug']); } $this->args = $args; $this->out = array(); $this->discoverChildren($this->args['table'], $this->args['where'], true); //print_R($this->deletes); //print_r($this->dumps); //exit; $this->discover($this->args['table'], $this->args['where'], true); if (!file_exists($args['dump-dir'])) { mkdir($args['dump-dir'], 0777, true); } // create uid's // dump items.. echo "GENERATED FILES:\n"; // summary echo " " . implode("\n ", $this->out) . "\n"; exit; }
function debug($n) { return DB_DataObject::debugLevel($n); }