Example #1
0
function groups($request)
{
    $comments = loadcomments($request);
    /*if (loggedin()) {
    		$subs="";
    		foreach ($_SESSION["subscribed"] as $sub) {
    			$subs.='<a href="index.php?q='.$sub["url"].'" class="subitem"><span>'.$sub["name"].'</span></a>';
    		}
    		$header='
    				<div id="navbarlinks">
    					<a target=_blank href="http://www.reddit.com/u/'.$_SESSION["username"].'">+'.$_SESSION["username"].'</a>
    					<div id="subtoggle" href="#">
    						<div id="subscribed">
    							'.$subs.'
    						</div>
    						subscribed
    					</div>
    				</div>
    				<div id="navbarmenu">
    					<div id="navbarmenuicon"></div>
    					<div id="navbarmenunotification"></div>
    					<div id="navbarmenuadd"></div>
    					<div id="navbarmenuprofile" tabindex="1">
    						<a href="index.php?action=logout" id="navbarlogout">
    							Logout
    						</a>
    					</div>
    				</div>';
    	} else {
    		$header='<div id="navbarmenu">
    					<div id="navbarmenuicon"></div>
    					<label for="logincheckbox" id="navbarmenubutton">Sign In</label>
    					<input type="checkbox" id="logincheckbox" value="1" style="display:none;">
    					<div id="navbarlogin">
    						<form method="post">
    							<input type="hidden" name="q" value="'.$_SESSION["query"].'">
    							<input type="hidden" name="action" value="login">
    							<input type="text" name="username" placeholder="User">
    							<input type="password" name="password" placeholder="Password">
    							<button id="loginbutton" type="submit">Sign In</button>
    						</form>
    					</div>
    				</div>';
    	}*/
    $header = '<div id="navbarmenu">
					<div id="navbarmenuicon"></div>
					<div id="navbarmenubutton">Sign In</div>
				</div>';
    echo '
		<!DOCTYPE HTML>
		<head>
			<meta charset="utf-8">
			<title>Cluffle Groups</title>
			<link rel="shortcut icon" href="gfx/faviconsmall.png" />
			<style>';
    require "css/searchpage.css";
    echo '</style>
			<style>';
    require "css/groups.css";
    echo '</style>
			<script>';
    require "js/jquery-2.1.1.min.js";
    echo '</script>
			<style>
				body {
					position:relative;
					background-color:white;
					padding:0;
					margin:0;
					padding-top:172px;
					min-width:980px;
				}
			</style>
		</head>
		<body>
			<div id="navbar">
				<a href="index.php">
					<img id="logo" src="gfx/logo.png"></img>
				</a>
				<form>
					<input type="text" id="searchbox" name="q" value="' . $_SESSION["query"] . '" autocomplete=off>
					<label id="searchbutton" for="searchbuttoninput">
						<input id="searchbuttoninput" type="submit" style="display:none;">
					</label>
				</form>
				' . $header . '
			</div>
			<img id="snippet1" src="gfx/snippet1.png">
			<img id="snippet2" src="gfx/snippet2.png">
			<img id="snippet3" src="gfx/snippet3.png">
			<div id="content">
				<a id="subredditlink" href="index.php?q=/r/' . $comments["subreddit"] . '">' . $comments["subreddit"] . '</a> <span style="font-size:11px;">&gt;</span><br>
				<span id="threadheader">' . $comments["title"] . '</span><br>
				<span id="threadsubheader">' . $comments["score"] . ' points and ' . $comments["num_comments"] . ' comments.</span><br>';
    foreach ($comments["comments"] as $comment) {
        echo '<div class="comment">
							<div class="iconwrapper">
								<img class="icon" src="gfx/icon.png">
							</div>
							<div class="commentthingywrapper">
								<span class="date">
									' . time_passed($comment["timestamp"]) . '
								</span>
								<img class="commentthingy" src="gfx/commentthingy.png">
							</div>
							<div class="commentcontent" style="padding-left:' . $comment["counter"] * 10 . 'px;">
								<div class="commentuser">
									' . $comment["author"] . '
								</div>
								<div class="commenttext">
									' . $comment["text"] . '
								</div>
							</div>
						</div>';
    }
    echo '
			</div>
	';
}
    }
    if (floor($days)) {
        $timestring .= floor($days) . " days ";
    }
    if (floor($hours)) {
        $timestring .= floor($hours) . " hours ";
    }
    if (floor($minutes)) {
        $timestring .= floor($minutes) . " minutes ";
    }
    if (!floor($minutes) && !floor($hours) && !floor($days)) {
        $timestring .= floor($seconds) . " seconds ";
    }
    return $timestring;
}
echo '
<p>';
// path to file - last update
// echo 'file example last updated '.time_passed(filectime('folder/folder/file')).' ago';
// this file - last update
$diff = time_passed(filectime(__FILE__));
$max = $diff < 10000000;
if ($max) {
    echo 'this file last updated less than 10ksec ago ago';
} else {
    echo 'this file last updated more than 10ksec ago ago';
}
// any timestamp - time passed
//echo time_passed(time()-(2*3600));
echo '
</p>';
Example #3
0
 private function hostlist($hosts)
 {
     $tpl = new Template('page_hosts_hostlist.html');
     foreach ($hosts as $host) {
         $tpl->setVar('hostname', $host['hostname']);
         if ($_SESSION['hosts'][$host['hostname']]['connected']) {
             $nics = 0;
             foreach ($_SESSION['hosts'][$host['hostname']]['hardware']->pciDevice as $device) {
                 if ($device->classId == 512) {
                     $nics++;
                 }
             }
             $tpl->setVars(array('software' => $_SESSION['hosts'][$host['hostname']]['about']->name . ' ' . $_SESSION['hosts'][$host['hostname']]['about']->version, 'memory' => readable_bytes($_SESSION['hosts'][$host['hostname']]['hardware']->memorySize), 'cpucount' => $_SESSION['hosts'][$host['hostname']]['hardware']->cpuInfo->numCpuPackages, 'niccount' => $nics, 'uptime' => time_passed(strtotime($_SESSION['hosts'][$host['hostname']]['runtime']->bootTime))));
             $tpl->parse('hostrow');
         } else {
             $tpl->setVar('software', _('Not connected...'));
             $tpl->parse('hostrow');
         }
     }
     $tpl->setVars(array('label_hosts' => _('Hosts'), 'label_hostname' => _('Hostname'), 'label_software' => _('Software'), 'label_memory' => _('Memory'), 'label_cpucount' => _('CPU count'), 'label_niccount' => _('NIC count'), 'label_uptime' => _('Uptime'), 'label_addhost' => _('Add host')));
     $this->html['content'] = $tpl->get();
 }