Skip to content

Instantly share code, notes, and snippets.

View gsmcwhirter's full-sized avatar

Gregory McWhirter gsmcwhirter

View GitHub Profile
function get_files($dir) {
$data = array();
if(is_dir($dir)) {
if($d = opendir($dir)) {
while(($f = readdir($d)) !== FALSE) {
if($f == ".." || $f == ".") { continue; }
else {
$data[] = sprintf("<a href='%s' rel='lightbox[%s]'><img src='http://www.charmcharter.se/imgsize.php?w=59&amp;h=34&amp;img=%s' width='%s' height='%s'></a>",$dir.$f,ALBUM,$dir.$f,WIDTH,HEIGHT);
}
}
function my_format_number($num)
{
$num = number_format(round($num, 2), 2, ".","");
return substr($num, -2) == "00" ? substr($num,0,-3) : $num;
}
<?php
function scheduleLinkGetScheduleId($id = false) {
$query = "
SELECT
schedule_id
FROM
schedule_links
WHERE
deleted = 0
<?php
$query = "SELECT mapid, kills, games, connections FROM ps_c_map_data ORDER BY games desc";
$result = mysql_query($query)
or die('Sorry, we could not retrieve pending from the database. Please try again.');
$totalmaps = mysql_num_rows($result);
$mapdata = array();
$kpgdata = array();
while ($row=mysql_fetch_array($result, MYSQL_ASSOC))
{
$mapdata[$row['mapid']] = array();
<?php
$query = "SELECT mapid, kills, games, kills/games as kpg, connections, connections/games as cpg FROM ps_c_map_data ORDER BY kpg IS NOT NULL DESC, kpg DESC, games desc";
$result = mysql_query($query)
or die('Sorry, we could not retrieve pending from the database. Please try again.');
$totalmaps = mysql_num_rows($result);
while ($row=mysql_fetch_array($result, MYSQL_ASSOC))
{
$mapid = $row['mapid'];
$kills = (int)$row['kills'];
$games = (int)$row['games'];
<?php
function FileMimeType($file)
{
static $finfo;
if(extension_loaded("fileinfo") || @dl("fileinfo.so"))
{
if(!($finfo instanceOf finfo))
{
$finfo = new finfo(FILEINFO_MIME|FILEINFO_SYMLINK|FILEINFO_PRESERVE_ATIME, SETTINGS::$MimeMagicFile);
}
function (newDoc, oldDoc, cdbuser)
{
var email_regex = new RegExp('^([a-zA-Z0-9_\\-.]+)@(([a-zA-Z0-9\\-]+\\.)+)([a-zA-Z]{2,9})$');
function require(beTrue)
{
if(typeof(beTrue) == 'array')
{
for(testidx in beTrue){
var http = require('http'),
sys = require('sys'),
responseText = '';
var client = http.createClient(7080,'127.0.0.1');
var request = client.request("GET","/api/users.json",{"Accept": "*/*","Host":"127.0.0.1"});
request.on("response", function (r){
r.setEncoding('utf8');
sys.debug(r.statusCode);
r.on("data", function (c){
HTTP/1.1 200 OK
Content-type: application/json
Content-Length: 39
Set-Cookie: connect.sid=d52e4ac997a1cbb4b1c128572b3.1f1ffe1262768417500af8859cc9d7bf; path=/; httpOnly; expires=Wed, 15 Sep 2010 02:59:18 GMT
T: u
9: m
C: o
N: o
Connection: keep-alive
[["Content-Type","text/html; charset=utf-8"],["Content-Length",5230],["Set-Cookie","connect.sid=7dbb34fca3f070aac33cf2c111ef.bcba442beded9890dd246964cfa5e980; path=/; httpOnly; expires=Wed, 15 Sep 2010 22:48:32 GMT"]]