Ejemplo n.º 1
0
function getPage($doc_id)
{
    global $dbase;
    global $table_prefix;
    global $page_cache;
    // If already cached, return this instead of doing another MySQL query
    if (isset($page_cache[$doc_id])) {
        return $page_cache[$doc_id];
    }
    $tblsc = $dbase . "." . $table_prefix . "site_content";
    $tbldg = $dbase . "." . $table_prefix . "document_groups";
    // modify field names to use sc. table reference
    $fields = 'sc.' . implode(',sc.', preg_replace("/^\\s/i", "", explode(',', $fields)));
    $sort = 'sc.' . implode(',sc.', preg_replace("/^\\s/i", "", explode(',', $sort)));
    $sql = "SELECT sc.parent, sc.menutitle, sc.pagetitle, sc.menuindex, sc.published FROM {$tblsc} sc\n      LEFT JOIN {$tbldg} dg on dg.document = sc.id\n      WHERE sc.published=1 AND sc.deleted=0 AND sc.id={$doc_id};";
    $resourceArray = doSql($sql);
    // If we have got this far, it must not have been cached already, so lets do it now.
    $page_cache[$doc_id] = $resourceArray[0];
    return $resourceArray[0];
}
Ejemplo n.º 2
0
            } else {
                if ($mode == "remove") {
                    if (!is_numeric($_GET["timestamp"])) {
                        die;
                    }
                    if ($_GET["type"] == "bump") {
                        doSql("UPDATE counters SET hits = hits - 1 WHERE id={$id}");
                        doSql("DELETE FROM counter_hits WHERE counter_id={$id} AND type='bump' AND `when`=" . $_GET["timestamp"] . " LIMIT 1");
                    } else {
                        if ($_GET["type"] == "reset") {
                            doSql("UPDATE counters SET hits = 0 WHERE id={$id}");
                            doSql("DELETE FROM counter_hits WHERE counter_id={$id} AND type='reset' AND `when`=" . $_GET["timestamp"] . " LIMIT 1");
                        }
                    }
                } else {
                    if ($mode == "reset") {
                        if (!is_numeric($_GET["timestamp"])) {
                            die;
                        }
                        doSql("UPDATE counters SET hits = 0 WHERE id={$id}");
                        doSql("INSERT INTO counter_hits VALUES(NULL, {$id}, 'reset', " . $_GET["timestamp"] . ")");
                    } else {
                        if ($mode == "share") {
                            doSql("UPDATE counters SET share = 1 WHERE id={$id}");
                        }
                    }
                }
            }
        }
    }
}
Ejemplo n.º 3
0
         <div id="counttablewrap">
            <table id="counttable">
               <thead>
                  <tr>
                     <td>Count</td>
                     <td>Type</td>
                     <td>When</td>
                     <td class="hidden"></td>
                     <td></td>
                  </tr>
               </thead>

               <tbody id="counttablebody">
               <?php 
$rows = doSql("SELECT * FROM counter_hits WHERE counter_id={$id} ORDER BY `when` ASC");
if ($rows && count($rows) > 0) {
    $hits = 1;
    for ($i = 0; $i < count($rows); $i++) {
        $row =& $rows[$i];
        if ($row["type"] == "reset") {
            $row["hits"] = "0";
            $hits = 1;
        } else {
            if ($row["type"] == "bump") {
                $row["hits"] = $hits;
                $hits++;
            } else {
                if ($row["type"] == "creation") {
                    $row["hits"] = "0";
                    $hits = 1;