inital commit

This commit is contained in:
2026-06-19 20:08:01 +06:00
commit 8a5abeeae4
13128 changed files with 3192007 additions and 0 deletions

View File

@@ -0,0 +1,114 @@
<?php
/**
* MyBB 1.8
* Copyright 2014 MyBB Group, All Rights Reserved
*
* Website: http://www.mybb.com
* License: http://www.mybb.com/about/license
*
*/
/**
* APC Cache Handler
*/
class apcCacheHandler implements CacheHandlerInterface
{
/**
* Unique identifier representing this copy of MyBB
*
* @var string
*/
public $unique_id;
function __construct()
{
global $mybb;
if(!function_exists("apc_fetch"))
{
// Check if our DB engine is loaded
if(!extension_loaded("apc"))
{
// Throw our super awesome cache loading error
$mybb->trigger_generic_error("apc_load_error");
die;
}
}
}
/**
* Connect and initialize this handler.
*
* @return boolean True if successful, false on failure
*/
function connect()
{
// Set a unique identifier for all queries in case other forums on this server also use this cache handler
$this->unique_id = md5(MYBB_ROOT);
return true;
}
/**
* Connect and initialize this handler.
*
* @param string $name
* @return boolean True if successful, false on failure
*/
function fetch($name)
{
if(apc_exists($this->unique_id."_".$name))
{
$data = apc_fetch($this->unique_id."_".$name);
return unserialize($data);
}
return false;
}
/**
* Write an item to the cache.
*
* @param string $name The name of the cache
* @param mixed $contents The data to write to the cache item
* @return boolean True on success, false on failure
*/
function put($name, $contents)
{
$status = apc_store($this->unique_id."_".$name, serialize($contents));
return $status;
}
/**
* Delete a cache
*
* @param string $name The name of the cache
* @return boolean True on success, false on failure
*/
function delete($name)
{
return apc_delete($this->unique_id."_".$name);
}
/**
* Disconnect from the cache
*
* @return bool
*/
function disconnect()
{
return true;
}
/**
* @param string $name
*
* @return string
*/
function size_of($name='')
{
global $lang;
return $lang->na;
}
}

View File

@@ -0,0 +1,126 @@
<?php
/**
* MyBB 1.8
* Copyright 2014 MyBB Group, All Rights Reserved
*
* Website: http://www.mybb.com
* License: http://www.mybb.com/about/license
*
*/
/**
* Disk Cache Handler
*/
class diskCacheHandler implements CacheHandlerInterface
{
/**
* Connect and initialize this handler.
*
* @return boolean True if successful, false on failure
*/
function connect()
{
if(!@is_writable(MYBB_ROOT."cache"))
{
return false;
}
return true;
}
/**
* Retrieve an item from the cache.
*
* @param string $name The name of the cache
* @return mixed Cache data if successful, false if failure
*/
function fetch($name)
{
if(!@file_exists(MYBB_ROOT."/cache/{$name}.php"))
{
return false;
}
@include(MYBB_ROOT."/cache/{$name}.php");
// Return data
return $$name;
}
/**
* Write an item to the cache.
*
* @param string $name The name of the cache
* @param mixed $contents The data to write to the cache item
* @return boolean True on success, false on failure
*/
function put($name, $contents)
{
global $mybb;
if(!is_writable(MYBB_ROOT."cache"))
{
$mybb->trigger_generic_error("cache_no_write");
return false;
}
$cache_file = fopen(MYBB_ROOT."cache/{$name}.php", "w") or $mybb->trigger_generic_error("cache_no_write");
flock($cache_file, LOCK_EX);
$cache_contents = "<?php\ndeclare(encoding='UTF-8');\n\n/** MyBB Generated Cache - Do Not Alter\n * Cache Name: $name\n * Generated: ".gmdate("r")."\n*/\n\n";
$cache_contents .= "\$$name = ".var_export($contents, true).";\n\n?>";
fwrite($cache_file, $cache_contents);
flock($cache_file, LOCK_UN);
fclose($cache_file);
return true;
}
/**
* Delete a cache
*
* @param string $name The name of the cache
* @return boolean True on success, false on failure
*/
function delete($name)
{
return @unlink(MYBB_ROOT."/cache/{$name}.php");
}
/**
* Disconnect from the cache
*
* @return bool
*/
function disconnect()
{
return true;
}
/**
* Select the size of the disk cache
*
* @param string $name The name of the cache
* @return integer the size of the disk cache
*/
function size_of($name='')
{
if($name != '')
{
return @filesize(MYBB_ROOT."/cache/{$name}.php");
}
else
{
$total = 0;
$dir = opendir(MYBB_ROOT."/cache");
while(($file = readdir($dir)) !== false)
{
if($file == "." || $file == ".." || $file == ".svn" || !is_file(MYBB_ROOT."/cache/{$file}"))
{
continue;
}
$total += filesize(MYBB_ROOT."/cache/{$file}");
}
return $total;
}
}
}

View File

@@ -0,0 +1,116 @@
<?php
/**
* MyBB 1.8
* Copyright 2014 MyBB Group, All Rights Reserved
*
* Website: http://www.mybb.com
* License: http://www.mybb.com/about/license
*
*/
/**
* eAccelerator Cache Handler
*/
class eacceleratorCacheHandler implements CacheHandlerInterface
{
/**
* Unique identifier representing this copy of MyBB
*
* @var string
*/
public $unique_id;
function __construct()
{
global $mybb;
if(!function_exists("eaccelerator_get"))
{
// Check if our DB engine is loaded
if(!extension_loaded("Eaccelerator"))
{
// Throw our super awesome cache loading error
$mybb->trigger_generic_error("eaccelerator_load_error");
die;
}
}
}
/**
* Connect and initialize this handler.
*
* @return boolean True if successful, false on failure
*/
function connect()
{
// Set a unique identifier for all queries in case other forums on this server also use this cache handler
$this->unique_id = md5(MYBB_ROOT);
return true;
}
/**
* Retrieve an item from the cache.
*
* @param string $name The name of the cache
* @return mixed Cache data if successful, false if failure
*/
function fetch($name)
{
$data = eaccelerator_get($this->unique_id."_".$name);
if($data === false)
{
return false;
}
return unserialize($data);
}
/**
* Write an item to the cache.
*
* @param string $name The name of the cache
* @param mixed $contents The data to write to the cache item
* @return boolean True on success, false on failure
*/
function put($name, $contents)
{
eaccelerator_lock($this->unique_id."_".$name);
$status = eaccelerator_put($this->unique_id."_".$name, serialize($contents));
eaccelerator_unlock($this->unique_id."_".$name);
return $status;
}
/**
* Delete a cache
*
* @param string $name The name of the cache
* @return boolean True on success, false on failure
*/
function delete($name)
{
return eaccelerator_rm($this->unique_id."_".$name);
}
/**
* Disconnect from the cache
*
* @return bool
*/
function disconnect()
{
return true;
}
/**
* @param string $name
*
* @return string
*/
function size_of($name='')
{
global $lang;
return $lang->na;
}
}

View File

@@ -0,0 +1,8 @@
<html>
<head>
<title></title>
</head>
<body>
&nbsp;
</body>
</html>

View File

@@ -0,0 +1,61 @@
<?php
/**
* MyBB 1.8
* Copyright 2014 MyBB Group, All Rights Reserved
*
* Website: http://www.mybb.com
* License: http://www.mybb.com/about/license
*
*/
/**
* Cache Handler Interface
*/
interface CacheHandlerInterface
{
/**
* Connect and initialize this handler.
*
* @return boolean True if successful, false on failure
*/
function connect();
/**
* Connect and initialize this handler.
*
* @param string $name
* @return boolean True if successful, false on failure
*/
function fetch($name);
/**
* Write an item to the cache.
*
* @param string $name The name of the cache
* @param mixed $contents The data to write to the cache item
* @return boolean True on success, false on failure
*/
function put($name, $contents);
/**
* Delete a cache
*
* @param string $name The name of the cache
* @return boolean True on success, false on failure
*/
function delete($name);
/**
* Disconnect from the cache
*
* @return bool
*/
function disconnect();
/**
* @param string $name
*
* @return string
*/
function size_of($name='');
}

View File

@@ -0,0 +1,157 @@
<?php
/**
* MyBB 1.8
* Copyright 2014 MyBB Group, All Rights Reserved
*
* Website: http://www.mybb.com
* License: http://www.mybb.com/about/license
*
*/
/**
* Memcache Cache Handler
*/
class memcacheCacheHandler implements CacheHandlerInterface
{
/**
* The memcache server resource
*
* @var Memcache
*/
public $memcache;
/**
* Unique identifier representing this copy of MyBB
*
* @var string
*/
public $unique_id;
function __construct()
{
global $mybb;
if(!function_exists("memcache_connect"))
{
// Check if our DB engine is loaded
if(!extension_loaded("Memcache"))
{
// Throw our super awesome cache loading error
$mybb->trigger_generic_error("memcache_load_error");
die;
}
}
}
/**
* Connect and initialize this handler.
*
* @return boolean True if successful, false on failure
*/
function connect()
{
global $mybb, $error_handler;
$this->memcache = new Memcache;
if($mybb->config['memcache']['host'])
{
$mybb->config['memcache'][0] = $mybb->config['memcache'];
unset($mybb->config['memcache']['host']);
unset($mybb->config['memcache']['port']);
}
foreach($mybb->config['memcache'] as $memcache)
{
if(!$memcache['host'])
{
$message = "Please configure the memcache settings in inc/config.php before attempting to use this cache handler";
$error_handler->trigger($message, MYBB_CACHEHANDLER_LOAD_ERROR);
die;
}
if(!isset($memcache['port']))
{
$memcache['port'] = "11211";
}
$this->memcache->addServer($memcache['host'], $memcache['port']);
if(!$this->memcache)
{
$message = "Unable to connect to the memcache server on {$memcache['memcache_host']}:{$memcache['memcache_port']}. Are you sure it is running?";
$error_handler->trigger($message, MYBB_CACHEHANDLER_LOAD_ERROR);
die;
}
}
// Set a unique identifier for all queries in case other forums are using the same memcache server
$this->unique_id = md5(MYBB_ROOT);
return true;
}
/**
* Retrieve an item from the cache.
*
* @param string $name The name of the cache
* @return mixed Cache data if successful, false if failure
*/
function fetch($name)
{
$data = $this->memcache->get($this->unique_id."_".$name);
if($data === false)
{
return false;
}
else
{
return $data;
}
}
/**
* Write an item to the cache.
*
* @param string $name The name of the cache
* @param mixed $contents The data to write to the cache item
* @return boolean True on success, false on failure
*/
function put($name, $contents)
{
return $this->memcache->set($this->unique_id."_".$name, $contents);
}
/**
* Delete a cache
*
* @param string $name The name of the cache
* @return boolean True on success, false on failure
*/
function delete($name)
{
return $this->memcache->delete($this->unique_id."_".$name);
}
/**
* Disconnect from the cache
*/
function disconnect()
{
@$this->memcache->close();
}
/**
* @param string $name
*
* @return string
*/
function size_of($name='')
{
global $lang;
return $lang->na;
}
}

View File

@@ -0,0 +1,157 @@
<?php
/**
* MyBB 1.8
* Copyright 2014 MyBB Group, All Rights Reserved
*
* Website: http://www.mybb.com
* License: http://www.mybb.com/about/license
*
*/
/**
* Memcached Cache Handler
*/
class memcachedCacheHandler implements CacheHandlerInterface
{
/**
* The memcached server resource
*
* @var Memcached
*/
public $memcached;
/**
* Unique identifier representing this copy of MyBB
*
* @var string
*/
public $unique_id;
function __construct()
{
global $mybb;
if(!function_exists("memcached_connect"))
{
// Check if our Memcached extension is loaded
if(!extension_loaded("Memcached"))
{
// Throw our super awesome cache loading error
$mybb->trigger_generic_error("memcached_load_error");
die;
}
}
}
/**
* Connect and initialize this handler.
*
* @return boolean True if successful, false on failure
*/
function connect()
{
global $mybb, $error_handler;
$this->memcached = new Memcached;
if($mybb->config['memcache']['host'])
{
$mybb->config['memcache'][0] = $mybb->config['memcache'];
unset($mybb->config['memcache']['host']);
unset($mybb->config['memcache']['port']);
}
foreach($mybb->config['memcache'] as $memcached)
{
if(!$memcached['host'])
{
$message = "Please configure the memcache settings in inc/config.php before attempting to use this cache handler";
$error_handler->trigger($message, MYBB_CACHEHANDLER_LOAD_ERROR);
die;
}
if(!isset($memcached['port']))
{
$memcached['port'] = "11211";
}
$this->memcached->addServer($memcached['host'], $memcached['port']);
if(!$this->memcached)
{
$message = "Unable to connect to the memcached server on {$memcached['memcache_host']}:{$memcached['memcache_port']}. Are you sure it is running?";
$error_handler->trigger($message, MYBB_CACHEHANDLER_LOAD_ERROR);
die;
}
}
// Set a unique identifier for all queries in case other forums are using the same memcache server
$this->unique_id = md5(MYBB_ROOT);
return true;
}
/**
* Retrieve an item from the cache.
*
* @param string $name The name of the cache
* @return mixed Cache data if successful, false if failure
*/
function fetch($name)
{
$data = $this->memcached->get($this->unique_id."_".$name);
if($data === false)
{
return false;
}
else
{
return $data;
}
}
/**
* Write an item to the cache.
*
* @param string $name The name of the cache
* @param mixed $contents The data to write to the cache item
* @return boolean True on success, false on failure
*/
function put($name, $contents)
{
return $this->memcached->set($this->unique_id."_".$name, $contents);
}
/**
* Delete a cache
*
* @param string $name The name of the cache
* @return boolean True on success, false on failure
*/
function delete($name)
{
return $this->memcached->delete($this->unique_id."_".$name);
}
/**
* Disconnect from the cache
*/
function disconnect()
{
@$this->memcached->quit();
}
/**
* @param string $name
*
* @return string
*/
function size_of($name='')
{
global $lang;
return $lang->na;
}
}

View File

@@ -0,0 +1,111 @@
<?php
/**
* MyBB 1.8
* Copyright 2014 MyBB Group, All Rights Reserved
*
* Website: http://www.mybb.com
* License: http://www.mybb.com/about/license
*
*/
/**
* Xcache Cache Handler
*/
class xcacheCacheHandler implements CacheHandlerInterface
{
/**
* Unique identifier representing this copy of MyBB
*
* @var string
*/
public $unique_id;
function __construct()
{
global $mybb;
if(!function_exists("xcache_get"))
{
// Check if our DB engine is loaded
if(!extension_loaded("XCache"))
{
// Throw our super awesome cache loading error
$mybb->trigger_generic_error("xcache_load_error");
die;
}
}
}
/**
* Connect and initialize this handler.
*
* @return boolean True if successful, false on failure
*/
function connect()
{
// Set a unique identifier for all queries in case other forums on this server also use this cache handler
$this->unique_id = md5(MYBB_ROOT);
return true;
}
/**
* Retrieve an item from the cache.
*
* @param string $name The name of the cache
* @return mixed Cache data if successful, false if failure
*/
function fetch($name)
{
if(!xcache_isset($this->unique_id."_".$name))
{
return false;
}
return xcache_get($this->unique_id."_".$name);
}
/**
* Write an item to the cache.
*
* @param string $name The name of the cache
* @param mixed $contents The data to write to the cache item
* @return boolean True on success, false on failure
*/
function put($name, $contents)
{
return xcache_set($this->unique_id."_".$name, $contents);
}
/**
* Delete a cache
*
* @param string $name The name of the cache
* @return boolean True on success, false on failure
*/
function delete($name)
{
return xcache_set($this->unique_id."_".$name, "", 1);
}
/**
* Disconnect from the cache
*
* @return bool
*/
function disconnect()
{
return true;
}
/**
* @param string $name
*
* @return string
*/
function size_of($name='')
{
global $lang;
return $lang->na;
}
}