forked from devsam/core
e_lib 코드들을 composer로 이동
func_http 삭제. guzzle로 대체 php 파일에서 include, require 앞에 있는 구문들을 전부 뒤로 이동.
This commit is contained in:
+3
-1
@@ -2,6 +2,8 @@
|
||||
"require": {
|
||||
"brandonwamboldt/utilphp": "^1.1",
|
||||
"sergeytsalkov/meekrodb": "^2.3",
|
||||
"league/plates": "^3.3"
|
||||
"league/plates": "^3.3",
|
||||
"phpmailer/phpmailer": "^6.0",
|
||||
"guzzlehttp/guzzle": "^6.3"
|
||||
}
|
||||
}
|
||||
|
||||
Generated
+298
-1
@@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "08d6fa0a77eca6b860aa39d42081eea9",
|
||||
"content-hash": "450a6f5772559666e92515aa10280024",
|
||||
"packages": [
|
||||
{
|
||||
"name": "brandonwamboldt/utilphp",
|
||||
@@ -52,6 +52,187 @@
|
||||
],
|
||||
"time": "2015-02-02T17:56:14+00:00"
|
||||
},
|
||||
{
|
||||
"name": "guzzlehttp/guzzle",
|
||||
"version": "6.3.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/guzzle/guzzle.git",
|
||||
"reference": "f4db5a78a5ea468d4831de7f0bf9d9415e348699"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/f4db5a78a5ea468d4831de7f0bf9d9415e348699",
|
||||
"reference": "f4db5a78a5ea468d4831de7f0bf9d9415e348699",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"guzzlehttp/promises": "^1.0",
|
||||
"guzzlehttp/psr7": "^1.4",
|
||||
"php": ">=5.5"
|
||||
},
|
||||
"require-dev": {
|
||||
"ext-curl": "*",
|
||||
"phpunit/phpunit": "^4.0 || ^5.0",
|
||||
"psr/log": "^1.0"
|
||||
},
|
||||
"suggest": {
|
||||
"psr/log": "Required for using the Log middleware"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "6.2-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"files": [
|
||||
"src/functions_include.php"
|
||||
],
|
||||
"psr-4": {
|
||||
"GuzzleHttp\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Michael Dowling",
|
||||
"email": "mtdowling@gmail.com",
|
||||
"homepage": "https://github.com/mtdowling"
|
||||
}
|
||||
],
|
||||
"description": "Guzzle is a PHP HTTP client library",
|
||||
"homepage": "http://guzzlephp.org/",
|
||||
"keywords": [
|
||||
"client",
|
||||
"curl",
|
||||
"framework",
|
||||
"http",
|
||||
"http client",
|
||||
"rest",
|
||||
"web service"
|
||||
],
|
||||
"time": "2017-06-22T18:50:49+00:00"
|
||||
},
|
||||
{
|
||||
"name": "guzzlehttp/promises",
|
||||
"version": "v1.3.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/guzzle/promises.git",
|
||||
"reference": "a59da6cf61d80060647ff4d3eb2c03a2bc694646"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/guzzle/promises/zipball/a59da6cf61d80060647ff4d3eb2c03a2bc694646",
|
||||
"reference": "a59da6cf61d80060647ff4d3eb2c03a2bc694646",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.5.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^4.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.4-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"GuzzleHttp\\Promise\\": "src/"
|
||||
},
|
||||
"files": [
|
||||
"src/functions_include.php"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Michael Dowling",
|
||||
"email": "mtdowling@gmail.com",
|
||||
"homepage": "https://github.com/mtdowling"
|
||||
}
|
||||
],
|
||||
"description": "Guzzle promises library",
|
||||
"keywords": [
|
||||
"promise"
|
||||
],
|
||||
"time": "2016-12-20T10:07:11+00:00"
|
||||
},
|
||||
{
|
||||
"name": "guzzlehttp/psr7",
|
||||
"version": "1.4.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/guzzle/psr7.git",
|
||||
"reference": "f5b8a8512e2b58b0071a7280e39f14f72e05d87c"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/guzzle/psr7/zipball/f5b8a8512e2b58b0071a7280e39f14f72e05d87c",
|
||||
"reference": "f5b8a8512e2b58b0071a7280e39f14f72e05d87c",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.4.0",
|
||||
"psr/http-message": "~1.0"
|
||||
},
|
||||
"provide": {
|
||||
"psr/http-message-implementation": "1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~4.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.4-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"GuzzleHttp\\Psr7\\": "src/"
|
||||
},
|
||||
"files": [
|
||||
"src/functions_include.php"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Michael Dowling",
|
||||
"email": "mtdowling@gmail.com",
|
||||
"homepage": "https://github.com/mtdowling"
|
||||
},
|
||||
{
|
||||
"name": "Tobias Schultze",
|
||||
"homepage": "https://github.com/Tobion"
|
||||
}
|
||||
],
|
||||
"description": "PSR-7 message implementation that also provides common utility methods",
|
||||
"keywords": [
|
||||
"http",
|
||||
"message",
|
||||
"request",
|
||||
"response",
|
||||
"stream",
|
||||
"uri",
|
||||
"url"
|
||||
],
|
||||
"time": "2017-03-20T17:10:46+00:00"
|
||||
},
|
||||
{
|
||||
"name": "league/plates",
|
||||
"version": "3.3.0",
|
||||
@@ -107,6 +288,122 @@
|
||||
],
|
||||
"time": "2016-12-28T00:14:17+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpmailer/phpmailer",
|
||||
"version": "v6.0.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/PHPMailer/PHPMailer.git",
|
||||
"reference": "44d49bab5ab1fef721d3ee07e75dc0865ddf4cc6"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/PHPMailer/PHPMailer/zipball/44d49bab5ab1fef721d3ee07e75dc0865ddf4cc6",
|
||||
"reference": "44d49bab5ab1fef721d3ee07e75dc0865ddf4cc6",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-ctype": "*",
|
||||
"ext-filter": "*",
|
||||
"php": ">=5.5.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"doctrine/annotations": "1.2.*",
|
||||
"friendsofphp/php-cs-fixer": "^2.2",
|
||||
"phpdocumentor/phpdocumentor": "2.*",
|
||||
"phpunit/phpunit": "^4.8 || ^5.7",
|
||||
"zendframework/zend-eventmanager": "3.0.*",
|
||||
"zendframework/zend-i18n": "2.7.3",
|
||||
"zendframework/zend-serializer": "2.7.*"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-mbstring": "Needed to send email in multibyte encoding charset",
|
||||
"hayageek/oauth2-yahoo": "Needed for Yahoo XOAUTH2 authentication",
|
||||
"league/oauth2-google": "Needed for Google XOAUTH2 authentication",
|
||||
"psr/log": "For optional PSR-3 debug logging",
|
||||
"stevenmaguire/oauth2-microsoft": "Needed for Microsoft XOAUTH2 authentication",
|
||||
"symfony/polyfill-mbstring": "To support UTF-8 if the Mbstring PHP extension is not enabled (^1.2)"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"PHPMailer\\PHPMailer\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"LGPL-2.1"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Jim Jagielski",
|
||||
"email": "jimjag@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Marcus Bointon",
|
||||
"email": "phpmailer@synchromedia.co.uk"
|
||||
},
|
||||
{
|
||||
"name": "Andy Prevost",
|
||||
"email": "codeworxtech@users.sourceforge.net"
|
||||
},
|
||||
{
|
||||
"name": "Brent R. Matzelle"
|
||||
}
|
||||
],
|
||||
"description": "PHPMailer is a full-featured email creation and transfer class for PHP",
|
||||
"time": "2018-01-05T13:19:58+00:00"
|
||||
},
|
||||
{
|
||||
"name": "psr/http-message",
|
||||
"version": "1.0.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/php-fig/http-message.git",
|
||||
"reference": "f6561bf28d520154e4b0ec72be95418abe6d9363"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363",
|
||||
"reference": "f6561bf28d520154e4b0ec72be95418abe6d9363",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Psr\\Http\\Message\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "PHP-FIG",
|
||||
"homepage": "http://www.php-fig.org/"
|
||||
}
|
||||
],
|
||||
"description": "Common interface for HTTP messages",
|
||||
"homepage": "https://github.com/php-fig/http-message",
|
||||
"keywords": [
|
||||
"http",
|
||||
"http-message",
|
||||
"psr",
|
||||
"psr-7",
|
||||
"request",
|
||||
"response"
|
||||
],
|
||||
"time": "2016-08-06T14:39:51+00:00"
|
||||
},
|
||||
{
|
||||
"name": "sergeytsalkov/meekrodb",
|
||||
"version": "v2.3",
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
<?php
|
||||
require(__dir__.'/../vendor/autoload.php');
|
||||
require_once(__dir__.'/../e_lib/phpmailer5/class.phpmailer.php');
|
||||
require_once(__dir__.'/../e_lib/phpmailer5/class.smtp.php');
|
||||
|
||||
/**
|
||||
* DB 객체 생성
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
<?php
|
||||
include(__DIR__.'/plates.php');
|
||||
include(__DIR__.'/meekrodb.2.3.class.php');
|
||||
?>
|
||||
@@ -1,956 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (C) 2008-2012 Sergey Tsalkov (stsalkov@gmail.com)
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
class DB {
|
||||
// initial connection
|
||||
public static $dbName = '';
|
||||
public static $user = '';
|
||||
public static $password = '';
|
||||
public static $host = 'localhost';
|
||||
public static $port = null;
|
||||
public static $encoding = 'latin1';
|
||||
|
||||
// configure workings
|
||||
public static $param_char = '%';
|
||||
public static $named_param_seperator = '_';
|
||||
public static $success_handler = false;
|
||||
public static $error_handler = true;
|
||||
public static $throw_exception_on_error = false;
|
||||
public static $nonsql_error_handler = null;
|
||||
public static $throw_exception_on_nonsql_error = false;
|
||||
public static $nested_transactions = false;
|
||||
public static $usenull = true;
|
||||
public static $ssl = array('key' => '', 'cert' => '', 'ca_cert' => '', 'ca_path' => '', 'cipher' => '');
|
||||
public static $connect_options = array(MYSQLI_OPT_CONNECT_TIMEOUT => 30);
|
||||
|
||||
// internal
|
||||
protected static $mdb = null;
|
||||
|
||||
public static function getMDB() {
|
||||
$mdb = DB::$mdb;
|
||||
|
||||
if ($mdb === null) {
|
||||
$mdb = DB::$mdb = new MeekroDB();
|
||||
}
|
||||
|
||||
static $variables_to_sync = array('param_char', 'named_param_seperator', 'success_handler', 'error_handler', 'throw_exception_on_error',
|
||||
'nonsql_error_handler', 'throw_exception_on_nonsql_error', 'nested_transactions', 'usenull', 'ssl', 'connect_options');
|
||||
|
||||
$db_class_vars = get_class_vars('DB'); // the DB::$$var syntax only works in 5.3+
|
||||
|
||||
foreach ($variables_to_sync as $variable) {
|
||||
if ($mdb->$variable !== $db_class_vars[$variable]) {
|
||||
$mdb->$variable = $db_class_vars[$variable];
|
||||
}
|
||||
}
|
||||
|
||||
return $mdb;
|
||||
}
|
||||
|
||||
// yes, this is ugly. __callStatic() only works in 5.3+
|
||||
public static function get() { $args = func_get_args(); return call_user_func_array(array(DB::getMDB(), 'get'), $args); }
|
||||
public static function disconnect() { $args = func_get_args(); return call_user_func_array(array(DB::getMDB(), 'disconnect'), $args); }
|
||||
public static function query() { $args = func_get_args(); return call_user_func_array(array(DB::getMDB(), 'query'), $args); }
|
||||
public static function queryFirstRow() { $args = func_get_args(); return call_user_func_array(array(DB::getMDB(), 'queryFirstRow'), $args); }
|
||||
public static function queryOneRow() { $args = func_get_args(); return call_user_func_array(array(DB::getMDB(), 'queryOneRow'), $args); }
|
||||
public static function queryAllLists() { $args = func_get_args(); return call_user_func_array(array(DB::getMDB(), 'queryAllLists'), $args); }
|
||||
public static function queryFullColumns() { $args = func_get_args(); return call_user_func_array(array(DB::getMDB(), 'queryFullColumns'), $args); }
|
||||
public static function queryFirstList() { $args = func_get_args(); return call_user_func_array(array(DB::getMDB(), 'queryFirstList'), $args); }
|
||||
public static function queryOneList() { $args = func_get_args(); return call_user_func_array(array(DB::getMDB(), 'queryOneList'), $args); }
|
||||
public static function queryFirstColumn() { $args = func_get_args(); return call_user_func_array(array(DB::getMDB(), 'queryFirstColumn'), $args); }
|
||||
public static function queryOneColumn() { $args = func_get_args(); return call_user_func_array(array(DB::getMDB(), 'queryOneColumn'), $args); }
|
||||
public static function queryFirstField() { $args = func_get_args(); return call_user_func_array(array(DB::getMDB(), 'queryFirstField'), $args); }
|
||||
public static function queryOneField() { $args = func_get_args(); return call_user_func_array(array(DB::getMDB(), 'queryOneField'), $args); }
|
||||
public static function queryRaw() { $args = func_get_args(); return call_user_func_array(array(DB::getMDB(), 'queryRaw'), $args); }
|
||||
public static function queryRawUnbuf() { $args = func_get_args(); return call_user_func_array(array(DB::getMDB(), 'queryRawUnbuf'), $args); }
|
||||
|
||||
public static function insert() { $args = func_get_args(); return call_user_func_array(array(DB::getMDB(), 'insert'), $args); }
|
||||
public static function insertIgnore() { $args = func_get_args(); return call_user_func_array(array(DB::getMDB(), 'insertIgnore'), $args); }
|
||||
public static function insertUpdate() { $args = func_get_args(); return call_user_func_array(array(DB::getMDB(), 'insertUpdate'), $args); }
|
||||
public static function replace() { $args = func_get_args(); return call_user_func_array(array(DB::getMDB(), 'replace'), $args); }
|
||||
public static function update() { $args = func_get_args(); return call_user_func_array(array(DB::getMDB(), 'update'), $args); }
|
||||
public static function delete() { $args = func_get_args(); return call_user_func_array(array(DB::getMDB(), 'delete'), $args); }
|
||||
|
||||
public static function insertId() { $args = func_get_args(); return call_user_func_array(array(DB::getMDB(), 'insertId'), $args); }
|
||||
public static function count() { $args = func_get_args(); return call_user_func_array(array(DB::getMDB(), 'count'), $args); }
|
||||
public static function affectedRows() { $args = func_get_args(); return call_user_func_array(array(DB::getMDB(), 'affectedRows'), $args); }
|
||||
|
||||
public static function useDB() { $args = func_get_args(); return call_user_func_array(array(DB::getMDB(), 'useDB'), $args); }
|
||||
public static function startTransaction() { $args = func_get_args(); return call_user_func_array(array(DB::getMDB(), 'startTransaction'), $args); }
|
||||
public static function commit() { $args = func_get_args(); return call_user_func_array(array(DB::getMDB(), 'commit'), $args); }
|
||||
public static function rollback() { $args = func_get_args(); return call_user_func_array(array(DB::getMDB(), 'rollback'), $args); }
|
||||
public static function tableList() { $args = func_get_args(); return call_user_func_array(array(DB::getMDB(), 'tableList'), $args); }
|
||||
public static function columnList() { $args = func_get_args(); return call_user_func_array(array(DB::getMDB(), 'columnList'), $args); }
|
||||
|
||||
public static function sqlEval() { $args = func_get_args(); return call_user_func_array(array(DB::getMDB(), 'sqlEval'), $args); }
|
||||
public static function nonSQLError() { $args = func_get_args(); return call_user_func_array(array(DB::getMDB(), 'nonSQLError'), $args); }
|
||||
|
||||
public static function serverVersion() { $args = func_get_args(); return call_user_func_array(array(DB::getMDB(), 'serverVersion'), $args); }
|
||||
public static function transactionDepth() { $args = func_get_args(); return call_user_func_array(array(DB::getMDB(), 'transactionDepth'), $args); }
|
||||
|
||||
|
||||
public static function debugMode($handler = true) {
|
||||
DB::$success_handler = $handler;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
class MeekroDB {
|
||||
// initial connection
|
||||
public $dbName = '';
|
||||
public $user = '';
|
||||
public $password = '';
|
||||
public $host = 'localhost';
|
||||
public $port = null;
|
||||
public $encoding = 'latin1';
|
||||
|
||||
// configure workings
|
||||
public $param_char = '%';
|
||||
public $named_param_seperator = '_';
|
||||
public $success_handler = false;
|
||||
public $error_handler = true;
|
||||
public $throw_exception_on_error = false;
|
||||
public $nonsql_error_handler = null;
|
||||
public $throw_exception_on_nonsql_error = false;
|
||||
public $nested_transactions = false;
|
||||
public $usenull = true;
|
||||
public $ssl = array('key' => '', 'cert' => '', 'ca_cert' => '', 'ca_path' => '', 'cipher' => '');
|
||||
public $connect_options = array(MYSQLI_OPT_CONNECT_TIMEOUT => 30);
|
||||
|
||||
// internal
|
||||
public $internal_mysql = null;
|
||||
public $server_info = null;
|
||||
public $insert_id = 0;
|
||||
public $num_rows = 0;
|
||||
public $affected_rows = 0;
|
||||
public $current_db = null;
|
||||
public $nested_transactions_count = 0;
|
||||
|
||||
|
||||
public function __construct($host=null, $user=null, $password=null, $dbName=null, $port=null, $encoding=null) {
|
||||
if ($host === null) $host = DB::$host;
|
||||
if ($user === null) $user = DB::$user;
|
||||
if ($password === null) $password = DB::$password;
|
||||
if ($dbName === null) $dbName = DB::$dbName;
|
||||
if ($port === null) $port = DB::$port;
|
||||
if ($encoding === null) $encoding = DB::$encoding;
|
||||
|
||||
$this->host = $host;
|
||||
$this->user = $user;
|
||||
$this->password = $password;
|
||||
$this->dbName = $dbName;
|
||||
$this->port = $port;
|
||||
$this->encoding = $encoding;
|
||||
}
|
||||
|
||||
public function get() {
|
||||
$mysql = $this->internal_mysql;
|
||||
|
||||
if (!($mysql instanceof MySQLi)) {
|
||||
if (! $this->port) $this->port = ini_get('mysqli.default_port');
|
||||
$this->current_db = $this->dbName;
|
||||
$mysql = new mysqli();
|
||||
|
||||
$connect_flags = 0;
|
||||
if ($this->ssl['key']) {
|
||||
$mysql->ssl_set($this->ssl['key'], $this->ssl['cert'], $this->ssl['ca_cert'], $this->ssl['ca_path'], $this->ssl['cipher']);
|
||||
$connect_flags |= MYSQLI_CLIENT_SSL;
|
||||
}
|
||||
foreach ($this->connect_options as $key => $value) {
|
||||
$mysql->options($key, $value);
|
||||
}
|
||||
|
||||
// suppress warnings, since we will check connect_error anyway
|
||||
@$mysql->real_connect($this->host, $this->user, $this->password, $this->dbName, $this->port, null, $connect_flags);
|
||||
|
||||
if ($mysql->connect_error) {
|
||||
$this->nonSQLError('Unable to connect to MySQL server! Error: ' . $mysql->connect_error);
|
||||
}
|
||||
|
||||
$mysql->set_charset($this->encoding);
|
||||
$this->internal_mysql = $mysql;
|
||||
$this->server_info = $mysql->server_info;
|
||||
}
|
||||
|
||||
return $mysql;
|
||||
}
|
||||
|
||||
public function disconnect() {
|
||||
$mysqli = $this->internal_mysql;
|
||||
if ($mysqli instanceof MySQLi) {
|
||||
if ($thread_id = $mysqli->thread_id) $mysqli->kill($thread_id);
|
||||
$mysqli->close();
|
||||
}
|
||||
$this->internal_mysql = null;
|
||||
}
|
||||
|
||||
public function nonSQLError($message) {
|
||||
if ($this->throw_exception_on_nonsql_error) {
|
||||
$e = new MeekroDBException($message);
|
||||
throw $e;
|
||||
}
|
||||
|
||||
$error_handler = is_callable($this->nonsql_error_handler) ? $this->nonsql_error_handler : 'meekrodb_error_handler';
|
||||
|
||||
call_user_func($error_handler, array(
|
||||
'type' => 'nonsql',
|
||||
'error' => $message
|
||||
));
|
||||
}
|
||||
|
||||
public function debugMode($handler = true) {
|
||||
$this->success_handler = $handler;
|
||||
}
|
||||
|
||||
public function serverVersion() { $this->get(); return $this->server_info; }
|
||||
public function transactionDepth() { return $this->nested_transactions_count; }
|
||||
public function insertId() { return $this->insert_id; }
|
||||
public function affectedRows() { return $this->affected_rows; }
|
||||
public function count() { $args = func_get_args(); return call_user_func_array(array($this, 'numRows'), $args); }
|
||||
public function numRows() { return $this->num_rows; }
|
||||
|
||||
public function useDB() { $args = func_get_args(); return call_user_func_array(array($this, 'setDB'), $args); }
|
||||
public function setDB($dbName) {
|
||||
$db = $this->get();
|
||||
if (! $db->select_db($dbName)) $this->nonSQLError("Unable to set database to $dbName");
|
||||
$this->current_db = $dbName;
|
||||
}
|
||||
|
||||
|
||||
public function startTransaction() {
|
||||
if ($this->nested_transactions && $this->serverVersion() < '5.5') {
|
||||
return $this->nonSQLError("Nested transactions are only available on MySQL 5.5 and greater. You are using MySQL " . $this->serverVersion());
|
||||
}
|
||||
|
||||
if (!$this->nested_transactions || $this->nested_transactions_count == 0) {
|
||||
$this->query('START TRANSACTION');
|
||||
$this->nested_transactions_count = 1;
|
||||
} else {
|
||||
$this->query("SAVEPOINT LEVEL{$this->nested_transactions_count}");
|
||||
$this->nested_transactions_count++;
|
||||
}
|
||||
|
||||
return $this->nested_transactions_count;
|
||||
}
|
||||
|
||||
public function commit($all=false) {
|
||||
if ($this->nested_transactions && $this->serverVersion() < '5.5') {
|
||||
return $this->nonSQLError("Nested transactions are only available on MySQL 5.5 and greater. You are using MySQL " . $this->serverVersion());
|
||||
}
|
||||
|
||||
if ($this->nested_transactions && $this->nested_transactions_count > 0)
|
||||
$this->nested_transactions_count--;
|
||||
|
||||
if (!$this->nested_transactions || $all || $this->nested_transactions_count == 0) {
|
||||
$this->nested_transactions_count = 0;
|
||||
$this->query('COMMIT');
|
||||
} else {
|
||||
$this->query("RELEASE SAVEPOINT LEVEL{$this->nested_transactions_count}");
|
||||
}
|
||||
|
||||
return $this->nested_transactions_count;
|
||||
}
|
||||
|
||||
public function rollback($all=false) {
|
||||
if ($this->nested_transactions && $this->serverVersion() < '5.5') {
|
||||
return $this->nonSQLError("Nested transactions are only available on MySQL 5.5 and greater. You are using MySQL " . $this->serverVersion());
|
||||
}
|
||||
|
||||
if ($this->nested_transactions && $this->nested_transactions_count > 0)
|
||||
$this->nested_transactions_count--;
|
||||
|
||||
if (!$this->nested_transactions || $all || $this->nested_transactions_count == 0) {
|
||||
$this->nested_transactions_count = 0;
|
||||
$this->query('ROLLBACK');
|
||||
} else {
|
||||
$this->query("ROLLBACK TO SAVEPOINT LEVEL{$this->nested_transactions_count}");
|
||||
}
|
||||
|
||||
return $this->nested_transactions_count;
|
||||
}
|
||||
|
||||
protected function formatTableName($table) {
|
||||
$table = trim($table, '`');
|
||||
|
||||
if (strpos($table, '.')) return implode('.', array_map(array($this, 'formatTableName'), explode('.', $table)));
|
||||
else return '`' . str_replace('`', '``', $table) . '`';
|
||||
}
|
||||
|
||||
public function update() {
|
||||
$args = func_get_args();
|
||||
$table = array_shift($args);
|
||||
$params = array_shift($args);
|
||||
$where = array_shift($args);
|
||||
|
||||
$query = str_replace('%', $this->param_char, "UPDATE %b SET %? WHERE ") . $where;
|
||||
|
||||
array_unshift($args, $params);
|
||||
array_unshift($args, $table);
|
||||
array_unshift($args, $query);
|
||||
return call_user_func_array(array($this, 'query'), $args);
|
||||
}
|
||||
|
||||
public function insertOrReplace($which, $table, $datas, $options=array()) {
|
||||
$datas = unserialize(serialize($datas)); // break references within array
|
||||
$keys = $values = array();
|
||||
|
||||
if (isset($datas[0]) && is_array($datas[0])) {
|
||||
foreach ($datas as $datum) {
|
||||
ksort($datum);
|
||||
if (! $keys) $keys = array_keys($datum);
|
||||
$values[] = array_values($datum);
|
||||
}
|
||||
|
||||
} else {
|
||||
$keys = array_keys($datas);
|
||||
$values = array_values($datas);
|
||||
}
|
||||
|
||||
if (isset($options['ignore']) && $options['ignore']) $which = 'INSERT IGNORE';
|
||||
|
||||
if (isset($options['update']) && is_array($options['update']) && $options['update'] && strtolower($which) == 'insert') {
|
||||
if (array_values($options['update']) !== $options['update']) {
|
||||
return $this->query(
|
||||
str_replace('%', $this->param_char, "INSERT INTO %b %lb VALUES %? ON DUPLICATE KEY UPDATE %?"),
|
||||
$table, $keys, $values, $options['update']);
|
||||
} else {
|
||||
$update_str = array_shift($options['update']);
|
||||
$query_param = array(
|
||||
str_replace('%', $this->param_char, "INSERT INTO %b %lb VALUES %? ON DUPLICATE KEY UPDATE ") . $update_str,
|
||||
$table, $keys, $values);
|
||||
$query_param = array_merge($query_param, $options['update']);
|
||||
return call_user_func_array(array($this, 'query'), $query_param);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $this->query(
|
||||
str_replace('%', $this->param_char, "%l INTO %b %lb VALUES %?"),
|
||||
$which, $table, $keys, $values);
|
||||
}
|
||||
|
||||
public function insert($table, $data) { return $this->insertOrReplace('INSERT', $table, $data); }
|
||||
public function insertIgnore($table, $data) { return $this->insertOrReplace('INSERT', $table, $data, array('ignore' => true)); }
|
||||
public function replace($table, $data) { return $this->insertOrReplace('REPLACE', $table, $data); }
|
||||
|
||||
public function insertUpdate() {
|
||||
$args = func_get_args();
|
||||
$table = array_shift($args);
|
||||
$data = array_shift($args);
|
||||
|
||||
if (! isset($args[0])) { // update will have all the data of the insert
|
||||
if (isset($data[0]) && is_array($data[0])) { //multiple insert rows specified -- failing!
|
||||
$this->nonSQLError("Badly formatted insertUpdate() query -- you didn't specify the update component!");
|
||||
}
|
||||
|
||||
$args[0] = $data;
|
||||
}
|
||||
|
||||
if (is_array($args[0])) $update = $args[0];
|
||||
else $update = $args;
|
||||
|
||||
return $this->insertOrReplace('INSERT', $table, $data, array('update' => $update));
|
||||
}
|
||||
|
||||
public function delete() {
|
||||
$args = func_get_args();
|
||||
$table = $this->formatTableName(array_shift($args));
|
||||
$where = array_shift($args);
|
||||
$buildquery = "DELETE FROM $table WHERE $where";
|
||||
array_unshift($args, $buildquery);
|
||||
return call_user_func_array(array($this, 'query'), $args);
|
||||
}
|
||||
|
||||
public function sqleval() {
|
||||
$args = func_get_args();
|
||||
$text = call_user_func_array(array($this, 'parseQueryParams'), $args);
|
||||
return new MeekroDBEval($text);
|
||||
}
|
||||
|
||||
public function columnList($table) {
|
||||
return $this->queryOneColumn('Field', "SHOW COLUMNS FROM %b", $table);
|
||||
}
|
||||
|
||||
public function tableList($db = null) {
|
||||
if ($db) {
|
||||
$olddb = $this->current_db;
|
||||
$this->useDB($db);
|
||||
}
|
||||
|
||||
$result = $this->queryFirstColumn('SHOW TABLES');
|
||||
if (isset($olddb)) $this->useDB($olddb);
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected function preparseQueryParams() {
|
||||
$args = func_get_args();
|
||||
$sql = trim(strval(array_shift($args)));
|
||||
$args_all = $args;
|
||||
|
||||
if (count($args_all) == 0) return array($sql);
|
||||
|
||||
$param_char_length = strlen($this->param_char);
|
||||
$named_seperator_length = strlen($this->named_param_seperator);
|
||||
|
||||
$types = array(
|
||||
$this->param_char . 'll', // list of literals
|
||||
$this->param_char . 'ls', // list of strings
|
||||
$this->param_char . 'l', // literal
|
||||
$this->param_char . 'li', // list of integers
|
||||
$this->param_char . 'ld', // list of decimals
|
||||
$this->param_char . 'lb', // list of backticks
|
||||
$this->param_char . 'lt', // list of timestamps
|
||||
$this->param_char . 's', // string
|
||||
$this->param_char . 'i', // integer
|
||||
$this->param_char . 'd', // double / decimal
|
||||
$this->param_char . 'b', // backtick
|
||||
$this->param_char . 't', // timestamp
|
||||
$this->param_char . '?', // infer type
|
||||
$this->param_char . 'ss' // search string (like string, surrounded with %'s)
|
||||
);
|
||||
|
||||
// generate list of all MeekroDB variables in our query, and their position
|
||||
// in the form "offset => variable", sorted by offsets
|
||||
$posList = array();
|
||||
foreach ($types as $type) {
|
||||
$lastPos = 0;
|
||||
while (($pos = strpos($sql, $type, $lastPos)) !== false) {
|
||||
$lastPos = $pos + 1;
|
||||
if (isset($posList[$pos]) && strlen($posList[$pos]) > strlen($type)) continue;
|
||||
$posList[$pos] = $type;
|
||||
}
|
||||
}
|
||||
|
||||
ksort($posList);
|
||||
|
||||
// for each MeekroDB variable, substitute it with array(type: i, value: 53) or whatever
|
||||
$chunkyQuery = array(); // preparsed query
|
||||
$pos_adj = 0; // how much we've added or removed from the original sql string
|
||||
foreach ($posList as $pos => $type) {
|
||||
$type = substr($type, $param_char_length); // variable, without % in front of it
|
||||
$length_type = strlen($type) + $param_char_length; // length of variable w/o %
|
||||
|
||||
$new_pos = $pos + $pos_adj; // position of start of variable
|
||||
$new_pos_back = $new_pos + $length_type; // position of end of variable
|
||||
$arg_number_length = 0; // length of any named or numbered parameter addition
|
||||
|
||||
// handle numbered parameters
|
||||
if ($arg_number_length = strspn($sql, '0123456789', $new_pos_back)) {
|
||||
$arg_number = substr($sql, $new_pos_back, $arg_number_length);
|
||||
if (! array_key_exists($arg_number, $args_all)) $this->nonSQLError("Non existent argument reference (arg $arg_number): $sql");
|
||||
|
||||
$arg = $args_all[$arg_number];
|
||||
|
||||
// handle named parameters
|
||||
} else if (substr($sql, $new_pos_back, $named_seperator_length) == $this->named_param_seperator) {
|
||||
$arg_number_length = strspn($sql, 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_',
|
||||
$new_pos_back + $named_seperator_length) + $named_seperator_length;
|
||||
|
||||
$arg_number = substr($sql, $new_pos_back + $named_seperator_length, $arg_number_length - $named_seperator_length);
|
||||
if (count($args_all) != 1 || !is_array($args_all[0])) $this->nonSQLError("If you use named parameters, the second argument must be an array of parameters");
|
||||
if (! array_key_exists($arg_number, $args_all[0])) $this->nonSQLError("Non existent argument reference (arg $arg_number): $sql");
|
||||
|
||||
$arg = $args_all[0][$arg_number];
|
||||
|
||||
} else {
|
||||
$arg_number = 0;
|
||||
$arg = array_shift($args);
|
||||
}
|
||||
|
||||
if ($new_pos > 0) $chunkyQuery[] = substr($sql, 0, $new_pos);
|
||||
|
||||
if (is_object($arg) && ($arg instanceof WhereClause)) {
|
||||
list($clause_sql, $clause_args) = $arg->textAndArgs();
|
||||
array_unshift($clause_args, $clause_sql);
|
||||
$preparsed_sql = call_user_func_array(array($this, 'preparseQueryParams'), $clause_args);
|
||||
$chunkyQuery = array_merge($chunkyQuery, $preparsed_sql);
|
||||
} else {
|
||||
$chunkyQuery[] = array('type' => $type, 'value' => $arg);
|
||||
}
|
||||
|
||||
$sql = substr($sql, $new_pos_back + $arg_number_length);
|
||||
$pos_adj -= $new_pos_back + $arg_number_length;
|
||||
}
|
||||
|
||||
if (strlen($sql) > 0) $chunkyQuery[] = $sql;
|
||||
|
||||
return $chunkyQuery;
|
||||
}
|
||||
|
||||
protected function escape($str) { return "'" . $this->get()->real_escape_string(strval($str)) . "'"; }
|
||||
|
||||
protected function sanitize($value) {
|
||||
if (is_object($value)) {
|
||||
if ($value instanceof MeekroDBEval) return $value->text;
|
||||
else if ($value instanceof DateTime) return $this->escape($value->format('Y-m-d H:i:s'));
|
||||
else return '';
|
||||
}
|
||||
|
||||
if (is_null($value)) return $this->usenull ? 'NULL' : "''";
|
||||
else if (is_bool($value)) return ($value ? 1 : 0);
|
||||
else if (is_int($value)) return $value;
|
||||
else if (is_float($value)) return $value;
|
||||
|
||||
else if (is_array($value)) {
|
||||
// non-assoc array?
|
||||
if (array_values($value) === $value) {
|
||||
if (is_array($value[0])) return implode(', ', array_map(array($this, 'sanitize'), $value));
|
||||
else return '(' . implode(', ', array_map(array($this, 'sanitize'), $value)) . ')';
|
||||
}
|
||||
|
||||
$pairs = array();
|
||||
foreach ($value as $k => $v) {
|
||||
$pairs[] = $this->formatTableName($k) . '=' . $this->sanitize($v);
|
||||
}
|
||||
|
||||
return implode(', ', $pairs);
|
||||
}
|
||||
else return $this->escape($value);
|
||||
}
|
||||
|
||||
protected function parseTS($ts) {
|
||||
if (is_string($ts)) return date('Y-m-d H:i:s', strtotime($ts));
|
||||
else if (is_object($ts) && ($ts instanceof DateTime)) return $ts->format('Y-m-d H:i:s');
|
||||
}
|
||||
|
||||
protected function intval($var) {
|
||||
if (PHP_INT_SIZE == 8) return intval($var);
|
||||
return floor(doubleval($var));
|
||||
}
|
||||
|
||||
protected function parseQueryParams() {
|
||||
$args = func_get_args();
|
||||
$chunkyQuery = call_user_func_array(array($this, 'preparseQueryParams'), $args);
|
||||
|
||||
$query = '';
|
||||
$array_types = array('ls', 'li', 'ld', 'lb', 'll', 'lt');
|
||||
|
||||
foreach ($chunkyQuery as $chunk) {
|
||||
if (is_string($chunk)) {
|
||||
$query .= $chunk;
|
||||
continue;
|
||||
}
|
||||
|
||||
$type = $chunk['type'];
|
||||
$arg = $chunk['value'];
|
||||
$result = '';
|
||||
|
||||
if ($type != '?') {
|
||||
$is_array_type = in_array($type, $array_types, true);
|
||||
if ($is_array_type && !is_array($arg)) $this->nonSQLError("Badly formatted SQL query: Expected array, got scalar instead!");
|
||||
else if (!$is_array_type && is_array($arg)) $this->nonSQLError("Badly formatted SQL query: Expected scalar, got array instead!");
|
||||
}
|
||||
|
||||
if ($type == 's') $result = $this->escape($arg);
|
||||
else if ($type == 'i') $result = $this->intval($arg);
|
||||
else if ($type == 'd') $result = doubleval($arg);
|
||||
else if ($type == 'b') $result = $this->formatTableName($arg);
|
||||
else if ($type == 'l') $result = $arg;
|
||||
else if ($type == 'ss') $result = $this->escape("%" . str_replace(array('%', '_'), array('\%', '\_'), $arg) . "%");
|
||||
else if ($type == 't') $result = $this->escape($this->parseTS($arg));
|
||||
|
||||
else if ($type == 'ls') $result = array_map(array($this, 'escape'), $arg);
|
||||
else if ($type == 'li') $result = array_map(array($this, 'intval'), $arg);
|
||||
else if ($type == 'ld') $result = array_map('doubleval', $arg);
|
||||
else if ($type == 'lb') $result = array_map(array($this, 'formatTableName'), $arg);
|
||||
else if ($type == 'll') $result = $arg;
|
||||
else if ($type == 'lt') $result = array_map(array($this, 'escape'), array_map(array($this, 'parseTS'), $arg));
|
||||
|
||||
else if ($type == '?') $result = $this->sanitize($arg);
|
||||
|
||||
else $this->nonSQLError("Badly formatted SQL query: Invalid MeekroDB param $type");
|
||||
|
||||
if (is_array($result)) $result = '(' . implode(',', $result) . ')';
|
||||
|
||||
$query .= $result;
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
protected function prependCall($function, $args, $prepend) { array_unshift($args, $prepend); return call_user_func_array($function, $args); }
|
||||
public function query() { $args = func_get_args(); return $this->prependCall(array($this, 'queryHelper'), $args, 'assoc'); }
|
||||
public function queryAllLists() { $args = func_get_args(); return $this->prependCall(array($this, 'queryHelper'), $args, 'list'); }
|
||||
public function queryFullColumns() { $args = func_get_args(); return $this->prependCall(array($this, 'queryHelper'), $args, 'full'); }
|
||||
|
||||
public function queryRaw() { $args = func_get_args(); return $this->prependCall(array($this, 'queryHelper'), $args, 'raw_buf'); }
|
||||
public function queryRawUnbuf() { $args = func_get_args(); return $this->prependCall(array($this, 'queryHelper'), $args, 'raw_unbuf'); }
|
||||
|
||||
protected function queryHelper() {
|
||||
$args = func_get_args();
|
||||
$type = array_shift($args);
|
||||
$db = $this->get();
|
||||
|
||||
$is_buffered = true;
|
||||
$row_type = 'assoc'; // assoc, list, raw
|
||||
$full_names = false;
|
||||
|
||||
switch ($type) {
|
||||
case 'assoc':
|
||||
break;
|
||||
case 'list':
|
||||
$row_type = 'list';
|
||||
break;
|
||||
case 'full':
|
||||
$row_type = 'list';
|
||||
$full_names = true;
|
||||
break;
|
||||
case 'raw_buf':
|
||||
$row_type = 'raw';
|
||||
break;
|
||||
case 'raw_unbuf':
|
||||
$is_buffered = false;
|
||||
$row_type = 'raw';
|
||||
break;
|
||||
default:
|
||||
$this->nonSQLError('Error -- invalid argument to queryHelper!');
|
||||
}
|
||||
|
||||
$sql = call_user_func_array(array($this, 'parseQueryParams'), $args);
|
||||
|
||||
if ($this->success_handler) $starttime = microtime(true);
|
||||
$result = $db->query($sql, $is_buffered ? MYSQLI_STORE_RESULT : MYSQLI_USE_RESULT);
|
||||
if ($this->success_handler) $runtime = microtime(true) - $starttime;
|
||||
else $runtime = 0;
|
||||
|
||||
// ----- BEGIN ERROR HANDLING
|
||||
if (!$sql || $db->error) {
|
||||
if ($this->error_handler) {
|
||||
$error_handler = is_callable($this->error_handler) ? $this->error_handler : 'meekrodb_error_handler';
|
||||
|
||||
call_user_func($error_handler, array(
|
||||
'type' => 'sql',
|
||||
'query' => $sql,
|
||||
'error' => $db->error,
|
||||
'code' => $db->errno
|
||||
));
|
||||
}
|
||||
|
||||
if ($this->throw_exception_on_error) {
|
||||
$e = new MeekroDBException($db->error, $sql, $db->errno);
|
||||
throw $e;
|
||||
}
|
||||
} else if ($this->success_handler) {
|
||||
$runtime = sprintf('%f', $runtime * 1000);
|
||||
$success_handler = is_callable($this->success_handler) ? $this->success_handler : 'meekrodb_debugmode_handler';
|
||||
|
||||
call_user_func($success_handler, array(
|
||||
'query' => $sql,
|
||||
'runtime' => $runtime,
|
||||
'affected' => $db->affected_rows
|
||||
));
|
||||
}
|
||||
|
||||
// ----- END ERROR HANDLING
|
||||
|
||||
$this->insert_id = $db->insert_id;
|
||||
$this->affected_rows = $db->affected_rows;
|
||||
|
||||
// mysqli_result->num_rows won't initially show correct results for unbuffered data
|
||||
if ($is_buffered && ($result instanceof MySQLi_Result)) $this->num_rows = $result->num_rows;
|
||||
else $this->num_rows = null;
|
||||
|
||||
if ($row_type == 'raw' || !($result instanceof MySQLi_Result)) return $result;
|
||||
|
||||
$return = array();
|
||||
|
||||
if ($full_names) {
|
||||
$infos = array();
|
||||
foreach ($result->fetch_fields() as $info) {
|
||||
if (strlen($info->table)) $infos[] = $info->table . '.' . $info->name;
|
||||
else $infos[] = $info->name;
|
||||
}
|
||||
}
|
||||
|
||||
while ($row = ($row_type == 'assoc' ? $result->fetch_assoc() : $result->fetch_row())) {
|
||||
if ($full_names) $row = array_combine($infos, $row);
|
||||
$return[] = $row;
|
||||
}
|
||||
|
||||
// free results
|
||||
$result->free();
|
||||
while ($db->more_results()) {
|
||||
$db->next_result();
|
||||
if ($result = $db->use_result()) $result->free();
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
public function queryOneRow() { $args = func_get_args(); return call_user_func_array(array($this, 'queryFirstRow'), $args); }
|
||||
public function queryFirstRow() {
|
||||
$args = func_get_args();
|
||||
$result = call_user_func_array(array($this, 'query'), $args);
|
||||
if (!$result || !is_array($result)) return null;
|
||||
return reset($result);
|
||||
}
|
||||
|
||||
public function queryOneList() { $args = func_get_args(); return call_user_func_array(array($this, 'queryFirstList'), $args); }
|
||||
public function queryFirstList() {
|
||||
$args = func_get_args();
|
||||
$result = call_user_func_array(array($this, 'queryAllLists'), $args);
|
||||
if (!$result || !is_array($result)) return null;
|
||||
return reset($result);
|
||||
}
|
||||
|
||||
public function queryFirstColumn() {
|
||||
$args = func_get_args();
|
||||
$results = call_user_func_array(array($this, 'queryAllLists'), $args);
|
||||
$ret = array();
|
||||
|
||||
if (!count($results) || !count($results[0])) return $ret;
|
||||
|
||||
foreach ($results as $row) {
|
||||
$ret[] = $row[0];
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function queryOneColumn() {
|
||||
$args = func_get_args();
|
||||
$column = array_shift($args);
|
||||
$results = call_user_func_array(array($this, 'query'), $args);
|
||||
$ret = array();
|
||||
|
||||
if (!count($results) || !count($results[0])) return $ret;
|
||||
if ($column === null) {
|
||||
$keys = array_keys($results[0]);
|
||||
$column = $keys[0];
|
||||
}
|
||||
|
||||
foreach ($results as $row) {
|
||||
$ret[] = $row[$column];
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function queryFirstField() {
|
||||
$args = func_get_args();
|
||||
$row = call_user_func_array(array($this, 'queryFirstList'), $args);
|
||||
if ($row == null) return null;
|
||||
return $row[0];
|
||||
}
|
||||
|
||||
public function queryOneField() {
|
||||
$args = func_get_args();
|
||||
$column = array_shift($args);
|
||||
|
||||
$row = call_user_func_array(array($this, 'queryOneRow'), $args);
|
||||
if ($row == null) {
|
||||
return null;
|
||||
} else if ($column === null) {
|
||||
$keys = array_keys($row);
|
||||
$column = $keys[0];
|
||||
}
|
||||
|
||||
return $row[$column];
|
||||
}
|
||||
}
|
||||
|
||||
class WhereClause {
|
||||
public $type = 'and'; //AND or OR
|
||||
public $negate = false;
|
||||
public $clauses = array();
|
||||
|
||||
function __construct($type) {
|
||||
$type = strtolower($type);
|
||||
if ($type !== 'or' && $type !== 'and') DB::nonSQLError('you must use either WhereClause(and) or WhereClause(or)');
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
function add() {
|
||||
$args = func_get_args();
|
||||
$sql = array_shift($args);
|
||||
|
||||
if ($sql instanceof WhereClause) {
|
||||
$this->clauses[] = $sql;
|
||||
} else {
|
||||
$this->clauses[] = array('sql' => $sql, 'args' => $args);
|
||||
}
|
||||
}
|
||||
|
||||
function negateLast() {
|
||||
$i = count($this->clauses) - 1;
|
||||
if (!isset($this->clauses[$i])) return;
|
||||
|
||||
if ($this->clauses[$i] instanceof WhereClause) {
|
||||
$this->clauses[$i]->negate();
|
||||
} else {
|
||||
$this->clauses[$i]['sql'] = 'NOT (' . $this->clauses[$i]['sql'] . ')';
|
||||
}
|
||||
}
|
||||
|
||||
function negate() {
|
||||
$this->negate = ! $this->negate;
|
||||
}
|
||||
|
||||
function addClause($type) {
|
||||
$r = new WhereClause($type);
|
||||
$this->add($r);
|
||||
return $r;
|
||||
}
|
||||
|
||||
function count() {
|
||||
return count($this->clauses);
|
||||
}
|
||||
|
||||
function textAndArgs() {
|
||||
$sql = array();
|
||||
$args = array();
|
||||
|
||||
if (count($this->clauses) == 0) return array('(1)', $args);
|
||||
|
||||
foreach ($this->clauses as $clause) {
|
||||
if ($clause instanceof WhereClause) {
|
||||
list($clause_sql, $clause_args) = $clause->textAndArgs();
|
||||
} else {
|
||||
$clause_sql = $clause['sql'];
|
||||
$clause_args = $clause['args'];
|
||||
}
|
||||
|
||||
$sql[] = "($clause_sql)";
|
||||
$args = array_merge($args, $clause_args);
|
||||
}
|
||||
|
||||
if ($this->type == 'and') $sql = implode(' AND ', $sql);
|
||||
else $sql = implode(' OR ', $sql);
|
||||
|
||||
if ($this->negate) $sql = '(NOT ' . $sql . ')';
|
||||
return array($sql, $args);
|
||||
}
|
||||
|
||||
// backwards compatability
|
||||
// we now return full WhereClause object here and evaluate it in preparseQueryParams
|
||||
function text() { return $this; }
|
||||
}
|
||||
|
||||
class DBTransaction {
|
||||
private $committed = false;
|
||||
|
||||
function __construct() {
|
||||
DB::startTransaction();
|
||||
}
|
||||
function __destruct() {
|
||||
if (! $this->committed) DB::rollback();
|
||||
}
|
||||
function commit() {
|
||||
DB::commit();
|
||||
$this->committed = true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
class MeekroDBException extends Exception {
|
||||
protected $query = '';
|
||||
|
||||
function __construct($message='', $query='', $code = 0) {
|
||||
parent::__construct($message);
|
||||
$this->query = $query;
|
||||
$this->code = $code;
|
||||
}
|
||||
|
||||
public function getQuery() { return $this->query; }
|
||||
}
|
||||
|
||||
class DBHelper {
|
||||
/*
|
||||
verticalSlice
|
||||
1. For an array of assoc rays, return an array of values for a particular key
|
||||
2. if $keyfield is given, same as above but use that hash key as the key in new array
|
||||
*/
|
||||
|
||||
public static function verticalSlice($array, $field, $keyfield = null) {
|
||||
$array = (array) $array;
|
||||
|
||||
$R = array();
|
||||
foreach ($array as $obj) {
|
||||
if (! array_key_exists($field, $obj)) die("verticalSlice: array doesn't have requested field\n");
|
||||
|
||||
if ($keyfield) {
|
||||
if (! array_key_exists($keyfield, $obj)) die("verticalSlice: array doesn't have requested field\n");
|
||||
$R[$obj[$keyfield]] = $obj[$field];
|
||||
} else {
|
||||
$R[] = $obj[$field];
|
||||
}
|
||||
}
|
||||
return $R;
|
||||
}
|
||||
|
||||
/*
|
||||
reIndex
|
||||
For an array of assoc rays, return a new array of assoc rays using a certain field for keys
|
||||
*/
|
||||
|
||||
public static function reIndex() {
|
||||
$fields = func_get_args();
|
||||
$array = array_shift($fields);
|
||||
$array = (array) $array;
|
||||
|
||||
$R = array();
|
||||
foreach ($array as $obj) {
|
||||
$target =& $R;
|
||||
|
||||
foreach ($fields as $field) {
|
||||
if (! array_key_exists($field, $obj)) die("reIndex: array doesn't have requested field\n");
|
||||
|
||||
$nextkey = $obj[$field];
|
||||
$target =& $target[$nextkey];
|
||||
}
|
||||
$target = $obj;
|
||||
}
|
||||
return $R;
|
||||
}
|
||||
}
|
||||
|
||||
function meekrodb_error_handler($params) {
|
||||
if (isset($params['query'])) $out[] = "QUERY: " . $params['query'];
|
||||
if (isset($params['error'])) $out[] = "ERROR: " . $params['error'];
|
||||
$out[] = "";
|
||||
|
||||
if (php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) {
|
||||
echo implode("\n", $out);
|
||||
} else {
|
||||
echo implode("<br>\n", $out);
|
||||
}
|
||||
|
||||
die;
|
||||
}
|
||||
|
||||
function meekrodb_debugmode_handler($params) {
|
||||
echo "QUERY: " . $params['query'] . " [" . $params['runtime'] . " ms]";
|
||||
if (php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) {
|
||||
echo "\n";
|
||||
} else {
|
||||
echo "<br>\n";
|
||||
}
|
||||
}
|
||||
|
||||
class MeekroDBEval {
|
||||
public $text = '';
|
||||
|
||||
function __construct($text) {
|
||||
$this->text = $text;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPMailer SPL autoloader.
|
||||
* PHP Version 5
|
||||
* @package PHPMailer
|
||||
* @link https://github.com/PHPMailer/PHPMailer/ The PHPMailer GitHub project
|
||||
* @author Marcus Bointon (Synchro/coolbru) <phpmailer@synchromedia.co.uk>
|
||||
* @author Jim Jagielski (jimjag) <jimjag@gmail.com>
|
||||
* @author Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net>
|
||||
* @author Brent R. Matzelle (original founder)
|
||||
* @copyright 2012 - 2014 Marcus Bointon
|
||||
* @copyright 2010 - 2012 Jim Jagielski
|
||||
* @copyright 2004 - 2009 Andy Prevost
|
||||
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
|
||||
* @note This program is distributed in the hope that it will be useful - WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* PHPMailer SPL autoloader.
|
||||
* @param string $classname The name of the class to load
|
||||
*/
|
||||
function PHPMailerAutoload($classname)
|
||||
{
|
||||
//Can't use __DIR__ as it's only in PHP 5.3+
|
||||
$filename = dirname(__FILE__).DIRECTORY_SEPARATOR.'class.'.strtolower($classname).'.php';
|
||||
if (is_readable($filename)) {
|
||||
require $filename;
|
||||
}
|
||||
}
|
||||
|
||||
if (version_compare(PHP_VERSION, '5.1.2', '>=')) {
|
||||
//SPL autoloading was introduced in PHP 5.1.2
|
||||
if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
|
||||
spl_autoload_register('PHPMailerAutoload', true, true);
|
||||
} else {
|
||||
spl_autoload_register('PHPMailerAutoload');
|
||||
}
|
||||
} else {
|
||||
/**
|
||||
* Fall back to traditional autoload for old PHP versions
|
||||
* @param string $classname The name of the class to load
|
||||
*/
|
||||
function __autoload($classname)
|
||||
{
|
||||
PHPMailerAutoload($classname);
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
5.2.26
|
||||
@@ -1,197 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPMailer - PHP email creation and transport class.
|
||||
* PHP Version 5.4
|
||||
* @package PHPMailer
|
||||
* @link https://github.com/PHPMailer/PHPMailer/ The PHPMailer GitHub project
|
||||
* @author Marcus Bointon (Synchro/coolbru) <phpmailer@synchromedia.co.uk>
|
||||
* @author Jim Jagielski (jimjag) <jimjag@gmail.com>
|
||||
* @author Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net>
|
||||
* @author Brent R. Matzelle (original founder)
|
||||
* @copyright 2012 - 2014 Marcus Bointon
|
||||
* @copyright 2010 - 2012 Jim Jagielski
|
||||
* @copyright 2004 - 2009 Andy Prevost
|
||||
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
|
||||
* @note This program is distributed in the hope that it will be useful - WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* PHPMailerOAuth - PHPMailer subclass adding OAuth support.
|
||||
* @package PHPMailer
|
||||
* @author @sherryl4george
|
||||
* @author Marcus Bointon (@Synchro) <phpmailer@synchromedia.co.uk>
|
||||
*/
|
||||
class PHPMailerOAuth extends PHPMailer
|
||||
{
|
||||
/**
|
||||
* The OAuth user's email address
|
||||
* @var string
|
||||
*/
|
||||
public $oauthUserEmail = '';
|
||||
|
||||
/**
|
||||
* The OAuth refresh token
|
||||
* @var string
|
||||
*/
|
||||
public $oauthRefreshToken = '';
|
||||
|
||||
/**
|
||||
* The OAuth client ID
|
||||
* @var string
|
||||
*/
|
||||
public $oauthClientId = '';
|
||||
|
||||
/**
|
||||
* The OAuth client secret
|
||||
* @var string
|
||||
*/
|
||||
public $oauthClientSecret = '';
|
||||
|
||||
/**
|
||||
* An instance of the PHPMailerOAuthGoogle class.
|
||||
* @var PHPMailerOAuthGoogle
|
||||
* @access protected
|
||||
*/
|
||||
protected $oauth = null;
|
||||
|
||||
/**
|
||||
* Get a PHPMailerOAuthGoogle instance to use.
|
||||
* @return PHPMailerOAuthGoogle
|
||||
*/
|
||||
public function getOAUTHInstance()
|
||||
{
|
||||
if (!is_object($this->oauth)) {
|
||||
$this->oauth = new PHPMailerOAuthGoogle(
|
||||
$this->oauthUserEmail,
|
||||
$this->oauthClientSecret,
|
||||
$this->oauthClientId,
|
||||
$this->oauthRefreshToken
|
||||
);
|
||||
}
|
||||
return $this->oauth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initiate a connection to an SMTP server.
|
||||
* Overrides the original smtpConnect method to add support for OAuth.
|
||||
* @param array $options An array of options compatible with stream_context_create()
|
||||
* @uses SMTP
|
||||
* @access public
|
||||
* @return bool
|
||||
* @throws phpmailerException
|
||||
*/
|
||||
public function smtpConnect($options = array())
|
||||
{
|
||||
if (is_null($this->smtp)) {
|
||||
$this->smtp = $this->getSMTPInstance();
|
||||
}
|
||||
|
||||
if (is_null($this->oauth)) {
|
||||
$this->oauth = $this->getOAUTHInstance();
|
||||
}
|
||||
|
||||
// Already connected?
|
||||
if ($this->smtp->connected()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$this->smtp->setTimeout($this->Timeout);
|
||||
$this->smtp->setDebugLevel($this->SMTPDebug);
|
||||
$this->smtp->setDebugOutput($this->Debugoutput);
|
||||
$this->smtp->setVerp($this->do_verp);
|
||||
$hosts = explode(';', $this->Host);
|
||||
$lastexception = null;
|
||||
|
||||
foreach ($hosts as $hostentry) {
|
||||
$hostinfo = array();
|
||||
if (!preg_match('/^((ssl|tls):\/\/)*([a-zA-Z0-9\.-]*):?([0-9]*)$/', trim($hostentry), $hostinfo)) {
|
||||
// Not a valid host entry
|
||||
continue;
|
||||
}
|
||||
// $hostinfo[2]: optional ssl or tls prefix
|
||||
// $hostinfo[3]: the hostname
|
||||
// $hostinfo[4]: optional port number
|
||||
// The host string prefix can temporarily override the current setting for SMTPSecure
|
||||
// If it's not specified, the default value is used
|
||||
$prefix = '';
|
||||
$secure = $this->SMTPSecure;
|
||||
$tls = ($this->SMTPSecure == 'tls');
|
||||
if ('ssl' == $hostinfo[2] or ('' == $hostinfo[2] and 'ssl' == $this->SMTPSecure)) {
|
||||
$prefix = 'ssl://';
|
||||
$tls = false; // Can't have SSL and TLS at the same time
|
||||
$secure = 'ssl';
|
||||
} elseif ($hostinfo[2] == 'tls') {
|
||||
$tls = true;
|
||||
// tls doesn't use a prefix
|
||||
$secure = 'tls';
|
||||
}
|
||||
//Do we need the OpenSSL extension?
|
||||
$sslext = defined('OPENSSL_ALGO_SHA1');
|
||||
if ('tls' === $secure or 'ssl' === $secure) {
|
||||
//Check for an OpenSSL constant rather than using extension_loaded, which is sometimes disabled
|
||||
if (!$sslext) {
|
||||
throw new phpmailerException($this->lang('extension_missing').'openssl', self::STOP_CRITICAL);
|
||||
}
|
||||
}
|
||||
$host = $hostinfo[3];
|
||||
$port = $this->Port;
|
||||
$tport = (integer)$hostinfo[4];
|
||||
if ($tport > 0 and $tport < 65536) {
|
||||
$port = $tport;
|
||||
}
|
||||
if ($this->smtp->connect($prefix . $host, $port, $this->Timeout, $options)) {
|
||||
try {
|
||||
if ($this->Helo) {
|
||||
$hello = $this->Helo;
|
||||
} else {
|
||||
$hello = $this->serverHostname();
|
||||
}
|
||||
$this->smtp->hello($hello);
|
||||
//Automatically enable TLS encryption if:
|
||||
// * it's not disabled
|
||||
// * we have openssl extension
|
||||
// * we are not already using SSL
|
||||
// * the server offers STARTTLS
|
||||
if ($this->SMTPAutoTLS and $sslext and $secure != 'ssl' and $this->smtp->getServerExt('STARTTLS')) {
|
||||
$tls = true;
|
||||
}
|
||||
if ($tls) {
|
||||
if (!$this->smtp->startTLS()) {
|
||||
throw new phpmailerException($this->lang('connect_host'));
|
||||
}
|
||||
// We must resend HELO after tls negotiation
|
||||
$this->smtp->hello($hello);
|
||||
}
|
||||
if ($this->SMTPAuth) {
|
||||
if (!$this->smtp->authenticate(
|
||||
$this->Username,
|
||||
$this->Password,
|
||||
$this->AuthType,
|
||||
$this->Realm,
|
||||
$this->Workstation,
|
||||
$this->oauth
|
||||
)
|
||||
) {
|
||||
throw new phpmailerException($this->lang('authenticate'));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} catch (phpmailerException $exc) {
|
||||
$lastexception = $exc;
|
||||
$this->edebug($exc->getMessage());
|
||||
// We must have connected, but then failed TLS or Auth, so close connection nicely
|
||||
$this->smtp->quit();
|
||||
}
|
||||
}
|
||||
}
|
||||
// If we get here, all connection attempts have failed, so close connection hard
|
||||
$this->smtp->close();
|
||||
// As we've caught all exceptions, just report whatever the last one was
|
||||
if ($this->exceptions and !is_null($lastexception)) {
|
||||
throw $lastexception;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPMailer - PHP email creation and transport class.
|
||||
* PHP Version 5.4
|
||||
* @package PHPMailer
|
||||
* @link https://github.com/PHPMailer/PHPMailer/ The PHPMailer GitHub project
|
||||
* @author Marcus Bointon (Synchro/coolbru) <phpmailer@synchromedia.co.uk>
|
||||
* @author Jim Jagielski (jimjag) <jimjag@gmail.com>
|
||||
* @author Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net>
|
||||
* @author Brent R. Matzelle (original founder)
|
||||
* @copyright 2012 - 2014 Marcus Bointon
|
||||
* @copyright 2010 - 2012 Jim Jagielski
|
||||
* @copyright 2004 - 2009 Andy Prevost
|
||||
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
|
||||
* @note This program is distributed in the hope that it will be useful - WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* PHPMailerOAuthGoogle - Wrapper for League OAuth2 Google provider.
|
||||
* @package PHPMailer
|
||||
* @author @sherryl4george
|
||||
* @author Marcus Bointon (@Synchro) <phpmailer@synchromedia.co.uk>
|
||||
* @link https://github.com/thephpleague/oauth2-client
|
||||
*/
|
||||
class PHPMailerOAuthGoogle
|
||||
{
|
||||
private $oauthUserEmail = '';
|
||||
private $oauthRefreshToken = '';
|
||||
private $oauthClientId = '';
|
||||
private $oauthClientSecret = '';
|
||||
|
||||
/**
|
||||
* @param string $UserEmail
|
||||
* @param string $ClientSecret
|
||||
* @param string $ClientId
|
||||
* @param string $RefreshToken
|
||||
*/
|
||||
public function __construct(
|
||||
$UserEmail,
|
||||
$ClientSecret,
|
||||
$ClientId,
|
||||
$RefreshToken
|
||||
) {
|
||||
$this->oauthClientId = $ClientId;
|
||||
$this->oauthClientSecret = $ClientSecret;
|
||||
$this->oauthRefreshToken = $RefreshToken;
|
||||
$this->oauthUserEmail = $UserEmail;
|
||||
}
|
||||
|
||||
private function getProvider()
|
||||
{
|
||||
return new League\OAuth2\Client\Provider\Google([
|
||||
'clientId' => $this->oauthClientId,
|
||||
'clientSecret' => $this->oauthClientSecret
|
||||
]);
|
||||
}
|
||||
|
||||
private function getGrant()
|
||||
{
|
||||
return new \League\OAuth2\Client\Grant\RefreshToken();
|
||||
}
|
||||
|
||||
private function getToken()
|
||||
{
|
||||
$provider = $this->getProvider();
|
||||
$grant = $this->getGrant();
|
||||
return $provider->getAccessToken($grant, ['refresh_token' => $this->oauthRefreshToken]);
|
||||
}
|
||||
|
||||
public function getOauth64()
|
||||
{
|
||||
$token = $this->getToken();
|
||||
return base64_encode("user=" . $this->oauthUserEmail . "\001auth=Bearer " . $token . "\001\001");
|
||||
}
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
{
|
||||
"name": "phpmailer/phpmailer",
|
||||
"type": "library",
|
||||
"description": "PHPMailer is a full-featured email creation and transfer class for PHP",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Marcus Bointon",
|
||||
"email": "phpmailer@synchromedia.co.uk"
|
||||
},
|
||||
{
|
||||
"name": "Jim Jagielski",
|
||||
"email": "jimjag@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Andy Prevost",
|
||||
"email": "codeworxtech@users.sourceforge.net"
|
||||
},
|
||||
{
|
||||
"name": "Brent R. Matzelle"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"ext-ctype": "*",
|
||||
"php": ">=5.0.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"doctrine/annotations": "1.2.*",
|
||||
"jms/serializer": "0.16.*",
|
||||
"phpdocumentor/phpdocumentor": "2.*",
|
||||
"phpunit/phpunit": "4.8.*",
|
||||
"symfony/debug": "2.8.*",
|
||||
"symfony/filesystem": "2.8.*",
|
||||
"symfony/translation": "2.8.*",
|
||||
"symfony/yaml": "2.8.*",
|
||||
"zendframework/zend-cache": "2.5.1",
|
||||
"zendframework/zend-config": "2.5.1",
|
||||
"zendframework/zend-eventmanager": "2.5.1",
|
||||
"zendframework/zend-filter": "2.5.1",
|
||||
"zendframework/zend-i18n": "2.5.1",
|
||||
"zendframework/zend-json": "2.5.1",
|
||||
"zendframework/zend-math": "2.5.1",
|
||||
"zendframework/zend-serializer": "2.5.*",
|
||||
"zendframework/zend-servicemanager": "2.5.*",
|
||||
"zendframework/zend-stdlib": "2.5.1"
|
||||
},
|
||||
"suggest": {
|
||||
"league/oauth2-google": "Needed for Google XOAUTH2 authentication"
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"class.phpmailer.php",
|
||||
"class.phpmaileroauth.php",
|
||||
"class.phpmaileroauthgoogle.php",
|
||||
"class.smtp.php",
|
||||
"class.pop3.php",
|
||||
"extras/EasyPeasyICS.php",
|
||||
"extras/ntlm_sasl_client.php"
|
||||
]
|
||||
},
|
||||
"license": "LGPL-2.1"
|
||||
}
|
||||
Generated
-3593
File diff suppressed because it is too large
Load Diff
@@ -1,162 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Get an OAuth2 token from Google.
|
||||
* * Install this script on your server so that it's accessible
|
||||
* as [https/http]://<yourdomain>/<folder>/get_oauth_token.php
|
||||
* e.g.: http://localhost/phpmail/get_oauth_token.php
|
||||
* * Ensure dependencies are installed with 'composer install'
|
||||
* * Set up an app in your Google developer console
|
||||
* * Set the script address as the app's redirect URL
|
||||
* If no refresh token is obtained when running this file, revoke access to your app
|
||||
* using link: https://accounts.google.com/b/0/IssuedAuthSubTokens and run the script again.
|
||||
* This script requires PHP 5.4 or later
|
||||
* PHP Version 5.4
|
||||
*/
|
||||
|
||||
namespace League\OAuth2\Client\Provider;
|
||||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use League\OAuth2\Client\Provider\Exception\IdentityProviderException;
|
||||
use League\OAuth2\Client\Token\AccessToken;
|
||||
use League\OAuth2\Client\Tool\BearerAuthorizationTrait;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
session_start();
|
||||
|
||||
//If this automatic URL doesn't work, set it yourself manually
|
||||
$redirectUri = isset($_SERVER['HTTPS']) ? 'https://' : 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
|
||||
//$redirectUri = 'http://localhost/phpmailer/get_oauth_token.php';
|
||||
|
||||
//These details obtained are by setting up app in Google developer console.
|
||||
$clientId = 'RANDOMCHARS-----duv1n2.apps.googleusercontent.com';
|
||||
$clientSecret = 'RANDOMCHARS-----lGyjPcRtvP';
|
||||
|
||||
class Google extends AbstractProvider
|
||||
{
|
||||
use BearerAuthorizationTrait;
|
||||
|
||||
const ACCESS_TOKEN_RESOURCE_OWNER_ID = 'id';
|
||||
|
||||
/**
|
||||
* @var string If set, this will be sent to google as the "access_type" parameter.
|
||||
* @link https://developers.google.com/accounts/docs/OAuth2WebServer#offline
|
||||
*/
|
||||
protected $accessType;
|
||||
|
||||
/**
|
||||
* @var string If set, this will be sent to google as the "hd" parameter.
|
||||
* @link https://developers.google.com/accounts/docs/OAuth2Login#hd-param
|
||||
*/
|
||||
protected $hostedDomain;
|
||||
|
||||
/**
|
||||
* @var string If set, this will be sent to google as the "scope" parameter.
|
||||
* @link https://developers.google.com/gmail/api/auth/scopes
|
||||
*/
|
||||
protected $scope;
|
||||
|
||||
public function getBaseAuthorizationUrl()
|
||||
{
|
||||
return 'https://accounts.google.com/o/oauth2/auth';
|
||||
}
|
||||
|
||||
public function getBaseAccessTokenUrl(array $params)
|
||||
{
|
||||
return 'https://accounts.google.com/o/oauth2/token';
|
||||
}
|
||||
|
||||
public function getResourceOwnerDetailsUrl(AccessToken $token)
|
||||
{
|
||||
return ' ';
|
||||
}
|
||||
|
||||
protected function getAuthorizationParameters(array $options)
|
||||
{
|
||||
if (is_array($this->scope)) {
|
||||
$separator = $this->getScopeSeparator();
|
||||
$this->scope = implode($separator, $this->scope);
|
||||
}
|
||||
|
||||
$params = array_merge(
|
||||
parent::getAuthorizationParameters($options),
|
||||
array_filter([
|
||||
'hd' => $this->hostedDomain,
|
||||
'access_type' => $this->accessType,
|
||||
'scope' => $this->scope,
|
||||
// if the user is logged in with more than one account ask which one to use for the login!
|
||||
'authuser' => '-1'
|
||||
])
|
||||
);
|
||||
return $params;
|
||||
}
|
||||
|
||||
protected function getDefaultScopes()
|
||||
{
|
||||
return [
|
||||
'email',
|
||||
'openid',
|
||||
'profile',
|
||||
];
|
||||
}
|
||||
|
||||
protected function getScopeSeparator()
|
||||
{
|
||||
return ' ';
|
||||
}
|
||||
|
||||
protected function checkResponse(ResponseInterface $response, $data)
|
||||
{
|
||||
if (!empty($data['error'])) {
|
||||
$code = 0;
|
||||
$error = $data['error'];
|
||||
|
||||
if (is_array($error)) {
|
||||
$code = $error['code'];
|
||||
$error = $error['message'];
|
||||
}
|
||||
|
||||
throw new IdentityProviderException($error, $code, $data);
|
||||
}
|
||||
}
|
||||
|
||||
protected function createResourceOwner(array $response, AccessToken $token)
|
||||
{
|
||||
return new GoogleUser($response);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Set Redirect URI in Developer Console as [https/http]://<yourdomain>/<folder>/get_oauth_token.php
|
||||
$provider = new Google(
|
||||
array(
|
||||
'clientId' => $clientId,
|
||||
'clientSecret' => $clientSecret,
|
||||
'redirectUri' => $redirectUri,
|
||||
'scope' => array('https://mail.google.com/'),
|
||||
'accessType' => 'offline'
|
||||
)
|
||||
);
|
||||
|
||||
if (!isset($_GET['code'])) {
|
||||
// If we don't have an authorization code then get one
|
||||
$authUrl = $provider->getAuthorizationUrl();
|
||||
$_SESSION['oauth2state'] = $provider->getState();
|
||||
header('Location: ' . $authUrl);
|
||||
exit;
|
||||
// Check given state against previously stored one to mitigate CSRF attack
|
||||
} elseif (empty($_GET['state']) || ($_GET['state'] !== $_SESSION['oauth2state'])) {
|
||||
unset($_SESSION['oauth2state']);
|
||||
exit('Invalid state');
|
||||
} else {
|
||||
// Try to get an access token (using the authorization code grant)
|
||||
$token = $provider->getAccessToken(
|
||||
'authorization_code',
|
||||
array(
|
||||
'code' => $_GET['code']
|
||||
)
|
||||
);
|
||||
|
||||
// Use this to get a new access token if the old one expires
|
||||
echo 'Refresh Token: ' . $token->getRefreshToken();
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
<?php
|
||||
|
||||
include(__DIR__.'/plates/Engine.php');
|
||||
include(__DIR__.'/plates/Extension/ExtensionInterface.php');
|
||||
include(__DIR__.'/plates/Template/Data.php');
|
||||
include(__DIR__.'/plates/Template/Directory.php');
|
||||
include(__DIR__.'/plates/Template/FileExtension.php');
|
||||
include(__DIR__.'/plates/Template/Folders.php');
|
||||
include(__DIR__.'/plates/Template/Func.php');
|
||||
include(__DIR__.'/plates/Template/Functions.php');
|
||||
include(__DIR__.'/plates/Template/Name.php');
|
||||
include(__DIR__.'/plates/Template/Template.php');
|
||||
|
||||
class Plates extends League\Plates\Engine { }
|
||||
|
||||
?>
|
||||
@@ -1,279 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace League\Plates;
|
||||
|
||||
use League\Plates\Extension\ExtensionInterface;
|
||||
use League\Plates\Template\Data;
|
||||
use League\Plates\Template\Directory;
|
||||
use League\Plates\Template\FileExtension;
|
||||
use League\Plates\Template\Folders;
|
||||
use League\Plates\Template\Func;
|
||||
use League\Plates\Template\Functions;
|
||||
use League\Plates\Template\Name;
|
||||
use League\Plates\Template\Template;
|
||||
|
||||
/**
|
||||
* Template API and environment settings storage.
|
||||
*/
|
||||
class Engine
|
||||
{
|
||||
/**
|
||||
* Default template directory.
|
||||
* @var Directory
|
||||
*/
|
||||
protected $directory;
|
||||
|
||||
/**
|
||||
* Template file extension.
|
||||
* @var FileExtension
|
||||
*/
|
||||
protected $fileExtension;
|
||||
|
||||
/**
|
||||
* Collection of template folders.
|
||||
* @var Folders
|
||||
*/
|
||||
protected $folders;
|
||||
|
||||
/**
|
||||
* Collection of template functions.
|
||||
* @var Functions
|
||||
*/
|
||||
protected $functions;
|
||||
|
||||
/**
|
||||
* Collection of preassigned template data.
|
||||
* @var Data
|
||||
*/
|
||||
protected $data;
|
||||
|
||||
/**
|
||||
* Create new Engine instance.
|
||||
* @param string $directory
|
||||
* @param string $fileExtension
|
||||
*/
|
||||
public function __construct($directory = null, $fileExtension = 'php')
|
||||
{
|
||||
$this->directory = new Directory($directory);
|
||||
$this->fileExtension = new FileExtension($fileExtension);
|
||||
$this->folders = new Folders();
|
||||
$this->functions = new Functions();
|
||||
$this->data = new Data();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set path to templates directory.
|
||||
* @param string|null $directory Pass null to disable the default directory.
|
||||
* @return Engine
|
||||
*/
|
||||
public function setDirectory($directory)
|
||||
{
|
||||
$this->directory->set($directory);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get path to templates directory.
|
||||
* @return string
|
||||
*/
|
||||
public function getDirectory()
|
||||
{
|
||||
return $this->directory->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the template file extension.
|
||||
* @param string|null $fileExtension Pass null to manually set it.
|
||||
* @return Engine
|
||||
*/
|
||||
public function setFileExtension($fileExtension)
|
||||
{
|
||||
$this->fileExtension->set($fileExtension);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the template file extension.
|
||||
* @return string
|
||||
*/
|
||||
public function getFileExtension()
|
||||
{
|
||||
return $this->fileExtension->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new template folder for grouping templates under different namespaces.
|
||||
* @param string $name
|
||||
* @param string $directory
|
||||
* @param boolean $fallback
|
||||
* @return Engine
|
||||
*/
|
||||
public function addFolder($name, $directory, $fallback = false)
|
||||
{
|
||||
$this->folders->add($name, $directory, $fallback);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a template folder.
|
||||
* @param string $name
|
||||
* @return Engine
|
||||
*/
|
||||
public function removeFolder($name)
|
||||
{
|
||||
$this->folders->remove($name);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get collection of all template folders.
|
||||
* @return Folders
|
||||
*/
|
||||
public function getFolders()
|
||||
{
|
||||
return $this->folders;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add preassigned template data.
|
||||
* @param array $data;
|
||||
* @param null|string|array $templates;
|
||||
* @return Engine
|
||||
*/
|
||||
public function addData(array $data, $templates = null)
|
||||
{
|
||||
$this->data->add($data, $templates);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all preassigned template data.
|
||||
* @param null|string $template;
|
||||
* @return array
|
||||
*/
|
||||
public function getData($template = null)
|
||||
{
|
||||
return $this->data->get($template);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a new template function.
|
||||
* @param string $name;
|
||||
* @param callback $callback;
|
||||
* @return Engine
|
||||
*/
|
||||
public function registerFunction($name, $callback)
|
||||
{
|
||||
$this->functions->add($name, $callback);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a template function.
|
||||
* @param string $name;
|
||||
* @return Engine
|
||||
*/
|
||||
public function dropFunction($name)
|
||||
{
|
||||
$this->functions->remove($name);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a template function.
|
||||
* @param string $name
|
||||
* @return Func
|
||||
*/
|
||||
public function getFunction($name)
|
||||
{
|
||||
return $this->functions->get($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a template function exists.
|
||||
* @param string $name
|
||||
* @return boolean
|
||||
*/
|
||||
public function doesFunctionExist($name)
|
||||
{
|
||||
return $this->functions->exists($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load an extension.
|
||||
* @param ExtensionInterface $extension
|
||||
* @return Engine
|
||||
*/
|
||||
public function loadExtension(ExtensionInterface $extension)
|
||||
{
|
||||
$extension->register($this);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load multiple extensions.
|
||||
* @param array $extensions
|
||||
* @return Engine
|
||||
*/
|
||||
public function loadExtensions(array $extensions = array())
|
||||
{
|
||||
foreach ($extensions as $extension) {
|
||||
$this->loadExtension($extension);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a template path.
|
||||
* @param string $name
|
||||
* @return string
|
||||
*/
|
||||
public function path($name)
|
||||
{
|
||||
$name = new Name($this, $name);
|
||||
|
||||
return $name->getPath();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a template exists.
|
||||
* @param string $name
|
||||
* @return boolean
|
||||
*/
|
||||
public function exists($name)
|
||||
{
|
||||
$name = new Name($this, $name);
|
||||
|
||||
return $name->doesPathExist();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new template.
|
||||
* @param string $name
|
||||
* @return Template
|
||||
*/
|
||||
public function make($name)
|
||||
{
|
||||
return new Template($this, $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new template and render it.
|
||||
* @param string $name
|
||||
* @param array $data
|
||||
* @return string
|
||||
*/
|
||||
public function render($name, array $data = array())
|
||||
{
|
||||
return $this->make($name)->render($data);
|
||||
}
|
||||
}
|
||||
@@ -1,85 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace League\Plates\Extension;
|
||||
|
||||
use League\Plates\Engine;
|
||||
use League\Plates\Template\Template;
|
||||
use LogicException;
|
||||
|
||||
/**
|
||||
* Extension that adds the ability to create "cache busted" asset URLs.
|
||||
*/
|
||||
class Asset implements ExtensionInterface
|
||||
{
|
||||
/**
|
||||
* Instance of the current template.
|
||||
* @var Template
|
||||
*/
|
||||
public $template;
|
||||
|
||||
/**
|
||||
* Path to asset directory.
|
||||
* @var string
|
||||
*/
|
||||
public $path;
|
||||
|
||||
/**
|
||||
* Enables the filename method.
|
||||
* @var boolean
|
||||
*/
|
||||
public $filenameMethod;
|
||||
|
||||
/**
|
||||
* Create new Asset instance.
|
||||
* @param string $path
|
||||
* @param boolean $filenameMethod
|
||||
*/
|
||||
public function __construct($path, $filenameMethod = false)
|
||||
{
|
||||
$this->path = rtrim($path, '/');
|
||||
$this->filenameMethod = $filenameMethod;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register extension function.
|
||||
* @param Engine $engine
|
||||
* @return null
|
||||
*/
|
||||
public function register(Engine $engine)
|
||||
{
|
||||
$engine->registerFunction('asset', array($this, 'cachedAssetUrl'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create "cache busted" asset URL.
|
||||
* @param string $url
|
||||
* @return string
|
||||
*/
|
||||
public function cachedAssetUrl($url)
|
||||
{
|
||||
$filePath = $this->path . '/' . ltrim($url, '/');
|
||||
|
||||
if (!file_exists($filePath)) {
|
||||
throw new LogicException(
|
||||
'Unable to locate the asset "' . $url . '" in the "' . $this->path . '" directory.'
|
||||
);
|
||||
}
|
||||
|
||||
$lastUpdated = filemtime($filePath);
|
||||
$pathInfo = pathinfo($url);
|
||||
|
||||
if ($pathInfo['dirname'] === '.') {
|
||||
$directory = '';
|
||||
} elseif ($pathInfo['dirname'] === '/') {
|
||||
$directory = '/';
|
||||
} else {
|
||||
$directory = $pathInfo['dirname'] . '/';
|
||||
}
|
||||
|
||||
if ($this->filenameMethod) {
|
||||
return $directory . $pathInfo['filename'] . '.' . $lastUpdated . '.' . $pathInfo['extension'];
|
||||
}
|
||||
|
||||
return $directory . $pathInfo['filename'] . '.' . $pathInfo['extension'] . '?v=' . $lastUpdated;
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace League\Plates\Extension;
|
||||
|
||||
use League\Plates\Engine;
|
||||
|
||||
/**
|
||||
* A common interface for extensions.
|
||||
*/
|
||||
interface ExtensionInterface
|
||||
{
|
||||
public function register(Engine $engine);
|
||||
}
|
||||
@@ -1,113 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace League\Plates\Extension;
|
||||
|
||||
use League\Plates\Engine;
|
||||
use League\Plates\Template\Template;
|
||||
use LogicException;
|
||||
|
||||
/**
|
||||
* Extension that adds a number of URI checks.
|
||||
*/
|
||||
class URI implements ExtensionInterface
|
||||
{
|
||||
/**
|
||||
* Instance of the current template.
|
||||
* @var Template
|
||||
*/
|
||||
public $template;
|
||||
|
||||
/**
|
||||
* The request URI.
|
||||
* @var string
|
||||
*/
|
||||
protected $uri;
|
||||
|
||||
/**
|
||||
* The request URI as an array.
|
||||
* @var array
|
||||
*/
|
||||
protected $parts;
|
||||
|
||||
/**
|
||||
* Create new URI instance.
|
||||
* @param string $uri
|
||||
*/
|
||||
public function __construct($uri)
|
||||
{
|
||||
$this->uri = $uri;
|
||||
$this->parts = explode('/', $this->uri);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register extension functions.
|
||||
* @param Engine $engine
|
||||
* @return null
|
||||
*/
|
||||
public function register(Engine $engine)
|
||||
{
|
||||
$engine->registerFunction('uri', array($this, 'runUri'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform URI check.
|
||||
* @param null|integer|string $var1
|
||||
* @param mixed $var2
|
||||
* @param mixed $var3
|
||||
* @param mixed $var4
|
||||
* @return mixed
|
||||
*/
|
||||
public function runUri($var1 = null, $var2 = null, $var3 = null, $var4 = null)
|
||||
{
|
||||
if (is_null($var1)) {
|
||||
return $this->uri;
|
||||
}
|
||||
|
||||
if (is_numeric($var1) and is_null($var2)) {
|
||||
return array_key_exists($var1, $this->parts) ? $this->parts[$var1] : null;
|
||||
}
|
||||
|
||||
if (is_numeric($var1) and is_string($var2)) {
|
||||
return $this->checkUriSegmentMatch($var1, $var2, $var3, $var4);
|
||||
}
|
||||
|
||||
if (is_string($var1)) {
|
||||
return $this->checkUriRegexMatch($var1, $var2, $var3);
|
||||
}
|
||||
|
||||
throw new LogicException('Invalid use of the uri function.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform a URI segment match.
|
||||
* @param integer $key
|
||||
* @param string $string
|
||||
* @param mixed $returnOnTrue
|
||||
* @param mixed $returnOnFalse
|
||||
* @return mixed
|
||||
*/
|
||||
protected function checkUriSegmentMatch($key, $string, $returnOnTrue = null, $returnOnFalse = null)
|
||||
{
|
||||
if (array_key_exists($key, $this->parts) && $this->parts[$key] === $string) {
|
||||
return is_null($returnOnTrue) ? true : $returnOnTrue;
|
||||
}
|
||||
|
||||
return is_null($returnOnFalse) ? false : $returnOnFalse;
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform a regular express match.
|
||||
* @param string $regex
|
||||
* @param mixed $returnOnTrue
|
||||
* @param mixed $returnOnFalse
|
||||
* @return mixed
|
||||
*/
|
||||
protected function checkUriRegexMatch($regex, $returnOnTrue = null, $returnOnFalse = null)
|
||||
{
|
||||
if (preg_match('#^' . $regex . '$#', $this->uri) === 1) {
|
||||
return is_null($returnOnTrue) ? true : $returnOnTrue;
|
||||
}
|
||||
|
||||
return is_null($returnOnFalse) ? false : $returnOnFalse;
|
||||
}
|
||||
}
|
||||
@@ -1,93 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace League\Plates\Template;
|
||||
|
||||
use LogicException;
|
||||
|
||||
/**
|
||||
* Preassigned template data.
|
||||
*/
|
||||
class Data
|
||||
{
|
||||
/**
|
||||
* Variables shared by all templates.
|
||||
* @var array
|
||||
*/
|
||||
protected $sharedVariables = array();
|
||||
|
||||
/**
|
||||
* Specific template variables.
|
||||
* @var array
|
||||
*/
|
||||
protected $templateVariables = array();
|
||||
|
||||
/**
|
||||
* Add template data.
|
||||
* @param array $data;
|
||||
* @param null|string|array $templates;
|
||||
* @return Data
|
||||
*/
|
||||
public function add(array $data, $templates = null)
|
||||
{
|
||||
if (is_null($templates)) {
|
||||
return $this->shareWithAll($data);
|
||||
}
|
||||
|
||||
if (is_array($templates)) {
|
||||
return $this->shareWithSome($data, $templates);
|
||||
}
|
||||
|
||||
if (is_string($templates)) {
|
||||
return $this->shareWithSome($data, array($templates));
|
||||
}
|
||||
|
||||
throw new LogicException(
|
||||
'The templates variable must be null, an array or a string, ' . gettype($templates) . ' given.'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add data shared with all templates.
|
||||
* @param array $data;
|
||||
* @return Data
|
||||
*/
|
||||
public function shareWithAll($data)
|
||||
{
|
||||
$this->sharedVariables = array_merge($this->sharedVariables, $data);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add data shared with some templates.
|
||||
* @param array $data;
|
||||
* @param array $templates;
|
||||
* @return Data
|
||||
*/
|
||||
public function shareWithSome($data, array $templates)
|
||||
{
|
||||
foreach ($templates as $template) {
|
||||
if (isset($this->templateVariables[$template])) {
|
||||
$this->templateVariables[$template] = array_merge($this->templateVariables[$template], $data);
|
||||
} else {
|
||||
$this->templateVariables[$template] = $data;
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get template data.
|
||||
* @param null|string $template;
|
||||
* @return array
|
||||
*/
|
||||
public function get($template = null)
|
||||
{
|
||||
if (isset($template, $this->templateVariables[$template])) {
|
||||
return array_merge($this->sharedVariables, $this->templateVariables[$template]);
|
||||
}
|
||||
|
||||
return $this->sharedVariables;
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace League\Plates\Template;
|
||||
|
||||
use LogicException;
|
||||
|
||||
/**
|
||||
* Default template directory.
|
||||
*/
|
||||
class Directory
|
||||
{
|
||||
/**
|
||||
* Template directory path.
|
||||
* @var string
|
||||
*/
|
||||
protected $path;
|
||||
|
||||
/**
|
||||
* Create new Directory instance.
|
||||
* @param string $path
|
||||
*/
|
||||
public function __construct($path = null)
|
||||
{
|
||||
$this->set($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set path to templates directory.
|
||||
* @param string|null $path Pass null to disable the default directory.
|
||||
* @return Directory
|
||||
*/
|
||||
public function set($path)
|
||||
{
|
||||
if (!is_null($path) and !is_dir($path)) {
|
||||
throw new LogicException(
|
||||
'The specified path "' . $path . '" does not exist.'
|
||||
);
|
||||
}
|
||||
|
||||
$this->path = $path;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get path to templates directory.
|
||||
* @return string
|
||||
*/
|
||||
public function get()
|
||||
{
|
||||
return $this->path;
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace League\Plates\Template;
|
||||
|
||||
/**
|
||||
* Template file extension.
|
||||
*/
|
||||
class FileExtension
|
||||
{
|
||||
/**
|
||||
* Template file extension.
|
||||
* @var string
|
||||
*/
|
||||
protected $fileExtension;
|
||||
|
||||
/**
|
||||
* Create new FileExtension instance.
|
||||
* @param null|string $fileExtension
|
||||
*/
|
||||
public function __construct($fileExtension = 'php')
|
||||
{
|
||||
$this->set($fileExtension);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the template file extension.
|
||||
* @param null|string $fileExtension
|
||||
* @return FileExtension
|
||||
*/
|
||||
public function set($fileExtension)
|
||||
{
|
||||
$this->fileExtension = $fileExtension;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the template file extension.
|
||||
* @return string
|
||||
*/
|
||||
public function get()
|
||||
{
|
||||
return $this->fileExtension;
|
||||
}
|
||||
}
|
||||
@@ -1,109 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace League\Plates\Template;
|
||||
|
||||
use LogicException;
|
||||
|
||||
/**
|
||||
* A template folder.
|
||||
*/
|
||||
class Folder
|
||||
{
|
||||
/**
|
||||
* The folder name.
|
||||
* @var string
|
||||
*/
|
||||
protected $name;
|
||||
|
||||
/**
|
||||
* The folder path.
|
||||
* @var string
|
||||
*/
|
||||
protected $path;
|
||||
|
||||
/**
|
||||
* The folder fallback status.
|
||||
* @var boolean
|
||||
*/
|
||||
protected $fallback;
|
||||
|
||||
/**
|
||||
* Create a new Folder instance.
|
||||
* @param string $name
|
||||
* @param string $path
|
||||
* @param boolean $fallback
|
||||
*/
|
||||
public function __construct($name, $path, $fallback = false)
|
||||
{
|
||||
$this->setName($name);
|
||||
$this->setPath($path);
|
||||
$this->setFallback($fallback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the folder name.
|
||||
* @param string $name
|
||||
* @return Folder
|
||||
*/
|
||||
public function setName($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the folder name.
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the folder path.
|
||||
* @param string $path
|
||||
* @return Folder
|
||||
*/
|
||||
public function setPath($path)
|
||||
{
|
||||
if (!is_dir($path)) {
|
||||
throw new LogicException('The specified directory path "' . $path . '" does not exist.');
|
||||
}
|
||||
|
||||
$this->path = $path;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the folder path.
|
||||
* @return string
|
||||
*/
|
||||
public function getPath()
|
||||
{
|
||||
return $this->path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the folder fallback status.
|
||||
* @param boolean $fallback
|
||||
* @return Folder
|
||||
*/
|
||||
public function setFallback($fallback)
|
||||
{
|
||||
$this->fallback = $fallback;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the folder fallback status.
|
||||
* @return boolean
|
||||
*/
|
||||
public function getFallback()
|
||||
{
|
||||
return $this->fallback;
|
||||
}
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace League\Plates\Template;
|
||||
|
||||
use LogicException;
|
||||
|
||||
/**
|
||||
* A collection of template folders.
|
||||
*/
|
||||
class Folders
|
||||
{
|
||||
/**
|
||||
* Array of template folders.
|
||||
* @var array
|
||||
*/
|
||||
protected $folders = array();
|
||||
|
||||
/**
|
||||
* Add a template folder.
|
||||
* @param string $name
|
||||
* @param string $path
|
||||
* @param boolean $fallback
|
||||
* @return Folders
|
||||
*/
|
||||
public function add($name, $path, $fallback = false)
|
||||
{
|
||||
if ($this->exists($name)) {
|
||||
throw new LogicException('The template folder "' . $name . '" is already being used.');
|
||||
}
|
||||
|
||||
$this->folders[$name] = new Folder($name, $path, $fallback);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a template folder.
|
||||
* @param string $name
|
||||
* @return Folders
|
||||
*/
|
||||
public function remove($name)
|
||||
{
|
||||
if (!$this->exists($name)) {
|
||||
throw new LogicException('The template folder "' . $name . '" was not found.');
|
||||
}
|
||||
|
||||
unset($this->folders[$name]);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a template folder.
|
||||
* @param string $name
|
||||
* @return Folder
|
||||
*/
|
||||
public function get($name)
|
||||
{
|
||||
if (!$this->exists($name)) {
|
||||
throw new LogicException('The template folder "' . $name . '" was not found.');
|
||||
}
|
||||
|
||||
return $this->folders[$name];
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a template folder exists.
|
||||
* @param string $name
|
||||
* @return boolean
|
||||
*/
|
||||
public function exists($name)
|
||||
{
|
||||
return isset($this->folders[$name]);
|
||||
}
|
||||
}
|
||||
@@ -1,107 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace League\Plates\Template;
|
||||
|
||||
use League\Plates\Extension\ExtensionInterface;
|
||||
use LogicException;
|
||||
|
||||
/**
|
||||
* A template function.
|
||||
*/
|
||||
class Func
|
||||
{
|
||||
/**
|
||||
* The function name.
|
||||
* @var string
|
||||
*/
|
||||
protected $name;
|
||||
|
||||
/**
|
||||
* The function callback.
|
||||
* @var callable
|
||||
*/
|
||||
protected $callback;
|
||||
|
||||
/**
|
||||
* Create new Func instance.
|
||||
* @param string $name
|
||||
* @param callable $callback
|
||||
*/
|
||||
public function __construct($name, $callback)
|
||||
{
|
||||
$this->setName($name);
|
||||
$this->setCallback($callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the function name.
|
||||
* @param string $name
|
||||
* @return Func
|
||||
*/
|
||||
public function setName($name)
|
||||
{
|
||||
if (preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $name) !== 1) {
|
||||
throw new LogicException(
|
||||
'Not a valid function name.'
|
||||
);
|
||||
}
|
||||
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the function name.
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the function callback
|
||||
* @param callable $callback
|
||||
* @return Func
|
||||
*/
|
||||
public function setCallback($callback)
|
||||
{
|
||||
if (!is_callable($callback, true)) {
|
||||
throw new LogicException(
|
||||
'Not a valid function callback.'
|
||||
);
|
||||
}
|
||||
|
||||
$this->callback = $callback;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the function callback.
|
||||
* @return callable
|
||||
*/
|
||||
public function getCallback()
|
||||
{
|
||||
return $this->callback;
|
||||
}
|
||||
|
||||
/**
|
||||
* Call the function.
|
||||
* @param Template $template
|
||||
* @param array $arguments
|
||||
* @return mixed
|
||||
*/
|
||||
public function call(Template $template = null, $arguments = array())
|
||||
{
|
||||
if (is_array($this->callback) and
|
||||
isset($this->callback[0]) and
|
||||
$this->callback[0] instanceof ExtensionInterface
|
||||
) {
|
||||
$this->callback[0]->template = $template;
|
||||
}
|
||||
|
||||
return call_user_func_array($this->callback, $arguments);
|
||||
}
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace League\Plates\Template;
|
||||
|
||||
use LogicException;
|
||||
|
||||
/**
|
||||
* A collection of template functions.
|
||||
*/
|
||||
class Functions
|
||||
{
|
||||
/**
|
||||
* Array of template functions.
|
||||
* @var array
|
||||
*/
|
||||
protected $functions = array();
|
||||
|
||||
/**
|
||||
* Add a new template function.
|
||||
* @param string $name;
|
||||
* @param callback $callback;
|
||||
* @return Functions
|
||||
*/
|
||||
public function add($name, $callback)
|
||||
{
|
||||
if ($this->exists($name)) {
|
||||
throw new LogicException(
|
||||
'The template function name "' . $name . '" is already registered.'
|
||||
);
|
||||
}
|
||||
|
||||
$this->functions[$name] = new Func($name, $callback);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a template function.
|
||||
* @param string $name;
|
||||
* @return Functions
|
||||
*/
|
||||
public function remove($name)
|
||||
{
|
||||
if (!$this->exists($name)) {
|
||||
throw new LogicException(
|
||||
'The template function "' . $name . '" was not found.'
|
||||
);
|
||||
}
|
||||
|
||||
unset($this->functions[$name]);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a template function.
|
||||
* @param string $name
|
||||
* @return Func
|
||||
*/
|
||||
public function get($name)
|
||||
{
|
||||
if (!$this->exists($name)) {
|
||||
throw new LogicException('The template function "' . $name . '" was not found.');
|
||||
}
|
||||
|
||||
return $this->functions[$name];
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a template function exists.
|
||||
* @param string $name
|
||||
* @return boolean
|
||||
*/
|
||||
public function exists($name)
|
||||
{
|
||||
return isset($this->functions[$name]);
|
||||
}
|
||||
}
|
||||
@@ -1,202 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace League\Plates\Template;
|
||||
|
||||
use League\Plates\Engine;
|
||||
use LogicException;
|
||||
|
||||
/**
|
||||
* A template name.
|
||||
*/
|
||||
class Name
|
||||
{
|
||||
/**
|
||||
* Instance of the template engine.
|
||||
* @var Engine
|
||||
*/
|
||||
protected $engine;
|
||||
|
||||
/**
|
||||
* The original name.
|
||||
* @var string
|
||||
*/
|
||||
protected $name;
|
||||
|
||||
/**
|
||||
* The parsed template folder.
|
||||
* @var Folder
|
||||
*/
|
||||
protected $folder;
|
||||
|
||||
/**
|
||||
* The parsed template filename.
|
||||
* @var string
|
||||
*/
|
||||
protected $file;
|
||||
|
||||
/**
|
||||
* Create a new Name instance.
|
||||
* @param Engine $engine
|
||||
* @param string $name
|
||||
*/
|
||||
public function __construct(Engine $engine, $name)
|
||||
{
|
||||
$this->setEngine($engine);
|
||||
$this->setName($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the engine.
|
||||
* @param Engine $engine
|
||||
* @return Name
|
||||
*/
|
||||
public function setEngine(Engine $engine)
|
||||
{
|
||||
$this->engine = $engine;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the engine.
|
||||
* @return Engine
|
||||
*/
|
||||
public function getEngine()
|
||||
{
|
||||
return $this->engine;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the original name and parse it.
|
||||
* @param string $name
|
||||
* @return Name
|
||||
*/
|
||||
public function setName($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
$parts = explode('::', $this->name);
|
||||
|
||||
if (count($parts) === 1) {
|
||||
$this->setFile($parts[0]);
|
||||
} elseif (count($parts) === 2) {
|
||||
$this->setFolder($parts[0]);
|
||||
$this->setFile($parts[1]);
|
||||
} else {
|
||||
throw new LogicException(
|
||||
'The template name "' . $this->name . '" is not valid. ' .
|
||||
'Do not use the folder namespace separator "::" more than once.'
|
||||
);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the original name.
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the parsed template folder.
|
||||
* @param string $folder
|
||||
* @return Name
|
||||
*/
|
||||
public function setFolder($folder)
|
||||
{
|
||||
$this->folder = $this->engine->getFolders()->get($folder);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the parsed template folder.
|
||||
* @return string
|
||||
*/
|
||||
public function getFolder()
|
||||
{
|
||||
return $this->folder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the parsed template file.
|
||||
* @param string $file
|
||||
* @return Name
|
||||
*/
|
||||
public function setFile($file)
|
||||
{
|
||||
if ($file === '') {
|
||||
throw new LogicException(
|
||||
'The template name "' . $this->name . '" is not valid. ' .
|
||||
'The template name cannot be empty.'
|
||||
);
|
||||
}
|
||||
|
||||
$this->file = $file;
|
||||
|
||||
if (!is_null($this->engine->getFileExtension())) {
|
||||
$this->file .= '.' . $this->engine->getFileExtension();
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the parsed template file.
|
||||
* @return string
|
||||
*/
|
||||
public function getFile()
|
||||
{
|
||||
return $this->file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve template path.
|
||||
* @return string
|
||||
*/
|
||||
public function getPath()
|
||||
{
|
||||
if (is_null($this->folder)) {
|
||||
return $this->getDefaultDirectory() . DIRECTORY_SEPARATOR . $this->file;
|
||||
}
|
||||
|
||||
$path = $this->folder->getPath() . DIRECTORY_SEPARATOR . $this->file;
|
||||
|
||||
if (!is_file($path) and $this->folder->getFallback() and is_file($this->getDefaultDirectory() . DIRECTORY_SEPARATOR . $this->file)) {
|
||||
$path = $this->getDefaultDirectory() . DIRECTORY_SEPARATOR . $this->file;
|
||||
}
|
||||
|
||||
return $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if template path exists.
|
||||
* @return boolean
|
||||
*/
|
||||
public function doesPathExist()
|
||||
{
|
||||
return is_file($this->getPath());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default templates directory.
|
||||
* @return string
|
||||
*/
|
||||
protected function getDefaultDirectory()
|
||||
{
|
||||
$directory = $this->engine->getDirectory();
|
||||
|
||||
if (is_null($directory)) {
|
||||
throw new LogicException(
|
||||
'The template name "' . $this->name . '" is not valid. '.
|
||||
'The default directory has not been defined.'
|
||||
);
|
||||
}
|
||||
|
||||
return $directory;
|
||||
}
|
||||
}
|
||||
@@ -1,346 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace League\Plates\Template;
|
||||
|
||||
use Exception;
|
||||
use League\Plates\Engine;
|
||||
use LogicException;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
* Container which holds template data and provides access to template functions.
|
||||
*/
|
||||
class Template
|
||||
{
|
||||
/**
|
||||
* Instance of the template engine.
|
||||
* @var Engine
|
||||
*/
|
||||
protected $engine;
|
||||
|
||||
/**
|
||||
* The name of the template.
|
||||
* @var Name
|
||||
*/
|
||||
protected $name;
|
||||
|
||||
/**
|
||||
* The data assigned to the template.
|
||||
* @var array
|
||||
*/
|
||||
protected $data = array();
|
||||
|
||||
/**
|
||||
* An array of section content.
|
||||
* @var array
|
||||
*/
|
||||
protected $sections = array();
|
||||
|
||||
/**
|
||||
* The name of the section currently being rendered.
|
||||
* @var string
|
||||
*/
|
||||
protected $sectionName;
|
||||
|
||||
/**
|
||||
* Whether the section should be appended or not.
|
||||
* @var boolean
|
||||
*/
|
||||
protected $appendSection;
|
||||
|
||||
/**
|
||||
* The name of the template layout.
|
||||
* @var string
|
||||
*/
|
||||
protected $layoutName;
|
||||
|
||||
/**
|
||||
* The data assigned to the template layout.
|
||||
* @var array
|
||||
*/
|
||||
protected $layoutData;
|
||||
|
||||
/**
|
||||
* Create new Template instance.
|
||||
* @param Engine $engine
|
||||
* @param string $name
|
||||
*/
|
||||
public function __construct(Engine $engine, $name)
|
||||
{
|
||||
$this->engine = $engine;
|
||||
$this->name = new Name($engine, $name);
|
||||
|
||||
$this->data($this->engine->getData($name));
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic method used to call extension functions.
|
||||
* @param string $name
|
||||
* @param array $arguments
|
||||
* @return mixed
|
||||
*/
|
||||
public function __call($name, $arguments)
|
||||
{
|
||||
return $this->engine->getFunction($name)->call($this, $arguments);
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias for render() method.
|
||||
* @throws \Throwable
|
||||
* @throws \Exception
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return $this->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Assign or get template data.
|
||||
* @param array $data
|
||||
* @return mixed
|
||||
*/
|
||||
public function data(array $data = null)
|
||||
{
|
||||
if (is_null($data)) {
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
$this->data = array_merge($this->data, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the template exists.
|
||||
* @return boolean
|
||||
*/
|
||||
public function exists()
|
||||
{
|
||||
return $this->name->doesPathExist();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the template path.
|
||||
* @return string
|
||||
*/
|
||||
public function path()
|
||||
{
|
||||
return $this->name->getPath();
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the template and layout.
|
||||
* @param array $data
|
||||
* @throws \Throwable
|
||||
* @throws \Exception
|
||||
* @return string
|
||||
*/
|
||||
public function render(array $data = array())
|
||||
{
|
||||
$this->data($data);
|
||||
unset($data);
|
||||
extract($this->data);
|
||||
|
||||
if (!$this->exists()) {
|
||||
throw new LogicException(
|
||||
'The template "' . $this->name->getName() . '" could not be found at "' . $this->path() . '".'
|
||||
);
|
||||
}
|
||||
|
||||
try {
|
||||
$level = ob_get_level();
|
||||
ob_start();
|
||||
|
||||
include $this->path();
|
||||
|
||||
$content = ob_get_clean();
|
||||
|
||||
if (isset($this->layoutName)) {
|
||||
$layout = $this->engine->make($this->layoutName);
|
||||
$layout->sections = array_merge($this->sections, array('content' => $content));
|
||||
$content = $layout->render($this->layoutData);
|
||||
}
|
||||
|
||||
return $content;
|
||||
} catch (Throwable $e) {
|
||||
while (ob_get_level() > $level) {
|
||||
ob_end_clean();
|
||||
}
|
||||
|
||||
throw $e;
|
||||
} catch (Exception $e) {
|
||||
while (ob_get_level() > $level) {
|
||||
ob_end_clean();
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the template's layout.
|
||||
* @param string $name
|
||||
* @param array $data
|
||||
* @return null
|
||||
*/
|
||||
public function layout($name, array $data = array())
|
||||
{
|
||||
$this->layoutName = $name;
|
||||
$this->layoutData = $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Start a new section block.
|
||||
* @param string $name
|
||||
* @return null
|
||||
*/
|
||||
public function start($name)
|
||||
{
|
||||
if ($name === 'content') {
|
||||
throw new LogicException(
|
||||
'The section name "content" is reserved.'
|
||||
);
|
||||
}
|
||||
|
||||
if ($this->sectionName) {
|
||||
throw new LogicException('You cannot nest sections within other sections.');
|
||||
}
|
||||
|
||||
$this->sectionName = $name;
|
||||
|
||||
ob_start();
|
||||
}
|
||||
|
||||
/**
|
||||
* Start a new append section block.
|
||||
* @param string $name
|
||||
* @return null
|
||||
*/
|
||||
public function push($name)
|
||||
{
|
||||
$this->appendSection = true;
|
||||
|
||||
$this->start($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop the current section block.
|
||||
* @return null
|
||||
*/
|
||||
public function stop()
|
||||
{
|
||||
if (is_null($this->sectionName)) {
|
||||
throw new LogicException(
|
||||
'You must start a section before you can stop it.'
|
||||
);
|
||||
}
|
||||
|
||||
if (!isset($this->sections[$this->sectionName])) {
|
||||
$this->sections[$this->sectionName] = '';
|
||||
}
|
||||
|
||||
$this->sections[$this->sectionName] = $this->appendSection ? $this->sections[$this->sectionName] . ob_get_clean() : ob_get_clean();
|
||||
$this->sectionName = null;
|
||||
$this->appendSection = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias of stop().
|
||||
* @return null
|
||||
*/
|
||||
public function end()
|
||||
{
|
||||
$this->stop();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the content for a section block.
|
||||
* @param string $name Section name
|
||||
* @param string $default Default section content
|
||||
* @return string|null
|
||||
*/
|
||||
public function section($name, $default = null)
|
||||
{
|
||||
if (!isset($this->sections[$name])) {
|
||||
return $default;
|
||||
}
|
||||
|
||||
return $this->sections[$name];
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch a rendered template.
|
||||
* @param string $name
|
||||
* @param array $data
|
||||
* @return string
|
||||
*/
|
||||
public function fetch($name, array $data = array())
|
||||
{
|
||||
return $this->engine->render($name, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Output a rendered template.
|
||||
* @param string $name
|
||||
* @param array $data
|
||||
* @return null
|
||||
*/
|
||||
public function insert($name, array $data = array())
|
||||
{
|
||||
echo $this->engine->render($name, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply multiple functions to variable.
|
||||
* @param mixed $var
|
||||
* @param string $functions
|
||||
* @return mixed
|
||||
*/
|
||||
public function batch($var, $functions)
|
||||
{
|
||||
foreach (explode('|', $functions) as $function) {
|
||||
if ($this->engine->doesFunctionExist($function)) {
|
||||
$var = call_user_func(array($this, $function), $var);
|
||||
} elseif (is_callable($function)) {
|
||||
$var = call_user_func($function, $var);
|
||||
} else {
|
||||
throw new LogicException(
|
||||
'The batch function could not find the "' . $function . '" function.'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $var;
|
||||
}
|
||||
|
||||
/**
|
||||
* Escape string.
|
||||
* @param string $string
|
||||
* @param null|string $functions
|
||||
* @return string
|
||||
*/
|
||||
public function escape($string, $functions = null)
|
||||
{
|
||||
static $flags;
|
||||
|
||||
if (!isset($flags)) {
|
||||
$flags = ENT_QUOTES | (defined('ENT_SUBSTITUTE') ? ENT_SUBSTITUTE : 0);
|
||||
}
|
||||
|
||||
if ($functions) {
|
||||
$string = $this->batch($string, $functions);
|
||||
}
|
||||
|
||||
return htmlspecialchars($string, $flags, 'UTF-8');
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias to escape function.
|
||||
* @param string $string
|
||||
* @param null|string $functions
|
||||
* @return string
|
||||
*/
|
||||
public function e($string, $functions = null)
|
||||
{
|
||||
return $this->escape($string, $functions);
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
<?php
|
||||
|
||||
include 'Engine.php';
|
||||
include 'Extension/ExtensionInterface.php';
|
||||
include 'Template/Data.php';
|
||||
include 'Template/Directory.php';
|
||||
include 'Template/FileExtension.php';
|
||||
include 'Template/Folders.php';
|
||||
include 'Template/Func.php';
|
||||
include 'Template/Functions.php';
|
||||
include 'Template/Name.php';
|
||||
include 'Template/Template.php';
|
||||
// Create new Plates instance
|
||||
$templates = new League\Plates\Engine('templates');
|
||||
|
||||
// Preassign data to the layout
|
||||
$templates->addData(['company' => 'The Company Name'], 'layout');
|
||||
|
||||
// Render a template
|
||||
echo $templates->render('profile', ['name' => 'Jonathan']);
|
||||
@@ -1,12 +0,0 @@
|
||||
<html>
|
||||
<head>
|
||||
<title><?=$this->e($title)?> | <?=$this->e($company)?></title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<?=$this->section('content')?>
|
||||
|
||||
<?=$this->section('scripts')?>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,12 +0,0 @@
|
||||
<?php $this->layout('layout', ['title' => 'User Profile']) ?>
|
||||
|
||||
<h1>User Profile</h1>
|
||||
<p>Hello, <?=$this->e($name)?>!</p>
|
||||
|
||||
<?php $this->insert('sidebar') ?>
|
||||
|
||||
<?php $this->push('scripts') ?>
|
||||
<script>
|
||||
// Some JavaScript
|
||||
</script>
|
||||
<?php $this->end() ?>
|
||||
@@ -1,6 +0,0 @@
|
||||
<ul>
|
||||
<li><a href="#link">Example sidebar link</a></li>
|
||||
<li><a href="#link">Example sidebar link</a></li>
|
||||
<li><a href="#link">Example sidebar link</a></li>
|
||||
<li><a href="#link">Example sidebar link</a></li>
|
||||
</ul>
|
||||
File diff suppressed because one or more lines are too long
@@ -1,10 +0,0 @@
|
||||
<?php
|
||||
|
||||
require __DIR__ . '/src/utilphp/util.php';
|
||||
|
||||
/**
|
||||
* Globally namespaced version of the class.
|
||||
*
|
||||
* @author Brandon Wamboldt <brandon.wamboldt@gmail.com>
|
||||
*/
|
||||
class util extends \utilphp\util { }
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
require(__dir__.'/../vendor/autoload.php');
|
||||
define('__LINE__',__FILE__." ".__FUNCTION__." ".__LINE__." : ");
|
||||
ob_start();
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<?php
|
||||
require_once('_common.php');
|
||||
require_once(ROOT.'/f_config/config.php');
|
||||
require_once(ROOT.W.F_FUNC.W.'class._DB.php');
|
||||
require_once(ROOT.W.F_FUNC.W.'class._JSON.php');
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
require(__dir__.'/../vendor/autoload.php');
|
||||
|
||||
class _JSON {
|
||||
public static function Encode($arr) {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<?php
|
||||
require_once('_common.php');
|
||||
require_once(ROOT.'/f_config/config.php');
|
||||
|
||||
class _Lock {
|
||||
private static $l = ROOT.W.'lock.txt';
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<?php
|
||||
|
||||
require_once('_common.php');
|
||||
require_once(ROOT.'/f_config/config.php');
|
||||
|
||||
require_once(ROOT.W.F_FUNC.W.'class._DB.php');
|
||||
require_once(ROOT.W.F_FUNC.W.'class._JSON.php');
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<?php
|
||||
require_once('_common.php');
|
||||
require_once(ROOT.'/f_config/config.php');
|
||||
require_once(ROOT.W.F_FUNC.W.'class._Lock.php');
|
||||
|
||||
class _Process {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
require(__dir__.'/../vendor/autoload.php');
|
||||
|
||||
class _Queue {
|
||||
private $capacity;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
require(__dir__.'/../vendor/autoload.php');
|
||||
|
||||
class _Session {
|
||||
public function __construct() {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<?php
|
||||
require_once('_common.php');
|
||||
require_once(ROOT.'/f_config/config.php');
|
||||
|
||||
class _Setting {
|
||||
private $settingFile;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
require(__dir__.'/../vendor/autoload.php');
|
||||
|
||||
class _String {
|
||||
public static function GetStrLen($str) {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
require(__dir__.'/../vendor/autoload.php');
|
||||
|
||||
class _Time {
|
||||
public static function DateToday() {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
require_once(ROOT.W.F_FUNC.W.'class._String.php');
|
||||
require(__dir__.'/../vendor/autoload.php');
|
||||
require_once(ROOT.W.F_FUNC.W.'class._String.php');
|
||||
|
||||
class _Validation {
|
||||
public static function CheckID($id) {
|
||||
$len = strlen($id);
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
require(__dir__.'/../vendor/autoload.php');
|
||||
|
||||
function CustomHeader() {
|
||||
//FIXME: 왜 Contect-Type이 text/html로 고정이지?!
|
||||
if(!headers_sent()) {
|
||||
header('Cache-Control: no-cache');
|
||||
header('Pragma: no-cache');
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
require_once('_common.php');
|
||||
// dbHost, dbId, dbPw, dbName, mailHost, mailPort, mailId, mailPw
|
||||
$dbHost = $_POST['dbHost'];
|
||||
$dbId = $_POST['dbId'];
|
||||
@@ -10,7 +11,7 @@ $mailId = $_POST['mailId'];
|
||||
$mailPw = $_POST['mailPw'];
|
||||
$mailAddr = $_POST['mailAddr'];
|
||||
|
||||
require_once('_common.php');
|
||||
|
||||
require_once(ROOT.W.F_FUNC.W.'class._DB.php');
|
||||
require_once(ROOT.W.F_FUNC.W.'class._String.php');
|
||||
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
<?php
|
||||
require_once('_common.php');
|
||||
|
||||
// id, pw
|
||||
$id = $_POST['id'];
|
||||
$pw = $_POST['pw'];
|
||||
$pw = md5($pw.$pw);
|
||||
|
||||
require_once('_common.php');
|
||||
require_once(ROOT.W.F_FUNC.W.'class._Time.php');
|
||||
require_once(ROOT.W.F_CONFIG.W.DB.PHP);
|
||||
|
||||
|
||||
@@ -6,8 +6,6 @@
|
||||
// $_POST['select'] : 0: 폐쇄, 1: 리셋, 2: 오픈
|
||||
|
||||
require_once('_common.php');
|
||||
require_once(ROOT.W.E_LIB.W.'util.php');
|
||||
require_once(ROOT.W.E_LIB.W.'plates.php');
|
||||
require_once(ROOT.W.F_FUNC.W.'class._JSON.php');
|
||||
require_once(ROOT.W.F_CONFIG.W.DB.PHP);
|
||||
require_once(ROOT.W.F_CONFIG.W.SESSION.PHP);
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
<?php
|
||||
// 외부 파라미터
|
||||
|
||||
require_once('_common.php');
|
||||
|
||||
require_once(ROOT.W.F_FUNC.W.'class._JSON.php');
|
||||
require_once(ROOT.W.F_FUNC.W.'class._Time.php');
|
||||
require_once(ROOT.W.F_CONFIG.W.DB.PHP);
|
||||
require_once(ROOT.W.F_CONFIG.W.SESSION.PHP);
|
||||
|
||||
// 외부 파라미터
|
||||
|
||||
$rs = $DB->Select('GRADE', 'MEMBER', "NO='{$SESSION->NoMember()}'");
|
||||
$member = $DB->Get($rs);
|
||||
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
<?php
|
||||
require_once('_common.php');
|
||||
require_once(ROOT.W.F_FUNC.W.'class._JSON.php');
|
||||
require_once(ROOT.W.F_CONFIG.W.DB.PHP);
|
||||
require_once(ROOT.W.F_CONFIG.W.SESSION.PHP);
|
||||
|
||||
// 외부 파라미터
|
||||
// $_POST['date'] : 일자
|
||||
// $_POST['id'] : ID
|
||||
@@ -13,11 +18,6 @@ $rname = $_POST['rname'];
|
||||
$subname = $_POST['subname'];
|
||||
$amount = $_POST['amount'];
|
||||
|
||||
require_once('_common.php');
|
||||
require_once(ROOT.W.F_FUNC.W.'class._JSON.php');
|
||||
require_once(ROOT.W.F_CONFIG.W.DB.PHP);
|
||||
require_once(ROOT.W.F_CONFIG.W.SESSION.PHP);
|
||||
|
||||
$rs = $DB->Select('GRADE', 'MEMBER', "NO='{$SESSION->NoMember()}'");
|
||||
$member = $DB->Get($rs);
|
||||
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
<?php
|
||||
// 외부 파라미터
|
||||
|
||||
require_once('_common.php');
|
||||
require_once(ROOT.W.F_FUNC.W.'class._JSON.php');
|
||||
require_once(ROOT.W.F_CONFIG.W.DB.PHP);
|
||||
require_once(ROOT.W.F_CONFIG.W.SESSION.PHP);
|
||||
|
||||
// 외부 파라미터
|
||||
$rs = $DB->Select('GRADE', 'MEMBER', "NO='{$SESSION->NoMember()}'");
|
||||
$member = $DB->Get($rs);
|
||||
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
<?php
|
||||
// 외부 파라미터
|
||||
// $_POST['serverDir'] : 로그인할 서버 디렉토리
|
||||
//$serverDir = $_POST['serverDir']; //TODO:쓸모 없어보이는데?
|
||||
|
||||
require_once('_common.php');
|
||||
require_once(ROOT.W.F_FUNC.W.'class._JSON.php');
|
||||
require_once(ROOT.W.F_CONFIG.W.DB.PHP);
|
||||
require_once(ROOT.W.F_CONFIG.W.SESSION.PHP);
|
||||
|
||||
// 외부 파라미터
|
||||
// $_POST['serverDir'] : 로그인할 서버 디렉토리
|
||||
//$serverDir = $_POST['serverDir']; //TODO:쓸모 없어보이는데?
|
||||
|
||||
|
||||
$rs = $DB->Select('ID, PW, CONMSG', 'MEMBER', "NO='{$SESSION->NoMember()}'");
|
||||
$member = $DB->Get($rs);
|
||||
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
<?php
|
||||
// 외부 파라미터
|
||||
|
||||
require_once('_common.php');
|
||||
require_once(ROOT.W.F_FUNC.W.'class._JSON.php');
|
||||
require_once(ROOT.W.F_CONFIG.W.DB.PHP);
|
||||
require_once(ROOT.W.F_CONFIG.W.SESSION.PHP);
|
||||
|
||||
// 외부 파라미터
|
||||
|
||||
|
||||
$SESSION->Logout();
|
||||
|
||||
$response['result'] = 'SUCCESS';
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
<?php
|
||||
// 외부 파라미터
|
||||
|
||||
require_once('_common.php');
|
||||
require_once(ROOT.W.F_FUNC.W.'class._JSON.php');
|
||||
require_once(ROOT.W.F_CONFIG.W.DB.PHP);
|
||||
require_once(ROOT.W.F_CONFIG.W.SESSION.PHP);
|
||||
|
||||
// 외부 파라미터
|
||||
|
||||
|
||||
$rs = $DB->Select('ID, NAME, GRADE, PICTURE', 'MEMBER', "NO='{$SESSION->NoMember()}'");
|
||||
$member = $DB->Get($rs);
|
||||
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
<?php
|
||||
// 외부 파라미터
|
||||
|
||||
require_once('_common.php');
|
||||
require_once(ROOT.W.F_FUNC.W.'class._JSON.php');
|
||||
require_once(ROOT.W.F_CONFIG.W.DB.PHP);
|
||||
@@ -8,6 +6,8 @@ require_once(ROOT.W.F_CONFIG.W.'DBS'.PHP);
|
||||
require_once(ROOT.W.F_CONFIG.W.SETTINGS.PHP);
|
||||
require_once(ROOT.W.F_CONFIG.W.SESSION.PHP);
|
||||
|
||||
// 외부 파라미터
|
||||
|
||||
$dest = ROOT.W.D."pic/pic_{$SESSION->NoMember()}.jpg";
|
||||
|
||||
$rs = $DB->Select('ID, PICTURE', 'MEMBER', "NO='{$SESSION->NoMember()}'");
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
<?php
|
||||
// 외부 파라미터
|
||||
// $_FILES['picture'] : 사진파일
|
||||
|
||||
require_once('_common.php');
|
||||
require_once(ROOT.W.F_CONFIG.W.DB.PHP);
|
||||
require_once(ROOT.W.F_CONFIG.W.'DBS'.PHP);
|
||||
require_once(ROOT.W.F_CONFIG.W.SETTINGS.PHP);
|
||||
require_once(ROOT.W.F_CONFIG.W.SESSION.PHP);
|
||||
|
||||
// 외부 파라미터
|
||||
// $_FILES['picture'] : 사진파일
|
||||
|
||||
$image = $_FILES['picture'];
|
||||
$ext = strrchr($image['name'], ".");
|
||||
$size = getImageSize($image['tmp_name']);
|
||||
|
||||
@@ -1,10 +1,4 @@
|
||||
<?php
|
||||
// 외부 파라미터
|
||||
// $_POST['pw'] : PW
|
||||
// $_POST['newPw'] : 새 PW
|
||||
$pw = $_POST['pw'];
|
||||
$newPw = $_POST['newPw'];
|
||||
|
||||
require_once('_common.php');
|
||||
require_once(ROOT.W.F_FUNC.W.'class._JSON.php');
|
||||
require_once(ROOT.W.F_CONFIG.W.DB.PHP);
|
||||
@@ -12,6 +6,12 @@ require_once(ROOT.W.F_CONFIG.W.'DBS'.PHP);
|
||||
require_once(ROOT.W.F_CONFIG.W.SETTINGS.PHP);
|
||||
require_once(ROOT.W.F_CONFIG.W.SESSION.PHP);
|
||||
|
||||
// 외부 파라미터
|
||||
// $_POST['pw'] : PW
|
||||
// $_POST['newPw'] : 새 PW
|
||||
$pw = $_POST['pw'];
|
||||
$newPw = $_POST['newPw'];
|
||||
|
||||
$response['result'] = 'FAIL';
|
||||
|
||||
$rs = $DB->Select('ID, PW', 'MEMBER', "NO='{$SESSION->NoMember()}'");
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
<?php
|
||||
// 외부 파라미터
|
||||
// $_POST['pw'] : PW
|
||||
$pw = $_POST['pw'];
|
||||
|
||||
require_once('_common.php');
|
||||
require_once(ROOT.W.F_FUNC.W.'class._JSON.php');
|
||||
require_once(ROOT.W.F_FUNC.W.'class._Time.php');
|
||||
require_once(ROOT.W.F_CONFIG.W.DB.PHP);
|
||||
require_once(ROOT.W.F_CONFIG.W.SESSION.PHP);
|
||||
|
||||
// 외부 파라미터
|
||||
// $_POST['pw'] : PW
|
||||
$pw = $_POST['pw'];
|
||||
|
||||
$response['result'] = 'FAIL';
|
||||
|
||||
$rs = $DB->Select('PW', 'MEMBER', "NO='{$SESSION->NoMember()}'");
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
<?php
|
||||
// 외부 파라미터
|
||||
// $_GET['select'] : 정렬선택
|
||||
$select = $_GET['select'];
|
||||
|
||||
require_once('_common.php');
|
||||
require_once(ROOT.W.F_FUNC.W.'class._JSON.php');
|
||||
require_once(ROOT.W.F_CONFIG.W.DB.PHP);
|
||||
require_once(ROOT.W.F_CONFIG.W.SESSION.PHP);
|
||||
require_once(ROOT.W.E_LIB.W.'util.php');
|
||||
|
||||
// 외부 파라미터
|
||||
// $_GET['select'] : 정렬선택
|
||||
$select = $_GET['select'];
|
||||
|
||||
$rs = $DB->Select('GRADE', 'MEMBER', "NO='{$SESSION->NoMember()}'");
|
||||
$member = $DB->Get($rs);
|
||||
|
||||
@@ -1,10 +1,4 @@
|
||||
<?php
|
||||
// 외부 파라미터
|
||||
// $_POST['select'] : 처리종류
|
||||
// $_POST['no'] : NO
|
||||
$select = $_POST['select'];
|
||||
$no = $_POST['no'];
|
||||
|
||||
require_once('_common.php');
|
||||
require_once(ROOT.W.F_FUNC.W.'class._JSON.php');
|
||||
require_once(ROOT.W.F_CONFIG.W.DB.PHP);
|
||||
@@ -12,6 +6,12 @@ require_once(ROOT.W.F_CONFIG.W.'DBS'.PHP);
|
||||
require_once(ROOT.W.F_CONFIG.W.SETTINGS.PHP);
|
||||
require_once(ROOT.W.F_CONFIG.W.SESSION.PHP);
|
||||
|
||||
// 외부 파라미터
|
||||
// $_POST['select'] : 처리종류
|
||||
// $_POST['no'] : NO
|
||||
$select = $_POST['select'];
|
||||
$no = $_POST['no'];
|
||||
|
||||
$rs = $DB->Select('GRADE', 'MEMBER', "NO='{$SESSION->NoMember()}'");
|
||||
$member = $DB->Get($rs);
|
||||
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
<?php
|
||||
// 외부 파라미터
|
||||
|
||||
require_once('_common.php');
|
||||
require_once(ROOT.W.F_FUNC.W.'class._JSON.php');
|
||||
require_once(ROOT.W.F_CONFIG.W.DB.PHP);
|
||||
@@ -8,6 +6,9 @@ require_once(ROOT.W.F_CONFIG.W.DBS.PHP);
|
||||
require_once(ROOT.W.F_CONFIG.W.SETTINGS.PHP);
|
||||
require_once(ROOT.W.F_CONFIG.W.SESSION.PHP);
|
||||
|
||||
// 외부 파라미터
|
||||
|
||||
|
||||
$rs = $DB->Select('ID, GRADE', 'MEMBER', "NO='{$SESSION->NoMember()}'");
|
||||
$member = $DB->Get($rs);
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
Deny from all
|
||||
<?php if(isset($allow_ip) && $allow_ip != ''): ?>
|
||||
SetEnvIf X-Forwarded-For ^192\.168\.0\.1 env_allow_1
|
||||
SetEnvIf X-Forwarded-For ^<?=str_replace('.', '\\.', $allow_ip)?> env_allow_1
|
||||
Allow from env=env_allow_1
|
||||
Allow from 192.168.0.1
|
||||
Allow from <?=$allow_ip?>
|
||||
<?php endif; ?>
|
||||
+6
-6
@@ -1,4 +1,10 @@
|
||||
<?php
|
||||
require_once('_common.php');
|
||||
require_once(ROOT.W.F_FUNC.W.'class._JSON.php');
|
||||
require_once(ROOT.W.F_FUNC.W.'class._Session.php');
|
||||
require_once(ROOT.W.F_FUNC.W.'class._String.php');
|
||||
require_once(ROOT.W.F_CONFIG.W.DB.PHP);
|
||||
|
||||
// 외부 파라미터
|
||||
// $_POST['id'] : ID
|
||||
// $_POST['pw'] : PW
|
||||
@@ -7,12 +13,6 @@ $id = $_POST['id'];
|
||||
$pw = $_POST['pw'];
|
||||
$conmsg = $_POST['conmsg'];
|
||||
|
||||
require_once('_common.php');
|
||||
require_once(ROOT.W.F_FUNC.W.'class._JSON.php');
|
||||
require_once(ROOT.W.F_FUNC.W.'class._Session.php');
|
||||
require_once(ROOT.W.F_FUNC.W.'class._String.php');
|
||||
require_once(ROOT.W.F_CONFIG.W.DB.PHP);
|
||||
|
||||
$id = _String::NoSpecialCharacter($id);
|
||||
$pw = substr($pw, 0, 32);
|
||||
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
<?php
|
||||
require_once('_common.php');
|
||||
require_once(ROOT.W.F_FUNC.W.'class._JSON.php');
|
||||
require_once(ROOT.W.F_FUNC.W.'class._Time.php');
|
||||
require_once(ROOT.W.F_FUNC.W.'class._String.php');
|
||||
require_once(ROOT.W.F_FUNC.W.'class._Validation.php');
|
||||
require_once(ROOT.W.F_CONFIG.W.DB.PHP);
|
||||
|
||||
// 외부 파라미터
|
||||
// $_POST['id'] : ID
|
||||
// $_POST['pid1'] : 주민번호
|
||||
@@ -10,12 +17,6 @@ $pid2 = $_POST['pid2'];
|
||||
$pid = $_POST['pid1'].'-'.substr($_POST['pid2'],0,1).'-'.md5($_POST['pid2']);
|
||||
$email = $_POST['email'];
|
||||
|
||||
require_once('_common.php');
|
||||
require_once(ROOT.W.F_FUNC.W.'class._JSON.php');
|
||||
require_once(ROOT.W.F_FUNC.W.'class._Time.php');
|
||||
require_once(ROOT.W.F_FUNC.W.'class._String.php');
|
||||
require_once(ROOT.W.F_FUNC.W.'class._Validation.php');
|
||||
require_once(ROOT.W.F_CONFIG.W.DB.PHP);
|
||||
|
||||
$response['result'] = 'FAIL';
|
||||
$err = _Validation::CheckID($id);
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
<?php
|
||||
require_once('_common.php');
|
||||
require_once(ROOT.W.F_FUNC.W.'class._JSON.php');
|
||||
require_once(ROOT.W.F_FUNC.W.'class._String.php');
|
||||
require_once(ROOT.W.F_FUNC.W.'class._Validation.php');
|
||||
require_once(ROOT.W.F_CONFIG.W.DB.PHP);
|
||||
|
||||
// 외부 파라미터
|
||||
// $_POST['type'] : 0: ID체크, 1: 주민번호 체크, 2: 이메일 체크
|
||||
// $_POST['id'] : ID
|
||||
@@ -12,11 +18,6 @@ $pid2 = $_POST['pid2'];
|
||||
$pid = $_POST['pid1'].'-'.substr($_POST['pid2'],0,1).'-'.md5($_POST['pid2']);
|
||||
$email = $_POST['email'];
|
||||
|
||||
require_once('_common.php');
|
||||
require_once(ROOT.W.F_FUNC.W.'class._JSON.php');
|
||||
require_once(ROOT.W.F_FUNC.W.'class._String.php');
|
||||
require_once(ROOT.W.F_FUNC.W.'class._Validation.php');
|
||||
require_once(ROOT.W.F_CONFIG.W.DB.PHP);
|
||||
|
||||
$response['type'] = $type;
|
||||
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
<?php
|
||||
// 외부 파라미터
|
||||
// $_POST['email'] : 이메일
|
||||
$email = $_POST['email'];
|
||||
|
||||
require_once('_common.php');
|
||||
require_once(ROOT.W.F_FUNC.W.'class._JSON.php');
|
||||
require_once(ROOT.W.F_FUNC.W.'class._String.php');
|
||||
@@ -11,6 +7,10 @@ require_once(ROOT.W.F_FUNC.W.'class._Time.php');
|
||||
require_once(ROOT.W.F_CONFIG.W.DB.PHP);
|
||||
require_once(ROOT.W.F_CONFIG.W.'MAIL'.PHP);
|
||||
|
||||
// 외부 파라미터
|
||||
// $_POST['email'] : 이메일
|
||||
$email = $_POST['email'];
|
||||
|
||||
$response['result'] = 'FAIL';
|
||||
|
||||
$err = _Validation::CheckEmail($email);
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
<?php
|
||||
require_once('_common.php');
|
||||
require_once(ROOT.W.F_FUNC.W.'class._JSON.php');
|
||||
require_once(ROOT.W.F_FUNC.W.'class._Validation.php');
|
||||
require_once(ROOT.W.F_FUNC.W.'class._Time.php');
|
||||
require_once(ROOT.W.F_CONFIG.W.DB.PHP);
|
||||
|
||||
// 외부 파라미터
|
||||
// $_POST['email'] : 이메일
|
||||
// $_POST['code'] : 인증번호
|
||||
$email = $_POST['email'];
|
||||
$code = $_POST['code'];
|
||||
|
||||
require_once('_common.php');
|
||||
require_once(ROOT.W.F_FUNC.W.'class._JSON.php');
|
||||
require_once(ROOT.W.F_FUNC.W.'class._Validation.php');
|
||||
require_once(ROOT.W.F_FUNC.W.'class._Time.php');
|
||||
require_once(ROOT.W.F_CONFIG.W.DB.PHP);
|
||||
|
||||
$response['result'] = 'FAIL';
|
||||
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
<?php
|
||||
require_once('_common.php');
|
||||
require_once(ROOT.W.F_FUNC.W.'class._JSON.php');
|
||||
require_once(ROOT.W.F_FUNC.W.'class._Time.php');
|
||||
require_once(ROOT.W.F_FUNC.W.'class._String.php');
|
||||
require_once(ROOT.W.F_FUNC.W.'class._Validation.php');
|
||||
require_once(ROOT.W.F_CONFIG.W.DB.PHP);
|
||||
|
||||
// 외부 파라미터
|
||||
// $_POST['id'] : ID
|
||||
// $_POST['pw'] : PW
|
||||
@@ -14,14 +21,7 @@ $pid = $_POST['pid1'].'-'.substr($_POST['pid2'],0,1).'-'.md5($_POST['pid2']);
|
||||
$name = $_POST['name'];
|
||||
$email = $_POST['email'];
|
||||
|
||||
$pw = substr($pw, 0, 32);
|
||||
|
||||
require_once('_common.php');
|
||||
require_once(ROOT.W.F_FUNC.W.'class._JSON.php');
|
||||
require_once(ROOT.W.F_FUNC.W.'class._Time.php');
|
||||
require_once(ROOT.W.F_FUNC.W.'class._String.php');
|
||||
require_once(ROOT.W.F_FUNC.W.'class._Validation.php');
|
||||
require_once(ROOT.W.F_CONFIG.W.DB.PHP);
|
||||
$pw = substr($pw, 0, 32); //FIXME: 32글자 제한을 왜해!
|
||||
|
||||
$name = _String::NoSpecialCharacter($name);
|
||||
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
<?php
|
||||
require_once('_common.php');
|
||||
require_once(ROOT.W.F_FUNC.W.'class._JSON.php');
|
||||
require_once(ROOT.W.F_FUNC.W.'class._String.php');
|
||||
require_once(ROOT.W.F_FUNC.W.'class._Validation.php');
|
||||
require_once(ROOT.W.F_CONFIG.W.DB.PHP);
|
||||
|
||||
// 외부 파라미터
|
||||
// $_POST['type'] : 0: ID체크, 1: 주민번호 체크, 2: 닉네임 체크, 3: 이메일 체크
|
||||
// $_POST['id'] : ID
|
||||
@@ -14,12 +20,6 @@ $pid = $_POST['pid1'].'-'.substr($_POST['pid2'],0,1).'-'.md5($_POST['pid2']);
|
||||
$name = $_POST['name'];
|
||||
$email = $_POST['email'];
|
||||
|
||||
require_once('_common.php');
|
||||
require_once(ROOT.W.F_FUNC.W.'class._JSON.php');
|
||||
require_once(ROOT.W.F_FUNC.W.'class._String.php');
|
||||
require_once(ROOT.W.F_FUNC.W.'class._Validation.php');
|
||||
require_once(ROOT.W.F_CONFIG.W.DB.PHP);
|
||||
|
||||
$name = _String::NoSpecialCharacter($name);
|
||||
|
||||
$response['type'] = $type;
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
<?php
|
||||
// 외부 파라미터
|
||||
// $_POST['email'] : 이메일
|
||||
$email = $_POST['email'];
|
||||
|
||||
require_once('_common.php');
|
||||
require_once(ROOT.W.F_FUNC.W.'class._JSON.php');
|
||||
require_once(ROOT.W.F_FUNC.W.'class._String.php');
|
||||
@@ -11,6 +7,10 @@ require_once(ROOT.W.F_FUNC.W.'class._Time.php');
|
||||
require_once(ROOT.W.F_CONFIG.W.DB.PHP);
|
||||
require_once(ROOT.W.F_CONFIG.W.'MAIL'.PHP);
|
||||
|
||||
// 외부 파라미터
|
||||
// $_POST['email'] : 이메일
|
||||
$email = $_POST['email'];
|
||||
|
||||
$response['result'] = 'FAIL';
|
||||
|
||||
$err = _Validation::CheckEmail($email);
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
<?php
|
||||
// 외부 파라미터
|
||||
// $_POST['email'] : 이메일
|
||||
// $_POST['code'] : 인증번호
|
||||
$email = $_POST['email'];
|
||||
$code = $_POST['code'];
|
||||
|
||||
require_once('_common.php');
|
||||
require_once(ROOT.W.F_FUNC.W.'class._JSON.php');
|
||||
require_once(ROOT.W.F_FUNC.W.'class._Validation.php');
|
||||
require_once(ROOT.W.F_FUNC.W.'class._Time.php');
|
||||
require_once(ROOT.W.F_CONFIG.W.DB.PHP);
|
||||
|
||||
// 외부 파라미터
|
||||
// $_POST['email'] : 이메일
|
||||
// $_POST['code'] : 인증번호
|
||||
$email = $_POST['email'];
|
||||
$code = $_POST['code'];
|
||||
|
||||
$response['result'] = 'FAIL';
|
||||
|
||||
$err = _Validation::CheckEmail($email);
|
||||
|
||||
+2
-1
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
require_once('_common.php');
|
||||
|
||||
$category = util::array_get($_GET['category'], 0);
|
||||
//FIXME: 겨우 category 구분을 위해 php를 써야하는가? JavaScript로 바꾸자
|
||||
$images = IMAGES;
|
||||
?>
|
||||
|
||||
|
||||
+1
-1
@@ -5,4 +5,4 @@ require_once('_common.php');
|
||||
|
||||
<!--<meta HTTP-EQUIV="refresh" CONTENT="0; URL=f_install/install.php">-->
|
||||
Go to f_install/install.php<br>
|
||||
Todo : Back to replace code
|
||||
Todo: Back to replace code
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<?php
|
||||
include "lib.php";
|
||||
include "func.php";
|
||||
require_once '../e_lib/util.php';
|
||||
//로그인 검사
|
||||
|
||||
$isgen = util::array_get($_POST['isgen'], '');
|
||||
|
||||
+1
-2
@@ -1,8 +1,7 @@
|
||||
<?php
|
||||
$yearmonth = $_POST['yearmonth'];
|
||||
|
||||
include "lib.php";
|
||||
include "func.php";
|
||||
$yearmonth = $_POST['yearmonth'];
|
||||
//로그인 검사
|
||||
CheckLogin();
|
||||
$connect = dbConn();
|
||||
|
||||
+4
-2
@@ -1,8 +1,10 @@
|
||||
<?php
|
||||
// $btn0~15, $gold0~15
|
||||
|
||||
include "lib.php";
|
||||
include "func.php";
|
||||
|
||||
// $btn0~15, $gold0~15
|
||||
|
||||
|
||||
//로그인 검사
|
||||
CheckLogin();
|
||||
$connect = dbConn();
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
// $title, $msg, $num
|
||||
|
||||
include "lib.php";
|
||||
include "func.php";
|
||||
// $title, $msg, $num
|
||||
|
||||
//로그인 검사
|
||||
CheckLogin();
|
||||
$connect = dbConn();
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
// $btn, $msg, $scoutmsg, $rate, $bill, $secretlimit
|
||||
|
||||
include "lib.php";
|
||||
include "func.php";
|
||||
// $btn, $msg, $scoutmsg, $rate, $bill, $secretlimit
|
||||
|
||||
//로그인 검사
|
||||
CheckLogin();
|
||||
$connect = dbConn();
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
// $turn, $command, $cost, $name, $nationname, $note, $double, $third, $fourth
|
||||
|
||||
include "lib.php";
|
||||
include "func.php";
|
||||
// $turn, $command, $cost, $name, $nationname, $note, $double, $third, $fourth
|
||||
|
||||
//로그인 검사
|
||||
CheckLogin();
|
||||
$connect = dbConn();
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
// $msg, $genlist
|
||||
|
||||
include "lib.php";
|
||||
include "func.php";
|
||||
// $msg, $genlist
|
||||
|
||||
//로그인 검사
|
||||
CheckLogin(1);
|
||||
$connect = dbConn();
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
// $btn, $level, $genlist, $outlist
|
||||
|
||||
include "lib.php";
|
||||
include "func.php";
|
||||
// $btn, $level, $genlist, $outlist
|
||||
|
||||
//로그인 검사
|
||||
CheckLogin();
|
||||
$connect = dbConn();
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
// $title, $msg, $num
|
||||
|
||||
include "lib.php";
|
||||
include "func.php";
|
||||
// $title, $msg, $num
|
||||
|
||||
//로그인 검사
|
||||
CheckLogin();
|
||||
$connect = dbConn();
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
// $msg
|
||||
|
||||
include "lib.php";
|
||||
include "func.php";
|
||||
// $msg
|
||||
|
||||
//로그인 검사
|
||||
CheckLogin();
|
||||
$connect = dbConn();
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
// $btn, $msg
|
||||
|
||||
include "lib.php";
|
||||
include "func.php";
|
||||
// $btn, $msg
|
||||
|
||||
//로그인 검사
|
||||
CheckLogin();
|
||||
$connect = dbConn();
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
// $btn, $name, $troop
|
||||
|
||||
include "lib.php";
|
||||
include "func.php";
|
||||
// $btn, $name, $troop
|
||||
|
||||
//로그인 검사
|
||||
CheckLogin();
|
||||
$connect = dbConn();
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
//TODO: 등용장 재 디자인.
|
||||
//xxx: 일단 비활성화
|
||||
die("<script>location.replace('msglist.php');</script>");
|
||||
header('Location:msglist.php');
|
||||
die();
|
||||
|
||||
include "lib.php";
|
||||
include "func.php";
|
||||
|
||||
+2
-2
@@ -1,10 +1,10 @@
|
||||
<?php
|
||||
include "lib.php";
|
||||
include "func.php";
|
||||
//////////////////////////장수성격//////////////////////////////////////////////
|
||||
//은둔 안전 유지 재간 출세 할거 정복 패권 의협 대의 왕좌
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
include "lib.php";
|
||||
include "func.php";
|
||||
//로그인 검사
|
||||
CheckLogin();
|
||||
$connect = dbConn();
|
||||
|
||||
+2
-2
@@ -1,10 +1,10 @@
|
||||
<?php
|
||||
include "lib.php";
|
||||
include "func.php";
|
||||
//////////////////////////장수성격//////////////////////////////////////////////
|
||||
//은둔 안전 유지 재간 출세 할거 정복 패권 의협 대의 왕좌
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
include "lib.php";
|
||||
include "func.php";
|
||||
//로그인 검사
|
||||
CheckLogin();
|
||||
$connect = dbConn();
|
||||
|
||||
+2
-2
@@ -1,10 +1,10 @@
|
||||
<?php
|
||||
include "lib.php";
|
||||
include "func.php";
|
||||
//////////////////////////장수성격//////////////////////////////////////////////
|
||||
//은둔 안전 유지 재간 출세 할거 정복 패권 의협 대의 왕좌
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
include "lib.php";
|
||||
include "func.php";
|
||||
//로그인 검사
|
||||
CheckLogin();
|
||||
$connect = dbConn();
|
||||
|
||||
+2
-2
@@ -1,10 +1,10 @@
|
||||
<?php
|
||||
include "lib.php";
|
||||
include "func.php";
|
||||
//////////////////////////장수성격//////////////////////////////////////////////
|
||||
//은둔 안전 유지 재간 출세 할거 정복 패권 의협 대의 왕좌
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
include "lib.php";
|
||||
include "func.php";
|
||||
//로그인 검사
|
||||
CheckLogin();
|
||||
$connect = dbConn();
|
||||
|
||||
+5
-19
@@ -1,6 +1,5 @@
|
||||
<?php
|
||||
require_once('../e_lib/util.php');
|
||||
include "func_http.php";
|
||||
require(__dir__.'/../vendor/autoload.php');
|
||||
|
||||
function getHistory($count, $year, $month, $isFirst=0) {
|
||||
$fp = @fopen("logs/_history.txt", "r");
|
||||
@@ -79,26 +78,13 @@ function LogHistory($connect, $isFirst=0) {
|
||||
array_pop($map_path);
|
||||
array_push($map_path, 'map.php?type=2&graphic=0');
|
||||
$map_path = join('/', $map_path);
|
||||
//$file = explode('/', __FILE__);
|
||||
//$url = '/'.$file[count($file)-3].'/'.$file[count($file)-2].'/map.php?type=2&graphic=0';
|
||||
|
||||
/* 소켓 통신을 통하여 필요한 html정보를 가져옴 */
|
||||
if(STEP_LOG) pushStepLog(date('Y-m-d H:i:s').', Start HTTP');
|
||||
|
||||
//$http = new HTTP("62che.com", 80, 10);
|
||||
$http = new HTTP(parse_url($current_url, PHP_URL_HOST), parse_url($current_url, PHP_URL_PORT), 10);
|
||||
if(STEP_LOG) pushStepLog(date('Y-m-d H:i:s').', Connect end, '.$http->GetError());
|
||||
if($http->GetErr() == true) { return false; }
|
||||
$http->setHttpVersion("1.1");
|
||||
$cookie = "";
|
||||
$http->Get($map_path, $cookie);
|
||||
if(STEP_LOG) pushStepLog(date('Y-m-d H:i:s').', Response end, '.$http->GetError());
|
||||
if($http->GetErr() == true) { return false; }
|
||||
$map = $http->Response["body"];
|
||||
$client = new GuzzleHttp\Client();
|
||||
$response = $client->get($map_path);
|
||||
|
||||
$map = (string)$response->getBody();
|
||||
$map = str_replace("'", '<_quot_>', $map);
|
||||
$map = str_replace('"', '<_dquot_>', $map);
|
||||
$http->Close();
|
||||
if($http->GetErr() == true) { return false; }
|
||||
|
||||
$log = getHistory(20, $admin['year'], $admin['month'], $isFirst);
|
||||
$genlog = getGenHistory(50, $admin['year'], $admin['month'], $isFirst);
|
||||
|
||||
@@ -1,288 +0,0 @@
|
||||
<?php
|
||||
class HTTP{
|
||||
var $Socket, $Server, $Port, $Timeout, $HttpVersion = "1.0", $Url, $Length, $ResponseTime, $ErrNum, $ErrMsg;
|
||||
var $headers = array();
|
||||
var $Response = array();
|
||||
var $Err = false;
|
||||
var $_chunkedLength =0;
|
||||
|
||||
function HTTP($Server, $Port = 80, $Timeout = 30){
|
||||
$this->Server = $Server;
|
||||
$this->Port = $Port;
|
||||
$this->Timeout = $Timeout;
|
||||
|
||||
$this->Socket = @fsockopen ($this->Server, $this->Port, $errno, $errstr, $this->Timeout);
|
||||
if(!$this->Socket){
|
||||
$this->Error(0, "Socket Connection Fail");
|
||||
}
|
||||
}
|
||||
|
||||
function setTimeout($Timeout){
|
||||
$this->Timeout = $Timeout;
|
||||
}
|
||||
|
||||
function setHttpVersion($HttpVersion){
|
||||
$this->HttpVersion = $HttpVersion;
|
||||
}
|
||||
|
||||
function Head($Url = "/") {
|
||||
$this->Url = $Url;
|
||||
$msg = sprintf("HEAD %s HTTP/%s\r\n", $this->Url, $this->HttpVersion);
|
||||
$msg .= $this->PutHead();
|
||||
$msg .= "\r\n\r\n";
|
||||
fputs($this->Socket, $msg);
|
||||
|
||||
return $this->Read();
|
||||
}
|
||||
|
||||
function isHead($Url = "/"){
|
||||
$this->Url = $Url;
|
||||
$msg = sprintf("HEAD %s HTTP/%s\r\n", $this->Url, $this->HttpVersion);
|
||||
if($Cookie != ""){
|
||||
$msg .= $this->PutCookie($Cookie);
|
||||
}
|
||||
$msg .= $this->PutHead();
|
||||
$msg .= "\r\n\r\n";
|
||||
fputs($this->Socket, $msg);
|
||||
|
||||
return $this->isOK();
|
||||
}
|
||||
|
||||
function GetHead($Url = "/") {
|
||||
$this->Url = $Url;
|
||||
$msg = sprintf("GET %s HTTP/%s\r\n", $this->Url, $this->HttpVersion);
|
||||
$msg .= $this->PutHead();
|
||||
$msg .= "\r\n\r\n";
|
||||
fputs($this->Socket, $msg);
|
||||
$out = $this->ReadHeader();
|
||||
return $out;
|
||||
}
|
||||
|
||||
function Get($Url = "/", $Cookie="") {
|
||||
$this->Url = $Url;
|
||||
$msg = sprintf("GET %s HTTP/%s\r\n", $this->Url, $this->HttpVersion);
|
||||
if($Cookie != ""){
|
||||
$msg .= $this->PutCookie($Cookie);
|
||||
}
|
||||
$msg .= $this->PutHead();
|
||||
$msg .= "\r\n\r\n";
|
||||
fputs($this->Socket, $msg);
|
||||
return $this->Read();
|
||||
}
|
||||
|
||||
function isGet($Url = "/", $Cookie=""){
|
||||
$this->Url = $Url;
|
||||
$msg = sprintf("GET %s HTTP/%s\r\n", $this->Url, $this->HttpVersion);
|
||||
if($Cookie != ""){
|
||||
$msg .= $this->PutCookie($Cookie);
|
||||
}
|
||||
$msg .= $this->PutHead();
|
||||
$msg .= "\r\n\r\n";
|
||||
fputs($this->Socket, $msg);
|
||||
return $this->isOK();
|
||||
}
|
||||
|
||||
function isGetAll($Url = "/", $Cookie=""){
|
||||
$this->Url = $Url;
|
||||
$msg = sprintf("GET %s HTTP/%s\r\n", $this->Url, $this->HttpVersion);
|
||||
if($Cookie != ""){
|
||||
$msg .= $this->PutCookie($Cookie);
|
||||
}
|
||||
$msg .= $this->PutHead();
|
||||
$msg .= "\r\n\r\n";
|
||||
fputs($this->Socket, $msg);
|
||||
|
||||
$data = $this->Read();
|
||||
$this->Length = strlen($data);
|
||||
return $this->isOK($data);
|
||||
}
|
||||
|
||||
function Post($Url, $Data, $Cookie = ""){
|
||||
$this->Url = $Url;
|
||||
fputs($this->Socket,sprintf("POST %s HTTP/%s\r\n", $this->Url, $this->HttpVersion));
|
||||
if($Cookie != ""){
|
||||
$this->PutCookie($Cookie);
|
||||
}
|
||||
$this->PutHead();
|
||||
fputs($this->Socket, "Content-type: application/x-www-form-urlencoded\r\n");
|
||||
$out = "";
|
||||
while (list ($k, $v) = each ($Data)) {
|
||||
if(strlen($out) != 0) $out .= "&";
|
||||
$out .= rawurlencode($k). "=" .rawurlencode($v);
|
||||
}
|
||||
fputs($this->Socket, "Content-length: ".strlen($out)."\r\n");
|
||||
fputs($this->Socket, "$out");
|
||||
fputs($this->Socket, "\r\n");
|
||||
return $this->Read();
|
||||
}
|
||||
|
||||
function IsPost($Url, $Data, $Cookie = ""){
|
||||
$this->Url = $Url;
|
||||
fputs($this->Socket,sprintf("POST %s HTTP/%s\r\n", $this->Url, $this->HttpVersion));
|
||||
if($Cookie != ""){
|
||||
$this->PutCookie($Cookie);
|
||||
}
|
||||
$this->PutHead();
|
||||
fputs($this->Socket, "Content-type: application/x-www-form-urlencoded\r\n");
|
||||
$out = "";
|
||||
while (list ($k, $v) = each ($Data)) {
|
||||
if(strlen($out) != 0) $out .= "&";
|
||||
$out .= rawurlencode($k). "=" .rawurlencode($v);
|
||||
}
|
||||
fputs($this->Socket, "Content-length: ".strlen($out)."\r\n\r\n");
|
||||
fputs($this->Socket, "$out");
|
||||
fputs($this->Socket, "\r\n");
|
||||
return $this->isOk();
|
||||
}
|
||||
|
||||
function PutHead(){
|
||||
$msg = "";
|
||||
$msg .= "Accept: */*\r\n";
|
||||
$msg .= "Accept-Language: ko\r\n";
|
||||
$msg .= "Accept-Encoding: gzip, deflate\r\n";
|
||||
$msg .= "User-Agent: Mozilla/4.0 (compatible; 62che)\r\n";
|
||||
while (list($name, $value) = each ($this->headers)) {
|
||||
$msg .= "$name: $value\r\n";
|
||||
}
|
||||
$msg .= "Host: ".$this->Server.":".$this->Port."\r\n";
|
||||
$msg .= "Connection: close\r\n";
|
||||
return $msg;
|
||||
}
|
||||
|
||||
function AddHeader($name, $value){
|
||||
$this->headers[$name] = $value;
|
||||
}
|
||||
|
||||
function PutCookie($cookie){
|
||||
$msg = "";
|
||||
if(is_array($cookie)){
|
||||
$out = "";
|
||||
while (list ($k, $v) = each ($cookie)) {
|
||||
if(strlen($out) != 0) $out .= ";";
|
||||
$out .= rawurlencode($k). "=" .rawurlencode($v);
|
||||
}
|
||||
$msg = "Cookie: $out\n";
|
||||
} else {
|
||||
$msg = "Cookie: $cookie\n";
|
||||
}
|
||||
return $msg;
|
||||
}
|
||||
|
||||
function Read(){
|
||||
$out = $this->ReadHeader();
|
||||
$chunked = isset($this->Response['transfer-encoding']) && ('chunked' == $this->Response['transfer-encoding']);
|
||||
$gzipped = isset($this->Response['content-encoding']) && ('gzip' == $this->Response['content-encoding']);
|
||||
$body = '';
|
||||
$this->_chunkLength = 0;
|
||||
while(!feof($this->Socket)){
|
||||
if ($chunked) {
|
||||
$buf = $this->_readChunked();
|
||||
} else {
|
||||
$buf = fread($this->Socket, 4096);
|
||||
}
|
||||
$body .= $buf;
|
||||
}
|
||||
if($gzipped){
|
||||
$body = gzinflate(substr($body, 10));
|
||||
}
|
||||
$this->Response['body'] = $body;
|
||||
$out .= $body;
|
||||
return $out;
|
||||
}
|
||||
|
||||
function ReadHeader(){
|
||||
$out = '';
|
||||
$buf = $this->_readLine();
|
||||
if (sscanf($buf, 'HTTP/%s %s', $http_version, $returncode) != 2) {
|
||||
$this->Error(0,"Malformed response");
|
||||
return false;
|
||||
} else {
|
||||
$this->Response["protocol"] = 'HTTP/' . $http_version;
|
||||
$this->Response["code"] = intval($returncode);
|
||||
}
|
||||
$out .= $buf;
|
||||
while(!feof($this->Socket)){
|
||||
$buf = $this->_readLine();
|
||||
$out .= $buf;
|
||||
|
||||
if($buf == "\n" || $buf == "\r\n"){
|
||||
break;
|
||||
}
|
||||
|
||||
list($name,$value) = split(":",rtrim($buf,"\r\n"),2);
|
||||
$this->Response[strtolower($name)] = trim($value);
|
||||
}
|
||||
$this->Response["header"] = $out;
|
||||
return $out;
|
||||
}
|
||||
|
||||
function isOk($buffer = ""){
|
||||
if($buffer == "") $buffer .= fgets($this->Socket, 128);
|
||||
if(preg_match('/^HTTP\/.* (2\d{2}|3\d{2}).*/', $buffer)){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function _readLine(){
|
||||
$line = '';
|
||||
while(!feof($this->Socket)){
|
||||
$line .= fgets($this->Socket, 4096);
|
||||
if (substr($line, -2) == "\r\n" || substr($line, -1) == "\n") {
|
||||
return $line;
|
||||
}
|
||||
}
|
||||
return $line;
|
||||
}
|
||||
|
||||
function _readAll(){
|
||||
$data = '';
|
||||
while(!feof($this->Socket)){
|
||||
$data .= fread($this->Socket, 4096);
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
function _readChunked(){
|
||||
// at start of the next chunk?
|
||||
if (0 == $this->_chunkLength) {
|
||||
$line = $this->_readLine();
|
||||
if (preg_match('/^([0-9a-f]+)/i', $line, $matches)) {
|
||||
$this->_chunkLength = hexdec($matches[1]);
|
||||
// Chunk with zero length indicates the end
|
||||
if (0 == $this->_chunkLength) {
|
||||
$this->_readAll(); // make this an eof()
|
||||
return '';
|
||||
}
|
||||
}
|
||||
}
|
||||
$data = fread($this->Socket, $this->_chunkLength);
|
||||
$this->_chunkLength -= strlen($data);
|
||||
if (0 == $this->_chunkLength) {
|
||||
$this->_readLine(); // Trailing CRLF
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
function Close(){
|
||||
fclose($this->Socket);
|
||||
}
|
||||
|
||||
function Error($errnum, $errmsg){
|
||||
$this->Err = true;
|
||||
$this->ErrNum = $errnum;
|
||||
$this->ErrMsg = $errmsg;
|
||||
}
|
||||
|
||||
function GetErr() {
|
||||
return $this->Err;
|
||||
}
|
||||
|
||||
function GetError() {
|
||||
if($this->Err == true) {
|
||||
return "{$this->ErrNum}, {$this->ErrMsg}";
|
||||
} else {
|
||||
return "No Err";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
<?php
|
||||
require_once(__dir__.'/d_setting/conf.php');
|
||||
require_once(__dir__.'/../e_lib/util.php');
|
||||
require_once(__dir__.'/../e_lib/plates.php');
|
||||
require(__dir__.'/../vendor/autoload.php');
|
||||
|
||||
class Message{
|
||||
//기본 정보
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<?php
|
||||
include "lib.php";
|
||||
include "func.php";
|
||||
require('../e_lib/util.php');
|
||||
|
||||
$turnterm = util::array_get($_POST['turnterm'],'0');
|
||||
$sync = util::array_get($_POST['sync'],'0');
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
include "lib.php";
|
||||
include "schema.php";
|
||||
include "func.php";
|
||||
require "../e_lib/util.php";
|
||||
if(file_exists("d_setting/set.php")) error("이미 set.php가 생성되어 있습니다.<br><br>재설치하려면 해당 파일을 지우세요");
|
||||
|
||||
|
||||
|
||||
+2
-3
@@ -1,11 +1,10 @@
|
||||
<?php
|
||||
// $msg, $genlist
|
||||
|
||||
include 'lib.php';
|
||||
include 'func.php';
|
||||
require_once('../e_lib/util.php');
|
||||
require_once('func_message.php');
|
||||
|
||||
// $msg, $genlist
|
||||
|
||||
|
||||
$post = parseJsonPost();
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<?php
|
||||
include "lib.php";
|
||||
include "func.php";
|
||||
require "../e_lib/util.php";
|
||||
|
||||
$id = $_POST['id'];
|
||||
$pw = $_POST['pw'];
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
require(__dir__.'/../vendor/autoload.php');
|
||||
/******************************************************************************
|
||||
체섭용 인클루드 파일
|
||||
******************************************************************************/
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
require(__dir__.'/../vendor/autoload.php');
|
||||
include "lib.php";
|
||||
include "func.php";
|
||||
require_once('../e_lib/util.php');
|
||||
$connect = dbConn("sammo");
|
||||
|
||||
$id = util::array_get($_POST['id'],'');
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
include "lib.php";
|
||||
include "func.php";
|
||||
include "schema.sql";
|
||||
include "schema.php";
|
||||
|
||||
$connect = dbConn();
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user