Location: PHPKode > scripts > Noostr > _engine/includes/admin.php
<?php defined('SYSPATH') OR die('No direct access to this file is allowed.');

function get_visits() {
	global $db;
	$return = array();
	$sql = 'select distinct sessionid, userid, count(sessionid) as hits from '.PREFIX.'log group by sessionid with rollup';
	$result = $db->query($sql);
	$return['total'] = $result[count($result) - 1]['hits'];
	$return['unique'] = count($result) - 1;
	return $return;
}

function get_vars($site) {
	$vars = array();
	foreach ($site as $key => $val) {
		if (strpos($key, '_group') !== false) {
			$vars[] = substr($key, 0, strlen($key) - 6);
		}
	}
	return $vars;
}

function newer_version() {
	global $timerstart, $site;
	$return = null;
	// First see if we've done this in the last XX hours
	if ($timerstart - $site->lastUpdateCheck > $site->updateCheckInterval) {
		global $db;
		$ver = array('major' => substr(VERSION, 0, strpos(VERSION, '.')), 'minor' => substr(VERSION, strpos(VERSION, '.') + 1), 'build' => explode('.', BUILD));
		$cur = null;
		$url = APPADDRESS.'/current.json';
		try {
			// Try cURL first, since it's faster.
			$ch = curl_init();
			curl_setopt($ch, CURLOPT_URL, $url);
			curl_setopt($ch, CURLOPT_HEADER, 0);
			ob_start();
			curl_exec($ch);
			curl_close($ch);
			$cur = ob_get_contents();
			ob_end_clean();
		} catch (Exception $e) {
			// cURL failed, let's try the built-in functions.
			try {
				$cur = file_get_contents($url);
			} catch (Exception $e) {
				// Nothing worked, skip new version check.
			}
		}
		if (isset($cur)) {
			if (substr($cur, 0, 2) == '{"') {
				// A valid version info file was found.
				$cur = json_decode($cur, true);
				if ((int)$cur['major'] > (int)$ver['major'] || (int)$cur['minor'] > (int)$ver['minor'] || (int)$cur['build'][0] > (int)$ver['build'][0] || (int)$cur['build'][1] > (int)$ver['build'][1] || (int)$cur['build'][2] > (int)$ver['build'][2]) {
					// Newer version is available.
					$return = (int)$cur['major'].'.'.(int)$cur['minor'].' - '.(int)$cur['build'][0].'.'.(int)$cur['build'][1].'.'.(int)$cur['build'][2];
				}
			}
		}
		$sql = 'update '.PREFIX.'settings_site set `value` = ? where variable = ?';
		$data = array($timerstart, 'lastUpdateCheck');
		$db->query($sql, $data);
	}
	return $return;
}

function get_pages($allpages, $page = null) {
	$pages = array();
	for ($i = 0, $c = count($allpages); $i < $c; $i++) {
		if ($page == null) {
			if ($allpages[$i]['type'] == 'page') {
				$pages[] = $allpages[$i];
			}
		} else {
			if ($allpages[$i]['type'] == 'page' && $allpages[$i]['uid'] == $page) {
				$pages = $allpages[$i];
				if ($pages != null) {
					$pages['content'] = get_page_content($pages['uid']);
				}
			}
		}
	}
	return $pages;
}

function get_page_content($uid) {
	global $db;
	$return = null;
	$sql = 'select description from '.PREFIX.'pages where uid = ?';
	$result = $db->query($sql, $uid);
	if ($result != null) {
		$return = $result[0]['description'];
	}
	return $return;
}

function get_all_roles() {
	global $acl;
	return $acl->getAllRoles();
}
Return current item: Noostr