@ -0,0 +1,66 @@
|
||||
config/config.php
|
||||
prototypes/
|
||||
|
||||
# Created by https://www.gitignore.io/api/windows,osx,linux
|
||||
|
||||
### Windows ###
|
||||
# Windows image file caches
|
||||
Thumbs.db
|
||||
ehthumbs.db
|
||||
|
||||
# Folder config file
|
||||
Desktop.ini
|
||||
|
||||
# Recycle Bin used on file shares
|
||||
$RECYCLE.BIN/
|
||||
|
||||
# Windows Installer files
|
||||
*.cab
|
||||
*.msi
|
||||
*.msm
|
||||
*.msp
|
||||
|
||||
# Windows shortcuts
|
||||
*.lnk
|
||||
|
||||
|
||||
### OSX ###
|
||||
*.DS_Store
|
||||
.AppleDouble
|
||||
.LSOverride
|
||||
|
||||
# Icon must end with two \r
|
||||
Icon
|
||||
|
||||
|
||||
# Thumbnails
|
||||
._*
|
||||
|
||||
# Files that might appear in the root of a volume
|
||||
.DocumentRevisions-V100
|
||||
.fseventsd
|
||||
.Spotlight-V100
|
||||
.TemporaryItems
|
||||
.Trashes
|
||||
.VolumeIcon.icns
|
||||
.com.apple.timemachine.donotpresent
|
||||
|
||||
# Directories potentially created on remote AFP share
|
||||
.AppleDB
|
||||
.AppleDesktop
|
||||
Network Trash Folder
|
||||
Temporary Items
|
||||
.apdisk
|
||||
|
||||
|
||||
### Linux ###
|
||||
*~
|
||||
|
||||
# temporary files which can be created if a process still has a handle open of a deleted file
|
||||
.fuse_hidden*
|
||||
|
||||
# KDE directory preferences
|
||||
.directory
|
||||
|
||||
# Linux trash folder which might appear on any partition or disk
|
||||
.Trash-*
|
@ -0,0 +1,43 @@
|
||||
# (c) 2015-2016 Wruczek <wruczekk@gmail.com>
|
||||
|
||||
AddDefaultCharset UTF-8
|
||||
|
||||
# DISABLE DIRECTORY LISTING
|
||||
Options -Indexes
|
||||
|
||||
ErrorDocument 403 "<!DOCTYPE html><html lang=\"pl\"><head> <meta charset=\"utf-8\"> <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\"> <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"> <meta name=\"author\" content=\"Wruczek\"> <title>403 - brak dostępu</title> <link rel=\"shortcut icon\" href=\"img/icon/icon-64.png\" style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;\"></head><body style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;margin: 0;font-family: "Lato","Helvetica Neue",Helvetica,Arial,sans-serif;font-size: 15px;line-height: 1.42857143;color: #ebebeb;background-color: #2b3e50;\"> <div class=\"container\" style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;margin-right: auto;margin-left: auto;padding-left: 15px;padding-right: 15px;display: table;position: absolute;height: 100%;width: 100%;\"> <div class=\"text-center\" style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;text-align: center;display: table-cell;vertical-align: middle;\"> <h1 style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;font-size: 39px;margin: 0.67em 0;font-family: inherit;font-weight: 400;line-height: 1.1;color: inherit;margin-top: 21px;margin-bottom: 10.5px;\">403 <span style=\"font-size: 32px;color: #9E9E9E;-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;\">brak dostępu</span></h1> <h3 style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;orphans: 3;widows: 3;page-break-after: avoid;font-family: inherit;font-weight: 400;line-height: 1.1;color: inherit;margin-top: 21px;margin-bottom: 10.5px;font-size: 26px;\">Nie posiadasz uprawnień do przeglądania tej strony.</h3> <br style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;\"> <a href=\".\" class=\"btn btn-primary btn-lg\" style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;background-color: #df691a;color: #ffffff;text-decoration: none;display: inline-block;margin-bottom: 0;font-weight: normal;text-align: center;vertical-align: middle;-ms-touch-action: manipulation;touch-action: manipulation;cursor: pointer;background-image: none;border: 1px solid transparent;white-space: nowrap;padding: 12px 24px;font-size: 19px;line-height: 1.3333333;border-radius: 0;-webkit-user-select: none;-moz-user-select: none;-ms-user-select: none;user-select: none;border-color: transparent;\">← Powrót</a> </div></div></body></html>"
|
||||
|
||||
ErrorDocument 404 "<!DOCTYPE html><html lang=\"pl\"><head> <meta charset=\"utf-8\"> <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\"> <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"> <meta name=\"author\" content=\"Wruczek\"> <title>404 - nie znaleziono</title> <link rel=\"shortcut icon\" href=\"img/icon/icon-64.png\"></head><body style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;margin: 0;font-family: "Lato","Helvetica Neue",Helvetica,Arial,sans-serif;font-size: 15px;line-height: 1.42857143;color: #ebebeb;background-color: #2b3e50;\"> <div class=\"container\" style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;margin-right: auto;margin-left: auto;padding-left: 15px;padding-right: 15px;display: table;position: absolute;height: 100%;width: 100%;\"> <div class=\"text-center\" style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;text-align: center;display: table-cell;vertical-align: middle;\"> <h1 style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;font-size: 39px;margin: 0.67em 0;font-family: inherit;font-weight: 400;line-height: 1.1;color: inherit;margin-top: 21px;margin-bottom: 10.5px;\">404 <span style=\"font-size: 32px;color: #9E9E9E;-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;\">strony nie znaleziono</span></h1> <h3 style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;orphans: 3;widows: 3;page-break-after: avoid;font-family: inherit;font-weight: 400;line-height: 1.1;color: inherit;margin-top: 21px;margin-bottom: 10.5px;font-size: 26px;\">Strona której szukasz nie została odnaleziona.</h3> <br style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;\"> <a href=\".\" class=\"btn btn-primary btn-lg\" style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;background-color: #df691a;color: #ffffff;text-decoration: none;display: inline-block;margin-bottom: 0;font-weight: normal;text-align: center;vertical-align: middle;-ms-touch-action: manipulation;touch-action: manipulation;cursor: pointer;background-image: none;border: 1px solid transparent;white-space: nowrap;padding: 12px 24px;font-size: 19px;line-height: 1.3333333;border-radius: 0;-webkit-user-select: none;-moz-user-select: none;-ms-user-select: none;user-select: none;border-color: transparent;\">← Powrót</a> </div></div></body></html>"
|
||||
|
||||
ErrorDocument 500 "<!DOCTYPE html><html lang=\"pl\"><head> <meta charset=\"utf-8\"> <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\"> <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"> <meta name=\"author\" content=\"Wruczek\"> <title>500 - błąd serwera</title> <link rel=\"shortcut icon\" href=\"img/icon/icon-64.png\"></head><body style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;margin: 0;font-family: "Lato","Helvetica Neue",Helvetica,Arial,sans-serif;font-size: 15px;line-height: 1.42857143;color: #ebebeb;background-color: #2b3e50;\"> <div class=\"container\" style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;margin-right: auto;margin-left: auto;padding-left: 15px;padding-right: 15px;display: table;position: absolute;height: 100%;width: 100%;\"> <div class=\"text-center\" style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;text-align: center;display: table-cell;vertical-align: middle;\"> <h1 style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;font-size: 39px;margin: 0.67em 0;font-family: inherit;font-weight: 400;line-height: 1.1;color: inherit;margin-top: 21px;margin-bottom: 10.5px;\">500 <span style=\"font-size: 32px;color: #9E9E9E;-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;\">błąd serwera</span></h1> <h3 style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;orphans: 3;widows: 3;page-break-after: avoid;font-family: inherit;font-weight: 400;line-height: 1.1;color: inherit;margin-top: 21px;margin-bottom: 10.5px;font-size: 26px;\">Wystąpił błąd serwera. Spróbuj ponownie później.</h3> <br style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;\"> <a href=\".\" class=\"btn btn-primary btn-lg\" style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;background-color: #df691a;color: #ffffff;text-decoration: none;display: inline-block;margin-bottom: 0;font-weight: normal;text-align: center;vertical-align: middle;-ms-touch-action: manipulation;touch-action: manipulation;cursor: pointer;background-image: none;border: 1px solid transparent;white-space: nowrap;padding: 12px 24px;font-size: 19px;line-height: 1.3333333;border-radius: 0;-webkit-user-select: none;-moz-user-select: none;-ms-user-select: none;user-select: none;border-color: transparent;\">← Powrót</a> </div></div></body></html>"
|
||||
|
||||
|
||||
<IfModule mod_rewrite.c>
|
||||
|
||||
RewriteEngine On
|
||||
|
||||
# REDIRECTING FROM lol.com/page.php or lol.com/page.html to lol.com/page
|
||||
RewriteCond %{THE_REQUEST} \ /(.+)\.php
|
||||
RewriteRule ^ /%1 [L,R=301]
|
||||
RewriteCond %{THE_REQUEST} \ /(.+)\.html
|
||||
RewriteRule ^ /%1 [L,R=301]
|
||||
|
||||
# PAGES WITHOUT .PHP AT THE END
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
RewriteCond %{REQUEST_FILENAME}\.php -f
|
||||
RewriteRule ^(.*)$ $1.php
|
||||
|
||||
# PAGES WITHOUT .HTML AT THE END
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
RewriteCond %{REQUEST_FILENAME}\.html -f
|
||||
RewriteRule ^(.*)$ $1.html
|
||||
|
||||
</IfModule>
|
||||
|
||||
# Enable GZIP
|
||||
<ifmodule mod_deflate.c>
|
||||
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript
|
||||
BrowserMatch ^Mozilla/4 gzip-only-text/html
|
||||
BrowserMatch ^Mozilla/4\.0[678] no-gzip
|
||||
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
|
||||
</ifmodule>
|
@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016 Wruczek <wruczekk@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
@ -0,0 +1,83 @@
|
||||
<?php
|
||||
// error_reporting(0);
|
||||
header('Content-Type: application/json');
|
||||
set_error_handler("exception_error_handler", E_ALL);
|
||||
|
||||
require_once __DIR__ . "/../include/tsutils.php";
|
||||
require_once __DIR__ . "/../lib/phpfastcache/autoload.php";
|
||||
|
||||
use phpFastCache\Util;
|
||||
use phpFastCache\CacheManager;
|
||||
|
||||
Util\Languages::setEncoding("UTF-8");
|
||||
$cache = CacheManager::Files();
|
||||
|
||||
$serverstatus = $cache->get('serverstatus');
|
||||
|
||||
// $cache->clean();
|
||||
|
||||
if (is_null($serverstatus)) {
|
||||
$serverstatus = getResult();
|
||||
$cache->set('serverstatus', $serverstatus, 10);
|
||||
}
|
||||
|
||||
die ($serverstatus);
|
||||
|
||||
// *********
|
||||
// METHODS
|
||||
// *********
|
||||
|
||||
function getResult() {
|
||||
try {
|
||||
$start = microtime(true);
|
||||
|
||||
$tsstatus = getTeamspeakServerStatus();
|
||||
|
||||
$stop = microtime(true);
|
||||
|
||||
return json_encode(array(
|
||||
"tsstatus" => $tsstatus,
|
||||
"generated" => date('d-m-Y H:i:s')
|
||||
));
|
||||
} catch (Exception $e) {
|
||||
scriptFail($e);
|
||||
}
|
||||
}
|
||||
|
||||
function scriptFail($error) {
|
||||
die(json_encode(array(
|
||||
"success" => false,
|
||||
"id" => "script_error",
|
||||
"message" => "There has been an error while retrieving the server status"
|
||||
,"error" => $error
|
||||
)));
|
||||
}
|
||||
|
||||
function exception_error_handler($errno, $errstr, $errfile, $errline ) {
|
||||
scriptFail("[$errfile @ $errline] " . $errstr);
|
||||
}
|
||||
|
||||
function getTeamspeakServerStatus() {
|
||||
|
||||
$response = pingTeamspeakServerFromConfig();
|
||||
|
||||
if ($response) {
|
||||
return array(
|
||||
"success" => $response["virtualserver_status"]->toString() == "online",
|
||||
"name" => $response["virtualserver_name"]->toString(),
|
||||
"clientsonline" => $response["virtualserver_clientsonline"] - $response["virtualserver_queryclientsonline"],
|
||||
"maxclients" => $response["virtualserver_maxclients"],
|
||||
"version" => TeamSpeak3_Helper_Convert::versionShort($response["virtualserver_version"]->toString())->toString(),
|
||||
"platform" => $response["virtualserver_platform"]->toString(),
|
||||
"uptime" => TeamSpeak3_Helper_Convert::seconds($response["virtualserver_uptime"], false, "%dd %02dh %02dm"),
|
||||
"averagePacketloss" => $response["virtualserver_total_packetloss_total"]->toString(),
|
||||
"averagePing" => $response["virtualserver_total_ping"]->toString()
|
||||
);
|
||||
} else {
|
||||
return array(
|
||||
"success" => false,
|
||||
"id" => "not_responding",
|
||||
"message" => "Server is not responding"
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,105 @@
|
||||
<?php
|
||||
$bansPage = true;
|
||||
require_once __DIR__ . "/include/header.php";
|
||||
require_once __DIR__ . "/include/tsutils.php";
|
||||
require_once __DIR__ . "/lib/phpfastcache/autoload.php";
|
||||
|
||||
|
||||
|
||||
use phpFastCache\Util;
|
||||
use phpFastCache\CacheManager;
|
||||
|
||||
Util\Languages::setEncoding("UTF-8");
|
||||
$cache = CacheManager::Files();
|
||||
|
||||
$banlist = $cache->get('banlist');
|
||||
|
||||
// $cache->clean();
|
||||
|
||||
if (is_null($banlist)) {
|
||||
$banlist = array(getBanlist(), date('d-m-Y H:i:s'));
|
||||
$cache->set('banlist', $banlist, 60);
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title"><i class="fa fa-ban" aria-hidden="true"></i> Lista banów</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
|
||||
<?php if(!$banlist[0]) { ?>
|
||||
<div class="alert alert-success">
|
||||
<p class="text-center">BRAK ZBANOWANYCH UŻYTKOWNIKÓW</p>
|
||||
</div>
|
||||
<?php } else { ?>
|
||||
<div class="table-responsive">
|
||||
<table id="banlist" class="table table-striped table-bordered" cellspacing="0" width="100%">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Nick</th>
|
||||
<th>Powód</th>
|
||||
<th>Zbanowany przez</th>
|
||||
<th>Data zbanowania</th>
|
||||
<th>Wygasa</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php echo $banlist[0]; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
</div>
|
||||
<div class="panel-footer">
|
||||
Stan na <?php echo $banlist[1]; ?><!-- <span style="float: right">Podgląd odświerza się co 60 sekund</span> -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
|
||||
function getBanlist() {
|
||||
|
||||
try {
|
||||
$tsAdmin = TeamSpeak3::factory(getTeamspeakURI(). "#no_query_clients");
|
||||
|
||||
$bany = $tsAdmin->banList();
|
||||
|
||||
$output = "";
|
||||
|
||||
foreach ($bany as $ban) {
|
||||
|
||||
if(!isset($ban['lastnickname']))
|
||||
continue;
|
||||
|
||||
$lastnickname = $ban['lastnickname']->toString();
|
||||
$reason = $ban['reason']->toString();
|
||||
$invokername = $ban['invokername']->toString();
|
||||
$created = date('d-m-Y H:i:s', $ban['created']);
|
||||
$duration = $ban['duration'];
|
||||
|
||||
if($duration == 0)
|
||||
$expires = "Ban permanentny";
|
||||
else
|
||||
$expires = date('d-m-Y H:i:s', $ban['created'] + $duration);
|
||||
|
||||
$output .= "<tr><td>$lastnickname</td><td>$reason</td><td>$invokername</td><td>$created</td><td>$expires</td></tr>";
|
||||
}
|
||||
|
||||
return $output;
|
||||
} catch(TeamSpeak3_Exception $e) {
|
||||
if($e->getCode() == 1281) {
|
||||
return false;
|
||||
} else {
|
||||
return '<div class="alert alert-danger"><p class="text-center">Wystąpił błąd ' . $e->getCode() . ': ' . $e->getMessage() . '</p></div>';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
require_once __DIR__ . "/include/footer.php";
|
||||
?>
|
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/*
|
||||
Autor: Wruczek
|
||||
Kontakt:
|
||||
TeamSpeak: ts.wruczek.top
|
||||
E-mail: wruczekk@gmail.com
|
||||
Prześlij dotację: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=9PL5J7ULZQYJQ
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/************* Konfiguracja generalna strony *************/
|
||||
|
||||
$config["general"]["title"] = "TwojTS.PL"; // Tytuł strony - wyświetlany np. w menu i na pasku nawigacji
|
||||
$config["general"]["icon"] = "img/icon/icon-32.png"; // Ikona używana na pasku nawigacji
|
||||
$config["general"]["subtitle"] = " - Najlepszy serwer Teamspeak!"; // Dodatkowy tekst dodawany do tytułu na pasku przeglądarki
|
||||
$config["general"]["desc"] = "Polski serwer TeamSpeak! Zapraszamy :)"; // Opis strony - wyświetlany np. w wynikach wyszukiwarki Google
|
||||
$config["general"]["newsDir"] = "news"; // Folder z newsami (relatywnie do głównego folderu)
|
||||
$config["general"]["contactEmail"] = "email@strona.pl"; // Twój email kontaktowy
|
||||
|
||||
|
||||
|
||||
/********* Konfiguracja serwera TeamSpeak *********/
|
||||
|
||||
$config['teamspeak']['host'] = '127.0.0.1'; // Adres serwera TeamSpeak
|
||||
$config['teamspeak']['login'] = 'serveradmin'; // Login konta Query
|
||||
$config['teamspeak']['password'] = 'pa$$word'; // Hasło konta Query
|
||||
$config['teamspeak']['server_port'] = 9987; // Port serwera TeamSpeak
|
||||
$config['teamspeak']['query_port'] = 10011; // Port Query
|
||||
$config['teamspeak']['displayip'] = 'ts.serwer.pl'; // IP wyświetlane na stronie i używane do połączeń
|
||||
|
||||
|
||||
|
||||
/************* Dodatkowe linki na pasku nawigacji *************/
|
||||
|
||||
$config["navlinks"] = array(
|
||||
// WZÓR: array("ikona", "tekst", "link") GDZIE ikona to nazwa ikony ze strony: http://fontawesome.io/icons/
|
||||
array("fa-facebook-official", "Facebook", "https://facebook.com/najlepszytsXd"),
|
||||
array("fa-comments", "Forum", "forum"),
|
||||
array("fa-shopping-cart", "Sklep", "sklep")
|
||||
);
|
||||
|
||||
/************* Konfiguracja listy administratorow *************/
|
||||
|
||||
// ID grup wyświetlanych na liście administracji
|
||||
$config["adminlist"] = array(6, 17, 19);
|
@ -0,0 +1,390 @@
|
||||
.navbar {
|
||||
position: relative;
|
||||
min-height: 60px;
|
||||
margin-bottom: 21px;
|
||||
border: 1px solid transparent;
|
||||
}
|
||||
|
||||
@media (min-width: 768px) {
|
||||
.navbar {
|
||||
border-radius: 4px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 768px) {
|
||||
.navbar-header {
|
||||
float: left;
|
||||
}
|
||||
}
|
||||
|
||||
.navbar-collapse {
|
||||
overflow-x: visible;
|
||||
padding-right: 15px;
|
||||
padding-left: 15px;
|
||||
border-top: 1px solid transparent;
|
||||
-webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
|
||||
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
|
||||
-webkit-overflow-scrolling: touch;
|
||||
}
|
||||
|
||||
.navbar-collapse.in {
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
@media (min-width: 768px) {
|
||||
.navbar-collapse {
|
||||
width: auto;
|
||||
border-top: 0;
|
||||
-webkit-box-shadow: none;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.navbar-collapse.collapse {
|
||||
display: block !important;
|
||||
height: auto !important;
|
||||
padding-bottom: 0;
|
||||
overflow: visible !important;
|
||||
}
|
||||
|
||||
.navbar-collapse.in {
|
||||
overflow-y: visible;
|
||||
}
|
||||
|
||||
.navbar-fixed-top .navbar-collapse,
|
||||
.navbar-static-top .navbar-collapse,
|
||||
.navbar-fixed-bottom .navbar-collapse {
|
||||
padding-left: 0;
|
||||
padding-right: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.navbar-fixed-top .navbar-collapse,
|
||||
.navbar-fixed-bottom .navbar-collapse {
|
||||
max-height: 340px;
|
||||
}
|
||||
|
||||
@media (max-device-width: 480px) and (orientation: landscape) {
|
||||
.navbar-fixed-top .navbar-collapse,
|
||||
.navbar-fixed-bottom .navbar-collapse {
|
||||
max-height: 200px;
|
||||
}
|
||||
}
|
||||
|
||||
.container > .navbar-header,
|
||||
.container-fluid > .navbar-header,
|
||||
.container > .navbar-collapse,
|
||||
.container-fluid > .navbar-collapse {
|
||||
margin-right: -15px;
|
||||
margin-left: -15px;
|
||||
}
|
||||
|
||||
@media (min-width: 768px) {
|
||||
.container > .navbar-header,
|
||||
.container-fluid > .navbar-header,
|
||||
.container > .navbar-collapse,
|
||||
.container-fluid > .navbar-collapse {
|
||||
margin-right: 0;
|
||||
margin-left: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.navbar-static-top {
|
||||
z-index: 1000;
|
||||
border-width: 0 0 1px;
|
||||
}
|
||||
|
||||
@media (min-width: 768px) {
|
||||
.navbar-static-top {
|
||||
border-radius: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.navbar-fixed-top,
|
||||
.navbar-fixed-bottom {
|
||||
position: fixed;
|
||||
right: 0;
|
||||
left: 0;
|
||||
z-index: 1030;
|
||||
}
|
||||
|
||||
@media (min-width: 768px) {
|
||||
.navbar-fixed-top,
|
||||
.navbar-fixed-bottom {
|
||||
border-radius: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.navbar-fixed-top {
|
||||
top: 0;
|
||||
border-width: 0 0 1px;
|
||||
}
|
||||
|
||||
.navbar-fixed-bottom {
|
||||
bottom: 0;
|
||||
margin-bottom: 0;
|
||||
border-width: 1px 0 0;
|
||||
}
|
||||
|
||||
.navbar-brand {
|
||||
float: left;
|
||||
padding: 19.5px 15px;
|
||||
font-size: 19px;
|
||||
line-height: 21px;
|
||||
height: 60px;
|
||||
}
|
||||
|
||||
.navbar-brand:hover,
|
||||
.navbar-brand:focus {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.navbar-brand > img {
|
||||
display: block;
|
||||
}
|
||||
|
||||
@media (min-width: 768px) {
|
||||
.navbar > .container .navbar-brand,
|
||||
.navbar > .container-fluid .navbar-brand {
|
||||
margin-left: -15px;
|
||||
}
|
||||
}
|
||||
|
||||
.navbar-toggle {
|
||||
position: relative;
|
||||
float: right;
|
||||
margin-right: 15px;
|
||||
padding: 9px 10px;
|
||||
margin-top: 13px;
|
||||
margin-bottom: 0px;
|
||||
background-color: transparent;
|
||||
background-image: none;
|
||||
border: 1px solid transparent;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.navbar-toggle:focus {
|
||||
outline: 0;
|
||||
}
|
||||
|
||||
.navbar-toggle .icon-bar {
|
||||
display: block;
|
||||
width: 22px;
|
||||
height: 2px;
|
||||
border-radius: 1px;
|
||||
}
|
||||
|
||||
.navbar-toggle .icon-bar + .icon-bar {
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
@media (min-width: 768px) {
|
||||
.navbar-toggle {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
.navbar-nav {
|
||||
margin: 9.75px -15px;
|
||||
}
|
||||
|
||||
.navbar-nav > li > a {
|
||||
padding-top: 10px;
|
||||
padding-bottom: 10px;
|
||||
line-height: 21px;
|
||||
}
|
||||
|
||||
@media (max-width: 767px) {
|
||||
.navbar-nav .open .dropdown-menu {
|
||||
position: static;
|
||||
float: none;
|
||||
width: auto;
|
||||
margin-top: 0;
|
||||
background-color: transparent;
|
||||
border: 0;
|
||||
-webkit-box-shadow: none;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.navbar-nav .open .dropdown-menu > li > a,
|
||||
.navbar-nav .open .dropdown-menu .dropdown-header {
|
||||
padding: 5px 15px 5px 25px;
|
||||
}
|
||||
|
||||
.navbar-nav .open .dropdown-menu > li > a {
|
||||
line-height: 21px;
|
||||
}
|
||||
|
||||
.navbar-nav .open .dropdown-menu > li > a:hover,
|
||||
.navbar-nav .open .dropdown-menu > li > a:focus {
|
||||
background-image: none;
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 768px) {
|
||||
.navbar-nav {
|
||||
float: left;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.navbar-nav > li {
|
||||
float: left;
|
||||
}
|
||||
|
||||
.navbar-nav > li > a {
|
||||
padding-top: 19.5px;
|
||||
padding-bottom: 19.5px;
|
||||
}
|
||||
}
|
||||
|
||||
.navbar-form {
|
||||
margin-left: -15px;
|
||||
margin-right: -15px;
|
||||
padding: 10px 15px;
|
||||
border-top: 1px solid transparent;
|
||||
border-bottom: 1px solid transparent;
|
||||
-webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(255, 255, 255, 0.1);
|
||||
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(255, 255, 255, 0.1);
|
||||
margin-top: 7.5px;
|
||||
margin-bottom: 7.5px;
|
||||
}
|
||||
|
||||
@media (min-width: 768px) {
|
||||
.navbar-form .form-group {
|
||||
display: inline-block;
|
||||
margin-bottom: 0;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.navbar-form .form-control {
|
||||
display: inline-block;
|
||||
width: auto;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.navbar-form .form-control-static {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.navbar-form .input-group {
|
||||
display: inline-table;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.navbar-form .input-group .input-group-addon,
|
||||
.navbar-form .input-group .input-group-btn,
|
||||
.navbar-form .input-group .form-control {
|
||||
width: auto;
|
||||
}
|
||||
|
||||
.navbar-form .input-group > .form-control {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.navbar-form .control-label {
|
||||
margin-bottom: 0;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.navbar-form .radio,
|
||||
.navbar-form .checkbox {
|
||||
display: inline-block;
|
||||
margin-top: 0;
|
||||
margin-bottom: 0;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.navbar-form .radio label,
|
||||
.navbar-form .checkbox label {
|
||||
padding-left: 0;
|
||||
}
|
||||
|
||||
.navbar-form .radio input[type="radio"],
|
||||
.navbar-form .checkbox input[type="checkbox"] {
|
||||
position: relative;
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
.navbar-form .has-feedback .form-control-feedback {
|
||||
top: 0;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 767px) {
|
||||
.navbar-form .form-group {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.navbar-form .form-group:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 768px) {
|
||||
.navbar-form {
|
||||
width: auto;
|
||||
border: 0;
|
||||
margin-left: 0;
|
||||
margin-right: 0;
|
||||
padding-top: 0;
|
||||
padding-bottom: 0;
|
||||
-webkit-box-shadow: none;
|
||||
box-shadow: none;
|
||||
}
|
||||
}
|
||||
|
||||
.navbar-nav > li > .dropdown-menu {
|
||||
margin-top: 0;
|
||||
border-top-right-radius: 0;
|
||||
border-top-left-radius: 0;
|
||||
}
|
||||
|
||||
.navbar-fixed-bottom .navbar-nav > li > .dropdown-menu {
|
||||
margin-bottom: 0;
|
||||
border-top-right-radius: 4px;
|
||||
border-top-left-radius: 4px;
|
||||
border-bottom-right-radius: 0;
|
||||
border-bottom-left-radius: 0;
|
||||
}
|
||||
|
||||
.navbar-btn {
|
||||
margin-top: 7.5px;
|
||||
margin-bottom: 7.5px;
|
||||
}
|
||||
|
||||
.navbar-btn.btn-sm {
|
||||
margin-top: 12.5px;
|
||||
margin-bottom: 12.5px;
|
||||
}
|
||||
|
||||
.navbar-btn.btn-xs {
|
||||
margin-top: 19px;
|
||||
margin-bottom: 19px;
|
||||
}
|
||||
|
||||
.navbar-text {
|
||||
margin-top: 19.5px;
|
||||
margin-bottom: 19.5px;
|
||||
}
|
||||
|
||||
@media (min-width: 768px) {
|
||||
.navbar-text {
|
||||
float: left;
|
||||
margin-left: 15px;
|
||||
margin-right: 15px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 768px) {
|
||||
.navbar-left {
|
||||
float: left !important;
|
||||
}
|
||||
|
||||
.navbar-right {
|
||||
float: right !important;
|
||||
margin-right: -15px;
|
||||
}
|
||||
|
||||
.navbar-right ~ .navbar-right {
|
||||
margin-right: 0;
|
||||
}
|
||||
}
|
@ -0,0 +1,100 @@
|
||||
.fa {
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
.icon-smaller {
|
||||
font-size: 0.7em;
|
||||
}
|
||||
|
||||
a {
|
||||
-webkit-transition: color 500ms ease-out;
|
||||
-moz-transition: color 500ms ease-out;
|
||||
-o-transition: color 500ms ease-out;
|
||||
transition: color 500ms ease-out;
|
||||
}
|
||||
|
||||
.news-header {
|
||||
font-size: 1.4em;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.news-author {
|
||||
font-size: 0.7em;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.pullright {
|
||||
float: right
|
||||
}
|
||||
|
||||
/* ****** */
|
||||
/* STATUS */
|
||||
/* ****** */
|
||||
|
||||
.serverstatus p {
|
||||
margin: 0px
|
||||
}
|
||||
|
||||
.serverstatus a {
|
||||
float: right
|
||||
}
|
||||
|
||||
.serverstatus span {
|
||||
float: right
|
||||
}
|
||||
|
||||
/* ********* */
|
||||
/* ADMINLIST */
|
||||
/* ********* */
|
||||
|
||||
.adminlist > .groupname ~ .groupname {
|
||||
margin-top: 15px;
|
||||
}
|
||||
|
||||
.adminlist .groupname {
|
||||
text-align: center;
|
||||
font-size: 1.2em;
|
||||
border-bottom: 1px solid #677481;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.adminlist .label-primary {
|
||||
background-color: #375a7f;
|
||||
}
|
||||
|
||||
.adminlist p {
|
||||
margin: 0px
|
||||
}
|
||||
|
||||
.adminlist img {
|
||||
margin-right: 3px
|
||||
}
|
||||
|
||||
.adminlist .iconspacer {
|
||||
margin-left: 19px
|
||||
}
|
||||
|
||||
|
||||
/* ****** */
|
||||
/* NAVBAR */
|
||||
/* ****** */
|
||||
|
||||
body {
|
||||
padding-top: 80px;
|
||||
}
|
||||
|
||||
.navbar {
|
||||
font-size: initial;
|
||||
}
|
||||
|
||||
.navbar-brand {
|
||||
padding: 0px 10px 0px 0px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.navbar-brand > img {
|
||||
height: 100%;
|
||||
padding: 10px 5px 10px 15px;
|
||||
width: auto;
|
||||
}
|
@ -0,0 +1,74 @@
|
||||
<?php
|
||||
$bansPage = true;
|
||||
require_once __DIR__ . "/tsutils.php";
|
||||
require_once __DIR__ . "/../lib/phpfastcache/autoload.php";
|
||||
|
||||
|
||||
|
||||
use phpFastCache\Util;
|
||||
use phpFastCache\CacheManager;
|
||||
|
||||
Util\Languages::setEncoding("UTF-8");
|
||||
$cache = CacheManager::Files();
|
||||
|
||||
$adminlist = $cache->get('adminlist');
|
||||
|
||||
// $cache->clean();
|
||||
|
||||
if (is_null($adminlist)) {
|
||||
$adminlist = array(getAdminList(), date('d-m-Y H:i:s'));
|
||||
$cache->set('adminlist', $adminlist, 30);
|
||||
}
|
||||
|
||||
// FUNCTIONS
|
||||
|
||||
function getAdminList() {
|
||||
|
||||
try {
|
||||
$tsAdmin = TeamSpeak3::factory(getTeamspeakURI(). "#no_query_clients");
|
||||
$serverGroupList = $tsAdmin->serverGroupList();
|
||||
|
||||
$output = "";
|
||||
|
||||
foreach ($serverGroupList as $group) {
|
||||
|
||||
if(!isAdminGroup($group->getId()))
|
||||
continue;
|
||||
|
||||
$output .= "<p class=\"groupname\">$group</p>";
|
||||
|
||||
foreach ($group->clientList() as $userInfo) {
|
||||
$user = getClientByDbid($tsAdmin, $userInfo['cldbid']);
|
||||
|
||||
if(!$user) {
|
||||
$output .= '<p><span class="label label-primary iconspacer">' . $userInfo['client_nickname'] . '</span><span class="label label-danger pullright">Offline</span></p>';
|
||||
continue;
|
||||
}
|
||||
|
||||
$output .= '<p>' . '<img src="lib/ts3phpframework/images/viewer/' . $user->getIcon() . '.png">' . '<span class="label label-primary">' . $user . '</span>' . ($user['client_away'] ? '<span class="label label-warning pullright">Away</span>' : '<span class="label label-success pullright">Online</span>') . '</p>';
|
||||
}
|
||||
}
|
||||
|
||||
return $output;
|
||||
} catch(TeamSpeak3_Exception $e) {
|
||||
return '<div class="alert alert-danger"><p class="text-center">Wystąpił błąd ' . $e->getCode() . ': ' . $e->getMessage() . '</p></div>';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function isAdminGroup($groupid) {
|
||||
global $config;
|
||||
$admingroups = $config["adminlist"];
|
||||
|
||||
return in_array($groupid, $admingroups);
|
||||
}
|
||||
|
||||
function getClientByDbid($tsAdmin, $cldbid) {
|
||||
try {
|
||||
return $tsAdmin->clientGetByDbid($cldbid);
|
||||
} catch(TeamSpeak3_Exception $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// echo getAdminList();
|
@ -0,0 +1,53 @@
|
||||
<?php if(!file_exists(__DIR__ . "/../config/config.php")) { ?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="pl">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
||||
<meta name="description" content="Brak wymaganych rozszerzeń">
|
||||
<meta name="author" content="Wruczek">
|
||||
|
||||
<title>BŁĄD: Brak pliku config.php</title>
|
||||
|
||||
<!-- Icon -->
|
||||
<link rel="shortcut icon" href="https://assets-cdn.github.com/images/icons/emoji/unicode/26a0.png">
|
||||
|
||||
<!-- Twitter Bootstrap -->
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.6/superhero/bootstrap.min.css" rel="stylesheet">
|
||||
|
||||
<!--[if IE]>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<style>
|
||||
body { margin-top: 70px }
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container">
|
||||
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title"><img src="https://assets-cdn.github.com/images/icons/emoji/unicode/26a0.png" width="20px">Brak pliku config.php</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<p>Przejdź do folderu <code>config</code> i zmień nazwę pliku z <code>config.template.php</code> na <code>config.php</code>.</p>
|
||||
<p>Skonfiguruj stronę według własnych potrzeb.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<!-- /container -->
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
<?php
|
||||
die();
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Footer -->
|
||||
<hr>
|
||||
<footer>
|
||||
<p class="pull-left">© <a href="http://wruczek.top">Wruczek</a> 2016</p>
|
||||
<div class="pull-right">
|
||||
<ul class="list-inline">
|
||||
<li><a href="https://github.com/Wruczek/ts-website">ts-website</a> v 1.0.0 | MIT License</li>
|
||||
</ul>
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
<!-- /container -->
|
||||
|
||||
<!-- ################ -->
|
||||
<!-- # JAVASCRIPT # -->
|
||||
<!-- ################ -->
|
||||
|
||||
<!-- jQuery -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
|
||||
|
||||
<!-- Twitter Bootstrap -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Readmore.js -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/Readmore.js/2.2.0/readmore.min.js"></script>
|
||||
|
||||
<?php if(isset($bansPage)) { ?>
|
||||
<!-- DataTables for Bootstrap -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/datatables/1.10.12/js/jquery.dataTables.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/datatables/1.10.12/js/dataTables.bootstrap.min.js"></script>
|
||||
<script src="js/bans.js"></script>
|
||||
<?php } ?>
|
||||
|
||||
<!-- Custom JS -->
|
||||
<script src="js/script.js"></script>
|
||||
<script src="js/status.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
<?php
|
||||
$end = microtime(true);
|
||||
$creationtime = ($end - $start);
|
||||
printf("<!-- Page generated " . date('d-m-Y H:i:s') . " in %.6f seconds. -->", $creationtime);
|
||||
?>
|
@ -0,0 +1,130 @@
|
||||
<?php
|
||||
$start = microtime(true);
|
||||
require_once __DIR__ . "/configcheck.php";
|
||||
require_once __DIR__ . "/modulecheck.php";
|
||||
require_once __DIR__ . "/../config/config.php";
|
||||
require_once __DIR__ . "/../include/adminlist.php";
|
||||
// require_once __DIR__ . "/include/adminlist.php";
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="pl">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
||||
<meta name="description" content="<?php echo $config["general"]["desc"]; ?>">
|
||||
<meta name="author" content="Wruczek">
|
||||
|
||||
<title><?php echo $config["general"]["title"] . $config["general"]["subtitle"]; ?></title>
|
||||
|
||||
<!-- Icon -->
|
||||
<link rel="shortcut icon" href="img/icon/icon-64.png">
|
||||
|
||||
<!-- Bootswatch -->
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.6/superhero/bootstrap.min.css" rel="stylesheet">
|
||||
|
||||
<!-- Font Awesome -->
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.5.0/css/font-awesome.min.css" rel="stylesheet">
|
||||
|
||||
<?php if(isset($bansPage)) { ?>
|
||||
<!-- DataTables for Bootstrap -->
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/datatables/1.10.12/css/dataTables.bootstrap.min.css" rel="stylesheet">
|
||||
<?php } ?>
|
||||
|
||||
<!-- Custom CSS -->
|
||||
<link href="css/navbar.css" rel="stylesheet">
|
||||
<link href="css/style.css" rel="stylesheet">
|
||||
|
||||
<!--[if IE]>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<nav class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="container">
|
||||
<!-- Brand and toggle get grouped for better mobile display -->
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
|
||||
<span class="sr-only">Nawigacja</span>
|
||||
<i class="fa fa-bars fa-lg" aria-hidden="true"></i>
|
||||
</button>
|
||||
|
||||
<a class="navbar-brand" href="."><img style="width: 64px;" src="img/icon/icon-64.png" alt="Logo strony"><?php echo $config["general"]["title"]; ?></a>
|
||||
</div>
|
||||
|
||||
<!-- Collect the nav links, forms, and other content for toggling -->
|
||||
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
|
||||
<ul class="nav navbar-nav">
|
||||
<li><a href="viewer"><i class="fa fa-eye" aria-hidden="true"></i> Podgląd serwera</a></li>
|
||||
<li><a href="bans"><i class="fa fa-ban" aria-hidden="true"></i> Lista banów</a></li>
|
||||
<!-- Nie mam na to czasu
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><i class="fa fa-television" aria-hidden="true"></i></i>Ranking <span class="caret"></span></a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="#"><i class="fa fa-clock-o" aria-hidden="true"></i>Ranking Aktywności</a></li>
|
||||
<li><a href="#"><i class="fa fa-sign-in" aria-hidden="true"></i>Ranking Połaczeń</a></li>
|
||||
<li><a href="#"><i class="fa fa-sign-out" aria-hidden="true"></i>Ranking Połączenia</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
-->
|
||||
</ul>
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<?php foreach ($config["navlinks"] as $navlink) {
|
||||
$icon = $navlink[0];
|
||||
$text = $navlink[1];
|
||||
$link = $navlink[2]; ?>
|
||||
<li><a href="<?php echo $link; ?>"><i class="fa <?php echo $icon; ?>" aria-hidden="true"></i> <?php echo $text; ?></a></li>
|
||||
<?php } ?>
|
||||
|
||||
<li data-toggle="tooltip" data-placement="bottom" title="Kontaktuj się z nami pod adresem <?php echo $config["general"]["contactEmail"]; ?>"><a href="mailto:<?php echo $config["general"]["contactEmail"]; ?>"><i class="fa fa-envelope" aria-hidden="true"></i>Kontakt</a></li>
|
||||
|
||||
<li data-toggle="tooltip" data-placement="bottom" title="Kliknij, by połączyć się z serwerem <?php echo $config['teamspeak']['displayip']; ?>"><a href="ts3server://<?php echo $config['teamspeak']['displayip']; ?>"><i class="fa fa-sign-in" aria-hidden="true"></i>Połącz z serwerem</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<!-- /.navbar-collapse -->
|
||||
</div>
|
||||
<!-- /.container-fluid -->
|
||||
</nav>
|
||||
|
||||
<div class="container">
|
||||
|
||||
<div class="row">
|
||||
|
||||
<div class="col-md-3 col-md-push-9">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading"><i class="fa fa-bar-chart" aria-hidden="true"></i> Status serwera</div>
|
||||
<div class="panel-body">
|
||||
<div class="serverstatus">
|
||||
<p><i class="fa fa-globe" aria-hidden="true"></i> Adres: <a href="ts3server://<?php echo $config['teamspeak']['displayip']; ?>"><?php echo $config['teamspeak']['displayip']; ?></a></p>
|
||||
<div id="serverstatus">
|
||||
<div class="text-center">
|
||||
<i class="fa fa-refresh fa-spin fa-3x fa-fw"></i>
|
||||
<span class="sr-only">Ładowanie...</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading"><i class="fa fa-shield" aria-hidden="true"></i> Status administracji <span class="pullright"><i class="fa fa-question-circle" aria-hidden="true" data-toggle="tooltip" data-placement="bottom" title="Stan na <?php echo $adminlist[1]; ?>"></i></span></div>
|
||||
<div class="panel-body adminlist">
|
||||
<?php echo $adminlist[0]; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading"><i class="fa fa-eye" aria-hidden="true"></i> Podgląd serwera</div>
|
||||
<div class="panel-body">
|
||||
<a href="viewer" class="btn btn-primary btn-lg btn-block"><i class="fa fa-eye" aria-hidden="true"></i> Zobacz »</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-9 col-md-pull-3">
|
@ -0,0 +1,59 @@
|
||||
<?php if(!in_array('mod_rewrite', apache_get_modules())) { ?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="pl">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
||||
<meta name="description" content="Brak wymaganych rozszerzeń">
|
||||
<meta name="author" content="Wruczek">
|
||||
|
||||
<title>BŁĄD: Brak wymaganych rozszerzeń</title>
|
||||
|
||||
<!-- Icon -->
|
||||
<link rel="shortcut icon" href="https://assets-cdn.github.com/images/icons/emoji/unicode/26a0.png">
|
||||
|
||||
<!-- Twitter Bootstrap -->
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.6/superhero/bootstrap.min.css" rel="stylesheet">
|
||||
|
||||
<!--[if IE]>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<style>
|
||||
body { margin-top: 70px }
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container">
|
||||
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title"><img src="https://assets-cdn.github.com/images/icons/emoji/unicode/26a0.png" width="20px">Brak wymaganych rozszerzeń</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<p>Na swoim serwerze nie posiadasz modułu <code>rewrite</code> wymaganego do poprawnego działania tej strony.</p>
|
||||
<p>Posiadasz system Ubuntu? Świetnie! Uruchom poniższe komendy, by włączyć wymagany moduł:</p>
|
||||
<pre>sudo a2enmod rewrite
|
||||
sudo service apache2 reload</pre>
|
||||
<p>Używasz system Debian? Uruchom owe komendy pomijając przedrostek <code>sudo</code>:</p>
|
||||
<pre>a2enmod rewrite
|
||||
service apache2 reload</pre>
|
||||
<p>Jeśli używasz hostingu i nie masz dostępu do konsoli, skontaktuj się z administratorem lub pomocą techniczną Twojego hostingu.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<!-- /container -->
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
<?php
|
||||
die();
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/../config/config.php';
|
||||
require_once __DIR__ . "/../lib/ts3phpframework/libraries/TeamSpeak3/TeamSpeak3.php";
|
||||
|
||||
function pingTeamspeakServerFromConfig() {
|
||||
return pingTeamspeakServer(getTeamspeakURI() . "&use_offline_as_virtual=1&no_query_clients=1");
|
||||
}
|
||||
|
||||
function pingTeamspeakServer($uri) {
|
||||
try {
|
||||
$tsAdmin = TeamSpeak3::factory($uri);
|
||||
|
||||
if(!$tsAdmin->getProperty("virtualserver_status"))
|
||||
throw new Exception("Server is offline");
|
||||
|
||||
return $tsAdmin->getInfo();
|
||||
} catch(TeamSpeak3_Exception $e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function getTeamspeakURI() {
|
||||
global $config;
|
||||
$host = $config['teamspeak']['host'];
|
||||
$login = $config['teamspeak']['login'];
|
||||
$passwd = $config['teamspeak']['password'];
|
||||
$sport = $config['teamspeak']['server_port'];
|
||||
$qport = $config['teamspeak']['query_port'];
|
||||
return "serverquery://$login:$passwd@$host:$qport/?server_port=$sport";
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
$(document).ready(function () {
|
||||
$('#banlist').dataTable({
|
||||
"order": [],
|
||||
"language": {
|
||||
"url": "//cdn.datatables.net/plug-ins/1.10.12/i18n/Polish.json"
|
||||
}
|
||||
});
|
||||
});
|
@ -0,0 +1,10 @@
|
||||
$(function () {
|
||||
$('[data-toggle="tooltip"]').tooltip({"html": true})
|
||||
})
|
||||
|
||||
$('.news-body').readmore({
|
||||
speed: 500,
|
||||
collapsedHeight: 300,
|
||||
moreLink: '<button type="button" class="btn btn-info">Pokaż wiecej</button>',
|
||||
lessLink: '<button type="button" class="btn btn-info">Pokaż mniej</button>'
|
||||
});
|
@ -0,0 +1,46 @@
|
||||
$(document).ready(function () {
|
||||
|
||||
checkStatus();
|
||||
|
||||
var intervalid = setInterval(function () {
|
||||
checkStatus();
|
||||
}, 10 * 1000);
|
||||
})
|
||||
|
||||
function checkStatus() {
|
||||
|
||||
$.ajax({
|
||||
url: "api/status",
|
||||
success: function (json) {
|
||||
|
||||
json = json.tsstatus;
|
||||
|
||||
var result = "";
|
||||
|
||||
if (json.success) {
|
||||
var clientsonline = json.clientsonline;
|
||||
var maxclients = json.maxclients;
|
||||
var clientsprecent = Math.round(json.clientsonline * 100 / json.maxclients);
|
||||
var version = json.version;
|
||||
var platform = json.platform;
|
||||
var uptime = json.uptime;
|
||||
var averagePacketloss = Math.round(json.averagePacketloss * 100) / 100;
|
||||
var averagePing = Math.round(json.averagePing * 100) / 100;
|
||||
|
||||
result =
|
||||
'<p><i class="fa fa-power-off" aria-hidden="true"></i> Online: <span class="label label-success">' + clientsonline + ' / ' + maxclients + ' (' + clientsprecent + '%)</span></p>' +
|
||||
'<p><i class="fa fa-clock-o" aria-hidden="true"></i> Uptime: <span class="label label-success">' + uptime + '</span></p>' +
|
||||
'<p><i class="fa fa-info-circle" aria-hidden="true"></i> Wersja: <span class="label label-success">' + version + ' @ ' + platform + '</span></p>' +
|
||||
'<p><i class="fa fa-signal" aria-hidden="true"></i> Średni ping: <span class="label label-success">' + averagePing + ' ms</span></p>' +
|
||||
'<p><i class="fa fa-bolt" aria-hidden="true"></i> Średni packet loss: <span class="label label-success">' + averagePacketloss + '%</span></p>';
|
||||
} else {
|
||||
result = '<p><i class="fa fa-power-off" aria-hidden="true"></i> Online: <span class="label label-danger">Offline</span></p>';
|
||||
}
|
||||
|
||||
$("#serverstatus").html(result);
|
||||
},
|
||||
error: function (result) {
|
||||
$("#serverstatus").html('<p><i class="fa fa-power-off" aria-hidden="true"></i> Online: <span class="label label-danger">ERROR</span></p>');
|
||||
}
|
||||
})
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of phpFastCache.
|
||||
*
|
||||
* @license MIT License (MIT)
|
||||
*
|
||||
* For full copyright and license information, please see the docs/CREDITS.txt file.
|
||||
*
|
||||
* @author Khoa Bui (khoaofgod) <khoaofgod@gmail.com> http://www.phpfastcache.com
|
||||
* @author Georges.L (Geolim4) <contact@geolim4.com>
|
||||
*
|
||||
*/
|
||||
|
||||
require_once __DIR__."/phpFastCache/phpFastCache.php";
|
@ -0,0 +1,3 @@
|
||||
order deny,allow
|
||||
deny from all
|
||||
allow from 127.0.0.1
|
@ -0,0 +1,173 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of phpFastCache.
|
||||
*
|
||||
* @license MIT License (MIT)
|
||||
*
|
||||
* For full copyright and license information, please see the docs/CREDITS.txt file.
|
||||
*
|
||||
* @author Khoa Bui (khoaofgod) <khoaofgod@gmail.com> http://www.phpfastcache.com
|
||||
* @author Georges.L (Geolim4) <contact@geolim4.com>
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpFastCache;
|
||||
|
||||
use phpFastCache\Core\phpFastCache;
|
||||
use phpFastCache\Core\DriverAbstract;
|
||||
|
||||
/**
|
||||
* Class CacheManager
|
||||
* @package phpFastCache
|
||||
*
|
||||
* @method static DriverAbstract Apc() Apc($config = array()) Return a driver "apc" instance
|
||||
* @method static DriverAbstract Cookie() Cookie($config = array()) Return a driver "cookie" instance
|
||||
* @method static DriverAbstract Files() Files($config = array()) Return a driver "files" instance
|
||||
* @method static DriverAbstract Memcache() Memcache($config = array()) Return a driver "memcache" instance
|
||||
* @method static DriverAbstract Memcached() Memcached($config = array()) Return a driver "memcached" instance
|
||||
* @method static DriverAbstract Predis() Predis($config = array()) Return a driver "predis" instance
|
||||
* @method static DriverAbstract Redis() Redis($config = array()) Return a driver "redis" instance
|
||||
* @method static DriverAbstract Sqlite() Sqlite($config = array()) Return a driver "sqlite" instance
|
||||
* @method static DriverAbstract Ssdb() Ssdb($config = array()) Return a driver "ssdb" instance
|
||||
* @method static DriverAbstract Wincache() Wincache($config = array()) Return a driver "wincache" instance
|
||||
* @method static DriverAbstract Xcache() Xcache($config = array()) Return a driver "xcache" instance
|
||||
*
|
||||
*/
|
||||
class CacheManager
|
||||
{
|
||||
public static $instances = array();
|
||||
public static $memory = array();
|
||||
public static $hit = array();
|
||||
|
||||
/**
|
||||
* @param string $storage
|
||||
* @param array $config
|
||||
* @return DriverAbstract
|
||||
*/
|
||||
public static function getInstance($storage = 'auto', $config = array())
|
||||
{
|
||||
$storage = strtolower($storage);
|
||||
if (empty($config)) {
|
||||
$config = phpFastCache::$config;
|
||||
}
|
||||
if (!isset($config[ 'cache_method' ])) {
|
||||
$config[ 'cache_method' ] = phpFastCache::$config[ 'cache_method' ];
|
||||
}
|
||||
if (!isset($config[ 'limited_memory_each_object' ])) {
|
||||
$config[ 'limited_memory_each_object' ] = phpFastCache::$config[ 'limited_memory_each_object' ];
|
||||
}
|
||||
if (isset(phpFastCache::$config[ 'overwrite' ]) && !in_array(phpFastCache::$config[ 'overwrite' ], array('auto', ''), true)) {
|
||||
phpFastCache::$config[ 'storage' ] = phpFastCache::$config[ 'overwrite' ];
|
||||
$storage = phpFastCache::$config[ 'overwrite' ];
|
||||
} else if (isset(phpFastCache::$config[ 'storage' ]) && !in_array(phpFastCache::$config[ 'storage' ], array('auto', ''), true)) {
|
||||
$storage = phpFastCache::$config[ 'storage' ];
|
||||
} else if (in_array($storage, array('auto', ''), true)) {
|
||||
$storage = phpFastCache::getAutoClass($config);
|
||||
}
|
||||
|
||||
// echo $storage."<br>";
|
||||
$instance = md5(serialize($config) . $storage);
|
||||
if (!isset(self::$instances[ $instance ]) || is_null(self::$instances[ $instance ])) {
|
||||
$class = '\phpFastCache\Drivers\\' . $storage;
|
||||
$config[ 'storage' ] = $storage;
|
||||
$config[ 'instance' ] = $instance;
|
||||
$config[ 'class' ] = $class;
|
||||
if (!isset(self::$memory[ $instance ])) {
|
||||
self::$memory[ $instance ] = array();
|
||||
}
|
||||
|
||||
if (!isset(self::$hit[ $instance ])) {
|
||||
self::$hit[ $instance ] = array(
|
||||
"class" => $class,
|
||||
"storage" => $storage,
|
||||
"data" => array(),
|
||||
);
|
||||
if ($config[ 'cache_method' ] == 4) {
|
||||
register_shutdown_function('phpFastCache\CacheManager::cleanCachingMethod', null);
|
||||
}
|
||||
}
|
||||
|
||||
self::$instances[ $instance ] = new $class($config);
|
||||
}
|
||||
|
||||
return self::$instances[ $instance ];
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup Method
|
||||
* @param string $string | traditional(normal), memory (fast), phpfastcache (fastest)
|
||||
*/
|
||||
public static function CachingMethod($string = "phpFastCache")
|
||||
{
|
||||
$string = strtolower($string);
|
||||
if (in_array($string, array("normal", "traditional"))) {
|
||||
phpFastCache::$config[ 'cache_method' ] = 1;
|
||||
} else if (in_array($string, array("fast", "memory"))) {
|
||||
phpFastCache::$config[ 'cache_method' ] = 2;
|
||||
} else if (in_array($string, array("fastest", "phpfastcache"))) {
|
||||
phpFastCache::$config[ 'cache_method' ] = 3;
|
||||
} else if (in_array($string, array("superfast", "phpfastcachex"))) {
|
||||
phpFastCache::$config[ 'cache_method' ] = 4;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* CacheManager::Files();
|
||||
* CacheManager::Memcached();
|
||||
* CacheManager::get($keyword);
|
||||
* CacheManager::set(), touch, other @method supported
|
||||
*/
|
||||
public static function __callStatic($name, $arguments)
|
||||
{
|
||||
$driver = strtolower($name);
|
||||
if (!isset(self::$instances[ 'loaded' ][ $driver ]) && class_exists("\\phpFastCache\\Drivers\\{$driver}")) {
|
||||
self::$instances[ 'loaded' ][ $driver ] = true;
|
||||
}
|
||||
if (isset(self::$instances[ 'loaded' ][ $driver ])) {
|
||||
return self::getInstance($name, (isset($arguments[ 0 ]) ? $arguments[ 0 ] : array()));
|
||||
} else {
|
||||
return call_user_func_array(array(self::getInstance(), $name), $arguments);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Shortcut to phpFastCache::setup()
|
||||
*/
|
||||
public static function setup($name, $value = '')
|
||||
{
|
||||
phpFastCache::setup($name, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $instance
|
||||
*/
|
||||
public static function cleanCachingMethod($instance = null)
|
||||
{
|
||||
if (is_null($instance)) {
|
||||
foreach (self::$instances as $instance => $data) {
|
||||
self::__CleanCachingMethod($instance);
|
||||
unset($data);
|
||||
}
|
||||
} else {
|
||||
self::__CleanCachingMethod($instance);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $instance
|
||||
*/
|
||||
protected static function __CleanCachingMethod($instance)
|
||||
{
|
||||
if(is_array(self::$memory[ $instance ]) && !empty(self::$memory[ $instance ])) {
|
||||
$old = self::$instances[$instance]->config['cache_method'];
|
||||
self::$instances[$instance]->config['cache_method'] = 1;
|
||||
foreach (self::$memory[$instance] as $keyword => $object) {
|
||||
self::$instances[$instance]->set($keyword, $object['value'], $object['expired_in']);
|
||||
}
|
||||
self::$instances[$instance]->config['cache_method'] = $old;
|
||||
self::$memory[$instance] = array();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,846 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of phpFastCache.
|
||||
*
|
||||
* @license MIT License (MIT)
|
||||
*
|
||||
* For full copyright and license information, please see the docs/CREDITS.txt file.
|
||||
*
|
||||
* @author Khoa Bui (khoaofgod) <khoaofgod@gmail.com> http://www.phpfastcache.com
|
||||
* @author Georges.L (Geolim4) <contact@geolim4.com>
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpFastCache\Core;
|
||||
|
||||
use phpFastCache\Exceptions\phpFastCacheDriverException;
|
||||
use phpFastCache\CacheManager;
|
||||
|
||||
/**
|
||||
* Class DriverAbstract
|
||||
* @package phpFastCache\Core
|
||||
*/
|
||||
abstract class DriverAbstract implements DriverInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public $extension_dir = '_extensions';
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public $tmp = array();
|
||||
|
||||
/**
|
||||
* @var array default options, this will be merge to Driver's Options
|
||||
*/
|
||||
public $config = array();
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
public $fallback = false;
|
||||
|
||||
/**
|
||||
* @var
|
||||
*/
|
||||
public $instant;
|
||||
|
||||
|
||||
public function __destruct()
|
||||
{
|
||||
// clean up the memory and don't want for PHP clean for caching method "phpfastcache"
|
||||
if (isset($this->config[ 'instance' ]) && (int)$this->config[ 'cache_method' ] === 3) {
|
||||
CacheManager::cleanCachingMethod($this->config[ 'instance' ]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $keyword
|
||||
* @return string
|
||||
*/
|
||||
protected function encodeFilename($keyword)
|
||||
{
|
||||
// return trim(trim(preg_replace('/[^a-zA-Z0-9]+/', '_', $keyword), '_'));
|
||||
// return rtrim(base64_encode($keyword), '=');
|
||||
return md5($keyword);
|
||||
}
|
||||
|
||||
/**
|
||||
* Basic Functions
|
||||
* @param $keyword
|
||||
* @param string $value
|
||||
* @param int $time
|
||||
* @param array $option
|
||||
* @return bool|null
|
||||
*/
|
||||
public function set($keyword, $value = '', $time = 0, $option = array())
|
||||
{
|
||||
/**
|
||||
* Infinity Time
|
||||
* Khoa. B
|
||||
*/
|
||||
if ((int)$time <= 0) {
|
||||
/**
|
||||
* 5 years, however memcached or memory cached will gone when u restart it
|
||||
* just recommended for sqlite. files
|
||||
*/
|
||||
$time = 3600 * 24 * 365 * 5;
|
||||
}
|
||||
|
||||
/**
|
||||
* Temporary disabled phpFastCache::$disabled = true
|
||||
* Khoa. B
|
||||
*/
|
||||
if (phpFastCache::$disabled === true) {
|
||||
return false;
|
||||
}
|
||||
$object = array(
|
||||
"value" => $value,
|
||||
"write_time" => time(),
|
||||
"expired_in" => $time,
|
||||
"expired_time" => time() + (int)$time,
|
||||
"size" => (is_array($value) || is_object($value)) ? strlen(serialize($value)) : strlen((String)$value),
|
||||
);
|
||||
|
||||
// handle search
|
||||
if (isset($this->config[ 'allow_search' ]) && $this->config[ 'allow_search' ] == true) {
|
||||
$option[ 'tags' ][] = "search";
|
||||
}
|
||||
|
||||
// handle tags
|
||||
if (isset($option[ 'tags' ])) {
|
||||
$this->_handleTags($keyword, $time, $option[ 'tags' ]);
|
||||
}
|
||||
|
||||
// handle method
|
||||
if ((int)$this->config[ 'cache_method' ] > 1 && isset($object[ 'size' ]) && (int)$object[ 'size' ] <= (int)$this->config[ 'limited_memory_each_object' ]) {
|
||||
CacheManager::$memory[ $this->config[ 'instance' ] ][ $keyword ] = $object;
|
||||
if (in_array((int)$this->config[ 'cache_method' ], array(3, 4))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
$this->_hit("set", 1);
|
||||
return $this->driver_set($keyword, $object, $time, $option);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $keyword
|
||||
* @param array $option
|
||||
* @return mixed
|
||||
*/
|
||||
public function get($keyword, $option = array())
|
||||
{
|
||||
/**
|
||||
* Temporary disabled phpFastCache::$disabled = true
|
||||
* Khoa. B
|
||||
*/
|
||||
|
||||
if (phpFastCache::$disabled === true) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// handle method
|
||||
if ((int)$this->config[ 'cache_method' ] > 1) {
|
||||
if (isset(CacheManager::$memory[ $this->config[ 'instance' ] ][ $keyword ])) {
|
||||
$object = CacheManager::$memory[ $this->config[ 'instance' ] ][ $keyword ];
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($object)) {
|
||||
$this->_hit("get", 1);
|
||||
$object = $this->driver_get($keyword, $option);
|
||||
|
||||
// handle method
|
||||
if ((int)$this->config[ 'cache_method' ] > 1 && isset($object[ 'size' ]) && (int)$object[ 'size' ] <= (int)$this->config[ 'limited_memory_each_object' ]) {
|
||||
CacheManager::$memory[ $this->config[ 'instance' ] ][ $keyword ] = $object;
|
||||
}
|
||||
// end handle method
|
||||
}
|
||||
|
||||
if ($object == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$value = isset($object[ 'value' ]) ? $object[ 'value' ] : null;
|
||||
return isset($option[ 'all_keys' ]) && $option[ 'all_keys' ] ? $object : $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $keyword
|
||||
* @param array $option
|
||||
* @return null|object
|
||||
*/
|
||||
public function getInfo($keyword, $option = array())
|
||||
{
|
||||
if ((int)$this->config[ 'cache_method' ] > 1) {
|
||||
if (isset(CacheManager::$memory[ $this->config[ 'instance' ] ][ $keyword ])) {
|
||||
$object = CacheManager::$memory[ $this->config[ 'instance' ] ][ $keyword ];
|
||||
}
|
||||
}
|
||||
if (!isset($object)) {
|
||||
$object = $this->driver_get($keyword, $option);
|
||||
}
|
||||
if ($object == null) {
|
||||
return null;
|
||||
}
|
||||
return $object;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $keyword
|
||||
* @param array $option
|
||||
* @return mixed
|
||||
*/
|
||||
public function delete($keyword, array $option = array())
|
||||
{
|
||||
// handle method
|
||||
if ((int)$this->config[ 'cache_method' ] > 1) {
|
||||
// use memory
|
||||
unset(CacheManager::$memory[ $this->config[ 'instance' ] ][ $keyword ]);
|
||||
}
|
||||
// end handle method
|
||||
return $this->driver_delete($keyword, $option);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $option
|
||||
* @return mixed
|
||||
*/
|
||||
public function stats(array $option = array())
|
||||
{
|
||||
return $this->driver_stats($option);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $option
|
||||
* @return mixed
|
||||
*/
|
||||
public function clean(array $option = array())
|
||||
{
|
||||
// handle method
|
||||
if ((int)$this->config[ 'cache_method' ] > 1) {
|
||||
// use memory
|
||||
CacheManager::$memory[ $this->config[ 'instance' ] ] = array();
|
||||
}
|
||||
// end handle method
|
||||
return $this->driver_clean($option);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $keyword
|
||||
* @return bool
|
||||
*/
|
||||
public function isExisting($keyword)
|
||||
{
|
||||
if (method_exists($this, 'driver_isExisting')) {
|
||||
return $this->driver_isExisting($keyword);
|
||||
}
|
||||
|
||||
$data = $this->get($keyword);
|
||||
if ($data == null) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches though the cache for keys that match the given query.
|
||||
* @param $query_as_regex_or_string
|
||||
* @param bool $search_in_value
|
||||
* @return mixed
|
||||
* @throws phpFastCacheDriverException
|
||||
*/
|
||||
public function search($query_as_regex_or_string, $search_in_value = false)
|
||||
{
|
||||
if ($this->config[ 'allow_search' ] != true) {
|
||||
throw new phpFastCacheDriverException('Please setup allow_search = true');
|
||||
} else {
|
||||
$list = $this->getTags("search", $search_in_value);
|
||||
$tmp = explode("/", $query_as_regex_or_string, 2);
|
||||
$regex = isset($tmp[ 1 ]) ? true : false;
|
||||
$return_list = array();
|
||||
foreach ($list as $tag) {
|
||||
foreach ($tag as $keyword => $value) {
|
||||
$gotcha = false;
|
||||
if ($search_in_value == true) {
|
||||
$value = $this->get($keyword);
|
||||
}
|
||||
|
||||
if ($regex == true && $gotcha == false) { // look in keyword
|
||||
if (preg_match($query_as_regex_or_string, $keyword)) {
|
||||
$return_list[ $keyword ] = $value;
|
||||
$gotcha = true;
|
||||
}
|
||||
}
|
||||
if ($gotcha == false) {
|
||||
if (strpos($keyword, $query_as_regex_or_string) !== false) {
|
||||
$return_list[ $keyword ] = $value;
|
||||
$gotcha = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ($search_in_value == true && $gotcha == false) { // value search
|
||||
if ($regex == true && $gotcha == false) {
|
||||
if (preg_match($query_as_regex_or_string, $value)) {
|
||||
$return_list[ $keyword ] = $value;
|
||||
$gotcha = true;
|
||||
}
|
||||
}
|
||||
if ($gotcha == false) {
|
||||
if (strpos($value, $query_as_regex_or_string) !== false) {
|
||||
$return_list[ $keyword ] = $value;
|
||||
$gotcha = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
} // each tags loop
|
||||
} // end foreach
|
||||
return $return_list;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $keyword
|
||||
* @param int $step
|
||||
* @param array $option
|
||||
* @return bool
|
||||
*/
|
||||
public function increment($keyword, $step = 1, array $option = array())
|
||||
{
|
||||
$object = $this->get($keyword, array('all_keys' => true));
|
||||
if ($object == null) {
|
||||
return false;
|
||||
} else {
|
||||
$value = (int)$object[ 'value' ] + (int)$step;
|
||||
$time = $object[ 'expired_time' ] - time();
|
||||
$this->set($keyword, $value, $time, $option);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $keyword
|
||||
* @param int $step
|
||||
* @param array $option
|
||||
* @return bool
|
||||
*/
|
||||
public function decrement($keyword, $step = 1, array $option = array())
|
||||
{
|
||||
$object = $this->get($keyword, array('all_keys' => true));
|
||||
if ($object == null) {
|
||||
return false;
|
||||
} else {
|
||||
$value = (int)$object[ 'value' ] - (int)$step;
|
||||
$time = $object[ 'expired_time' ] - time();
|
||||
$this->set($keyword, $value, $time, $option);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Extend more time
|
||||
* @param $keyword
|
||||
* @param int $time
|
||||
* @param array $option
|
||||
* @return bool
|
||||
*/
|
||||
public function touch($keyword, $time = 300, array $option = array())
|
||||
{
|
||||
$object = $this->get($keyword, array('all_keys' => true));
|
||||
if ($object == null) {
|
||||
return false;
|
||||
} else {
|
||||
$value = $object[ 'value' ];
|
||||
$time = $object[ 'expired_time' ] - time() + $time;
|
||||
$this->set($keyword, $value, $time, $option);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Other Functions Built-int for phpFastCache since 1.3
|
||||
*/
|
||||
|
||||
/**
|
||||
* @param array $list
|
||||
*/
|
||||
public function setMulti(array $list = array())
|
||||
{
|
||||
foreach ($list as $array) {
|
||||
$this->set($array[ 0 ], isset($array[ 1 ]) ? $array[ 1 ] : 0,
|
||||
isset($array[ 2 ]) ? $array[ 2 ] : array());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $list
|
||||
* @return array
|
||||
*/
|
||||
public function getMulti(array $list = array())
|
||||
{
|
||||
$res = array();
|
||||
foreach ($list as $array) {
|
||||
$name = $array[ 0 ];
|
||||
$res[ $name ] = $this->get($name,
|
||||
isset($array[ 1 ]) ? $array[ 1 ] : array());
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $list
|
||||
* @return array
|
||||
*/
|
||||
public function getInfoMulti(array $list = array())
|
||||
{
|
||||
$res = array();
|
||||
foreach ($list as $array) {
|
||||
$name = $array[ 0 ];
|
||||
$res[ $name ] = $this->getInfo($name,
|
||||
isset($array[ 1 ]) ? $array[ 1 ] : array());
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $list
|
||||
* @param array $option
|
||||
*/
|
||||
public function deleteMulti(array $list = array(), array $option = array())
|
||||
{
|
||||
foreach ($list as $item) {
|
||||
if (is_array($item) && count($item) === 2) {
|
||||
$this->delete($item[ 0 ], $item[ 1 ]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $list
|
||||
* @return array
|
||||
*/
|
||||
public function isExistingMulti(array $list = array())
|
||||
{
|
||||
$res = array();
|
||||
foreach ($list as $array) {
|
||||
$name = $array[ 0 ];
|
||||
$res[ $name ] = $this->isExisting($name);
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $list
|
||||
* @return array
|
||||
*/
|
||||
public function incrementMulti(array $list = array())
|
||||
{
|
||||
$res = array();
|
||||
foreach ($list as $array) {
|
||||
$name = $array[ 0 ];
|
||||
$res[ $name ] = $this->increment($name, $array[ 1 ],
|
||||
isset($array[ 2 ]) ? $array[ 2 ] : array());
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $list
|
||||
* @return array
|
||||
*/
|
||||
public function decrementMulti(array $list = array())
|
||||
{
|
||||
$res = array();
|
||||
foreach ($list as $array) {
|
||||
$name = $array[ 0 ];
|
||||
$res[ $name ] = $this->decrement($name, $array[ 1 ],
|
||||
isset($array[ 2 ]) ? $array[ 2 ] : array());
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $list
|
||||
* @return array
|
||||
*/
|
||||
public function touchMulti(array $list = array())
|
||||
{
|
||||
$res = array();
|
||||
foreach ($list as $array) {
|
||||
$name = $array[ 0 ];
|
||||
$res[ $name ] = $this->touch($name, $array[ 1 ],
|
||||
isset($array[ 2 ]) ? $array[ 2 ] : array());
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $config_name
|
||||
* @param string $value
|
||||
*/
|
||||
public function setup($config_name, $value = '')
|
||||
{
|
||||
/*
|
||||
* Config for class
|
||||
*/
|
||||
if (is_array($config_name)) {
|
||||
$this->config = array_merge($this->config, $config_name);
|
||||
} else {
|
||||
$this->config[ $config_name ] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $time
|
||||
*/
|
||||
public function autoCleanExpired($time = 3600)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic methods
|
||||
*/
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
* @return mixed
|
||||
*/
|
||||
public function __get($name)
|
||||
{
|
||||
return $this->get($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
* @param $v
|
||||
* @return bool|null
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function __set($name, $v)
|
||||
{
|
||||
if (isset($v[ 1 ]) && is_scalar($v[ 1 ])) {
|
||||
return $this->set($name, $v[ 0 ], $v[ 1 ],
|
||||
isset($v[ 2 ]) ? $v[ 2 ] : array());
|
||||
} else {
|
||||
throw new phpFastCacheDriverException("Example ->$name = array('VALUE', 300);", 98);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Base Methods
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
protected function backup()
|
||||
{
|
||||
return phpFastCache(phpFastCache::$config[ 'fallback' ]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
* @return void
|
||||
*/
|
||||
protected function required_extension($name)
|
||||
{
|
||||
require_once(__DIR__ . '/../' . $this->extension_dir . '/' . $name . '.' . PHP_EXT);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $file
|
||||
* @return string
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function readfile($file)
|
||||
{
|
||||
if (function_exists('file_get_contents')) {
|
||||
return file_get_contents($file);
|
||||
} else {
|
||||
$string = '';
|
||||
|
||||
$file_handle = @fopen($file, 'r');
|
||||
if (!$file_handle) {
|
||||
throw new phpFastCacheDriverException("Can't Read File", 96);
|
||||
|
||||
}
|
||||
while (!feof($file_handle)) {
|
||||
$line = fgets($file_handle);
|
||||
$string .= $line;
|
||||
}
|
||||
fclose($file_handle);
|
||||
|
||||
return $string;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* return PATH for Files & PDO only
|
||||
* @param bool $create_path
|
||||
* @return string
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getPath($create_path = false)
|
||||
{
|
||||
return phpFastCache::getPath($create_path, $this->config);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Object for Files & SQLite
|
||||
* @param $data
|
||||
* @return string
|
||||
*/
|
||||
protected function encode($data)
|
||||
{
|
||||
return serialize($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
* @return mixed
|
||||
*/
|
||||
protected function decode($value)
|
||||
{
|
||||
$x = @unserialize($value);
|
||||
if ($x == false) {
|
||||
return $value;
|
||||
} else {
|
||||
return $x;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check phpModules or CGI
|
||||
* @return bool
|
||||
*/
|
||||
protected function isPHPModule()
|
||||
{
|
||||
return phpFastCache::isPHPModule();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $class
|
||||
* @return bool
|
||||
*/
|
||||
protected function isExistingDriver($class)
|
||||
{
|
||||
return class_exists("\\phpFastCache\\Drivers\\{$class}");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
protected function __setChmodAuto()
|
||||
{
|
||||
return phpFastCache::__setChmodAuto($this->config);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $tag
|
||||
* @return string
|
||||
*/
|
||||
protected function _getTagName($tag)
|
||||
{
|
||||
return "__tag__" . $tag;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \phpFastCache\Core\DriverAbstract
|
||||
*/
|
||||
protected function _tagCaching()
|
||||
{
|
||||
return CacheManager::Sqlite(
|
||||
array(
|
||||
"path" => $this->config[ 'path' ],
|
||||
"cache_method" => 3,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $keyword
|
||||
* @param mixed $value
|
||||
* @param integer $time
|
||||
* @param array $tags
|
||||
* @param array $option | $option = array("tags" => array("a","b","c")
|
||||
* @return mixed
|
||||
*/
|
||||
public function setTags($keyword, $value = '', $time = 0, $tags = array(), $option = array())
|
||||
{
|
||||
if (!is_array($tags)) {
|
||||
$tags = array($tags);
|
||||
}
|
||||
$option[ 'tags' ] = $tags;
|
||||
return $this->set($keyword, $value, $time, $option);
|
||||
}
|
||||
|
||||
protected function _handleTags($keyword, $time, $tags)
|
||||
{
|
||||
foreach ($tags as $tag) {
|
||||
$list = $this->_tagCaching()->get($this->_getTagName($tag));
|
||||
if (is_null($list)) {
|
||||
$list = array();
|
||||
}
|
||||
$list[ $keyword ] = time() + $time;
|
||||
$this->_tagCaching()->set($this->_getTagName($tag), $list, 3600 * 24 * 30);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param array $tags
|
||||
* @param bool $return_content
|
||||
* @param array $option | $option = array("tags" => array("a","b","c")
|
||||
* @return array
|
||||
*/
|
||||
public function getTags($tags = array(), $return_content = true, $option = array())
|
||||
{
|
||||
if (!is_array($tags)) {
|
||||
$tags = array($tags);
|
||||
}
|
||||
$keywords = array();
|
||||
$tmp = 0;
|
||||
|
||||
foreach ($tags as $tag) {
|
||||
$list = $this->_tagCaching()->get($this->_getTagName($tag));
|
||||
$list_return = array();
|
||||
if (is_null($list)) {
|
||||
$list = array();
|
||||
}
|
||||
foreach ($list as $keyword => $time) {
|
||||
if ($time <= time()) {
|
||||
unset($list[ $keyword ]);
|
||||
} else {
|
||||
if ($tmp < $time) {
|
||||
$tmp = $time;
|
||||
}
|
||||
if ($return_content == true) {
|
||||
$list_return[ $keyword ] = $this->get($keyword);
|
||||
} else {
|
||||
$list_return[ $keyword ] = $time;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->_tagCaching()->set($this->_getTagName($tag), $list, $tmp);
|
||||
$keywords[ $tag ] = $list_return;
|
||||
}
|
||||
return $keywords;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $tags | array("a","b","c")
|
||||
* @param int $time
|
||||
* @param array $options
|
||||
* @return mixed
|
||||
* @internal param array $option | $option = array("tags" => array("a","b","c")
|
||||
*/
|
||||
public function touchTags($tags = array(), $time = 300, $options = array())
|
||||
{
|
||||
if (!is_array($tags)) {
|
||||
$tags = array($tags);
|
||||
}
|
||||
$lists = $this->getTags($tags);
|
||||
foreach ($lists as $tag => $keywords) {
|
||||
foreach ($keywords as $keyword => $time) {
|
||||
$this->touch($keyword, $time, $options);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $tags | array("a","b","c")
|
||||
* @param array $option | $option = array("tags" => array("a","b","c")
|
||||
* @return mixed
|
||||
*/
|
||||
public function deleteTags($tags = array(), $option = array())
|
||||
{
|
||||
if (!is_array($tags)) {
|
||||
$tags = array($tags);
|
||||
}
|
||||
$lists = $this->getTags($tags);
|
||||
foreach ($lists as $tag => $keywords) {
|
||||
foreach ($keywords as $keyword => $time) {
|
||||
$this->delete($keyword, $option);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param array $tags | array("a","b","c")
|
||||
* @param integer
|
||||
* @param array $option | $option = array("tags" => array("a","b","c")
|
||||
* @return mixed
|
||||
*/
|
||||
public function incrementTags($tags = array(), $step = 1, $option = array())
|
||||
{
|
||||
if (!is_array($tags)) {
|
||||
$tags = array($tags);
|
||||
}
|
||||
$lists = $this->getTags($tags);
|
||||
foreach ($lists as $tag => $keywords) {
|
||||
foreach ($keywords as $keyword => $time) {
|
||||
$this->increment($keyword, $step, $option);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $tags | array("a","b","c")
|
||||
* @param integer
|
||||
* @param array $option | $option = array("tags" => array("a","b","c")
|
||||
* @return mixed
|
||||
*/
|
||||
public function decrementTags($tags = array(), $step = 1, $option = array())
|
||||
{
|
||||
if (!is_array($tags)) {
|
||||
$tags = array($tags);
|
||||
}
|
||||
$lists = $this->getTags($tags);
|
||||
foreach ($lists as $tag => $keywords) {
|
||||
foreach ($keywords as $keyword => $time) {
|
||||
$this->decrement($keyword, $step, $option);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
*/
|
||||
protected function _kbdebug($value)
|
||||
{
|
||||
/*
|
||||
echo "<pre>";
|
||||
print_r($value);
|
||||
echo "</pre>";
|
||||
*/
|
||||
}
|
||||
|
||||
public function _hit($index, $step = 1)
|
||||
{
|
||||
$instance = $this->config[ 'instance' ];
|
||||
$current = isset(CacheManager::$hit[ $instance ][ 'data' ][ $index ]) ? CacheManager::$hit[ $instance ][ 'data' ][ $index ] : 0;
|
||||
CacheManager::$hit[ $instance ][ 'data' ][ $index ] = $current + ($step);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,86 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of phpFastCache.
|
||||
*
|
||||
* @license MIT License (MIT)
|
||||
*
|
||||
* For full copyright and license information, please see the docs/CREDITS.txt file.
|
||||
*
|
||||
* @author Khoa Bui (khoaofgod) <khoaofgod@gmail.com> http://www.phpfastcache.com
|
||||
* @author Georges.L (Geolim4) <contact@geolim4.com>
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpFastCache\Core;
|
||||
|
||||
/**
|
||||
* Interface DriverInterface
|
||||
* @package phpFastCache\Core
|
||||
*/
|
||||
interface DriverInterface
|
||||
{
|
||||
/**
|
||||
* Check if this Cache driver is available for server or not
|
||||
* phpFastCache_driver constructor.
|
||||
* @param array $config
|
||||
*/
|
||||
public function __construct($config = array());
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function checkdriver();
|
||||
|
||||
/**
|
||||
* Set a obj to cache
|
||||
* @param $keyword
|
||||
* @param string $value
|
||||
* @param int $time
|
||||
* @param array $option
|
||||
* @return mixed
|
||||
*/
|
||||
public function driver_set(
|
||||
$keyword,
|
||||
$value = '',
|
||||
$time = 300,
|
||||
$option = array()
|
||||
);
|
||||
|
||||
/**
|
||||
* Return null or value of cache
|
||||
* @param $keyword
|
||||
* @param array $option
|
||||
* @return mixed
|
||||
*/
|
||||
public function driver_get($keyword, $option = array());
|
||||
|
||||
/**
|
||||
* Show stats of caching
|
||||
* Return array("info","size","data")
|
||||
* @param array $option
|
||||
* @return mixed
|
||||
*/
|
||||
public function driver_stats($option = array());
|
||||
|
||||
/**
|
||||
* Delete a cache
|
||||
* @param $keyword
|
||||
* @param array $option
|
||||
* @return mixed
|
||||
*/
|
||||
public function driver_delete($keyword, $option = array());
|
||||
|
||||
/**
|
||||
* Clean up whole cache
|
||||
* @param array $option
|
||||
* @return mixed
|
||||
*/
|
||||
public function driver_clean($option = array());
|
||||
|
||||
/**
|
||||
* @param $config_name
|
||||
* @param string $value
|
||||
*/
|
||||
public function setup($config_name, $value = '');
|
||||
}
|
@ -0,0 +1,354 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of phpFastCache.
|
||||
*
|
||||
* @license MIT License (MIT)
|
||||
*
|
||||
* For full copyright and license information, please see the docs/CREDITS.txt file.
|
||||
*
|
||||
* @author Khoa Bui (khoaofgod) <khoaofgod@gmail.com> http://www.phpfastcache.com
|
||||
* @author Georges.L (Geolim4) <contact@geolim4.com>
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpFastCache\Core;
|
||||
|
||||
use phpFastCache\CacheManager;
|
||||
use phpFastCache\Exceptions\phpFastCacheCoreException;
|
||||
use phpFastCache\Exceptions\phpFastCacheDriverException;
|
||||
|
||||
/**
|
||||
* Class phpFastCache
|
||||
* @package phpFastCache\Core
|
||||
*
|
||||
* Handle methods using annotations for IDE
|
||||
* because they're handled by __call()
|
||||
* Check out DriverInterface to see all
|
||||
* the drivers methods magically implemented
|
||||
*
|
||||
* @method get() driver_get($keyword, $option = array()) Return null or value of cache
|
||||
* @method set() driver_set($keyword, $value = '', $time = 300, $option = array()) Set a obj to cache
|
||||
* @method delete() delete(string $keyword) Delete key from cache
|
||||
* @method clean() clean($option = array()) Clean up whole cache
|
||||
* @method checkdriver() checkdriver() Delete key from cache
|
||||
* @method stats() stats($option = array()) Show stats of caching
|
||||
* @method systemInfo() systemInfo() Return System Information
|
||||
*
|
||||
*/
|
||||
class phpFastCache
|
||||
{
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
public static $disabled = false;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public static $config = array(
|
||||
'storage' => '', // blank for auto
|
||||
'default_chmod' => 0777, // 0777 , 0666, 0644
|
||||
|
||||
'overwrite' => "", // files, sqlite, etc it will overwrite ur storage and all other caching for waiting u fix ur server
|
||||
'allow_search' => false, // turn to true will allow $method search("/regex/")
|
||||
|
||||
'fallback' => 'files', //Fall back when old driver is not support
|
||||
|
||||
'securityKey' => 'auto',
|
||||
'htaccess' => true,
|
||||
'path' => '',
|
||||
|
||||
'memcache' => array(
|
||||
array('127.0.0.1', 11211, 1),
|
||||
// array("new.host.ip",11211,1),
|
||||
),
|
||||
|
||||
'redis' => array(
|
||||
'host' => '127.0.0.1',
|
||||
'port' => '',
|
||||
'password' => '',
|
||||
'database' => '',
|
||||
'timeout' => '',
|
||||
),
|
||||
|
||||
'ssdb' => array(
|
||||
'host' => '127.0.0.1',
|
||||
'port' => 8888,
|
||||
'password' => '',
|
||||
'timeout' => '',
|
||||
),
|
||||
|
||||
'extensions' => array(),
|
||||
"cache_method" => 1, // 1 = normal, 2 = phpfastcache, 3 = memory
|
||||
"limited_memory_each_object" => 4000, // maximum size (bytes) of object store in memory
|
||||
"compress_data" => false // compress stored data, if the backend supports it
|
||||
);
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected static $tmp = array();
|
||||
|
||||
/**
|
||||
* @var DriverAbstract $instance
|
||||
*/
|
||||
public $instance;
|
||||
|
||||
/**
|
||||
* phpFastCache constructor.
|
||||
* @param string $storage
|
||||
* @param array $config
|
||||
*/
|
||||
public function __construct($storage = '', $config = array())
|
||||
{
|
||||
if (empty($config)) {
|
||||
$config = phpFastCache::$config;
|
||||
}
|
||||
$config[ 'storage' ] = $storage;
|
||||
|
||||
$storage = strtolower($storage);
|
||||
if ($storage == '' || $storage == 'auto') {
|
||||
$storage = self::getAutoClass($config);
|
||||
}
|
||||
|
||||
$this->instance = CacheManager::getInstance($storage, $config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Cores
|
||||
*/
|
||||
|
||||
/**
|
||||
* @param $config
|
||||
* @return string
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function getAutoClass($config)
|
||||
{
|
||||
$path = self::getPath(false, $config);
|
||||
if (is_writable($path)) {
|
||||
$driver = 'files';
|
||||
} else if (extension_loaded('apc') && ini_get('apc.enabled') && strpos(PHP_SAPI, 'CGI') === false) {
|
||||
$driver = 'apc';
|
||||
} else if (class_exists('memcached')) {
|
||||
$driver = 'memcached';
|
||||
} elseif (extension_loaded('wincache') && function_exists('wincache_ucache_set')) {
|
||||
$driver = 'wincache';
|
||||
} elseif (extension_loaded('xcache') && function_exists('xcache_get')) {
|
||||
$driver = 'xcache';
|
||||
} else if (function_exists('memcache_connect')) {
|
||||
$driver = 'memcache';
|
||||
} else if (class_exists('Redis')) {
|
||||
$driver = 'redis';
|
||||
} else {
|
||||
$driver = 'files';
|
||||
}
|
||||
|
||||
return $driver;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $skip_create_path
|
||||
* @param $config
|
||||
* @return string
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function getPath($skip_create_path = false, $config)
|
||||
{
|
||||
$tmp_dir = ini_get('upload_tmp_dir') ? ini_get('upload_tmp_dir') : sys_get_temp_dir();
|
||||
|
||||
if (!isset($config[ 'path' ]) || $config[ 'path' ] == '') {
|
||||
if (self::isPHPModule()) {
|
||||
$path = $tmp_dir;
|
||||
} else {
|
||||
$document_root_path = rtrim($_SERVER[ 'DOCUMENT_ROOT' ], '/') . '/../';
|
||||
$path = isset($_SERVER[ 'DOCUMENT_ROOT' ]) && is_writable($document_root_path)
|
||||
? $document_root_path
|
||||
: rtrim(__DIR__, '/') . '/';
|
||||
}
|
||||
|
||||
if (self::$config[ 'path' ] != '') {
|
||||
$path = $config[ 'path' ];
|
||||
}
|
||||
|
||||
} else {
|
||||
$path = $config[ 'path' ];
|
||||
}
|
||||
|
||||
$securityKey = array_key_exists('securityKey',
|
||||
$config) ? $config[ 'securityKey' ] : '';
|
||||
if ($securityKey == "" || $securityKey == 'auto') {
|
||||
$securityKey = self::$config[ 'securityKey' ];
|
||||
if ($securityKey == 'auto' || $securityKey == '') {
|
||||
$securityKey = isset($_SERVER[ 'HTTP_HOST' ]) ? preg_replace('/^www./',
|
||||
'', strtolower(str_replace(':', '_', $_SERVER[ 'HTTP_HOST' ]))) : "default";
|
||||
}
|
||||
}
|
||||
if ($securityKey != '') {
|
||||
$securityKey .= '/';
|
||||
}
|
||||
|
||||
$securityKey = self::cleanFileName($securityKey);
|
||||
|
||||
$full_path = rtrim($path,'/') . '/' . $securityKey;
|
||||
$full_pathx = md5($full_path);
|
||||
|
||||
|
||||
if ($skip_create_path == false && !isset(self::$tmp[ $full_pathx ])) {
|
||||
|
||||
if (!@file_exists($full_path) || !@is_writable($full_path)) {
|
||||
if (!@file_exists($full_path)) {
|
||||
@mkdir($full_path, self::__setChmodAuto($config), true);
|
||||
}
|
||||
if (!@is_writable($full_path)) {
|
||||
@chmod($full_path, self::__setChmodAuto($config));
|
||||
}
|
||||
if(!@is_writable($full_path)) {
|
||||
// switch back to tmp dir again if the path is not writeable
|
||||
$full_path = rtrim($tmp_dir,'/') . '/' . $securityKey;
|
||||
if (!@file_exists($full_path)) {
|
||||
@mkdir($full_path, self::__setChmodAuto($config), true);
|
||||
}
|
||||
if (!@is_writable($full_path)) {
|
||||
@chmod($full_path, self::__setChmodAuto($config));
|
||||
}
|
||||
}
|
||||
if (!@file_exists($full_path) || !@is_writable($full_path)) {
|
||||
throw new phpFastCacheCoreException('PLEASE CREATE OR CHMOD ' . $full_path . ' - 0777 OR ANY WRITABLE PERMISSION!', 92);
|
||||
}
|
||||
}
|
||||
|
||||
self::$tmp[ $full_pathx ] = true;
|
||||
self::htaccessGen($full_path, array_key_exists('htaccess', $config) ? $config[ 'htaccess' ] : false);
|
||||
}
|
||||
|
||||
return realpath($full_path);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $filename
|
||||
* @return mixed
|
||||
*/
|
||||
public static function cleanFileName($filename)
|
||||
{
|
||||
$regex = array(
|
||||
'/[\?\[\]\/\\\=\<\>\:\;\,\'\"\&\$\#\*\(\)\|\~\`\!\{\}]/',
|
||||
'/\.$/',
|
||||
'/^\./',
|
||||
);
|
||||
$replace = array('-', '', '');
|
||||
return trim(preg_replace($regex, $replace, trim($filename)),'-');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $config
|
||||
* @return int
|
||||
*/
|
||||
public static function __setChmodAuto($config)
|
||||
{
|
||||
if (!isset($config[ 'default_chmod' ]) || $config[ 'default_chmod' ] == '' || is_null($config[ 'default_chmod' ])) {
|
||||
return 0777;
|
||||
} else {
|
||||
return $config[ 'default_chmod' ];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected static function getOS()
|
||||
{
|
||||
$os = array(
|
||||
'os' => PHP_OS,
|
||||
'php' => PHP_SAPI,
|
||||
'system' => php_uname(),
|
||||
'unique' => md5(php_uname() . PHP_OS . PHP_SAPI),
|
||||
);
|
||||
return $os;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public static function isPHPModule()
|
||||
{
|
||||
if (PHP_SAPI === 'apache2handler') {
|
||||
return true;
|
||||
} else {
|
||||
if (strpos(PHP_SAPI, 'handler') !== false) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $path
|
||||
* @param bool $create
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected static function htaccessGen($path, $create = true)
|
||||
{
|
||||
|
||||
if ($create == true) {
|
||||
if (!is_writable($path)) {
|
||||
try {
|
||||
chmod($path, 0777);
|
||||
} catch (phpFastCacheDriverException $e) {
|
||||
throw new phpFastCacheDriverException('PLEASE CHMOD ' . $path . ' - 0777 OR ANY WRITABLE PERMISSION!',
|
||||
92);
|
||||
}
|
||||
}
|
||||
|
||||
if(!file_exists($path."/.htaccess")) {
|
||||
// echo "write me";
|
||||
$html = "order deny, allow \r\n
|
||||
deny from all \r\n
|
||||
allow from 127.0.0.1";
|
||||
|
||||
$f = @fopen($path . '/.htaccess', 'w+');
|
||||
if (!$f) {
|
||||
throw new phpFastCacheDriverException('PLEASE CHMOD ' . $path . ' - 0777 OR ANY WRITABLE PERMISSION!', 92);
|
||||
}
|
||||
fwrite($f, $html);
|
||||
fclose($f);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
* @param string $value
|
||||
*/
|
||||
public static function setup($name, $value = '')
|
||||
{
|
||||
if (is_array($name)) {
|
||||
self::$config = array_merge(self::$config,$name);
|
||||
} else {
|
||||
self::$config[ $name ] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $something
|
||||
*/
|
||||
public static function debug($something)
|
||||
{
|
||||
echo "Starting Debugging ...<br>\r\n ";
|
||||
if (is_array($something)) {
|
||||
echo '<pre>';
|
||||
print_r($something);
|
||||
echo '</pre>';
|
||||
var_dump($something);
|
||||
} else {
|
||||
echo $something;
|
||||
}
|
||||
echo "\r\n<br> Ended";
|
||||
exit;
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of phpFastCache.
|
||||
*
|
||||
* @license MIT License (MIT)
|
||||
*
|
||||
* For full copyright and license information, please see the docs/CREDITS.txt file.
|
||||
*
|
||||
* @author Khoa Bui (khoaofgod) <khoaofgod@gmail.com> http://www.phpfastcache.com
|
||||
* @author Georges.L (Geolim4) <contact@geolim4.com>
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpFastCache\Core;
|
||||
|
||||
/**
|
||||
* Class phpFastCacheExtensions
|
||||
* @package phpFastCache\Core
|
||||
*/
|
||||
abstract class phpFastCacheExtensions
|
||||
{
|
||||
/**
|
||||
* @param $name
|
||||
* @param $agr
|
||||
*/
|
||||
public function __call($name, $agr)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,137 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of phpFastCache.
|
||||
*
|
||||
* @license MIT License (MIT)
|
||||
*
|
||||
* For full copyright and license information, please see the docs/CREDITS.txt file.
|
||||
*
|
||||
* @author Khoa Bui (khoaofgod) <khoaofgod@gmail.com> http://www.phpfastcache.com
|
||||
* @author Georges.L (Geolim4) <contact@geolim4.com>
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpFastCache\Drivers;
|
||||
|
||||
use phpFastCache\Core\DriverAbstract;
|
||||
use phpFastCache\Exceptions\phpFastCacheDriverException;
|
||||
|
||||
/**
|
||||
* Class apc
|
||||
* @package phpFastCache\Drivers
|
||||
*/
|
||||
class apc extends DriverAbstract
|
||||
{
|
||||
/**
|
||||
* phpFastCache_apc constructor.
|
||||
* @param array $config
|
||||
* @throws phpFastCacheDriverException
|
||||
*/
|
||||
public function __construct($config = array())
|
||||
{
|
||||
$this->setup($config);
|
||||
|
||||
if (!$this->checkdriver()) {
|
||||
throw new phpFastCacheDriverException('APC is not installed, cannot continue.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function checkdriver()
|
||||
{
|
||||
if (extension_loaded('apc') && ini_get('apc.enabled')) {
|
||||
return true;
|
||||
} else {
|
||||
$this->fallback = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $keyword
|
||||
* @param string $value
|
||||
* @param int $time
|
||||
* @param array $option
|
||||
* @return array|bool
|
||||
*/
|
||||
public function driver_set(
|
||||
$keyword,
|
||||
$value = '',
|
||||
$time = 300,
|
||||
$option = array()
|
||||
) {
|
||||
if (isset($option[ 'skipExisting' ]) && $option[ 'skipExisting' ] == true) {
|
||||
return apc_add($keyword, $value, $time);
|
||||
} else {
|
||||
return apc_store($keyword, $value, $time);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $keyword
|
||||
* @param array $option
|
||||
* @return mixed|null
|
||||
*/
|
||||
public function driver_get($keyword, $option = array())
|
||||
{
|
||||
$data = apc_fetch($keyword, $bo);
|
||||
if ($bo === false) {
|
||||
return null;
|
||||
}
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $keyword
|
||||
* @param array $option
|
||||
* @return bool|\string[]
|
||||
*/
|
||||
public function driver_delete($keyword, $option = array())
|
||||
{
|
||||
return apc_delete($keyword);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $option
|
||||
* @return array
|
||||
*/
|
||||
public function driver_stats($option = array())
|
||||
{
|
||||
$res = array(
|
||||
'info' => '',
|
||||
'size' => '',
|
||||
'data' => '',
|
||||
);
|
||||
|
||||
try {
|
||||
$res[ 'data' ] = apc_cache_info('user');
|
||||
} catch (\Exception $e) {
|
||||
$res[ 'data' ] = array();
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $option
|
||||
* @return void
|
||||
*/
|
||||
public function driver_clean($option = array())
|
||||
{
|
||||
@apc_clear_cache();
|
||||
@apc_clear_cache('user');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $keyword
|
||||
* @return bool
|
||||
*/
|
||||
public function driver_isExisting($keyword)
|
||||
{
|
||||
return (bool) apc_exists($keyword);
|
||||
}
|
||||
}
|
@ -0,0 +1,156 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of phpFastCache.
|
||||
*
|
||||
* @license MIT License (MIT)
|
||||
*
|
||||
* For full copyright and license information, please see the docs/CREDITS.txt file.
|
||||
*
|
||||
* @author Khoa Bui (khoaofgod) <khoaofgod@gmail.com> http://www.phpfastcache.com
|
||||
* @author Georges.L (Geolim4) <contact@geolim4.com>
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpFastCache\Drivers;
|
||||
|
||||
use phpFastCache\Core\DriverAbstract;
|
||||
|
||||
/**
|
||||
* Class cookie
|
||||
* @package phpFastCache\Drivers
|
||||
*/
|
||||
class cookie extends DriverAbstract
|
||||
{
|
||||
/**
|
||||
* phpFastCache_cookie constructor.
|
||||
* @param array $config
|
||||
*/
|
||||
public function __construct($config = array())
|
||||
{
|
||||
$this->setup($config);
|
||||
if (!$this->checkdriver() && !isset($config[ 'skipError' ])) {
|
||||
$this->fallback = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function checkdriver()
|
||||
{
|
||||
// Check memcache
|
||||
if (function_exists('setcookie')) {
|
||||
return true;
|
||||
}
|
||||
$this->fallback = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function connectServer()
|
||||
{
|
||||
// for cookie check output
|
||||
if (!isset($_COOKIE[ 'phpFastCache' ])) {
|
||||
if (!@setcookie('phpFastCache', 1, 10)) {
|
||||
$this->fallback = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $keyword
|
||||
* @param string $value
|
||||
* @param int $time
|
||||
* @param array $option
|
||||
* @return bool
|
||||
*/
|
||||
public function driver_set($keyword, $value = '', $time = 300, $option = array())
|
||||
{
|
||||
$this->connectServer();
|
||||
$keyword = 'phpFastCache_' . $keyword;
|
||||
$v = $this->encode($value);
|
||||
if(isset($this->config['limited_memory_each_object'])
|
||||
&& strlen($v) > $this->config['limited_memory_each_object']) {
|
||||
return false;
|
||||
}
|
||||
return setcookie($keyword, $v, time() + ($time ? (int)$time : 300), '/');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $keyword
|
||||
* @param array $option
|
||||
* @return bool|mixed|null
|
||||
*/
|
||||
public function driver_get($keyword, $option = array())
|
||||
{
|
||||
$this->connectServer();
|
||||
// return null if no caching
|
||||
// return value if in caching
|
||||
$keyword = 'phpFastCache_' . $keyword;
|
||||
$x = isset($_COOKIE[ $keyword ]) ? $this->decode($_COOKIE[ $keyword ]) : false;
|
||||
if ($x == false) {
|
||||
return null;
|
||||
} else {
|
||||
return $x;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $keyword
|
||||
* @param array $option
|
||||
*/
|
||||
public function driver_delete($keyword, $option = array())
|
||||
{
|
||||
$this->connectServer();
|
||||
$keyword = 'phpFastCache_' . $keyword;
|
||||
@setcookie($keyword, null, -10);
|
||||
$_COOKIE[ $keyword ] = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $option
|
||||
* @return array
|
||||
*/
|
||||
public function driver_stats($option = array())
|
||||
{
|
||||
$this->connectServer();
|
||||
$res = array(
|
||||
'info' => '',
|
||||
'size' => '',
|
||||
'data' => $_COOKIE,
|
||||
);
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $option
|
||||
*/
|
||||
public function driver_clean($option = array())
|
||||
{
|
||||
$this->connectServer();
|
||||
foreach ($_COOKIE as $keyword => $value) {
|
||||
if (strpos($keyword, 'phpFastCache') !== false) {
|
||||
@setcookie($keyword, null, -10);
|
||||
$_COOKIE[ $keyword ] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $keyword
|
||||
* @return bool
|
||||
*/
|
||||
public function driver_isExisting($keyword)
|
||||
{
|
||||
$this->connectServer();
|
||||
$x = $this->get($keyword);
|
||||
|
||||
return !($x == null);
|
||||
}
|
||||
}
|
@ -0,0 +1,128 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of phpFastCache.
|
||||
*
|
||||
* @license MIT License (MIT)
|
||||
*
|
||||
* For full copyright and license information, please see the docs/CREDITS.txt file.
|
||||
*
|
||||
* @author Khoa Bui (khoaofgod) <khoaofgod@gmail.com> http://www.phpfastcache.com
|
||||
* @author Georges.L (Geolim4) <contact@geolim4.com>
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpFastCache\Drivers;
|
||||
|
||||
use phpFastCache\Core\DriverAbstract;
|
||||
use phpFastCache\Core\DriverInterface;
|
||||
use phpFastCache\Exceptions\phpFastCacheDriverException;
|
||||
|
||||
/**
|
||||
* Class example
|
||||
* @package phpFastCache\Drivers
|
||||
*/
|
||||
class example extends DriverAbstract
|
||||
{
|
||||
/**
|
||||
* phpFastCache_example constructor.
|
||||
* @param array $config
|
||||
* @throws phpFastCacheDriverException
|
||||
*/
|
||||
public function __construct($config = array())
|
||||
{
|
||||
$this->setup($config);
|
||||
if (!$this->checkdriver() && !isset($config[ 'skipError' ])) {
|
||||
throw new phpFastCacheDriverException("Can't use this driver for your website!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function checkdriver()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function connectServer()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $keyword
|
||||
* @param string $value
|
||||
* @param int $time
|
||||
* @param array $option
|
||||
* @return void
|
||||
*/
|
||||
public function driver_set($keyword, $value = '', $time = 300, $option = array())
|
||||
{
|
||||
if (isset($option[ 'skipExisting' ]) && $option[ 'skipExisting' ] == true) {
|
||||
// skip driver
|
||||
} else {
|
||||
// add driver
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $keyword
|
||||
* @param array $option
|
||||
* @return null
|
||||
*/
|
||||
public function driver_get($keyword, $option = array())
|
||||
{
|
||||
// return null if no caching
|
||||
// return value if in caching
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $keyword
|
||||
* @param array $option
|
||||
* @return void
|
||||
*/
|
||||
public function driver_delete($keyword, $option = array())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $option
|
||||
* @return array
|
||||
*/
|
||||
public function driver_stats($option = array())
|
||||
{
|
||||
$res = array(
|
||||
'info' => '',
|
||||
'size' => '',
|
||||
'data' => '',
|
||||
);
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $option
|
||||
* @return void
|
||||
*/
|
||||
public function driver_clean($option = array())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $keyword
|
||||
*/
|
||||
public function driver_isExisting($keyword)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,306 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of phpFastCache.
|
||||
*
|
||||
* @license MIT License (MIT)
|
||||
*
|
||||
* For full copyright and license information, please see the docs/CREDITS.txt file.
|
||||
*
|
||||
* @author Khoa Bui (khoaofgod) <khoaofgod@gmail.com> http://www.phpfastcache.com
|
||||
* @author Georges.L (Geolim4) <contact@geolim4.com>
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpFastCache\Drivers;
|
||||
|
||||
use phpFastCache\Core\DriverAbstract;
|
||||
use phpFastCache\Exceptions\phpFastCacheDriverException;
|
||||
|
||||
/**
|
||||
* Class files
|
||||
* @package phpFastCache\Drivers
|
||||
*/
|
||||
class files extends DriverAbstract
|
||||
{
|
||||
/**
|
||||
* Init Cache Path
|
||||
* phpFastCache_files constructor.
|
||||
* @param array $config
|
||||
* @throws phpFastCacheDriverException
|
||||
*/
|
||||
public function __construct($config = array())
|
||||
{
|
||||
$this->setup($config);
|
||||
$this->getPath(); // force create path
|
||||
|
||||
if (!$this->checkdriver() && !isset($config[ 'skipError' ])) {
|
||||
throw new phpFastCacheDriverException("Can't use this driver for your website!");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function checkdriver()
|
||||
{
|
||||
if (is_writable($this->getPath())) {
|
||||
return true;
|
||||
}/* else {
|
||||
|
||||
}*/
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $keyword
|
||||
* @param bool $skip
|
||||
* @return string
|
||||
* @throws phpFastCacheDriverException
|
||||
*/
|
||||
private function getFilePath($keyword, $skip = false)
|
||||
{
|
||||
$path = $this->getPath();
|
||||
|
||||
$filename = $this->encodeFilename($keyword);
|
||||
$folder = substr($filename, 0, 2);
|
||||
$path = rtrim($path, '/') . '/' . $folder;
|
||||
/**
|
||||
* Skip Create Sub Folders;
|
||||
*/
|
||||
if ($skip == false) {
|
||||
if (!file_exists($path)) {
|
||||
if (!mkdir($path, $this->__setChmodAuto(), true)) {
|
||||
throw new phpFastCacheDriverException('PLEASE CHMOD ' . $this->getPath() . ' - 0777 OR ANY WRITABLE PERMISSION!', 92);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $path . '/' . $filename . '.txt';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $keyword
|
||||
* @param string $value
|
||||
* @param int $time
|
||||
* @param array $option
|
||||
* @return bool
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function driver_set($keyword, $value = '', $time = 300, $option = array())
|
||||
{
|
||||
$file_path = $this->getFilePath($keyword);
|
||||
$data = $this->encode($value);
|
||||
|
||||
$toWrite = true;
|
||||
/*
|
||||
* Skip if Existing Caching in Options
|
||||
*/
|
||||
if (isset($option[ 'skipExisting' ]) && $option[ 'skipExisting' ] == true && file_exists($file_path)) {
|
||||
$content = $this->readfile($file_path);
|
||||
$old = $this->decode($content);
|
||||
$toWrite = false;
|
||||
if ($this->isExpired($old)) {
|
||||
$toWrite = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Force write
|
||||
try {
|
||||
if ($toWrite == true) {
|
||||
$f = fopen($file_path, 'w+');
|
||||
fwrite($f, $data);
|
||||
fclose($f);
|
||||
return true;
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $keyword
|
||||
* @param array $option
|
||||
* @return mixed|null
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function driver_get($keyword, $option = array())
|
||||
{
|
||||
|
||||
$file_path = $this->getFilePath($keyword);
|
||||
if (!file_exists($file_path)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$content = $this->readfile($file_path);
|
||||
$object = $this->decode($content);
|
||||
if ($this->isExpired($object)) {
|
||||
@unlink($file_path);
|
||||
$this->autoCleanExpired();
|
||||
return null;
|
||||
}
|
||||
|
||||
return $object;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $keyword
|
||||
* @param array $option
|
||||
* @return bool
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function driver_delete($keyword, $option = array())
|
||||
{
|
||||
$file_path = $this->getFilePath($keyword, true);
|
||||
if (file_exists($file_path) && @unlink($file_path)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return total cache size + auto removed expired files
|
||||
* @param array $option
|
||||
* @return array
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function driver_stats($option = array())
|
||||
{
|
||||
$res = array(
|
||||
'info' => '',
|
||||
'size' => '',
|
||||
'data' => '',
|
||||
);
|
||||
|
||||
$path = $this->getPath();
|
||||
$dir = @opendir($path);
|
||||
if (!$dir) {
|
||||
throw new phpFastCacheDriverException("Can't read PATH:" . $path, 94);
|
||||
}
|
||||
|
||||
$total = 0;
|
||||
$removed = 0;
|
||||
while ($file = readdir($dir)) {
|
||||
if ($file != '.' && $file != '..' && is_dir($path . '/' . $file)) {
|
||||
// read sub dir
|
||||
$subdir = opendir($path . "/" . $file);
|
||||
if (!$subdir) {
|
||||
throw new phpFastCacheDriverException("Can't read path:" . $path . '/' . $file, 93);
|
||||
}
|
||||
|
||||
while ($f = readdir($subdir)) {
|
||||
if ($f != '.' && $f != '..') {
|
||||
$file_path = $path . '/' . $file . '/' . $f;
|
||||
$size = filesize($file_path);
|
||||
$object = $this->decode($this->readfile($file_path));
|
||||
|
||||
if (strpos($f, '.') === false) {
|
||||
$key = $f;
|
||||
} else {
|
||||
//Because PHP 5.3, this cannot be written in single line
|
||||
$key = explode('.', $f);
|
||||
$key = $key[ 0 ];
|
||||
}
|
||||
$content[ $key ] = array(
|
||||
'size' => $size,
|
||||
'write_time' => (isset($object[ 'write_time' ]) ? $object[ 'write_time' ] : null),
|
||||
);
|
||||
if ($this->isExpired($object)) {
|
||||
@unlink($file_path);
|
||||
$removed += $size;
|
||||
}
|
||||
$total += $size;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$res[ 'size' ] = $total - $removed;
|
||||
$res[ 'info' ] = array(
|
||||
'Total [bytes]' => $total,
|
||||
'Expired and removed [bytes]' => $removed,
|
||||
'Current [bytes]' => $res[ 'size' ],
|
||||
);
|
||||
$res[ "data" ] = $content;
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param int $time
|
||||
*/
|
||||
public function autoCleanExpired($time = 3600)
|
||||
{
|
||||
$autoclean = $this->get('keyword_clean_up_driver_files');
|
||||
if ($autoclean == null) {
|
||||
$this->set('keyword_clean_up_driver_files', $time);
|
||||
$res = $this->stats();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $option
|
||||
* @throws \Exception
|
||||
* @return void
|
||||
*/
|
||||
public function driver_clean($option = array())
|
||||
{
|
||||
|
||||
$path = $this->getPath();
|
||||
$dir = @opendir($path);
|
||||
if (!$dir) {
|
||||
throw new phpFastCacheDriverException("Can't read PATH:" . $path, 94);
|
||||
}
|
||||
|
||||
while ($file = readdir($dir)) {
|
||||
if ($file != '.' && $file != '..' && is_dir($path . '/' . $file)) {
|
||||
// read sub dir
|
||||
$subdir = @opendir($path . '/' . $file);
|
||||
if (!$subdir) {
|
||||
throw new phpFastCacheDriverException("Can't read path:" . $path . '/' . $file, 93);
|
||||
}
|
||||
|
||||
while ($f = readdir($subdir)) {
|
||||
if ($f != '.' && $f != '..') {
|
||||
$file_path = $path . '/' . $file . '/' . $f;
|
||||
@unlink($file_path);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $keyword
|
||||
* @return bool
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function driver_isExisting($keyword)
|
||||
{
|
||||
$file_path = $this->getFilePath($keyword, true);
|
||||
if (!file_exists($file_path)) {
|
||||
return false;
|
||||
} else {
|
||||
// check expired or not
|
||||
$value = $this->get($keyword);
|
||||
|
||||
return !($value == null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $object
|
||||
* @return bool
|
||||
*/
|
||||
public function isExpired($object)
|
||||
{
|
||||
if (isset($object[ 'expired_time' ]) && time() >= $object[ 'expired_time' ]) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,200 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of phpFastCache.
|
||||
*
|
||||
* @license MIT License (MIT)
|
||||
*
|
||||
* For full copyright and license information, please see the docs/CREDITS.txt file.
|
||||
*
|
||||
* @author Khoa Bui (khoaofgod) <khoaofgod@gmail.com> http://www.phpfastcache.com
|
||||
* @author Georges.L (Geolim4) <contact@geolim4.com>
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpFastCache\Drivers;
|
||||
|
||||
use phpFastCache\Core\DriverAbstract;
|
||||
use Memcache as MemcacheSoftware;
|
||||
|
||||
/**
|
||||
* Class memcache
|
||||
* @package phpFastCache\Drivers
|
||||
*/
|
||||
class memcache extends DriverAbstract
|
||||
{
|
||||
|
||||
/**
|
||||
* @var \Memcache
|
||||
*/
|
||||
public $instant;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $memcacheFlags = 0;
|
||||
|
||||
/**
|
||||
* phpFastCache_memcache constructor.
|
||||
* @param array $config
|
||||
*/
|
||||
public function __construct($config = array())
|
||||
{
|
||||
$this->setup($config);
|
||||
if (!$this->checkdriver() && !isset($config[ 'skipError' ])) {
|
||||
$this->fallback = true;
|
||||
}
|
||||
if (class_exists('Memcache')) {
|
||||
$this->instant = new MemcacheSoftware();
|
||||
|
||||
if (array_key_exists('compress_data', $config) && $config[ 'compress_data' ] === true) {
|
||||
$this->memcacheFlags = MEMCACHE_COMPRESSED;
|
||||
}
|
||||
} else {
|
||||
$this->fallback = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function checkdriver()
|
||||
{
|
||||
// Check memcache
|
||||
if (function_exists('memcache_connect')) {
|
||||
return true;
|
||||
}
|
||||
$this->fallback = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function connectServer()
|
||||
{
|
||||
$server = $this->config[ 'memcache' ];
|
||||
if (count($server) < 1) {
|
||||
$server = array(
|
||||
array('127.0.0.1', 11211),
|
||||
);
|
||||
}
|
||||
|
||||
foreach ($server as $s) {
|
||||
$name = $s[ 0 ] . "_" . $s[ 1 ];
|
||||
if (!isset($this->checked[ $name ])) {
|
||||
try {
|
||||
if (!$this->instant->addserver($s[ 0 ], $s[ 1 ])) {
|
||||
$this->fallback = true;
|
||||
}
|
||||
|
||||
$this->checked[ $name ] = 1;
|
||||
} catch (\Exception $e) {
|
||||
$this->fallback = true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $keyword
|
||||
* @param string $value
|
||||
* @param int $time
|
||||
* @param array $option
|
||||
* @return array|bool
|
||||
*/
|
||||
public function driver_set(
|
||||
$keyword,
|
||||
$value = '',
|
||||
$time = 300,
|
||||
$option = array()
|
||||
) {
|
||||
$this->connectServer();
|
||||
|
||||
// Memcache will only allow a expiration timer less than 2592000 seconds,
|
||||
// otherwise, it will assume you're giving it a UNIX timestamp.
|
||||
if ($time > 2592000) {
|
||||
$time = time() + $time;
|
||||
}
|
||||
|
||||
if (isset($option[ 'skipExisting' ]) && $option[ 'skipExisting' ] == true) {
|
||||
return $this->instant->add($keyword, $value, $this->memcacheFlags, $time);
|
||||
|
||||
} else {
|
||||
return $this->instant->set($keyword, $value, $this->memcacheFlags, $time);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $keyword
|
||||
* @param array $option
|
||||
* @return array|null|string
|
||||
*/
|
||||
public function driver_get($keyword, $option = array())
|
||||
{
|
||||
$this->connectServer();
|
||||
|
||||
// return null if no caching
|
||||
// return value if in caching
|
||||
|
||||
$x = $this->instant->get($keyword);
|
||||
|
||||
if ($x == false) {
|
||||
return null;
|
||||
} else {
|
||||
return $x;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $keyword
|
||||
* @param array $option
|
||||
*/
|
||||
public function driver_delete($keyword, $option = array())
|
||||
{
|
||||
$this->connectServer();
|
||||
$this->instant->delete($keyword);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $option
|
||||
* @return array
|
||||
*/
|
||||
public function driver_stats($option = array())
|
||||
{
|
||||
$this->connectServer();
|
||||
$res = array(
|
||||
'info' => '',
|
||||
'size' => '',
|
||||
'data' => $this->instant->getStats(),
|
||||
);
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $option
|
||||
*/
|
||||
public function driver_clean($option = array())
|
||||
{
|
||||
$this->connectServer();
|
||||
$this->instant->flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $keyword
|
||||
* @return bool
|
||||
*/
|
||||
public function driver_isExisting($keyword)
|
||||
{
|
||||
$this->connectServer();
|
||||
$x = $this->get($keyword);
|
||||
|
||||
return !($x == null);
|
||||
}
|
||||
}
|
@ -0,0 +1,200 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of phpFastCache.
|
||||
*
|
||||
* @license MIT License (MIT)
|
||||
*
|
||||
* For full copyright and license information, please see the docs/CREDITS.txt file.
|
||||
*
|
||||
* @author Khoa Bui (khoaofgod) <khoaofgod@gmail.com> http://www.phpfastcache.com
|
||||
* @author Georges.L (Geolim4) <contact@geolim4.com>
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpFastCache\Drivers;
|
||||
|
||||
use phpFastCache\Core\DriverAbstract;
|
||||
use Memcached as MemcachedSoftware;
|
||||
|
||||
/**
|
||||
* Class memcached
|
||||
* @package phpFastCache\Drivers
|
||||
*/
|
||||
class memcached extends DriverAbstract
|
||||
{
|
||||
|
||||
/**
|
||||
* @var \Memcached
|
||||
*/
|
||||
public $instant;
|
||||
|
||||
/**
|
||||
* phpFastCache_memcached constructor.
|
||||
* @param array $config
|
||||
*/
|
||||
public function __construct($config = array())
|
||||
{
|
||||
$this->setup($config);
|
||||
|
||||
if (!$this->checkdriver() && !isset($config[ 'skipError' ])) {
|
||||
$this->fallback = true;
|
||||
}
|
||||
|
||||
if (class_exists('Memcached')) {
|
||||
$this->instant = new MemcachedSoftware();
|
||||
} else {
|
||||
$this->fallback = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function checkdriver()
|
||||
{
|
||||
if (class_exists('Memcached')) {
|
||||
return true;
|
||||
}
|
||||
$this->fallback = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function connectServer()
|
||||
{
|
||||
if ($this->checkdriver() == false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$s = $this->config[ 'memcache' ];
|
||||
if (count($s) < 1) {
|
||||
$s = array(
|
||||
array('127.0.0.1', 11211, 100),
|
||||
);
|
||||
}
|
||||
|
||||
foreach ($s as $server) {
|
||||
$name = isset($server[ 0 ]) ? $server[ 0 ] : '127.0.0.1';
|
||||
$port = isset($server[ 1 ]) ? $server[ 1 ] : 11211;
|
||||
$sharing = isset($server[ 2 ]) ? $server[ 2 ] : 0;
|
||||
$checked = $name . '_' . $port;
|
||||
if (!isset($this->checked[ $checked ])) {
|
||||
try {
|
||||
if ($sharing > 0) {
|
||||
if (!$this->instant->addServer($name, $port,
|
||||
$sharing)
|
||||
) {
|
||||
$this->fallback = true;
|
||||
}
|
||||
} else {
|
||||
|
||||
if (!$this->instant->addServer($name, $port)) {
|
||||
$this->fallback = true;
|
||||
}
|
||||
}
|
||||
$this->checked[ $checked ] = 1;
|
||||
} catch (\Exception $e) {
|
||||
$this->fallback = true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $keyword
|
||||
* @param string $value
|
||||
* @param int $time
|
||||
* @param array $option
|
||||
* @return bool
|
||||
*/
|
||||
public function driver_set($keyword, $value = '', $time = 300, $option = array())
|
||||
{
|
||||
$this->connectServer();
|
||||
|
||||
// Memcache will only allow a expiration timer less than 2592000 seconds,
|
||||
// otherwise, it will assume you're giving it a UNIX timestamp.
|
||||
if ($time > 2592000) {
|
||||
$time = time() + $time;
|
||||
}
|
||||
|
||||
if (isset($option[ 'isExisting' ]) && $option[ 'isExisting' ] == true) {
|
||||
return $this->instant->add($keyword, $value, $time);
|
||||
} else {
|
||||
return $this->instant->set($keyword, $value, $time);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $keyword
|
||||
* @param array $option
|
||||
* @return mixed|null
|
||||
*/
|
||||
public function driver_get($keyword, $option = array())
|
||||
{
|
||||
// return null if no caching
|
||||
// return value if in caching
|
||||
$this->connectServer();
|
||||
$x = @$this->instant->get($keyword);// Prevent memcached to return a warning for long keywords
|
||||
if ($x == false) {
|
||||
return null;
|
||||
} else {
|
||||
return $x;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $keyword
|
||||
* @param array $option
|
||||
* @return void
|
||||
*/
|
||||
public function driver_delete($keyword, $option = array())
|
||||
{
|
||||
$this->connectServer();
|
||||
$this->instant->delete($keyword);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $option
|
||||
* @return array
|
||||
*/
|
||||
public function driver_stats($option = array())
|
||||
{
|
||||
$this->connectServer();
|
||||
$res = array(
|
||||
'info' => '',
|
||||
'size' => '',
|
||||
'data' => $this->instant->getStats(),
|
||||
);
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $option
|
||||
* @return void
|
||||
*/
|
||||
public function driver_clean($option = array())
|
||||
{
|
||||
$this->connectServer();
|
||||
$this->instant->flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $keyword
|
||||
* @return bool
|
||||
*/
|
||||
public function driver_isExisting($keyword)
|
||||
{
|
||||
$this->connectServer();
|
||||
$x = $this->get($keyword);
|
||||
|
||||
return !($x == null);
|
||||
}
|
||||
}
|
@ -0,0 +1,125 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of phpFastCache.
|
||||
*
|
||||
* @license MIT License (MIT)
|
||||
*
|
||||
* For full copyright and license information, please see the docs/CREDITS.txt file.
|
||||
*
|
||||
* @author Khoa Bui (khoaofgod) <khoaofgod@gmail.com> http://www.phpfastcache.com
|
||||
* @author Georges.L (Geolim4) <contact@geolim4.com>
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpFastCache\Drivers;
|
||||
|
||||
use phpFastCache\Core\DriverAbstract;
|
||||
use phpFastCache\Exceptions\phpFastCacheDriverException;
|
||||
|
||||
/**
|
||||
* Class mongodb
|
||||
* @package phpFastCache\Drivers
|
||||
*/
|
||||
class mongodb extends DriverAbstract
|
||||
{
|
||||
/**
|
||||
* phpFastCache constructor.
|
||||
* @param array $config
|
||||
* @throws phpFastCacheDriverException
|
||||
*/
|
||||
public function __construct($config = array())
|
||||
{
|
||||
$this->setup($config);
|
||||
if (!$this->checkdriver() && !isset($config[ 'skipError' ])) {
|
||||
throw new phpFastCacheDriverException("Can't use this driver for your website!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function checkdriver()
|
||||
{
|
||||
// return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function connectServer()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $keyword
|
||||
* @param string $value
|
||||
* @param int $time
|
||||
* @param array $option
|
||||
*/
|
||||
public function driver_set($keyword, $value = '', $time = 300, $option = array())
|
||||
{
|
||||
if (isset($option[ 'skipExisting' ]) && $option[ 'skipExisting' ] == true) {
|
||||
// skip driver
|
||||
} else {
|
||||
// add driver
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $keyword
|
||||
* @param array $option
|
||||
* @return null
|
||||
*/
|
||||
public function driver_get($keyword, $option = array())
|
||||
{
|
||||
// return null if no caching
|
||||
// return value if in caching
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $keyword
|
||||
* @param array $option
|
||||
*/
|
||||
public function driver_delete($keyword, $option = array())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $option
|
||||
* @return array
|
||||
*/
|
||||
public function driver_stats($option = array())
|
||||
{
|
||||
$res = array(
|
||||
'info' => '',
|
||||
'size' => '',
|
||||
'data' => '',
|
||||
);
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $option
|
||||
*/
|
||||
public function driver_clean($option = array())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $keyword
|
||||
*/
|
||||
public function driver_isExisting($keyword)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,222 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of phpFastCache.
|
||||
*
|
||||
* @license MIT License (MIT)
|
||||
*
|
||||
* For full copyright and license information, please see the docs/CREDITS.txt file.
|
||||
*
|
||||
* @author Khoa Bui (khoaofgod) <khoaofgod@gmail.com> http://www.phpfastcache.com
|
||||
* @author Georges.L (Geolim4) <contact@geolim4.com>
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpFastCache\Drivers;
|
||||
|
||||
use phpFastCache\Core\DriverAbstract;
|
||||
use Predis\Client as PredisSoftware;
|
||||
|
||||
/**
|
||||
* Class predis
|
||||
* @package phpFastCache\Drivers
|
||||
*/
|
||||
class predis extends DriverAbstract
|
||||
{
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
public $checked_redis = false;
|
||||
|
||||
/**
|
||||
* phpFastCache_predis constructor.
|
||||
* @param array $config
|
||||
*/
|
||||
public function __construct($config = array())
|
||||
{
|
||||
$this->setup($config);
|
||||
if (!class_exists("\\Predis\\Client")) {
|
||||
$this->required_extension("predis-1.0/autoload");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function checkdriver()
|
||||
{
|
||||
// Check memcache
|
||||
if (!class_exists("\\Predis\\Client")) {
|
||||
$this->required_extension("predis-1.0/autoload");
|
||||
try {
|
||||
\Predis\Autoloader::register();
|
||||
} catch (\Exception $e) {
|
||||
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function connectServer()
|
||||
{
|
||||
|
||||
$server = isset($this->config[ 'redis' ]) ? $this->config[ 'redis' ] : array(
|
||||
'host' => '127.0.0.1',
|
||||
'port' => '6379',
|
||||
'password' => '',
|
||||
'database' => '',
|
||||
);
|
||||
|
||||
|
||||
if ($this->checked_redis === false) {
|
||||
$c = array(
|
||||
'host' => $server[ 'host' ],
|
||||
);
|
||||
|
||||
$port = isset($server[ 'port' ]) ? $server[ 'port' ] : '';
|
||||
if ($port != '') {
|
||||
$c[ 'port' ] = $port;
|
||||
}
|
||||
|
||||
$password = isset($server[ 'password' ]) ? $server[ 'password' ] : '';
|
||||
if ($password != '') {
|
||||
$c[ 'password' ] = $password;
|
||||
}
|
||||
|
||||
$database = isset($server[ 'database' ]) ? $server[ 'database' ] : '';
|
||||
if ($database != '') {
|
||||
$c[ 'database' ] = $database;
|
||||
}
|
||||
|
||||
$timeout = isset($server[ 'timeout' ]) ? $server[ 'timeout' ] : '';
|
||||
if ($timeout != '') {
|
||||
$c[ 'timeout' ] = $timeout;
|
||||
}
|
||||
|
||||
$read_write_timeout = isset($server[ 'read_write_timeout' ]) ? $server[ 'read_write_timeout' ] : '';
|
||||
if ($read_write_timeout != '') {
|
||||
$c[ 'read_write_timeout' ] = $read_write_timeout;
|
||||
}
|
||||
|
||||
$this->instant = new PredisSoftware($c);
|
||||
|
||||
$this->checked_redis = true;
|
||||
|
||||
if (!$this->instant) {
|
||||
$this->fallback = true;
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $keyword
|
||||
* @param string $value
|
||||
* @param int $time
|
||||
* @param array $option
|
||||
* @return mixed
|
||||
*/
|
||||
public function driver_set($keyword, $value = '', $time = 300, $option = array())
|
||||
{
|
||||
if ($this->connectServer()) {
|
||||
$value = $this->encode($value);
|
||||
if (isset($option[ 'skipExisting' ]) && $option[ 'skipExisting' ] == true) {
|
||||
return $this->instant->setex($keyword, $time, $value);
|
||||
} else {
|
||||
return $this->instant->setex($keyword, $time, $value);
|
||||
}
|
||||
} else {
|
||||
return $this->backup()->set($keyword, $value, $time, $option);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $keyword
|
||||
* @param array $option
|
||||
* @return mixed|null
|
||||
*/
|
||||
public function driver_get($keyword, $option = array())
|
||||
{
|
||||
if ($this->connectServer()) {
|
||||
// return null if no caching
|
||||
// return value if in caching'
|
||||
$x = $this->instant->get($keyword);
|
||||
if ($x == false) {
|
||||
return null;
|
||||
} else {
|
||||
|
||||
return $this->decode($x);
|
||||
}
|
||||
} else {
|
||||
$this->backup()->get($keyword, $option);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $keyword
|
||||
* @param array $option
|
||||
*/
|
||||
public function driver_delete($keyword, $option = array())
|
||||
{
|
||||
|
||||
if ($this->connectServer()) {
|
||||
$this->instant->del($keyword);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $option
|
||||
* @return array
|
||||
*/
|
||||
public function driver_stats($option = array())
|
||||
{
|
||||
if ($this->connectServer()) {
|
||||
$res = array(
|
||||
'info' => '',
|
||||
'size' => '',
|
||||
'data' => $this->instant->info(),
|
||||
);
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
return array();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $option
|
||||
* @return void
|
||||
*/
|
||||
public function driver_clean($option = array())
|
||||
{
|
||||
if ($this->connectServer()) {
|
||||
$this->instant->flushDB();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $keyword
|
||||
* @return bool
|
||||
*/
|
||||
public function driver_isExisting($keyword)
|
||||
{
|
||||
if ($this->connectServer()) {
|
||||
$x = $this->instant->exists($keyword);
|
||||
return !($x == null);
|
||||
} else {
|
||||
return $this->backup()->isExisting($keyword);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,225 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of phpFastCache.
|
||||
*
|
||||
* @license MIT License (MIT)
|
||||
*
|
||||
* For full copyright and license information, please see the docs/CREDITS.txt file.
|
||||
*
|
||||
* @author Khoa Bui (khoaofgod) <khoaofgod@gmail.com> http://www.phpfastcache.com
|
||||
* @author Georges.L (Geolim4) <contact@geolim4.com>
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpFastCache\Drivers;
|
||||
|
||||
use phpFastCache\Core\DriverAbstract;
|
||||
use Redis as RedisSoftware;
|
||||
|
||||
/**
|
||||
* Class redis
|
||||
* @package phpFastCache\Drivers
|
||||
*/
|
||||
class redis extends DriverAbstract
|
||||
{
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
public $checked_redis = false;
|
||||
|
||||
/**
|
||||
* phpFastCache_predis constructor.
|
||||
* @param array $config
|
||||
*/
|
||||
public function __construct($config = array())
|
||||
{
|
||||
$this->setup($config);
|
||||
if (!$this->checkdriver() && !isset($config[ 'skipError' ])) {
|
||||
$this->fallback = true;
|
||||
}
|
||||
if (class_exists('Redis')) {
|
||||
$this->instant = new RedisSoftware();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function checkdriver()
|
||||
{
|
||||
// Check memcache
|
||||
if (class_exists('Redis')) {
|
||||
return true;
|
||||
}
|
||||
$this->fallback = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function connectServer()
|
||||
{
|
||||
|
||||
$server = isset($this->config[ 'redis' ]) ? $this->config[ 'redis' ] : array(
|
||||
'host' => '127.0.0.1',
|
||||
'port' => '6379',
|
||||
'password' => '',
|
||||
'database' => '',
|
||||
'timeout' => '1',
|
||||
);
|
||||
|
||||
if ($this->checked_redis === false) {
|
||||
|
||||
$host = $server[ 'host' ];
|
||||
|
||||
$port = isset($server[ 'port' ]) ? (int)$server[ 'port' ] : "";
|
||||
if ($port != '') {
|
||||
$c[ 'port' ] = $port;
|
||||
}
|
||||
|
||||
$password = isset($server[ 'password' ]) ? $server[ 'password' ] : '';
|
||||
if ($password != '') {
|
||||
$c[ 'password' ] = $password;
|
||||
}
|
||||
|
||||
$database = isset($server[ 'database' ]) ? $server[ 'database' ] : '';
|
||||
if ($database != '') {
|
||||
$c[ 'database' ] = $database;
|
||||
}
|
||||
|
||||
$timeout = isset($server[ 'timeout' ]) ? $server[ 'timeout' ] : '';
|
||||
if ($timeout != '') {
|
||||
$c[ 'timeout' ] = $timeout;
|
||||
}
|
||||
|
||||
$read_write_timeout = isset($server[ 'read_write_timeout' ]) ? $server[ 'read_write_timeout' ] : '';
|
||||
if ($read_write_timeout != '') {
|
||||
$c[ 'read_write_timeout' ] = $read_write_timeout;
|
||||
}
|
||||
|
||||
|
||||
if (!$this->instant->connect($host, (int)$port, (int)$timeout)) {
|
||||
$this->checked_redis = true;
|
||||
$this->fallback = true;
|
||||
return false;
|
||||
} else {
|
||||
if ($database != '') {
|
||||
$this->instant->select((int)$database);
|
||||
}
|
||||
$this->checked_redis = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $keyword
|
||||
* @param string $value
|
||||
* @param int $time
|
||||
* @param array $option
|
||||
* @return bool
|
||||
*/
|
||||
public function driver_set($keyword, $value = '', $time = 300, $option = array())
|
||||
{
|
||||
if ($this->connectServer()) {
|
||||
$value = $this->encode($value);
|
||||
if (isset($option[ 'skipExisting' ]) && $option[ 'skipExisting' ] == true) {
|
||||
return $this->instant->set($keyword, $value,
|
||||
array('xx', 'ex' => $time));
|
||||
} else {
|
||||
return $this->instant->set($keyword, $value, $time);
|
||||
}
|
||||
} else {
|
||||
return $this->backup()->set($keyword, $value, $time, $option);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $keyword
|
||||
* @param array $option
|
||||
* @return mixed|null
|
||||
*/
|
||||
public function driver_get($keyword, $option = array())
|
||||
{
|
||||
if ($this->connectServer()) {
|
||||
// return null if no caching
|
||||
// return value if in caching'
|
||||
$x = $this->instant->get($keyword);
|
||||
if ($x == false) {
|
||||
return null;
|
||||
} else {
|
||||
|
||||
return $this->decode($x);
|
||||
}
|
||||
} else {
|
||||
$this->backup()->get($keyword, $option);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $keyword
|
||||
* @param array $option
|
||||
* @return void
|
||||
*/
|
||||
public function driver_delete($keyword, $option = array())
|
||||
{
|
||||
if ($this->connectServer()) {
|
||||
$this->instant->delete($keyword);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $option
|
||||
* @return array
|
||||
*/
|
||||
public function driver_stats($option = array())
|
||||
{
|
||||
if ($this->connectServer()) {
|
||||
$res = array(
|
||||
'info' => '',
|
||||
'size' => '',
|
||||
'data' => $this->instant->info(),
|
||||
);
|
||||
|
||||
return $res;
|
||||
}
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $option
|
||||
*/
|
||||
public function driver_clean($option = array())
|
||||
{
|
||||
if ($this->connectServer()) {
|
||||
$this->instant->flushDB();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $keyword
|
||||
* @return bool
|
||||
*/
|
||||
public function driver_isExisting($keyword)
|
||||
{
|
||||
if ($this->connectServer()) {
|
||||
$x = $this->instant->exists($keyword);
|
||||
if ($x == null) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
return $this->backup()->isExisting($keyword);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,482 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of phpFastCache.
|
||||
*
|
||||
* @license MIT License (MIT)
|
||||
*
|
||||
* For full copyright and license information, please see the docs/CREDITS.txt file.
|
||||
*
|
||||
* @author Khoa Bui (khoaofgod) <khoaofgod@gmail.com> http://www.phpfastcache.com
|
||||
* @author Georges.L (Geolim4) <contact@geolim4.com>
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpFastCache\Drivers;
|
||||
|
||||
use phpFastCache\Core\DriverAbstract;
|
||||
use PDO;
|
||||
use PDOException;
|
||||
use phpFastCache\Exceptions\phpFastCacheDriverException;
|
||||
|
||||
/**
|
||||
* Class sqlite
|
||||
* @package phpFastCache\Drivers
|
||||
*/
|
||||
class sqlite extends DriverAbstract
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
const SQLITE_DIR = 'sqlite';
|
||||
/**
|
||||
*
|
||||
*/
|
||||
const INDEXING_FILE = 'indexing';
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public $max_size = 10; // 10 mb
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public $instant = array();
|
||||
/**
|
||||
* @var null
|
||||
*/
|
||||
public $indexing = null;
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $path = '';
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public $currentDB = 1;
|
||||
|
||||
/**
|
||||
* Init Main Database & Sub Database
|
||||
* phpFastCache_sqlite constructor.
|
||||
* @param array $config
|
||||
* @throws phpFastCacheDriverException
|
||||
*/
|
||||
public function __construct($config = array())
|
||||
{
|
||||
/**
|
||||
* init the path
|
||||
*/
|
||||
$this->setup($config);
|
||||
if (!$this->checkdriver()) {
|
||||
throw new phpFastCacheDriverException('SQLITE is not installed, cannot continue.');
|
||||
}
|
||||
|
||||
if (!file_exists($this->getPath() . '/' . self::SQLITE_DIR)) {
|
||||
if (!mkdir($this->getPath() . '/' . self::SQLITE_DIR, $this->__setChmodAuto(), true)) {
|
||||
$this->fallback = true;
|
||||
}
|
||||
}
|
||||
$this->path = $this->getPath() . '/' . self::SQLITE_DIR;
|
||||
}
|
||||
|
||||
/**
|
||||
* INIT NEW DB
|
||||
* @param \PDO $db
|
||||
*/
|
||||
public function initDB(PDO $db)
|
||||
{
|
||||
$db->exec('drop table if exists "caching"');
|
||||
$db->exec('CREATE TABLE "caching" ("id" INTEGER PRIMARY KEY AUTOINCREMENT, "keyword" VARCHAR UNIQUE, "object" BLOB, "exp" INTEGER)');
|
||||
$db->exec('CREATE UNIQUE INDEX "cleanup" ON "caching" ("keyword","exp")');
|
||||
$db->exec('CREATE INDEX "exp" ON "caching" ("exp")');
|
||||
$db->exec('CREATE UNIQUE INDEX "keyword" ON "caching" ("keyword")');
|
||||
}
|
||||
|
||||
/**
|
||||
* INIT Indexing DB
|
||||
* @param \PDO $db
|
||||
*/
|
||||
public function initIndexing(PDO $db)
|
||||
{
|
||||
|
||||
// delete everything before reset indexing
|
||||
$dir = opendir($this->path);
|
||||
while ($file = readdir($dir)) {
|
||||
if ($file != '.' && $file != '..' && $file != 'indexing' && $file != 'dbfastcache') {
|
||||
unlink($this->path . '/' . $file);
|
||||
}
|
||||
}
|
||||
|
||||
$db->exec('drop table if exists "balancing"');
|
||||
$db->exec('CREATE TABLE "balancing" ("keyword" VARCHAR PRIMARY KEY NOT NULL UNIQUE, "db" INTEGER)');
|
||||
$db->exec('CREATE INDEX "db" ON "balancing" ("db")');
|
||||
$db->exec('CREATE UNIQUE INDEX "lookup" ON "balancing" ("keyword")');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* INIT Instant DB
|
||||
* Return Database of Keyword
|
||||
* @param $keyword
|
||||
* @return int
|
||||
*/
|
||||
public function indexing($keyword)
|
||||
{
|
||||
if ($this->indexing == null) {
|
||||
$createTable = false;
|
||||
if (!file_exists($this->path . '/indexing')) {
|
||||
$createTable = true;
|
||||
}
|
||||
|
||||
$PDO = new PDO("sqlite:" . $this->path . '/' . self::INDEXING_FILE);
|
||||
$PDO->setAttribute(PDO::ATTR_ERRMODE,
|
||||
PDO::ERRMODE_EXCEPTION);
|
||||
|
||||
if ($createTable == true) {
|
||||
$this->initIndexing($PDO);
|
||||
}
|
||||
$this->indexing = $PDO;
|
||||
unset($PDO);
|
||||
|
||||
$stm = $this->indexing->prepare("SELECT MAX(`db`) as `db` FROM `balancing`");
|
||||
$stm->execute();
|
||||
$row = $stm->fetch(PDO::FETCH_ASSOC);
|
||||
if (!isset($row[ 'db' ])) {
|
||||
$db = 1;
|
||||
} elseif ($row[ 'db' ] <= 1) {
|
||||
$db = 1;
|
||||
} else {
|
||||
$db = $row[ 'db' ];
|
||||
}
|
||||
|
||||
// check file size
|
||||
|
||||
$size = file_exists($this->path . '/db' . $db) ? filesize($this->path . '/db' . $db) : 1;
|
||||
$size = round($size / 1024 / 1024, 1);
|
||||
|
||||
|
||||
if ($size > $this->max_size) {
|
||||
$db = $db + 1;
|
||||
}
|
||||
$this->currentDB = $db;
|
||||
|
||||
}
|
||||
|
||||
// look for keyword
|
||||
$stm = $this->indexing->prepare("SELECT * FROM `balancing` WHERE `keyword`=:keyword LIMIT 1");
|
||||
$stm->execute(array(
|
||||
':keyword' => $keyword,
|
||||
));
|
||||
$row = $stm->fetch(PDO::FETCH_ASSOC);
|
||||
if (isset($row[ 'db' ]) && $row[ 'db' ] != '') {
|
||||
$db = $row[ 'db' ];
|
||||
} else {
|
||||
/*
|
||||
* Insert new to Indexing
|
||||
*/
|
||||
$db = $this->currentDB;
|
||||
$stm = $this->indexing->prepare("INSERT INTO `balancing` (`keyword`,`db`) VALUES(:keyword, :db)");
|
||||
$stm->execute(array(
|
||||
':keyword' => $keyword,
|
||||
':db' => $db,
|
||||
));
|
||||
}
|
||||
|
||||
return $db;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $keyword
|
||||
* @param bool $reset
|
||||
* @return mixed
|
||||
*/
|
||||
public function db($keyword, $reset = false)
|
||||
{
|
||||
/**
|
||||
* Default is fastcache
|
||||
*/
|
||||
$instant = $this->indexing($keyword);
|
||||
|
||||
/**
|
||||
* init instant
|
||||
*/
|
||||
if (!isset($this->instant[ $instant ])) {
|
||||
// check DB Files ready or not
|
||||
$createTable = false;
|
||||
if (!file_exists($this->path . '/db' . $instant) || $reset == true) {
|
||||
$createTable = true;
|
||||
}
|
||||
$PDO = new PDO('sqlite:' . $this->path . '/db' . $instant);
|
||||
$PDO->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
|
||||
if ($createTable == true) {
|
||||
$this->initDB($PDO);
|
||||
}
|
||||
|
||||
$this->instant[ $instant ] = $PDO;
|
||||
unset($PDO);
|
||||
|
||||
}
|
||||
|
||||
return $this->instant[ $instant ];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function checkdriver()
|
||||
{
|
||||
if (extension_loaded('pdo_sqlite') && is_writable($this->getPath())) {
|
||||
return true;
|
||||
}
|
||||
$this->fallback = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $keyword
|
||||
* @param string $value
|
||||
* @param int $time
|
||||
* @param array $option
|
||||
* @return bool
|
||||
*/
|
||||
public function driver_set(
|
||||
$keyword,
|
||||
$value = '',
|
||||
$time = 300,
|
||||
$option = array()
|
||||
) {
|
||||
$skipExisting = isset($option[ 'skipExisting' ]) ? $option[ 'skipExisting' ] : false;
|
||||
$toWrite = true;
|
||||
|
||||
// check in cache first
|
||||
$in_cache = $this->get($keyword, $option);
|
||||
|
||||
if ($skipExisting == true) {
|
||||
if ($in_cache == null) {
|
||||
$toWrite = true;
|
||||
} else {
|
||||
$toWrite = false;
|
||||
}
|
||||
}
|
||||
|
||||
if ($toWrite == true) {
|
||||
try {
|
||||
$stm = $this->db($keyword)
|
||||
->prepare("INSERT OR REPLACE INTO `caching` (`keyword`,`object`,`exp`) values(:keyword,:object,:exp)");
|
||||
$stm->execute(array(
|
||||
':keyword' => $keyword,
|
||||
':object' => $this->encode($value),
|
||||
':exp' => time() + (int)$time,
|
||||
));
|
||||
|
||||
return true;
|
||||
} catch (\PDOException $e) {
|
||||
|
||||
try {
|
||||
$stm = $this->db($keyword, true)
|
||||
->prepare("INSERT OR REPLACE INTO `caching` (`keyword`,`object`,`exp`) values(:keyword,:object,:exp)");
|
||||
$stm->execute(array(
|
||||
':keyword' => $keyword,
|
||||
':object' => $this->encode($value),
|
||||
':exp' => time() + (int)$time,
|
||||
));
|
||||
} catch (PDOException $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $keyword
|
||||
* @param array $option
|
||||
* @return mixed|null
|
||||
*/
|
||||
public function driver_get($keyword, $option = array())
|
||||
{
|
||||
// return null if no caching
|
||||
// return value if in caching
|
||||
try {
|
||||
$stm = $this->db($keyword)
|
||||
->prepare("SELECT * FROM `caching` WHERE `keyword`=:keyword LIMIT 1");
|
||||
$stm->execute(array(
|
||||
':keyword' => $keyword,
|
||||
));
|
||||
$row = $stm->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
} catch (PDOException $e) {
|
||||
try {
|
||||
$stm = $this->db($keyword, true)
|
||||
->prepare("SELECT * FROM `caching` WHERE `keyword`=:keyword LIMIT 1");
|
||||
$stm->execute(array(
|
||||
':keyword' => $keyword,
|
||||
));
|
||||
$row = $stm->fetch(PDO::FETCH_ASSOC);
|
||||
} catch (PDOException $e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ($this->isExpired($row)) {
|
||||
$this->deleteRow($row);
|
||||
return null;
|
||||
}
|
||||
|
||||
if (isset($row[ 'id' ])) {
|
||||
$data = $this->decode($row[ 'object' ]);
|
||||
return $data;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $row
|
||||
* @return bool
|
||||
*/
|
||||
public function isExpired($row)
|
||||
{
|
||||
if (isset($row[ 'exp' ]) && time() >= $row[ 'exp' ]) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $row
|
||||
* @return bool
|
||||
*/
|
||||
public function deleteRow($row)
|
||||
{
|
||||
try {
|
||||
$stm = $this->db($row[ 'keyword' ])
|
||||
->prepare("DELETE FROM `caching` WHERE (`id`=:id) OR (`exp` <= :U) ");
|
||||
$stm->execute(array(
|
||||
':id' => $row[ 'id' ],
|
||||
':U' => time(),
|
||||
));
|
||||
} catch (PDOException $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $keyword
|
||||
* @param array $option
|
||||
* @return bool
|
||||
*/
|
||||
public function driver_delete($keyword, $option = array())
|
||||
{
|
||||
try {
|
||||
$stm = $this->db($keyword)
|
||||
->prepare("DELETE FROM `caching` WHERE (`keyword`=:keyword) OR (`exp` <= :U)");
|
||||
$stm->execute(array(
|
||||
':keyword' => $keyword,
|
||||
':U' => time(),
|
||||
));
|
||||
} catch (PDOException $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return total cache size + auto removed expired entries
|
||||
* @param array $option
|
||||
* @return array
|
||||
*/
|
||||
public function driver_stats($option = array())
|
||||
{
|
||||
$res = array(
|
||||
'info' => '',
|
||||
'size' => '',
|
||||
'data' => '',
|
||||
);
|
||||
$total = 0;
|
||||
$optimized = 0;
|
||||
|
||||
$dir = opendir($this->path);
|
||||
while ($file = readdir($dir)) {
|
||||
if ($file != '.' && $file != '..') {
|
||||
$file_path = $this->path . "/" . $file;
|
||||
$size = filesize($file_path);
|
||||
$total = $total + $size;
|
||||
|
||||
try {
|
||||
$PDO = new PDO("sqlite:" . $file_path);
|
||||
$PDO->setAttribute(PDO::ATTR_ERRMODE,
|
||||
PDO::ERRMODE_EXCEPTION);
|
||||
|
||||
$stm = $PDO->prepare("DELETE FROM `caching` WHERE `exp` <= :U");
|
||||
$stm->execute(array(
|
||||
':U' => date('U'),
|
||||
));
|
||||
|
||||
$PDO->exec('VACUUM;');
|
||||
$size = filesize($file_path);
|
||||
$optimized = $optimized + $size;
|
||||
} catch (PDOException $e) {
|
||||
$size = 0;
|
||||
$optimized = 0;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
$res[ 'size' ] = $optimized;
|
||||
$res[ 'info' ] = array(
|
||||
'total before removing expired entries [bytes]' => $total,
|
||||
'optimized after removing expired entries [bytes]' => $optimized,
|
||||
);
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $option
|
||||
* @return void
|
||||
*/
|
||||
public function driver_clean($option = array())
|
||||
{
|
||||
// close connection
|
||||
$this->instant = array();
|
||||
$this->indexing = null;
|
||||
|
||||
// delete everything before reset indexing
|
||||
$dir = opendir($this->path);
|
||||
while ($file = readdir($dir)) {
|
||||
if ($file != '.' && $file != '..') {
|
||||
unlink($this->path . '/' . $file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $keyword
|
||||
* @return bool
|
||||
*/
|
||||
public function driver_isExisting($keyword)
|
||||
{
|
||||
try {
|
||||
$stm = $this->db($keyword)
|
||||
->prepare("SELECT COUNT(`id`) as `total` FROM `caching` WHERE `keyword`=:keyword");
|
||||
$stm->execute(array(
|
||||
':keyword' => $keyword,
|
||||
));
|
||||
$data = $stm->fetch(PDO::FETCH_ASSOC);
|
||||
if ($data[ 'total' ] >= 1) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} catch (PDOException $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,191 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of phpFastCache.
|
||||
*
|
||||
* @license MIT License (MIT)
|
||||
*
|
||||
* For full copyright and license information, please see the docs/CREDITS.txt file.
|
||||
*
|
||||
* @author Khoa Bui (khoaofgod) <khoaofgod@gmail.com> http://www.phpfastcache.com
|
||||
* @author Georges.L (Geolim4) <contact@geolim4.com>
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpFastCache\Drivers;
|
||||
|
||||
use phpFastCache\Core\DriverAbstract;
|
||||
|
||||
/**
|
||||
* Class ssdb
|
||||
* @package phpFastCache\Drivers
|
||||
*/
|
||||
class ssdb extends DriverAbstract
|
||||
{
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $checked_ssdb = false;
|
||||
|
||||
/**
|
||||
* phpFastCache_ssdb constructor.
|
||||
* @param array $config
|
||||
*/
|
||||
public function __construct($config = array())
|
||||
{
|
||||
$this->setup($config);
|
||||
if (!$this->checkdriver() && !isset($config[ 'skipError' ])) {
|
||||
$this->fallback = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function checkdriver()
|
||||
{
|
||||
// Check memcache
|
||||
$this->required_extension('SSDB');
|
||||
if (class_exists('SimpleSSDB')) {
|
||||
return true;
|
||||
}
|
||||
$this->fallback = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function connectServer()
|
||||
{
|
||||
|
||||
$server = isset($this->config[ 'ssdb' ]) ? $this->config[ 'ssdb' ] : array(
|
||||
'host' => "127.0.0.1",
|
||||
'port' => 8888,
|
||||
'password' => '',
|
||||
'timeout' => 2000,
|
||||
);
|
||||
|
||||
if ($this->checked_ssdb === false) {
|
||||
$host = $server[ 'host' ];
|
||||
$port = isset($server[ 'port' ]) ? (int)$server[ 'port' ] : 8888;
|
||||
$password = isset($server[ 'password' ]) ? $server[ 'password' ] : '';
|
||||
$timeout = !empty($server[ 'timeout' ]) ? (int)$server[ 'timeout' ] : 2000;
|
||||
$this->instant = new \SimpleSSDB($host, $port, $timeout);
|
||||
if (!empty($password)) {
|
||||
$this->instant->auth($password);
|
||||
}
|
||||
$this->checked_ssdb = true;
|
||||
if (!$this->instant) {
|
||||
$this->fallback = true;
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $keyword
|
||||
* @param string $value
|
||||
* @param int $time
|
||||
* @param array $option
|
||||
* @return bool
|
||||
*/
|
||||
public function driver_set($keyword, $value = '', $time = 300, $option = array())
|
||||
{
|
||||
if ($this->connectServer()) {
|
||||
if (isset($option[ 'skipExisting' ]) && $option[ 'skipExisting' ] == true) {
|
||||
$x = $this->instant->get($keyword);
|
||||
if ($x === false) {
|
||||
return false;
|
||||
} elseif (!is_null($x)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
$value = $this->encode($value);
|
||||
return $this->instant->setx($keyword, $value, $time);
|
||||
} else {
|
||||
return $this->backup()->set($keyword, $value, $time, $option);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $keyword
|
||||
* @param array $option
|
||||
* @return mixed|null
|
||||
*/
|
||||
public function driver_get($keyword, $option = array())
|
||||
{
|
||||
if ($this->connectServer()) {
|
||||
// return null if no caching
|
||||
// return value if in caching'
|
||||
$x = $this->instant->get($keyword);
|
||||
if ($x == false) {
|
||||
return null;
|
||||
} else {
|
||||
return $this->decode($x);
|
||||
}
|
||||
} else {
|
||||
$this->backup()->get($keyword, $option);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $keyword
|
||||
* @param array $option
|
||||
*/
|
||||
public function driver_delete($keyword, $option = array())
|
||||
{
|
||||
if ($this->connectServer()) {
|
||||
$this->instant->del($keyword);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $option
|
||||
* @return array
|
||||
*/
|
||||
public function driver_stats($option = array())
|
||||
{
|
||||
if ($this->connectServer()) {
|
||||
$res = array(
|
||||
'info' => '',
|
||||
'size' => $this->instant->dbsize(),
|
||||
'data' => $this->instant->info(),
|
||||
);
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $option
|
||||
* @return bool
|
||||
*/
|
||||
public function driver_clean($option = array())
|
||||
{
|
||||
//Is not supported, only support command line operations
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $keyword
|
||||
* @return bool
|
||||
*/
|
||||
public function driver_isExisting($keyword)
|
||||
{
|
||||
if ($this->connectServer()) {
|
||||
$x = $this->instant->exists($keyword);
|
||||
return !($x == null);
|
||||
} else {
|
||||
return $this->backup()->isExisting($keyword);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,133 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of phpFastCache.
|
||||
*
|
||||
* @license MIT License (MIT)
|
||||
*
|
||||
* For full copyright and license information, please see the docs/CREDITS.txt file.
|
||||
*
|
||||
* @author Khoa Bui (khoaofgod) <khoaofgod@gmail.com> http://www.phpfastcache.com
|
||||
* @author Georges.L (Geolim4) <contact@geolim4.com>
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpFastCache\Drivers;
|
||||
|
||||
use phpFastCache\Core\DriverAbstract;
|
||||
|
||||
/**
|
||||
* Class wincache
|
||||
* @package phpFastCache\Drivers
|
||||
*/
|
||||
class wincache extends DriverAbstract
|
||||
{
|
||||
|
||||
/**
|
||||
* phpFastCache_wincache constructor.
|
||||
* @param array $config
|
||||
*/
|
||||
public function __construct($config = array())
|
||||
{
|
||||
$this->setup($config);
|
||||
if (!$this->checkdriver() && !isset($config[ 'skipError' ])) {
|
||||
$this->fallback = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function checkdriver()
|
||||
{
|
||||
if (extension_loaded('wincache') && function_exists('wincache_ucache_set')) {
|
||||
return true;
|
||||
}
|
||||
$this->fallback = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $keyword
|
||||
* @param string $value
|
||||
* @param int $time
|
||||
* @param array $option
|
||||
* @return bool
|
||||
*/
|
||||
public function driver_set($keyword, $value = "", $time = 300, $option = array())
|
||||
{
|
||||
if (isset($option[ 'skipExisting' ]) && $option[ 'skipExisting' ] == true) {
|
||||
return wincache_ucache_add($keyword, $value, $time);
|
||||
} else {
|
||||
return wincache_ucache_set($keyword, $value, $time);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $keyword
|
||||
* @param array $option
|
||||
* @return mixed|null
|
||||
*/
|
||||
public function driver_get($keyword, $option = array())
|
||||
{
|
||||
// return null if no caching
|
||||
// return value if in caching
|
||||
|
||||
$x = wincache_ucache_get($keyword, $suc);
|
||||
|
||||
if ($suc == false) {
|
||||
return null;
|
||||
} else {
|
||||
return $x;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $keyword
|
||||
* @param array $option
|
||||
* @return bool
|
||||
*/
|
||||
public function driver_delete($keyword, $option = array())
|
||||
{
|
||||
return wincache_ucache_delete($keyword);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $option
|
||||
* @return array
|
||||
*/
|
||||
public function driver_stats($option = array())
|
||||
{
|
||||
$res = array(
|
||||
'info' => '',
|
||||
'size' => '',
|
||||
'data' => wincache_scache_info(),
|
||||
);
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $option
|
||||
* @return bool
|
||||
*/
|
||||
public function driver_clean($option = array())
|
||||
{
|
||||
wincache_ucache_clear();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $keyword
|
||||
* @return bool
|
||||
*/
|
||||
public function driver_isExisting($keyword)
|
||||
{
|
||||
if (wincache_ucache_exists($keyword)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,141 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of phpFastCache.
|
||||
*
|
||||
* @license MIT License (MIT)
|
||||
*
|
||||
* For full copyright and license information, please see the docs/CREDITS.txt file.
|
||||
*
|
||||
* @author Khoa Bui (khoaofgod) <khoaofgod@gmail.com> http://www.phpfastcache.com
|
||||
* @author Georges.L (Geolim4) <contact@geolim4.com>
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpFastCache\Drivers;
|
||||
|
||||
use phpFastCache\Core\DriverAbstract;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Class xcache
|
||||
* @package phpFastCache\Drivers
|
||||
*/
|
||||
class xcache extends DriverAbstract
|
||||
{
|
||||
|
||||
/**
|
||||
* phpFastCache_xcache constructor.
|
||||
* @param array $config
|
||||
*/
|
||||
public function __construct($config = array())
|
||||
{
|
||||
$this->setup($config);
|
||||
if (!$this->checkdriver() && !isset($config[ 'skipError' ])) {
|
||||
$this->fallback = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function checkdriver()
|
||||
{
|
||||
// Check xcache
|
||||
if (extension_loaded('xcache') && function_exists('xcache_get')) {
|
||||
return true;
|
||||
}
|
||||
$this->fallback = true;
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $keyword
|
||||
* @param string $value
|
||||
* @param int $time
|
||||
* @param array $option
|
||||
* @return bool
|
||||
*/
|
||||
public function driver_set($keyword, $value = "", $time = 300, $option = array())
|
||||
{
|
||||
|
||||
if (isset($option[ 'skipExisting' ]) && $option[ 'skipExisting' ] == true) {
|
||||
if (!$this->isExisting($keyword)) {
|
||||
return xcache_set($keyword, serialize($value), $time);
|
||||
}
|
||||
} else {
|
||||
return xcache_set($keyword, serialize($value), $time);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $keyword
|
||||
* @param array $option
|
||||
* @return mixed|null
|
||||
*/
|
||||
public function driver_get($keyword, $option = array())
|
||||
{
|
||||
// return null if no caching
|
||||
// return value if in caching
|
||||
$data = unserialize(xcache_get($keyword));
|
||||
if ($data === false || $data == '') {
|
||||
return null;
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $keyword
|
||||
* @param array $option
|
||||
* @return bool
|
||||
*/
|
||||
public function driver_delete($keyword, $option = array())
|
||||
{
|
||||
return xcache_unset($keyword);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $option
|
||||
* @return array
|
||||
*/
|
||||
public function driver_stats($option = array())
|
||||
{
|
||||
$res = array(
|
||||
'info' => '',
|
||||
'size' => '',
|
||||
'data' => '',
|
||||
);
|
||||
|
||||
try {
|
||||
$res[ 'data' ] = xcache_list(XC_TYPE_VAR, 100);
|
||||
} catch (Exception $e) {
|
||||
$res[ 'data' ] = array();
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $option
|
||||
* @return bool
|
||||
*/
|
||||
public function driver_clean($option = array())
|
||||
{
|
||||
$cnt = xcache_count(XC_TYPE_VAR);
|
||||
for ($i = 0; $i < $cnt; $i++) {
|
||||
xcache_clear_cache(XC_TYPE_VAR, $i);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $keyword
|
||||
* @return bool
|
||||
*/
|
||||
public function driver_isExisting($keyword)
|
||||
{
|
||||
return xcache_isset($keyword);
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of phpFastCache.
|
||||
*
|
||||
* @license MIT License (MIT)
|
||||
*
|
||||
* For full copyright and license information, please see the docs/CREDITS.txt file.
|
||||
*
|
||||
* @author Khoa Bui (khoaofgod) <khoaofgod@gmail.com> http://www.phpfastcache.com
|
||||
* @author Georges.L (Geolim4) <contact@geolim4.com>
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpFastCache\Exceptions;
|
||||
|
||||
use \Exception;
|
||||
|
||||
/**
|
||||
* Class phpFastCacheCoreException
|
||||
* @package phpFastCache\Exceptions
|
||||
*/
|
||||
class phpFastCacheCoreException extends Exception
|
||||
{
|
||||
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of phpFastCache.
|
||||
*
|
||||
* @license MIT License (MIT)
|
||||
*
|
||||
* For full copyright and license information, please see the docs/CREDITS.txt file.
|
||||
*
|
||||
* @author Khoa Bui (khoaofgod) <khoaofgod@gmail.com> http://www.phpfastcache.com
|
||||
* @author Georges.L (Geolim4) <contact@geolim4.com>
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpFastCache\Exceptions;
|
||||
|
||||
use \Exception;
|
||||
|
||||
/**
|
||||
* Class phpFastCacheDriverException
|
||||
* @package phpFastCache\Exceptions
|
||||
*/
|
||||
class phpFastCacheDriverException extends Exception
|
||||
{
|
||||
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of phpFastCache.
|
||||
*
|
||||
* @license MIT License (MIT)
|
||||
*
|
||||
* For full copyright and license information, please see the docs/CREDITS.txt file.
|
||||
*
|
||||
* @author Khoa Bui (khoaofgod) <khoaofgod@gmail.com> http://www.phpfastcache.com
|
||||
* @author Georges.L (Geolim4) <contact@geolim4.com>
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpFastCache\plugins;
|
||||
|
||||
use phpFastCache\CacheManager;
|
||||
|
||||
// Setup your cronjob to run this file every
|
||||
// 30 mins - 60 mins to help clean up
|
||||
// the expired files faster
|
||||
|
||||
require_once (__DIR__ . "/../phpFastCache.php");
|
||||
|
||||
$setup = array(
|
||||
"path" => "/your_path/to_clean/"
|
||||
);
|
||||
|
||||
$cache = CacheManager::Files($setup);
|
||||
|
||||
// clean up expired files cache every hour
|
||||
// For now only "files" drivers is supported
|
||||
$cache->autoCleanExpired(3600*1);
|
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of phpFastCache.
|
||||
*
|
||||
* @license MIT License (MIT)
|
||||
*
|
||||
* For full copyright and license information, please see the docs/CREDITS.txt file.
|
||||
*
|
||||
* @author Khoa Bui (khoaofgod) <khoaofgod@gmail.com> http://www.phpfastcache.com
|
||||
* @author Georges.L (Geolim4) <contact@geolim4.com>
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpFastCache\Util;
|
||||
use phpFastCache\Exceptions\phpFastCacheCoreException;
|
||||
|
||||
|
||||
/**
|
||||
* Class Languages
|
||||
* @author Khoa Bui (khoaofgod) <khoaofgod@gmail.com> http://www.phpfastcache.com
|
||||
* @author Georges.L (Geolim4) <contact@geolim4.com>
|
||||
*
|
||||
*/
|
||||
class Languages
|
||||
{
|
||||
public static function setEncoding($encoding = 'UTF-8', $language = null)
|
||||
{
|
||||
if ($language === null || !in_array($language, array('uni', 'Japanese', 'ja', 'English', 'en'), true)) {
|
||||
$language = 'uni';
|
||||
}
|
||||
switch(strtoupper($encoding))
|
||||
{
|
||||
case 'UTF-8':
|
||||
if(extension_loaded("mbstring")) {
|
||||
mb_internal_encoding($encoding);
|
||||
mb_http_output($encoding);
|
||||
mb_http_input($encoding);
|
||||
mb_language($language);
|
||||
mb_regex_encoding($encoding);
|
||||
} else {
|
||||
throw new phpFastCacheCoreException("MB String need to be installed for Unicode Encoding");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
/*
|
||||
* If Any problem with Autoload on other project
|
||||
* Try to put this line on your config project
|
||||
* define("PHPFASTCACHE_LEGACY",true);
|
||||
* and just keep include phpFastCache/phpFastCache.php or Composer Autoloader
|
||||
*/
|
||||
|
||||
use phpFastCache\CacheManager;
|
||||
|
||||
require_once __DIR__.'/../Core/DriverInterface.php';
|
||||
require_once __DIR__.'/../Core/DriverAbstract.php';
|
||||
require_once __DIR__.'/../Core/phpFastCache.php';
|
||||
require_once __DIR__.'/../Core/phpFastCacheExtensions.php';
|
||||
require_once __DIR__.'/../Exceptions/phpFastCacheCoreException.php';
|
||||
require_once __DIR__.'/../Exceptions/phpFastCacheDriverException.php';
|
||||
|
||||
require_once __DIR__.'/../Drivers/files.php';
|
||||
require_once __DIR__.'/../Drivers/memcache.php';
|
||||
require_once __DIR__.'/../Drivers/memcached.php';
|
||||
require_once __DIR__.'/../Drivers/mongodb.php';
|
||||
require_once __DIR__.'/../Drivers/predis.php';
|
||||
require_once __DIR__.'/../Drivers/redis.php';
|
||||
require_once __DIR__.'/../Drivers/sqlite.php';
|
||||
|
||||
require_once __DIR__.'/../CacheManager.php';
|
||||
require_once __DIR__.'/../phpFastCache.php';
|
||||
|
||||
|
||||
/**
|
||||
* __c() Short alias
|
||||
* @param string $storage
|
||||
* @param array $config
|
||||
* @return mixed
|
||||
*/
|
||||
if (!function_exists("__c")) {
|
||||
function __c($storage = 'auto', $config = array())
|
||||
{
|
||||
return CacheManager::getInstance($storage, $config);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
namespace phpFastCache\Util;
|
||||
define('PHP_OPEN_BASEDIR', @ini_get("open_basedir"));
|
||||
|
||||
class OpenBaseDir {
|
||||
public static $stores = array();
|
||||
public static function checkBaseDir($path) {
|
||||
if(!is_null(PHP_OPEN_BASEDIR) && PHP_OPEN_BASEDIR != "") {
|
||||
/*
|
||||
* ONLY check ONE time if System Have Open Base Dir
|
||||
* Else, always return TRUE for system without OPenBaseDir
|
||||
*/
|
||||
$index = md5($path);
|
||||
if (!isset(self::$stores[$index])) {
|
||||
// never check before, then check it 1 one time for the src dir only
|
||||
$list = explode(":", PHP_OPEN_BASEDIR);
|
||||
foreach ($list as $allowed_path) {
|
||||
$tmp = explode($allowed_path, $path, 2);
|
||||
if ($tmp[0] != $path) {
|
||||
// echo "<br>".$tmp[0]." = ".$path." BY {$allowed_path}";
|
||||
self::$stores[$index] = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
self::$stores[$index] = false;
|
||||
} else {
|
||||
return self::$stores[$index];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1 @@
|
||||
<a href="http://www.phpfastcache.com" title="Simple Php Caching Class">Visit www.phpfastcache.com</a>
|
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of phpFastCache.
|
||||
*
|
||||
* @license MIT License (MIT)
|
||||
*
|
||||
* For full copyright and license information, please see the docs/CREDITS.txt file.
|
||||
*
|
||||
* @author Khoa Bui (khoaofgod) <khoaofgod@gmail.com> http://www.phpfastcache.com
|
||||
* @author Georges.L (Geolim4) <contact@geolim4.com>
|
||||
*
|
||||
*/
|
||||
|
||||
use phpFastCache\CacheManager;
|
||||
define('PHP_EXT', substr(strrchr(__FILE__, '.'), 1));
|
||||
|
||||
if(!defined("PHPFASTCACHE_LEGACY")) {
|
||||
/**
|
||||
* Register Autoload
|
||||
*/
|
||||
spl_autoload_register(function ($entity) {
|
||||
// Explode is faster than substr & strstr also more control
|
||||
$module = explode('\\',$entity,2);
|
||||
if ($module[0] !== 'phpFastCache') {
|
||||
/**
|
||||
* Not a part of phpFastCache file
|
||||
* then we return here.
|
||||
*/
|
||||
return;
|
||||
}
|
||||
|
||||
$entity = str_replace('\\', '/', $module[1]);
|
||||
$path = __DIR__ . '/' . $entity . '.' . PHP_EXT;
|
||||
if (is_readable($path)) {
|
||||
require_once $path;
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
require_once __DIR__.'/Util/Legacy.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* phpFastCache() Full alias
|
||||
* @param string $storage
|
||||
* @param array $config
|
||||
* @return mixed
|
||||
*/
|
||||
if (!function_exists("phpFastCache")) {
|
||||
function phpFastCache($storage = 'auto', $config = array())
|
||||
{
|
||||
return CacheManager::getInstance($storage, $config);
|
||||
}
|
||||
}
|
@ -0,0 +1,674 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
{one line to give the program's name and a brief idea of what it does.}
|
||||
Copyright (C) {year} {name of author}
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
{project} Copyright (C) {year} {fullname}
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
After Width: | Height: | Size: 643 B |
After Width: | Height: | Size: 408 B |
After Width: | Height: | Size: 604 B |
After Width: | Height: | Size: 591 B |
After Width: | Height: | Size: 643 B |
After Width: | Height: | Size: 600 B |
After Width: | Height: | Size: 497 B |
After Width: | Height: | Size: 488 B |
After Width: | Height: | Size: 428 B |
After Width: | Height: | Size: 506 B |
After Width: | Height: | Size: 647 B |
After Width: | Height: | Size: 403 B |
After Width: | Height: | Size: 673 B |
After Width: | Height: | Size: 524 B |
After Width: | Height: | Size: 663 B |
After Width: | Height: | Size: 589 B |
After Width: | Height: | Size: 593 B |
After Width: | Height: | Size: 585 B |
After Width: | Height: | Size: 504 B |
After Width: | Height: | Size: 449 B |
After Width: | Height: | Size: 497 B |
After Width: | Height: | Size: 462 B |
After Width: | Height: | Size: 457 B |
After Width: | Height: | Size: 675 B |
After Width: | Height: | Size: 486 B |
After Width: | Height: | Size: 545 B |
After Width: | Height: | Size: 611 B |
After Width: | Height: | Size: 639 B |
After Width: | Height: | Size: 500 B |
After Width: | Height: | Size: 593 B |
After Width: | Height: | Size: 526 B |
After Width: | Height: | Size: 631 B |
After Width: | Height: | Size: 512 B |
After Width: | Height: | Size: 443 B |
After Width: | Height: | Size: 514 B |
After Width: | Height: | Size: 600 B |
After Width: | Height: | Size: 628 B |
After Width: | Height: | Size: 625 B |
After Width: | Height: | Size: 528 B |
After Width: | Height: | Size: 614 B |
After Width: | Height: | Size: 521 B |
After Width: | Height: | Size: 367 B |
After Width: | Height: | Size: 453 B |
After Width: | Height: | Size: 586 B |
After Width: | Height: | Size: 450 B |
After Width: | Height: | Size: 525 B |
After Width: | Height: | Size: 472 B |
After Width: | Height: | Size: 483 B |
After Width: | Height: | Size: 477 B |
After Width: | Height: | Size: 439 B |
After Width: | Height: | Size: 563 B |
After Width: | Height: | Size: 529 B |