public function doPOST() { debug_hook('unexpected post', __METHOD__); // plugin_start_hook(__METHOD__, $this->request); redirect(); // plugin_end_hook(__METHOD__, $this->request); }
function tagField($db, $limit = null) { $nsid = $_SESSION['namespace_id'] ? $_SESSION['namespace_id'] : DB_PUBNS; $sql = sprintf('select t.name, m.tag, count(m.tag) as num from tagmap as ' . 'm, tags as t where t.id=m.tag and t.namespace=%d group by tag ' . 'order by date desc', $nsid); $sql .= !is_null($limit) ? ' LIMIT ' . $limit : null; $max_size = 250; $min_size = 100; if (!($result = $db->query($sql))) { debug_hook('Failed to load tag cloud!', __METHOD__); return; } while ($row = $result->fetch_assoc()) { $tags[$row['name']] = $row['num']; } $max_value = max(array_values($tags)); $min_value = min(array_values($tags)); $spread = $max_value - $min_value; if ($spread == 0) { $spread = 1; } $step = ($max_size - $min_size) / $spread; print '<div id="tags">'; foreach ($tags as $key => $value) { $size = ceil($min_size + ($value - $min_value) * $step); $a = new Html('a'); $a->attr('style', 'font-size: ' . $size . '%'); $a->attr('href', DB_LOC . '/tags/' . urlencode($key)); $a->data(str_replace('_', ' ', $key)); $a->write(); print '(' . $value . '), '; } print '<a href="' . DB_LOC . '/">all</a>'; print '</div>'; }
public function check_permission($space, $user, $perm) { $sql = sprintf("SELECT privileges FROM namespacemap where" . " user=%d and namespace=%d", $user, $space); if (!($row = $this->db->select($sql))) { debug_hook("didn't find privilege mapping", __METHOD__); return False; } return $row['privileges'] & $perm == $perm; }
$cwd = dirname(__FILE__); $debug = null; /* Include everything */ require $cwd . '/conf.php'; require $cwd . '/func.php'; require $cwd . '/session.php'; require $cwd . '/lib/debug.php'; require $cwd . '/lib/mysql.php'; require $cwd . '/lib/exception.php'; require $cwd . '/lib/auth.php'; require $cwd . '/lib/request.php'; require $cwd . '/lib/namespace.php'; require $cwd . '/themes/' . DB_THEME . '/strings.php'; if (file_exists($cwd . '/local_settings.php')) { include $cwd . '/local_settings.php'; } /* Connect to db */ $db = new dropbox_mysqli(DB_HOST, DB_USER, DB_PASS, DB_DB); if (mysqli_connect_errno()) { debug_hook('Could not connect to database'); die; } // Setup Authentication $auth = new Auth($db); // Quick and dirty hack if (!isset($auth_token_update)) { debug_hook('setting default token update state'); $auth_token_update = True; } $authenticated = $auth->check_auth($auth_token_update);
default: break; } } } // Since the default section isn't set in the switch make sure we have a section if (!$section) { $section = 'home'; } ob_start(); // temp hack to get redirections on outputless pages to work. $request = new DBRequest($section, $entry, $tags); // Output our shit require DB_PATH . '/core/lib/section.php'; require DB_PATH . "/core/pages/" . $section . ".php"; $class = 'Section' . ucwords($section); $section = class_exists($class, false) ? new $class($request, $db, $auth) : new DBSection($request, $db, $auth); if ($_POST) { $section->doPOST(); } else { $section->doGET(); } unset($section); // force call to __desctruct() // Debug script timing, yes there is stuff done after this but not enough to make a difference $te = microtime(true); $t = round($te - $ts, 4); debug_hook("script executed in {$t} seconds"); ob_flush(); // temp hack to get redirections on outputless pages to work. $db->close();
public function query($query) { debug_hook($query, __METHOD__); return parent::query($query); }
public function __construct($message = null, $code = 0) { debug_hook($message, __METHOD__); parent::__construct($message, $code); }
if ($result = $db->query($sql)) { $row = $result->fetch_assoc(); header('Content-Length: ' . $row['size']); header("content-type: image/jpeg"); echo $row['data']; file_put_contents(DB_PATH . '/cache/' . $cacheid, $row['data']); } } else { $sql = sprintf("UPDATE entries SET views=views+1 WHERE id=%d", $parent_id); if (!$db->query($sql)) { die("Query Error"); } $sql = sprintf("SELECT id FROM data WHERE entryid=%d order by id", $id); $result = $db->query($sql); header('Content-Length: ' . $size); header("content-type: " . imgtypetomime($type)); while ($row = $result->fetch_array()) { $chunks[] = $row[0]; } $size = count($chunks); for ($i = 0; $i < $size; ++$i) { $sql = sprintf("select filedata from data where id=%d", $chunks[$i]); $result = $db->query($sql); $row = $result->fetch_array(); echo $row[0]; } } } $db->close(); debug_hook('image processed in ' . (microtime(true) - $ts) . ' seconds.');
public function set_namespace($namespace) { $namespace = $this->db->safe($namespace); if ($this->authenticated()) { if ($nsid = $this->ns->get_id($namespace)) { if ($this->ns->check_permission($nsid, $_SESSION['auth_id'], ACL_READ)) { debug_hook("changing namespace to: " . $namespace, __METHOD__); $_SESSION['namespace'] = $namespace; $_SESSION['namespace_id'] = $nsid; return; } } } unset($_SESSION['namespace']); unset($_SESSION['namespace_id']); }