Example #1
0
				LIMIT 5");
			$News = $DB->to_array();
			$Cache->cache_value('news',$News,1209600);
		}
		foreach ($News as $NewsItem) {
			list($NewsID,$Title,$Body,$NewsTime) = $NewsItem;
			echo $Feed->item($Title, $Text->strip_bbcode($Body), 'index.php#'.$NewsID, SITE_NAME.' Staff','','',$NewsTime);
		}
		break;
	case 'feed_blog': 
		include(SERVER_ROOT.'/classes/class_text.php');
		$Text = new TEXT;
		$Feed->channel('Blog', 'RSS feed for site blog.');
		if (!$Blog = $Cache->get_value('blog')) {
			require(SERVER_ROOT.'/classes/class_mysql.php'); //Require the database wrapper
			$DB=NEW DB_MYSQL; //Load the database wrapper
			$DB->query("SELECT
				b.ID,
				um.Username,
				b.Title,
				b.Body,
				b.Time,
				b.ThreadID
				FROM blog AS b LEFT JOIN users_main AS um ON b.UserID=um.ID
				ORDER BY Time DESC
				LIMIT 20");
			$Blog = $DB->to_array();
			$Cache->cache_value('Blog',$Blog,1209600);
		}
		foreach ($Blog as $BlogItem) {
			list($BlogID, $Author, $Title, $Body, $BlogTime, $ThreadID) = $BlogItem;
Example #2
0
    $DB->query("\n\t\tSELECT Token, Name\n\t\tFROM api_applications\n\t\tWHERE ID = '{$AppID}'\n\t\tLIMIT 1");
    $App = $DB->to_array(false, MYSQLI_ASSOC);
    $Cache->cache_value("api_apps_{$AppID}", $App, 0);
}
$App = $App[0];
//Handle our request auths
if ($_GET['req'] === 'access_request') {
    if (md5($App['Token']) !== $_GET['key']) {
        error('invalid');
    }
} else {
    $User = $Cache->get_value("api_users_{$UserID}");
    if (!is_array($User)) {
        if (!isset($DB)) {
            require SERVER_ROOT . '/classes/mysql.class.php';
            $DB = new DB_MYSQL();
        }
        $DB->query("\n\t\t\tSELECT AppID, Token, State, Time, Access\n\t\t\tFROM api_users\n\t\t\tWHERE UserID = '{$UserID}'\n\t\t\tLIMIT 1");
        //int, no db_string
        $User = $DB->to_array('AppID', MYSQLI_ASSOC);
        $Cache->cache_value("api_users_{$UserID}", $User, 0);
    }
    $User = $User[$AppID];
    if (md5($User['Token'] . $App['Token']) !== $_GET['key']) {
        error('invalid');
    }
}
die('API put on hold');
require SERVER_ROOT . '/sections/api/' . $_GET['req'] . '.php';
echo '</payload>';
$Debug->profile();
Example #3
0
require SERVER_ROOT . '/classes/mysql.class.php';
//Require the database wrapper
require SERVER_ROOT . '/classes/cache.class.php';
//Require the caching class
require SERVER_ROOT . '/classes/encrypt.class.php';
//Require the encryption class
require SERVER_ROOT . '/classes/time.class.php';
//Require the time class
require SERVER_ROOT . '/classes/paranoia.class.php';
//Require the paranoia check_paranoia function
require SERVER_ROOT . '/classes/regex.php';
require SERVER_ROOT . '/classes/util.php';
$Debug = new DEBUG();
$Debug->handle_errors();
$Debug->set_flag('Debug constructed');
$DB = new DB_MYSQL();
$Cache = new CACHE($MemcachedServers);
$Enc = new CRYPT();
// Autoload classes.
require SERVER_ROOT . '/classes/classloader.php';
// Note: G::initialize is called twice.
// This is necessary as the code inbetween (initialization of $LoggedUser) makes use of G::$DB and G::$Cache.
// TODO: remove one of the calls once we're moving everything into that class
G::initialize();
//Begin browser identification
$Browser = UserAgent::browser($_SERVER['HTTP_USER_AGENT']);
$OperatingSystem = UserAgent::operating_system($_SERVER['HTTP_USER_AGENT']);
//$Mobile = UserAgent::mobile($_SERVER['HTTP_USER_AGENT']);
$Mobile = in_array($_SERVER['HTTP_HOST'], array('m.' . NONSSL_SITE_URL, 'm.' . NONSSL_SITE_URL));
$Debug->set_flag('start user handling');
// Get classes
Example #4
0
<?php

require "/home/ptpimg/config.dat";
require "misc.class.php";
require "sql.class.php";
require "cache.php";
$DB = new DB_MYSQL();
$Cache = new CACHE();
if (isset($_GET['action']) && !empty($_GET['action'])) {
    $Action = $_GET['action'];
} else {
    die("json_request");
}
function getImageCount()
{
    global $DB, $Cache;
    if ((list($Count) = $Cache->get_value('ptpimg_sql_counts')) === false) {
        $DB->query("SELECT Count(ID) FROM uploads");
        list($Count) = $DB->next_record();
        $Cache->cache_value('ptpimg_sql_counts', array($Count), 60);
        // 30 minutes
    }
    return $Count;
}
function getTotalSize()
{
    global $DB, $Cache;
    if ((list($Size) = $Cache->get_value('ptpimg_sql_size')) === false) {
        $DB->query("SELECT SUM(Size) FROM uploads");
        list($Size) = $DB->next_record();
        $Cache->cache_value('ptpimg_sql_size', array($Size), 60);
Example #5
0
ob_start(); //Start a buffer, mainly in case there is a mysql error


require(SERVER_ROOT.'/classes/class_debug.php'); //Require the debug class
require(SERVER_ROOT.'/classes/class_mysql.php'); //Require the database wrapper
require(SERVER_ROOT.'/classes/class_cache.php'); //Require the caching class
require(SERVER_ROOT.'/classes/class_encrypt.php'); //Require the encryption class
require(SERVER_ROOT.'/classes/class_useragent.php'); //Require the useragent class
require(SERVER_ROOT.'/classes/class_time.php'); //Require the time class
require(SERVER_ROOT.'/classes/class_search.php'); //Require the searching class

$Debug = new DEBUG;
$Debug->handle_errors();

$DB = new DB_MYSQL;
$Cache = new CACHE;
$Enc = new CRYPT;
$UA = new USER_AGENT;
$SS = new SPHINX_SEARCH;




//resource_type://username:password@domain:port/path?query_string#anchor
define('RESOURCE_REGEX','(https?|ftps?):\/\/');
define('IP_REGEX','(\d{1,3}\.){3}\d{1,3}');
define('DOMAIN_REGEX','(ssl.)?(www.)?[a-z0-9-\.]{1,255}\.[a-zA-Z]{2,6}');
define('PORT_REGEX', '\d{1,5}');
define('URL_REGEX','('.RESOURCE_REGEX.')('.IP_REGEX.'|'.DOMAIN_REGEX.')(:'.PORT_REGEX.')?(\/\S+)*');
define('EMAIL_REGEX','[_a-z0-9-]+([.+][_a-z0-9-]+)*@'.DOMAIN_REGEX);
Example #6
0
<?php

require "/home/ptpimg/config.dat";
require "misc.class.php";
require "sql.class.php";
require "cache.php";
$DB = new DB_MYSQL();
$Cache = new CACHE();
session_start();
require_once 'jpgraph/jpgraph.php';
require_once 'jpgraph/jpgraph_line.php';
require_once 'jpgraph/jpgraph_mgraph.php';
//------------------------------------------------------------------
// Create some random data for the plot. We use the current time for the
// first X-position
//------------------------------------------------------------------
$datay = array();
$datax = array();
$datay2 = array();
$ts = time();
if (isset($_GET['i']) && is_numeric($_GET['i'])) {
    $Interval = $_GET['i'];
} else {
    $Interval = 1;
}
// This is for the totals
// Data sets are too big for 12-48 hours
$Extra = '';
if ($Interval > 12) {
    $Extra = "AND DATE_FORMAT(Time, '%i') IN (0,15,30,45)";
}
Example #7
0
File: v8.php Project: morilo/ptpimg
}
if (!isset($_GET['nolimit'])) {
    if (!isset($_GET['id']) || !is_numeric($_GET['id'])) {
        $ID = 0;
    } else {
        $ID = $_GET['id'];
    }
    $IDExtra = "AND ID>" . $ID . " AND ID<" . ($ID + 20000);
} else {
    $IDExtra = "";
}
error_reporting(0);
require '../config.dat';
require "misc.class.php";
require "sql.class.php";
$DB = new DB_MYSQL();
$Resolution = "";
if (!isset($_GET['v2'])) {
    $v2 == "def";
} else {
    $v2 = $_GET['v2'];
}
if ($v2 == "def") {
    $Resolution = "(resolution='1536x1180' OR\n\t\tresolution='1180x1536' OR\n\t\tresolution='1600x1200' OR\n\t\tresolution='1200x1600' OR\n\t\tresolution='2048x1536' OR\n\t\tresolution='1536x2048' OR\n\t\tresolution='2240x1680' OR\n\t\tresolution='1680x2240' OR\n\t\tresolution='2560x1920' OR\n\t\tresolution='1920x2560' OR\n\t\tresolution='3032x2008' OR\n\t\tresolution='2008x3032' OR\n\t\tresolution='3072x2304' OR\n\t\tresolution='2304x3072' OR\n\t\tresolution='3264x2448' OR\n\t\tresolution='2448x3264')";
} else {
    $Resolution = "resolution='" . db_string($_GET['v2']) . "'";
    $IDExtra = "";
}
$q = "SELECT Code, Extension\n\t\tFROM uploads\n\t\tWHERE\n{$Resolution}\n{$IDExtra}";
$DB->query($q);
$Data = $DB->to_array();
Example #8
0
//The MySQL host ip/fqdn
define('SQLLOGIN', 'ptpimg');
//The MySQL login
define('SQLPASS', 'mri34mni');
//The MySQL password
define('SQLDB', 'ptpimg');
//The MySQL database to use
define('SQLPORT', '3306');
//The MySQL port to connect on
define('SQLSOCK', '/var/run/mysqld/mysqld.sock');
require "sql.class.php";
require "cache.php";
require "class_ua.php";
require "class_user.php";
require "class_encrypt.php";
$DB = new DB_MYSQL();
$Cache = new CACHE();
$User = new USER();
$UA = new USER_AGENT();
$Enc = new CRYPT();
require "misc.class.php";
session_start();
if (!isset($_GET['act']) || empty($_GET['act'])) {
    $_GET['act'] = "def_action";
}
switch ($_GET['act']) {
    case 'login':
    case 'logout':
        //-------------------
        // LOGIN/LOGOUT
        //-------------------
Example #9
0
require(SERVER_ROOT.'/classes/class_encrypt.php'); //Require the caching class
$Cache = NEW CACHE; //Load the caching class
$Enc = NEW CRYPT; //Load the encryption class
date_default_timezone_set('UTC');

if (isset($_COOKIE['session'])) { $LoginCookie=$Enc->decrypt($_COOKIE['session']); }
if(isset($LoginCookie)) {
	list($SessionID, $UserID)=explode("|~|",$Enc->decrypt($LoginCookie));
	
	if(!$UserID || !$SessionID) {
		die('Not logged in!');
	}
	
	if(!$Enabled = $Cache->get_value('enabled_'.$UserID)){
		require(SERVER_ROOT.'/classes/class_mysql.php'); //Require the database wrapper
		$DB=NEW DB_MYSQL; //Load the database wrapper
		$DB->query("SELECT Enabled FROM users_main WHERE ID='$UserID'");
		list($Enabled) = $DB->next_record();
		$Cache->cache_value('enabled_'.$UserID, $Enabled, 0);
	}
} else {
	die('Not logged in!');
}

function error($Error) {
	die($Error);
}

function is_number($Str) {
	if ($Str < 0) { return false; }
	// We're converting input to a int, then string and comparing to original
Example #10
0
<?php

error_reporting(E_ALL ^ E_NOTICE);
require "/home/ptpimg/config.dat";
require "misc.class.php";
require "sql.class.php";
require "cache.php";
$DB = new DB_MYSQL();
$Cache = new CACHE();
session_start();
function getdata($f, $nomd5 = false)
{
    if (!$nomd5) {
        $Md5 = md5_file($f);
    } else {
        $Md5 = "";
    }
    $Type = @exif_imagetype($f);
    switch ($Type) {
        case 1:
            $ext = "gif";
            break;
        case 2:
            $ext = "jpg";
            break;
        case 3:
            $ext = "png";
            break;
    }
    $size = filesize($f);
    list($w, $h, $t, $a) = getimagesize($f);
Example #11
0
<?php

//树形
require_once '../../../include/config.php';
require_once '../../../include/mysql.class.php';
require_once '../../../include/common.fun.php';
/*New DB*/
$dbc = new DB_MYSQL();
$dbc->connect(g_db_host, g_db_user, g_db_pass, g_db_name, 0, 'utf8');
$tree_id = $_REQUEST['tree_id'];
if ($tree_id != '') {
    $sql = "SELECT a.*,(SELECT COUNT(*) FROM " . g_tbl_prefix . "call_nature b WHERE a.id = b.parentid ) as cid_num FROM " . g_tbl_prefix . "call_nature a \r\n\tWHERE 1=1 AND a.active = 1  ";
    $sql .= "AND a.parentid = '{$tree_id}' ";
    $sql .= "ORDER BY a.orders ASC,a.id ASC";
    $q = $dbc->query($sql);
    while ($r = $dbc->fetch_array($q)) {
        $n = $r['cid_num'];
        $list .= "<li id='{$r['id']}'><span class=''>{$r['title']} [ID:{$r['id']} 子类:{$r['cid_num']}]</span>\r\n";
        if ($n > 0) {
            $list .= "<ul class='ajax'>\r\n";
            $list .= "<li id='{$r['email']}'>{url:loadTree.php?tree_id=" . $r['id'] . "}</li>\r\n";
            $list .= "</ul>\r\n";
        }
        $list .= "</li>\r\n";
    }
    echo $list;
}
unset($dbc);
?>
<!--
<li id='35'><span class="text">Tree Node Ajax 1</span></li>
Example #12
0
// 0 is a case of an unknown image type, so you can do whatever you want there
$MimeType = array(0 => 'application/octet-stream', 1 => 'image/gif', 2 => 'image/jpeg', 3 => 'image/png');
$ScriptStartTime = microtime(true);
//To track how long a page takes to create
ob_start();
//Start a buffer, mainly in case there is a mysql error
// Include our dependencies
require ASSETS . '/class_debug.php';
//Require the debug class
require ASSETS . "/class_misc.php";
require ASSETS . "/class_mysql.php";
require ASSETS . "/class_cache.php";
require ASSETS . "/class_encrypt.php";
require ASSETS . "/class_useragent.php";
require ASSETS . "/class_time.php";
$DB = new DB_MYSQL();
$Cache = new CACHE();
$Enc = new CRYPT();
$UA = new USER_AGENT();
$Debug = new DEBUG();
$Debug->handle_errors();
$Debug->set_flag('Debug constructed');
// throw_error(code/message) - any sort of error will go here
// Technically we shouldn't print all the data from these objects.
// The DB object has all the database credentials
function throw_error($c, $Sneaky = false)
{
    echo $c;
    if ($Sneaky) {
        global $DB, $Cache;
        print_r($DB);
Example #13
0
//Load the caching class
$Enc = new CRYPT();
//Load the encryption class
$SSL = $_SERVER['SERVER_PORT'] === '443';
if (isset($_COOKIE['session'])) {
    $LoginCookie = $Enc->decrypt($_COOKIE['session']);
}
if (isset($LoginCookie)) {
    list($SessionID, $UserID) = explode("|~|", $Enc->decrypt($LoginCookie));
    if (!$UserID || !$SessionID) {
        die('Not logged in!');
    }
    if (!($Enabled = $Cache->get_value("enabled_{$UserID}"))) {
        require SERVER_ROOT . '/classes/mysql.class.php';
        //Require the database wrapper
        $DB = new DB_MYSQL();
        //Load the database wrapper
        $DB->query("\n\t\t\tSELECT Enabled\n\t\t\tFROM users_main\n\t\t\tWHERE ID = '{$UserID}'");
        list($Enabled) = $DB->next_record();
        $Cache->cache_value("enabled_{$UserID}", $Enabled, 0);
    }
} else {
    die('Not logged in!');
}
function error($Error)
{
    die($Error);
}
function is_number($Str)
{
    if ($Str < 0) {
Example #14
0
    die("nah");
}
define('SQLHOST', 'localhost');
//The MySQL host ip/fqdn
define('SQLLOGIN', 'ptpimg');
//The MySQL login
define('SQLPASS', 'mri34mni');
//The MySQL password
define('SQLDB', 'ptpimg');
//The MySQL database to use
define('SQLPORT', '3306');
//The MySQL port to connect on
define('SQLSOCK', '/var/run/mysqld/mysqld.sock');
require "misc.class.php";
require "sql.class.php";
$DB = new DB_MYSQL();
$DB->query("SELECT ID, Code FROM uploads WHERE NewHash=''");
$Results = $DB->to_array('', MYSQLI_NUM, false);
$UBound = count($Results);
$QueryCount = 0;
$Query = array();
while (list($Key, list($ID, $Code)) = each($Results)) {
    if ($QueryCount > 500) {
        echo "500 queries, flushing.";
        $x = microtime();
        $x = explode(" ", $x);
        $x = $x[1] + $x[0];
        foreach ($Query as $q) {
            $DB->query($q);
        }
        $y = microtime();
Example #15
0
<?
$UserStats = $Cache->get_value('user_stats_'.$UserID);
if(!is_array($UserStats)) {
	if (!isset($DB)) {
		require(SERVER_ROOT.'/classes/class_mysql.php');
		$DB = new DB_MYSQL;
	}
	$DB->query("SELECT Uploaded AS BytesUploaded, Downloaded AS BytesDownloaded, RequiredRatio FROM users_main WHERE ID='$UserID'");
	$UserStats = $DB->next_record(MYSQLI_ASSOC);
	$Cache->cache_value('user_stats_'.$LoggedUser['ID'], $UserStats, 3600);
}
$Up = $UserStats['BytesUploaded'];
$Down = $UserStats['BytesDownloaded'];
$ReqRat = $UserStats['RequiredRatio'];
if ($Down > 0) {
	$Rat = $Up/$Down;
} else {
	$Rat = 0;
}
?>
<uploaded><?php 
echo $Up;
?>
</uploaded>
<downloaded><?php 
echo $Down;
?>
</downloaded>
<ratio><?php 
echo $Rat;
?>
Example #16
0
     }
     foreach ($Blog as $BlogItem) {
         list($BlogID, $Author, $AuthorID, $Title, $Body, $BlogTime, $ThreadID) = $BlogItem;
         if ($ThreadID) {
             echo $Feed->item($Title, Text::strip_bbcode($Body), "forums.php?action=viewthread&amp;threadid={$ThreadID}", SITE_NAME . ' Staff', '', '', $BlogTime);
         } else {
             echo $Feed->item($Title, Text::strip_bbcode($Body), "blog.php#blog{$BlogID}", SITE_NAME . ' Staff', '', '', $BlogTime);
         }
     }
     break;
 case 'feed_changelog':
     $Feed->channel('Gazelle Change Log', 'RSS feed for Gazelle\'s changelog.');
     if (!($Changelog = $Cache->get_value('changelog'))) {
         require SERVER_ROOT . '/classes/mysql.class.php';
         require SERVER_ROOT . '/classes/misc.class.php';
         $DB = new DB_MYSQL();
         $DB->query("\n\t\t\t\tSELECT Message, Author, Date(Time)\n\t\t\t\tFROM changelog\n\t\t\t\tORDER BY Time DESC\n\t\t\t\tLIMIT 20");
         $Changelog = $DB->to_array();
         $Cache->cache_value('changelog', $Changelog, 86400);
     }
     foreach ($Changelog as $Change) {
         list($Message, $Author, $Date) = $Change;
         echo $Feed->item("{$Date} by {$Author}", $Message, 'tools.php?action=change_log', SITE_NAME . ' Staff', '', '', $Date);
     }
     break;
 case 'torrents_all':
     $Feed->channel('All Torrents', 'RSS feed for all new torrent uploads.');
     $Feed->retrieve('torrents_all', $_GET['authkey'], $_GET['passkey']);
     break;
 case 'torrents_music':
     $Feed->channel('Music Torrents', 'RSS feed for all new music torrents.');