Ejemplo n.º 1
0
 static function count($force = false)
 {
     global $db;
     $count = get_count('posts');
     if ($count === false || $force) {
         $count = $db->get_var("select count(*) from posts");
         set_count('posts', $count);
     }
     return $count;
 }
Ejemplo n.º 2
0
 static function count($status = '', $force = false)
 {
     global $db, $globals;
     $my_id = SitesMgr::my_id();
     if (!$status) {
         return Link::count('published', $force) + Link::count('queued', $force) + Link::count('discard', $force) + Link::count('abuse', $force) + Link::count('autodiscard', $force);
     }
     $count = get_count("{$my_id}.{$status}");
     if ($count === false || $force) {
         $count = $db->get_var("select count(*) from sub_statuses where id = {$my_id} and status = '{$status}'");
         set_count("{$my_id}.{$status}", $count);
     }
     return $count;
 }
Ejemplo n.º 3
0
 static function count($status = '', $cat = '', $force = false)
 {
     global $db;
     if (!$status) {
         return Link::count('published', $cat, $force) + Link::count('queued', $cat, $force) + Link::count('discard', $cat, $force) + Link::count('abuse', $cat, $force) + Link::count('autodiscard', $cat, $force);
     }
     $count = get_count("{$status}.{$cat}");
     if ($count === false || $force) {
         if ($cat) {
             $cond = " and link_category in ({$cat}) ";
         }
         $count = $db->get_var("select count(*) from links where link_status = '{$status}' {$cond}");
         set_count("{$status}.{$cat}", $count);
     }
     return $count;
 }
Ejemplo n.º 4
0
	static function count($status='', $cat='', $force = false) {
		global $db;

		if (!$status) return Link::count('published', $cat, $force) +
							Link::count('queued', $cat, $force) +
							Link::count('discard', $cat, $force) +
							Link::count('abuse', $cat, $force) +
							Link::count('autodiscard', $cat, $force);


		$count = get_count("$status.$cat");
		if ($count === false || $force) {
			if ($cat) $cond = " and link_category in ($cat) ";
			$count = $db->get_var("select count(*) from links where link_status = '$status' $cond");
			set_count("$status.$cat", $count);
		}
		return $count;
	}
Ejemplo n.º 5
0
		if(file_exists("$file_name")){
			$handle = fopen($file_name, "w+");
			$views = (int) fread($handle, 20)++; //20 bytes is enough for a very large number
			fwrite($handle, $views);
			fclose($handle);
			echo $views;
		}else{
			$handle = fopen($file_name, "w");
			$views = 1;
			fwrite($handle, $views);
			fclose($handle);
			echo "1";
		}
	}*/
function set_count($file_name = "counter.txt")
{
    if (file_exists($file_name)) {
        $views = (int) file_get_contents($file_name) + 1;
        file_put_contents($file_name, $views);
        //overwrite the existing file contents
        return $views;
    } else {
        $handle = fopen($file_name, "w+");
        $views = 1;
        fwrite($handle, $views);
        fclose($handle);
        return $views;
    }
}
$count = set_count();
require "index.tmpl.php";
Ejemplo n.º 6
0
 static function count($status = '', $cat = '', $force = false)
 {
     global $db, $globals;
     $my_id = SitesMgr::my_id();
     if (!$status) {
         return Link::count('published', $cat, $force) + Link::count('queued', $cat, $force) + Link::count('discard', $cat, $force) + Link::count('abuse', $cat, $force) + Link::count('autodiscard', $cat, $force);
     }
     $count = get_count("{$my_id}.{$status}.{$cat}");
     if ($count === false || $force) {
         if (!empty($cat)) {
             $extra = "and category in ({$cat})";
         } else {
             $extra = '';
         }
         $count = $db->get_var("select count(*) from sub_statuses where id = {$my_id} and status = '{$status}' {$extra}");
         set_count("{$my_id}.{$status}.{$cat}", $count);
     }
     return $count;
 }