public static function authentication($username_or_email, $password, $by = 'username') { import('system/share/network/session'); Session::start(); if (self::is_authenticated() && self::$info && $_SESSION[self::SESSION_NAME]) { return self::$info; } if (!in_array($by, array('username', 'email'))) { return false; } try { DatabaseBackend::load_model('system/contrib/auth'); $user = Doctrine_Query::create()->select('*')->from('User u')->leftJoin('u.Group g')->where(sprintf('u.%s="%s"', $by, $username_or_email))->fetchOne(); if (!$user) { return _('Username or email does not exits'); } list($func, $random, $encryped) = explode('$', $user->password); if ($user->password && $user->password === self::generate_password($password, $random, $func)) { self::$is_authenticated = true; self::$info = $_SESSION[self::SESSION_NAME] = array('id' => $user->id, 'username' => $user->username, 'group' => array('id' => $user->Group->id, 'name' => $user->Group->name)); if ($user->Role) { foreach ($user->Role as $role) { self::$info['role'][] = $_SESSION[self::SESSION_NAME]['role'][] = array('id' => $role->id, 'name' => $role->name, 'alias' => $role->alias); } } } else { return _("Password doesn't match"); } } catch (Doctrine_Query_Exception $e) { return _('System error'); } return $user ? $user : _('Username or email does not exits'); }
public function syncdb($application = null) { if ($_GET['confirm'] == 'true') { import('system/bin/doctrine'); DatabaseBackend::syncdb($application); } else { $this->load('smarty')->display('dev_tools/confirm_syncdb'); } }
public static function init($dsn = null, $init_connect = true) { BaseConfig::load(Package::get_file('etc/conf.d/database.yml')); self::$dsn = sprintf('%s://%s:%s@%s:%s/%s', ini('database/' . RUN_MODE . '/adapter'), ini('database/' . RUN_MODE . '/user'), ini('database/' . RUN_MODE . '/passwd'), ini('database/' . RUN_MODE . '/host'), ini('database/' . RUN_MODE . '/port'), ini('database/' . RUN_MODE . '/name')); if (self::$inited !== true) { import('system/vendors/Doctrine/Doctrine'); spl_autoload_register(array('Doctrine', 'autoload')); self::$inited = true; } if ($dsn) { self::$dsn = $dsn; } if ($init_connect) { self::create_connection(null, self::$dsn, ini('database/' . RUN_MODE . '/charset')); } spl_autoload_register(array('Doctrine_Core', 'modelsAutoload')); }
if ($result->result->item) { die(json_encode(array_map(function ($str) { return str_replace("\r", "", $str); }, $result->result->item))); } die(json_encode(array())); } if ($_GET['action'] == 'stop') { $result = $client->commandStop(array('commandid' => $_GET['cmd_id'])); die(json_encode(true)); } } $id = preg_replace('/[^0-9]/', '', $_GET['id']); if ($_GET['type'] == 'log') { // Fetch data from local SQL log $dbBackend = new DatabaseBackend($settings->getDatabase()); $mail = $dbBackend->getMail($id); if (!$mail) { die('Invalid mail'); } // Resolv SOAP node $node = $settings->getNodeBySerial($mail->serialno); if (!$node) { die('Unable to find SOAP node'); } $args = array('searchlog', '-a', $mail->msgts, '--', $mail->msgid); } else { $node = $settings->getNode($_GET['node']); if (!$node) { die('Invalid mail'); }
protected function __load__model__($model, $init_connect = true, $dsn = null) { import('system/bin/doctrine'); $tmp = explode('.', $model); DatabaseBackend::init($dsn, $init_connect); DatabaseBackend::load_model($tmp[0], $tmp[1]); }
} } catch (SoapFault $f) { die($f->getMessage()); } } header('Location: ' . $_SERVER['REQUEST_URI']); die; } $action_colors = array('DELIVER' => '#8c1', 'QUEUE' => '#1ad', 'QUARANTINE' => '#f70', 'REJECT' => '#ba0f4b', 'DELETE' => '#333', 'BOUNCE' => '#333', 'ERROR' => '#333', 'DEFER' => '#b5b'); $action_icons = array('DELIVER' => 'check', 'QUEUE' => 'exchange', 'QUARANTINE' => 'inbox', 'REJECT' => 'ban', 'DELETE' => 'trash-o', 'BOUNCE' => 'mail-reply', 'ERROR' => 'exclamation', 'DEFER' => 'clock-o'); function get_preview_link($m) { return '?' . http_build_query(array('page' => 'preview', 'node' => $m['id'], 'id' => $m['data']->id, 'msgid' => $m['data']->msgid, 'msgactionid' => $m['data']->msgactionid, 'type' => $m['type'])); } // Backends $dbBackend = new DatabaseBackend($settings->getDatabase()); $nodeBackend = new NodeBackend($settings->getNodes()); // Default values $search = isset($_GET['search']) ? hql_transform($_GET['search']) : ''; $size = isset($_GET['size']) ? intval($_GET['size']) : 50; $size = $size > 5000 ? 5000 : $size; $source = isset($_GET['source']) ? $_GET['source'] : $settings->getDefaultSource(); // Select box arrays $pagesize = array(10, 50, 100, 500, 1000, 5000); $sources = array(); if ($settings->getUseDatabaseLog()) { $sources += array('log' => 'Log'); } if ($settings->getDisplayHistory()) { $sources += array('history' => 'History'); }