Skip to content

Instantly share code, notes, and snippets.

@blackswansolutions
blackswansolutions / gist:6361909
Last active December 21, 2015 20:29
PHP: Xenforo Loader
// Sets up XenForo App
define('XF_ROOT', '/home/victor/Workspace/candidatovaga/public/forum'); // set this (absolute path)!
define('TIMENOW', time());
$startTime = microtime(true);
define('SESSION_BYPASS', false); // if true: logged in user info and sessions are not needed
require_once(XF_ROOT . '/library/XenForo/Autoloader.php');
XenForo_Autoloader::getInstance()->setupAutoloader(XF_ROOT . '/library');
@blackswansolutions
blackswansolutions / gist:6361906
Last active December 13, 2017 19:38
PHP: Xenforo Session
<?php
class Session {
#Xenforo if logged in function
function isOnline(){
$session = new XenForo_Session();
if (!$session->sessionExists())
{//when user info and sessions are needed
XenForo_Session::startPublicSession();
@blackswansolutions
blackswansolutions / bytesize.php
Created August 9, 2012 17:32 — forked from LaffinToo/bytesize.php
PHP: Tracker - Returns units based on bytes
function ByteSize($size)
{
static $unit = array('B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
$size/=(pow(1024,($idx=floor(log($size)/log(1024)))));
return number_format($size,2).$unit[$idx];
}
@blackswansolutions
blackswansolutions / bracket.php
Created August 9, 2012 17:31 — forked from LaffinToo/bracket.php
PHP: Tourney Bracket System
<?php
$teams=array('Alpha','Beta','Gamma','Delta','Epsilon','Zeta','Eta');
define('MY_EOL','<br .>'.PHP_EOL);
$round=0;
$participants=$teams;
while(count($participants)>1)
{
$round++; // Increment our round