/** getObjectType @param $o is the Object, ObjectName or ObjectInteger */ static function getObjectType($o, $r = null) { $arg = array(); $sql = 'SELECT * FROM base_object '; // Convert Object to String to use String Comp below if (is_object($o)) { $o = strtolower(get_class($o)); } if (intval($o) > 0) { $sql .= ' WHERE id = ?'; $arg[] = intval($o); if (empty($r)) { $r = 'name'; } } elseif (is_string($o)) { $o = strtolower($o); $sql .= ' WHERE stub = ? OR path = ? OR link = ? '; $arg[] = $o; $arg[] = $o; $arg[] = $o; if (empty($r)) { $r = 'id'; } } // Find and Return Value $ot = SQL::fetch_row($sql); if ($ot) { switch ($r) { case 'id': return $ot->id; case 'link': return $ot->link; case 'name': return $ot->name; case 'path': return $ot->path; case 'stub': return $ot->stub; default: return $ot; } } //throw new Exception('Cannot Handle Object Type ' . get_class($o) . '/' . $r . '[' . $sql->assemble() . ']'); return null; }
*/ namespace Edoceo\Imperium; use Edoceo\Radix; use Edoceo\Radix\Session; use Edoceo\Radix\DB\SQL; switch (strtolower($_POST['a'])) { case 'sign in': if (!acl::may('/auth/sign-in', 'POST')) { Session::flash('fail', 'Access Denied'); Radix::redirect('/auth/sign-in'); } $sql = 'SELECT * FROM auth_user WHERE username = ? '; $sql .= ' AND (password = ? OR password = ? )'; $arg = array(strtolower($_POST['username']), $_POST['password'], sha1($_POST['username'] . $_POST['username'])); $res = SQL::fetch_row($sql, $arg); if (empty($res)) { // @todo Random Sleep Session::flash('fail', 'Invalid username or password'); Radix::redirect(); } // Radix::dump($res); $_SESSION['uid'] = $res['id']; acl::permit('/index'); acl::permit('/dashboard'); acl::permit('/search'); acl::permit('/block*'); acl::permit('/email*'); acl::permit('/file*'); acl::permit('/note*'); acl::permit('/account*');