HOR-4527
This commit is contained in:
committed by
Julio Cesar Laura Avendaño
parent
abe71a6ffe
commit
0d533e19d9
@@ -27,12 +27,13 @@
|
|||||||
"minimum-stability": "dev",
|
"minimum-stability": "dev",
|
||||||
"prefer-stable": true,
|
"prefer-stable": true,
|
||||||
"require": {
|
"require": {
|
||||||
|
"php": ">=5.6",
|
||||||
"laravel/framework": "5.4.*",
|
"laravel/framework": "5.4.*",
|
||||||
"luracast/restler": "^3.0",
|
"luracast/restler": "^3.0",
|
||||||
"bshaffer/oauth2-server-php": "v1.0",
|
"bshaffer/oauth2-server-php": "v1.0",
|
||||||
"colosa/pmUI": "release/3.2.3-dev",
|
"colosa/pmUI": "release/3.2.4-dev",
|
||||||
"colosa/MichelangeloFE": "release/3.2.3-dev",
|
"colosa/MichelangeloFE": "release/3.2.4-dev",
|
||||||
"colosa/pmdynaform": "release/3.2.3-dev",
|
"colosa/pmdynaform": "release/3.2.4-dev",
|
||||||
"google/apiclient": "1.1.6",
|
"google/apiclient": "1.1.6",
|
||||||
"dapphp/securimage": "^3.6",
|
"dapphp/securimage": "^3.6",
|
||||||
"psr/log":"1.0.0",
|
"psr/log":"1.0.0",
|
||||||
@@ -43,9 +44,11 @@
|
|||||||
"pear/archive_tar": "1.4.*",
|
"pear/archive_tar": "1.4.*",
|
||||||
"pear/console_getopt": "1.4.*",
|
"pear/console_getopt": "1.4.*",
|
||||||
"TYPO3/class-alias-loader": "^1.0",
|
"TYPO3/class-alias-loader": "^1.0",
|
||||||
"ralouphie/getallheaders": "^2.0"
|
"ralouphie/getallheaders": "^2.0",
|
||||||
|
"smarty/smarty": "2.6.30"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
|
"fzaninotto/faker": "^1.7",
|
||||||
"guzzle/guzzle": "~3.1.1",
|
"guzzle/guzzle": "~3.1.1",
|
||||||
"phpunit/phpunit": "~5.7",
|
"phpunit/phpunit": "~5.7",
|
||||||
"lmc/steward": "^2.2",
|
"lmc/steward": "^2.2",
|
||||||
@@ -59,7 +62,8 @@
|
|||||||
"ProcessMaker\\": "workflow/engine/src"
|
"ProcessMaker\\": "workflow/engine/src"
|
||||||
},
|
},
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
"Maveriks\\": "framework/src/Maveriks/"
|
"Maveriks\\": "framework/src/Maveriks/",
|
||||||
|
"Tests\\": "tests/"
|
||||||
},
|
},
|
||||||
"classmap": [
|
"classmap": [
|
||||||
"gulliver/system/",
|
"gulliver/system/",
|
||||||
@@ -68,7 +72,6 @@
|
|||||||
"workflow/engine/classes/",
|
"workflow/engine/classes/",
|
||||||
"workflow/engine/controllers/",
|
"workflow/engine/controllers/",
|
||||||
"workflow/engine/includes/",
|
"workflow/engine/includes/",
|
||||||
"thirdparty/smarty/libs/Smarty.class.php",
|
|
||||||
"thirdparty/jsmin/jsmin.php",
|
"thirdparty/jsmin/jsmin.php",
|
||||||
"thirdparty/pear",
|
"thirdparty/pear",
|
||||||
"thirdparty/html2ps_pdf",
|
"thirdparty/html2ps_pdf",
|
||||||
@@ -79,7 +82,6 @@
|
|||||||
"files": [
|
"files": [
|
||||||
"gulliver/includes/inc.ajax.php",
|
"gulliver/includes/inc.ajax.php",
|
||||||
"gulliver/includes/smarty_plugins/function.pmos.php",
|
"gulliver/includes/smarty_plugins/function.pmos.php",
|
||||||
"thirdparty/pear/PEAR.php",
|
|
||||||
"thirdparty/pake/pakeFunction.php",
|
"thirdparty/pake/pakeFunction.php",
|
||||||
"thirdparty/HTMLPurifier/HTMLPurifier.auto.php",
|
"thirdparty/HTMLPurifier/HTMLPurifier.auto.php",
|
||||||
"workflow/engine/classes/class.pmFunctions.php",
|
"workflow/engine/classes/class.pmFunctions.php",
|
||||||
|
|||||||
1045
composer.lock
generated
1045
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -6,6 +6,7 @@ use Illuminate\View\ViewServiceProvider;
|
|||||||
|
|
||||||
return [
|
return [
|
||||||
'name' => env('APP_NAME', 'ProcessMaker'),
|
'name' => env('APP_NAME', 'ProcessMaker'),
|
||||||
|
'url' => env('APP_URL', 'http://localhost'),
|
||||||
'env' => env('APP_ENV', 'production'),
|
'env' => env('APP_ENV', 'production'),
|
||||||
'debug' => env('APP_DEBUG', false),
|
'debug' => env('APP_DEBUG', false),
|
||||||
'log' => env('APP_LOG', 'single'),
|
'log' => env('APP_LOG', 'single'),
|
||||||
@@ -16,6 +17,8 @@ return [
|
|||||||
FilesystemServiceProvider::class,
|
FilesystemServiceProvider::class,
|
||||||
CacheServiceProvider::class,
|
CacheServiceProvider::class,
|
||||||
ViewServiceProvider::class,
|
ViewServiceProvider::class,
|
||||||
|
\Illuminate\Database\DatabaseServiceProvider::class,
|
||||||
|
|
||||||
],
|
],
|
||||||
|
|
||||||
'aliases' => [
|
'aliases' => [
|
||||||
|
|||||||
75
config/database.php
Normal file
75
config/database.php
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
<?php
|
||||||
|
return [
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Default Database Connection Name
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here you may specify which of the database connections below you wish
|
||||||
|
| to use as your default connection for all database work. Of course
|
||||||
|
| you may use many connections at once using the Database library.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
'default' => env('DB_CONNECTION', 'workflow'),
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Database Connections
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here are each of the database connections setup for your application.
|
||||||
|
| Of course, examples of configuring each database platform that is
|
||||||
|
| supported by Laravel is shown below to make development simple.
|
||||||
|
|
|
||||||
|
|
|
||||||
|
| All database work in Laravel is done through the PHP PDO facilities
|
||||||
|
| so make sure you have the driver for your particular database of
|
||||||
|
| choice installed on your machine before you begin development.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
'connections' => [
|
||||||
|
'workflow' => [
|
||||||
|
'driver' => 'mysql',
|
||||||
|
'host' => env('DB_HOST', '127.0.0.1'),
|
||||||
|
'port' => env('DB_PORT', '3306'),
|
||||||
|
'database' => env('DB_DATABASE', 'workflow'),
|
||||||
|
'username' => env('DB_USERNAME', 'workflow'),
|
||||||
|
'password' => env('DB_PASSWORD', ''),
|
||||||
|
'unix_socket' => env('DB_SOCKET', ''),
|
||||||
|
'charset' => 'utf8mb4',
|
||||||
|
'collation' => 'utf8mb4_unicode_ci',
|
||||||
|
'prefix' => '',
|
||||||
|
'strict' => true,
|
||||||
|
'engine' => null,
|
||||||
|
]
|
||||||
|
],
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Migration Repository Table
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This table keeps track of all the migrations that have already run for
|
||||||
|
| your application. Using this information, we can determine which of
|
||||||
|
| the migrations on disk haven't actually been run in the database.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
'migrations' => 'migrations',
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Redis Databases
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Redis is an open source, fast, and advanced key-value store that also
|
||||||
|
| provides a richer set of commands than a typical key-value systems
|
||||||
|
| such as APC or Memcached. Laravel makes it easy to dig right in.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
'redis' => [
|
||||||
|
'client' => 'predis',
|
||||||
|
'default' => [
|
||||||
|
'host' => env('REDIS_HOST', '127.0.0.1'),
|
||||||
|
'password' => env('REDIS_PASSWORD', null),
|
||||||
|
'port' => env('REDIS_PORT', 6379),
|
||||||
|
'database' => 0,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
||||||
31
database/factories/DbSourceFactory.php
Normal file
31
database/factories/DbSourceFactory.php
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Model factory for a process
|
||||||
|
*/
|
||||||
|
use Faker\Generator as Faker;
|
||||||
|
|
||||||
|
$factory->define(\ProcessMaker\Model\DbSource::class, function(Faker $faker) {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @todo Determine if we need more base columns populated
|
||||||
|
*/
|
||||||
|
$dbName = $faker->word;
|
||||||
|
return [
|
||||||
|
'DBS_UID' => G::generateUniqueID(),
|
||||||
|
'PRO_UID' => function() {
|
||||||
|
return factory(\ProcessMaker\Model\Process::class)->create()->PRO_UID;
|
||||||
|
},
|
||||||
|
'DBS_TYPE' => 'mysql',
|
||||||
|
'DBS_SERVER' => $faker->localIpv4,
|
||||||
|
'DBS_DATABASE_NAME' => $faker->word,
|
||||||
|
'DBS_USERNAME' => $faker->userName,
|
||||||
|
/**
|
||||||
|
* @todo WHY figure out there's a magic value to the encryption here
|
||||||
|
*/
|
||||||
|
'DBS_PASSWORD' => \G::encrypt( $faker->password, $dbName) . "_2NnV3ujj3w",
|
||||||
|
'DBS_PORT' => $faker->numberBetween(1000, 9000),
|
||||||
|
'DBS_ENCODE' => 'utf8', // @todo Perhaps grab this from our definitions in DbConnections
|
||||||
|
'DBS_CONNECTION_TYPE' => 'NORMAL', // @todo Determine what this value means
|
||||||
|
'DBS_TNS' => null // @todo Determine what this value means
|
||||||
|
];
|
||||||
|
});
|
||||||
17
database/factories/ProcessFactory.php
Normal file
17
database/factories/ProcessFactory.php
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Model factory for a process
|
||||||
|
*/
|
||||||
|
use Faker\Generator as Faker;
|
||||||
|
|
||||||
|
$factory->define(\ProcessMaker\Model\Process::class, function(Faker $faker) {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @todo Determine if we need more base columns populated
|
||||||
|
*/
|
||||||
|
return [
|
||||||
|
'PRO_UID' => G::generateUniqueID(),
|
||||||
|
'PRO_TITLE' => $faker->sentence(3),
|
||||||
|
'PRO_DESCRIPTION' => $faker->paragraph(3)
|
||||||
|
];
|
||||||
|
});
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -10,99 +10,97 @@ function lookup($target)
|
|||||||
global $ntarget;
|
global $ntarget;
|
||||||
$msg = $target . ' => ';
|
$msg = $target . ' => ';
|
||||||
//if( eregi('[a-zA-Z]', $target) )
|
//if( eregi('[a-zA-Z]', $target) )
|
||||||
if( preg_match('[a-zA-Z]', $target)) //Made compatible to PHP 5.3
|
if (preg_match('[a-zA-Z]', $target)) { //Made compatible to PHP 5.3
|
||||||
$ntarget = gethostbyname($target);
|
$ntarget = gethostbyname($target);
|
||||||
else
|
} else {
|
||||||
$ntarget = gethostbyaddr($target);
|
$ntarget = gethostbyaddr($target);
|
||||||
|
}
|
||||||
$msg .= $ntarget;
|
$msg .= $ntarget;
|
||||||
return($msg);
|
return($msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDbServicesAvailables()
|
function getDbServicesAvailables()
|
||||||
{
|
{
|
||||||
$servicesAvailables = Array();
|
$servicesAvailables = array();
|
||||||
|
|
||||||
$dbServices = Array(
|
$dbServices = array(
|
||||||
'mysql' => Array(
|
'mysql' => array(
|
||||||
'id' => 'mysql',
|
'id' => 'mysql',
|
||||||
'command' => 'mysql_connect',
|
'command' => 'mysqli_connect',
|
||||||
'name' => 'MySql'
|
'name' => 'MySql'
|
||||||
),
|
),
|
||||||
'pgsql' => Array(
|
'pgsql' => array(
|
||||||
'id' => 'pgsql',
|
'id' => 'pgsql',
|
||||||
'command' => 'pg_connect',
|
'command' => 'pg_connect',
|
||||||
'name' => 'PostgreSQL'
|
'name' => 'PostgreSQL'
|
||||||
),
|
),
|
||||||
'mssql' => Array(
|
'mssql' => array(
|
||||||
'id' => 'mssql',
|
'id' => 'mssql',
|
||||||
'command' => 'mssql_connect',
|
'command' => 'mssql_connect',
|
||||||
'name' => 'Microsoft SQL Server'),
|
'name' => 'Microsoft SQL Server'),
|
||||||
'oracle'=> Array(
|
'oracle'=> array(
|
||||||
'id' => 'oracle',
|
'id' => 'oracle',
|
||||||
'command' => 'oci_connect',
|
'command' => 'oci_connect',
|
||||||
'name' => 'Oracle'
|
'name' => 'Oracle'
|
||||||
),
|
),
|
||||||
'informix'=> Array(
|
'informix'=> array(
|
||||||
'id' => 'informix',
|
'id' => 'informix',
|
||||||
'command' => 'ifx_connect',
|
'command' => 'ifx_connect',
|
||||||
'name' => 'Informix'
|
'name' => 'Informix'
|
||||||
),
|
),
|
||||||
'sqlite' => Array(
|
'sqlite' => array(
|
||||||
'id' => 'sqlite',
|
'id' => 'sqlite',
|
||||||
'command' => 'sqlite_open',
|
'command' => 'sqlite_open',
|
||||||
'name' => 'SQLite'
|
'name' => 'SQLite'
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach($dbServices as $service) {
|
foreach ($dbServices as $service) {
|
||||||
if(@function_exists($service['command'])){
|
if (@function_exists($service['command'])) {
|
||||||
$servicesAvailables[] = $service;
|
$servicesAvailables[] = $service;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $servicesAvailables;
|
return $servicesAvailables;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDbServerVersion($driver) {
|
function getDbServerVersion($driver)
|
||||||
try{
|
|
||||||
switch($driver)
|
|
||||||
{
|
{
|
||||||
|
try {
|
||||||
|
switch ($driver) {
|
||||||
case 'mysql':
|
case 'mysql':
|
||||||
if($link = @mysql_connect( DB_HOST, DB_USER, DB_PASS)){
|
if ($link = mysqli_connect(DB_HOST, DB_USER, DB_PASS)) {
|
||||||
$v = @mysql_get_server_info();
|
$v = mysqli_get_server_info($link);
|
||||||
} else {
|
} else {
|
||||||
throw new Exception(@mysql_error($link));
|
throw new Exception(mysqli_error($link));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return (isset($v))?$v:'none';
|
return (isset($v))?$v:'none';
|
||||||
} catch (Exception $e){
|
} catch (Exception $e) {
|
||||||
return ($e->getMessage());
|
return ($e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file_exists(PATH_METHODS . 'login/version-{projectName}.php'))
|
if (file_exists(PATH_METHODS . 'login/version-{projectName}.php')) {
|
||||||
{
|
|
||||||
include('version-{projectName}.php');
|
include('version-{projectName}.php');
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
define('PRG_VERSION', 'Development Version');
|
define('PRG_VERSION', 'Development Version');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getenv('HTTP_CLIENT_IP')) {
|
if (getenv('HTTP_CLIENT_IP')) {
|
||||||
$ip = getenv('HTTP_CLIENT_IP');
|
$ip = getenv('HTTP_CLIENT_IP');
|
||||||
}
|
} elseif (getenv('HTTP_X_FORWARDED_FOR')) {
|
||||||
elseif(getenv('HTTP_X_FORWARDED_FOR')) {
|
|
||||||
$ip = getenv('HTTP_X_FORWARDED_FOR');
|
$ip = getenv('HTTP_X_FORWARDED_FOR');
|
||||||
} else {
|
} else {
|
||||||
$ip = getenv('REMOTE_ADDR');
|
$ip = getenv('REMOTE_ADDR');
|
||||||
}
|
}
|
||||||
|
|
||||||
$redhat = '';
|
$redhat = '';
|
||||||
if ( file_exists ( '/etc/redhat-release' ) ) {
|
if (file_exists('/etc/redhat-release')) {
|
||||||
$fnewsize = filesize( '/etc/redhat-release' );
|
$fnewsize = filesize('/etc/redhat-release');
|
||||||
$fp = fopen( '/etc/redhat-release' , 'r' );
|
$fp = fopen('/etc/redhat-release', 'r');
|
||||||
$redhat = fread( $fp, $fnewsize );
|
$redhat = fread($fp, $fnewsize);
|
||||||
fclose( $fp );
|
fclose($fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
$redhat .= " (" . PHP_OS . ")";
|
$redhat .= " (" . PHP_OS . ")";
|
||||||
@@ -111,8 +109,10 @@ function lookup($target)
|
|||||||
//$dbNetView->loginDbServer(DB_USER, DB_PASS);
|
//$dbNetView->loginDbServer(DB_USER, DB_PASS);
|
||||||
|
|
||||||
$availdb = '';
|
$availdb = '';
|
||||||
foreach ( getDbServicesAvailables() as $key => $val ) {
|
foreach (getDbServicesAvailables() as $key => $val) {
|
||||||
if ( $availdb != '' ) $availdb .= ', ';
|
if ($availdb != '') {
|
||||||
|
$availdb .= ', ';
|
||||||
|
}
|
||||||
$availdb .= $val['name'];
|
$availdb .= $val['name'];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,7 +122,7 @@ function lookup($target)
|
|||||||
$Fields['DATABASE_NAME'] = DB_NAME;
|
$Fields['DATABASE_NAME'] = DB_NAME;
|
||||||
$Fields['PHP'] = phpversion();
|
$Fields['PHP'] = phpversion();
|
||||||
$Fields['FLUID'] = PRG_VERSION;
|
$Fields['FLUID'] = PRG_VERSION;
|
||||||
$Fields['IP'] = lookup ($ip);
|
$Fields['IP'] = lookup($ip);
|
||||||
$Fields['ENVIRONMENT'] = SYS_SYS;
|
$Fields['ENVIRONMENT'] = SYS_SYS;
|
||||||
$Fields['SERVER_SOFTWARE'] = getenv('SERVER_SOFTWARE');
|
$Fields['SERVER_SOFTWARE'] = getenv('SERVER_SOFTWARE');
|
||||||
$Fields['SERVER_NAME'] = getenv('SERVER_NAME');
|
$Fields['SERVER_NAME'] = getenv('SERVER_NAME');
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
$smarty->display('blank.html');
|
$smarty->display('blank.html');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$oHeadPublisher =& headPublisher::getSingleton();
|
$oHeadPublisher = headPublisher::getSingleton();
|
||||||
if (isset($oHeadPublisher)) $header = $oHeadPublisher->printHeader();
|
if (isset($oHeadPublisher)) $header = $oHeadPublisher->printHeader();
|
||||||
$smarty->assign('username', (isset($_SESSION['USR_USERNAME']) ? '(' . $_SESSION['USR_USERNAME'] . ' ' . G::LoadTranslation('ID_IN') . ' ' . SYS_SYS . ')' : '') );
|
$smarty->assign('username', (isset($_SESSION['USR_USERNAME']) ? '(' . $_SESSION['USR_USERNAME'] . ' ' . G::LoadTranslation('ID_IN') . ' ' . SYS_SYS . ')' : '') );
|
||||||
$smarty->assign('header', $header );
|
$smarty->assign('header', $header );
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
/* Render page */
|
/* Render page */
|
||||||
$oHeadPublisher = &headPublisher::getSingleton();
|
$oHeadPublisher = headPublisher::getSingleton();
|
||||||
|
|
||||||
$G_MAIN_MENU = "processmaker";
|
$G_MAIN_MENU = "processmaker";
|
||||||
$G_ID_MENU_SELECTED = "{menuId}_MNU_01";
|
$G_ID_MENU_SELECTED = "{menuId}_MNU_01";
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
try {
|
try {
|
||||||
$oHeadPublisher = &headPublisher::getSingleton();
|
$oHeadPublisher = headPublisher::getSingleton();
|
||||||
|
|
||||||
$oHeadPublisher->addContent("{className}/{className}Application2"); //Adding a html file .html.
|
$oHeadPublisher->addContent("{className}/{className}Application2"); //Adding a html file .html.
|
||||||
$oHeadPublisher->addExtJsScript("{className}/{className}Application2", false); //Adding a javascript file .js
|
$oHeadPublisher->addExtJsScript("{className}/{className}Application2", false); //Adding a javascript file .js
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
try {
|
try {
|
||||||
$oHeadPublisher = &headPublisher::getSingleton();
|
$oHeadPublisher = headPublisher::getSingleton();
|
||||||
|
|
||||||
$oHeadPublisher->addContent("{className}/{className}Application3"); //Adding a html file .html.
|
$oHeadPublisher->addContent("{className}/{className}Application3"); //Adding a html file .html.
|
||||||
$oHeadPublisher->addExtJsScript("{className}/{className}Application3", false); //Adding a javascript file .js
|
$oHeadPublisher->addExtJsScript("{className}/{className}Application3", false); //Adding a javascript file .js
|
||||||
|
|||||||
@@ -111,5 +111,5 @@ class {className}Plugin extends PMPlugin
|
|||||||
<!-- END BLOCK : dashboard -->
|
<!-- END BLOCK : dashboard -->
|
||||||
}
|
}
|
||||||
|
|
||||||
$oPluginRegistry = &PMPluginRegistry::getSingleton();
|
$oPluginRegistry = PMPluginRegistry::getSingleton();
|
||||||
$oPluginRegistry->registerPlugin("{className}", __FILE__);
|
$oPluginRegistry->registerPlugin("{className}", __FILE__);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
try {
|
try {
|
||||||
global $Fields;
|
global $Fields;
|
||||||
$oHeadPublisher = &headPublisher::getSingleton();
|
$oHeadPublisher = headPublisher::getSingleton();
|
||||||
|
|
||||||
//SYS_SYS //Workspace name
|
//SYS_SYS //Workspace name
|
||||||
//PROCESS //Process UID
|
//PROCESS //Process UID
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ $docuroot = explode ( PATH_SEP , $_SERVER['DOCUMENT_ROOT'] );
|
|||||||
|
|
||||||
//***************** Call Gulliver Classes **************************
|
//***************** Call Gulliver Classes **************************
|
||||||
|
|
||||||
$oHeadPublisher =& headPublisher::getSingleton();
|
$oHeadPublisher = headPublisher::getSingleton();
|
||||||
|
|
||||||
//***************** database and workspace definition ************************
|
//***************** database and workspace definition ************************
|
||||||
//if SYS_TEMP exists, the URL has a workspace, now we need to verify if exists their db.php file
|
//if SYS_TEMP exists, the URL has a workspace, now we need to verify if exists their db.php file
|
||||||
@@ -203,7 +203,7 @@ $docuroot = explode ( PATH_SEP , $_SERVER['DOCUMENT_ROOT'] );
|
|||||||
// //the singleton has a list of enabled plugins
|
// //the singleton has a list of enabled plugins
|
||||||
|
|
||||||
// $sSerializedFile = PATH_DATA_SITE . 'plugin.singleton';
|
// $sSerializedFile = PATH_DATA_SITE . 'plugin.singleton';
|
||||||
// $oPluginRegistry =& PMPluginRegistry::getSingleton();
|
// $oPluginRegistry = PMPluginRegistry::getSingleton();
|
||||||
// if ( file_exists ($sSerializedFile) )
|
// if ( file_exists ($sSerializedFile) )
|
||||||
// $oPluginRegistry->unSerializeInstance( file_get_contents ( $sSerializedFile ) );
|
// $oPluginRegistry->unSerializeInstance( file_get_contents ( $sSerializedFile ) );
|
||||||
//
|
//
|
||||||
@@ -297,7 +297,7 @@ $docuroot = explode ( PATH_SEP , $_SERVER['DOCUMENT_ROOT'] );
|
|||||||
|
|
||||||
// ***************** enable rbac **************************
|
// ***************** enable rbac **************************
|
||||||
|
|
||||||
$RBAC =& RBAC::getSingleton();
|
$RBAC = RBAC::getSingleton();
|
||||||
$RBAC->sSystem = '{rbacProjectName}';
|
$RBAC->sSystem = '{rbacProjectName}';
|
||||||
|
|
||||||
// ***************** Headers **************************
|
// ***************** Headers **************************
|
||||||
|
|||||||
@@ -26,110 +26,112 @@
|
|||||||
|
|
||||||
use ProcessMaker\Plugins\PluginRegistry;
|
use ProcessMaker\Plugins\PluginRegistry;
|
||||||
|
|
||||||
if (isset( $_SESSION['CURRENT_PAGE_INITILIZATION'] ))
|
if (isset($_SESSION['CURRENT_PAGE_INITILIZATION'])) {
|
||||||
eval( $_SESSION['CURRENT_PAGE_INITILIZATION'] );
|
eval($_SESSION['CURRENT_PAGE_INITILIZATION']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// $json=new Services_JSON();
|
// $json=new Services_JSON();
|
||||||
if (! defined( 'XMLFORM_AJAX_PATH' ))
|
if (!defined('XMLFORM_AJAX_PATH')) {
|
||||||
define( 'XMLFORM_AJAX_PATH', PATH_XMLFORM );
|
define('XMLFORM_AJAX_PATH', PATH_XMLFORM);
|
||||||
|
}
|
||||||
|
|
||||||
$_DBArray = array ();
|
$_DBArray = array();
|
||||||
if (isset( $_SESSION['_DBArray'] )) {
|
if (isset($_SESSION['_DBArray'])) {
|
||||||
$_DBArray = $_SESSION['_DBArray'];
|
$_DBArray = $_SESSION['_DBArray'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$xmlFile = G::getUIDName( urlDecode( $_POST['form'] ) );
|
$xmlFile = G::getUIDName(urlDecode($_POST['form']));
|
||||||
$sPath = XMLFORM_AJAX_PATH;
|
$sPath = XMLFORM_AJAX_PATH;
|
||||||
|
|
||||||
//if the xmlform file doesn't exist, then try with the plugins folders
|
//if the xmlform file doesn't exist, then try with the plugins folders
|
||||||
if (! is_file( XMLFORM_AJAX_PATH . $xmlFile )) {
|
if (!is_file(XMLFORM_AJAX_PATH . $xmlFile)) {
|
||||||
$aux = explode( PATH_SEP, $xmlFile );
|
$aux = explode(PATH_SEP, $xmlFile);
|
||||||
//check if G_PLUGIN_CLASS is defined, because publisher can be called without an environment
|
//check if G_PLUGIN_CLASS is defined, because publisher can be called without an environment
|
||||||
if (count( $aux ) == 2 && defined( 'G_PLUGIN_CLASS' )) {
|
if (count($aux) == 2 && defined('G_PLUGIN_CLASS')) {
|
||||||
$oPluginRegistry = PluginRegistry::loadSingleton();
|
$oPluginRegistry = PluginRegistry::loadSingleton();
|
||||||
if ($oPluginRegistry->isRegisteredFolder( $aux[0] )) {
|
if ($oPluginRegistry->isRegisteredFolder($aux[0])) {
|
||||||
$sPath = PATH_PLUGINS;
|
$sPath = PATH_PLUGINS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$G_FORM = new Form( $xmlFile, $sPath );
|
$G_FORM = new Form($xmlFile, $sPath);
|
||||||
$G_FORM->id = urlDecode( $_POST['form'] );
|
$G_FORM->id = urlDecode($_POST['form']);
|
||||||
$G_FORM->values = isset( $_SESSION[$G_FORM->id] ) ? $_SESSION[$G_FORM->id] : array ();
|
$G_FORM->values = isset($_SESSION[$G_FORM->id]) ? $_SESSION[$G_FORM->id] : array();
|
||||||
|
|
||||||
$newValues = (Bootstrap::json_decode( urlDecode( stripslashes( $_POST['fields'] ) ) ));
|
$newValues = (Bootstrap::json_decode(urlDecode(stripslashes($_POST['fields']))));
|
||||||
|
|
||||||
if (isset( $_POST['grid'] )) {
|
if (isset($_POST['grid'])) {
|
||||||
$_POST['row'] = (int) $_POST['row'];
|
$_POST['row'] = (int)$_POST['row'];
|
||||||
$aAux = array ();
|
$aAux = array();
|
||||||
|
|
||||||
foreach ($newValues as $sKey => $newValue) {
|
foreach ($newValues as $sKey => $newValue) {
|
||||||
$newValue = (array) $newValue;
|
$newValue = (array)$newValue;
|
||||||
$aKeys = array_keys( $newValue );
|
$aKeys = array_keys($newValue);
|
||||||
if (count($aKeys)>0) {
|
if (count($aKeys) > 0) {
|
||||||
$aValues = array ();
|
$aValues = array();
|
||||||
for ($i = 1; $i <= ($_POST['row'] - 1); $i ++) {
|
for ($i = 1; $i <= ($_POST['row'] - 1); $i++) {
|
||||||
$aValues[$i] = array ($aKeys[0] => '' );
|
$aValues[$i] = array($aKeys[0] => '');
|
||||||
}
|
}
|
||||||
$aValues[$_POST['row']] = array ($aKeys[0] => $newValue[$aKeys[0]] );
|
$aValues[$_POST['row']] = array($aKeys[0] => $newValue[$aKeys[0]]);
|
||||||
$newValues[$sKey]->$_POST['grid'] = $aValues;
|
$newValues[$sKey]->{$_POST['grid']} = $aValues;
|
||||||
unset( $newValues[$sKey]->$aKeys[0] );
|
unset($newValues[$sKey]->{$aKeys[0]});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Next Lines re-build newValues array to send multiple dependent fields merged by row into a grid.
|
//Next Lines re-build newValues array to send multiple dependent fields merged by row into a grid.
|
||||||
if (sizeof( $newValues ) > 1 && isset( $_POST['grid'] )) {
|
if (count($newValues) > 1 && isset($_POST['grid'])) {
|
||||||
$fieldBase = array ();
|
$fieldBase = array();
|
||||||
foreach ($newValues as $key => $values) {
|
foreach ($newValues as $key => $values) {
|
||||||
for ($r2 = 1; $r2 <= $_POST['row']; $r2 ++) {
|
for ($r2 = 1; $r2 <= $_POST['row']; $r2++) {
|
||||||
foreach ($values as $class => $value) {
|
foreach ($values as $class => $value) {
|
||||||
if ($class == $_POST['grid']) {
|
if ($class == $_POST['grid']) {
|
||||||
$value = (array) $value;
|
$value = (array)$value;
|
||||||
$arrayK = $value[$r2];
|
$arrayK = $value[$r2];
|
||||||
foreach ($arrayK as $key2 => $val) {
|
foreach ($arrayK as $key2 => $val) {
|
||||||
$fieldBase[$r2][$key2] = is_array( $val ) ? $val[$key2] : $val;
|
$fieldBase[$r2][$key2] = is_array($val) ? $val[$key2] : $val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$newValues[0]->$_POST['grid'] = $fieldBase;
|
$newValues[0]->{$_POST['grid']} = $fieldBase;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Resolve dependencies
|
//Resolve dependencies
|
||||||
//Returns an array ($dependentFields) with the names of the fields
|
//Returns an array ($dependentFields) with the names of the fields
|
||||||
//that depends of fields passed through AJAX ($_GET/$_POST)
|
//that depends of fields passed through AJAX ($_GET/$_POST)
|
||||||
//Returns all dependencies of all fields, this in grids
|
//Returns all dependencies of all fields, this in grids
|
||||||
$dependentFields = array ();
|
$dependentFields = array();
|
||||||
$aux = array ();
|
$aux = array();
|
||||||
for ($r = 0; $r < sizeof( $newValues ); $r ++) {
|
for ($r = 0; $r < count($newValues); $r++) {
|
||||||
$newValues[$r] = (array) $newValues[$r];
|
$newValues[$r] = (array)$newValues[$r];
|
||||||
$G_FORM->setValues( $newValues[$r] );
|
$G_FORM->setValues($newValues[$r]);
|
||||||
//Search dependent fields
|
//Search dependent fields
|
||||||
foreach ($newValues[$r] as $k => $v) {
|
foreach ($newValues[$r] as $k => $v) {
|
||||||
if (! is_array( $v )) {
|
if (!is_array($v)) {
|
||||||
$myDependentFields = subDependencies( $k, $G_FORM, $aux );
|
$myDependentFields = subDependencies($k, $G_FORM, $aux);
|
||||||
$_SESSION[$G_FORM->id][$k] = $v;
|
$_SESSION[$G_FORM->id][$k] = $v;
|
||||||
} else {
|
} else {
|
||||||
foreach ($v[$_POST['row']] as $k1 => $v1) {
|
foreach ($v[$_POST['row']] as $k1 => $v1) {
|
||||||
$myDependentFields = subDependencies( $k1, $G_FORM, $aux, $_POST['grid'] );
|
$myDependentFields = subDependencies($k1, $G_FORM, $aux, $_POST['grid']);
|
||||||
$_SESSION[$G_FORM->id][$_POST['grid']][$_POST['row']][$k1] = $v1;
|
$_SESSION[$G_FORM->id][$_POST['grid']][$_POST['row']][$k1] = $v1;
|
||||||
$G_FORM->values[$_POST['grid']][$_POST['row']][$k1] = $v1;
|
$G_FORM->values[$_POST['grid']][$_POST['row']][$k1] = $v1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$dependentFields = array_merge( $dependentFields, $myDependentFields );
|
$dependentFields = array_merge($dependentFields, $myDependentFields);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$dependentFields = array_unique( $dependentFields );
|
$dependentFields = array_unique($dependentFields);
|
||||||
|
|
||||||
//Update when is depenfield set empty
|
//Update when is depenfield set empty
|
||||||
$newForm = $G_FORM->values;
|
$newForm = $G_FORM->values;
|
||||||
foreach($newForm as $fKey => $values){
|
foreach ($newForm as $fKey => $values) {
|
||||||
foreach($dependentFields as $att){
|
foreach ($dependentFields as $att) {
|
||||||
if($att == $fKey){
|
if ($att == $fKey) {
|
||||||
$newForm[$fKey] = '';
|
$newForm[$fKey] = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -148,7 +150,7 @@ if (isset($_POST["grid"])) {
|
|||||||
$arrayAux = (array)($fieldData);
|
$arrayAux = (array)($fieldData);
|
||||||
|
|
||||||
foreach ($arrayAux as $index => $value) {
|
foreach ($arrayAux as $index => $value) {
|
||||||
$ereg = $ereg . (($ereg != null)? "|" : null) . $index; //Concatenate field
|
$ereg = $ereg . (($ereg != null) ? "|" : null) . $index; //Concatenate field
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -200,10 +202,10 @@ if (isset($_POST["grid"]) && isset($_POST["gridField"])) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Parse and update the new content
|
//Parse and update the new content
|
||||||
$newContent = $G_FORM->getFields(PATH_CORE . "templates" . PATH_SEP . "xmlform.html", (isset($_POST["row"])? $_POST["row"] : -1));
|
$newContent = $G_FORM->getFields(PATH_CORE . "templates" . PATH_SEP . "xmlform.html", (isset($_POST["row"]) ? $_POST["row"] : -1));
|
||||||
|
|
||||||
//Returns the dependentFields's content
|
//Returns the dependentFields's content
|
||||||
$sendContent = array ();
|
$sendContent = array();
|
||||||
$r = 0;
|
$r = 0;
|
||||||
|
|
||||||
//Set data
|
//Set data
|
||||||
@@ -213,19 +215,19 @@ foreach ($dependentFields as $d) {
|
|||||||
$sendContent[$r]->name = $d;
|
$sendContent[$r]->name = $d;
|
||||||
$sendContent[$r]->content = new stdclass();
|
$sendContent[$r]->content = new stdclass();
|
||||||
|
|
||||||
if (! isset( $_POST['grid'] )) {
|
if (!isset($_POST['grid'])) {
|
||||||
if (isset( $G_FORM->fields[$d] )) {
|
if (isset($G_FORM->fields[$d])) {
|
||||||
foreach ($G_FORM->fields[$d] as $attribute => $value) {
|
foreach ($G_FORM->fields[$d] as $attribute => $value) {
|
||||||
switch ($attribute) {
|
switch ($attribute) {
|
||||||
case 'type':
|
case 'type':
|
||||||
$sendContent[$r]->content->{$attribute} = $value;
|
$sendContent[$r]->content->{$attribute} = $value;
|
||||||
break;
|
break;
|
||||||
case 'options':
|
case 'options':
|
||||||
$sendContent[$r]->content->{$attribute} = toJSArray( $value, $sendContent[$r]->content->type );
|
$sendContent[$r]->content->{$attribute} = toJSArray($value, $sendContent[$r]->content->type);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$sendContent[$r]->value = isset( $G_FORM->values[$d] ) ? $G_FORM->values[$d] : '';
|
$sendContent[$r]->value = isset($G_FORM->values[$d]) ? $G_FORM->values[$d] : '';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
foreach ($G_FORM->fields[$_POST['grid']]->fields[$d] as $attribute => $value) {
|
foreach ($G_FORM->fields[$_POST['grid']]->fields[$d] as $attribute => $value) {
|
||||||
@@ -237,12 +239,12 @@ foreach ($dependentFields as $d) {
|
|||||||
if ($sendContent[$r]->content->type != "text" && $sendContent[$r]->content->type != "textarea") {
|
if ($sendContent[$r]->content->type != "text" && $sendContent[$r]->content->type != "textarea") {
|
||||||
$sendContent[$r]->content->{$attribute} = toJSArray($value);
|
$sendContent[$r]->content->{$attribute} = toJSArray($value);
|
||||||
} else {
|
} else {
|
||||||
$sendContent[$r]->content->{$attribute} = toJSArray((isset($value[$_POST["row"]])? array($value[$_POST["row"]]) : array()));
|
$sendContent[$r]->content->{$attribute} = toJSArray((isset($value[$_POST["row"]]) ? array($value[$_POST["row"]]) : array()));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$sendContent[$r]->value = isset( $G_FORM->values[$_POST['grid']][$_POST['row']][$d] ) ? $G_FORM->values[$_POST['grid']][$_POST['row']][$d] : '';
|
$sendContent[$r]->value = isset($G_FORM->values[$_POST['grid']][$_POST['row']][$d]) ? $G_FORM->values[$_POST['grid']][$_POST['row']][$d] : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$r = $r + 1;
|
$r = $r + 1;
|
||||||
@@ -250,9 +252,9 @@ foreach ($dependentFields as $d) {
|
|||||||
|
|
||||||
echo Bootstrap::json_encode($sendContent);
|
echo Bootstrap::json_encode($sendContent);
|
||||||
|
|
||||||
function toJSArray ($array, $type = '')
|
function toJSArray($array, $type = '')
|
||||||
{
|
{
|
||||||
$result = array ();
|
$result = array();
|
||||||
foreach ($array as $k => $v) {
|
foreach ($array as $k => $v) {
|
||||||
$o = new stdclass();
|
$o = new stdclass();
|
||||||
$o->key = $k;
|
$o->key = $k;
|
||||||
@@ -264,55 +266,62 @@ function toJSArray ($array, $type = '')
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
function subDependencies ($k, &$G_FORM, &$aux, $grid = '')
|
function subDependencies($k, &$G_FORM, &$aux, $grid = '')
|
||||||
{
|
{
|
||||||
if (array_search( $k, $aux ) !== FALSE)
|
if (array_search($k, $aux) !== false) {
|
||||||
return array ();
|
return array();
|
||||||
|
}
|
||||||
if ($grid == '') {
|
if ($grid == '') {
|
||||||
if (! array_key_exists( $k, $G_FORM->fields ))
|
if (!array_key_exists($k, $G_FORM->fields)) {
|
||||||
return array ();
|
return array();
|
||||||
if (! isset( $G_FORM->fields[$k]->dependentFields ))
|
}
|
||||||
return array ();
|
if (!isset($G_FORM->fields[$k]->dependentFields)) {
|
||||||
$aux[] = $k;
|
return array();
|
||||||
if (strpos( $G_FORM->fields[$k]->dependentFields, ',' ) !== false) {
|
}
|
||||||
$myDependentFields = explode( ',', $G_FORM->fields[$k]->dependentFields );
|
$aux[] = $k;
|
||||||
} else {
|
if (strpos($G_FORM->fields[$k]->dependentFields, ',') !== false) {
|
||||||
$myDependentFields = explode( '|', $G_FORM->fields[$k]->dependentFields );
|
$myDependentFields = explode(',', $G_FORM->fields[$k]->dependentFields);
|
||||||
|
} else {
|
||||||
|
$myDependentFields = explode('|', $G_FORM->fields[$k]->dependentFields);
|
||||||
|
}
|
||||||
|
for ($r = 0; $r < count($myDependentFields); $r++) {
|
||||||
|
if ($myDependentFields[$r] == "") {
|
||||||
|
unset($myDependentFields[$r]);
|
||||||
}
|
}
|
||||||
for ($r = 0; $r < sizeof( $myDependentFields ); $r ++) {
|
|
||||||
if ($myDependentFields[$r] == "")
|
|
||||||
unset( $myDependentFields[$r] );
|
|
||||||
}
|
}
|
||||||
$mD = $myDependentFields;
|
$mD = $myDependentFields;
|
||||||
foreach( $mD as $ki) {
|
foreach ($mD as $ki) {
|
||||||
$myDependentFields = array_merge( $myDependentFields , subDependencies( $ki , $G_FORM , $aux ) );
|
$myDependentFields = array_merge($myDependentFields, subDependencies($ki, $G_FORM, $aux));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (! isset($G_FORM->fields[$grid])) {
|
if (!isset($G_FORM->fields[$grid])) {
|
||||||
return array ();
|
return array();
|
||||||
|
}
|
||||||
|
if (!array_key_exists($k, $G_FORM->fields[$grid]->fields)) {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
if (!isset($G_FORM->fields[$grid]->fields[$k]->dependentFields)) {
|
||||||
|
return array();
|
||||||
}
|
}
|
||||||
if (! array_key_exists( $k, $G_FORM->fields[$grid]->fields ))
|
|
||||||
return array ();
|
|
||||||
if (! isset( $G_FORM->fields[$grid]->fields[$k]->dependentFields ))
|
|
||||||
return array ();
|
|
||||||
|
|
||||||
$aux[] = $k;
|
$aux[] = $k;
|
||||||
|
|
||||||
if (strpos( $G_FORM->fields[$grid]->fields[$k]->dependentFields, ',' ) !== false) {
|
if (strpos($G_FORM->fields[$grid]->fields[$k]->dependentFields, ',') !== false) {
|
||||||
$myDependentFields = explode( ',', $G_FORM->fields[$grid]->fields[$k]->dependentFields );
|
$myDependentFields = explode(',', $G_FORM->fields[$grid]->fields[$k]->dependentFields);
|
||||||
} else {
|
} else {
|
||||||
$myDependentFields = explode( '|', $G_FORM->fields[$grid]->fields[$k]->dependentFields );
|
$myDependentFields = explode('|', $G_FORM->fields[$grid]->fields[$k]->dependentFields);
|
||||||
}
|
}
|
||||||
|
|
||||||
for ($r = 0; $r < sizeof( $myDependentFields ); $r ++) {
|
for ($r = 0; $r < count($myDependentFields); $r++) {
|
||||||
if ($myDependentFields[$r] == "")
|
if ($myDependentFields[$r] == "") {
|
||||||
unset( $myDependentFields[$r] );
|
unset($myDependentFields[$r]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$mD = $myDependentFields;
|
$mD = $myDependentFields;
|
||||||
|
|
||||||
foreach( $mD as $ki) {
|
foreach ($mD as $ki) {
|
||||||
$myDependentFields = array_merge( $myDependentFields , subDependencies( $ki , $G_FORM , $aux, $grid) );
|
$myDependentFields = array_merge($myDependentFields, subDependencies($ki, $G_FORM, $aux, $grid));
|
||||||
}
|
}
|
||||||
|
|
||||||
//Set field and the dependent field of the grid
|
//Set field and the dependent field of the grid
|
||||||
@@ -323,4 +332,3 @@ function subDependencies ($k, &$G_FORM, &$aux, $grid = '')
|
|||||||
|
|
||||||
return $myDependentFields;
|
return $myDependentFields;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ if (isset($request)) {
|
|||||||
$_SESSION[$_POST["formID"]][$_POST["gridname"]] = (array)$_SESSION[$_POST["formID"]][$_POST["gridname"]];
|
$_SESSION[$_POST["formID"]][$_POST["gridname"]] = (array)$_SESSION[$_POST["formID"]][$_POST["gridname"]];
|
||||||
}
|
}
|
||||||
ksort($_SESSION[$_POST["formID"]][$_POST["gridname"]]);
|
ksort($_SESSION[$_POST["formID"]][$_POST["gridname"]]);
|
||||||
$oFields = array();
|
$oFields = [];
|
||||||
$initialKey = 1;
|
$initialKey = 1;
|
||||||
|
|
||||||
foreach ($_SESSION[$_POST["formID"]][$_POST["gridname"]] as $key => $value) {
|
foreach ($_SESSION[$_POST["formID"]][$_POST["gridname"]] as $key => $value) {
|
||||||
@@ -66,12 +66,12 @@ if (isset($request)) {
|
|||||||
|
|
||||||
|
|
||||||
$bdUid = 'workflow';
|
$bdUid = 'workflow';
|
||||||
if (isset($_GET['type']) && $_GET['type']==='form' && isset($myForm->fields[$_GET['variable']]->sql)) {
|
if (isset($_GET['type']) && $_GET['type'] === 'form' && isset($myForm->fields[$_GET['variable']]->sql)) {
|
||||||
$sqlQuery = $myForm->fields[$_GET['variable']]->sql;
|
$sqlQuery = $myForm->fields[$_GET['variable']]->sql;
|
||||||
if (isset($myForm->fields[$_GET['variable']]->sqlConnection) && !empty($myForm->fields[$_GET['variable']]->sqlConnection)) {
|
if (isset($myForm->fields[$_GET['variable']]->sqlConnection) && !empty($myForm->fields[$_GET['variable']]->sqlConnection)) {
|
||||||
$bdUid = $myForm->fields[$_GET['variable']]->sqlConnection;
|
$bdUid = $myForm->fields[$_GET['variable']]->sqlConnection;
|
||||||
}
|
}
|
||||||
} elseif (isset($_GET['type']) && $_GET['type']==='grid' && isset($myForm->fields[$_GET['grid']])) {
|
} elseif (isset($_GET['type']) && $_GET['type'] === 'grid' && isset($myForm->fields[$_GET['grid']])) {
|
||||||
foreach ($myForm->fields[$_GET['grid']] as $index => $value) {
|
foreach ($myForm->fields[$_GET['grid']] as $index => $value) {
|
||||||
if (is_array($value) && isset($value[$_GET['variable']])) {
|
if (is_array($value) && isset($value[$_GET['variable']])) {
|
||||||
$newObj = $value[$_GET['variable']];
|
$newObj = $value[$_GET['variable']];
|
||||||
@@ -89,7 +89,7 @@ if (isset($request)) {
|
|||||||
$aDependentFieldsKeys = explode("|", base64_decode(str_rot13($_GET['dependentFieldsKeys'])));
|
$aDependentFieldsKeys = explode("|", base64_decode(str_rot13($_GET['dependentFieldsKeys'])));
|
||||||
$aDependentFieldsValue = explode("|", $_GET['dependentFieldsValue']);
|
$aDependentFieldsValue = explode("|", $_GET['dependentFieldsValue']);
|
||||||
if ($aDependentFieldsKeys) {
|
if ($aDependentFieldsKeys) {
|
||||||
$aDependentFields = array();
|
$aDependentFields = [];
|
||||||
foreach ($aDependentFieldsKeys as $nKey => $sFieldVar) {
|
foreach ($aDependentFieldsKeys as $nKey => $sFieldVar) {
|
||||||
$sKeyDepFields = substr($sFieldVar, 2);
|
$sKeyDepFields = substr($sFieldVar, 2);
|
||||||
$aDependentFields[$sKeyDepFields] = $aDependentFieldsValue[$nKey];
|
$aDependentFields[$sKeyDepFields] = $aDependentFieldsValue[$nKey];
|
||||||
@@ -105,7 +105,7 @@ if (isset($request)) {
|
|||||||
// Verify parsed array
|
// Verify parsed array
|
||||||
$sqlQuery = queryModified($parser->parsed, $_GET['input'], $searchType);
|
$sqlQuery = queryModified($parser->parsed, $_GET['input'], $searchType);
|
||||||
|
|
||||||
$aRows = Array();
|
$aRows = [];
|
||||||
try {
|
try {
|
||||||
$con = Propel::getConnection($bdUid);
|
$con = Propel::getConnection($bdUid);
|
||||||
$con->begin();
|
$con->begin();
|
||||||
@@ -122,7 +122,7 @@ if (isset($request)) {
|
|||||||
$input = strtolower($_GET['input']);
|
$input = strtolower($_GET['input']);
|
||||||
$len = strlen($input);
|
$len = strlen($input);
|
||||||
$limit = isset($_GET['limit']) ? (int)$_GET['limit'] : 0;
|
$limit = isset($_GET['limit']) ? (int)$_GET['limit'] : 0;
|
||||||
$aResults = array();
|
$aResults = [];
|
||||||
$count = 0;
|
$count = 0;
|
||||||
$aRows = sortByChar($aRows, $input);
|
$aRows = sortByChar($aRows, $input);
|
||||||
|
|
||||||
@@ -213,7 +213,7 @@ if (isset($request)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// See above. Gross, but it works.
|
// See above. Gross, but it works.
|
||||||
$field = mysql_real_escape_string($_GET['fld']);
|
$field = mysqli_real_escape_string($con->getResource(), $_GET['fld']);
|
||||||
$field = str_replace("`", "", $field);
|
$field = str_replace("`", "", $field);
|
||||||
|
|
||||||
$query = "INSERT INTO $tableName ($primaryKeyField, $field) VALUES (?, ?)"; // '$gKey', '{$_GET['value']}')";
|
$query = "INSERT INTO $tableName ($primaryKeyField, $field) VALUES (?, ?)"; // '$gKey', '{$_GET['value']}')";
|
||||||
@@ -235,8 +235,8 @@ if (isset($request)) {
|
|||||||
|
|
||||||
function sortByChar($aRows, $charSel)
|
function sortByChar($aRows, $charSel)
|
||||||
{
|
{
|
||||||
$aIniChar = array();
|
$aIniChar = [];
|
||||||
$aRest = array();
|
$aRest = [];
|
||||||
for ($i = 0; $i < count($aRows); $i++) {
|
for ($i = 0; $i < count($aRows); $i++) {
|
||||||
$aRow = $aRows[$i];
|
$aRow = $aRows[$i];
|
||||||
$nCols = sizeof($aRow);
|
$nCols = sizeof($aRow);
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ class Bootstrap
|
|||||||
|
|
||||||
$filter = new InputFilter();
|
$filter = new InputFilter();
|
||||||
|
|
||||||
$smarty = new Smarty ();
|
$smarty = new Smarty();
|
||||||
$smarty->compile_dir = Bootstrap::sys_get_temp_dir();
|
$smarty->compile_dir = Bootstrap::sys_get_temp_dir();
|
||||||
$smarty->cache_dir = Bootstrap::sys_get_temp_dir();
|
$smarty->cache_dir = Bootstrap::sys_get_temp_dir();
|
||||||
$configDir = PATH_THIRDPARTY . 'smarty/configs';
|
$configDir = PATH_THIRDPARTY . 'smarty/configs';
|
||||||
@@ -320,7 +320,7 @@ class Bootstrap
|
|||||||
if ($download) {
|
if ($download) {
|
||||||
Bootstrap::sendHeaders($fileNameIni, "text/plain", $download, $downloadFileName);
|
Bootstrap::sendHeaders($fileNameIni, "text/plain", $download, $downloadFileName);
|
||||||
} else {
|
} else {
|
||||||
require_once ($filename);
|
require_once($filename);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -334,7 +334,7 @@ class Bootstrap
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (strpos($file, 'gulliver') !== false) {
|
if (strpos($file, 'gulliver') !== false) {
|
||||||
list ($path, $filename) = explode('gulliver', $file);
|
list($path, $filename) = explode('gulliver', $file);
|
||||||
}
|
}
|
||||||
|
|
||||||
$_SESSION['phpFileNotFound'] = $file;
|
$_SESSION['phpFileNotFound'] = $file;
|
||||||
@@ -358,7 +358,7 @@ class Bootstrap
|
|||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
static public function parseURI($uri, array $arrayFriendlyUri = null)
|
public static function parseURI($uri, array $arrayFriendlyUri = null)
|
||||||
{
|
{
|
||||||
// *** process the $_POST with magic_quotes enabled
|
// *** process the $_POST with magic_quotes enabled
|
||||||
// The magic_quotes_gpc feature has been DEPRECATED as of PHP 5.3.0.
|
// The magic_quotes_gpc feature has been DEPRECATED as of PHP 5.3.0.
|
||||||
@@ -475,21 +475,21 @@ class Bootstrap
|
|||||||
*/
|
*/
|
||||||
public static function LoadTranslationObject($lang = SYS_LANG)
|
public static function LoadTranslationObject($lang = SYS_LANG)
|
||||||
{
|
{
|
||||||
$defaultTranslations = Array();
|
$defaultTranslations = array();
|
||||||
$foreignTranslations = Array();
|
$foreignTranslations = array();
|
||||||
|
|
||||||
// if the default translations table doesn't exist we can't proceed
|
// if the default translations table doesn't exist we can't proceed
|
||||||
if (!is_file(PATH_LANGUAGECONT . 'translation.en')) {
|
if (!is_file(PATH_LANGUAGECONT . 'translation.en')) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
// load the translations table
|
// load the translations table
|
||||||
require_once (PATH_LANGUAGECONT . 'translation.en');
|
require_once(PATH_LANGUAGECONT . 'translation.en');
|
||||||
$defaultTranslations = $translation;
|
$defaultTranslations = $translation;
|
||||||
|
|
||||||
// if some foreign language was requested and its translation file
|
// if some foreign language was requested and its translation file
|
||||||
// exists
|
// exists
|
||||||
if ($lang != 'en' && file_exists(PATH_LANGUAGECONT . 'translation.' . $lang)) {
|
if ($lang != 'en' && file_exists(PATH_LANGUAGECONT . 'translation.' . $lang)) {
|
||||||
require_once (PATH_LANGUAGECONT . 'translation.' . $lang); // load the foreign translations table
|
require_once(PATH_LANGUAGECONT . 'translation.' . $lang); // load the foreign translations table
|
||||||
$foreignTranslations = $translation;
|
$foreignTranslations = $translation;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -514,9 +514,9 @@ class Bootstrap
|
|||||||
* @param array list plugins active
|
* @param array list plugins active
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function LoadTranslationPlugins ($lang = SYS_LANG, $listPluginsActive)
|
public static function LoadTranslationPlugins($lang = SYS_LANG, $listPluginsActive)
|
||||||
{
|
{
|
||||||
if ( ! ( is_array ( $listPluginsActive ) ) ) {
|
if (! (is_array($listPluginsActive))) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -528,17 +528,17 @@ class Bootstrap
|
|||||||
Translation::generateFileTranslationPlugin($namePlugin, 'en');
|
Translation::generateFileTranslationPlugin($namePlugin, 'en');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ($lang != 'en') && (!file_exists(PATH_LANGUAGECONT . $namePlugin . '.' . $lang)) ) {
|
if (($lang != 'en') && (!file_exists(PATH_LANGUAGECONT . $namePlugin . '.' . $lang))) {
|
||||||
Translation::generateFileTranslationPlugin($namePlugin, $lang);
|
Translation::generateFileTranslationPlugin($namePlugin, $lang);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file_exists(PATH_LANGUAGECONT . $namePlugin . '.' . $lang)) {
|
if (file_exists(PATH_LANGUAGECONT . $namePlugin . '.' . $lang)) {
|
||||||
eval('global $translation'.$namePlugin.';');
|
eval('global $translation'.$namePlugin.';');
|
||||||
require_once (PATH_LANGUAGECONT . $namePlugin . '.' . $lang);
|
require_once(PATH_LANGUAGECONT . $namePlugin . '.' . $lang);
|
||||||
} else {
|
} else {
|
||||||
if (file_exists(PATH_LANGUAGECONT . $namePlugin . '.en')) {
|
if (file_exists(PATH_LANGUAGECONT . $namePlugin . '.en')) {
|
||||||
eval('global $translation'.$namePlugin.';');
|
eval('global $translation'.$namePlugin.';');
|
||||||
require_once (PATH_LANGUAGECONT . $namePlugin . '.en');
|
require_once(PATH_LANGUAGECONT . $namePlugin . '.en');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -575,7 +575,7 @@ class Bootstrap
|
|||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
global $G_PUBLISH;
|
global $G_PUBLISH;
|
||||||
if (is_null($G_PUBLISH)) {
|
if (is_null($G_PUBLISH)) {
|
||||||
$G_PUBLISH = new Publisher ();
|
$G_PUBLISH = new Publisher();
|
||||||
}
|
}
|
||||||
if (count($G_PUBLISH->Parts) == 1) {
|
if (count($G_PUBLISH->Parts) == 1) {
|
||||||
array_shift($G_PUBLISH->Parts);
|
array_shift($G_PUBLISH->Parts);
|
||||||
@@ -594,7 +594,7 @@ class Bootstrap
|
|||||||
} else {
|
} else {
|
||||||
$token = strtotime("now");
|
$token = strtotime("now");
|
||||||
PMException::registerErrorLog($e, $token);
|
PMException::registerErrorLog($e, $token);
|
||||||
G::outRes( G::LoadTranslation("ID_EXCEPTION_LOG_INTERFAZ", array($token)) );
|
G::outRes(G::LoadTranslation("ID_EXCEPTION_LOG_INTERFAZ", array($token)));
|
||||||
die;
|
die;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -676,7 +676,7 @@ class Bootstrap
|
|||||||
{
|
{
|
||||||
// Get the current Include path, where the plugins directories should be
|
// Get the current Include path, where the plugins directories should be
|
||||||
if (!defined('PATH_SEPARATOR')) {
|
if (!defined('PATH_SEPARATOR')) {
|
||||||
define('PATH_SEPARATOR', (substr(PHP_OS, 0, 3) == 'WIN') ? ';' : ':' );
|
define('PATH_SEPARATOR', (substr(PHP_OS, 0, 3) == 'WIN') ? ';' : ':');
|
||||||
}
|
}
|
||||||
$path = explode(PATH_SEPARATOR, get_include_path());
|
$path = explode(PATH_SEPARATOR, get_include_path());
|
||||||
|
|
||||||
@@ -687,7 +687,7 @@ class Bootstrap
|
|||||||
if ($handle = opendir($baseDir)) {
|
if ($handle = opendir($baseDir)) {
|
||||||
while (false !== ($file = readdir($handle))) {
|
while (false !== ($file = readdir($handle))) {
|
||||||
if (strpos($file, '.php', 1) && !strpos($file, 'Peer.php', 1)) {
|
if (strpos($file, '.php', 1) && !strpos($file, 'Peer.php', 1)) {
|
||||||
require_once ($baseDir . PATH_SEP . $file);
|
require_once($baseDir . PATH_SEP . $file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -756,19 +756,19 @@ class Bootstrap
|
|||||||
$fileConst = ($typeName == 'translation') ? 'translation.' . $locale : 'translation.' . $typeName . '.' . $locale;
|
$fileConst = ($typeName == 'translation') ? 'translation.' . $locale : 'translation.' . $typeName . '.' . $locale;
|
||||||
|
|
||||||
if ($typeName == 'translation') {
|
if ($typeName == 'translation') {
|
||||||
$defaultTranslations = Array();
|
$defaultTranslations = array();
|
||||||
$foreignTranslations = Array();
|
$foreignTranslations = array();
|
||||||
$calendarJs = '';
|
$calendarJs = '';
|
||||||
|
|
||||||
//load the translations table
|
//load the translations table
|
||||||
if (is_file(PATH_LANGUAGECONT . 'translation.en')) {
|
if (is_file(PATH_LANGUAGECONT . 'translation.en')) {
|
||||||
require_once (PATH_LANGUAGECONT . 'translation.en');
|
require_once(PATH_LANGUAGECONT . 'translation.en');
|
||||||
$defaultTranslations = $translation;
|
$defaultTranslations = $translation;
|
||||||
}
|
}
|
||||||
|
|
||||||
//if some foreign language was requested and its translation file exists
|
//if some foreign language was requested and its translation file exists
|
||||||
if ($locale != 'en' && file_exists(PATH_LANGUAGECONT . 'translation.' . $locale)) {
|
if ($locale != 'en' && file_exists(PATH_LANGUAGECONT . 'translation.' . $locale)) {
|
||||||
require_once (PATH_LANGUAGECONT . 'translation.' . $locale); //load the foreign translations table
|
require_once(PATH_LANGUAGECONT . 'translation.' . $locale); //load the foreign translations table
|
||||||
$foreignTranslations = $translation;
|
$foreignTranslations = $translation;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -790,7 +790,7 @@ class Bootstrap
|
|||||||
unset($typearray[count($typearray)]);
|
unset($typearray[count($typearray)]);
|
||||||
$newName = implode('.', $typearray);
|
$newName = implode('.', $typearray);
|
||||||
if (file_exists(PATH_LANGUAGECONT . $newName)) {
|
if (file_exists(PATH_LANGUAGECONT . $newName)) {
|
||||||
require_once (PATH_LANGUAGECONT . $newName);
|
require_once(PATH_LANGUAGECONT . $newName);
|
||||||
$return = '';
|
$return = '';
|
||||||
eval('$return = "var TRANSLATIONS_" . strtoupper($typeName) . " = " . Bootstrap::json_encode($translation' . $typeName . ') . ";";');
|
eval('$return = "var TRANSLATIONS_" . strtoupper($typeName) . " = " . Bootstrap::json_encode($translation' . $typeName . ') . ";";');
|
||||||
return $return;
|
return $return;
|
||||||
@@ -921,8 +921,7 @@ class Bootstrap
|
|||||||
|
|
||||||
if (((in_array($browserName, $enabledBrowsers)) || (in_array('ALL', $enabledBrowsers))) && (!(in_array($browserName, $disabledBrowsers)))) {
|
if (((in_array($browserName, $enabledBrowsers)) || (in_array('ALL', $enabledBrowsers))) && (!(in_array($browserName, $disabledBrowsers)))) {
|
||||||
if ($cssFileInfo['__ATTRIBUTES__']['file'] == 'rtl.css') {
|
if ($cssFileInfo['__ATTRIBUTES__']['file'] == 'rtl.css') {
|
||||||
|
$oServerConf = ServerConf::getSingleton();
|
||||||
$oServerConf = & ServerConf::getSingleton();
|
|
||||||
if (!(defined('SYS_LANG'))) {
|
if (!(defined('SYS_LANG'))) {
|
||||||
if (isset($_SERVER['HTTP_REFERER'])) {
|
if (isset($_SERVER['HTTP_REFERER'])) {
|
||||||
$syss = explode('://', $_SERVER['HTTP_REFERER']);
|
$syss = explode('://', $_SERVER['HTTP_REFERER']);
|
||||||
@@ -997,7 +996,6 @@ class Bootstrap
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!$download) {
|
if (!$download) {
|
||||||
|
|
||||||
header('Pragma: cache');
|
header('Pragma: cache');
|
||||||
|
|
||||||
if (file_exists($filename)) {
|
if (file_exists($filename)) {
|
||||||
@@ -1203,7 +1201,6 @@ class Bootstrap
|
|||||||
if (function_exists('json_encode')) {
|
if (function_exists('json_encode')) {
|
||||||
return json_encode($Json);
|
return json_encode($Json);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
$oJSON = new Services_JSON();
|
$oJSON = new Services_JSON();
|
||||||
return $oJSON->encode($Json);
|
return $oJSON->encode($Json);
|
||||||
}
|
}
|
||||||
@@ -1219,7 +1216,6 @@ class Bootstrap
|
|||||||
if (function_exists('json_decode')) {
|
if (function_exists('json_decode')) {
|
||||||
return json_decode($Json);
|
return json_decode($Json);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
$oJSON = new Services_JSON();
|
$oJSON = new Services_JSON();
|
||||||
return $oJSON->decode($Json);
|
return $oJSON->decode($Json);
|
||||||
}
|
}
|
||||||
@@ -1575,7 +1571,7 @@ class Bootstrap
|
|||||||
//start the search after the first string occurrence
|
//start the search after the first string occurrence
|
||||||
if (strpos($pv_browser_user_agent, $pv_search_string, $start_pos) !== false) {
|
if (strpos($pv_browser_user_agent, $pv_search_string, $start_pos) !== false) {
|
||||||
$start_pos = strpos($pv_browser_user_agent, $pv_search_string, $start_pos) + strlen($pv_search_string);
|
$start_pos = strpos($pv_browser_user_agent, $pv_search_string, $start_pos) + strlen($pv_search_string);
|
||||||
if (!$pv_b_break_last || ( $pv_extra_search && strstr($pv_browser_user_agent, $pv_extra_search) )) {
|
if (!$pv_b_break_last || ($pv_extra_search && strstr($pv_browser_user_agent, $pv_extra_search))) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -1683,7 +1679,7 @@ class Bootstrap
|
|||||||
$os_working_type = 'nt';
|
$os_working_type = 'nt';
|
||||||
} elseif (strstr($pv_browser_string, '95')) {
|
} elseif (strstr($pv_browser_string, '95')) {
|
||||||
$os_working_number = '95';
|
$os_working_number = '95';
|
||||||
} elseif (( strstr($pv_browser_string, '9x 4.9') ) || ( strstr($pv_browser_string, ' me') )) {
|
} elseif ((strstr($pv_browser_string, '9x 4.9')) || (strstr($pv_browser_string, ' me'))) {
|
||||||
$os_working_number = 'me';
|
$os_working_number = 'me';
|
||||||
} elseif (strstr($pv_browser_string, '98')) {
|
} elseif (strstr($pv_browser_string, '98')) {
|
||||||
$os_working_number = '98';
|
$os_working_number = '98';
|
||||||
@@ -1699,9 +1695,9 @@ class Bootstrap
|
|||||||
} else {
|
} else {
|
||||||
$os_working_number = 10;
|
$os_working_number = 10;
|
||||||
}
|
}
|
||||||
} elseif (( $pv_browser_name == 'saf' ) || ( $pv_browser_name == 'cam' ) ||
|
} elseif (($pv_browser_name == 'saf') || ($pv_browser_name == 'cam') ||
|
||||||
( ( $pv_browser_name == 'moz' ) && ( $pv_version_number >= 1.3 ) ) ||
|
(($pv_browser_name == 'moz') && ($pv_version_number >= 1.3)) ||
|
||||||
( ( $pv_browser_name == 'ie' ) && ( $pv_version_number >= 5.2 ) )) {
|
(($pv_browser_name == 'ie') && ($pv_version_number >= 5.2))) {
|
||||||
$os_working_number = 10;
|
$os_working_number = 10;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -1712,23 +1708,23 @@ class Bootstrap
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
} elseif (is_array($os_working_data) && ( $i == ( $i_count - 2 ) )) {
|
} elseif (is_array($os_working_data) && ($i == ($i_count - 2))) {
|
||||||
$j_count = count($os_working_data);
|
$j_count = count($os_working_data);
|
||||||
for ($j = 0; $j < $j_count; $j++) {
|
for ($j = 0; $j < $j_count; $j++) {
|
||||||
if (strstr($pv_browser_string, $os_working_data[$j])) {
|
if (strstr($pv_browser_string, $os_working_data[$j])) {
|
||||||
$os_working_type = 'unix'; //if the os is in the unix array, it's unix, obviously...
|
$os_working_type = 'unix'; //if the os is in the unix array, it's unix, obviously...
|
||||||
$os_working_number = ( $os_working_data[$j] != 'unix' ) ? $os_working_data[$j] : ''; // assign sub unix version from the unix array
|
$os_working_number = ($os_working_data[$j] != 'unix') ? $os_working_data[$j] : ''; // assign sub unix version from the unix array
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} elseif (is_array($os_working_data) && ( $i == ( $i_count - 1 ))) {
|
} elseif (is_array($os_working_data) && ($i == ($i_count - 1))) {
|
||||||
$j_count = count($os_working_data);
|
$j_count = count($os_working_data);
|
||||||
for ($j = 0; $j < $j_count; $j++) {
|
for ($j = 0; $j < $j_count; $j++) {
|
||||||
if (strstr($pv_browser_string, $os_working_data[$j])) {
|
if (strstr($pv_browser_string, $os_working_data[$j])) {
|
||||||
$os_working_type = 'lin';
|
$os_working_type = 'lin';
|
||||||
// assign linux distro from the linux array, there's a default
|
// assign linux distro from the linux array, there's a default
|
||||||
//search for 'lin', if it's that, set version to ''
|
//search for 'lin', if it's that, set version to ''
|
||||||
$os_working_number = ( $os_working_data[$j] != 'linux' ) ? $os_working_data[$j] : '';
|
$os_working_number = ($os_working_data[$j] != 'linux') ? $os_working_data[$j] : '';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1827,7 +1823,7 @@ class Bootstrap
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// just for cases where we know it's a mobile device already
|
// just for cases where we know it's a mobile device already
|
||||||
if (!$mobile_os && ( $mobile_browser || $mobile_device || $mobile_server ) && strstr($pv_browser_user_agent, 'linux')) {
|
if (!$mobile_os && ($mobile_browser || $mobile_device || $mobile_server) && strstr($pv_browser_user_agent, 'linux')) {
|
||||||
$mobile_os = 'linux';
|
$mobile_os = 'linux';
|
||||||
$mobile_os_number = Bootstrap::get_item_version($pv_browser_user_agent, 'linux');
|
$mobile_os_number = Bootstrap::get_item_version($pv_browser_user_agent, 'linux');
|
||||||
}
|
}
|
||||||
@@ -2176,7 +2172,7 @@ class Bootstrap
|
|||||||
switch ($DBEngine) {
|
switch ($DBEngine) {
|
||||||
case 'mysql':
|
case 'mysql':
|
||||||
$con = Propel::getConnection('workflow');
|
$con = Propel::getConnection('workflow');
|
||||||
return mysql_real_escape_string(stripslashes($sqlString), $con->getResource());
|
return mysqli_real_escape_string($con->getResource(), stripslashes($sqlString));
|
||||||
break;
|
break;
|
||||||
case 'myxml':
|
case 'myxml':
|
||||||
$sqlString = str_replace('"', '""', $sqlString);
|
$sqlString = str_replace('"', '""', $sqlString);
|
||||||
@@ -2207,13 +2203,13 @@ class Bootstrap
|
|||||||
// Check if its a user template
|
// Check if its a user template
|
||||||
if (file_exists($file)) {
|
if (file_exists($file)) {
|
||||||
//require_once( $file );
|
//require_once( $file );
|
||||||
include ($file);
|
include($file);
|
||||||
} else {
|
} else {
|
||||||
// Try to get the global system template
|
// Try to get the global system template
|
||||||
$file = PATH_TEMPLATE . PATH_SEP . $temp;
|
$file = PATH_TEMPLATE . PATH_SEP . $temp;
|
||||||
//require_once( $file );
|
//require_once( $file );
|
||||||
if (file_exists($file)) {
|
if (file_exists($file)) {
|
||||||
include ($file);
|
include($file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2295,8 +2291,8 @@ class Bootstrap
|
|||||||
$lang = defined(SYS_LANG) ? SYS_LANG : 'en';
|
$lang = defined(SYS_LANG) ? SYS_LANG : 'en';
|
||||||
}
|
}
|
||||||
$aux = explode(' ', $date); //para dividir la fecha del dia
|
$aux = explode(' ', $date); //para dividir la fecha del dia
|
||||||
$date = explode('-', isset($aux[0]) ? $aux[0] : '00-00-00' ); //para obtener los dias, el mes, y el año.
|
$date = explode('-', isset($aux[0]) ? $aux[0] : '00-00-00'); //para obtener los dias, el mes, y el año.
|
||||||
$time = explode(':', isset($aux[1]) ? $aux[1] : '00:00:00' ); //para obtener las horas, minutos, segundos.
|
$time = explode(':', isset($aux[1]) ? $aux[1] : '00:00:00'); //para obtener las horas, minutos, segundos.
|
||||||
|
|
||||||
|
|
||||||
$year = (int) ((isset($date[0])) ? $date[0] : '0'); //year
|
$year = (int) ((isset($date[0])) ? $date[0] : '0'); //year
|
||||||
@@ -2309,7 +2305,7 @@ class Bootstrap
|
|||||||
$s = isset($time[2]) ? $time[2] : '00'; //second
|
$s = isset($time[2]) ? $time[2] : '00'; //second
|
||||||
|
|
||||||
|
|
||||||
$MONTHS = Array();
|
$MONTHS = array();
|
||||||
for ($i = 1; $i <= 12; $i++) {
|
for ($i = 1; $i <= 12; $i++) {
|
||||||
$MONTHS[$i] = Bootstrap::LoadTranslation("ID_MONTH_$i", $lang);
|
$MONTHS[$i] = Bootstrap::LoadTranslation("ID_MONTH_$i", $lang);
|
||||||
}
|
}
|
||||||
@@ -2418,7 +2414,7 @@ class Bootstrap
|
|||||||
*/
|
*/
|
||||||
public function evalJScript($c)
|
public function evalJScript($c)
|
||||||
{
|
{
|
||||||
print ("<script language=\"javascript\">{$c}</script>");
|
print("<script language=\"javascript\">{$c}</script>");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2595,13 +2591,13 @@ class Bootstrap
|
|||||||
//To enable compatibility with soap login
|
//To enable compatibility with soap login
|
||||||
if ((Bootstrap::hashPassword($pass, $hashTypeCurrent) == $userPass) || ($pass === $hashTypeCurrent . ':' . $userPass)) {
|
if ((Bootstrap::hashPassword($pass, $hashTypeCurrent) == $userPass) || ($pass === $hashTypeCurrent . ':' . $userPass)) {
|
||||||
$acceptance = true;
|
$acceptance = true;
|
||||||
} else if ((Bootstrap::hashPassword($pass, $hashTypePrevious) == $userPass) || ($pass === $hashTypePrevious . ':' . $userPass)) {
|
} elseif ((Bootstrap::hashPassword($pass, $hashTypePrevious) == $userPass) || ($pass === $hashTypePrevious . ':' . $userPass)) {
|
||||||
$acceptance = true;
|
$acceptance = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (Bootstrap::hashPassword($pass, $hashTypeCurrent) == $userPass) {
|
if (Bootstrap::hashPassword($pass, $hashTypeCurrent) == $userPass) {
|
||||||
$acceptance = true;
|
$acceptance = true;
|
||||||
} else if (Bootstrap::hashPassword($pass, $hashTypePrevious) == $userPass) {
|
} elseif (Bootstrap::hashPassword($pass, $hashTypePrevious) == $userPass) {
|
||||||
$acceptance = true;
|
$acceptance = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2613,7 +2609,7 @@ class Bootstrap
|
|||||||
* @param $string
|
* @param $string
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function encryptOld ($string)
|
public function encryptOld($string)
|
||||||
{
|
{
|
||||||
$consthashFx = self::hashFx;
|
$consthashFx = self::hashFx;
|
||||||
return $consthashFx($string);
|
return $consthashFx($string);
|
||||||
@@ -2630,7 +2626,7 @@ class Bootstrap
|
|||||||
$translationsTable = $Translations->getTranslationEnvironments();
|
$translationsTable = $Translations->getTranslationEnvironments();
|
||||||
$inLang = false;
|
$inLang = false;
|
||||||
foreach ($translationsTable as $locale) {
|
foreach ($translationsTable as $locale) {
|
||||||
if ($locale['LOCALE'] == $acceptLanguage){
|
if ($locale['LOCALE'] == $acceptLanguage) {
|
||||||
$inLang = true;
|
$inLang = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -2638,7 +2634,6 @@ class Bootstrap
|
|||||||
$lang = $inLang?$acceptLanguage:'en';
|
$lang = $inLang?$acceptLanguage:'en';
|
||||||
define("SYS_LANG", $lang);
|
define("SYS_LANG", $lang);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2672,7 +2667,7 @@ class Bootstrap
|
|||||||
{
|
{
|
||||||
$fileLog = $pathData .'sites'. PATH_SEP . $ws . PATH_SEP . 'log' . PATH_SEP . $file;
|
$fileLog = $pathData .'sites'. PATH_SEP . $ws . PATH_SEP . 'log' . PATH_SEP . $file;
|
||||||
|
|
||||||
$registerLogger = &MonologProvider::getSingleton($channel, $fileLog);
|
$registerLogger = MonologProvider::getSingleton($channel, $fileLog);
|
||||||
$registerLogger->addLog($level, $message, $context);
|
$registerLogger->addLog($level, $message, $context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2747,6 +2742,4 @@ class Bootstrap
|
|||||||
}
|
}
|
||||||
set_include_path(get_include_path() . PATH_SEPARATOR . PATH_DATA_SITE);
|
set_include_path(get_include_path() . PATH_SEPARATOR . PATH_DATA_SITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ class Controller
|
|||||||
*
|
*
|
||||||
* @var array - private array to store proxy data
|
* @var array - private array to store proxy data
|
||||||
*/
|
*/
|
||||||
private $__data__ = array ();
|
private $__data__ = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -64,7 +64,7 @@ class Controller
|
|||||||
* @param string $name
|
* @param string $name
|
||||||
* @param string $value
|
* @param string $value
|
||||||
*/
|
*/
|
||||||
public function __set ($name, $value)
|
public function __set($name, $value)
|
||||||
{
|
{
|
||||||
$this->__data__[$name] = $value;
|
$this->__data__[$name] = $value;
|
||||||
}
|
}
|
||||||
@@ -75,14 +75,14 @@ class Controller
|
|||||||
* @param string $name
|
* @param string $name
|
||||||
* @return string or NULL if the internal var doesn't exist
|
* @return string or NULL if the internal var doesn't exist
|
||||||
*/
|
*/
|
||||||
public function __get ($name)
|
public function __get($name)
|
||||||
{
|
{
|
||||||
if (array_key_exists( $name, $this->__data__ )) {
|
if (array_key_exists($name, $this->__data__)) {
|
||||||
return $this->__data__[$name];
|
return $this->__data__[$name];
|
||||||
}
|
}
|
||||||
|
|
||||||
$trace = debug_backtrace();
|
$trace = debug_backtrace();
|
||||||
trigger_error( 'Undefined property via __get(): ' . $name . ' in ' . $trace[0]['file'] . ' on line ' . $trace[0]['line'], E_USER_NOTICE );
|
trigger_error('Undefined property via __get(): ' . $name . ' in ' . $trace[0]['file'] . ' on line ' . $trace[0]['line'], E_USER_NOTICE);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,9 +91,9 @@ class Controller
|
|||||||
*
|
*
|
||||||
* @param string $name
|
* @param string $name
|
||||||
*/
|
*/
|
||||||
public function __isset ($name)
|
public function __isset($name)
|
||||||
{
|
{
|
||||||
return isset( $this->__data__[$name] );
|
return isset($this->__data__[$name]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -101,9 +101,9 @@ class Controller
|
|||||||
*
|
*
|
||||||
* @param string $name
|
* @param string $name
|
||||||
*/
|
*/
|
||||||
public function __unset ($name)
|
public function __unset($name)
|
||||||
{
|
{
|
||||||
unset( $this->__data__[$name] );
|
unset($this->__data__[$name]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -111,7 +111,7 @@ class Controller
|
|||||||
*
|
*
|
||||||
* @param string $type contains : json|plain
|
* @param string $type contains : json|plain
|
||||||
*/
|
*/
|
||||||
public function setResponseType ($type)
|
public function setResponseType($type)
|
||||||
{
|
{
|
||||||
$this->responseType = $type;
|
$this->responseType = $type;
|
||||||
}
|
}
|
||||||
@@ -121,12 +121,12 @@ class Controller
|
|||||||
*
|
*
|
||||||
* @param string $name
|
* @param string $name
|
||||||
*/
|
*/
|
||||||
public function call ($name)
|
public function call($name)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$result = $this->$name( $this->__request__ );
|
$result = $this->$name($this->__request__);
|
||||||
if ($this->responseType == 'json') {
|
if ($this->responseType == 'json') {
|
||||||
print G::json_encode( $result );
|
print G::json_encode($result);
|
||||||
}
|
}
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$result = new StdClass();
|
$result = new StdClass();
|
||||||
@@ -134,7 +134,7 @@ class Controller
|
|||||||
Bootstrap::renderTemplate('controller.exception.tpl', array(
|
Bootstrap::renderTemplate('controller.exception.tpl', array(
|
||||||
'title' => 'Controller Exception',
|
'title' => 'Controller Exception',
|
||||||
'message' => nl2br($e->getMessage()),
|
'message' => nl2br($e->getMessage()),
|
||||||
'controller' => (function_exists( 'get_called_class' ) ? get_called_class() : 'Controller'),
|
'controller' => (function_exists('get_called_class') ? get_called_class() : 'Controller'),
|
||||||
'exceptionClass' => get_class($e),
|
'exceptionClass' => get_class($e),
|
||||||
'file' => $e->getFile(),
|
'file' => $e->getFile(),
|
||||||
'line' => $e->getLine(),
|
'line' => $e->getLine(),
|
||||||
@@ -143,7 +143,7 @@ class Controller
|
|||||||
} else {
|
} else {
|
||||||
$result->success = false;
|
$result->success = false;
|
||||||
$result->msg = $e->getMessage();
|
$result->msg = $e->getMessage();
|
||||||
switch (get_class( $e )) {
|
switch (get_class($e)) {
|
||||||
case 'Exception':
|
case 'Exception':
|
||||||
$error = "SYSTEM ERROR";
|
$error = "SYSTEM ERROR";
|
||||||
break;
|
break;
|
||||||
@@ -159,9 +159,9 @@ class Controller
|
|||||||
}
|
}
|
||||||
$result->error = $error;
|
$result->error = $error;
|
||||||
|
|
||||||
$result->exception->class = get_class( $e );
|
$result->exception->class = get_class($e);
|
||||||
$result->exception->code = $e->getCode();
|
$result->exception->code = $e->getCode();
|
||||||
print G::json_encode( $result );
|
print G::json_encode($result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -171,14 +171,14 @@ class Controller
|
|||||||
*
|
*
|
||||||
* @param array $data
|
* @param array $data
|
||||||
*/
|
*/
|
||||||
public function setHttpRequestData ($data)
|
public function setHttpRequestData($data)
|
||||||
{
|
{
|
||||||
if (! is_object( $this->__request__ )) {
|
if (! is_object($this->__request__)) {
|
||||||
$this->__request__ = new stdclass();
|
$this->__request__ = new stdclass();
|
||||||
}
|
}
|
||||||
if (is_array( $data )) {
|
if (is_array($data)) {
|
||||||
while ($var = each( $data )) {
|
while ($var = each($data)) {
|
||||||
$this->__request__->$var['key'] = $var['value'];
|
$this->__request__->{$var['key']} = $var['value'];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$this->__request__ = $data;
|
$this->__request__ = $data;
|
||||||
@@ -191,7 +191,7 @@ class Controller
|
|||||||
*
|
*
|
||||||
* @param boolan $val boolean value for debug var.
|
* @param boolan $val boolean value for debug var.
|
||||||
*/
|
*/
|
||||||
public function setDebug ($val)
|
public function setDebug($val)
|
||||||
{
|
{
|
||||||
$this->debug = $val;
|
$this->debug = $val;
|
||||||
}
|
}
|
||||||
@@ -200,10 +200,10 @@ class Controller
|
|||||||
* Get debug var.
|
* Get debug var.
|
||||||
* method
|
* method
|
||||||
*/
|
*/
|
||||||
public function getDebug ()
|
public function getDebug()
|
||||||
{
|
{
|
||||||
if ($this->debug === null) {
|
if ($this->debug === null) {
|
||||||
$this->debug = defined( 'DEBUG' ) && DEBUG ? true : false;
|
$this->debug = defined('DEBUG') && DEBUG ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->debug;
|
return $this->debug;
|
||||||
@@ -221,9 +221,9 @@ class Controller
|
|||||||
* $debug: true -> the js content will be not minified (readable)
|
* $debug: true -> the js content will be not minified (readable)
|
||||||
* false -> the js content will be minified
|
* false -> the js content will be minified
|
||||||
*/
|
*/
|
||||||
public function includeExtJSLib ($srcFile, $debug = false)
|
public function includeExtJSLib($srcFile, $debug = false)
|
||||||
{
|
{
|
||||||
$this->getHeadPublisher()->usingExtJs( $srcFile, ($debug ? $debug : $this->getDebug()) );
|
$this->getHeadPublisher()->usingExtJs($srcFile, ($debug ? $debug : $this->getDebug()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -234,9 +234,9 @@ class Controller
|
|||||||
* $debug: true -> the js content will be not minified (readable)
|
* $debug: true -> the js content will be not minified (readable)
|
||||||
* false -> the js content will be minified
|
* false -> the js content will be minified
|
||||||
*/
|
*/
|
||||||
public function includeExtJS ($srcFile, $debug = false)
|
public function includeExtJS($srcFile, $debug = false)
|
||||||
{
|
{
|
||||||
$this->getHeadPublisher()->addExtJsScript( $srcFile, ($debug ? $debug : $this->getDebug()) );
|
$this->getHeadPublisher()->addExtJsScript($srcFile, ($debug ? $debug : $this->getDebug()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -244,9 +244,9 @@ class Controller
|
|||||||
*
|
*
|
||||||
* @param string $file path of html file to include to the main output
|
* @param string $file path of html file to include to the main output
|
||||||
*/
|
*/
|
||||||
public function setView ($file)
|
public function setView($file)
|
||||||
{
|
{
|
||||||
$this->getHeadPublisher()->addContent( $file );
|
$this->getHeadPublisher()->addContent($file);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -255,9 +255,9 @@ class Controller
|
|||||||
* @param string $name contains var. name
|
* @param string $name contains var. name
|
||||||
* @param string $value conatins var. value
|
* @param string $value conatins var. value
|
||||||
*/
|
*/
|
||||||
public function setJSVar ($name, $value)
|
public function setJSVar($name, $value)
|
||||||
{
|
{
|
||||||
$this->getHeadPublisher()->assign( $name, $value );
|
$this->getHeadPublisher()->assign($name, $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -266,41 +266,41 @@ class Controller
|
|||||||
* @param string $name contains var. name
|
* @param string $name contains var. name
|
||||||
* @param string $value conatins var. value
|
* @param string $value conatins var. value
|
||||||
*/
|
*/
|
||||||
public function setVar ($name, $value)
|
public function setVar($name, $value)
|
||||||
{
|
{
|
||||||
$this->getHeadPublisher()->assignVar( $name, $value );
|
$this->getHeadPublisher()->assignVar($name, $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* method to get the local getHeadPublisher object
|
* method to get the local getHeadPublisher object
|
||||||
*/
|
*/
|
||||||
public function getHeadPublisher ()
|
public function getHeadPublisher()
|
||||||
{
|
{
|
||||||
if (! is_object( $this->headPublisher )) {
|
if (! is_object($this->headPublisher)) {
|
||||||
$this->headPublisher = headPublisher::getSingleton();
|
$this->headPublisher = headPublisher::getSingleton();
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->headPublisher;
|
return $this->headPublisher;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setLayout ($layout)
|
public function setLayout($layout)
|
||||||
{
|
{
|
||||||
$this->layout = $layout;
|
$this->layout = $layout;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function render ($type = 'mvc')
|
public function render($type = 'mvc')
|
||||||
{
|
{
|
||||||
G::RenderPage( 'publish', $type, null, $this->layout );
|
G::RenderPage('publish', $type, null, $this->layout);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function header ($header)
|
public function header($header)
|
||||||
{
|
{
|
||||||
G::header( $header );
|
G::header($header);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function redirect ($url)
|
public function redirect($url)
|
||||||
{
|
{
|
||||||
G::header( "Location: $url" );
|
G::header("Location: $url");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setPluginName($name)
|
public function setPluginName($name)
|
||||||
@@ -323,4 +323,3 @@ class Controller
|
|||||||
return $this->pluginHomeDir;
|
return $this->pluginHomeDir;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,31 +30,27 @@
|
|||||||
* @package gulliver.system
|
* @package gulliver.system
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class database extends database_base
|
class database extends database_base
|
||||||
{
|
{
|
||||||
|
public $iFetchType = MYSQLI_ASSOC;
|
||||||
public $iFetchType = MYSQL_ASSOC;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* class database constructor
|
* class database constructor.
|
||||||
*
|
*
|
||||||
* @param $sType adapter type
|
* @param string $sType adapter type
|
||||||
* @param $sServer server
|
* @param string $sServer server
|
||||||
* @param $sUser db user
|
* @param string $sUser db user
|
||||||
* @param $sPass db user password
|
* @param string $sPass db user password
|
||||||
* @param $sDataBase Database name
|
* @param string $sDataBase Database name
|
||||||
*/
|
*/
|
||||||
public function __construct ($sType = DB_ADAPTER, $sServer = DB_HOST, $sUser = DB_USER, $sPass = DB_PASS, $sDataBase = DB_NAME)
|
public function __construct($sType = DB_ADAPTER, $sServer = DB_HOST, $sUser = DB_USER, $sPass = DB_PASS, $sDataBase = DB_NAME)
|
||||||
{
|
{
|
||||||
$this->sType = $sType;
|
$this->sType = $sType;
|
||||||
$this->sServer = $sServer;
|
$this->sServer = $sServer;
|
||||||
$this->sUser = $sUser;
|
$this->sUser = $sUser;
|
||||||
$this->sPass = $sPass;
|
$this->sPass = $sPass;
|
||||||
$this->sDataBase = $sDataBase;
|
$this->sDataBase = $sDataBase;
|
||||||
$this->oConnection = @mysql_connect( $sServer, $sUser, $sPass ) || null;
|
$this->oConnection = mysqli_connect($sServer, $sUser, $sPass, $sDataBase) or die('Could not connect to database...');
|
||||||
$this->sQuoteCharacter = '`';
|
$this->sQuoteCharacter = '`';
|
||||||
$this->nullString = 'null';
|
$this->nullString = 'null';
|
||||||
}
|
}
|
||||||
@@ -66,30 +62,29 @@ class database extends database_base
|
|||||||
* @param $aColumns array of columns
|
* @param $aColumns array of columns
|
||||||
* @return $sSql the sql sentence
|
* @return $sSql the sql sentence
|
||||||
*/
|
*/
|
||||||
public function generateCreateTableSQL ($sTable, $aColumns)
|
public function generateCreateTableSQL($sTable, $aColumns)
|
||||||
{
|
{
|
||||||
$sKeys = '';
|
$sKeys = '';
|
||||||
$sSQL = 'CREATE TABLE IF NOT EXISTS ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . '(';
|
$sSQL = 'CREATE TABLE IF NOT EXISTS ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . '(';
|
||||||
|
|
||||||
foreach ($aColumns as $sColumnName => $aParameters) {
|
foreach ($aColumns as $sColumnName => $aParameters) {
|
||||||
if ($sColumnName != 'INDEXES') {
|
if ($sColumnName != 'INDEXES') {
|
||||||
|
if ($sColumnName != '' && isset($aParameters['Type']) && $aParameters['Type'] != '') {
|
||||||
if ($sColumnName != '' && isset( $aParameters['Type'] ) && $aParameters['Type'] != '') {
|
|
||||||
$sSQL .= $this->sQuoteCharacter . $sColumnName . $this->sQuoteCharacter . ' ' . $aParameters['Type'];
|
$sSQL .= $this->sQuoteCharacter . $sColumnName . $this->sQuoteCharacter . ' ' . $aParameters['Type'];
|
||||||
|
|
||||||
if (isset( $aParameters['Null'] ) && $aParameters['Null'] == 'YES') {
|
if (isset($aParameters['Null']) && $aParameters['Null'] == 'YES') {
|
||||||
$sSQL .= ' NULL';
|
$sSQL .= ' NULL';
|
||||||
} else {
|
} else {
|
||||||
$sSQL .= ' NOT NULL';
|
$sSQL .= ' NOT NULL';
|
||||||
}
|
}
|
||||||
if (isset( $aParameters['AutoIncrement'] ) && $aParameters['AutoIncrement']) {
|
if (isset($aParameters['AutoIncrement']) && $aParameters['AutoIncrement']) {
|
||||||
$sSQL .= ' AUTO_INCREMENT PRIMARY KEY';
|
$sSQL .= ' AUTO_INCREMENT PRIMARY KEY';
|
||||||
}
|
}
|
||||||
if (isset( $aParameters['Key'] ) && $aParameters['Key'] == 'PRI') {
|
if (isset($aParameters['Key']) && $aParameters['Key'] == 'PRI') {
|
||||||
$sKeys .= $this->sQuoteCharacter . $sColumnName . $this->sQuoteCharacter . ',';
|
$sKeys .= $this->sQuoteCharacter . $sColumnName . $this->sQuoteCharacter . ',';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset( $aParameters['Default'] )) {
|
if (isset($aParameters['Default'])) {
|
||||||
$sSQL .= " DEFAULT '" . trim($aParameters['Default']) . "'";
|
$sSQL .= " DEFAULT '" . trim($aParameters['Default']) . "'";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,9 +92,9 @@ class database extends database_base
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$sSQL = substr( $sSQL, 0, - 1 );
|
$sSQL = substr($sSQL, 0, -1);
|
||||||
if ($sKeys != '') {
|
if ($sKeys != '') {
|
||||||
$sSQL .= ',PRIMARY KEY(' . substr( $sKeys, 0, - 1 ) . ')';
|
$sSQL .= ',PRIMARY KEY(' . substr($sKeys, 0, -1) . ')';
|
||||||
}
|
}
|
||||||
$sSQL .= ')ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci' . $this->sEndLine;
|
$sSQL .= ')ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci' . $this->sEndLine;
|
||||||
|
|
||||||
@@ -112,7 +107,7 @@ class database extends database_base
|
|||||||
* @param $sTable table name
|
* @param $sTable table name
|
||||||
* @return sql sentence string
|
* @return sql sentence string
|
||||||
*/
|
*/
|
||||||
public function generateDropTableSQL ($sTable)
|
public function generateDropTableSQL($sTable)
|
||||||
{
|
{
|
||||||
return 'DROP TABLE ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . $this->sEndLine;
|
return 'DROP TABLE ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . $this->sEndLine;
|
||||||
}
|
}
|
||||||
@@ -123,7 +118,7 @@ class database extends database_base
|
|||||||
* @param $sTableOld old table name
|
* @param $sTableOld old table name
|
||||||
* @return $sSql sql sentence
|
* @return $sSql sql sentence
|
||||||
*/
|
*/
|
||||||
public function generateRenameTableSQL ($sTableOld)
|
public function generateRenameTableSQL($sTableOld)
|
||||||
{
|
{
|
||||||
$sSQL = 'ALTER TABLE ' . $sTableOld . ' RENAME TO RBAC_' . $sTableOld;
|
$sSQL = 'ALTER TABLE ' . $sTableOld . ' RENAME TO RBAC_' . $sTableOld;
|
||||||
return $sSQL;
|
return $sSQL;
|
||||||
@@ -136,7 +131,7 @@ class database extends database_base
|
|||||||
* @param $sColumn column name
|
* @param $sColumn column name
|
||||||
* @return $sSql sql sentence
|
* @return $sSql sql sentence
|
||||||
*/
|
*/
|
||||||
public function generateDropColumnSQL ($sTable, $sColumn)
|
public function generateDropColumnSQL($sTable, $sColumn)
|
||||||
{
|
{
|
||||||
$sSQL = 'ALTER TABLE ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . ' DROP COLUMN ' . $this->sQuoteCharacter . $sColumn . $this->sQuoteCharacter . $this->sEndLine;
|
$sSQL = 'ALTER TABLE ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . ' DROP COLUMN ' . $this->sQuoteCharacter . $sColumn . $this->sQuoteCharacter . $this->sEndLine;
|
||||||
return $sSQL;
|
return $sSQL;
|
||||||
@@ -187,7 +182,6 @@ class database extends database_base
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* generate an add column sentence
|
* generate an add column sentence
|
||||||
*
|
*
|
||||||
@@ -196,9 +190,9 @@ class database extends database_base
|
|||||||
* @param $aParameters parameters of field like typo or if it can be null
|
* @param $aParameters parameters of field like typo or if it can be null
|
||||||
* @return $sSql sql sentence
|
* @return $sSql sql sentence
|
||||||
*/
|
*/
|
||||||
public function generateAddColumnSQL ($sTable, $sColumn, $aParameters)
|
public function generateAddColumnSQL($sTable, $sColumn, $aParameters)
|
||||||
{
|
{
|
||||||
if (isset( $aParameters['Type'] ) && isset( $aParameters['Null'] )) {
|
if (isset($aParameters['Type']) && isset($aParameters['Null'])) {
|
||||||
$sSQL = 'ALTER TABLE ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . ' ADD COLUMN ' . $this->sQuoteCharacter . $sColumn . $this->sQuoteCharacter . ' ' . $aParameters['Type'];
|
$sSQL = 'ALTER TABLE ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . ' ADD COLUMN ' . $this->sQuoteCharacter . $sColumn . $this->sQuoteCharacter . ' ' . $aParameters['Type'];
|
||||||
if ($aParameters['Null'] == 'YES') {
|
if ($aParameters['Null'] == 'YES') {
|
||||||
$sSQL .= ' NULL';
|
$sSQL .= ' NULL';
|
||||||
@@ -206,18 +200,18 @@ class database extends database_base
|
|||||||
$sSQL .= ' NOT NULL';
|
$sSQL .= ' NOT NULL';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isset( $aParameters['AutoIncrement'] ) && $aParameters['AutoIncrement']) {
|
if (isset($aParameters['AutoIncrement']) && $aParameters['AutoIncrement']) {
|
||||||
$sSQL .= ' AUTO_INCREMENT';
|
$sSQL .= ' AUTO_INCREMENT';
|
||||||
}
|
}
|
||||||
if (isset( $aParameters['PrimaryKey'] ) && $aParameters['PrimaryKey']) {
|
if (isset($aParameters['PrimaryKey']) && $aParameters['PrimaryKey']) {
|
||||||
$sSQL .= ' PRIMARY KEY';
|
$sSQL .= ' PRIMARY KEY';
|
||||||
}
|
}
|
||||||
if (isset( $aParameters['Unique'] ) && $aParameters['Unique']) {
|
if (isset($aParameters['Unique']) && $aParameters['Unique']) {
|
||||||
$sSQL .= ' UNIQUE';
|
$sSQL .= ' UNIQUE';
|
||||||
}
|
}
|
||||||
|
|
||||||
//we need to check the property AI
|
//we need to check the property AI
|
||||||
if (isset( $aParameters['AI'] )) {
|
if (isset($aParameters['AI'])) {
|
||||||
if ($aParameters['AI'] == 1) {
|
if ($aParameters['AI'] == 1) {
|
||||||
$sSQL .= ' AUTO_INCREMENT';
|
$sSQL .= ' AUTO_INCREMENT';
|
||||||
} else {
|
} else {
|
||||||
@@ -226,7 +220,7 @@ class database extends database_base
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (isset( $aParameters['Default'] )) {
|
if (isset($aParameters['Default'])) {
|
||||||
$sSQL .= " DEFAULT '" . $aParameters['Default'] . "'";
|
$sSQL .= " DEFAULT '" . $aParameters['Default'] . "'";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -243,13 +237,13 @@ class database extends database_base
|
|||||||
* @param $sColumnNewName column new name
|
* @param $sColumnNewName column new name
|
||||||
* @return $sSql sql sentence
|
* @return $sSql sql sentence
|
||||||
*/
|
*/
|
||||||
public function generateChangeColumnSQL ($sTable, $sColumn, $aParameters, $sColumnNewName = '')
|
public function generateChangeColumnSQL($sTable, $sColumn, $aParameters, $sColumnNewName = '')
|
||||||
{
|
{
|
||||||
$sSQL = 'ALTER TABLE ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . ' CHANGE COLUMN ' . $this->sQuoteCharacter . ($sColumnNewName != '' ? $sColumnNewName : $sColumn) . $this->sQuoteCharacter . ' ' . $this->sQuoteCharacter . $sColumn . $this->sQuoteCharacter;
|
$sSQL = 'ALTER TABLE ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . ' CHANGE COLUMN ' . $this->sQuoteCharacter . ($sColumnNewName != '' ? $sColumnNewName : $sColumn) . $this->sQuoteCharacter . ' ' . $this->sQuoteCharacter . $sColumn . $this->sQuoteCharacter;
|
||||||
if (isset( $aParameters['Type'] )) {
|
if (isset($aParameters['Type'])) {
|
||||||
$sSQL .= ' ' . $aParameters['Type'];
|
$sSQL .= ' ' . $aParameters['Type'];
|
||||||
}
|
}
|
||||||
if (isset( $aParameters['Null'] )) {
|
if (isset($aParameters['Null'])) {
|
||||||
if ($aParameters['Null'] == 'YES') {
|
if ($aParameters['Null'] == 'YES') {
|
||||||
$sSQL .= ' NULL';
|
$sSQL .= ' NULL';
|
||||||
} else {
|
} else {
|
||||||
@@ -269,15 +263,15 @@ class database extends database_base
|
|||||||
// }
|
// }
|
||||||
//}
|
//}
|
||||||
//else {
|
//else {
|
||||||
if (isset( $aParameters['Default'] )) {
|
if (isset($aParameters['Default'])) {
|
||||||
if (trim( $aParameters['Default'] ) == '' && $aParameters['Type'] == 'datetime') {
|
if (trim($aParameters['Default']) == '' && $aParameters['Type'] == 'datetime') {
|
||||||
//do nothing
|
//do nothing
|
||||||
} else {
|
} else {
|
||||||
$sSQL .= " DEFAULT '" . $aParameters['Default'] . "'";
|
$sSQL .= " DEFAULT '" . $aParameters['Default'] . "'";
|
||||||
}
|
}
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
if (! isset( $aParameters['Default'] ) && isset( $aParameters['Null'] ) && $aParameters['Null'] == 'YES') {
|
if (!isset($aParameters['Default']) && isset($aParameters['Null']) && $aParameters['Null'] == 'YES') {
|
||||||
$sSQL .= " DEFAULT NULL ";
|
$sSQL .= " DEFAULT NULL ";
|
||||||
}
|
}
|
||||||
//}
|
//}
|
||||||
@@ -291,11 +285,11 @@ class database extends database_base
|
|||||||
* @param $sTable table name
|
* @param $sTable table name
|
||||||
* @return $sSql sql sentence
|
* @return $sSql sql sentence
|
||||||
*/
|
*/
|
||||||
public function generateGetPrimaryKeysSQL ($sTable)
|
public function generateGetPrimaryKeysSQL($sTable)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
if ($sTable == '') {
|
if ($sTable == '') {
|
||||||
throw new Exception( 'The table name cannot be empty!' );
|
throw new Exception('The table name cannot be empty!');
|
||||||
}
|
}
|
||||||
return 'SHOW INDEX FROM ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . ' WHERE Seq_in_index = 1' . $this->sEndLine;
|
return 'SHOW INDEX FROM ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . ' WHERE Seq_in_index = 1' . $this->sEndLine;
|
||||||
} catch (Exception $oException) {
|
} catch (Exception $oException) {
|
||||||
@@ -309,11 +303,11 @@ class database extends database_base
|
|||||||
* @param $sTable table name
|
* @param $sTable table name
|
||||||
* @return sql sentence
|
* @return sql sentence
|
||||||
*/
|
*/
|
||||||
public function generateDropPrimaryKeysSQL ($sTable)
|
public function generateDropPrimaryKeysSQL($sTable)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
if ($sTable == '') {
|
if ($sTable == '') {
|
||||||
throw new Exception( 'The table name cannot be empty!' );
|
throw new Exception('The table name cannot be empty!');
|
||||||
}
|
}
|
||||||
return 'ALTER TABLE ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . ' DROP PRIMARY KEY' . $this->sEndLine;
|
return 'ALTER TABLE ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . ' DROP PRIMARY KEY' . $this->sEndLine;
|
||||||
} catch (Exception $oException) {
|
} catch (Exception $oException) {
|
||||||
@@ -328,17 +322,17 @@ class database extends database_base
|
|||||||
* @param $aPrimaryKeys array of primary keys
|
* @param $aPrimaryKeys array of primary keys
|
||||||
* @return sql sentence
|
* @return sql sentence
|
||||||
*/
|
*/
|
||||||
public function generateAddPrimaryKeysSQL ($sTable, $aPrimaryKeys)
|
public function generateAddPrimaryKeysSQL($sTable, $aPrimaryKeys)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
if ($sTable == '') {
|
if ($sTable == '') {
|
||||||
throw new Exception( 'The table name cannot be empty!' );
|
throw new Exception('The table name cannot be empty!');
|
||||||
}
|
}
|
||||||
$sSQL = 'ALTER TABLE ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . ' ADD PRIMARY KEY (';
|
$sSQL = 'ALTER TABLE ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . ' ADD PRIMARY KEY (';
|
||||||
foreach ($aPrimaryKeys as $sKey) {
|
foreach ($aPrimaryKeys as $sKey) {
|
||||||
$sSQL .= $this->sQuoteCharacter . $sKey . $this->sQuoteCharacter . ',';
|
$sSQL .= $this->sQuoteCharacter . $sKey . $this->sQuoteCharacter . ',';
|
||||||
}
|
}
|
||||||
$sSQL = substr( $sSQL, 0, - 1 ) . ')' . $this->sEndLine;
|
$sSQL = substr($sSQL, 0, -1) . ')' . $this->sEndLine;
|
||||||
return $sSQL;
|
return $sSQL;
|
||||||
} catch (Exception $oException) {
|
} catch (Exception $oException) {
|
||||||
throw $oException;
|
throw $oException;
|
||||||
@@ -352,14 +346,14 @@ class database extends database_base
|
|||||||
* @param $sIndexName index name
|
* @param $sIndexName index name
|
||||||
* @return sql sentence
|
* @return sql sentence
|
||||||
*/
|
*/
|
||||||
public function generateDropKeySQL ($sTable, $sIndexName)
|
public function generateDropKeySQL($sTable, $sIndexName)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
if ($sTable == '') {
|
if ($sTable == '') {
|
||||||
throw new Exception( 'The table name cannot be empty!' );
|
throw new Exception('The table name cannot be empty!');
|
||||||
}
|
}
|
||||||
if ($sIndexName == '') {
|
if ($sIndexName == '') {
|
||||||
throw new Exception( 'The column name cannot be empty!' );
|
throw new Exception('The column name cannot be empty!');
|
||||||
}
|
}
|
||||||
return 'ALTER TABLE ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . ' DROP INDEX ' . $this->sQuoteCharacter . $sIndexName . $this->sQuoteCharacter . $this->sEndLine;
|
return 'ALTER TABLE ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . ' DROP INDEX ' . $this->sQuoteCharacter . $sIndexName . $this->sQuoteCharacter . $this->sEndLine;
|
||||||
} catch (Exception $oException) {
|
} catch (Exception $oException) {
|
||||||
@@ -376,7 +370,7 @@ class database extends database_base
|
|||||||
* @return sql sentence
|
* @return sql sentence
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public function generateAddKeysSQL ($sTable, $indexName, $aKeys)
|
public function generateAddKeysSQL($sTable, $indexName, $aKeys)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$indexType = 'INDEX';
|
$indexType = 'INDEX';
|
||||||
@@ -388,7 +382,7 @@ class database extends database_base
|
|||||||
foreach ($aKeys as $sKey) {
|
foreach ($aKeys as $sKey) {
|
||||||
$sSQL .= $this->sQuoteCharacter . $sKey . $this->sQuoteCharacter . ', ';
|
$sSQL .= $this->sQuoteCharacter . $sKey . $this->sQuoteCharacter . ', ';
|
||||||
}
|
}
|
||||||
$sSQL = substr( $sSQL, 0, - 2 );
|
$sSQL = substr($sSQL, 0, -2);
|
||||||
$sSQL .= ')' . $this->sEndLine;
|
$sSQL .= ')' . $this->sEndLine;
|
||||||
return $sSQL;
|
return $sSQL;
|
||||||
} catch (Exception $oException) {
|
} catch (Exception $oException) {
|
||||||
@@ -401,7 +395,7 @@ class database extends database_base
|
|||||||
*
|
*
|
||||||
* @return sql sentence
|
* @return sql sentence
|
||||||
*/
|
*/
|
||||||
public function generateShowTablesSQL ()
|
public function generateShowTablesSQL()
|
||||||
{
|
{
|
||||||
return 'SHOW TABLES' . $this->sEndLine;
|
return 'SHOW TABLES' . $this->sEndLine;
|
||||||
}
|
}
|
||||||
@@ -411,7 +405,7 @@ class database extends database_base
|
|||||||
*
|
*
|
||||||
* @return sql sentence
|
* @return sql sentence
|
||||||
*/
|
*/
|
||||||
public function generateShowTablesLikeSQL ($sTable)
|
public function generateShowTablesLikeSQL($sTable)
|
||||||
{
|
{
|
||||||
return "SHOW TABLES LIKE '" . $sTable . "'" . $this->sEndLine;
|
return "SHOW TABLES LIKE '" . $sTable . "'" . $this->sEndLine;
|
||||||
}
|
}
|
||||||
@@ -422,11 +416,11 @@ class database extends database_base
|
|||||||
* @param $sTable table name
|
* @param $sTable table name
|
||||||
* @return sql sentence
|
* @return sql sentence
|
||||||
*/
|
*/
|
||||||
public function generateDescTableSQL ($sTable)
|
public function generateDescTableSQL($sTable)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
if ($sTable == '') {
|
if ($sTable == '') {
|
||||||
throw new Exception( 'The table name cannot be empty!' );
|
throw new Exception('The table name cannot be empty!');
|
||||||
}
|
}
|
||||||
return 'DESC ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . $this->sEndLine;
|
return 'DESC ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . $this->sEndLine;
|
||||||
} catch (Exception $oException) {
|
} catch (Exception $oException) {
|
||||||
@@ -440,7 +434,7 @@ class database extends database_base
|
|||||||
* @param $sTable table name
|
* @param $sTable table name
|
||||||
* @return sql sentence
|
* @return sql sentence
|
||||||
*/
|
*/
|
||||||
public function generateTableIndexSQL ($sTable)
|
public function generateTableIndexSQL($sTable)
|
||||||
{
|
{
|
||||||
return 'SHOW INDEX FROM ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . " " . $this->sEndLine;
|
return 'SHOW INDEX FROM ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . " " . $this->sEndLine;
|
||||||
//return 'SHOW INDEX FROM ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . " WHERE Key_name <> 'PRIMARY'" . $this->sEndLine;
|
//return 'SHOW INDEX FROM ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . " WHERE Key_name <> 'PRIMARY'" . $this->sEndLine;
|
||||||
@@ -451,12 +445,14 @@ class database extends database_base
|
|||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function isConnected ()
|
public function isConnected()
|
||||||
{
|
{
|
||||||
if (! $this->oConnection) {
|
$connect = false;
|
||||||
return false;
|
if ($this->oConnection !== false) {
|
||||||
|
$this->executeQuery('USE ' . $this->sDataBase);
|
||||||
|
$connect = true;
|
||||||
}
|
}
|
||||||
return $this->executeQuery( 'USE ' . $this->sDataBase );
|
return $connect;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -465,34 +461,34 @@ class database extends database_base
|
|||||||
* @param $sQuery sql query string
|
* @param $sQuery sql query string
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function logQuery ($sQuery)
|
public function logQuery($sQuery)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$found = false;
|
$found = false;
|
||||||
if (substr( $sQuery, 0, 6 ) == 'SELECT') {
|
if (substr($sQuery, 0, 6) == 'SELECT') {
|
||||||
$found = true;
|
$found = true;
|
||||||
}
|
}
|
||||||
if (substr( $sQuery, 0, 4 ) == 'SHOW') {
|
if (substr($sQuery, 0, 4) == 'SHOW') {
|
||||||
$found = true;
|
$found = true;
|
||||||
}
|
}
|
||||||
if (substr( $sQuery, 0, 4 ) == 'DESC') {
|
if (substr($sQuery, 0, 4) == 'DESC') {
|
||||||
$found = true;
|
$found = true;
|
||||||
}
|
}
|
||||||
if (substr( $sQuery, 0, 4 ) == 'USE ') {
|
if (substr($sQuery, 0, 4) == 'USE ') {
|
||||||
$found = true;
|
$found = true;
|
||||||
}
|
}
|
||||||
if (! $found) {
|
if (!$found) {
|
||||||
$logDir = PATH_DATA . 'log';
|
$logDir = PATH_DATA . 'log';
|
||||||
if (! file_exists( $logDir )) {
|
if (!file_exists($logDir)) {
|
||||||
if (! mkdir( $logDir )) {
|
if (!mkdir($logDir)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$logFile = "$logDir/query.log";
|
$logFile = "$logDir/query.log";
|
||||||
$fp = fopen( $logFile, 'a+' );
|
$fp = fopen($logFile, 'a+');
|
||||||
if ($fp !== false) {
|
if ($fp !== false) {
|
||||||
fwrite( $fp, date( "Y-m-d H:i:s" ) . " " . $this->sDataBase . " " . $sQuery . "\n" );
|
fwrite($fp, date("Y-m-d H:i:s") . " " . $this->sDataBase . " " . $sQuery . "\n");
|
||||||
fclose( $fp );
|
fclose($fp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception $oException) {
|
} catch (Exception $oException) {
|
||||||
@@ -505,20 +501,21 @@ class database extends database_base
|
|||||||
* @param $sQuery table name
|
* @param $sQuery table name
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function executeQuery ($sQuery)
|
public function executeQuery($sQuery)
|
||||||
{
|
{
|
||||||
$this->logQuery( $sQuery );
|
$this->logQuery($sQuery);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if ($this->oConnection) {
|
if ($this->oConnection) {
|
||||||
@mysql_select_db( $this->sDataBase );
|
mysqli_select_db($this->oConnection, $this->sDataBase);
|
||||||
|
$result = mysqli_query($this->oConnection, $sQuery);
|
||||||
return @mysql_query( $sQuery );
|
mysqli_use_result($this->oConnection);
|
||||||
|
return $result;
|
||||||
} else {
|
} else {
|
||||||
throw new Exception( 'invalid connection to database ' . $this->sDataBase );
|
throw new Exception('invalid connection to database ' . $this->sDataBase);
|
||||||
}
|
}
|
||||||
} catch (Exception $oException) {
|
} catch (Exception $oException) {
|
||||||
$this->logQuery( $oException->getMessage() );
|
$this->logQuery($oException->getMessage());
|
||||||
throw $oException;
|
throw $oException;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -529,20 +526,24 @@ class database extends database_base
|
|||||||
* @param $oDataset
|
* @param $oDataset
|
||||||
* @return the number of rows
|
* @return the number of rows
|
||||||
*/
|
*/
|
||||||
public function countResults ($oDataset)
|
public function countResults($oDataset)
|
||||||
{
|
{
|
||||||
return @mysql_num_rows( $oDataset );
|
return mysqli_num_rows($oDataset);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* count an array of the registry from a dataset
|
* count an array of the registry from a dataset
|
||||||
*
|
*
|
||||||
* @param $oDataset
|
* @param $dataSet
|
||||||
* @return the registry
|
* @return the registry
|
||||||
*/
|
*/
|
||||||
public function getRegistry ($oDataset)
|
public function getRegistry($dataSet)
|
||||||
{
|
{
|
||||||
return @mysql_fetch_array( $oDataset, $this->iFetchType );
|
$response = null;
|
||||||
|
if ($dataSet !== false) {
|
||||||
|
$response = mysqli_fetch_array($dataSet, $this->iFetchType);
|
||||||
|
}
|
||||||
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -550,80 +551,80 @@ class database extends database_base
|
|||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function close ()
|
public function close()
|
||||||
{
|
{
|
||||||
@mysql_close( $this->oConnection );
|
mysqli_close($this->oConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function generateInsertSQL ($table, $data)
|
public function generateInsertSQL($table, $data)
|
||||||
{
|
{
|
||||||
$fields = array ();
|
$fields = array();
|
||||||
$values = array ();
|
$values = array();
|
||||||
foreach ($data as $field) {
|
foreach ($data as $field) {
|
||||||
$fields[] = $field['field'];
|
$fields[] = $field['field'];
|
||||||
if (! is_null( $field['value'] )) {
|
if (!is_null($field['value'])) {
|
||||||
switch ($field['type']) {
|
switch ($field['type']) {
|
||||||
case 'text':
|
case 'text':
|
||||||
case 'date':
|
case 'date':
|
||||||
$values[] = "'" . mysql_real_escape_string( $field['value'] ) . "'";
|
$values[] = "'" . mysqli_real_escape_string($this->oConnection, $field['value']) . "'";
|
||||||
break;
|
break;
|
||||||
case 'int':
|
case 'int':
|
||||||
default:
|
default:
|
||||||
$values[] = mysql_real_escape_string( $field['value'] );
|
$values[] = mysqli_real_escape_string($this->oConnection, $field['value']);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$values[] = $this->nullString;
|
$values[] = $this->nullString;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$fields = array_map( array ($this,'putQuotes'
|
$fields = array_map(array($this, 'putQuotes'
|
||||||
), $fields );
|
), $fields);
|
||||||
$sql = sprintf( "INSERT INTO %s (%s) VALUES (%s)", $this->putQuotes( $table ), implode( ', ', $fields ), implode( ', ', $values ) );
|
$sql = sprintf("INSERT INTO %s (%s) VALUES (%s)", $this->putQuotes($table), implode(', ', $fields), implode(', ', $values));
|
||||||
return $sql;
|
return $sql;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function generateUpdateSQL ($table, $keys, $data)
|
public function generateUpdateSQL($table, $keys, $data)
|
||||||
{
|
{
|
||||||
$fields = array ();
|
$fields = array();
|
||||||
$where = array ();
|
$where = array();
|
||||||
foreach ($data as $field) {
|
foreach ($data as $field) {
|
||||||
if (! is_null( $field['value'] )) {
|
if (!is_null($field['value'])) {
|
||||||
switch ($field['type']) {
|
switch ($field['type']) {
|
||||||
case 'text':
|
case 'text':
|
||||||
case 'date':
|
case 'date':
|
||||||
$fields[] = $this->putQuotes( $field['field'] ) . " = '" . mysql_real_escape_string( $field['value'] ) . "'";
|
$fields[] = $this->putQuotes($field['field']) . " = '" . mysqli_real_escape_string($this->oConnection, $field['value']) . "'";
|
||||||
break;
|
break;
|
||||||
case 'int':
|
case 'int':
|
||||||
default:
|
default:
|
||||||
$fields[] = $this->putQuotes( $field['field'] ) . " = " . mysql_real_escape_string( $field['value'] );
|
$fields[] = $this->putQuotes($field['field']) . " = " . mysqli_real_escape_string($this->oConnection, $field['value']);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$values[] = $this->nullString;
|
$values[] = $this->nullString;
|
||||||
}
|
}
|
||||||
if (in_array( $field['field'], $keys )) {
|
if (in_array($field['field'], $keys)) {
|
||||||
$where[] = $fields[count( $fields ) - 1];
|
$where[] = $fields[count($fields) - 1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$sql = sprintf( "UPDATE %s SET %s WHERE %s", $this->putQuotes( $table ), implode( ', ', $fields ), implode( ', ', $where ) );
|
$sql = sprintf("UPDATE %s SET %s WHERE %s", $this->putQuotes($table), implode(', ', $fields), implode(', ', $where));
|
||||||
return $sql;
|
return $sql;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function generateDeleteSQL ($table, $keys, $data)
|
public function generateDeleteSQL($table, $keys, $data)
|
||||||
{
|
{
|
||||||
$fields = array ();
|
$fields = array();
|
||||||
$where = array ();
|
$where = array();
|
||||||
foreach ($data as $field) {
|
foreach ($data as $field) {
|
||||||
if (in_array( $field['field'], $keys )) {
|
if (in_array($field['field'], $keys)) {
|
||||||
if (! is_null( $field['value'] )) {
|
if (!is_null($field['value'])) {
|
||||||
switch ($field['type']) {
|
switch ($field['type']) {
|
||||||
case 'text':
|
case 'text':
|
||||||
case 'date':
|
case 'date':
|
||||||
$where[] = $this->putQuotes( $field['field'] ) . " = '" . mysql_real_escape_string( $field['value'] ) . "'";
|
$where[] = $this->putQuotes($field['field']) . " = '" . mysqli_real_escape_string($this->oConnection, $field['value']) . "'";
|
||||||
break;
|
break;
|
||||||
case 'int':
|
case 'int':
|
||||||
default:
|
default:
|
||||||
$where[] = $this->putQuotes( $field['field'] ) . " = " . mysql_real_escape_string( $field['value'] );
|
$where[] = $this->putQuotes($field['field']) . " = " . mysqli_real_escape_string($this->oConnection, $field['value']);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -631,25 +632,25 @@ class database extends database_base
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$sql = sprintf( "DELETE FROM %s WHERE %s", $this->putQuotes( $table ), implode( ', ', $where ) );
|
$sql = sprintf("DELETE FROM %s WHERE %s", $this->putQuotes($table), implode(', ', $where));
|
||||||
return $sql;
|
return $sql;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function generateSelectSQL ($table, $keys, $data)
|
public function generateSelectSQL($table, $keys, $data)
|
||||||
{
|
{
|
||||||
$fields = array ();
|
$fields = array();
|
||||||
$where = array ();
|
$where = array();
|
||||||
foreach ($data as $field) {
|
foreach ($data as $field) {
|
||||||
if (in_array( $field['field'], $keys )) {
|
if (in_array($field['field'], $keys)) {
|
||||||
if (! is_null( $field['value'] )) {
|
if (!is_null($field['value'])) {
|
||||||
switch ($field['type']) {
|
switch ($field['type']) {
|
||||||
case 'text':
|
case 'text':
|
||||||
case 'date':
|
case 'date':
|
||||||
$where[] = $this->putQuotes( $field['field'] ) . " = '" . mysql_real_escape_string( $field['value'] ) . "'";
|
$where[] = $this->putQuotes($field['field']) . " = '" . mysqli_real_escape_string($this->oConnection, $field['value']) . "'";
|
||||||
break;
|
break;
|
||||||
case 'int':
|
case 'int':
|
||||||
default:
|
default:
|
||||||
$where[] = $this->putQuotes( $field['field'] ) . " = " . mysql_real_escape_string( $field['value'] );
|
$where[] = $this->putQuotes($field['field']) . " = " . mysqli_real_escape_string($this->oConnection, $field['value']);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -657,11 +658,11 @@ class database extends database_base
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$sql = sprintf( "SELECT * FROM %s WHERE %s", $this->putQuotes( $table ), implode( ', ', $where ) );
|
$sql = sprintf("SELECT * FROM %s WHERE %s", $this->putQuotes($table), implode(', ', $where));
|
||||||
return $sql;
|
return $sql;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function putQuotes ($element)
|
private function putQuotes($element)
|
||||||
{
|
{
|
||||||
return $this->sQuoteCharacter . $element . $this->sQuoteCharacter;
|
return $this->sQuoteCharacter . $element . $this->sQuoteCharacter;
|
||||||
}
|
}
|
||||||
@@ -676,14 +677,14 @@ class database extends database_base
|
|||||||
*
|
*
|
||||||
* @return string $sConcat
|
* @return string $sConcat
|
||||||
*/
|
*/
|
||||||
public function concatString ()
|
public function concatString()
|
||||||
{
|
{
|
||||||
$nums = func_num_args();
|
$nums = func_num_args();
|
||||||
$vars = func_get_args();
|
$vars = func_get_args();
|
||||||
|
|
||||||
$sConcat = " CONCAT(";
|
$sConcat = " CONCAT(";
|
||||||
for ($i = 0; $i < $nums; $i ++) {
|
for ($i = 0; $i < $nums; $i++) {
|
||||||
if (isset( $vars[$i] )) {
|
if (isset($vars[$i])) {
|
||||||
$sConcat .= $vars[$i];
|
$sConcat .= $vars[$i];
|
||||||
if (($i + 1) < $nums) {
|
if (($i + 1) < $nums) {
|
||||||
$sConcat .= ", ";
|
$sConcat .= ", ";
|
||||||
@@ -693,7 +694,6 @@ class database extends database_base
|
|||||||
$sConcat .= ")";
|
$sConcat .= ")";
|
||||||
|
|
||||||
return $sConcat;
|
return $sConcat;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -709,11 +709,10 @@ class database extends database_base
|
|||||||
*
|
*
|
||||||
* @return string $sCompare
|
* @return string $sCompare
|
||||||
*/
|
*/
|
||||||
public function getCaseWhen ($compareValue, $trueResult, $falseResult)
|
public function getCaseWhen($compareValue, $trueResult, $falseResult)
|
||||||
{
|
{
|
||||||
$sCompare = "IF(" . $compareValue . ", " . $trueResult . ", " . $falseResult . ") ";
|
$sCompare = "IF(" . $compareValue . ", " . $trueResult . ", " . $falseResult . ") ";
|
||||||
return $sCompare;
|
return $sCompare;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -724,7 +723,7 @@ class database extends database_base
|
|||||||
*
|
*
|
||||||
* @return string $sql
|
* @return string $sql
|
||||||
*/
|
*/
|
||||||
public function createTableObjectPermission ()
|
public function createTableObjectPermission()
|
||||||
{
|
{
|
||||||
$sql = "CREATE TABLE IF NOT EXISTS `OBJECT_PERMISSION` (
|
$sql = "CREATE TABLE IF NOT EXISTS `OBJECT_PERMISSION` (
|
||||||
`OP_UID` varchar(32) NOT NULL,
|
`OP_UID` varchar(32) NOT NULL,
|
||||||
@@ -754,9 +753,8 @@ class database extends database_base
|
|||||||
*
|
*
|
||||||
* @return string $sql
|
* @return string $sql
|
||||||
*/
|
*/
|
||||||
public function getSelectReport4 ()
|
public function getSelectReport4()
|
||||||
{
|
{
|
||||||
|
|
||||||
$sqlConcat = " CONCAT(U.USR_LASTNAME,' ',USR_FIRSTNAME) AS USER ";
|
$sqlConcat = " CONCAT(U.USR_LASTNAME,' ',USR_FIRSTNAME) AS USER ";
|
||||||
$sqlGroupBy = " USER ";
|
$sqlGroupBy = " USER ";
|
||||||
|
|
||||||
@@ -772,7 +770,6 @@ class database extends database_base
|
|||||||
GROUP BY " . $sqlGroupBy;
|
GROUP BY " . $sqlGroupBy;
|
||||||
|
|
||||||
return $sql;
|
return $sql;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -783,7 +780,7 @@ class database extends database_base
|
|||||||
*
|
*
|
||||||
* @return string $sql
|
* @return string $sql
|
||||||
*/
|
*/
|
||||||
public function getSelectReport4Filter ($var)
|
public function getSelectReport4Filter($var)
|
||||||
{
|
{
|
||||||
$sqlConcat = " CONCAT(U.USR_LASTNAME,' ',USR_FIRSTNAME) AS USER ";
|
$sqlConcat = " CONCAT(U.USR_LASTNAME,' ',USR_FIRSTNAME) AS USER ";
|
||||||
$sqlGroupBy = " USER ";
|
$sqlGroupBy = " USER ";
|
||||||
@@ -800,7 +797,6 @@ class database extends database_base
|
|||||||
GROUP BY " . $sqlGroupBy;
|
GROUP BY " . $sqlGroupBy;
|
||||||
|
|
||||||
return $sql;
|
return $sql;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -811,7 +807,7 @@ class database extends database_base
|
|||||||
*
|
*
|
||||||
* @return string $sql
|
* @return string $sql
|
||||||
*/
|
*/
|
||||||
public function getSelectReport5 ()
|
public function getSelectReport5()
|
||||||
{
|
{
|
||||||
$sqlConcat = " CONCAT(U.USR_LASTNAME,' ',USR_FIRSTNAME) AS USER ";
|
$sqlConcat = " CONCAT(U.USR_LASTNAME,' ',USR_FIRSTNAME) AS USER ";
|
||||||
$sqlGroupBy = " USER ";
|
$sqlGroupBy = " USER ";
|
||||||
@@ -828,7 +824,6 @@ class database extends database_base
|
|||||||
GROUP BY " . $sqlGroupBy;
|
GROUP BY " . $sqlGroupBy;
|
||||||
|
|
||||||
return $sql;
|
return $sql;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -839,9 +834,8 @@ class database extends database_base
|
|||||||
*
|
*
|
||||||
* @return string $sql
|
* @return string $sql
|
||||||
*/
|
*/
|
||||||
public function getSelectReport5Filter ($var)
|
public function getSelectReport5Filter($var)
|
||||||
{
|
{
|
||||||
|
|
||||||
$sqlConcat = " CONCAT(U.USR_LASTNAME,' ',USR_FIRSTNAME) AS USER ";
|
$sqlConcat = " CONCAT(U.USR_LASTNAME,' ',USR_FIRSTNAME) AS USER ";
|
||||||
$sqlGroupBy = " USER ";
|
$sqlGroupBy = " USER ";
|
||||||
|
|
||||||
@@ -863,41 +857,39 @@ class database extends database_base
|
|||||||
* query functions for class class.net.php
|
* query functions for class class.net.php
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function getServerVersion ($driver, $dbIP, $dbPort, $dbUser, $dbPasswd, $dbSourcename)
|
public function getServerVersion($driver, $dbIP, $dbPort, $dbUser, $dbPasswd, $dbSourcename)
|
||||||
{
|
{
|
||||||
|
if ($link = mysqli_connect($dbIP, $dbUser, $dbPasswd, $dbSourcename)) {
|
||||||
if ($link = @mysql_connect( $dbIP, $dbUser, $dbPasswd )) {
|
$v = mysqli_get_server_info($link);
|
||||||
$v = @mysql_get_server_info();
|
|
||||||
} else {
|
} else {
|
||||||
throw new Exception( @mysql_error( $link ) );
|
throw new Exception(mysqli_error($link));
|
||||||
}
|
}
|
||||||
return (isset( $v )) ? $v : 'none';
|
return (isset($v)) ? $v : 'none';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* query functions for class class.net.php, class.reportTables.php
|
* query functions for class class.net.php, class.reportTables.php
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function getDropTable ($sTableName)
|
public function getDropTable($sTableName)
|
||||||
{
|
{
|
||||||
$sql = 'DROP TABLE IF EXISTS `' . $sTableName . '`';
|
$sql = 'DROP TABLE IF EXISTS `' . $sTableName . '`';
|
||||||
return $sql;
|
return $sql;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTableDescription ($sTableName)
|
public function getTableDescription($sTableName)
|
||||||
{
|
{
|
||||||
$sql = "DESC " . $sTableName;
|
$sql = "DESC " . $sTableName;
|
||||||
return $sql;
|
return $sql;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFieldNull ()
|
public function getFieldNull()
|
||||||
{
|
{
|
||||||
$fieldName = "Null";
|
$fieldName = "Null";
|
||||||
return $fieldName;
|
return $fieldName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getValidate ($validate)
|
public function getValidate($validate)
|
||||||
{
|
{
|
||||||
$oValidate = $validate;
|
$oValidate = $validate;
|
||||||
return $oValidate;
|
return $oValidate;
|
||||||
@@ -907,14 +899,14 @@ class database extends database_base
|
|||||||
* Determines whether a table exists
|
* Determines whether a table exists
|
||||||
* It is part of class.reportTables.php
|
* It is part of class.reportTables.php
|
||||||
*/
|
*/
|
||||||
public function reportTableExist ()
|
public function reportTableExist()
|
||||||
{
|
{
|
||||||
$filter = new InputFilter();
|
$filter = new InputFilter();
|
||||||
$DB_NAME = $filter->validateInput(DB_NAME);
|
$DB_NAME = $filter->validateInput(DB_NAME);
|
||||||
$bExists = true;
|
$bExists = true;
|
||||||
$oConnection = mysql_connect( DB_HOST, DB_USER, DB_PASS );
|
$oConnection = mysqli_connect(DB_HOST, DB_USER, DB_PASS);
|
||||||
mysql_select_db( $DB_NAME );
|
mysqli_select_db($oConnection, $DB_NAME);
|
||||||
$oDataset = mysql_query( 'SELECT COUNT(*) FROM REPORT_TABLE' ) || ($bExists = false);
|
$oDataset = mysqli_query($oConnection, 'SELECT COUNT(*) FROM REPORT_TABLE') || ($bExists = false);
|
||||||
|
|
||||||
return $bExists;
|
return $bExists;
|
||||||
}
|
}
|
||||||
@@ -922,7 +914,7 @@ class database extends database_base
|
|||||||
/**
|
/**
|
||||||
* It is part of class.pagedTable.php
|
* It is part of class.pagedTable.php
|
||||||
*/
|
*/
|
||||||
public function getLimitRenderTable ($nCurrentPage, $nRowsPerPage)
|
public function getLimitRenderTable($nCurrentPage, $nRowsPerPage)
|
||||||
{
|
{
|
||||||
$sql = ' LIMIT ' . (($nCurrentPage - 1) * $nRowsPerPage) . ', ' . $nRowsPerPage;
|
$sql = ' LIMIT ' . (($nCurrentPage - 1) * $nRowsPerPage) . ', ' . $nRowsPerPage;
|
||||||
return $sql;
|
return $sql;
|
||||||
@@ -930,32 +922,23 @@ class database extends database_base
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Determining the existence of a table
|
* Determining the existence of a table
|
||||||
|
*
|
||||||
|
* @param string $tableName
|
||||||
|
* @param string $database
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function tableExists ($tableName, $database)
|
public function tableExists($tableName, $database)
|
||||||
{
|
{
|
||||||
@mysql_select_db( $database );
|
mysqli_select_db($this->oConnection, $database);
|
||||||
$tables = array ();
|
$tables = array();
|
||||||
$tablesResult = mysql_query( "SHOW TABLES FROM $database;" );
|
$tablesResult = mysqli_query($this->oConnection, "SHOW TABLES FROM $database;");
|
||||||
while ($row = @mysql_fetch_row( $tablesResult )) {
|
while ($row = mysqli_fetch_row($tablesResult)) {
|
||||||
$tables[] = $row[0];
|
$tables[] = $row[0];
|
||||||
}
|
}
|
||||||
if (in_array( $tableName, $tables )) {
|
if (in_array($tableName, $tables)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Determining the existence of a table (Depricated)
|
|
||||||
*/
|
|
||||||
// function tableExists ($table, $db) {
|
|
||||||
// $tables = mysql_list_tables ($db);
|
|
||||||
// while (list ($temp) = @mysql_fetch_array ($tables)) {
|
|
||||||
// if ($temp == $table) {
|
|
||||||
// return TRUE;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// return FALSE;
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,6 @@
|
|||||||
*
|
*
|
||||||
* @package gulliver.system
|
* @package gulliver.system
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class DataBaseMaintenance
|
class DataBaseMaintenance
|
||||||
{
|
{
|
||||||
private $host;
|
private $host;
|
||||||
@@ -60,13 +59,13 @@ class DataBaseMaintenance
|
|||||||
*
|
*
|
||||||
* @return none
|
* @return none
|
||||||
*/
|
*/
|
||||||
public function __construct ($host = null, $user = null, $passwd = null)
|
public function __construct($host = null, $user = null, $passwd = null)
|
||||||
{
|
{
|
||||||
$this->tmpDir = './';
|
$this->tmpDir = './';
|
||||||
$this->link = null;
|
$this->link = null;
|
||||||
$this->dbName = null;
|
$this->dbName = null;
|
||||||
$this->isWindows = strtoupper(substr(PHP_OS, 0, 3)) === 'WIN';
|
$this->isWindows = strtoupper(substr(PHP_OS, 0, 3)) === 'WIN';
|
||||||
if (isset( $host ) && isset( $user ) && isset( $passwd )) {
|
if (isset($host) && isset($user) && isset($passwd)) {
|
||||||
$this->host = $host;
|
$this->host = $host;
|
||||||
$this->user = $user;
|
$this->user = $user;
|
||||||
$this->passwd = $passwd;
|
$this->passwd = $passwd;
|
||||||
@@ -80,7 +79,7 @@ class DataBaseMaintenance
|
|||||||
*
|
*
|
||||||
* @return none
|
* @return none
|
||||||
*/
|
*/
|
||||||
public function setUser ($user)
|
public function setUser($user)
|
||||||
{
|
{
|
||||||
$this->user = $user;
|
$this->user = $user;
|
||||||
}
|
}
|
||||||
@@ -92,7 +91,7 @@ class DataBaseMaintenance
|
|||||||
*
|
*
|
||||||
* @return none
|
* @return none
|
||||||
*/
|
*/
|
||||||
public function setPasswd ($passwd)
|
public function setPasswd($passwd)
|
||||||
{
|
{
|
||||||
$this->passwd = $passwd;
|
$this->passwd = $passwd;
|
||||||
}
|
}
|
||||||
@@ -104,7 +103,7 @@ class DataBaseMaintenance
|
|||||||
*
|
*
|
||||||
* @return none
|
* @return none
|
||||||
*/
|
*/
|
||||||
public function setHost ($host)
|
public function setHost($host)
|
||||||
{
|
{
|
||||||
$this->host = $host;
|
$this->host = $host;
|
||||||
}
|
}
|
||||||
@@ -116,11 +115,11 @@ class DataBaseMaintenance
|
|||||||
*
|
*
|
||||||
* @return none
|
* @return none
|
||||||
*/
|
*/
|
||||||
public function setTempDir ($tmpDir)
|
public function setTempDir($tmpDir)
|
||||||
{
|
{
|
||||||
$this->tmpDir = $tmpDir;
|
$this->tmpDir = $tmpDir;
|
||||||
if (! file_exists( $tmpDir )) {
|
if (!file_exists($tmpDir)) {
|
||||||
mkdir( $this->tmpDir );
|
mkdir($this->tmpDir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,7 +128,7 @@ class DataBaseMaintenance
|
|||||||
*
|
*
|
||||||
* @return $this->tmpDir
|
* @return $this->tmpDir
|
||||||
*/
|
*/
|
||||||
public function getTempDir ()
|
public function getTempDir()
|
||||||
{
|
{
|
||||||
return $this->tmpDir;
|
return $this->tmpDir;
|
||||||
}
|
}
|
||||||
@@ -139,7 +138,7 @@ class DataBaseMaintenance
|
|||||||
*
|
*
|
||||||
* @return $this->link
|
* @return $this->link
|
||||||
*/
|
*/
|
||||||
public function status ()
|
public function status()
|
||||||
{
|
{
|
||||||
return $$this->link;
|
return $$this->link;
|
||||||
}
|
}
|
||||||
@@ -151,25 +150,25 @@ class DataBaseMaintenance
|
|||||||
*
|
*
|
||||||
* @return none
|
* @return none
|
||||||
*/
|
*/
|
||||||
public function connect ($dbname = null)
|
public function connect($dbname = null)
|
||||||
{
|
{
|
||||||
if ($this->link != null) {
|
if ($this->link != null) {
|
||||||
mysql_close( $this->link );
|
mysqli_close($this->link);
|
||||||
$this->link = null;
|
$this->link = null;
|
||||||
}
|
}
|
||||||
if (isset( $dbname )) {
|
if (isset($dbname)) {
|
||||||
$this->dbName = $dbname;
|
$this->dbName = $dbname;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->link = mysql_connect( $this->host, $this->user, $this->passwd );
|
$this->link = mysqli_connect($this->host, $this->user, $this->passwd, $this->dbName);
|
||||||
@mysql_query( "SET NAMES 'utf8';" );
|
if (!$this->link) {
|
||||||
@mysql_query( "SET FOREIGN_KEY_CHECKS=0;" );
|
throw new Exception("Couldn't connect to host {$this->host} with user {$this->user}");
|
||||||
if (! $this->link) {
|
|
||||||
throw new Exception( "Couldn't connect to host {$this->host} with user {$this->user}" );
|
|
||||||
}
|
}
|
||||||
|
mysqli_query($this->link, "SET NAMES 'utf8';");
|
||||||
|
mysqli_query($this->link, "SET FOREIGN_KEY_CHECKS=0;");
|
||||||
|
|
||||||
if ($this->dbName != null) {
|
if ($this->dbName != null) {
|
||||||
$this->selectDataBase( $this->dbName );
|
$this->selectDataBase($this->dbName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -180,7 +179,7 @@ class DataBaseMaintenance
|
|||||||
*
|
*
|
||||||
* @return none
|
* @return none
|
||||||
*/
|
*/
|
||||||
public function setDbName ($dbname)
|
public function setDbName($dbname)
|
||||||
{
|
{
|
||||||
$this->dbName = $dbname;
|
$this->dbName = $dbname;
|
||||||
}
|
}
|
||||||
@@ -189,14 +188,15 @@ class DataBaseMaintenance
|
|||||||
* selectDataBase
|
* selectDataBase
|
||||||
*
|
*
|
||||||
* @param string $dbname
|
* @param string $dbname
|
||||||
|
* @param $dbname
|
||||||
*
|
*
|
||||||
* @return none
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function selectDataBase ($dbname)
|
public function selectDataBase($dbname)
|
||||||
{
|
{
|
||||||
$this->setDbName( $dbname );
|
$this->setDbName($dbname);
|
||||||
if (! @mysql_select_db( $this->dbName, $this->link )) {
|
if (!mysqli_select_db($this->link, $this->dbName)) {
|
||||||
throw new Exception( "Couldn't select database $dbname" );
|
throw new Exception("Couldn't select database $dbname");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -207,13 +207,13 @@ class DataBaseMaintenance
|
|||||||
*
|
*
|
||||||
* @return $aRows
|
* @return $aRows
|
||||||
*/
|
*/
|
||||||
public function query ($sql)
|
public function query($sql)
|
||||||
{
|
{
|
||||||
$this->result = @mysql_query( $sql );
|
$this->result = mysqli_query($this->link, $sql);
|
||||||
if ($this->result) {
|
if ($this->result) {
|
||||||
$aRows = Array ();
|
$aRows = [];
|
||||||
while ($aRow = @mysql_fetch_assoc( $this->result )) {
|
while ($aRow = mysqli_fetch_assoc($this->result)) {
|
||||||
array_push( $aRows, $aRow );
|
$aRows[] = $aRow;
|
||||||
}
|
}
|
||||||
return $aRows;
|
return $aRows;
|
||||||
} else {
|
} else {
|
||||||
@@ -224,26 +224,26 @@ class DataBaseMaintenance
|
|||||||
/**
|
/**
|
||||||
* error
|
* error
|
||||||
*
|
*
|
||||||
* @return @mysql_error()
|
* @return mysqli_error()
|
||||||
*/
|
*/
|
||||||
public function error ()
|
public function error()
|
||||||
{
|
{
|
||||||
return @mysql_error( $this->link );
|
return mysqli_error($this->link);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getTablesList
|
* getTablesList
|
||||||
*
|
*
|
||||||
* @return $aRows
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getTablesList ()
|
public function getTablesList()
|
||||||
{
|
{
|
||||||
$this->result = @mysql_query( "SHOW TABLES;" );
|
$this->result = mysqli_query($this->link, 'SHOW TABLES;');
|
||||||
$aRows = Array ();
|
$rows = [];
|
||||||
while ($aRow = mysql_fetch_row( $this->result )) {
|
while ($row = mysqli_fetch_row($this->result)) {
|
||||||
array_push( $aRows, $aRow[0] );
|
$rows[] = $row[0];
|
||||||
}
|
}
|
||||||
return $aRows;
|
return $rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -253,24 +253,24 @@ class DataBaseMaintenance
|
|||||||
*
|
*
|
||||||
* @return boolean true or false
|
* @return boolean true or false
|
||||||
*/
|
*/
|
||||||
function dumpData ($table)
|
public function dumpData($table)
|
||||||
{
|
{
|
||||||
$this->outfile = $this->tmpDir . $table . '.dump';
|
$this->outfile = $this->tmpDir . $table . '.dump';
|
||||||
|
|
||||||
//if the file exists delete it
|
//if the file exists delete it
|
||||||
if (is_file( $this->outfile )) {
|
if (is_file($this->outfile)) {
|
||||||
@unlink( $this->outfile );
|
@unlink($this->outfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = "SELECT * INTO OUTFILE '{$this->outfile}' FIELDS TERMINATED BY '\t|\t' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\t\t\r\r\n' FROM $table";
|
$sql = "SELECT * INTO OUTFILE '{$this->outfile}' FIELDS TERMINATED BY '\t|\t' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\t\t\r\r\n' FROM $table";
|
||||||
// The mysql_escape_string function has been DEPRECATED as of PHP 5.3.0.
|
// The mysql_escape_string function has been DEPRECATED as of PHP 5.3.0.
|
||||||
// Commented that is not assigned to a variable.
|
// Commented that is not assigned to a variable.
|
||||||
// mysql_escape_string("';");
|
// mysql_escape_string("';");
|
||||||
if (! @mysql_query( $sql )) {
|
if (!@mysqli_query($this->link, $sql)) {
|
||||||
$ws = (!empty(config("system.workspace")))? config("system.workspace") : "Undefined Workspace";
|
$ws = (!empty(config('system.workspace'))) ? config('system.workspace') : 'Undefined Workspace';
|
||||||
Bootstrap::registerMonolog('MysqlCron', 400, mysql_error(), array('sql'=>$sql), $ws, 'processmaker.log');
|
Bootstrap::registerMonolog('MysqlCron', 400, mysqli_error($this->link), ['sql' => $sql], $ws, 'processmaker.log');
|
||||||
$varRes = mysql_error() . "\n";
|
$varRes = mysqli_error($this->link) . "\n";
|
||||||
G::outRes( $varRes );
|
G::outRes($varRes);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -283,15 +283,15 @@ class DataBaseMaintenance
|
|||||||
*
|
*
|
||||||
* @return boolean true or false
|
* @return boolean true or false
|
||||||
*/
|
*/
|
||||||
function restoreData ($backupFile)
|
public function restoreData($backupFile)
|
||||||
{
|
{
|
||||||
$tableName = str_replace( '.dump', '', basename( $backupFile ) );
|
$tableName = str_replace('.dump', '', basename($backupFile));
|
||||||
$sql = "LOAD DATA INFILE '$backupFile' INTO TABLE $tableName FIELDS TERMINATED BY '\t|\t' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\t\t\r\r\n'";
|
$sql = "LOAD DATA INFILE '$backupFile' INTO TABLE $tableName FIELDS TERMINATED BY '\t|\t' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\t\t\r\r\n'";
|
||||||
if (! @mysql_query( $sql )) {
|
if (!@mysqli_query($this->link, $sql)) {
|
||||||
$ws = (!empty(config("system.workspace")))? config("system.workspace") : "Undefined Workspace";
|
$ws = (!empty(config("system.workspace"))) ? config("system.workspace") : "Wokspace Undefined";
|
||||||
Bootstrap::registerMonolog('MysqlCron', 400, mysql_error(), array('sql'=>$sql), $ws, 'processmaker.log');
|
Bootstrap::registerMonolog('MysqlCron', 400, mysqli_error($this->link), ['sql' => $sql], $ws, 'processmaker.log');
|
||||||
$varRes = mysql_error() . "\n";
|
$varRes = mysqli_error($this->link) . "\n";
|
||||||
G::outRes( $varRes );
|
G::outRes($varRes);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -304,26 +304,25 @@ class DataBaseMaintenance
|
|||||||
*
|
*
|
||||||
* @return none
|
* @return none
|
||||||
*/
|
*/
|
||||||
function restoreAllData ($type = null)
|
public function restoreAllData($type = null)
|
||||||
{
|
{
|
||||||
|
|
||||||
$aTables = $this->getTablesList();
|
$aTables = $this->getTablesList();
|
||||||
|
|
||||||
foreach ($aTables as $table) {
|
foreach ($aTables as $table) {
|
||||||
if (isset( $type ) && $type == 'sql') {
|
if (isset($type) && $type == 'sql') {
|
||||||
$this->infile = $this->tmpDir . $table . ".sql";
|
$this->infile = $this->tmpDir . $table . ".sql";
|
||||||
if (is_file( $this->infile )) {
|
if (is_file($this->infile)) {
|
||||||
$queries = $this->restoreFromSql( $this->infile, true );
|
$queries = $this->restoreFromSql($this->infile, true);
|
||||||
if (! isset( $queries )) {
|
if (!isset($queries)) {
|
||||||
$queries = "unknown";
|
$queries = "unknown";
|
||||||
}
|
}
|
||||||
printf( "%-59s%20s", "Restored table $table", "$queries queries\n" );
|
printf("%-59s%20s", "Restored table $table", "$queries queries\n");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$this->infile = $this->tmpDir . $table . ".dump";
|
$this->infile = $this->tmpDir . $table . ".dump";
|
||||||
if (is_file( $this->infile )) {
|
if (is_file($this->infile)) {
|
||||||
$this->restoreData( $this->infile );
|
$this->restoreData($this->infile);
|
||||||
printf( "%20s %s %s\n", 'Restoring data from ', $this->infile, " in table $table" );
|
printf("%20s %s %s\n", 'Restoring data from ', $this->infile, " in table $table");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -337,17 +336,17 @@ class DataBaseMaintenance
|
|||||||
*
|
*
|
||||||
* @return none
|
* @return none
|
||||||
*/
|
*/
|
||||||
function createDb ($dbname, $drop = false)
|
public function createDb($dbname, $drop = false)
|
||||||
{
|
{
|
||||||
if ($drop) {
|
if ($drop) {
|
||||||
$sql = "DROP DATABASE IF EXISTS $dbname;";
|
$sql = "DROP DATABASE IF EXISTS $dbname;";
|
||||||
if (! @mysql_query( $sql )) {
|
if (!mysqli_query($this->link, $sql)) {
|
||||||
throw new Exception( mysql_error() );
|
throw new Exception(mysqli_error($this->link));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$sql = "CREATE DATABASE IF NOT EXISTS $dbname DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;";
|
$sql = "CREATE DATABASE IF NOT EXISTS $dbname DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;";
|
||||||
if (! @mysql_query( $sql )) {
|
if (!mysqli_query($this->link, $sql)) {
|
||||||
throw new Exception( mysql_error() );
|
throw new Exception(mysqli_error($this->link));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -358,24 +357,23 @@ class DataBaseMaintenance
|
|||||||
*
|
*
|
||||||
* @return none
|
* @return none
|
||||||
*/
|
*/
|
||||||
function restoreFromSql2 ($sqlfile)
|
public function restoreFromSql2($sqlfile)
|
||||||
{
|
{
|
||||||
|
ini_set('memory_limit', '512M');
|
||||||
ini_set( 'memory_limit', '512M' );
|
if (!is_file($sqlfile)) {
|
||||||
if (! is_file( $sqlfile )) {
|
throw new Exception("the $sqlfile doesn't exist!");
|
||||||
throw new Exception( "the $sqlfile doesn't exist!" );
|
|
||||||
}
|
}
|
||||||
$query = file_get_contents( $sqlfile );
|
$query = file_get_contents($sqlfile);
|
||||||
$mysqli = new mysqli( $this->host, $this->user, $this->passwd, $this->dbName );
|
$mysqli = new mysqli($this->host, $this->user, $this->passwd, $this->dbName);
|
||||||
|
|
||||||
/* check connection */
|
/* check connection */
|
||||||
if (mysqli_connect_errno()) {
|
if (mysqli_connect_errno()) {
|
||||||
printf( "Connect failed: %s\n", mysqli_connect_error() );
|
printf("Connect failed: %s\n", mysqli_connect_error());
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* execute multi query */
|
/* execute multi query */
|
||||||
if ($mysqli->multi_query( $query )) {
|
if ($mysqli->multi_query($query)) {
|
||||||
do {
|
do {
|
||||||
/* store first result set */
|
/* store first result set */
|
||||||
if ($result = $mysqli->store_result()) {
|
if ($result = $mysqli->store_result()) {
|
||||||
@@ -383,7 +381,6 @@ class DataBaseMaintenance
|
|||||||
}
|
}
|
||||||
$result->free();
|
$result->free();
|
||||||
}
|
}
|
||||||
|
|
||||||
} while ($mysqli->next_result());
|
} while ($mysqli->next_result());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -398,7 +395,7 @@ class DataBaseMaintenance
|
|||||||
*
|
*
|
||||||
* @return none
|
* @return none
|
||||||
*/
|
*/
|
||||||
function backupDataBase ($outfile)
|
public function backupDataBase($outfile)
|
||||||
{
|
{
|
||||||
$password = escapeshellarg($this->passwd);
|
$password = escapeshellarg($this->passwd);
|
||||||
|
|
||||||
@@ -489,57 +486,56 @@ class DataBaseMaintenance
|
|||||||
*
|
*
|
||||||
* @return boolean false or true
|
* @return boolean false or true
|
||||||
*/
|
*/
|
||||||
function restoreFromSql ($sqlfile, $type = 'file')
|
public function restoreFromSql($sqlfile, $type = 'file')
|
||||||
{
|
{
|
||||||
ini_set( 'memory_limit', '64M' );
|
ini_set('memory_limit', '64M');
|
||||||
if ($type == 'file' && ! is_file( $sqlfile )) {
|
if ($type == 'file' && !is_file($sqlfile)) {
|
||||||
throw new Exception( "the $sqlfile doesn't exist!" );
|
throw new Exception("the $sqlfile doesn't exist!");
|
||||||
}
|
}
|
||||||
|
|
||||||
$metaFile = str_replace( '.sql', '.meta', $sqlfile );
|
$metaFile = str_replace('.sql', '.meta', $sqlfile);
|
||||||
|
|
||||||
$queries = 0;
|
$queries = 0;
|
||||||
|
|
||||||
if (is_file( $metaFile )) {
|
if (is_file($metaFile)) {
|
||||||
echo "Using $metaFile as metadata.\n";
|
echo "Using $metaFile as metadata.\n";
|
||||||
$fp = fopen( $sqlfile, 'rb' );
|
$fp = fopen($sqlfile, 'rb');
|
||||||
$fpmd = fopen( $metaFile, 'r' );
|
$fpmd = fopen($metaFile, 'r');
|
||||||
while ($offset = fgets( $fpmd, 1024 )) {
|
while ($offset = fgets($fpmd, 1024)) {
|
||||||
$buffer = intval( $offset ); //reading the size of $oData
|
$buffer = intval($offset); //reading the size of $oData
|
||||||
$query = fread( $fp, $buffer ); //reading string $oData
|
$query = fread($fp, $buffer); //reading string $oData
|
||||||
$queries += 1;
|
$queries += 1;
|
||||||
|
|
||||||
if (! @mysql_query( $query )) {
|
if (!mysqli_query($this->link, $query)) {
|
||||||
$varRes = mysql_error() . "\n";
|
$varRes = mysqli_error($this->link) . "\n";
|
||||||
G::outRes( $varRes );
|
G::outRes($varRes);
|
||||||
$varRes = "==>" . $query . "<==\n";
|
$varRes = "==>" . $query . "<==\n";
|
||||||
G::outRes( $varRes );
|
G::outRes($varRes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$queries = null;
|
$queries = null;
|
||||||
try {
|
try {
|
||||||
$mysqli = new mysqli( $this->host, $this->user, $this->passwd, $this->dbName );
|
$mysqli = new mysqli($this->host, $this->user, $this->passwd, $this->dbName);
|
||||||
/* check connection */
|
/* check connection */
|
||||||
if (mysqli_connect_errno()) {
|
if (mysqli_connect_errno()) {
|
||||||
printf( "Connect failed: %s\n", mysqli_connect_error() );
|
printf("Connect failed: %s\n", mysqli_connect_error());
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
if ($type == 'file') {
|
if ($type === 'file') {
|
||||||
$query = file_get_contents( $sqlfile );
|
$query = file_get_contents($sqlfile);
|
||||||
} else if ($type == 'string') {
|
} elseif ($type === 'string') {
|
||||||
$query = $sqlfile;
|
$query = $sqlfile;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (trim( $query ) == "") {
|
if (trim($query) == "") {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* execute multi query */
|
/* execute multi query */
|
||||||
if ($mysqli->multi_query( $query )) {
|
if ($mysqli->multi_query($query)) {
|
||||||
do {
|
do {
|
||||||
/* store first result set */
|
/* store first result set */
|
||||||
if ($result = $mysqli->store_result()) {
|
if ($result = $mysqli->store_result()) {
|
||||||
@@ -554,7 +550,7 @@ class DataBaseMaintenance
|
|||||||
}
|
}
|
||||||
} while ($mysqli->next_result());
|
} while ($mysqli->next_result());
|
||||||
} else {
|
} else {
|
||||||
throw new Exception( mysqli_error( $mysqli ) );
|
throw new Exception(mysqli_error($mysqli));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* close connection */
|
/* close connection */
|
||||||
@@ -563,7 +559,7 @@ class DataBaseMaintenance
|
|||||||
echo $query;
|
echo $query;
|
||||||
$token = strtotime("now");
|
$token = strtotime("now");
|
||||||
PMException::registerErrorLog($e, $token);
|
PMException::registerErrorLog($e, $token);
|
||||||
G::outRes( G::LoadTranslation("ID_EXCEPTION_LOG_INTERFAZ", array($token)) );
|
G::outRes(G::LoadTranslation("ID_EXCEPTION_LOG_INTERFAZ", array($token)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $queries;
|
return $queries;
|
||||||
@@ -576,20 +572,20 @@ class DataBaseMaintenance
|
|||||||
*
|
*
|
||||||
* @return string $tableSchema
|
* @return string $tableSchema
|
||||||
*/
|
*/
|
||||||
function getSchemaFromTable ($tablename)
|
public function getSchemaFromTable($tablename)
|
||||||
{
|
{
|
||||||
//$tableSchema = "/* Structure for table `$tablename` */\n";
|
//$tableSchema = "/* Structure for table `$tablename` */\n";
|
||||||
//$tableSchema .= "DROP TABLE IF EXISTS `$tablename`;\n\n";
|
//$tableSchema .= "DROP TABLE IF EXISTS `$tablename`;\n\n";
|
||||||
$tableSchema = "";
|
$tableSchema = "";
|
||||||
$sql = "show create table `$tablename`; ";
|
$sql = "show create table `$tablename`; ";
|
||||||
$result = @mysql_query( $sql );
|
$result = mysqli_query($this->link, $sql);
|
||||||
if ($result) {
|
if ($result) {
|
||||||
if ($row = mysql_fetch_assoc( $result )) {
|
if ($row = mysqli_fetch_assoc($result)) {
|
||||||
$tableSchema .= $row['Create Table'] . ";\n\n";
|
$tableSchema .= $row['Create Table'] . ";\n\n";
|
||||||
}
|
}
|
||||||
mysql_free_result( $result );
|
mysqli_free_result($result);
|
||||||
} else {
|
} else {
|
||||||
G::outRes( mysql_error() );
|
G::outRes(mysqli_error($this->link));
|
||||||
}
|
}
|
||||||
return $tableSchema;
|
return $tableSchema;
|
||||||
}
|
}
|
||||||
@@ -601,12 +597,12 @@ class DataBaseMaintenance
|
|||||||
*
|
*
|
||||||
* @return string $str
|
* @return string $str
|
||||||
*/
|
*/
|
||||||
function removeCommentsIntoString ($str)
|
public function removeCommentsIntoString($str)
|
||||||
{
|
{
|
||||||
$str = preg_replace( '/\/\*[\w\W]*\*\//', '', $str );
|
$str = preg_replace('/\/\*[\w\W]*\*\//', '', $str);
|
||||||
$str = preg_replace( "/--[\w\W]*\\n/", '', $str );
|
$str = preg_replace("/--[\w\W]*\\n/", '', $str);
|
||||||
$str = preg_replace( "/\/\/[\w\W]*\\n/", '', $str );
|
$str = preg_replace("/\/\/[\w\W]*\\n/", '', $str);
|
||||||
$str = preg_replace( "/\#[\w\W]*\\n/", '', $str );
|
$str = preg_replace("/\#[\w\W]*\\n/", '', $str);
|
||||||
return $str;
|
return $str;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -31,13 +31,13 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require_once ("DB.php");
|
require_once("DB.php");
|
||||||
|
|
||||||
define( 'DB_ERROR_NO_SHOW_AND_CONTINUE', 0 );
|
define('DB_ERROR_NO_SHOW_AND_CONTINUE', 0);
|
||||||
define( 'DB_ERROR_SHOW_AND_STOP', 1 );
|
define('DB_ERROR_SHOW_AND_STOP', 1);
|
||||||
define( 'DB_ERROR_SHOW_AND_CONTINUE', 2 );
|
define('DB_ERROR_SHOW_AND_CONTINUE', 2);
|
||||||
define( 'DB_ERROR_SHOWALL_AND_STOP', 3 );
|
define('DB_ERROR_SHOWALL_AND_STOP', 3);
|
||||||
define( 'DB_ERROR_SHOWALL_AND_CONTINUE', 4 );
|
define('DB_ERROR_SHOWALL_AND_CONTINUE', 4);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DBConnection class definition
|
* DBConnection class definition
|
||||||
@@ -49,10 +49,10 @@ define( 'DB_ERROR_SHOWALL_AND_CONTINUE', 4 );
|
|||||||
*/
|
*/
|
||||||
class DBConnection
|
class DBConnection
|
||||||
{
|
{
|
||||||
var $db;
|
public $db;
|
||||||
var $db_error;
|
public $db_error;
|
||||||
var $errorLevel;
|
public $errorLevel;
|
||||||
var $type;
|
public $type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ***************************************************************
|
* ***************************************************************
|
||||||
@@ -93,7 +93,7 @@ class DBConnection
|
|||||||
* @return string
|
* @return string
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function DBConnection ($strServer = DB_HOST, $strUser = DB_USER, $strPwd = DB_PASS, $strDB = DB_NAME, $type = DB_ADAPTER, $strPort = 0, $errorLevel = 2)
|
public function DBConnection($strServer = DB_HOST, $strUser = DB_USER, $strPwd = DB_PASS, $strDB = DB_NAME, $type = DB_ADAPTER, $strPort = 0, $errorLevel = 2)
|
||||||
{
|
{
|
||||||
$this->errorLevel = $errorLevel;
|
$this->errorLevel = $errorLevel;
|
||||||
if ($type == null) {
|
if ($type == null) {
|
||||||
@@ -101,36 +101,41 @@ class DBConnection
|
|||||||
}
|
}
|
||||||
$this->type = $type;
|
$this->type = $type;
|
||||||
//print "<hr>$type $strServer, $strUser, $strPwd, $strDB <hr>";
|
//print "<hr>$type $strServer, $strUser, $strPwd, $strDB <hr>";
|
||||||
if ($type == "mysql") {
|
switch ($type) {
|
||||||
|
case 'mysql':
|
||||||
$dsn = "mysql://$strUser:$strPwd@$strServer/$strDB";
|
$dsn = "mysql://$strUser:$strPwd@$strServer/$strDB";
|
||||||
}
|
break;
|
||||||
if ($type == "pgsql") {
|
case 'pgsql':
|
||||||
//$dsn = "pgsql://postgres@$strServer/$strDB";
|
//$dsn = "pgsql://postgres@$strServer/$strDB";
|
||||||
$prt = ($strPort == 0 || $strPort == 5432 ? '' : ":$strPort");
|
$prt = ($strPort == 0 || $strPort == 5432 ? '' : ":$strPort");
|
||||||
$dsn = "pgsql://$strUser:$strPwd@$strServer$prt/$strDB";
|
$dsn = "pgsql://$strUser:$strPwd@$strServer$prt/$strDB";
|
||||||
}
|
break;
|
||||||
if ($type == "odbc") {
|
case 'odbc':
|
||||||
$dsn = "odbc://$strUser:$strPwd@$strServer/$strDB";
|
$dsn = "odbc://$strUser:$strPwd@$strServer/$strDB";
|
||||||
}
|
break;
|
||||||
if ($type == "mssql") {
|
case 'mssql':
|
||||||
$strServer = substr( $strServer, 0, strpos( $strServer, ':' ) );
|
$strServer = substr($strServer, 0, strpos($strServer, ':'));
|
||||||
$prt = ($strPort == 0 || $strPort == 1433 ? '' : ":$strPort");
|
$prt = ($strPort == 0 || $strPort == 1433 ? '' : ":$strPort");
|
||||||
$dsn = "mssql://$strUser:$strPwd@$strServer$prt/$strDB";
|
$dsn = "mssql://$strUser:$strPwd@$strServer$prt/$strDB";
|
||||||
///--) $dsn = "mssql://$strUser:$strPwd@$strServer/$strDB";
|
///--) $dsn = "mssql://$strUser:$strPwd@$strServer/$strDB";
|
||||||
}
|
break;
|
||||||
if ($type == "oracle") {
|
case 'oracle':
|
||||||
$dsn = "oci8://$strUser:$strPwd@$strServer/$strDB";
|
$dsn = "oci8://$strUser:$strPwd@$strServer/$strDB";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$dsn = "mysql://$strUser:$strPwd@$strServer/$strDB";
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
$this->db_error = null;
|
$this->db_error = null;
|
||||||
if ($type === 'myxml') {
|
if ($type === 'myxml') {
|
||||||
$this->db = XMLDB::connect( $strServer );
|
$this->db = XMLDB::connect($strServer);
|
||||||
} else {
|
} else {
|
||||||
$this->db = DB::connect( $dsn );
|
$this->db = DB::connect($dsn);
|
||||||
}
|
}
|
||||||
if (DB::isError( $this->db )) {
|
if (DB::isError($this->db)) {
|
||||||
$this->db_error = $this->db;
|
$this->db_error = $this->db;
|
||||||
$this->db = null;
|
$this->db = null;
|
||||||
$this->logError( $this->db_error );
|
$this->logError($this->db_error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -141,7 +146,7 @@ class DBConnection
|
|||||||
* @access public
|
* @access public
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function Reset ()
|
public function Reset()
|
||||||
{
|
{
|
||||||
if ($this->db) {
|
if ($this->db) {
|
||||||
$this->db->disconnect();
|
$this->db->disconnect();
|
||||||
@@ -156,7 +161,7 @@ class DBConnection
|
|||||||
* @access public
|
* @access public
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function Free ()
|
public function Free()
|
||||||
{
|
{
|
||||||
$this->Reset();
|
$this->Reset();
|
||||||
}
|
}
|
||||||
@@ -168,7 +173,7 @@ class DBConnection
|
|||||||
* @access public
|
* @access public
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function Close ()
|
public function Close()
|
||||||
{
|
{
|
||||||
$this->Reset();
|
$this->Reset();
|
||||||
}
|
}
|
||||||
@@ -182,7 +187,7 @@ class DBConnection
|
|||||||
* @param string $errorLevel
|
* @param string $errorLevel
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function logError ($obj, $errorLevel = null)
|
public function logError($obj, $errorLevel = null)
|
||||||
{
|
{
|
||||||
global $_SESSION;
|
global $_SESSION;
|
||||||
global $_SERVER;
|
global $_SERVER;
|
||||||
@@ -190,12 +195,13 @@ class DBConnection
|
|||||||
$filter = new InputFilter();
|
$filter = new InputFilter();
|
||||||
$_SERVER = $filter->xssFilterHard($_SERVER);
|
$_SERVER = $filter->xssFilterHard($_SERVER);
|
||||||
$_SESSION = $filter->xssFilterHard($_SESSION);
|
$_SESSION = $filter->xssFilterHard($_SESSION);
|
||||||
if (is_null( $errorLevel ))
|
if (is_null($errorLevel)) {
|
||||||
if (isset( $this->errorLevel )) {
|
if (isset($this->errorLevel)) {
|
||||||
$errorLevel = $this->errorLevel;
|
$errorLevel = $this->errorLevel;
|
||||||
} else {
|
} else {
|
||||||
$errorLevel = DB_ERROR_SHOWALL_AND_STOP; //for fatal errors the default is 3, show detailed and die.
|
$errorLevel = DB_ERROR_SHOWALL_AND_STOP; //for fatal errors the default is 3, show detailed and die.
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($errorLevel == DB_ERROR_SHOW_AND_STOP || $errorLevel == DB_ERROR_SHOW_AND_CONTINUE || $errorLevel == DB_ERROR_SHOWALL_AND_STOP || $errorLevel == DB_ERROR_SHOWALL_AND_CONTINUE) {
|
if ($errorLevel == DB_ERROR_SHOW_AND_STOP || $errorLevel == DB_ERROR_SHOW_AND_CONTINUE || $errorLevel == DB_ERROR_SHOWALL_AND_STOP || $errorLevel == DB_ERROR_SHOWALL_AND_CONTINUE) {
|
||||||
print "<table border=1 style='font-family:Arial' cellspacing=1 cellpadding = 0 width=400 class= 'tableError' >";
|
print "<table border=1 style='font-family:Arial' cellspacing=1 cellpadding = 0 width=400 class= 'tableError' >";
|
||||||
@@ -205,9 +211,9 @@ class DBConnection
|
|||||||
}
|
}
|
||||||
print "</table>";
|
print "</table>";
|
||||||
}
|
}
|
||||||
if (defined( 'DB_ERROR_BACKTRACE' ) && DB_ERROR_BACKTRACE) {
|
if (defined('DB_ERROR_BACKTRACE') && DB_ERROR_BACKTRACE) {
|
||||||
print "<table border = 1 width=400 class= 'sendMsgRojo'><tr><td><textarea rows='12' cols='180' style='width:100%;font-family:courier;white-space:pre-line;overflow:auto;border:none;'>";
|
print "<table border = 1 width=400 class= 'sendMsgRojo'><tr><td><textarea rows='12' cols='180' style='width:100%;font-family:courier;white-space:pre-line;overflow:auto;border:none;'>";
|
||||||
print ((htmlentities( DBConnection::traceError() ))) ;
|
print((htmlentities(DBConnection::traceError()))) ;
|
||||||
print "</textarea></td></tr></table>";
|
print "</textarea></td></tr></table>";
|
||||||
}
|
}
|
||||||
//G::setErrorHandler ( );
|
//G::setErrorHandler ( );
|
||||||
@@ -225,7 +231,7 @@ class DBConnection
|
|||||||
* @param string $limit
|
* @param string $limit
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function traceError ($tts = 2, $limit = -1)
|
public function traceError($tts = 2, $limit = -1)
|
||||||
{
|
{
|
||||||
$trace = debug_backtrace();
|
$trace = debug_backtrace();
|
||||||
$out = '';
|
$out = '';
|
||||||
@@ -233,7 +239,7 @@ class DBConnection
|
|||||||
if ($tts > 0) {
|
if ($tts > 0) {
|
||||||
$tts --;
|
$tts --;
|
||||||
} else {
|
} else {
|
||||||
$out .= '[' . basename( $step['file'] ) . ': ' . $step['line'] . '] : ' . $step['function'] . '(' . DBConnection::printArgs( $step['args'] ) . ")\n";
|
$out .= '[' . basename($step['file']) . ': ' . $step['line'] . '] : ' . $step['function'] . '(' . DBConnection::printArgs($step['args']) . ")\n";
|
||||||
$limit --;
|
$limit --;
|
||||||
if ($limit === 0) {
|
if ($limit === 0) {
|
||||||
return $out;
|
return $out;
|
||||||
@@ -250,31 +256,31 @@ class DBConnection
|
|||||||
* @param string $args
|
* @param string $args
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function printArgs ($args)
|
public function printArgs($args)
|
||||||
{
|
{
|
||||||
$out = '';
|
$out = '';
|
||||||
if (is_array( $args )) {
|
if (is_array($args)) {
|
||||||
foreach ($args as $arg) {
|
foreach ($args as $arg) {
|
||||||
if ($out !== '') {
|
if ($out !== '') {
|
||||||
$out .= ' ,';
|
$out .= ' ,';
|
||||||
}
|
}
|
||||||
if (is_string( $arg )) {
|
if (is_string($arg)) {
|
||||||
$out .= "'" . ($arg) . "'";
|
$out .= "'" . ($arg) . "'";
|
||||||
} elseif (is_array( $arg )) {
|
} elseif (is_array($arg)) {
|
||||||
$out .= print_r( $arg, 1 );
|
$out .= print_r($arg, 1);
|
||||||
} elseif (is_object( $arg )) {
|
} elseif (is_object($arg)) {
|
||||||
$out .= get_class( $arg ); // print_r ( $arg ,1 );
|
$out .= get_class($arg); // print_r ( $arg ,1 );
|
||||||
} elseif (! isset( $arg )) {
|
} elseif (! isset($arg)) {
|
||||||
$out .= 'NULL';
|
$out .= 'NULL';
|
||||||
} else {
|
} else {
|
||||||
$out .= sprintf( "%s", $arg );
|
$out .= sprintf("%s", $arg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (! isset( $args )) {
|
if (! isset($args)) {
|
||||||
$out = 'NULL';
|
$out = 'NULL';
|
||||||
} else {
|
} else {
|
||||||
$out = print_r( $args, 1 );
|
$out = print_r($args, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $out;
|
return $out;
|
||||||
@@ -287,16 +293,15 @@ class DBConnection
|
|||||||
* @access public
|
* @access public
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function GetLastID ()
|
public function GetLastID()
|
||||||
{
|
{
|
||||||
if (PEAR_DATABASE == "mysql") {
|
if (PEAR_DATABASE === 'mysql') {
|
||||||
return mysql_insert_id();
|
$lastId = mysqli_insert_id($this->db);
|
||||||
} else {
|
} else {
|
||||||
$dberror = PEAR::raiseError( null, DB_ERROR_FEATURE_NOT_AVAILABLE, null, 'null', "getLastID with " . PEAR_DATABASE . ' database.', 'G_Error', true );
|
$dberror = PEAR::raiseError(null, DB_ERROR_FEATURE_NOT_AVAILABLE, null, 'null', "getLastID with " . PEAR_DATABASE . ' database.', 'G_Error', true);
|
||||||
DBconnection::logError( $dberror, DB_ERROR_SHOWALL_AND_STOP ); //this error will stop the execution, until we add this feature!!
|
DBconnection::logError($dberror, DB_ERROR_SHOWALL_AND_STOP); //this error will stop the execution, until we add this feature!!
|
||||||
return $dberror;
|
$lastId = $dberror;
|
||||||
}
|
}
|
||||||
return mysql_insert_id();
|
return $lastId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -185,7 +185,7 @@ class DBTable
|
|||||||
* @param array array of arguments key values
|
* @param array array of arguments key values
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function load()
|
public function load($sUID = null)
|
||||||
{
|
{
|
||||||
// bug::traceRoute();
|
// bug::traceRoute();
|
||||||
$ncount = 0;
|
$ncount = 0;
|
||||||
@@ -347,7 +347,7 @@ class DBTable
|
|||||||
* @access public
|
* @access public
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function save()
|
public function save($Fields = null, $labels = [], $options = [])
|
||||||
{
|
{
|
||||||
if ($this->is_new == true) {
|
if ($this->is_new == true) {
|
||||||
return $this->Insert();
|
return $this->Insert();
|
||||||
@@ -363,7 +363,7 @@ class DBTable
|
|||||||
* @access public
|
* @access public
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function delete()
|
public function delete($uid = null)
|
||||||
{
|
{
|
||||||
$stQry = "delete from `" . $this->table_name . "` ";
|
$stQry = "delete from `" . $this->table_name . "` ";
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -96,7 +96,7 @@ class headPublisher
|
|||||||
$this->addScriptCode(' var __usernameLogged__ = "' . (isset($_SESSION['USR_USERNAME']) ? $_SESSION['USR_USERNAME'] : '') . '";var SYS_LANG = "' . SYS_LANG . '";');
|
$this->addScriptCode(' var __usernameLogged__ = "' . (isset($_SESSION['USR_USERNAME']) ? $_SESSION['USR_USERNAME'] : '') . '";var SYS_LANG = "' . SYS_LANG . '";');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function &getSingleton()
|
public static function &getSingleton()
|
||||||
{
|
{
|
||||||
if (self::$instance == null) {
|
if (self::$instance == null) {
|
||||||
self::$instance = new headPublisher();
|
self::$instance = new headPublisher();
|
||||||
@@ -360,7 +360,7 @@ class headPublisher
|
|||||||
//$head .= $this->getExtJsStylesheets();
|
//$head .= $this->getExtJsStylesheets();
|
||||||
$head .= $this->getExtJsScripts();
|
$head .= $this->getExtJsScripts();
|
||||||
$head .= $this->getExtJsVariablesScript();
|
$head .= $this->getExtJsVariablesScript();
|
||||||
$oServerConf = & ServerConf::getSingleton();
|
$oServerConf = ServerConf::getSingleton();
|
||||||
if ($oServerConf->isRtl(SYS_LANG)) {
|
if ($oServerConf->isRtl(SYS_LANG)) {
|
||||||
$head = $head . " <script type=\"text/javascript\" src=\"" . G::browserCacheFilesUrl("/js/ext/extjs_rtl.js") . "\"></script>\n";
|
$head = $head . " <script type=\"text/javascript\" src=\"" . G::browserCacheFilesUrl("/js/ext/extjs_rtl.js") . "\"></script>\n";
|
||||||
}
|
}
|
||||||
@@ -752,7 +752,7 @@ class headPublisher
|
|||||||
$views = array();
|
$views = array();
|
||||||
$keyState = "extJsViewState";
|
$keyState = "extJsViewState";
|
||||||
$prefixExtJs = "ys-";
|
$prefixExtJs = "ys-";
|
||||||
$oServerConf = &ServerConf::getSingleton();
|
$oServerConf = ServerConf::getSingleton();
|
||||||
$deleteCache = true;
|
$deleteCache = true;
|
||||||
|
|
||||||
$sjson = $oServerConf->getProperty($keyState);
|
$sjson = $oServerConf->getProperty($keyState);
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ class HttpProxyController
|
|||||||
*
|
*
|
||||||
* @var array - private array to store proxy data
|
* @var array - private array to store proxy data
|
||||||
*/
|
*/
|
||||||
private $__data__ = array ();
|
private $__data__ = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -26,7 +26,8 @@ class HttpProxyController
|
|||||||
|
|
||||||
private $sendResponse = true;
|
private $sendResponse = true;
|
||||||
|
|
||||||
public function __construct() {
|
public function __construct()
|
||||||
|
{
|
||||||
$this->__request__ = new stdclass();
|
$this->__request__ = new stdclass();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,7 +37,7 @@ class HttpProxyController
|
|||||||
* @param string $name
|
* @param string $name
|
||||||
* @param string $value
|
* @param string $value
|
||||||
*/
|
*/
|
||||||
public function __set ($name, $value)
|
public function __set($name, $value)
|
||||||
{
|
{
|
||||||
//echo "Setting '$name' to '$value'\n";
|
//echo "Setting '$name' to '$value'\n";
|
||||||
$this->__data__[$name] = $value;
|
$this->__data__[$name] = $value;
|
||||||
@@ -48,10 +49,10 @@ class HttpProxyController
|
|||||||
* @param string $name
|
* @param string $name
|
||||||
* @return string or NULL if the internal var doesn't exist
|
* @return string or NULL if the internal var doesn't exist
|
||||||
*/
|
*/
|
||||||
public function __get ($name)
|
public function __get($name)
|
||||||
{
|
{
|
||||||
//echo "Getting '$name'\n";
|
//echo "Getting '$name'\n";
|
||||||
if (array_key_exists( $name, $this->__data__ )) {
|
if (array_key_exists($name, $this->__data__)) {
|
||||||
return $this->__data__[$name];
|
return $this->__data__[$name];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,10 +70,10 @@ class HttpProxyController
|
|||||||
*
|
*
|
||||||
* @param string $name
|
* @param string $name
|
||||||
*/
|
*/
|
||||||
public function __isset ($name)
|
public function __isset($name)
|
||||||
{
|
{
|
||||||
//echo "Is '$name' set?\n";
|
//echo "Is '$name' set?\n";
|
||||||
return isset( $this->__data__[$name] );
|
return isset($this->__data__[$name]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -80,10 +81,10 @@ class HttpProxyController
|
|||||||
*
|
*
|
||||||
* @param string $name
|
* @param string $name
|
||||||
*/
|
*/
|
||||||
public function __unset ($name)
|
public function __unset($name)
|
||||||
{
|
{
|
||||||
//echo "Unsetting '$name'\n";
|
//echo "Unsetting '$name'\n";
|
||||||
unset( $this->__data__[$name] );
|
unset($this->__data__[$name]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -91,11 +92,11 @@ class HttpProxyController
|
|||||||
*
|
*
|
||||||
* @param string $name
|
* @param string $name
|
||||||
*/
|
*/
|
||||||
public function call ($name)
|
public function call($name)
|
||||||
{
|
{
|
||||||
$result = new stdClass();
|
$result = new stdClass();
|
||||||
try {
|
try {
|
||||||
$result = $this->$name( $this->__request__ );
|
$result = $this->$name($this->__request__);
|
||||||
|
|
||||||
if (! $this->jsonResponse) {
|
if (! $this->jsonResponse) {
|
||||||
return null;
|
return null;
|
||||||
@@ -104,11 +105,10 @@ class HttpProxyController
|
|||||||
if (! $result) {
|
if (! $result) {
|
||||||
$result = $this->__data__;
|
$result = $this->__data__;
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$result->success = false;
|
$result->success = false;
|
||||||
$result->message = $result->msg = $e->getMessage();
|
$result->message = $result->msg = $e->getMessage();
|
||||||
switch (get_class( $e )) {
|
switch (get_class($e)) {
|
||||||
case 'Exception':
|
case 'Exception':
|
||||||
$error = "SYSTEM ERROR";
|
$error = "SYSTEM ERROR";
|
||||||
break;
|
break;
|
||||||
@@ -124,13 +124,13 @@ class HttpProxyController
|
|||||||
}
|
}
|
||||||
$result->error = $e->getMessage();
|
$result->error = $e->getMessage();
|
||||||
$result->exception = new stdClass();
|
$result->exception = new stdClass();
|
||||||
$result->exception->class = get_class( $e );
|
$result->exception->class = get_class($e);
|
||||||
$result->exception->code = $e->getCode();
|
$result->exception->code = $e->getCode();
|
||||||
$result->exception->trace = $e->getTraceAsString();
|
$result->exception->trace = $e->getTraceAsString();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->sendResponse) {
|
if ($this->sendResponse) {
|
||||||
print G::json_encode( $result );
|
print G::json_encode($result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -139,18 +139,18 @@ class HttpProxyController
|
|||||||
*
|
*
|
||||||
* @param array $data
|
* @param array $data
|
||||||
*/
|
*/
|
||||||
public function setHttpRequestData ($data)
|
public function setHttpRequestData($data)
|
||||||
{
|
{
|
||||||
if (is_array( $data )) {
|
if (is_array($data)) {
|
||||||
while ($var = each( $data )) {
|
while ($var = each($data)) {
|
||||||
$this->__request__->$var['key'] = $var['value'];
|
$this->__request__->{$var['key']} = $var['value'];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$this->__request__ = $data;
|
$this->__request__ = $data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setJsonResponse ($bool)
|
public function setJsonResponse($bool)
|
||||||
{
|
{
|
||||||
$this->jsonResponse = $bool;
|
$this->jsonResponse = $bool;
|
||||||
}
|
}
|
||||||
@@ -160,9 +160,8 @@ class HttpProxyController
|
|||||||
*
|
*
|
||||||
* @param boolean $val
|
* @param boolean $val
|
||||||
*/
|
*/
|
||||||
public function setSendResponse ($val)
|
public function setSendResponse($val)
|
||||||
{
|
{
|
||||||
$this->sendResponse = $val;
|
$this->sendResponse = $val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,8 +41,8 @@ class InputFilter
|
|||||||
$attrArray[$i] = strtolower($attrArray[$i]);
|
$attrArray[$i] = strtolower($attrArray[$i]);
|
||||||
}
|
}
|
||||||
// assign to member vars
|
// assign to member vars
|
||||||
$this->tagsArray = (array) $tagsArray;
|
$this->tagsArray = (array)$tagsArray;
|
||||||
$this->attrArray = (array) $attrArray;
|
$this->attrArray = (array)$attrArray;
|
||||||
$this->tagsMethod = $tagsMethod;
|
$this->tagsMethod = $tagsMethod;
|
||||||
$this->attrMethod = $attrMethod;
|
$this->attrMethod = $attrMethod;
|
||||||
$this->xssAuto = $xssAuto;
|
$this->xssAuto = $xssAuto;
|
||||||
@@ -83,7 +83,7 @@ class InputFilter
|
|||||||
*/
|
*/
|
||||||
public function remove($source)
|
public function remove($source)
|
||||||
{
|
{
|
||||||
$loopCounter=0;
|
$loopCounter = 0;
|
||||||
// provides nested-tag protection
|
// provides nested-tag protection
|
||||||
while ($source != $this->filterTags($source)) {
|
while ($source != $this->filterTags($source)) {
|
||||||
$source = $this->filterTags($source);
|
$source = $this->filterTags($source);
|
||||||
@@ -119,8 +119,8 @@ class InputFilter
|
|||||||
// next start of tag (for nested tag assessment)
|
// next start of tag (for nested tag assessment)
|
||||||
$tagOpen_nested = strpos($fromTagOpen, '<');
|
$tagOpen_nested = strpos($fromTagOpen, '<');
|
||||||
if (($tagOpen_nested !== false) && ($tagOpen_nested < $tagOpen_end)) {
|
if (($tagOpen_nested !== false) && ($tagOpen_nested < $tagOpen_end)) {
|
||||||
$preTag .= substr($postTag, 0, ($tagOpen_nested+1));
|
$preTag .= substr($postTag, 0, ($tagOpen_nested + 1));
|
||||||
$postTag = substr($postTag, ($tagOpen_nested+1));
|
$postTag = substr($postTag, ($tagOpen_nested + 1));
|
||||||
$tagOpen_start = strpos($postTag, '<');
|
$tagOpen_start = strpos($postTag, '<');
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -146,7 +146,7 @@ class InputFilter
|
|||||||
list($tagName) = explode(' ', $currentTag);
|
list($tagName) = explode(' ', $currentTag);
|
||||||
}
|
}
|
||||||
// excludes all "non-regular" tagnames OR no tagname OR remove if xssauto is on and tag is blacklisted
|
// excludes all "non-regular" tagnames OR no tagname OR remove if xssauto is on and tag is blacklisted
|
||||||
if ((!preg_match("/^[a-z][a-z0-9]*$/i",$tagName)) || (!$tagName) || ((in_array(strtolower($tagName), $this->tagBlacklist)) && ($this->xssAuto))) {
|
if ((!preg_match("/^[a-z][a-z0-9]*$/i", $tagName)) || (!$tagName) || ((in_array(strtolower($tagName), $this->tagBlacklist)) && ($this->xssAuto))) {
|
||||||
$postTag = substr($postTag, ($tagLength + 2));
|
$postTag = substr($postTag, ($tagLength + 2));
|
||||||
$tagOpen_start = strpos($postTag, '<');
|
$tagOpen_start = strpos($postTag, '<');
|
||||||
// don't append this tag
|
// don't append this tag
|
||||||
@@ -154,15 +154,15 @@ class InputFilter
|
|||||||
}
|
}
|
||||||
// this while is needed to support attribute values with spaces in!
|
// this while is needed to support attribute values with spaces in!
|
||||||
while ($currentSpace !== false) {
|
while ($currentSpace !== false) {
|
||||||
$fromSpace = substr($tagLeft, ($currentSpace+1));
|
$fromSpace = substr($tagLeft, ($currentSpace + 1));
|
||||||
$nextSpace = strpos($fromSpace, ' ');
|
$nextSpace = strpos($fromSpace, ' ');
|
||||||
$openQuotes = strpos($fromSpace, '"');
|
$openQuotes = strpos($fromSpace, '"');
|
||||||
$closeQuotes = strpos(substr($fromSpace, ($openQuotes+1)), '"') + $openQuotes + 1;
|
$closeQuotes = strpos(substr($fromSpace, ($openQuotes + 1)), '"') + $openQuotes + 1;
|
||||||
// another equals exists
|
// another equals exists
|
||||||
if (strpos($fromSpace, '=') !== false) {
|
if (strpos($fromSpace, '=') !== false) {
|
||||||
// opening and closing quotes exists
|
// opening and closing quotes exists
|
||||||
if (($openQuotes !== false) && (strpos(substr($fromSpace, ($openQuotes+1)), '"') !== false)) {
|
if (($openQuotes !== false) && (strpos(substr($fromSpace, ($openQuotes + 1)), '"') !== false)) {
|
||||||
$attr = substr($fromSpace, 0, ($closeQuotes+1));
|
$attr = substr($fromSpace, 0, ($closeQuotes + 1));
|
||||||
} else {
|
} else {
|
||||||
// one or neither exist
|
// one or neither exist
|
||||||
$attr = substr($fromSpace, 0, $nextSpace);
|
$attr = substr($fromSpace, 0, $nextSpace);
|
||||||
@@ -222,7 +222,7 @@ class InputFilter
|
|||||||
{
|
{
|
||||||
$newSet = array();
|
$newSet = array();
|
||||||
// process attributes
|
// process attributes
|
||||||
for ($i = 0; $i <count($attrSet); $i++) {
|
for ($i = 0; $i < count($attrSet); $i++) {
|
||||||
// skip blank spaces in tag
|
// skip blank spaces in tag
|
||||||
if (!$attrSet[$i]) {
|
if (!$attrSet[$i]) {
|
||||||
continue;
|
continue;
|
||||||
@@ -231,7 +231,7 @@ class InputFilter
|
|||||||
$attrSubSet = explode('=', trim($attrSet[$i]));
|
$attrSubSet = explode('=', trim($attrSet[$i]));
|
||||||
list($attrSubSet[0]) = explode(' ', $attrSubSet[0]);
|
list($attrSubSet[0]) = explode(' ', $attrSubSet[0]);
|
||||||
// removes all "non-regular" attr names AND also attr blacklisted
|
// removes all "non-regular" attr names AND also attr blacklisted
|
||||||
if ((!eregi("^[a-z]*$",$attrSubSet[0])) || (($this->xssAuto) && ((in_array(strtolower($attrSubSet[0]), $this->attrBlacklist)) || (substr($attrSubSet[0], 0, 2) == 'on')))) {
|
if ((!preg_match("/^[a-z]*$/i", $attrSubSet[0])) || (($this->xssAuto) && ((in_array(strtolower($attrSubSet[0]), $this->attrBlacklist)) || (substr($attrSubSet[0], 0, 2) == 'on')))) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// xss attr value filtering
|
// xss attr value filtering
|
||||||
@@ -250,7 +250,7 @@ class InputFilter
|
|||||||
$attrSubSet[1] = stripslashes($attrSubSet[1]);
|
$attrSubSet[1] = stripslashes($attrSubSet[1]);
|
||||||
}
|
}
|
||||||
// auto strip attr's with "javascript:
|
// auto strip attr's with "javascript:
|
||||||
if (((strpos(strtolower($attrSubSet[1]), 'expression') !== false) &&(strtolower($attrSubSet[0]) == 'style')) ||
|
if (((strpos(strtolower($attrSubSet[1]), 'expression') !== false) && (strtolower($attrSubSet[0]) == 'style')) ||
|
||||||
(strpos(strtolower($attrSubSet[1]), 'javascript:') !== false) ||
|
(strpos(strtolower($attrSubSet[1]), 'javascript:') !== false) ||
|
||||||
(strpos(strtolower($attrSubSet[1]), 'behaviour:') !== false) ||
|
(strpos(strtolower($attrSubSet[1]), 'behaviour:') !== false) ||
|
||||||
(strpos(strtolower($attrSubSet[1]), 'vbscript:') !== false) ||
|
(strpos(strtolower($attrSubSet[1]), 'vbscript:') !== false) ||
|
||||||
@@ -290,9 +290,13 @@ class InputFilter
|
|||||||
// url decode
|
// url decode
|
||||||
$source = html_entity_decode($source, ENT_QUOTES, "ISO-8859-1");
|
$source = html_entity_decode($source, ENT_QUOTES, "ISO-8859-1");
|
||||||
// convert decimal
|
// convert decimal
|
||||||
$source = preg_replace('/&#(\d+);/me',"chr(\\1)", $source);// decimal notation
|
$source = preg_replace_callback('/&#(\d+);/m', function ($matches) {
|
||||||
|
return utf8_encode(chr($matches[1]));
|
||||||
|
}, $source);// decimal notation
|
||||||
// convert hex
|
// convert hex
|
||||||
$source = preg_replace('/&#x([a-f0-9]+);/mei',"chr(0x\\1)", $source);// hex notation
|
$source = preg_replace_callback('/&#x([a-f0-9]+);/mi', function ($matches) {
|
||||||
|
return utf8_encode(chr('0x' . $matches[1]));
|
||||||
|
}, $source);// hex notation
|
||||||
return $source;
|
return $source;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -355,14 +359,7 @@ class InputFilter
|
|||||||
*/
|
*/
|
||||||
public function escapeString($string, &$connection)
|
public function escapeString($string, &$connection)
|
||||||
{
|
{
|
||||||
// depreciated function
|
return mysqli_real_escape_string($connection, $string);
|
||||||
if (version_compare(phpversion(),"4.3.0", "<")) {
|
|
||||||
mysql_escape_string($string);
|
|
||||||
} else {
|
|
||||||
// current function
|
|
||||||
mysql_real_escape_string($string);
|
|
||||||
}
|
|
||||||
return $string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -375,14 +372,14 @@ class InputFilter
|
|||||||
*/
|
*/
|
||||||
public function xssFilter($input, $type = "")
|
public function xssFilter($input, $type = "")
|
||||||
{
|
{
|
||||||
if(is_array($input)) {
|
if (is_array($input)) {
|
||||||
if(sizeof($input)) {
|
if (count($input)) {
|
||||||
foreach($input as $i => $val) {
|
foreach ($input as $i => $val) {
|
||||||
if(is_array($val) && sizeof($val)) {
|
if (is_array($val) && count($val)) {
|
||||||
$input[$i] = $this->xssFilter($val);
|
$input[$i] = $this->xssFilter($val);
|
||||||
} else {
|
} else {
|
||||||
if(!empty($val)) {
|
if (!empty($val)) {
|
||||||
if($type != "url") {
|
if ($type != "url") {
|
||||||
$inputFiltered = addslashes(htmlspecialchars(filter_var($val, FILTER_SANITIZE_STRING), ENT_COMPAT, 'UTF-8'));
|
$inputFiltered = addslashes(htmlspecialchars(filter_var($val, FILTER_SANITIZE_STRING), ENT_COMPAT, 'UTF-8'));
|
||||||
} else {
|
} else {
|
||||||
$inputFiltered = filter_var($val, FILTER_SANITIZE_STRING);
|
$inputFiltered = filter_var($val, FILTER_SANITIZE_STRING);
|
||||||
@@ -396,10 +393,10 @@ class InputFilter
|
|||||||
}
|
}
|
||||||
return $input;
|
return $input;
|
||||||
} else {
|
} else {
|
||||||
if(!isset($input) || trim($input) === '' || $input === NULL ) {
|
if (!isset($input) || trim($input) === '' || $input === null) {
|
||||||
return '';
|
return '';
|
||||||
} else {
|
} else {
|
||||||
if($type != "url") {
|
if ($type != "url") {
|
||||||
return addslashes(htmlspecialchars(filter_var($input, FILTER_SANITIZE_STRING), ENT_COMPAT, 'UTF-8'));
|
return addslashes(htmlspecialchars(filter_var($input, FILTER_SANITIZE_STRING), ENT_COMPAT, 'UTF-8'));
|
||||||
} else {
|
} else {
|
||||||
return filter_var($input, FILTER_SANITIZE_STRING);
|
return filter_var($input, FILTER_SANITIZE_STRING);
|
||||||
@@ -416,32 +413,32 @@ class InputFilter
|
|||||||
* @param String $type (url)
|
* @param String $type (url)
|
||||||
* @return Array or String $input
|
* @return Array or String $input
|
||||||
*/
|
*/
|
||||||
function xssFilterHard($input, $type = "")
|
public function xssFilterHard($input, $type = "")
|
||||||
{
|
{
|
||||||
$config = HTMLPurifier_Config::createDefault();
|
$config = HTMLPurifier_Config::createDefault();
|
||||||
$purifier = new HTMLPurifier($config);
|
$purifier = new HTMLPurifier($config);
|
||||||
if(is_array($input)) {
|
if (is_array($input)) {
|
||||||
if(sizeof($input)) {
|
if (count($input)) {
|
||||||
foreach($input as $i => $val) {
|
foreach ($input as $i => $val) {
|
||||||
if(is_array($val) || is_object($val) && sizeof($val)) {
|
if (is_array($val) || is_object($val) && count($val)) {
|
||||||
$input[$i] = $this->xssFilterHard($val);
|
$input[$i] = $this->xssFilterHard($val);
|
||||||
} else {
|
} else {
|
||||||
if(!empty($val)) {
|
if (!empty($val)) {
|
||||||
if(!is_object(G::json_decode($val))) {
|
if (!is_object(G::json_decode($val))) {
|
||||||
$inputFiltered = $purifier->purify($val);
|
$inputFiltered = $purifier->purify($val);
|
||||||
if($type != "url" && !strpos(basename($val), "=")) {
|
if ($type != "url" && !strpos(basename($val), "=")) {
|
||||||
$inputFiltered = htmlspecialchars($inputFiltered, ENT_NOQUOTES, 'UTF-8');
|
$inputFiltered = htmlspecialchars($inputFiltered, ENT_NOQUOTES, 'UTF-8');
|
||||||
} else {
|
} else {
|
||||||
$inputFiltered = str_replace('&','&',$inputFiltered);
|
$inputFiltered = str_replace('&', '&', $inputFiltered);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$jsArray = G::json_decode($val,true);
|
$jsArray = G::json_decode($val, true);
|
||||||
if(is_array($jsArray) && sizeof($jsArray)) {
|
if (is_array($jsArray) && count($jsArray)) {
|
||||||
foreach($jsArray as $j => $jsVal){
|
foreach ($jsArray as $j => $jsVal) {
|
||||||
if(is_array($jsVal) && sizeof($jsVal)) {
|
if (is_array($jsVal) && count($jsVal)) {
|
||||||
$jsArray[$j] = $this->xssFilterHard($jsVal);
|
$jsArray[$j] = $this->xssFilterHard($jsVal);
|
||||||
} else {
|
} else {
|
||||||
if(!empty($jsVal)) {
|
if (!empty($jsVal)) {
|
||||||
$jsArray[$j] = $purifier->purify($jsVal);
|
$jsArray[$j] = $purifier->purify($jsVal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -460,16 +457,16 @@ class InputFilter
|
|||||||
}
|
}
|
||||||
return $input;
|
return $input;
|
||||||
} else {
|
} else {
|
||||||
if(!isset($input) || empty($input)) {
|
if (!isset($input) || empty($input)) {
|
||||||
return '';
|
return '';
|
||||||
} else {
|
} else {
|
||||||
if(is_object($input)) {
|
if (is_object($input)) {
|
||||||
if(sizeof($input)) {
|
if (count($input)) {
|
||||||
foreach($input as $j => $jsVal){
|
foreach ($input as $j => $jsVal) {
|
||||||
if(is_array($jsVal) || is_object($jsVal) && sizeof($jsVal)) {
|
if (is_array($jsVal) || is_object($jsVal) && count($jsVal)) {
|
||||||
$input->j = $this->xssFilterHard($jsVal);
|
$input->j = $this->xssFilterHard($jsVal);
|
||||||
} else {
|
} else {
|
||||||
if(!empty($jsVal)) {
|
if (!empty($jsVal)) {
|
||||||
$input->j = $purifier->purify($jsVal);
|
$input->j = $purifier->purify($jsVal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -477,21 +474,21 @@ class InputFilter
|
|||||||
}
|
}
|
||||||
return $input;
|
return $input;
|
||||||
}
|
}
|
||||||
if(!is_object(G::json_decode($input))) {
|
if (!is_object(G::json_decode($input))) {
|
||||||
$input = $purifier->purify($input);
|
$input = $purifier->purify($input);
|
||||||
if($type != "url" && !strpos(basename($input), "=")) {
|
if ($type != "url" && !strpos(basename($input), "=")) {
|
||||||
$input = addslashes(htmlspecialchars($input, ENT_COMPAT, 'UTF-8'));
|
$input = addslashes(htmlspecialchars($input, ENT_COMPAT, 'UTF-8'));
|
||||||
} else {
|
} else {
|
||||||
$input = str_replace('&','&',$input);
|
$input = str_replace('&', '&', $input);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$jsArray = G::json_decode($input,true);
|
$jsArray = G::json_decode($input, true);
|
||||||
if(is_array($jsArray) && sizeof($jsArray)) {
|
if (is_array($jsArray) && count($jsArray)) {
|
||||||
foreach($jsArray as $j => $jsVal){
|
foreach ($jsArray as $j => $jsVal) {
|
||||||
if(is_array($jsVal) || is_object($jsVal) && sizeof($jsVal)) {
|
if (is_array($jsVal) || is_object($jsVal) && count($jsVal)) {
|
||||||
$jsArray[$j] = $this->xssFilterHard($jsVal);
|
$jsArray[$j] = $this->xssFilterHard($jsVal);
|
||||||
} else {
|
} else {
|
||||||
if(!empty($jsVal)) {
|
if (!empty($jsVal)) {
|
||||||
$jsArray[$j] = $purifier->purify($jsVal);
|
$jsArray[$j] = $purifier->purify($jsVal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -510,27 +507,31 @@ class InputFilter
|
|||||||
* @access protected
|
* @access protected
|
||||||
* @param String $con
|
* @param String $con
|
||||||
* @param String $query
|
* @param String $query
|
||||||
* @param Array $values
|
* @param array $values
|
||||||
* @return String $query
|
* @return String $query
|
||||||
*/
|
*/
|
||||||
function preventSqlInjection($query, $values = Array(), $con = NULL)
|
public function preventSqlInjection($query, $values = array(), $con = null)
|
||||||
{
|
{
|
||||||
if(is_array($values) && sizeof($values)) {
|
if (empty($con)) {
|
||||||
foreach($values as $k1 => $val1) {
|
$con = Propel::getConnection('workflow');
|
||||||
$values[$k1] = mysql_real_escape_string($val1);
|
$con = $con->getResource();
|
||||||
|
}
|
||||||
|
if (is_array($values) && count($values)) {
|
||||||
|
|
||||||
|
foreach ($values as $k1 => $val1) {
|
||||||
|
$values[$k1] = mysqli_real_escape_string($con, $val1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( get_magic_quotes_gpc() ) {
|
if (get_magic_quotes_gpc()) {
|
||||||
foreach($values as $k => $val) {
|
foreach ($values as $k => $val) {
|
||||||
$values[$k] = stripslashes($val);
|
$values[$k] = stripslashes($val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$newquery = vsprintf($query,$values);
|
$newQuery = vsprintf($query, $values);
|
||||||
} else {
|
} else {
|
||||||
//$newquery = mysql_real_escape_string($query);
|
$newQuery = $this->quoteSmart($this->decode($query), $con);
|
||||||
$newquery = $this->quoteSmart($this->decode($query), $con);
|
|
||||||
}
|
}
|
||||||
return $newquery;
|
return $newQuery;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -542,26 +543,26 @@ class InputFilter
|
|||||||
* @param String $valType ( validate | sanitize )
|
* @param String $valType ( validate | sanitize )
|
||||||
* @return String $value
|
* @return String $value
|
||||||
*/
|
*/
|
||||||
function validateInput($value, $types = 'string', $valType = 'sanitize')
|
public function validateInput($value, $types = 'string', $valType = 'sanitize')
|
||||||
{
|
{
|
||||||
if(!isset($value) || empty($value)) {
|
if (!isset($value) || empty($value)) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
if(is_array($types) && sizeof($types)){
|
if (is_array($types) && count($types)) {
|
||||||
foreach($types as $type){
|
foreach ($types as $type) {
|
||||||
if($valType == 'sanitize') {
|
if ($valType == 'sanitize') {
|
||||||
$value = $this->sanitizeInputValue($value, $type);
|
$value = $this->sanitizeInputValue($value, $type);
|
||||||
} else {
|
} else {
|
||||||
$value = $this->validateInputValue($value, $type);
|
$value = $this->validateInputValue($value, $type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} elseif(is_string($types)) {
|
} elseif (is_string($types)) {
|
||||||
if($types == 'sanitize' || $types == 'validate') {
|
if ($types === 'sanitize' || $types === 'validate') {
|
||||||
$valType = $types;
|
$valType = $types;
|
||||||
$types = 'string';
|
$types = 'string';
|
||||||
}
|
}
|
||||||
if($valType == 'sanitize') {
|
if ($valType === 'sanitize') {
|
||||||
$value = $this->sanitizeInputValue($value, $types);
|
$value = $this->sanitizeInputValue($value, $types);
|
||||||
} else {
|
} else {
|
||||||
$value = $this->validateInputValue($value, $types);
|
$value = $this->validateInputValue($value, $types);
|
||||||
@@ -576,9 +577,9 @@ class InputFilter
|
|||||||
* @param $type
|
* @param $type
|
||||||
* @return bool|int|mixed|string
|
* @return bool|int|mixed|string
|
||||||
*/
|
*/
|
||||||
function sanitizeInputValue($value, $type) {
|
public function sanitizeInputValue($value, $type)
|
||||||
|
{
|
||||||
switch($type) {
|
switch ($type) {
|
||||||
case 'float':
|
case 'float':
|
||||||
$value = filter_var($value, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION | FILTER_FLAG_ALLOW_THOUSAND);
|
$value = filter_var($value, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION | FILTER_FLAG_ALLOW_THOUSAND);
|
||||||
break;
|
break;
|
||||||
@@ -586,19 +587,19 @@ class InputFilter
|
|||||||
$value = (int)filter_var($value, FILTER_SANITIZE_NUMBER_INT);
|
$value = (int)filter_var($value, FILTER_SANITIZE_NUMBER_INT);
|
||||||
break;
|
break;
|
||||||
case 'boolean':
|
case 'boolean':
|
||||||
$value = (boolean)filter_var($value, FILTER_VALIDATE_BOOLEAN,FILTER_NULL_ON_FAILURE);
|
$value = (boolean)filter_var($value, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE);
|
||||||
break;
|
break;
|
||||||
case 'path':
|
case 'path':
|
||||||
if(!file_exists($value)) {
|
if (!file_exists($value)) {
|
||||||
if(!is_dir($value)) {
|
if (!is_dir($value)) {
|
||||||
$value = '';
|
$value = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'nosql':
|
case 'nosql':
|
||||||
$value = (string)filter_var($value, FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH);
|
$value = (string)filter_var($value, FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH);
|
||||||
if(preg_match('/\b(or|and|xor|drop|insert|update|delete|select)\b/i' , $value, $matches, PREG_OFFSET_CAPTURE)) {
|
if (preg_match('/\b(or|and|xor|drop|insert|update|delete|select)\b/i', $value, $matches, PREG_OFFSET_CAPTURE)) {
|
||||||
$value = substr($value,0,$matches[0][1]);
|
$value = substr($value, 0, $matches[0][1]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -613,39 +614,39 @@ class InputFilter
|
|||||||
* @param $type
|
* @param $type
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
function validateInputValue($value, $type) {
|
public function validateInputValue($value, $type)
|
||||||
|
{
|
||||||
switch($type) {
|
switch ($type) {
|
||||||
case 'float':
|
case 'float':
|
||||||
$value = str_replace(',', '.', $value);
|
$value = str_replace(',', '.', $value);
|
||||||
if(!filter_var($value, FILTER_VALIDATE_FLOAT)) {
|
if (!filter_var($value, FILTER_VALIDATE_FLOAT)) {
|
||||||
throw new Exception('not a float value');
|
throw new Exception('not a float value');
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'int':
|
case 'int':
|
||||||
if(!filter_var($value, FILTER_VALIDATE_INT)) {
|
if (!filter_var($value, FILTER_VALIDATE_INT)) {
|
||||||
throw new Exception('not a int value');
|
throw new Exception('not a int value');
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'boolean':
|
case 'boolean':
|
||||||
if(!preg_match('/\b(yes|no|false|true|1|0)\b/i' , $value)) {
|
if (!preg_match('/\b(yes|no|false|true|1|0)\b/i', $value)) {
|
||||||
throw new Exception('not a boolean value');
|
throw new Exception('not a boolean value');
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'path':
|
case 'path':
|
||||||
if(!file_exists($value)) {
|
if (!file_exists($value)) {
|
||||||
if(!is_dir($value)) {
|
if (!is_dir($value)) {
|
||||||
throw new Exception('not a valid path');
|
throw new Exception('not a valid path');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'nosql':
|
case 'nosql':
|
||||||
if(preg_match('/\b(or|and|xor|drop|insert|update|delete|select)\b/i' , $value)) {
|
if (preg_match('/\b(or|and|xor|drop|insert|update|delete|select)\b/i', $value)) {
|
||||||
throw new Exception('sql command found');
|
throw new Exception('sql command found');
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if(!is_string($value)) {
|
if (!is_string($value)) {
|
||||||
throw new Exception('not a string value');
|
throw new Exception('not a string value');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -655,7 +656,8 @@ class InputFilter
|
|||||||
* @param $pathFile
|
* @param $pathFile
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function validatePath($pathFile) {
|
public function validatePath($pathFile)
|
||||||
|
{
|
||||||
$sanitizefilteredPath = mb_ereg_replace("([\.]{2,})", '', $pathFile);
|
$sanitizefilteredPath = mb_ereg_replace("([\.]{2,})", '', $pathFile);
|
||||||
$sanitizefilteredPath = mb_ereg_replace("(^~)", '', $sanitizefilteredPath);
|
$sanitizefilteredPath = mb_ereg_replace("(^~)", '', $sanitizefilteredPath);
|
||||||
return $sanitizefilteredPath;
|
return $sanitizefilteredPath;
|
||||||
@@ -669,18 +671,18 @@ class InputFilter
|
|||||||
*
|
*
|
||||||
* @return mixed Returns data with the characters valids by regular expression
|
* @return mixed Returns data with the characters valids by regular expression
|
||||||
*/
|
*/
|
||||||
function xssRegexFilter($data, $regex)
|
public function xssRegexFilter($data, $regex)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
switch (gettype($data)) {
|
switch (gettype($data)) {
|
||||||
case 'array':
|
case 'array':
|
||||||
foreach ($data as $key => $value) {
|
foreach ($data as $key => $value) {
|
||||||
$data[$key] = $this->xssRegexFilter($value, (is_array($regex))? ((isset($regex[$key]))? $regex[$key] : '') : $regex);
|
$data[$key] = $this->xssRegexFilter($value, (is_array($regex)) ? ((isset($regex[$key])) ? $regex[$key] : '') : $regex);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if ($regex != '') {
|
if ($regex != '') {
|
||||||
$data = (preg_match_all($regex, $data, $arrayMatch))? implode('', $arrayMatch[0]) : '';
|
$data = (preg_match_all($regex, $data, $arrayMatch)) ? implode('', $arrayMatch[0]) : '';
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ class MonologProvider
|
|||||||
* @access public
|
* @access public
|
||||||
* @return object
|
* @return object
|
||||||
*/
|
*/
|
||||||
public function getSingleton ($channel, $fileLog)
|
public static function getSingleton ($channel, $fileLog)
|
||||||
{
|
{
|
||||||
if (self::$instance == null) {
|
if (self::$instance == null) {
|
||||||
self::$instance = new MonologProvider($channel, $fileLog);
|
self::$instance = new MonologProvider($channel, $fileLog);
|
||||||
|
|||||||
@@ -33,20 +33,19 @@
|
|||||||
* @package gulliver.system
|
* @package gulliver.system
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class pagedTable
|
class pagedTable
|
||||||
{
|
{
|
||||||
public $xmlFormFile;
|
public $xmlFormFile;
|
||||||
public $currentPage;
|
public $currentPage;
|
||||||
public $orderBy = '';
|
public $orderBy = '';
|
||||||
public $filter = array ();
|
public $filter = array();
|
||||||
public $filterType = array ();
|
public $filterType = array();
|
||||||
public $searchBy = '';
|
public $searchBy = '';
|
||||||
public $fastSearch = '';
|
public $fastSearch = '';
|
||||||
public $order = '';
|
public $order = '';
|
||||||
public $template = 'templates/paged-table.html';
|
public $template = 'templates/paged-table.html';
|
||||||
public $tpl;
|
public $tpl;
|
||||||
public $style = array ();
|
public $style = array();
|
||||||
public $rowsPerPage = 25;
|
public $rowsPerPage = 25;
|
||||||
public $ownerPage;
|
public $ownerPage;
|
||||||
public $popupPage;
|
public $popupPage;
|
||||||
@@ -105,30 +104,30 @@ class pagedTable
|
|||||||
* @access public
|
* @access public
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function analizeSql ()
|
public function analizeSql()
|
||||||
{
|
{
|
||||||
if (1 === preg_match( '/^\s*SELECT\s+(.+?)(?:\s+FROM\s+(.+?))(?:\s+WHERE\s+(.+?))?(?:\s+GROUP\s+BY\s+(.+?))?(?:\s+ORDER\s+BY\s+(.+?))?(?:\s+BETWEEN\s+(.+?)\s+AND\s+(.+?))?\s*$/im', $this->sqlSelect, $matches )) {
|
if (1 === preg_match('/^\s*SELECT\s+(.+?)(?:\s+FROM\s+(.+?))(?:\s+WHERE\s+(.+?))?(?:\s+GROUP\s+BY\s+(.+?))?(?:\s+ORDER\s+BY\s+(.+?))?(?:\s+BETWEEN\s+(.+?)\s+AND\s+(.+?))?\s*$/im', $this->sqlSelect, $matches)) {
|
||||||
$this->sqlSelect = 'SELECT ' . $matches[1] . (($matches[2] != '') ? ' FROM ' . $matches[2] : '');
|
$this->sqlSelect = 'SELECT ' . $matches[1] . (($matches[2] != '') ? ' FROM ' . $matches[2] : '');
|
||||||
$this->sqlSelect = 'SELECT ' . $matches[1] . (($matches[2] != '') ? ' FROM ' . $matches[2] : '');
|
$this->sqlSelect = 'SELECT ' . $matches[1] . (($matches[2] != '') ? ' FROM ' . $matches[2] : '');
|
||||||
} else {
|
} else {
|
||||||
//echo('Warning: SQL Query is not well formed.');
|
//echo('Warning: SQL Query is not well formed.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$this->sqlFrom = isset( $matches[2] ) ? $matches[2] : '';
|
$this->sqlFrom = isset($matches[2]) ? $matches[2] : '';
|
||||||
$this->sqlWhere = isset( $matches[3] ) ? $matches[3] : '';
|
$this->sqlWhere = isset($matches[3]) ? $matches[3] : '';
|
||||||
$this->sqlGroupBy = isset( $matches[4] ) ? $matches[4] : '';
|
$this->sqlGroupBy = isset($matches[4]) ? $matches[4] : '';
|
||||||
$this->sqlOrderBy = isset( $matches[5] ) ? $matches[5] : '';
|
$this->sqlOrderBy = isset($matches[5]) ? $matches[5] : '';
|
||||||
$this->order = '';
|
$this->order = '';
|
||||||
if ($this->sqlOrderBy != '') {
|
if ($this->sqlOrderBy != '') {
|
||||||
if ($n = preg_match_all( '/\b([\w\.]+)\b(?:\s+(ASC|DESC))?,?/im', $this->sqlOrderBy, $matches, PREG_SET_ORDER )) {
|
if ($n = preg_match_all('/\b([\w\.]+)\b(?:\s+(ASC|DESC))?,?/im', $this->sqlOrderBy, $matches, PREG_SET_ORDER)) {
|
||||||
for ($r = 0; $r < $n; $r ++) {
|
for ($r = 0; $r < $n; $r++) {
|
||||||
if (! isset( $matches[$r][2] )) {
|
if (!isset($matches[$r][2])) {
|
||||||
$matches[$r][2] = '';
|
$matches[$r][2] = '';
|
||||||
}
|
}
|
||||||
if ($matches[$r][2] == '') {
|
if ($matches[$r][2] == '') {
|
||||||
$matches[$r][2] = 'ASC';
|
$matches[$r][2] = 'ASC';
|
||||||
}
|
}
|
||||||
$ord = G::createUID( '', $matches[$r][1] ) . '=' . urlencode( $matches[$r][2] );
|
$ord = G::createUID('', $matches[$r][1]) . '=' . urlencode($matches[$r][2]);
|
||||||
if ($this->order == '') {
|
if ($this->order == '') {
|
||||||
$this->order = $ord;
|
$this->order = $ord;
|
||||||
} else {
|
} else {
|
||||||
@@ -137,7 +136,7 @@ class pagedTable
|
|||||||
}
|
}
|
||||||
//Orden ascendente
|
//Orden ascendente
|
||||||
if ($n == 1) {
|
if ($n == 1) {
|
||||||
$this->order = G::createUID( '', $matches[0][1] ) . '=' . $matches[0][2];
|
$this->order = G::createUID('', $matches[0][1]) . '=' . $matches[0][2];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -146,7 +145,7 @@ class pagedTable
|
|||||||
$uniqueWhere = '';
|
$uniqueWhere = '';
|
||||||
$this->fieldDataList = '';
|
$this->fieldDataList = '';
|
||||||
foreach ($this->fields as $r => $field) {
|
foreach ($this->fields as $r => $field) {
|
||||||
if ((strpos( $this->notFields, ' ' . $this->fields[$r]['Type'] . ' ' ) === false)) {
|
if ((strpos($this->notFields, ' ' . $this->fields[$r]['Type'] . ' ') === false)) {
|
||||||
if ($uniqueWhere == '') {
|
if ($uniqueWhere == '') {
|
||||||
$uniqueWhere = (($this->sqlWhere != '') ? ('(' . $this->sqlWhere . ') AND (') : '(');
|
$uniqueWhere = (($this->sqlWhere != '') ? ('(' . $this->sqlWhere . ') AND (') : '(');
|
||||||
} else {
|
} else {
|
||||||
@@ -173,77 +172,78 @@ class pagedTable
|
|||||||
* @access public
|
* @access public
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function prepareQuery ()
|
public function prepareQuery()
|
||||||
{
|
{
|
||||||
//DBConnection
|
//DBConnection
|
||||||
if (! $this->sqlConnection) {
|
if (!$this->sqlConnection) {
|
||||||
$this->dbc = new DBConnection();
|
$this->dbc = new DBConnection();
|
||||||
} else {
|
} else {
|
||||||
if (defined( 'DB_' . $this->sqlConnection . '_USER' )) {
|
if (defined('DB_' . $this->sqlConnection . '_USER')) {
|
||||||
if (defined( 'DB_' . $this->sqlConnection . '_HOST' )) {
|
if (defined('DB_' . $this->sqlConnection . '_HOST')) {
|
||||||
eval( '$res[\'DBC_SERVER\'] = DB_' . $this->sqlConnection . '_HOST;' );
|
eval('$res[\'DBC_SERVER\'] = DB_' . $this->sqlConnection . '_HOST;');
|
||||||
} else {
|
} else {
|
||||||
$res['DBC_SERVER'] = DB_HOST;
|
$res['DBC_SERVER'] = DB_HOST;
|
||||||
}
|
}
|
||||||
if (defined( 'DB_' . $this->sqlConnection . '_USER' )) {
|
if (defined('DB_' . $this->sqlConnection . '_USER')) {
|
||||||
eval( '$res[\'DBC_USERNAME\'] = DB_' . $this->sqlConnection . '_USER;' );
|
eval('$res[\'DBC_USERNAME\'] = DB_' . $this->sqlConnection . '_USER;');
|
||||||
}
|
}
|
||||||
if (defined( 'DB_' . $this->sqlConnection . '_PASS' )) {
|
if (defined('DB_' . $this->sqlConnection . '_PASS')) {
|
||||||
eval( '$res[\'DBC_PASSWORD\'] = DB_' . $this->sqlConnection . '_PASS;' );
|
eval('$res[\'DBC_PASSWORD\'] = DB_' . $this->sqlConnection . '_PASS;');
|
||||||
} else {
|
} else {
|
||||||
$res['DBC_PASSWORD'] = DB_PASS;
|
$res['DBC_PASSWORD'] = DB_PASS;
|
||||||
}
|
}
|
||||||
if (defined( 'DB_' . $this->sqlConnection . '_NAME' )) {
|
if (defined('DB_' . $this->sqlConnection . '_NAME')) {
|
||||||
eval( '$res[\'DBC_DATABASE\'] = DB_' . $this->sqlConnection . '_NAME;' );
|
eval('$res[\'DBC_DATABASE\'] = DB_' . $this->sqlConnection . '_NAME;');
|
||||||
} else {
|
} else {
|
||||||
$res['DBC_DATABASE'] = DB_NAME;
|
$res['DBC_DATABASE'] = DB_NAME;
|
||||||
}
|
}
|
||||||
if (defined( 'DB_' . $this->sqlConnection . '_TYPE' )) {
|
if (defined('DB_' . $this->sqlConnection . '_TYPE')) {
|
||||||
eval( '$res[\'DBC_TYPE\'] = DB_' . $this->sqlConnection . '_TYPE;' );
|
eval('$res[\'DBC_TYPE\'] = DB_' . $this->sqlConnection . '_TYPE;');
|
||||||
} else {
|
} else {
|
||||||
$res['DBC_TYPE'] = defined( 'DB_TYPE' ) ? DB_TYPE : 'mysql';
|
$res['DBC_TYPE'] = defined('DB_TYPE') ? DB_TYPE : 'mysql';
|
||||||
}
|
}
|
||||||
$this->dbc = new DBConnection( $res['DBC_SERVER'], $res['DBC_USERNAME'], $res['DBC_PASSWORD'], $res['DBC_DATABASE'], $res['DBC_TYPE'] );
|
$this->dbc = new DBConnection($res['DBC_SERVER'], $res['DBC_USERNAME'], $res['DBC_PASSWORD'], $res['DBC_DATABASE'], $res['DBC_TYPE']);
|
||||||
} else {
|
} else {
|
||||||
$dbc = new DBConnection();
|
$dbc = new DBConnection();
|
||||||
$dbs = new DBSession( $dbc );
|
$dbs = new DBSession($dbc);
|
||||||
$res = $dbs->execute( "select * from DB_CONNECTION WHERE DBC_UID=" . $this->sqlConnection );
|
$res = $dbs->execute("select * from DB_CONNECTION WHERE DBC_UID=" . $this->sqlConnection);
|
||||||
$res = $res->read();
|
$res = $res->read();
|
||||||
$this->dbc = new DBConnection( $res['DBC_SERVER'], $res['DBC_USERNAME'], $res['DBC_PASSWORD'], $res['DBC_DATABASE'] );
|
$this->dbc = new DBConnection($res['DBC_SERVER'], $res['DBC_USERNAME'], $res['DBC_PASSWORD'], $res['DBC_DATABASE']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->ses = new DBSession( $this->dbc );
|
$this->ses = new DBSession($this->dbc);
|
||||||
//Query
|
//Query
|
||||||
//Filter
|
//Filter
|
||||||
if (is_array( $this->filter )) {
|
if (is_array($this->filter)) {
|
||||||
$filterFields = $this->filter;
|
$filterFields = $this->filter;
|
||||||
} else {
|
} else {
|
||||||
parse_str( $this->filter, $filterFields );
|
parse_str($this->filter, $filterFields);
|
||||||
}
|
}
|
||||||
$this->aFilter = $filterFields;
|
$this->aFilter = $filterFields;
|
||||||
$filter = '';
|
$filter = '';
|
||||||
foreach ($filterFields as $field => $like) {
|
foreach ($filterFields as $field => $like) {
|
||||||
if ($like != '') {
|
if ($like !== '') {
|
||||||
if ($filter !== '') {
|
if ($filter !== '') {
|
||||||
$filter .= ' AND ';
|
$filter .= ' AND ';
|
||||||
}
|
}
|
||||||
if (isset( $this->filterType[$field] )) {
|
$like = mysqli_real_escape_string($this->dbc, $like);
|
||||||
|
if (isset($this->filterType[$field])) {
|
||||||
switch ($this->filterType[$field]) {
|
switch ($this->filterType[$field]) {
|
||||||
case '=':
|
case '=':
|
||||||
$filter .= $field . ' = "' . mysql_real_escape_string( $like ) . '"';
|
$filter .= $field . ' = "' . $like . '"';
|
||||||
break;
|
break;
|
||||||
case '<>':
|
case '<>':
|
||||||
$filter .= $field . ' <> "' . mysql_real_escape_string( $like ) . '"';
|
$filter .= $field . ' <> "' . $like . '"';
|
||||||
break;
|
break;
|
||||||
case 'contains':
|
case 'contains':
|
||||||
$filter .= $field . ' LIKE "%' . mysql_real_escape_string( $like ) . '%"';
|
$filter .= $field . ' LIKE "%' . $like . '%"';
|
||||||
break;
|
break;
|
||||||
case 'like':
|
case 'like':
|
||||||
$filter .= $field . ' LIKE "' . mysql_real_escape_string( $like ) . '"';
|
$filter .= $field . ' LIKE "' . $like . '"';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$filter .= $field . ' = "' . mysql_real_escape_string( $like ) . '"';
|
$filter .= $field . ' = "' . $like . '"';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -251,11 +251,11 @@ class pagedTable
|
|||||||
* QuickSearch
|
* QuickSearch
|
||||||
*/
|
*/
|
||||||
if ($this->searchBy !== '') {
|
if ($this->searchBy !== '') {
|
||||||
$aSB = explode( '|', $this->searchBy );
|
$aSB = explode('|', $this->searchBy);
|
||||||
$subFilter = '';
|
$subFilter = '';
|
||||||
foreach ($aSB as $sBy) {
|
foreach ($aSB as $sBy) {
|
||||||
$subFilter .= ($subFilter !== '') ? ' OR ' : '';
|
$subFilter .= ($subFilter !== '') ? ' OR ' : '';
|
||||||
$subFilter .= $sBy . ' LIKE "%' . G::sqlEscape( $this->fastSearch, $this->dbc->type ) . '%"';
|
$subFilter .= $sBy . ' LIKE "%' . G::sqlEscape($this->fastSearch, $this->dbc->type) . '%"';
|
||||||
}
|
}
|
||||||
if ($subFilter !== '') {
|
if ($subFilter !== '') {
|
||||||
$filter .= ($filter !== '') ? ' AND ' : '';
|
$filter .= ($filter !== '') ? ' AND ' : '';
|
||||||
@@ -263,18 +263,18 @@ class pagedTable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//Merge sort array defined by USER with the array defined by SQL
|
//Merge sort array defined by USER with the array defined by SQL
|
||||||
parse_str( $this->order, $orderFields );
|
parse_str($this->order, $orderFields);
|
||||||
parse_str( $this->orderBy, $orderFields2 );
|
parse_str($this->orderBy, $orderFields2);
|
||||||
//User sort is more important (first in merge).
|
//User sort is more important (first in merge).
|
||||||
$orderFields3 = array_merge( $orderFields2, $orderFields );
|
$orderFields3 = array_merge($orderFields2, $orderFields);
|
||||||
//User sort is overwrites XMLs definition.
|
//User sort is overwrites XMLs definition.
|
||||||
$orderFields = array_merge( $orderFields3, $orderFields2 );
|
$orderFields = array_merge($orderFields3, $orderFields2);
|
||||||
//Order (BY SQL DEFINITION AND USER'S DEFINITION)
|
//Order (BY SQL DEFINITION AND USER'S DEFINITION)
|
||||||
$this->aOrder = array ();
|
$this->aOrder = array();
|
||||||
$order = '';
|
$order = '';
|
||||||
foreach ($orderFields as $field => $fieldOrder) {
|
foreach ($orderFields as $field => $fieldOrder) {
|
||||||
$field = G::getUIDName( $field, '' );
|
$field = G::getUIDName($field, '');
|
||||||
$fieldOrder = strtoupper( $fieldOrder );
|
$fieldOrder = strtoupper($fieldOrder);
|
||||||
if ($fieldOrder === 'A') {
|
if ($fieldOrder === 'A') {
|
||||||
$fieldOrder = 'ASC';
|
$fieldOrder = 'ASC';
|
||||||
}
|
}
|
||||||
@@ -305,57 +305,57 @@ class pagedTable
|
|||||||
* @param string xmlForm
|
* @param string xmlForm
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function setupFromXmlform ($xmlForm)
|
public function setupFromXmlform($xmlForm)
|
||||||
{
|
{
|
||||||
$this->xmlForm = $xmlForm;
|
$this->xmlForm = $xmlForm;
|
||||||
//Config
|
//Config
|
||||||
$this->name = $xmlForm->name;
|
$this->name = $xmlForm->name;
|
||||||
$this->id = $xmlForm->id;
|
$this->id = $xmlForm->id;
|
||||||
$this->sqlConnection = ((isset( $this->xmlForm->sqlConnection )) ? $this->xmlForm->sqlConnection : '');
|
$this->sqlConnection = ((isset($this->xmlForm->sqlConnection)) ? $this->xmlForm->sqlConnection : '');
|
||||||
if (isset( $_GET['page'] )) {
|
if (isset($_GET['page'])) {
|
||||||
$this->currentPage = $_GET['page'];
|
$this->currentPage = $_GET['page'];
|
||||||
} else {
|
} else {
|
||||||
$this->currentPage = 1;
|
$this->currentPage = 1;
|
||||||
}
|
}
|
||||||
if (isset( $_GET['order'] )) {
|
if (isset($_GET['order'])) {
|
||||||
$this->orderBy = urldecode( $_GET['order'] );
|
$this->orderBy = urldecode($_GET['order']);
|
||||||
} else {
|
} else {
|
||||||
$this->orderBy = "";
|
$this->orderBy = "";
|
||||||
}
|
}
|
||||||
if (isset( $_GET['filter'] )) {
|
if (isset($_GET['filter'])) {
|
||||||
$this->filter = urldecode( $_GET['filter'] );
|
$this->filter = urldecode($_GET['filter']);
|
||||||
} else {
|
} else {
|
||||||
$this->filter = "";
|
$this->filter = "";
|
||||||
}
|
}
|
||||||
$this->ajaxServer = G::encryptLink( '../gulliver/pagedTableAjax' );
|
$this->ajaxServer = G::encryptLink('../gulliver/pagedTableAjax');
|
||||||
$this->ownerPage = G::encryptLink( SYS_CURRENT_URI );
|
$this->ownerPage = G::encryptLink(SYS_CURRENT_URI);
|
||||||
//Needed for $mysql_real_escape_string
|
//Needed for $mysql_real_escape_string
|
||||||
$auxDbc = new DBConnection();
|
$auxDbc = new DBConnection();
|
||||||
if (isset( $this->xmlForm->sql )) {
|
if (isset($this->xmlForm->sql)) {
|
||||||
$this->sqlSelect = G::replaceDataField( $this->xmlForm->sql, $this->xmlForm->values );
|
$this->sqlSelect = G::replaceDataField($this->xmlForm->sql, $this->xmlForm->values);
|
||||||
} else {
|
} else {
|
||||||
trigger_Error( 'Warning: sql query is empty', E_USER_WARNING );
|
trigger_Error('Warning: sql query is empty', E_USER_WARNING);
|
||||||
}
|
}
|
||||||
// Config attributes from XMLFORM file
|
// Config attributes from XMLFORM file
|
||||||
$myAttributes = get_class_vars( get_class( $this ) );
|
$myAttributes = get_class_vars(get_class($this));
|
||||||
foreach ($this->xmlForm->xmlform->tree->attribute as $atrib => $value) {
|
foreach ($this->xmlForm->xmlform->tree->attribute as $atrib => $value) {
|
||||||
if (array_key_exists( $atrib, $myAttributes )) {
|
if (array_key_exists($atrib, $myAttributes)) {
|
||||||
eval( 'settype($value,gettype($this->' . $atrib . '));' );
|
eval('settype($value,gettype($this->' . $atrib . '));');
|
||||||
if ($value !== '') {
|
if ($value !== '') {
|
||||||
eval( '$this->' . $atrib . '=$value;' );
|
eval('$this->' . $atrib . '=$value;');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//Prepare the fields
|
//Prepare the fields
|
||||||
$this->style = array ();
|
$this->style = array();
|
||||||
$this->gridWidth = "";
|
$this->gridWidth = "";
|
||||||
$this->gridFields = "";
|
$this->gridFields = "";
|
||||||
$this->fieldsType = array ();
|
$this->fieldsType = array();
|
||||||
foreach ($this->xmlForm->fields as $f => $v) {
|
foreach ($this->xmlForm->fields as $f => $v) {
|
||||||
$r = $f;
|
$r = $f;
|
||||||
$this->fields[$r]['Name'] = $this->xmlForm->fields[$f]->name;
|
$this->fields[$r]['Name'] = $this->xmlForm->fields[$f]->name;
|
||||||
$this->fields[$r]['Type'] = $this->xmlForm->fields[$f]->type;
|
$this->fields[$r]['Type'] = $this->xmlForm->fields[$f]->type;
|
||||||
if (isset( $this->xmlForm->fields[$f]->size )) {
|
if (isset($this->xmlForm->fields[$f]->size)) {
|
||||||
$this->fields[$r]['Size'] = $this->xmlForm->fields[$f]->size;
|
$this->fields[$r]['Size'] = $this->xmlForm->fields[$f]->size;
|
||||||
}
|
}
|
||||||
$this->fields[$r]['Label'] = $this->xmlForm->fields[$f]->label;
|
$this->fields[$r]['Label'] = $this->xmlForm->fields[$f]->label;
|
||||||
@@ -372,7 +372,7 @@ class pagedTable
|
|||||||
$r = $f;
|
$r = $f;
|
||||||
//Parse the column properties
|
//Parse the column properties
|
||||||
foreach ($this->xmlForm->fields[$f] as $attribute => $value) {
|
foreach ($this->xmlForm->fields[$f] as $attribute => $value) {
|
||||||
if (! is_object( $value )) {
|
if (!is_object($value)) {
|
||||||
$this->style[$r][$attribute] = $value;
|
$this->style[$r][$attribute] = $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -533,7 +533,7 @@ class pagedTable
|
|||||||
* @access public
|
* @access public
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function count ()
|
public function count()
|
||||||
{
|
{
|
||||||
$this->prepareQuery();
|
$this->prepareQuery();
|
||||||
return $this->query->count();
|
return $this->query->count();
|
||||||
@@ -546,51 +546,51 @@ class pagedTable
|
|||||||
* @access public
|
* @access public
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function renderTitle ()
|
public function renderTitle()
|
||||||
{
|
{
|
||||||
//Render Title
|
//Render Title
|
||||||
$thereisnotitle = true;
|
$thereisnotitle = true;
|
||||||
foreach ($this->fields as $r => $rval) {
|
foreach ($this->fields as $r => $rval) {
|
||||||
if ($this->fields[$r]['Type'] === 'title') {
|
if ($this->fields[$r]['Type'] === 'title') {
|
||||||
$this->tpl->assign( "title", $this->fields[$r]['Label'] );
|
$this->tpl->assign("title", $this->fields[$r]['Label']);
|
||||||
$thereisnotitle = false;
|
$thereisnotitle = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($thereisnotitle) {
|
if ($thereisnotitle) {
|
||||||
$this->tpl->assign( "title", ' ' );
|
$this->tpl->assign("title", ' ');
|
||||||
}
|
}
|
||||||
//Render headers
|
//Render headers
|
||||||
$this->colCount = 0;
|
$this->colCount = 0;
|
||||||
$this->shownFields = '[';
|
$this->shownFields = '[';
|
||||||
foreach ($this->fields as $r => $rval) {
|
foreach ($this->fields as $r => $rval) {
|
||||||
if ($this->style[$r]['showInTable'] != '0') {
|
if ($this->style[$r]['showInTable'] != '0') {
|
||||||
$this->tpl->newBlock( "headers" );
|
$this->tpl->newBlock("headers");
|
||||||
$sortOrder = (((isset( $this->aOrder[$this->fields[$r]['Name']] )) && ($this->aOrder[$this->fields[$r]['Name']] === 'ASC')) ? 'DESC' : 'ASC');
|
$sortOrder = (((isset($this->aOrder[$this->fields[$r]['Name']])) && ($this->aOrder[$this->fields[$r]['Name']] === 'ASC')) ? 'DESC' : 'ASC');
|
||||||
$sortOrder = (((isset( $this->aOrder[$this->fields[$r]['Name']] )) && ($this->aOrder[$this->fields[$r]['Name']] === 'DESC')) ? '' : $sortOrder);
|
$sortOrder = (((isset($this->aOrder[$this->fields[$r]['Name']])) && ($this->aOrder[$this->fields[$r]['Name']] === 'DESC')) ? '' : $sortOrder);
|
||||||
$this->style[$r]['href'] = $this->ownerPage . '?order=' . ($sortOrder !== '' ? urlencode( G::createUID( '', $this->fields[$r]['Name'] ) . '=' . $sortOrder ) : '') . '&page=' . $this->currentPage;
|
$this->style[$r]['href'] = $this->ownerPage . '?order=' . ($sortOrder !== '' ? urlencode(G::createUID('', $this->fields[$r]['Name']) . '=' . $sortOrder) : '') . '&page=' . $this->currentPage;
|
||||||
$this->style[$r]['onsort'] = $this->id . '.doSort("' . G::createUID( '', $this->fields[$r]['Name'] ) . '" , "' . $sortOrder . '");return false;';
|
$this->style[$r]['onsort'] = $this->id . '.doSort("' . G::createUID('', $this->fields[$r]['Name']) . '" , "' . $sortOrder . '");return false;';
|
||||||
if (isset( $this->style[$r]['href'] )) {
|
if (isset($this->style[$r]['href'])) {
|
||||||
$this->tpl->assign( "href", $this->style[$r]['href'] );
|
$this->tpl->assign("href", $this->style[$r]['href']);
|
||||||
}
|
}
|
||||||
if (isset( $this->style[$r]['onsort'] )) {
|
if (isset($this->style[$r]['onsort'])) {
|
||||||
$this->tpl->assign( "onclick", htmlentities( $this->style[$r]['onsort'], ENT_QUOTES, 'UTF-8' ) );
|
$this->tpl->assign("onclick", htmlentities($this->style[$r]['onsort'], ENT_QUOTES, 'UTF-8'));
|
||||||
}
|
}
|
||||||
if (isset( $this->style[$r]['colWidth'] )) {
|
if (isset($this->style[$r]['colWidth'])) {
|
||||||
$this->tpl->assign( "width", $this->style[$r]['colWidth'] );
|
$this->tpl->assign("width", $this->style[$r]['colWidth']);
|
||||||
}
|
}
|
||||||
if (isset( $this->style[$r]['colWidth'] )) {
|
if (isset($this->style[$r]['colWidth'])) {
|
||||||
$this->tpl->assign( "widthPercent", ($this->style[$r]['colWidth'] * 100 / $this->totalWidth) . "%" );
|
$this->tpl->assign("widthPercent", ($this->style[$r]['colWidth'] * 100 / $this->totalWidth) . "%");
|
||||||
}
|
}
|
||||||
if (isset( $this->style[$r]['titleAlign'] )) {
|
if (isset($this->style[$r]['titleAlign'])) {
|
||||||
$this->tpl->assign( "align", 'text-align:' . $this->style[$r]['titleAlign'] . ';' );
|
$this->tpl->assign("align", 'text-align:' . $this->style[$r]['titleAlign'] . ';');
|
||||||
}
|
}
|
||||||
if ($this->style[$r]['titleVisibility'] != '0') {
|
if ($this->style[$r]['titleVisibility'] != '0') {
|
||||||
$sortOrder = (((isset( $this->aOrder[$this->fields[$r]['Name']] )) && ($this->aOrder[$this->fields[$r]['Name']] === 'ASC')) ? 'b2' : '');
|
$sortOrder = (((isset($this->aOrder[$this->fields[$r]['Name']])) && ($this->aOrder[$this->fields[$r]['Name']] === 'ASC')) ? 'b2' : '');
|
||||||
$sortOrder = (((isset( $this->aOrder[$this->fields[$r]['Name']] )) && ($this->aOrder[$this->fields[$r]['Name']] === 'DESC')) ? 'b<' : $sortOrder);
|
$sortOrder = (((isset($this->aOrder[$this->fields[$r]['Name']])) && ($this->aOrder[$this->fields[$r]['Name']] === 'DESC')) ? 'b<' : $sortOrder);
|
||||||
$this->tpl->assign( "header", $this->fields[$r]['Label'] . $sortOrder );
|
$this->tpl->assign("header", $this->fields[$r]['Label'] . $sortOrder);
|
||||||
$this->tpl->assign( 'displaySeparator', (($this->colCount == 0) || (! isset( $this->fields[$r]['Label'] )) || ($this->fields[$r]['Label'] === '')) ? 'display:none;' : '' );
|
$this->tpl->assign('displaySeparator', (($this->colCount == 0) || (!isset($this->fields[$r]['Label'])) || ($this->fields[$r]['Label'] === '')) ? 'display:none;' : '');
|
||||||
} else {
|
} else {
|
||||||
$this->tpl->assign( 'displaySeparator', 'display:none;' );
|
$this->tpl->assign('displaySeparator', 'display:none;');
|
||||||
}
|
}
|
||||||
$this->colCount += 2;
|
$this->colCount += 2;
|
||||||
$this->shownFields .= ($this->shownFields !== '[') ? ',' : '';
|
$this->shownFields .= ($this->shownFields !== '[') ? ',' : '';
|
||||||
@@ -610,7 +610,7 @@ class pagedTable
|
|||||||
* @param eter string result
|
* @param eter string result
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function renderField ($row, $r, $result)
|
public function renderField($row, $r, $result)
|
||||||
{
|
{
|
||||||
global $G_DATE_FORMAT;
|
global $G_DATE_FORMAT;
|
||||||
//BEGIN: Special content: __sqlEdit__,__sqlDelete__
|
//BEGIN: Special content: __sqlEdit__,__sqlDelete__
|
||||||
@@ -620,10 +620,10 @@ class pagedTable
|
|||||||
$result['row__'] = $row;
|
$result['row__'] = $row;
|
||||||
//END: Special content.
|
//END: Special content.
|
||||||
//Merge $result with $xmlForm values (for default valuesSettings)
|
//Merge $result with $xmlForm values (for default valuesSettings)
|
||||||
$result = array_merge( $this->xmlForm->values, $result );
|
$result = array_merge($this->xmlForm->values, $result);
|
||||||
switch (true) {
|
switch (true) {
|
||||||
case ($this->style[$r]['data'] != ''):
|
case ($this->style[$r]['data'] != ''):
|
||||||
$value = ((isset( $result[$this->style[$r]['data']] )) ? $result[$this->style[$r]['data']] : '');
|
$value = ((isset($result[$this->style[$r]['data']])) ? $result[$this->style[$r]['data']] : '');
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$value = $this->fields[$r]['Label'];
|
$value = $this->fields[$r]['Label'];
|
||||||
@@ -631,37 +631,37 @@ class pagedTable
|
|||||||
switch ($this->fields[$r]['Type']) {
|
switch ($this->fields[$r]['Type']) {
|
||||||
case 'date':
|
case 'date':
|
||||||
/*Accept dates like 20070515 without - or / to separate its parts*/
|
/*Accept dates like 20070515 without - or / to separate its parts*/
|
||||||
if (strlen( $value ) <= 10 && strlen( $value ) > 4) {
|
if (strlen($value) <= 10 && strlen($value) > 4) {
|
||||||
$value = str_replace( '/', '-', $value );
|
$value = str_replace('/', '-', $value);
|
||||||
if (strpos( $value, '-' ) === false) {
|
if (strpos($value, '-') === false) {
|
||||||
$value = substr( $value, 0, 4 ) . '-' . substr( $value, 4, 2 ) . '-' . substr( $value, 6, 2 );
|
$value = substr($value, 0, 4) . '-' . substr($value, 4, 2) . '-' . substr($value, 6, 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->tpl->newBlock( "field" );
|
$this->tpl->newBlock("field");
|
||||||
$this->tpl->assign( 'width', $this->style[$r]['colWidth'] );
|
$this->tpl->assign('width', $this->style[$r]['colWidth']);
|
||||||
$this->tpl->assign( 'widthPercent', ($this->style[$r]['colWidth'] * 100 / $this->totalWidth) . '%' );
|
$this->tpl->assign('widthPercent', ($this->style[$r]['colWidth'] * 100 / $this->totalWidth) . '%');
|
||||||
$this->tpl->assign( 'className', (isset( $this->style[$r]['colClassName'] ) && ($this->style[$r]['colClassName'])) ? $this->style[$r]['colClassName'] : $this->tdClass );
|
$this->tpl->assign('className', (isset($this->style[$r]['colClassName']) && ($this->style[$r]['colClassName'])) ? $this->style[$r]['colClassName'] : $this->tdClass);
|
||||||
$this->tpl->assign( 'style', $this->tdStyle );
|
$this->tpl->assign('style', $this->tdStyle);
|
||||||
if (isset( $this->style[$r]['align'] )) {
|
if (isset($this->style[$r]['align'])) {
|
||||||
$this->tpl->assign( "align", $this->style[$r]['align'] );
|
$this->tpl->assign("align", $this->style[$r]['align']);
|
||||||
}
|
}
|
||||||
if (isset( $this->style[$r]['colAlign'] )) {
|
if (isset($this->style[$r]['colAlign'])) {
|
||||||
$this->tpl->assign( "align", $this->style[$r]['colAlign'] );
|
$this->tpl->assign("align", $this->style[$r]['colAlign']);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* BEGIN : Reeplace of @@, @%,...
|
* BEGIN : Reeplace of @@, @%,...
|
||||||
* in field's attributes like onclick, link,
|
* in field's attributes like onclick, link,
|
||||||
* ...
|
* ...
|
||||||
*/
|
*/
|
||||||
if (isset( $this->xmlForm->fields[$this->fields[$r]['Name']]->onclick )) {
|
if (isset($this->xmlForm->fields[$this->fields[$r]['Name']]->onclick)) {
|
||||||
$this->xmlForm->fields[$this->fields[$r]['Name']]->onclick = G::replaceDataField( $this->style[$r]['onclick'], $result );
|
$this->xmlForm->fields[$this->fields[$r]['Name']]->onclick = G::replaceDataField($this->style[$r]['onclick'], $result);
|
||||||
}
|
}
|
||||||
if (isset( $this->xmlForm->fields[$this->fields[$r]['Name']]->link )) {
|
if (isset($this->xmlForm->fields[$this->fields[$r]['Name']]->link)) {
|
||||||
$this->xmlForm->fields[$this->fields[$r]['Name']]->link = G::replaceDataField( $this->style[$r]['link'], $result );
|
$this->xmlForm->fields[$this->fields[$r]['Name']]->link = G::replaceDataField($this->style[$r]['link'], $result);
|
||||||
}
|
}
|
||||||
if (isset( $this->xmlForm->fields[$this->fields[$r]['Name']]->value )) {
|
if (isset($this->xmlForm->fields[$this->fields[$r]['Name']]->value)) {
|
||||||
$this->xmlForm->fields[$this->fields[$r]['Name']]->value = G::replaceDataField( $this->style[$r]['value'], $result );
|
$this->xmlForm->fields[$this->fields[$r]['Name']]->value = G::replaceDataField($this->style[$r]['value'], $result);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* BREAK : Reeplace of @@, @%,...
|
* BREAK : Reeplace of @@, @%,...
|
||||||
@@ -670,24 +670,24 @@ class pagedTable
|
|||||||
* Rendering of the field
|
* Rendering of the field
|
||||||
*/
|
*/
|
||||||
$this->xmlForm->setDefaultValues();
|
$this->xmlForm->setDefaultValues();
|
||||||
$this->xmlForm->setValues( $result );
|
$this->xmlForm->setValues($result);
|
||||||
$this->xmlForm->fields[$this->fields[$r]['Name']]->mode = 'view';
|
$this->xmlForm->fields[$this->fields[$r]['Name']]->mode = 'view';
|
||||||
if ((array_search( 'rendergrid', get_class_methods( get_class( $this->xmlForm->fields[$this->fields[$r]['Name']] ) ) ) !== false) || (array_search( 'renderGrid', get_class_methods( get_class( $this->xmlForm->fields[$this->fields[$r]['Name']] ) ) ) !== false)) {
|
if ((array_search('rendergrid', get_class_methods(get_class($this->xmlForm->fields[$this->fields[$r]['Name']]))) !== false) || (array_search('renderGrid', get_class_methods(get_class($this->xmlForm->fields[$this->fields[$r]['Name']]))) !== false)) {
|
||||||
$htmlField = $this->xmlForm->fields[$this->fields[$r]['Name']]->renderGrid( array ($value
|
$htmlField = $this->xmlForm->fields[$this->fields[$r]['Name']]->renderGrid(array($value
|
||||||
), $this->xmlForm );
|
), $this->xmlForm);
|
||||||
$this->tpl->assign( "value", $htmlField[0] );
|
$this->tpl->assign("value", $htmlField[0]);
|
||||||
} else {
|
} else {
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* CONTINUE : Reeplace of @@, @%,...
|
* CONTINUE : Reeplace of @@, @%,...
|
||||||
*/
|
*/
|
||||||
if (isset( $this->xmlForm->fields[$this->fields[$r]['Name']]->onclick )) {
|
if (isset($this->xmlForm->fields[$this->fields[$r]['Name']]->onclick)) {
|
||||||
$this->xmlForm->fields[$this->fields[$r]['Name']]->onclick = $this->style[$r]['onclick'];
|
$this->xmlForm->fields[$this->fields[$r]['Name']]->onclick = $this->style[$r]['onclick'];
|
||||||
}
|
}
|
||||||
if (isset( $this->xmlForm->fields[$this->fields[$r]['Name']]->link )) {
|
if (isset($this->xmlForm->fields[$this->fields[$r]['Name']]->link)) {
|
||||||
$this->xmlForm->fields[$this->fields[$r]['Name']]->link = $this->style[$r]['link'];
|
$this->xmlForm->fields[$this->fields[$r]['Name']]->link = $this->style[$r]['link'];
|
||||||
}
|
}
|
||||||
if (isset( $this->xmlForm->fields[$this->fields[$r]['Name']]->value )) {
|
if (isset($this->xmlForm->fields[$this->fields[$r]['Name']]->value)) {
|
||||||
$this->xmlForm->fields[$this->fields[$r]['Name']]->value = $this->style[$r]['value'];
|
$this->xmlForm->fields[$this->fields[$r]['Name']]->value = $this->style[$r]['value'];
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@@ -703,43 +703,43 @@ class pagedTable
|
|||||||
* @access public
|
* @access public
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function defaultStyle ()
|
public function defaultStyle()
|
||||||
{
|
{
|
||||||
// for($r=1;$r<=sizeof($this->fields);$r++)
|
// for($r=1;$r<=sizeof($this->fields);$r++)
|
||||||
foreach ($this->fields as $r => $rval) {
|
foreach ($this->fields as $r => $rval) {
|
||||||
$this->style[$r] = array ('showInTable' => '1','titleVisibility' => '1','colWidth' => '150','onclick' => '','event' => ''
|
$this->style[$r] = array('showInTable' => '1', 'titleVisibility' => '1', 'colWidth' => '150', 'onclick' => '', 'event' => ''
|
||||||
);
|
);
|
||||||
//Some widths
|
//Some widths
|
||||||
if (! (strpos( ' date linknew ', ' ' . $this->fields[$r]['Type'] . ' ' ) === false)) {
|
if (!(strpos(' date linknew ', ' ' . $this->fields[$r]['Type'] . ' ') === false)) {
|
||||||
$this->style[$r]['colWidth'] = '70';
|
$this->style[$r]['colWidth'] = '70';
|
||||||
//Data source:
|
//Data source:
|
||||||
}
|
}
|
||||||
if (! (strpos( ' title button linknew image-text jslink ', ' ' . $this->fields[$r]['Type'] . ' ' ) === false)) {
|
if (!(strpos(' title button linknew image-text jslink ', ' ' . $this->fields[$r]['Type'] . ' ') === false)) {
|
||||||
$this->style[$r]['data'] = ''; //If the control is a link it shows the label
|
$this->style[$r]['data'] = ''; //If the control is a link it shows the label
|
||||||
} else {
|
} else {
|
||||||
$this->style[$r]['data'] = $this->fields[$r]['Name']; //ELSE: The data value for that field
|
$this->style[$r]['data'] = $this->fields[$r]['Name']; //ELSE: The data value for that field
|
||||||
}
|
}
|
||||||
//Hidden fields
|
//Hidden fields
|
||||||
if (! isset( $this->style[$r]['showInTable'] )) {
|
if (!isset($this->style[$r]['showInTable'])) {
|
||||||
if (! (strpos( ' title button endgrid2 submit password ', ' ' . $this->fields[$r]['Type'] . ' ' ) === false)) {
|
if (!(strpos(' title button endgrid2 submit password ', ' ' . $this->fields[$r]['Type'] . ' ') === false)) {
|
||||||
$this->style[$r]['showInTable'] = '0';
|
$this->style[$r]['showInTable'] = '0';
|
||||||
} else {
|
} else {
|
||||||
$this->style[$r]['showInTable'] = '1';
|
$this->style[$r]['showInTable'] = '1';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//Hidden titles
|
//Hidden titles
|
||||||
if (! (strpos( ' linknew button endgrid2 ', ' ' . $this->fields[$r]['Type'] . ' ' ) === false)) {
|
if (!(strpos(' linknew button endgrid2 ', ' ' . $this->fields[$r]['Type'] . ' ') === false)) {
|
||||||
$this->style[$r]['titleVisibility'] = '0';
|
$this->style[$r]['titleVisibility'] = '0';
|
||||||
}
|
}
|
||||||
//Align titles
|
//Align titles
|
||||||
$this->style[$r]['titleAlign'] = 'center';
|
$this->style[$r]['titleAlign'] = 'center';
|
||||||
//Align fields
|
//Align fields
|
||||||
if (isset( $_SESSION['SET_DIRECTION'] ) && (strcasecmp( $_SESSION['SET_DIRECTION'], 'rtl' ) === 0)) {
|
if (isset($_SESSION['SET_DIRECTION']) && (strcasecmp($_SESSION['SET_DIRECTION'], 'rtl') === 0)) {
|
||||||
$this->style[$r]['align'] = 'right';
|
$this->style[$r]['align'] = 'right';
|
||||||
} else {
|
} else {
|
||||||
$this->style[$r]['align'] = 'left';
|
$this->style[$r]['align'] = 'left';
|
||||||
}
|
}
|
||||||
if (! (strpos( ' linknew date ', ' ' . $this->fields[$r]['Type'] . ' ' ) === false)) {
|
if (!(strpos(' linknew date ', ' ' . $this->fields[$r]['Type'] . ' ') === false)) {
|
||||||
$this->style[$r]['align'] = 'center';
|
$this->style[$r]['align'] = 'center';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -774,9 +774,8 @@ class pagedTable
|
|||||||
* @access public
|
* @access public
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function renderTable ($block = '')
|
public function renderTable($block = '')
|
||||||
{
|
{
|
||||||
|
|
||||||
$filter = new InputFilter();
|
$filter = new InputFilter();
|
||||||
$this->orderBy = $filter->xssFilterHard($this->orderBy);
|
$this->orderBy = $filter->xssFilterHard($this->orderBy);
|
||||||
$this->currentPage = $filter->xssFilterHard($this->currentPage);
|
$this->currentPage = $filter->xssFilterHard($this->currentPage);
|
||||||
@@ -786,65 +785,65 @@ class pagedTable
|
|||||||
// DBConnection
|
// DBConnection
|
||||||
$this->prepareQuery();
|
$this->prepareQuery();
|
||||||
//Query for get the number of rows
|
//Query for get the number of rows
|
||||||
$this->query = $this->ses->execute( $this->sql );
|
$this->query = $this->ses->execute($this->sql);
|
||||||
$this->totRows = $this->query->count();
|
$this->totRows = $this->query->count();
|
||||||
$this->totpages = ceil( $this->query->count() / $this->rowsPerPage );
|
$this->totpages = ceil($this->query->count() / $this->rowsPerPage);
|
||||||
//Query for obtain the records
|
//Query for obtain the records
|
||||||
$this->query = $this->ses->execute( $this->sql . ' LIMIT ' . (($this->currentPage - 1) * $this->rowsPerPage) . ', ' . $this->rowsPerPage );
|
$this->query = $this->ses->execute($this->sql . ' LIMIT ' . (($this->currentPage - 1) * $this->rowsPerPage) . ', ' . $this->rowsPerPage);
|
||||||
// Prepare the template
|
// Prepare the template
|
||||||
$this->tpl = new TemplatePower( PATH_CORE . $this->template );
|
$this->tpl = new TemplatePower(PATH_CORE . $this->template);
|
||||||
$this->tpl->prepare();
|
$this->tpl->prepare();
|
||||||
/**
|
/**
|
||||||
* ******** HEAD BLOCK **************
|
* ******** HEAD BLOCK **************
|
||||||
*/
|
*/
|
||||||
if (($block === '') || ($block === 'head')) {
|
if (($block === '') || ($block === 'head')) {
|
||||||
$this->tpl->newBlock( 'headBlock' );
|
$this->tpl->newBlock('headBlock');
|
||||||
$this->tpl->assign( 'pagedTable_Id', $this->id );
|
$this->tpl->assign('pagedTable_Id', $this->id);
|
||||||
$this->tpl->assign( 'pagedTable_Name', $this->name );
|
$this->tpl->assign('pagedTable_Name', $this->name);
|
||||||
$this->tpl->assign( 'pagedTable_Height', $this->xmlForm->height );
|
$this->tpl->assign('pagedTable_Height', $this->xmlForm->height);
|
||||||
$this->xmlForm->home = $filter->xssFilterHard($this->xmlForm->home);
|
$this->xmlForm->home = $filter->xssFilterHard($this->xmlForm->home);
|
||||||
$this->filterForm = $filter->xssFilterHard($this->filterForm);
|
$this->filterForm = $filter->xssFilterHard($this->filterForm);
|
||||||
$this->menu = $filter->xssFilterHard($this->menu);
|
$this->menu = $filter->xssFilterHard($this->menu);
|
||||||
if (file_exists( $this->xmlForm->home . $this->filterForm . '.xml' )) {
|
if (file_exists($this->xmlForm->home . $this->filterForm . '.xml')) {
|
||||||
$filterForm = new filterForm( $this->filterForm, $this->xmlForm->home );
|
$filterForm = new filterForm($this->filterForm, $this->xmlForm->home);
|
||||||
if ($this->menu === '') {
|
if ($this->menu === '') {
|
||||||
$this->menu = 'gulliver/pagedTable_Options';
|
$this->menu = 'gulliver/pagedTable_Options';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (file_exists( $this->xmlForm->home . $this->menu . '.xml' )) {
|
if (file_exists($this->xmlForm->home . $this->menu . '.xml')) {
|
||||||
$menu = new xmlMenu( $this->menu, $this->xmlForm->home );
|
$menu = new xmlMenu($this->menu, $this->xmlForm->home);
|
||||||
$this->tpl->newBlock( 'headerBlock' );
|
$this->tpl->newBlock('headerBlock');
|
||||||
$template = PATH_CORE . 'templates' . PATH_SEP . $menu->type . '.html';
|
$template = PATH_CORE . 'templates' . PATH_SEP . $menu->type . '.html';
|
||||||
$menu->setValues( $this->xmlForm->values );
|
$menu->setValues($this->xmlForm->values);
|
||||||
$menu->setValues( array ('PAGED_TABLE_ID' => $this->id
|
$menu->setValues(array('PAGED_TABLE_ID' => $this->id
|
||||||
) );
|
));
|
||||||
$menu->setValues( array ('PAGED_TABLE_FAST_SEARCH' => $this->fastSearch
|
$menu->setValues(array('PAGED_TABLE_FAST_SEARCH' => $this->fastSearch
|
||||||
) );
|
));
|
||||||
if (isset( $filterForm->name )) {
|
if (isset($filterForm->name)) {
|
||||||
$menu->setValues( array ('SEARCH_FILTER_FORM' => $filterForm->name
|
$menu->setValues(array('SEARCH_FILTER_FORM' => $filterForm->name
|
||||||
) );
|
));
|
||||||
}
|
}
|
||||||
$this->tpl->assign( 'content', $menu->render( $template, $scriptCode ) );
|
$this->tpl->assign('content', $menu->render($template, $scriptCode));
|
||||||
$oHeadPublisher = & headPublisher::getSingleton();
|
$oHeadPublisher = headPublisher::getSingleton();
|
||||||
$oHeadPublisher->addScriptFile( $menu->scriptURL );
|
$oHeadPublisher->addScriptFile($menu->scriptURL);
|
||||||
$oHeadPublisher->addScriptCode( $scriptCode );
|
$oHeadPublisher->addScriptCode($scriptCode);
|
||||||
}
|
}
|
||||||
if (file_exists( $this->xmlForm->home . $this->filterForm . '.xml' )) {
|
if (file_exists($this->xmlForm->home . $this->filterForm . '.xml')) {
|
||||||
$this->tpl->newBlock( 'headerBlock' );
|
$this->tpl->newBlock('headerBlock');
|
||||||
$this->filterForm_Id = $filterForm->id;
|
$this->filterForm_Id = $filterForm->id;
|
||||||
$filterForm->type = 'filterform';
|
$filterForm->type = 'filterform';
|
||||||
$filterForm->ajaxServer = '../gulliver/defaultAjax';
|
$filterForm->ajaxServer = '../gulliver/defaultAjax';
|
||||||
$template = PATH_CORE . 'templates/' . $filterForm->type . '.html';
|
$template = PATH_CORE . 'templates/' . $filterForm->type . '.html';
|
||||||
$filterForm->setValues( $this->xmlForm->values );
|
$filterForm->setValues($this->xmlForm->values);
|
||||||
$filterForm->setValues( array ('PAGED_TABLE_ID' => $this->id
|
$filterForm->setValues(array('PAGED_TABLE_ID' => $this->id
|
||||||
) );
|
));
|
||||||
$filterForm->setValues( array ('PAGED_TABLE_FAST_SEARCH' => $this->fastSearch
|
$filterForm->setValues(array('PAGED_TABLE_FAST_SEARCH' => $this->fastSearch
|
||||||
) );
|
));
|
||||||
$this->tpl->assign( 'content', $filterForm->render( $template, $scriptCode ) );
|
$this->tpl->assign('content', $filterForm->render($template, $scriptCode));
|
||||||
$oHeadPublisher = & headPublisher::getSingleton();
|
$oHeadPublisher = headPublisher::getSingleton();
|
||||||
$oHeadPublisher->addScriptFile( $filterForm->scriptURL );
|
$oHeadPublisher->addScriptFile($filterForm->scriptURL);
|
||||||
$oHeadPublisher->addScriptCode( $scriptCode );
|
$oHeadPublisher->addScriptCode($scriptCode);
|
||||||
if (isset( $_SESSION )) {
|
if (isset($_SESSION)) {
|
||||||
$_SESSION[$filterForm->id] = $filterForm->values;
|
$_SESSION[$filterForm->id] = $filterForm->values;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -853,52 +852,52 @@ class pagedTable
|
|||||||
* ******** CONTENT BLOCK **************
|
* ******** CONTENT BLOCK **************
|
||||||
*/
|
*/
|
||||||
if (($block === '') || ($block === 'content')) {
|
if (($block === '') || ($block === 'content')) {
|
||||||
$this->tpl->newBlock( 'contentBlock' );
|
$this->tpl->newBlock('contentBlock');
|
||||||
$this->tpl->assign( 'gridWidth', '=[' . substr( $this->gridWidth, 1 ) . ']' );
|
$this->tpl->assign('gridWidth', '=[' . substr($this->gridWidth, 1) . ']');
|
||||||
$this->tpl->assign( 'fieldNames', '=[' . substr( $this->gridFields, 1 ) . ']' );
|
$this->tpl->assign('fieldNames', '=[' . substr($this->gridFields, 1) . ']');
|
||||||
$this->tpl->assign( 'ajaxUri', '="' . addslashes( $this->ajaxServer ) . '"' );
|
$this->tpl->assign('ajaxUri', '="' . addslashes($this->ajaxServer) . '"');
|
||||||
$this->tpl->assign( 'currentUri', '="' . addslashes( $this->ownerPage ) . '"' );
|
$this->tpl->assign('currentUri', '="' . addslashes($this->ownerPage) . '"');
|
||||||
$this->tpl->assign( 'currentOrder', '="' . addslashes( $this->orderBy ) . '"' );
|
$this->tpl->assign('currentOrder', '="' . addslashes($this->orderBy) . '"');
|
||||||
$this->tpl->assign( 'currentPage', '=' . $this->currentPage );
|
$this->tpl->assign('currentPage', '=' . $this->currentPage);
|
||||||
$this->tpl->assign( 'currentFilter', '="' . '"' );
|
$this->tpl->assign('currentFilter', '="' . '"');
|
||||||
$this->tpl->assign( 'totalRows', '=' . $this->query->count() );
|
$this->tpl->assign('totalRows', '=' . $this->query->count());
|
||||||
$this->tpl->assign( 'rowsPerPage', '=' . $this->rowsPerPage );
|
$this->tpl->assign('rowsPerPage', '=' . $this->rowsPerPage);
|
||||||
$this->tpl->assign( 'popupPage', '="' . addslashes( $this->popupPage ) . '"' );
|
$this->tpl->assign('popupPage', '="' . addslashes($this->popupPage) . '"');
|
||||||
$this->tpl->assign( 'popupWidth', '=' . $this->popupWidth );
|
$this->tpl->assign('popupWidth', '=' . $this->popupWidth);
|
||||||
$this->tpl->assign( 'popupHeight', '=' . $this->popupHeight );
|
$this->tpl->assign('popupHeight', '=' . $this->popupHeight);
|
||||||
$this->tpl->assign( 'pagedTable_Id', $this->id );
|
$this->tpl->assign('pagedTable_Id', $this->id);
|
||||||
$this->tpl->assign( 'pagedTable_Name', $this->name );
|
$this->tpl->assign('pagedTable_Name', $this->name);
|
||||||
$this->tpl->assign( "pagedTable_JS", "{$this->id}.element=document.getElementById('pagedtable[{$this->id}]');" );
|
$this->tpl->assign("pagedTable_JS", "{$this->id}.element=document.getElementById('pagedtable[{$this->id}]');");
|
||||||
$this->renderTitle();
|
$this->renderTitle();
|
||||||
//Render rows
|
//Render rows
|
||||||
$gridRows = 0;
|
$gridRows = 0;
|
||||||
for ($j = 0; $j < $this->query->count(); $j ++) {
|
for ($j = 0; $j < $this->query->count(); $j++) {
|
||||||
$result = $this->query->read();
|
$result = $this->query->read();
|
||||||
//if (($j>=(($this->currentPage-1)*$this->rowsPerPage))&&($j<(($this->currentPage)*$this->rowsPerPage)))
|
//if (($j>=(($this->currentPage-1)*$this->rowsPerPage))&&($j<(($this->currentPage)*$this->rowsPerPage)))
|
||||||
//{
|
//{
|
||||||
$gridRows ++;
|
$gridRows++;
|
||||||
$this->tpl->newBlock( "row" );
|
$this->tpl->newBlock("row");
|
||||||
$this->tpl->assign( "class", "Row" . (($j % 2) + 1) );
|
$this->tpl->assign("class", "Row" . (($j % 2) + 1));
|
||||||
$this->tdStyle = '';
|
$this->tdStyle = '';
|
||||||
$this->tdClass = '';
|
$this->tdClass = '';
|
||||||
foreach ($this->fields as $r => $rval) {
|
foreach ($this->fields as $r => $rval) {
|
||||||
if (strcasecmp( $this->fields[$r]['Type'], 'cellMark' ) == 0) {
|
if (strcasecmp($this->fields[$r]['Type'], 'cellMark') == 0) {
|
||||||
$result1 = $result;
|
$result1 = $result;
|
||||||
$result1['row__'] = $j + 1;
|
$result1['row__'] = $j + 1;
|
||||||
$this->xmlForm->setDefaultValues();
|
$this->xmlForm->setDefaultValues();
|
||||||
$this->xmlForm->setValues( $result1 );
|
$this->xmlForm->setValues($result1);
|
||||||
$result1 = array_merge( $this->xmlForm->values, $result1 );
|
$result1 = array_merge($this->xmlForm->values, $result1);
|
||||||
$this->tdStyle = $this->xmlForm->fields[$this->fields[$r]['Name']]->tdStyle( $result1, $this->xmlForm );
|
$this->tdStyle = $this->xmlForm->fields[$this->fields[$r]['Name']]->tdStyle($result1, $this->xmlForm);
|
||||||
$this->tdClass = $this->xmlForm->fields[$this->fields[$r]['Name']]->tdClass( $result1, $this->xmlForm );
|
$this->tdClass = $this->xmlForm->fields[$this->fields[$r]['Name']]->tdClass($result1, $this->xmlForm);
|
||||||
} elseif ($this->style[$r]['showInTable'] != '0') {
|
} elseif ($this->style[$r]['showInTable'] != '0') {
|
||||||
$this->renderField( $j + 1, $r, $result );
|
$this->renderField($j + 1, $r, $result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
$this->tpl->assign( '_ROOT.gridRows', '=' . $gridRows ); //number of rows in the current page
|
$this->tpl->assign('_ROOT.gridRows', '=' . $gridRows); //number of rows in the current page
|
||||||
$this->tpl->newBlock( 'rowTag' );
|
$this->tpl->newBlock('rowTag');
|
||||||
$this->tpl->assign( 'rowId', 'insertAtLast' );
|
$this->tpl->assign('rowId', 'insertAtLast');
|
||||||
if ($this->currentPage > 1) {
|
if ($this->currentPage > 1) {
|
||||||
$firstUrl = $this->ownerPage . '?order=' . $this->orderBy . '&page=1';
|
$firstUrl = $this->ownerPage . '?order=' . $this->orderBy . '&page=1';
|
||||||
$firstUrl = $filter->xssFilterHard($firstUrl);
|
$firstUrl = $filter->xssFilterHard($firstUrl);
|
||||||
@@ -909,8 +908,8 @@ class pagedTable
|
|||||||
$prevUrl = $filter->xssFilterHard($prevUrl);
|
$prevUrl = $filter->xssFilterHard($prevUrl);
|
||||||
$prevAjax = $this->id . ".doGoToPage(" . $prevpage . ");return false;";
|
$prevAjax = $this->id . ".doGoToPage(" . $prevpage . ");return false;";
|
||||||
$prevAjax = $filter->xssFilterHard($prevAjax);
|
$prevAjax = $filter->xssFilterHard($prevAjax);
|
||||||
$first = "<a href=\"" . htmlentities( $firstUrl, ENT_QUOTES, 'utf-8' ) . "\" onclick=\"" . $firstAjax . "\" class='firstPage'> </a>";
|
$first = "<a href=\"" . htmlentities($firstUrl, ENT_QUOTES, 'utf-8') . "\" onclick=\"" . $firstAjax . "\" class='firstPage'> </a>";
|
||||||
$prev = "<a href=\"" . htmlentities( $prevUrl, ENT_QUOTES, 'utf-8' ) . "\" onclick=\"" . $prevAjax . "\" class='previousPage'> </a>";
|
$prev = "<a href=\"" . htmlentities($prevUrl, ENT_QUOTES, 'utf-8') . "\" onclick=\"" . $prevAjax . "\" class='previousPage'> </a>";
|
||||||
} else {
|
} else {
|
||||||
$first = "<a class='noFirstPage'> </a>";
|
$first = "<a class='noFirstPage'> </a>";
|
||||||
$prev = "<a class='noPreviousPage'> </a>";
|
$prev = "<a class='noPreviousPage'> </a>";
|
||||||
@@ -925,84 +924,85 @@ class pagedTable
|
|||||||
$nextUrl = $filter->xssFilterHard($nextUrl);
|
$nextUrl = $filter->xssFilterHard($nextUrl);
|
||||||
$nextAjax = $this->id . ".doGoToPage(" . $nextpage . ");return false;";
|
$nextAjax = $this->id . ".doGoToPage(" . $nextpage . ");return false;";
|
||||||
$nextAjax = $filter->xssFilterHard($nextAjax);
|
$nextAjax = $filter->xssFilterHard($nextAjax);
|
||||||
$next = "<a href=\"" . htmlentities( $nextUrl, ENT_QUOTES, 'utf-8' ) . "\" onclick=\"" . $nextAjax . "\" class='nextPage'> </a>";
|
$next = "<a href=\"" . htmlentities($nextUrl, ENT_QUOTES, 'utf-8') . "\" onclick=\"" . $nextAjax . "\" class='nextPage'> </a>";
|
||||||
$last = "<a href=\"" . htmlentities( $lastUrl, ENT_QUOTES, 'utf-8' ) . "\" onclick=\"" . $lastAjax . "\" class='lastPage'> </a>";
|
$last = "<a href=\"" . htmlentities($lastUrl, ENT_QUOTES, 'utf-8') . "\" onclick=\"" . $lastAjax . "\" class='lastPage'> </a>";
|
||||||
} else {
|
} else {
|
||||||
$next = "<a class='noNextPage'> </a>";
|
$next = "<a class='noNextPage'> </a>";
|
||||||
$last = "<a class='noLastPage'> </a>";
|
$last = "<a class='noLastPage'> </a>";
|
||||||
}
|
}
|
||||||
$pagesEnum = '';
|
$pagesEnum = '';
|
||||||
for ($r = 1; $r <= $this->totpages; $r ++) {
|
for ($r = 1; $r <= $this->totpages; $r++) {
|
||||||
if (($r >= ($this->currentPage - 5)) && ($r <= ($this->currentPage + 5))) {
|
if (($r >= ($this->currentPage - 5)) && ($r <= ($this->currentPage + 5))) {
|
||||||
$pageAjax = $this->id . ".doGoToPage(" . $r . ");return false;";
|
$pageAjax = $this->id . ".doGoToPage(" . $r . ");return false;";
|
||||||
if ($r != $this->currentPage) {
|
if ($r != $this->currentPage) {
|
||||||
$pageAjax = $filter->xssFilterHard($pageAjax);
|
$pageAjax = $filter->xssFilterHard($pageAjax);
|
||||||
$pagesEnum .= " <a href=\"" . htmlentities( $this->ownerPage . '?order=' . $this->orderBy . '&page=' . $r, ENT_QUOTES, 'utf-8' ) . "\" onclick=\"" . $pageAjax . "\">" . $r . "</a>";
|
$pagesEnum .= " <a href=\"" . htmlentities($this->ownerPage . '?order=' . $this->orderBy . '&page=' . $r, ENT_QUOTES, 'utf-8') . "\" onclick=\"" . $pageAjax . "\">" . $r . "</a>";
|
||||||
} else {
|
} else {
|
||||||
$pagesEnum .= " <a>" . $r . "</a>";
|
$pagesEnum .= " <a>" . $r . "</a>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($this->query->count() === 0) {
|
if ($this->query->count() === 0) {
|
||||||
$this->tpl->newBlock( 'norecords' );
|
$this->tpl->newBlock('norecords');
|
||||||
$this->tpl->assign( "columnCount", $this->colCount );
|
$this->tpl->assign("columnCount", $this->colCount);
|
||||||
$noRecordsFound = 'ID_NO_RECORDS_FOUND';
|
$noRecordsFound = 'ID_NO_RECORDS_FOUND';
|
||||||
if (G::LoadTranslation( $noRecordsFound )) {
|
if (G::LoadTranslation($noRecordsFound)) {
|
||||||
$noRecordsFound = G::LoadTranslation( $noRecordsFound );
|
$noRecordsFound = G::LoadTranslation($noRecordsFound);
|
||||||
}
|
}
|
||||||
$this->tpl->assign( "noRecordsFound", $noRecordsFound );
|
$this->tpl->assign("noRecordsFound", $noRecordsFound);
|
||||||
}
|
}
|
||||||
if (! $this->disableFooter) {
|
if (!$this->disableFooter) {
|
||||||
$this->tpl->newBlock( "bottomFooter" );
|
$this->tpl->newBlock("bottomFooter");
|
||||||
$this->tpl->assign( "columnCount", $this->colCount );
|
$this->tpl->assign("columnCount", $this->colCount);
|
||||||
$this->tpl->assign( "pagedTableId", $this->id );
|
$this->tpl->assign("pagedTableId", $this->id);
|
||||||
if (($this->query->count() !== 0)) {
|
if (($this->query->count() !== 0)) {
|
||||||
if ($this->totpages > 1) {
|
if ($this->totpages > 1) {
|
||||||
$this->tpl->assign( "first", $first );
|
$this->tpl->assign("first", $first);
|
||||||
$this->tpl->assign( "prev", $prev );
|
$this->tpl->assign("prev", $prev);
|
||||||
$this->tpl->assign( "next", $next );
|
$this->tpl->assign("next", $next);
|
||||||
$this->tpl->assign( "last", $last );
|
$this->tpl->assign("last", $last);
|
||||||
}
|
}
|
||||||
$this->tpl->assign( "currentPage", $this->currentPage );
|
$this->tpl->assign("currentPage", $this->currentPage);
|
||||||
$this->tpl->assign( "totalPages", $this->totpages );
|
$this->tpl->assign("totalPages", $this->totpages);
|
||||||
$firstRow = ($this->currentPage - 1) * $this->rowsPerPage + 1;
|
$firstRow = ($this->currentPage - 1) * $this->rowsPerPage + 1;
|
||||||
$lastRow = $firstRow + $this->query->count() - 1;
|
$lastRow = $firstRow + $this->query->count() - 1;
|
||||||
$this->tpl->assign( "firstRow", $firstRow );
|
$this->tpl->assign("firstRow", $firstRow);
|
||||||
$this->tpl->assign( "lastRow", $lastRow );
|
$this->tpl->assign("lastRow", $lastRow);
|
||||||
$this->tpl->assign( "totalRows", $this->totRows );
|
$this->tpl->assign("totalRows", $this->totRows);
|
||||||
} else {
|
} else {
|
||||||
$this->tpl->assign( "indexStyle", 'visibility:hidden;' );
|
$this->tpl->assign("indexStyle", 'visibility:hidden;');
|
||||||
}
|
}
|
||||||
if ($this->searchBy) {
|
if ($this->searchBy) {
|
||||||
$this->tpl->assign( "fastSearchValue", $this->fastSearch );
|
$this->tpl->assign("fastSearchValue", $this->fastSearch);
|
||||||
} else {
|
} else {
|
||||||
$this->tpl->assign( "fastSearchStyle", 'visibility:hidden;' );
|
$this->tpl->assign("fastSearchStyle", 'visibility:hidden;');
|
||||||
}
|
}
|
||||||
if ($this->addRow) {
|
if ($this->addRow) {
|
||||||
if ($this->sqlInsert != '') {
|
if ($this->sqlInsert != '') {
|
||||||
$this->tpl->assign( "insert", '<a href="#" onclick="pagedTable.event=\'Insert\';popup(\'' . $this->popupPage . '\');return false;">'./*G::LoadXml('labels','ID_ADD_NEW')*/ 'ID_ADD_NEW' . '</a>' );
|
$this->tpl->assign("insert", '<a href="#" onclick="pagedTable.event=\'Insert\';popup(\'' . $this->popupPage . '\');return false;">' ./*G::LoadXml('labels','ID_ADD_NEW')*/
|
||||||
|
'ID_ADD_NEW' . '</a>');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->tpl->assign( "pagesEnum", $pagesEnum );
|
$this->tpl->assign("pagesEnum", $pagesEnum);
|
||||||
}
|
} ?>
|
||||||
?>
|
|
||||||
<script language='JavaScript'>
|
<script language='JavaScript'>
|
||||||
var <?php echo $this->id?><?php echo ($this->name != '' ? '='.$this->name : '')?>=new G_PagedTable();
|
var <?php echo $this->id?><?php echo($this->name != '' ? '=' . $this->name : '')?>=
|
||||||
<?php echo $this->id?>.id<?php echo '="'. addslashes($this->id) . '"'?>;
|
new G_PagedTable();
|
||||||
<?php echo $this->id?>.name<?php echo '="'. addslashes($this->name) . '"'?>;
|
<?php echo $this->id?>.id<?php echo '="' . addslashes($this->id) . '"'?>;
|
||||||
<?php echo $this->id?>.ajaxUri<?php echo '="'. addslashes($this->ajaxServer) . '?ptID='.$this->id.'"'?>;
|
<?php echo $this->id?>.name<?php echo '="' . addslashes($this->name) . '"'?>;
|
||||||
<?php echo $this->id?>.currentOrder<?php echo '="'. addslashes($this->orderBy) . '"'?>;
|
<?php echo $this->id?>.ajaxUri<?php echo '="' . addslashes($this->ajaxServer) . '?ptID=' . $this->id . '"'?>;
|
||||||
|
<?php echo $this->id?>.currentOrder<?php echo '="' . addslashes($this->orderBy) . '"'?>;
|
||||||
<?php echo $this->id?>.currentFilter;
|
<?php echo $this->id?>.currentFilter;
|
||||||
<?php echo $this->id?>.currentPage<?php echo '='. $this->currentPage?>;
|
<?php echo $this->id?>.currentPage<?php echo '=' . $this->currentPage?>;
|
||||||
<?php echo $this->id?>.totalRows<?php echo '='.$this->query->count()?>;
|
<?php echo $this->id?>.totalRows<?php echo '=' . $this->query->count()?>;
|
||||||
<?php echo $this->id?>.rowsPerPage<?php echo '='.$this->rowsPerPage?>;
|
<?php echo $this->id?>.rowsPerPage<?php echo '=' . $this->rowsPerPage?>;
|
||||||
<?php echo $this->id?>.popupPage<?php echo '="'. addslashes($this->popupPage) . '?ptID='.$this->id.'"'?>;
|
<?php echo $this->id?>.popupPage<?php echo '="' . addslashes($this->popupPage) . '?ptID=' . $this->id . '"'?>;
|
||||||
<?php echo $this->id?>.onUpdateField<?php echo '="'. addslashes($this->onUpdateField) . '"'?>;
|
<?php echo $this->id?>.onUpdateField<?php echo '="' . addslashes($this->onUpdateField) . '"'?>;
|
||||||
<?php echo $this->id?>.shownFields<?php echo '='.$this->shownFields ?>;
|
<?php echo $this->id?>.shownFields<?php echo '=' . $this->shownFields ?>;
|
||||||
|
|
||||||
var panelPopup;
|
var panelPopup;
|
||||||
var popupWidth<?php echo '='.$this->popupWidth?>;
|
var popupWidth<?php echo '=' . $this->popupWidth?>;
|
||||||
var popupHeight<?php echo '='.$this->popupHeight?>;
|
var popupHeight<?php echo '=' . $this->popupHeight?>;
|
||||||
</script>
|
</script>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
@@ -1010,12 +1010,12 @@ class pagedTable
|
|||||||
* ******** CLOSE BLOCK **************
|
* ******** CLOSE BLOCK **************
|
||||||
*/
|
*/
|
||||||
if (($block === '') || ($block === 'close')) {
|
if (($block === '') || ($block === 'close')) {
|
||||||
$this->tpl->newBlock( "closeBlock" );
|
$this->tpl->newBlock("closeBlock");
|
||||||
}
|
}
|
||||||
$this->tpl->printToScreen();
|
$this->tpl->printToScreen();
|
||||||
unset( $this->tpl );
|
unset($this->tpl);
|
||||||
unset( $this->dbc );
|
unset($this->dbc);
|
||||||
unset( $this->ses );
|
unset($this->ses);
|
||||||
$_SESSION['pagedTable[' . $this->id . ']'] = base64_encode(serialize($this));
|
$_SESSION['pagedTable[' . $this->id . ']'] = base64_encode(serialize($this));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1028,14 +1028,14 @@ class pagedTable
|
|||||||
* @param array $data
|
* @param array $data
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function printForm ($filename, $data = array())
|
public function printForm($filename, $data = array())
|
||||||
{
|
{
|
||||||
// $G_FORM = new Form($filename, PATH_XMLFORM);
|
// $G_FORM = new Form($filename, PATH_XMLFORM);
|
||||||
// echo $G_FORM->render(PATH_TPL . 'xmlform.html', $scriptContent);
|
// echo $G_FORM->render(PATH_TPL . 'xmlform.html', $scriptContent);
|
||||||
global $G_PUBLISH;
|
global $G_PUBLISH;
|
||||||
$G_PUBLISH = new Publisher();
|
$G_PUBLISH = new Publisher();
|
||||||
$G_PUBLISH->AddContent( 'xmlform', 'xmlform', $filename, '', $data, $this->popupSubmit );
|
$G_PUBLISH->AddContent('xmlform', 'xmlform', $filename, '', $data, $this->popupSubmit);
|
||||||
G::RenderPage( "publish", "blank" );
|
G::RenderPage("publish", "blank");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1046,18 +1046,17 @@ class pagedTable
|
|||||||
* @param string $o
|
* @param string $o
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function var_dump2 ($o)
|
function var_dump2($o)
|
||||||
{
|
{
|
||||||
if (is_object( $o ) || is_array( $o )) {
|
if (is_object($o) || is_array($o)) {
|
||||||
foreach ($o as $key => $value) {
|
foreach ($o as $key => $value) {
|
||||||
echo ('<b>');
|
echo('<b>');
|
||||||
var_dump( $key );
|
var_dump($key);
|
||||||
echo ('</b>');
|
echo('</b>');
|
||||||
print_r( $value );
|
print_r($value);
|
||||||
echo ('<br>');
|
echo('<br>');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var_dump( $o );
|
var_dump($o);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -276,7 +276,7 @@ class Publisher
|
|||||||
if ($Part['Template'] == 'grid') {
|
if ($Part['Template'] == 'grid') {
|
||||||
print ('</form>') ;
|
print ('</form>') ;
|
||||||
}
|
}
|
||||||
$oHeadPublisher = & headPublisher::getSingleton();
|
$oHeadPublisher = headPublisher::getSingleton();
|
||||||
$oHeadPublisher->addScriptFile( $G_FORM->scriptURL );
|
$oHeadPublisher->addScriptFile( $G_FORM->scriptURL );
|
||||||
$oHeadPublisher->addScriptCode( $scriptCode );
|
$oHeadPublisher->addScriptCode( $scriptCode );
|
||||||
|
|
||||||
@@ -535,7 +535,7 @@ class Publisher
|
|||||||
$mainPanelScript .= '});';
|
$mainPanelScript .= '});';
|
||||||
$mainPanelScript .= 'function ' . $panelName . 'Clear(){';
|
$mainPanelScript .= 'function ' . $panelName . 'Clear(){';
|
||||||
$mainPanelScript .= 'for(var r=0;r<' . $tabCount . ';r++)' . 'if (' . $panelName . 'Tabs[r])' . $panelName . 'Tabs[r].style.display="none";}';
|
$mainPanelScript .= 'for(var r=0;r<' . $tabCount . ';r++)' . 'if (' . $panelName . 'Tabs[r])' . $panelName . 'Tabs[r].style.display="none";}';
|
||||||
$oHeadPublisher = & headPublisher::getSingleton();
|
$oHeadPublisher = headPublisher::getSingleton();
|
||||||
$oHeadPublisher->addScriptCode( $mainPanelScript );
|
$oHeadPublisher->addScriptCode( $mainPanelScript );
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -204,7 +204,6 @@ class RBAC
|
|||||||
];
|
];
|
||||||
$this->aliasPermissions['PM_CASES'] = [self::PM_GUEST_CASE];
|
$this->aliasPermissions['PM_CASES'] = [self::PM_GUEST_CASE];
|
||||||
$this->aliasPermissions['PM_LOGIN'] = [self::PM_GUEST_CASE];
|
$this->aliasPermissions['PM_LOGIN'] = [self::PM_GUEST_CASE];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -231,37 +230,30 @@ class RBAC
|
|||||||
public function initRBAC()
|
public function initRBAC()
|
||||||
{
|
{
|
||||||
if (is_null($this->userObj)) {
|
if (is_null($this->userObj)) {
|
||||||
|
|
||||||
$this->userObj = new RbacUsers();
|
$this->userObj = new RbacUsers();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_null($this->systemObj)) {
|
if (is_null($this->systemObj)) {
|
||||||
|
|
||||||
$this->systemObj = new Systems();
|
$this->systemObj = new Systems();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_null($this->usersRolesObj)) {
|
if (is_null($this->usersRolesObj)) {
|
||||||
|
|
||||||
$this->usersRolesObj = new UsersRoles();
|
$this->usersRolesObj = new UsersRoles();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_null($this->rolesObj)) {
|
if (is_null($this->rolesObj)) {
|
||||||
|
|
||||||
$this->rolesObj = new Roles();
|
$this->rolesObj = new Roles();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_null($this->permissionsObj)) {
|
if (is_null($this->permissionsObj)) {
|
||||||
|
|
||||||
$this->permissionsObj = new Permissions();
|
$this->permissionsObj = new Permissions();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_null($this->rolesPermissionsObj)) {
|
if (is_null($this->rolesPermissionsObj)) {
|
||||||
|
|
||||||
$this->rolesPermissionsObj = new RolesPermissions();
|
$this->rolesPermissionsObj = new RolesPermissions();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_null($this->authSourcesObj)) {
|
if (is_null($this->authSourcesObj)) {
|
||||||
|
|
||||||
$this->authSourcesObj = new AuthenticationSource();
|
$this->authSourcesObj = new AuthenticationSource();
|
||||||
}
|
}
|
||||||
//hook for RBAC plugins
|
//hook for RBAC plugins
|
||||||
@@ -269,13 +261,11 @@ class RBAC
|
|||||||
if (is_dir($pathPlugins)) {
|
if (is_dir($pathPlugins)) {
|
||||||
if ($handle = opendir($pathPlugins)) {
|
if ($handle = opendir($pathPlugins)) {
|
||||||
while (false !== ($file = readdir($handle))) {
|
while (false !== ($file = readdir($handle))) {
|
||||||
if (strpos($file, '.php', 1) && is_file($pathPlugins . PATH_SEP . $file) && substr($file, 0,
|
if (strpos($file, '.php', 1) && is_file($pathPlugins . PATH_SEP . $file) &&
|
||||||
6) == 'class.' && substr($file, -4) == '.php') {
|
substr($file, 0, 6) === 'class.' && substr($file, -4) === '.php') {
|
||||||
|
|
||||||
$className = substr($file, 6, strlen($file) - 10);
|
$className = substr($file, 6, strlen($file) - 10);
|
||||||
require_once($pathPlugins . PATH_SEP . $file);
|
require_once($pathPlugins . PATH_SEP . $file);
|
||||||
$this->aRbacPlugins[] = $className;
|
$this->aRbacPlugins[] = $className;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -873,9 +863,9 @@ class RBAC
|
|||||||
*/
|
*/
|
||||||
public function VerifyWithOtherAuthenticationSource($authType, $userFields, $strPass)
|
public function VerifyWithOtherAuthenticationSource($authType, $userFields, $strPass)
|
||||||
{
|
{
|
||||||
if ($authType == '' || $authType == 'MYSQL') {
|
if ($authType === '' || $authType === 'MYSQL') {
|
||||||
//check if the user is active
|
//check if the user is active
|
||||||
if ($userFields['USR_STATUS'] != 1) {
|
if ($userFields['USR_STATUS'] !== 1) {
|
||||||
return -3; //inactive user
|
return -3; //inactive user
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -886,13 +876,12 @@ class RBAC
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach ($this->aRbacPlugins as $className) {
|
foreach ($this->aRbacPlugins as $className) {
|
||||||
if (strtolower($className) == strtolower($authType)) {
|
if (strtolower($className) === strtolower($authType)) {
|
||||||
$plugin = new $className();
|
$plugin = new $className();
|
||||||
$plugin->sAuthSource = $userFields["UID_AUTH_SOURCE"];
|
$plugin->sAuthSource = $userFields['UID_AUTH_SOURCE'];
|
||||||
$plugin->sSystem = $this->sSystem;
|
$plugin->sSystem = $this->sSystem;
|
||||||
|
|
||||||
$bValidUser = false;
|
$bValidUser = $plugin->VerifyLogin($userFields['USR_AUTH_USER_DN'], $strPass);
|
||||||
$bValidUser = $plugin->VerifyLogin($userFields["USR_AUTH_USER_DN"], $strPass);
|
|
||||||
if ($bValidUser === true) {
|
if ($bValidUser === true) {
|
||||||
return ($userFields['USR_UID']);
|
return ($userFields['USR_UID']);
|
||||||
} else {
|
} else {
|
||||||
@@ -924,14 +913,16 @@ class RBAC
|
|||||||
{
|
{
|
||||||
/*----------------------------------********---------------------------------*/
|
/*----------------------------------********---------------------------------*/
|
||||||
|
|
||||||
$licenseManager =& PmLicenseManager::getSingleton();
|
$licenseManager = PmLicenseManager::getSingleton();
|
||||||
if (in_array(G::encryptOld($licenseManager->result),
|
if (in_array(
|
||||||
array('38afd7ae34bd5e3e6fc170d8b09178a3', 'ba2b45bdc11e2a4a6e86aab2ac693cbb'))) {
|
G::encryptOld($licenseManager->result),
|
||||||
|
['38afd7ae34bd5e3e6fc170d8b09178a3', 'ba2b45bdc11e2a4a6e86aab2ac693cbb']
|
||||||
|
)) {
|
||||||
return -7;
|
return -7;
|
||||||
}
|
}
|
||||||
/*----------------------------------********---------------------------------*/
|
/*----------------------------------********---------------------------------*/
|
||||||
|
|
||||||
if (strlen($strPass) == 0) {
|
if (strlen($strPass) === 0) {
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
//check if the user exists in the table RB_WORKFLOW.USERS
|
//check if the user exists in the table RB_WORKFLOW.USERS
|
||||||
@@ -955,12 +946,10 @@ class RBAC
|
|||||||
//Hook for RBAC plugins
|
//Hook for RBAC plugins
|
||||||
if ($authType != "mysql" && $authType != "") {
|
if ($authType != "mysql" && $authType != "") {
|
||||||
$res = $this->VerifyWithOtherAuthenticationSource($authType, $this->userObj->fields, $strPass);
|
$res = $this->VerifyWithOtherAuthenticationSource($authType, $this->userObj->fields, $strPass);
|
||||||
|
|
||||||
return $res;
|
return $res;
|
||||||
} else {
|
} else {
|
||||||
$this->userObj->reuseUserFields = true;
|
$this->userObj->reuseUserFields = true;
|
||||||
$res = $this->userObj->VerifyLogin($strUser, $strPass);
|
$res = $this->userObj->VerifyLogin($strUser, $strPass);
|
||||||
|
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -976,7 +965,6 @@ class RBAC
|
|||||||
public function verifyUser($strUser)
|
public function verifyUser($strUser)
|
||||||
{
|
{
|
||||||
$res = $this->userObj->verifyUser($strUser);
|
$res = $this->userObj->verifyUser($strUser);
|
||||||
|
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -990,7 +978,6 @@ class RBAC
|
|||||||
public function verifyUserId($strUserId)
|
public function verifyUserId($strUserId)
|
||||||
{
|
{
|
||||||
$res = $this->userObj->verifyUserId($strUserId);
|
$res = $this->userObj->verifyUserId($strUserId);
|
||||||
|
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1051,24 +1038,24 @@ class RBAC
|
|||||||
*/
|
*/
|
||||||
public function createUser($dataCase = [], $rolCode = '')
|
public function createUser($dataCase = [], $rolCode = '')
|
||||||
{
|
{
|
||||||
if ($dataCase["USR_STATUS"] . "" == "1") {
|
if ($dataCase['USR_STATUS'] . '' === '1') {
|
||||||
$dataCase["USR_STATUS"] = "ACTIVE";
|
$dataCase['USR_STATUS'] = 'ACTIVE';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($dataCase["USR_STATUS"] . "" == "0") {
|
if ($dataCase['USR_STATUS'] . '' === '0') {
|
||||||
$dataCase["USR_STATUS"] = "INACTIVE";
|
$dataCase['USR_STATUS'] = 'INACTIVE';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($dataCase['USR_STATUS'] == 'ACTIVE') {
|
if ($dataCase['USR_STATUS'] === 'ACTIVE') {
|
||||||
$dataCase['USR_STATUS'] = 1;
|
$dataCase['USR_STATUS'] = 1;
|
||||||
}
|
}
|
||||||
if ($dataCase['USR_STATUS'] == 'INACTIVE') {
|
if ($dataCase['USR_STATUS'] === 'INACTIVE') {
|
||||||
$dataCase['USR_STATUS'] = 0;
|
$dataCase['USR_STATUS'] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
$userUid = $this->userObj->create($dataCase);
|
$userUid = $this->userObj->create($dataCase);
|
||||||
|
|
||||||
if ($rolCode != '') {
|
if ($rolCode !== '') {
|
||||||
$this->assignRoleToUser($userUid, $rolCode);
|
$this->assignRoleToUser($userUid, $rolCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1086,7 +1073,7 @@ class RBAC
|
|||||||
public function updateUser($dataCase = [], $rolCode = '')
|
public function updateUser($dataCase = [], $rolCode = '')
|
||||||
{
|
{
|
||||||
if (isset($dataCase['USR_STATUS'])) {
|
if (isset($dataCase['USR_STATUS'])) {
|
||||||
if ($dataCase['USR_STATUS'] == 'ACTIVE') {
|
if ($dataCase['USR_STATUS'] === 'ACTIVE') {
|
||||||
$dataCase['USR_STATUS'] = 1;
|
$dataCase['USR_STATUS'] = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1141,9 +1128,9 @@ class RBAC
|
|||||||
$userStatus = 1;
|
$userStatus = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$aFields = $this->userObj->load($userUid);
|
$fields = $this->userObj->load($userUid);
|
||||||
$aFields['USR_STATUS'] = $userStatus;
|
$fields['USR_STATUS'] = $userStatus;
|
||||||
$this->userObj->update($aFields);
|
$this->userObj->update($fields);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1194,7 +1181,7 @@ class RBAC
|
|||||||
*/
|
*/
|
||||||
public function createPermision($code)
|
public function createPermision($code)
|
||||||
{
|
{
|
||||||
return $this->permissionsObj->create(array('PER_CODE' => $code));
|
return $this->permissionsObj->create(['PER_CODE' => $code]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1650,8 +1637,10 @@ class RBAC
|
|||||||
*/
|
*/
|
||||||
public function createAuthSource($dataCase)
|
public function createAuthSource($dataCase)
|
||||||
{
|
{
|
||||||
$dataCase['AUTH_SOURCE_PASSWORD'] = G::encrypt($dataCase['AUTH_SOURCE_PASSWORD'],
|
$dataCase['AUTH_SOURCE_PASSWORD'] = G::encrypt(
|
||||||
$dataCase['AUTH_SOURCE_SERVER_NAME']) . "_2NnV3ujj3w";
|
$dataCase['AUTH_SOURCE_PASSWORD'],
|
||||||
|
$dataCase['AUTH_SOURCE_SERVER_NAME']
|
||||||
|
) . "_2NnV3ujj3w";
|
||||||
$this->authSourcesObj->create($dataCase);
|
$this->authSourcesObj->create($dataCase);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1666,8 +1655,10 @@ class RBAC
|
|||||||
*/
|
*/
|
||||||
public function updateAuthSource($dataCase)
|
public function updateAuthSource($dataCase)
|
||||||
{
|
{
|
||||||
$dataCase['AUTH_SOURCE_PASSWORD'] = G::encrypt($dataCase['AUTH_SOURCE_PASSWORD'],
|
$dataCase['AUTH_SOURCE_PASSWORD'] = G::encrypt(
|
||||||
$dataCase['AUTH_SOURCE_SERVER_NAME']) . "_2NnV3ujj3w";
|
$dataCase['AUTH_SOURCE_PASSWORD'],
|
||||||
|
$dataCase['AUTH_SOURCE_SERVER_NAME']
|
||||||
|
) . "_2NnV3ujj3w";
|
||||||
$this->authSourcesObj->update($dataCase);
|
$this->authSourcesObj->update($dataCase);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1928,14 +1919,18 @@ class RBAC
|
|||||||
$isAssignedNewpermissions = $this->getPermissionAssignedRole($aRow['ROL_UID'], $item['PER_UID']);
|
$isAssignedNewpermissions = $this->getPermissionAssignedRole($aRow['ROL_UID'], $item['PER_UID']);
|
||||||
$assignPermissions = true;
|
$assignPermissions = true;
|
||||||
if (!$isAssignedNewpermissions) {
|
if (!$isAssignedNewpermissions) {
|
||||||
if ($aRow['ROL_CODE'] == 'PROCESSMAKER_OPERATOR' && in_array($item['PER_CODE'],
|
if ($aRow['ROL_CODE'] == 'PROCESSMAKER_OPERATOR' && in_array(
|
||||||
$permissionsForOperator)) {
|
$item['PER_CODE'],
|
||||||
|
$permissionsForOperator
|
||||||
|
)) {
|
||||||
$assignPermissions = false;
|
$assignPermissions = false;
|
||||||
}
|
}
|
||||||
if (!in_array($aRow['ROL_CODE'], $perCodePM)) {
|
if (!in_array($aRow['ROL_CODE'], $perCodePM)) {
|
||||||
$assignPermissions = false;
|
$assignPermissions = false;
|
||||||
$checkPermisionEdit = $this->getPermissionAssignedRole($aRow['ROL_UID'],
|
$checkPermisionEdit = $this->getPermissionAssignedRole(
|
||||||
'00000000000000000000000000000014');
|
$aRow['ROL_UID'],
|
||||||
|
'00000000000000000000000000000014'
|
||||||
|
);
|
||||||
if ($checkPermisionEdit && !in_array($item['PER_CODE'], $permissionsForOperator)) {
|
if ($checkPermisionEdit && !in_array($item['PER_CODE'], $permissionsForOperator)) {
|
||||||
$assignPermissions = true;
|
$assignPermissions = true;
|
||||||
}
|
}
|
||||||
@@ -2025,4 +2020,3 @@ class RBAC
|
|||||||
return self::GUEST_USER_UID === $usrUid;
|
return self::GUEST_USER_UID === $usrUid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,6 @@
|
|||||||
* @copyright (C) 2012 by Colosa Development Team.
|
* @copyright (C) 2012 by Colosa Development Team.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class XmlFormFieldWYSIWYGEditor extends XmlFormField
|
class XmlFormFieldWYSIWYGEditor extends XmlFormField
|
||||||
{
|
{
|
||||||
public $width = '100%';
|
public $width = '100%';
|
||||||
@@ -50,15 +49,18 @@ class XmlFormFieldWYSIWYGEditor extends XmlFormField
|
|||||||
*
|
*
|
||||||
* @author
|
* @author
|
||||||
* @access public
|
* @access public
|
||||||
|
*
|
||||||
* @param string $value
|
* @param string $value
|
||||||
* @param string $owner
|
* @param string $owner
|
||||||
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function render ($value, $owner = null)
|
public function render($value, $owner = null)
|
||||||
{
|
{
|
||||||
$value = ($value == '') ? '<br/>' : $value;
|
$value = ($value == '') ? '<br/>' : $value;
|
||||||
$html = "<textArea class='tmceEditor' id='form[" . $this->name . "]' name='form[" . $this->name . "]' >" . htmlentities( $value, ENT_QUOTES, 'UTF-8' ) . "</textarea>";
|
$html = "<textArea class='tmceEditor' id='form[" . $this->name . "]' name='form[" . $this->name . "]' >" . htmlentities($value,
|
||||||
|
ENT_QUOTES, 'UTF-8') . "</textarea>";
|
||||||
return $html;
|
return $html;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,19 +70,21 @@ class XmlFormFieldWYSIWYGEditor extends XmlFormField
|
|||||||
*
|
*
|
||||||
* @author
|
* @author
|
||||||
* @access public
|
* @access public
|
||||||
|
*
|
||||||
* @param string $element
|
* @param string $element
|
||||||
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function attachEvents ($element)
|
public function attachEvents($element)
|
||||||
{
|
{
|
||||||
$editorDefinition = 'tinyMCE.baseURL = "/js/tinymce/jscripts/tiny_mce"; ';
|
$editorDefinition = 'tinyMCE.baseURL = "/js/tinymce/jscripts/tiny_mce"; ';
|
||||||
$editorDefinition .= 'var domainURL = "/sys'.config("system.workspace").'/'.SYS_LANG.'/'.SYS_SKIN.'/"';
|
$editorDefinition .= 'var domainURL = "/sys' . config("system.workspace") . '/' . SYS_LANG . '/' . SYS_SKIN . '/"';
|
||||||
$serverConf =& ServerConf::getSingleton();
|
$serverConf = ServerConf::getSingleton();
|
||||||
|
|
||||||
switch ($this->editorType){
|
switch ($this->editorType) {
|
||||||
case 'EMAIL_TEMPLATE':
|
case 'EMAIL_TEMPLATE':
|
||||||
$editorDefinition.= '
|
$editorDefinition .= '
|
||||||
// is necessary the process uid variable in order to load the picker correctly
|
// is necessary the process uid variable in order to load the picker correctly
|
||||||
var actualCaretPositionBookmark;
|
var actualCaretPositionBookmark;
|
||||||
var formProcessID = document.getElementById("form[pro_uid]").value;
|
var formProcessID = document.getElementById("form[pro_uid]").value;
|
||||||
@@ -118,7 +122,7 @@ class XmlFormFieldWYSIWYGEditor extends XmlFormField
|
|||||||
';
|
';
|
||||||
break;
|
break;
|
||||||
case 'OUTPUT_DOCUMENT':
|
case 'OUTPUT_DOCUMENT':
|
||||||
$editorDefinition.= '
|
$editorDefinition .= '
|
||||||
// is necessary the process uid variable in order to load the picker correctly
|
// is necessary the process uid variable in order to load the picker correctly
|
||||||
var formProcessID = document.getElementById("form[PRO_UID]").value;
|
var formProcessID = document.getElementById("form[PRO_UID]").value;
|
||||||
tinyMCE.init({
|
tinyMCE.init({
|
||||||
@@ -156,7 +160,7 @@ class XmlFormFieldWYSIWYGEditor extends XmlFormField
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'DYNAFORM_TEMPLATE':
|
case 'DYNAFORM_TEMPLATE':
|
||||||
$editorDefinition.= '
|
$editorDefinition .= '
|
||||||
var formProcessID = document.getElementById("form[PRO_UID]").value;
|
var formProcessID = document.getElementById("form[PRO_UID]").value;
|
||||||
var formDynaformID = document.getElementById("form[DYN_UID]").value;
|
var formDynaformID = document.getElementById("form[DYN_UID]").value;
|
||||||
var actualCaretPositionBookmark;
|
var actualCaretPositionBookmark;
|
||||||
@@ -177,7 +181,7 @@ class XmlFormFieldWYSIWYGEditor extends XmlFormField
|
|||||||
popup_css : "/js/tinymce/jscripts/tiny_mce/themes/advanced/skins/default/dialog.css",
|
popup_css : "/js/tinymce/jscripts/tiny_mce/themes/advanced/skins/default/dialog.css",
|
||||||
skin : "o2k7",
|
skin : "o2k7",
|
||||||
skin_variant : "silver",
|
skin_variant : "silver",
|
||||||
content_css : "/css/'.SYS_SKIN.'.css",
|
content_css : "/css/' . SYS_SKIN . '.css",
|
||||||
template_external_list_url : "js/template_list.js",
|
template_external_list_url : "js/template_list.js",
|
||||||
external_link_list_url : "js/link_list.js",
|
external_link_list_url : "js/link_list.js",
|
||||||
external_image_list_url : "js/image_list.js",
|
external_image_list_url : "js/image_list.js",
|
||||||
@@ -207,7 +211,7 @@ class XmlFormFieldWYSIWYGEditor extends XmlFormField
|
|||||||
';
|
';
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$editorDefinition.= '
|
$editorDefinition .= '
|
||||||
tinyMCE.init({
|
tinyMCE.init({
|
||||||
// General options
|
// General options
|
||||||
mode : "textareas",
|
mode : "textareas",
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ class XmlFormFieldXmlMenu extends XmlFormField
|
|||||||
$this->type = 'xmlmenuDyn';
|
$this->type = 'xmlmenuDyn';
|
||||||
$template = PATH_CORE . 'templates/' . $this->type . '.html';
|
$template = PATH_CORE . 'templates/' . $this->type . '.html';
|
||||||
$out = $this->xmlMenu->render( $template, $scriptCode );
|
$out = $this->xmlMenu->render( $template, $scriptCode );
|
||||||
$oHeadPublisher = & headPublisher::getSingleton();
|
$oHeadPublisher = headPublisher::getSingleton();
|
||||||
$oHeadPublisher->addScriptFile( $this->xmlMenu->scriptURL );
|
$oHeadPublisher->addScriptFile( $this->xmlMenu->scriptURL );
|
||||||
$oHeadPublisher->addScriptCode( $scriptCode );
|
$oHeadPublisher->addScriptCode( $scriptCode );
|
||||||
return $out;
|
return $out;
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
13
phpunit.xml
13
phpunit.xml
@@ -33,6 +33,7 @@
|
|||||||
</filter>
|
</filter>
|
||||||
|
|
||||||
<php>
|
<php>
|
||||||
|
<var name="APP_ENV" value="testing" />
|
||||||
<var name="SYS_SYS" value="test" />
|
<var name="SYS_SYS" value="test" />
|
||||||
<var name="SYS_LANG" value="en" />
|
<var name="SYS_LANG" value="en" />
|
||||||
<var name="SYS_SKIN" value="neoclassic" />
|
<var name="SYS_SKIN" value="neoclassic" />
|
||||||
@@ -46,5 +47,17 @@
|
|||||||
<var name="APP_HOST" value="processmaker3.local" />
|
<var name="APP_HOST" value="processmaker3.local" />
|
||||||
<var name="HTTPS" value="off" />
|
<var name="HTTPS" value="off" />
|
||||||
<var name="SERVER_PORT" value="8080" />
|
<var name="SERVER_PORT" value="8080" />
|
||||||
|
|
||||||
|
|
||||||
|
<env name="DB_DATABASE" value="test" />
|
||||||
|
<env name="DB_USERNAME" value="root" />
|
||||||
|
<env name="DB_PASSWORD" value="" />
|
||||||
|
|
||||||
|
<env name="RUN_MSSQL_TESTS" value="true" />
|
||||||
|
<env name="MSSQL_HOST" value="172.16.3.1" />
|
||||||
|
<env name="MSSQL_PORT" value="1433" />
|
||||||
|
<env name="MSSQL_DATABASE" value="testexternal" />
|
||||||
|
<env name="MSSQL_USERNAME" value="test" />
|
||||||
|
<env name="MSSQL_PASSWORD" value="test" />
|
||||||
</php>
|
</php>
|
||||||
</phpunit>
|
</phpunit>
|
||||||
|
|||||||
97
tests/Feature/DBQueryTest.php
Normal file
97
tests/Feature/DBQueryTest.php
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
<?php
|
||||||
|
namespace Tests\Feature;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||||
|
use Illuminate\Queue\Console\WorkCommand;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use ProcessMaker\Model\DbSource;
|
||||||
|
use ProcessMaker\Model\Process;
|
||||||
|
use Tests\TestCase;
|
||||||
|
use Propel;
|
||||||
|
use DbConnections;
|
||||||
|
|
||||||
|
class DBQueryTest extends TestCase
|
||||||
|
{
|
||||||
|
use DatabaseTransactions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A basic cache example.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testStandardExecuteQuery()
|
||||||
|
{
|
||||||
|
$results = executeQuery("SELECT * FROM USERS WHERE USR_UID = '00000000000000000000000000000001'");
|
||||||
|
$this->assertCount(1, $results);
|
||||||
|
// Note, we check index 1 because results from executeQuery are 1 indexed, not 0 indexed.
|
||||||
|
$this->assertArraySubset([
|
||||||
|
'USR_UID' => '00000000000000000000000000000001',
|
||||||
|
'USR_USERNAME' => 'admin'
|
||||||
|
], $results[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testDBFacadeQuery()
|
||||||
|
{
|
||||||
|
$record = DB::table('USERS')->where([
|
||||||
|
'USR_UID' => '00000000000000000000000000000001'
|
||||||
|
])->first();
|
||||||
|
$this->assertEquals('admin', $record->USR_USERNAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testStandardExecuteQueryWithExternalMySQLDatabase()
|
||||||
|
{
|
||||||
|
// Our test external database is created in our tests/bootstrap.php file
|
||||||
|
// We'll use our factories to create our process and database
|
||||||
|
$process = factory(Process::class)->create();
|
||||||
|
// Let's create an external DB to ourselves
|
||||||
|
$externalDB = factory(DbSource::class)->create([
|
||||||
|
'DBS_SERVER' => 'localhost',
|
||||||
|
'DBS_PORT' => '3306',
|
||||||
|
'DBS_USERNAME' => env('DB_USERNAME'),
|
||||||
|
// Remember, we have to do some encryption here @see DbSourceFactory.php
|
||||||
|
'DBS_PASSWORD' => \G::encrypt( env('DB_PASSWORD'), 'testexternal') . "_2NnV3ujj3w",
|
||||||
|
'DBS_DATABASE_NAME' => 'testexternal',
|
||||||
|
'PRO_UID' => $process->PRO_UID
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Now set our process ID
|
||||||
|
/**
|
||||||
|
* @todo Migrate to non session based process store
|
||||||
|
*/
|
||||||
|
$_SESSION['PROCESS'] = $process->PRO_UID;
|
||||||
|
// Perform test
|
||||||
|
$results = executeQuery('SELECT * FROM test', $externalDB->DBS_UID);
|
||||||
|
$this->assertCount(1, $results);
|
||||||
|
$this->assertEquals('testvalue', $results[1]['value']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testStandardExecuteQueryWithExternalMSSqlDatabase()
|
||||||
|
{
|
||||||
|
if(!env('RUN_MSSQL_TESTS')) {
|
||||||
|
$this->markTestSkipped('MSSQL Related Test Skipped');
|
||||||
|
}
|
||||||
|
// Our test external database is created in our tests/bootstrap.php file
|
||||||
|
// We'll use our factories to create our process and database
|
||||||
|
$process = factory(Process::class)->create();
|
||||||
|
// Let's create an external DB to ourselves
|
||||||
|
$externalDB = factory(DbSource::class)->create([
|
||||||
|
'DBS_SERVER' => env('MSSQL_HOST'),
|
||||||
|
'DBS_PORT' => env('MSSQL_PORT'),
|
||||||
|
'DBS_TYPE' => 'mssql',
|
||||||
|
'DBS_USERNAME' => env('MSSQL_USERNAME'),
|
||||||
|
// Remember, we have to do some encryption here @see DbSourceFactory.php
|
||||||
|
'DBS_PASSWORD' => \G::encrypt( env('MSSQL_PASSWORD'), 'testexternal') . "_2NnV3ujj3w",
|
||||||
|
'DBS_DATABASE_NAME' => 'testexternal',
|
||||||
|
'PRO_UID' => $process->PRO_UID
|
||||||
|
]);
|
||||||
|
// Now set our process ID
|
||||||
|
/**
|
||||||
|
* @todo Migrate to non session based process store
|
||||||
|
*/
|
||||||
|
$_SESSION['PROCESS'] = $process->PRO_UID;
|
||||||
|
// Perform test
|
||||||
|
$results = executeQuery('SELECT * FROM test', $externalDB->DBS_UID);
|
||||||
|
$this->assertCount(1, $results);
|
||||||
|
$this->assertEquals('testvalue', $results[1]['value']);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,9 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace tests;
|
namespace Tests;
|
||||||
|
|
||||||
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
|
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Propel;
|
||||||
|
|
||||||
abstract class TestCase extends BaseTestCase
|
abstract class TestCase extends BaseTestCase
|
||||||
{
|
{
|
||||||
use CreatesApplication;
|
use CreatesApplication;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
136
tests/bootstrap.php
Normal file
136
tests/bootstrap.php
Normal file
@@ -0,0 +1,136 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Test harness bootstrap that sets up initial defines and builds up the initial database schema
|
||||||
|
*/
|
||||||
|
// Bring in our standard bootstrap
|
||||||
|
include_once(__DIR__ . '/../bootstrap/autoload.php');
|
||||||
|
|
||||||
|
use Illuminate\Contracts\Console\Kernel;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
// Setup our required defines
|
||||||
|
/**
|
||||||
|
* @todo Migrate to configuration parameters
|
||||||
|
*/
|
||||||
|
define('PATH_CORE', 'workflow/engine/');
|
||||||
|
define('PATH_CONFIG', PATH_CORE . 'config/');
|
||||||
|
define('PATH_RBAC_CORE', 'rbac/engine/');
|
||||||
|
define('PATH_DB', 'shared/sites/');
|
||||||
|
define('PATH_DATA', 'shared/rbac/');
|
||||||
|
define('PATH_SEP', '/');
|
||||||
|
define('PATH_METHODS', 'workflow/engine/methods/');
|
||||||
|
|
||||||
|
// Setup basic app services
|
||||||
|
$app = require __DIR__ . '/../bootstrap/app.php';
|
||||||
|
$app->make(Kernel::class)->bootstrap();
|
||||||
|
|
||||||
|
// Setup our testexternal database
|
||||||
|
config(['database.connections.testexternal' => [
|
||||||
|
'driver' => 'mysql',
|
||||||
|
'host' => env('DB_HOST', '127.0.0.1'),
|
||||||
|
'database' => env('DB_TESTEXTERNAL_DB', 'testexternal'),
|
||||||
|
'username' => env('DB_USERNAME', 'root'),
|
||||||
|
'password' => env('DB_PASSWORD', ''),
|
||||||
|
'unix_socket' => env('DB_SOCKET', ''),
|
||||||
|
'charset' => 'utf8mb4',
|
||||||
|
'collation' => 'utf8mb4_unicode_ci',
|
||||||
|
'prefix' => '',
|
||||||
|
'strict' => true,
|
||||||
|
'engine' => null,
|
||||||
|
]]);
|
||||||
|
|
||||||
|
// Now, drop all test tables and repopulate with schema
|
||||||
|
Schema::connection('testexternal')->dropIfExists('test');
|
||||||
|
|
||||||
|
Schema::connection('testexternal')->create('test', function($table) {
|
||||||
|
$table->increments('id');
|
||||||
|
$table->string('value');
|
||||||
|
});
|
||||||
|
DB::connection('testexternal')->table('test')->insert([
|
||||||
|
'value' => 'testvalue'
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Only do if we are supporting MSSql tests
|
||||||
|
if(env('RUN_MSSQL_TESTS')) {
|
||||||
|
config(['database.connections.mssql' => [
|
||||||
|
'driver' => 'sqlsrv',
|
||||||
|
'host' => env('MSSQL_HOST', '127.0.0.1'),
|
||||||
|
'database' => env('MSSQL_DATABASE', 'testexternal'),
|
||||||
|
'username' => env('MSSQL_USERNAME', 'root'),
|
||||||
|
'password' => env('MSSQL_PASSWORD', ''),
|
||||||
|
]]);
|
||||||
|
|
||||||
|
Schema::connection('mssql')->dropIfExists('test');
|
||||||
|
Schema::connection('mssql')->create('test', function($table) {
|
||||||
|
$table->increments('id');
|
||||||
|
$table->string('value');
|
||||||
|
});
|
||||||
|
DB::connection('mssql')->table('test')->insert([
|
||||||
|
'value' => 'testvalue'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// THIS IS FOR STANDARD PROCESSMAKER TABLES
|
||||||
|
|
||||||
|
// Now, drop all test tables and repopulate with schema
|
||||||
|
DB::unprepared('SET FOREIGN_KEY_CHECKS = 0');
|
||||||
|
$colname = 'Tables_in_' . env('DB_DATABASE');
|
||||||
|
$tables = DB::select('SHOW TABLES');
|
||||||
|
$drop = [];
|
||||||
|
foreach($tables as $table) {
|
||||||
|
$drop[] = $table->$colname;
|
||||||
|
}
|
||||||
|
if(count($drop)) {
|
||||||
|
$drop = implode(',', $drop);
|
||||||
|
DB::statement("DROP TABLE $drop");
|
||||||
|
DB::unprepared('SET FOREIGN_KEY_CHECKS = 1');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Repopulate with schema and standard inserts
|
||||||
|
DB::unprepared(file_get_contents(PATH_CORE.'data/mysql/schema.sql'));
|
||||||
|
DB::unprepared(file_get_contents(PATH_RBAC_CORE.'data/mysql/schema.sql'));
|
||||||
|
DB::unprepared(file_get_contents(PATH_CORE.'data/mysql/insert.sql'));
|
||||||
|
DB::unprepared(file_get_contents(PATH_RBAC_CORE.'data/mysql/insert.sql'));
|
||||||
|
|
||||||
|
// Set our APP_SEQUENCE val
|
||||||
|
DB::table('APP_SEQUENCE')->insert([
|
||||||
|
'ID' => 1
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Setup our initial oauth client for our web designer
|
||||||
|
DB::table('OAUTH_CLIENTS')->insert([
|
||||||
|
'CLIENT_ID' => 'x-pm-local-client',
|
||||||
|
'CLIENT_SECRET' => '179ad45c6ce2cb97cf1029e212046e81',
|
||||||
|
'CLIENT_NAME' => 'PM Web Designer',
|
||||||
|
'CLIENT_DESCRIPTION' => 'ProcessMaker Web Designer App',
|
||||||
|
'CLIENT_WEBSITE' => 'www.processmaker.com',
|
||||||
|
'REDIRECT_URI' => config('app.url') . '/sys' . config('system.workspace').'/en/neoclassic/oauth2/grant',
|
||||||
|
'USR_UID' => '00000000000000000000000000000001'
|
||||||
|
]);
|
||||||
|
DB::table('OAUTH_ACCESS_TOKENS')->insert([
|
||||||
|
'ACCESS_TOKEN' => '39704d17049f5aef45e884e7b769989269502f83',
|
||||||
|
'CLIENT_ID' => 'x-pm-local-client',
|
||||||
|
'USER_ID' => '00000000000000000000000000000001',
|
||||||
|
'EXPIRES' => '2017-06-15 17:55:19',
|
||||||
|
'SCOPE' => 'view_processes edit_processes *'
|
||||||
|
]);
|
||||||
|
|
||||||
|
// We need to manually initialize Propel with our test database
|
||||||
|
Propel::initConfiguration([
|
||||||
|
'datasources' => [
|
||||||
|
'workflow' => [
|
||||||
|
'connection' => 'mysql://' . config('database.connections.workflow.username') . ':' . config('database.connections.workflow.password') . '@' . config('database.connections.workflow.host') . '/test?encoding=utf8',
|
||||||
|
'adapter' => 'mysql'
|
||||||
|
],
|
||||||
|
'rbac' => [
|
||||||
|
'connection' => 'mysql://' . config('database.connections.workflow.username') . ':' . config('database.connections.workflow.password') . '@' . config('database.connections.workflow.host') . '/test?encoding=utf8',
|
||||||
|
'adapter' => 'mysql'
|
||||||
|
],
|
||||||
|
'rp' => [
|
||||||
|
'connection' => 'mysql://' . config('database.connections.workflow.username') . ':' . config('database.connections.workflow.password') . '@' . config('database.connections.workflow.host') . '/test?encoding=utf8',
|
||||||
|
'adapter' => 'mysql'
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]);
|
||||||
3
thirdparty/creole/Statement.php
vendored
3
thirdparty/creole/Statement.php
vendored
@@ -33,7 +33,8 @@
|
|||||||
* @version $Revision: 1.17 $
|
* @version $Revision: 1.17 $
|
||||||
* @package creole
|
* @package creole
|
||||||
*/
|
*/
|
||||||
interface Statement {
|
interface Statement
|
||||||
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the maximum number of rows to return from db.
|
* Sets the maximum number of rows to return from db.
|
||||||
|
|||||||
332
thirdparty/creole/contrib/DBArrayConnection.php
vendored
332
thirdparty/creole/contrib/DBArrayConnection.php
vendored
@@ -7,29 +7,31 @@ require_once 'creole/common/PreparedStatementCommon.php';
|
|||||||
require_once 'creole/ResultSet.php';
|
require_once 'creole/ResultSet.php';
|
||||||
require_once 'creole/common/ResultSetCommon.php';
|
require_once 'creole/common/ResultSetCommon.php';
|
||||||
|
|
||||||
class DBArrayPreparedStatement extends PreparedStatementCommon implements PreparedStatement {
|
class DBArrayPreparedStatement extends PreparedStatementCommon implements PreparedStatement
|
||||||
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Quotes string using native mysql function (mysql_real_escape_string()).
|
* Quotes string using native mysql function (mysqli_real_escape_string()).
|
||||||
* @param string $str
|
* @param string $str
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function escape($str) {
|
protected function escape($str)
|
||||||
|
{
|
||||||
return $str;
|
return $str;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function prepareStatement($sql) {
|
private function prepareStatement($sql)
|
||||||
|
{
|
||||||
return $sql;
|
return $sql;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class DBArrayResultSet extends ResultSetCommon implements ResultSet {
|
class DBArrayResultSet extends ResultSetCommon implements ResultSet
|
||||||
|
{
|
||||||
public $dbArray = null;
|
public $dbArray = null;
|
||||||
|
|
||||||
public function seek($rownum) {
|
public function seek($rownum)
|
||||||
|
{
|
||||||
$this->cursorPos = $rownum;
|
$this->cursorPos = $rownum;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -37,56 +39,38 @@ class DBArrayResultSet extends ResultSetCommon implements ResultSet {
|
|||||||
/**
|
/**
|
||||||
* @see ResultSet::next()
|
* @see ResultSet::next()
|
||||||
*/
|
*/
|
||||||
public function next() {
|
public function next()
|
||||||
|
{
|
||||||
if ($this->cursorPos == 0) {
|
if ($this->cursorPos == 0) {
|
||||||
$this->cursorPos++;
|
$this->cursorPos++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->cursorPos >= count($this->dbArray)) {
|
if ($this->cursorPos >= count($this->dbArray)) {
|
||||||
$this->fields = NULL;
|
$this->fields = null;
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
$this->fields = $this->dbArray[$this->cursorPos];
|
$this->fields = $this->dbArray[$this->cursorPos];
|
||||||
$this->cursorPos++;
|
$this->cursorPos++;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
*
|
|
||||||
$this->fields = mysql_fetch_array($this->result, $this->fetchmode);
|
|
||||||
|
|
||||||
if (!$this->fields) {
|
|
||||||
$errno = mysql_errno($this->conn->getResource());
|
|
||||||
if (!$errno) {
|
|
||||||
// We've advanced beyond end of recordset.
|
|
||||||
$this->afterLast();
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
throw new SQLException("Error fetching result", mysql_error($this->conn->getResource()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->fetchmode === ResultSet::FETCHMODE_ASSOC && $this->lowerAssocCase) {
|
|
||||||
$this->fields = array_change_key_case($this->fields, CASE_LOWER);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Advance cursor position
|
|
||||||
*/
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see ResultSet::getRecordCount()
|
* @see ResultSet::getRecordCount()
|
||||||
*/
|
*/
|
||||||
function getRecordCount() {
|
public function getRecordCount()
|
||||||
return (int) count($this->dbArray) - 1;
|
{
|
||||||
|
return (int)count($this->dbArray) - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see ResultSet::close()
|
* @see ResultSet::close()
|
||||||
*/
|
*/
|
||||||
function close() {
|
public function close()
|
||||||
|
{
|
||||||
if (is_resource($this->result)) {
|
if (is_resource($this->result)) {
|
||||||
@mysql_free_result($this->result);
|
mysqli_free_result($this->result);
|
||||||
}
|
}
|
||||||
$this->fields = array();
|
$this->fields = array();
|
||||||
}
|
}
|
||||||
@@ -96,7 +80,8 @@ class DBArrayResultSet extends ResultSetCommon implements ResultSet {
|
|||||||
* No rtrim() necessary for MySQL, as this happens natively.
|
* No rtrim() necessary for MySQL, as this happens natively.
|
||||||
* @see ResultSet::getString()
|
* @see ResultSet::getString()
|
||||||
*/
|
*/
|
||||||
public function getString($column) {
|
public function getString($column)
|
||||||
|
{
|
||||||
$idx = (is_int($column) ? $column - 1 : $column);
|
$idx = (is_int($column) ? $column - 1 : $column);
|
||||||
if (!array_key_exists($idx, $this->fields)) {
|
if (!array_key_exists($idx, $this->fields)) {
|
||||||
throw new SQLException("Invalid resultset column: " . $column);
|
throw new SQLException("Invalid resultset column: " . $column);
|
||||||
@@ -104,16 +89,16 @@ class DBArrayResultSet extends ResultSetCommon implements ResultSet {
|
|||||||
if ($this->fields[$idx] === null) {
|
if ($this->fields[$idx] === null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return (string) $this->fields[$idx];
|
return (string)$this->fields[$idx];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DBArray implementation of Connection.
|
* DBArray implementation of Connection.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class DBArrayConnection implements Connection {
|
class DBArrayConnection implements Connection
|
||||||
|
{
|
||||||
|
|
||||||
/** @var Connection */
|
/** @var Connection */
|
||||||
private $childConnection = null;
|
private $childConnection = null;
|
||||||
@@ -133,7 +118,8 @@ class DBArrayConnection implements Connection {
|
|||||||
* The logger class must have a log() method. All messages are logged at default log level.
|
* The logger class must have a log() method. All messages are logged at default log level.
|
||||||
* @param object $logger
|
* @param object $logger
|
||||||
*/
|
*/
|
||||||
public function setLogger($logger) {
|
public function setLogger($logger)
|
||||||
|
{
|
||||||
krumo('DBArrayConnection setLogger ');
|
krumo('DBArrayConnection setLogger ');
|
||||||
die;
|
die;
|
||||||
$this->logger = $logger;
|
$this->logger = $logger;
|
||||||
@@ -142,13 +128,13 @@ class DBArrayConnection implements Connection {
|
|||||||
/**
|
/**
|
||||||
* connect()
|
* connect()
|
||||||
*/
|
*/
|
||||||
public function connect($dsninfo, $flags = 0) {
|
public function connect($dsninfo, $flags = 0)
|
||||||
|
{
|
||||||
if (!($driver = Creole::getDriver($dsninfo['phptype']))) {
|
if (!($driver = Creole::getDriver($dsninfo['phptype']))) {
|
||||||
throw new SQLException("No driver has been registered to handle connection type: $type");
|
throw new SQLException("No driver has been registered to handle connection type: $type");
|
||||||
}
|
}
|
||||||
global $_DBArray;
|
global $_DBArray;
|
||||||
if ((!isset($_DBArray) ) && (isset($_SESSION['_DBArray']))) {
|
if ((!isset($_DBArray)) && (isset($_SESSION['_DBArray']))) {
|
||||||
//throw new SQLException("No Database Array defined for this connection but exists in session");
|
//throw new SQLException("No Database Array defined for this connection but exists in session");
|
||||||
//Added by JHL to avoid errors trying to execute query of a dbarray on June 25, 2011
|
//Added by JHL to avoid errors trying to execute query of a dbarray on June 25, 2011
|
||||||
$_DBArray = $_SESSION['_DBArray'];
|
$_DBArray = $_SESSION['_DBArray'];
|
||||||
@@ -163,7 +149,8 @@ class DBArrayConnection implements Connection {
|
|||||||
/**
|
/**
|
||||||
* @see Connection::getDatabaseInfo()
|
* @see Connection::getDatabaseInfo()
|
||||||
*/
|
*/
|
||||||
public function getDatabaseInfo() {
|
public function getDatabaseInfo()
|
||||||
|
{
|
||||||
krumo('DBArrayConnection getDatabaseInfo ');
|
krumo('DBArrayConnection getDatabaseInfo ');
|
||||||
die;
|
die;
|
||||||
return $this->childConnection->getDatabaseInfo();
|
return $this->childConnection->getDatabaseInfo();
|
||||||
@@ -172,7 +159,8 @@ class DBArrayConnection implements Connection {
|
|||||||
/**
|
/**
|
||||||
* @see Connection::getIdGenerator()
|
* @see Connection::getIdGenerator()
|
||||||
*/
|
*/
|
||||||
public function getIdGenerator() {
|
public function getIdGenerator()
|
||||||
|
{
|
||||||
krumo('DBArrayConnection getIdGenerator ');
|
krumo('DBArrayConnection getIdGenerator ');
|
||||||
die;
|
die;
|
||||||
return $this->childConnection->getIdGenerator();
|
return $this->childConnection->getIdGenerator();
|
||||||
@@ -181,7 +169,8 @@ class DBArrayConnection implements Connection {
|
|||||||
/**
|
/**
|
||||||
* @see Connection::isConnected()
|
* @see Connection::isConnected()
|
||||||
*/
|
*/
|
||||||
public function isConnected() {
|
public function isConnected()
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
krumo('DBArrayConnection isConnected ');
|
krumo('DBArrayConnection isConnected ');
|
||||||
die;
|
die;
|
||||||
@@ -191,7 +180,8 @@ class DBArrayConnection implements Connection {
|
|||||||
/**
|
/**
|
||||||
* @see Connection::prepareStatement()
|
* @see Connection::prepareStatement()
|
||||||
*/
|
*/
|
||||||
public function prepareStatement($dataSql) {
|
public function prepareStatement($dataSql)
|
||||||
|
{
|
||||||
$this->dataSql = $dataSql;
|
$this->dataSql = $dataSql;
|
||||||
return new DBArrayPreparedStatement($this, $this->dataSql);
|
return new DBArrayPreparedStatement($this, $this->dataSql);
|
||||||
}
|
}
|
||||||
@@ -199,7 +189,8 @@ class DBArrayConnection implements Connection {
|
|||||||
/**
|
/**
|
||||||
* @see Connection::createStatement()
|
* @see Connection::createStatement()
|
||||||
*/
|
*/
|
||||||
public function createStatement() {
|
public function createStatement()
|
||||||
|
{
|
||||||
return new DBArrayPreparedStatement($this, null);
|
return new DBArrayPreparedStatement($this, null);
|
||||||
return new DBArrayPreparedStatement($this, $dataSql['sql']);
|
return new DBArrayPreparedStatement($this, $dataSql['sql']);
|
||||||
krumo('DBArrayConnection createStatement ');
|
krumo('DBArrayConnection createStatement ');
|
||||||
@@ -212,7 +203,8 @@ class DBArrayConnection implements Connection {
|
|||||||
/**
|
/**
|
||||||
* @see Connection::applyLimit()
|
* @see Connection::applyLimit()
|
||||||
*/
|
*/
|
||||||
public function applyLimit(&$sql, $offset, $limit) {
|
public function applyLimit(&$sql, $offset, $limit)
|
||||||
|
{
|
||||||
krumo('DBArrayConnection applyLimit ');
|
krumo('DBArrayConnection applyLimit ');
|
||||||
die;
|
die;
|
||||||
$this->log("applyLimit(): $sql, offset: $offset, limit: $limit");
|
$this->log("applyLimit(): $sql, offset: $offset, limit: $limit");
|
||||||
@@ -222,7 +214,8 @@ class DBArrayConnection implements Connection {
|
|||||||
/**
|
/**
|
||||||
* @see Connection::close()
|
* @see Connection::close()
|
||||||
*/
|
*/
|
||||||
public function close() {
|
public function close()
|
||||||
|
{
|
||||||
krumo('DBArrayConnection connect ');
|
krumo('DBArrayConnection connect ');
|
||||||
die;
|
die;
|
||||||
$this->log("close(): Closing connection.");
|
$this->log("close(): Closing connection.");
|
||||||
@@ -238,7 +231,7 @@ class DBArrayConnection implements Connection {
|
|||||||
public function evaluateClause($clause)
|
public function evaluateClause($clause)
|
||||||
{
|
{
|
||||||
$sqlStr = $clause;
|
$sqlStr = $clause;
|
||||||
$sqlStr = str_replace(array('\\\'','\\"',"\r\n","\n","()"), array("''",'""'," "," "," "), $sqlStr);
|
$sqlStr = str_replace(array('\\\'', '\\"', "\r\n", "\n", "()"), array("''", '""', " ", " ", " "), $sqlStr);
|
||||||
$regex = "/((?:)[@A-Za-z0-9_.-]+(?:\(\s*\)){0,1})"
|
$regex = "/((?:)[@A-Za-z0-9_.-]+(?:\(\s*\)){0,1})"
|
||||||
. "|(\+|-|\*|\/|!=|>=|<=|<>|>|<|&&|\|\||=|\^)"
|
. "|(\+|-|\*|\/|!=|>=|<=|<>|>|<|&&|\|\||=|\^)"
|
||||||
. "|(\(.*?\))"
|
. "|(\(.*?\))"
|
||||||
@@ -264,45 +257,43 @@ class DBArrayConnection implements Connection {
|
|||||||
foreach ($evalClause as $key => $value) {
|
foreach ($evalClause as $key => $value) {
|
||||||
$value = strtoupper(trim($value));
|
$value = strtoupper(trim($value));
|
||||||
$sSelect = strtoupper($this->dataSql['selectClause'][0]);
|
$sSelect = strtoupper($this->dataSql['selectClause'][0]);
|
||||||
if( stripos($sSelect, $value) !== false ) {
|
if (stripos($sSelect, $value) !== false) {
|
||||||
$evalClause[$key] = "\$row['" . $evalClause[$key] . "']";
|
$evalClause[$key] = "\$row['" . $evalClause[$key] . "']";
|
||||||
}
|
}
|
||||||
if ( in_array($value, $aOperator) ) {
|
if (in_array($value, $aOperator)) {
|
||||||
switch ( $value ) {
|
switch ($value) {
|
||||||
case "=" :
|
case "=":
|
||||||
$evalClause[$key] = "==";
|
$evalClause[$key] = "==";
|
||||||
break;
|
break;
|
||||||
case "<>" :
|
case "<>":
|
||||||
$evalClause[$key] = "!=";
|
$evalClause[$key] = "!=";
|
||||||
break;
|
break;
|
||||||
case "AND" :
|
case "AND":
|
||||||
$evalClause[$key] = "&&";
|
$evalClause[$key] = "&&";
|
||||||
break;
|
break;
|
||||||
case "OR" :
|
case "OR":
|
||||||
$evalClause[$key] = "||";
|
$evalClause[$key] = "||";
|
||||||
break;
|
break;
|
||||||
case "NOT" :
|
case "NOT":
|
||||||
$evalClause[$key] = "!";
|
$evalClause[$key] = "!";
|
||||||
break;
|
break;
|
||||||
case "LIKE" :
|
case "LIKE":
|
||||||
$evalClause[$key] = ", ";
|
$evalClause[$key] = ", ";
|
||||||
if (trim($evalClause[$key-1]) !== "" ) {
|
if (trim($evalClause[$key - 1]) !== "") {
|
||||||
$evalClause[$key-1] = " stripos(" . $evalClause[$key-1];
|
$evalClause[$key - 1] = " stripos(" . $evalClause[$key - 1];
|
||||||
}
|
} else {
|
||||||
else {
|
if (trim($evalClause[$key - 2]) !== "") {
|
||||||
if (trim($evalClause[$key-2]) !== "" ) {
|
$evalClause[$key - 2] = " stripos(" . $evalClause[$key - 2];
|
||||||
$evalClause[$key-2] = " stripos(" . $evalClause[$key-2];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (trim($evalClause[$key+1]) !== "" ) {
|
if (trim($evalClause[$key + 1]) !== "") {
|
||||||
$evalClause[$key+1] = str_replace("%", "", $evalClause[$key+1]);
|
$evalClause[$key + 1] = str_replace("%", "", $evalClause[$key + 1]);
|
||||||
$evalClause[$key+1] = $evalClause[$key+1] . ") !== false";
|
$evalClause[$key + 1] = $evalClause[$key + 1] . ") !== false";
|
||||||
}
|
} else {
|
||||||
else {
|
if (trim($evalClause[$key + 2]) !== "") {
|
||||||
if (trim($evalClause[$key+2]) !== "" ) {
|
$evalClause[$key + 2] = str_replace("%", "", $evalClause[$key + 2]);
|
||||||
$evalClause[$key+2] = str_replace("%", "", $evalClause[$key+2]);
|
$evalClause[$key + 2] = $evalClause[$key + 2] . ") !== false";
|
||||||
$evalClause[$key+2] = $evalClause[$key+2] . ") !== false";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -313,7 +304,8 @@ class DBArrayConnection implements Connection {
|
|||||||
return $$sEvalClause;
|
return $$sEvalClause;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function parseSqlString($query) {
|
private function parseSqlString($query)
|
||||||
|
{
|
||||||
//we need a SQL parse, for now we only search for text 'select * from'
|
//we need a SQL parse, for now we only search for text 'select * from'
|
||||||
/* $aux = str_ireplace ( 'select * from', '', trim($query) );
|
/* $aux = str_ireplace ( 'select * from', '', trim($query) );
|
||||||
$sql = array();
|
$sql = array();
|
||||||
@@ -330,13 +322,13 @@ class DBArrayConnection implements Connection {
|
|||||||
$sql['selectClause'][0] = isset($matches[1]) ? $matches[1] : '';//Include selectClause. By JHL
|
$sql['selectClause'][0] = isset($matches[1]) ? $matches[1] : '';//Include selectClause. By JHL
|
||||||
$sql['fromClause'][0] = isset($matches[2]) ? $matches[2] : '';
|
$sql['fromClause'][0] = isset($matches[2]) ? $matches[2] : '';
|
||||||
//$sql['whereClause'][0] = isset($matches[3]) ? $matches[3] : '';
|
//$sql['whereClause'][0] = isset($matches[3]) ? $matches[3] : '';
|
||||||
if(isset($matches[3])){
|
if (isset($matches[3])) {
|
||||||
$sql['whereClause'][0] = $matches[3];
|
$sql['whereClause'][0] = $matches[3];
|
||||||
}
|
}
|
||||||
if(isset($matches[4])){
|
if (isset($matches[4])) {
|
||||||
$sql['groupByClause'][0] = $matches[4];
|
$sql['groupByClause'][0] = $matches[4];
|
||||||
}
|
}
|
||||||
if(isset($matches[5])){
|
if (isset($matches[5])) {
|
||||||
$sql['orderByClause'][0] = $matches[5];
|
$sql['orderByClause'][0] = $matches[5];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -349,9 +341,10 @@ class DBArrayConnection implements Connection {
|
|||||||
/**
|
/**
|
||||||
* @see Connection::executeQuery()
|
* @see Connection::executeQuery()
|
||||||
*/
|
*/
|
||||||
public function executeQuery($sql, $fetchmode = null) {
|
public function executeQuery($sql, $fetchmode = null)
|
||||||
|
{
|
||||||
if (!is_array($sql) && strlen($sql) > 1) {
|
if (!is_array($sql) && strlen($sql) > 1) {
|
||||||
$this->dataSql=$sql = $this->parseSqlString($sql);
|
$this->dataSql = $sql = $this->parseSqlString($sql);
|
||||||
}
|
}
|
||||||
$resultSet = new DBArrayResultSet($this, $sql, $fetchmode);
|
$resultSet = new DBArrayResultSet($this, $sql, $fetchmode);
|
||||||
$tableName = $sql['fromClause'][0];
|
$tableName = $sql['fromClause'][0];
|
||||||
@@ -364,10 +357,11 @@ class DBArrayConnection implements Connection {
|
|||||||
|
|
||||||
|
|
||||||
foreach ($this->_DBArray[$tableName] as $key => $row) {
|
foreach ($this->_DBArray[$tableName] as $key => $row) {
|
||||||
if ($key == 0)
|
if ($key == 0) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
$flag = 1;
|
$flag = 1;
|
||||||
if (isset($sql['whereClause'])){//If there is no where then return the row
|
if (isset($sql['whereClause'])) {//If there is no where then return the row
|
||||||
foreach ($sql['whereClause'] as $keyClause => $valClause) {
|
foreach ($sql['whereClause'] as $keyClause => $valClause) {
|
||||||
if (isset($valClause) && $flag == 1) {
|
if (isset($valClause) && $flag == 1) {
|
||||||
//$toEval = "\$flag = ( " . ($valClause != '' ? str_replace('=', '==', $valClause): '1') . ') ?1 :0;' ;
|
//$toEval = "\$flag = ( " . ($valClause != '' ? str_replace('=', '==', $valClause): '1') . ') ?1 :0;' ;
|
||||||
@@ -379,7 +373,7 @@ class DBArrayConnection implements Connection {
|
|||||||
$valClause = str_replace(")'", "", $valClause);
|
$valClause = str_replace(")'", "", $valClause);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stripos($valClause, "\$row[") !== false ){
|
if (stripos($valClause, "\$row[") !== false) {
|
||||||
if (stripos($valClause, "LIKE") !== false) {
|
if (stripos($valClause, "LIKE") !== false) {
|
||||||
$valClause = str_replace("%", "", $valClause);
|
$valClause = str_replace("%", "", $valClause);
|
||||||
$operands = explode('LIKE', $valClause);
|
$operands = explode('LIKE', $valClause);
|
||||||
@@ -393,15 +387,14 @@ class DBArrayConnection implements Connection {
|
|||||||
} else {//this is for EQUAL, LESS_THAN_EQUAL, ETC,
|
} else {//this is for EQUAL, LESS_THAN_EQUAL, ETC,
|
||||||
$toEval = "\$flag = ( " . ($valClause != '' ? $valClause : '1') . ') ?1 :0;';
|
$toEval = "\$flag = ( " . ($valClause != '' ? $valClause : '1') . ') ?1 :0;';
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$valClause = $this->evaluateClauseWhere($valClause);
|
$valClause = $this->evaluateClauseWhere($valClause);
|
||||||
$toEval = "\$flag = ( " . ($valClause != '' ? $valClause : '1') . ') ?1 :0;';
|
$toEval = "\$flag = ( " . ($valClause != '' ? $valClause : '1') . ') ?1 :0;';
|
||||||
}
|
}
|
||||||
eval($toEval);
|
eval($toEval);
|
||||||
}
|
}
|
||||||
}}else{
|
}
|
||||||
|
} else {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($flag) {
|
if ($flag) {
|
||||||
@@ -410,10 +403,11 @@ class DBArrayConnection implements Connection {
|
|||||||
}
|
}
|
||||||
if ($this->dataSql['selectClause'][0] == 'COUNT(*)') {
|
if ($this->dataSql['selectClause'][0] == 'COUNT(*)') {
|
||||||
$rows[] = array('1' => 'integer');
|
$rows[] = array('1' => 'integer');
|
||||||
if (isset($resultRow) && is_array($resultRow))
|
if (isset($resultRow) && is_array($resultRow)) {
|
||||||
$rows[] = array('1' => count($resultRow));
|
$rows[] = array('1' => count($resultRow));
|
||||||
else
|
} else {
|
||||||
$rows[] = array('1' => 0);
|
$rows[] = array('1' => 0);
|
||||||
|
}
|
||||||
$resultSet->dbArray = $rows;
|
$resultSet->dbArray = $rows;
|
||||||
return $resultSet;
|
return $resultSet;
|
||||||
}
|
}
|
||||||
@@ -424,7 +418,7 @@ class DBArrayConnection implements Connection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (isset($this->dataSql['orderByClause'])&&is_array($this->dataSql['orderByClause']) && count($this->dataSql['orderByClause']) > 0) {
|
if (isset($this->dataSql['orderByClause']) && is_array($this->dataSql['orderByClause']) && count($this->dataSql['orderByClause']) > 0) {
|
||||||
foreach ($resultRow as $key => $row) {
|
foreach ($resultRow as $key => $row) {
|
||||||
foreach ($this->dataSql['orderByClause'] as $keyOrder => $valOrder) {
|
foreach ($this->dataSql['orderByClause'] as $keyOrder => $valOrder) {
|
||||||
if (isset($row[$valOrder['columnName']])) {
|
if (isset($row[$valOrder['columnName']])) {
|
||||||
@@ -439,53 +433,92 @@ class DBArrayConnection implements Connection {
|
|||||||
}
|
}
|
||||||
$aOrderClause = $this->dataSql['orderByClause'];
|
$aOrderClause = $this->dataSql['orderByClause'];
|
||||||
switch (count($column)) {
|
switch (count($column)) {
|
||||||
case 1 :
|
case 1:
|
||||||
array_multisort($column[$aOrderClause[0]['columnName']], $direction[0], $resultRow);
|
array_multisort($column[$aOrderClause[0]['columnName']], $direction[0], $resultRow);
|
||||||
break;
|
break;
|
||||||
case 2 :
|
case 2:
|
||||||
array_multisort($column[$aOrderClause[0]['columnName']], $direction[0],
|
array_multisort(
|
||||||
$column[$aOrderClause[1]['columnName']], $direction[1],
|
$column[$aOrderClause[0]['columnName']],
|
||||||
$resultRow);
|
$direction[0],
|
||||||
|
$column[$aOrderClause[1]['columnName']],
|
||||||
|
$direction[1],
|
||||||
|
$resultRow
|
||||||
|
);
|
||||||
break;
|
break;
|
||||||
case 3 :
|
case 3:
|
||||||
array_multisort($column[$aOrderClause[0]['columnName']], $direction[0],
|
array_multisort(
|
||||||
$column[$aOrderClause[1]['columnName']], $direction[1],
|
$column[$aOrderClause[0]['columnName']],
|
||||||
$column[$aOrderClause[2]['columnName']], $direction[2],
|
$direction[0],
|
||||||
$resultRow);
|
$column[$aOrderClause[1]['columnName']],
|
||||||
|
$direction[1],
|
||||||
|
$column[$aOrderClause[2]['columnName']],
|
||||||
|
$direction[2],
|
||||||
|
$resultRow
|
||||||
|
);
|
||||||
break;
|
break;
|
||||||
case 4 :
|
case 4:
|
||||||
array_multisort($column[$aOrderClause[0]['columnName']], $direction[0],
|
array_multisort(
|
||||||
$column[$aOrderClause[1]['columnName']], $direction[1],
|
$column[$aOrderClause[0]['columnName']],
|
||||||
$column[$aOrderClause[2]['columnName']], $direction[2],
|
$direction[0],
|
||||||
$column[$aOrderClause[3]['columnName']], $direction[3],
|
$column[$aOrderClause[1]['columnName']],
|
||||||
$resultRow);
|
$direction[1],
|
||||||
|
$column[$aOrderClause[2]['columnName']],
|
||||||
|
$direction[2],
|
||||||
|
$column[$aOrderClause[3]['columnName']],
|
||||||
|
$direction[3],
|
||||||
|
$resultRow
|
||||||
|
);
|
||||||
break;
|
break;
|
||||||
case 5 :
|
case 5:
|
||||||
array_multisort($column[$aOrderClause[0]['columnName']], $direction[0],
|
array_multisort(
|
||||||
$column[$aOrderClause[1]['columnName']], $direction[1],
|
$column[$aOrderClause[0]['columnName']],
|
||||||
$column[$aOrderClause[2]['columnName']], $direction[2],
|
$direction[0],
|
||||||
$column[$aOrderClause[3]['columnName']], $direction[3],
|
$column[$aOrderClause[1]['columnName']],
|
||||||
$column[$aOrderClause[4]['columnName']], $direction[4],
|
$direction[1],
|
||||||
$resultRow);
|
$column[$aOrderClause[2]['columnName']],
|
||||||
|
$direction[2],
|
||||||
|
$column[$aOrderClause[3]['columnName']],
|
||||||
|
$direction[3],
|
||||||
|
$column[$aOrderClause[4]['columnName']],
|
||||||
|
$direction[4],
|
||||||
|
$resultRow
|
||||||
|
);
|
||||||
break;
|
break;
|
||||||
case 6 :
|
case 6:
|
||||||
array_multisort($column[$aOrderClause[0]['columnName']], $direction[0],
|
array_multisort(
|
||||||
$column[$aOrderClause[1]['columnName']], $direction[1],
|
$column[$aOrderClause[0]['columnName']],
|
||||||
$column[$aOrderClause[2]['columnName']], $direction[2],
|
$direction[0],
|
||||||
$column[$aOrderClause[3]['columnName']], $direction[3],
|
$column[$aOrderClause[1]['columnName']],
|
||||||
$column[$aOrderClause[4]['columnName']], $direction[4],
|
$direction[1],
|
||||||
$column[$aOrderClause[5]['columnName']], $direction[5],
|
$column[$aOrderClause[2]['columnName']],
|
||||||
$resultRow);
|
$direction[2],
|
||||||
|
$column[$aOrderClause[3]['columnName']],
|
||||||
|
$direction[3],
|
||||||
|
$column[$aOrderClause[4]['columnName']],
|
||||||
|
$direction[4],
|
||||||
|
$column[$aOrderClause[5]['columnName']],
|
||||||
|
$direction[5],
|
||||||
|
$resultRow
|
||||||
|
);
|
||||||
break;
|
break;
|
||||||
case 7 :
|
case 7:
|
||||||
array_multisort($column[$aOrderClause[0]['columnName']], $direction[0],
|
array_multisort(
|
||||||
$column[$aOrderClause[1]['columnName']], $direction[1],
|
$column[$aOrderClause[0]['columnName']],
|
||||||
$column[$aOrderClause[2]['columnName']], $direction[2],
|
$direction[0],
|
||||||
$column[$aOrderClause[3]['columnName']], $direction[3],
|
$column[$aOrderClause[1]['columnName']],
|
||||||
$column[$aOrderClause[4]['columnName']], $direction[4],
|
$direction[1],
|
||||||
$column[$aOrderClause[5]['columnName']], $direction[5],
|
$column[$aOrderClause[2]['columnName']],
|
||||||
$column[$aOrderClause[6]['columnName']], $direction[6],
|
$direction[2],
|
||||||
$resultRow);
|
$column[$aOrderClause[3]['columnName']],
|
||||||
|
$direction[3],
|
||||||
|
$column[$aOrderClause[4]['columnName']],
|
||||||
|
$direction[4],
|
||||||
|
$column[$aOrderClause[5]['columnName']],
|
||||||
|
$direction[5],
|
||||||
|
$column[$aOrderClause[6]['columnName']],
|
||||||
|
$direction[6],
|
||||||
|
$resultRow
|
||||||
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -523,7 +556,8 @@ class DBArrayConnection implements Connection {
|
|||||||
/**
|
/**
|
||||||
* @see Connection::executeUpdate()
|
* @see Connection::executeUpdate()
|
||||||
*/
|
*/
|
||||||
public function executeUpdate($sql) {
|
public function executeUpdate($sql)
|
||||||
|
{
|
||||||
krumo('DBArrayConnection executeUpdate ');
|
krumo('DBArrayConnection executeUpdate ');
|
||||||
die;
|
die;
|
||||||
$this->log("executeUpdate(): $sql");
|
$this->log("executeUpdate(): $sql");
|
||||||
@@ -535,7 +569,8 @@ class DBArrayConnection implements Connection {
|
|||||||
/**
|
/**
|
||||||
* @see Connection::getUpdateCount()
|
* @see Connection::getUpdateCount()
|
||||||
*/
|
*/
|
||||||
public function getUpdateCount() {
|
public function getUpdateCount()
|
||||||
|
{
|
||||||
krumo('DBArrayConnection getUpdateCount ');
|
krumo('DBArrayConnection getUpdateCount ');
|
||||||
die;
|
die;
|
||||||
return $this->childConnection->getUpdateCount();
|
return $this->childConnection->getUpdateCount();
|
||||||
@@ -544,7 +579,8 @@ class DBArrayConnection implements Connection {
|
|||||||
/**
|
/**
|
||||||
* @see Connection::prepareCall()
|
* @see Connection::prepareCall()
|
||||||
* */
|
* */
|
||||||
public function prepareCall($sql) {
|
public function prepareCall($sql)
|
||||||
|
{
|
||||||
krumo('DBArrayConnection prepareCall ');
|
krumo('DBArrayConnection prepareCall ');
|
||||||
die;
|
die;
|
||||||
$this->log("prepareCall(): $sql");
|
$this->log("prepareCall(): $sql");
|
||||||
@@ -554,7 +590,8 @@ class DBArrayConnection implements Connection {
|
|||||||
/**
|
/**
|
||||||
* @see Connection::getResource()
|
* @see Connection::getResource()
|
||||||
*/
|
*/
|
||||||
public function getResource() {
|
public function getResource()
|
||||||
|
{
|
||||||
krumo('DBArrayConnection getResource ');
|
krumo('DBArrayConnection getResource ');
|
||||||
die;
|
die;
|
||||||
return $this->childConnection->getResource();
|
return $this->childConnection->getResource();
|
||||||
@@ -563,7 +600,8 @@ class DBArrayConnection implements Connection {
|
|||||||
/**
|
/**
|
||||||
* @see Connection::connect()
|
* @see Connection::connect()
|
||||||
*/
|
*/
|
||||||
public function getDSN() {
|
public function getDSN()
|
||||||
|
{
|
||||||
krumo('DBArrayConnection getDSN ');
|
krumo('DBArrayConnection getDSN ');
|
||||||
die;
|
die;
|
||||||
return $this->childConnection->getDSN();
|
return $this->childConnection->getDSN();
|
||||||
@@ -572,14 +610,16 @@ class DBArrayConnection implements Connection {
|
|||||||
/**
|
/**
|
||||||
* @see Connection::getFlags()
|
* @see Connection::getFlags()
|
||||||
*/
|
*/
|
||||||
public function getFlags() {
|
public function getFlags()
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Connection::begin()
|
* @see Connection::begin()
|
||||||
*/
|
*/
|
||||||
public function begin() {
|
public function begin()
|
||||||
|
{
|
||||||
krumo('DBArrayConnection begin ');
|
krumo('DBArrayConnection begin ');
|
||||||
die;
|
die;
|
||||||
$this->log("Beginning transaction.");
|
$this->log("Beginning transaction.");
|
||||||
@@ -589,7 +629,8 @@ class DBArrayConnection implements Connection {
|
|||||||
/**
|
/**
|
||||||
* @see Connection::commit()
|
* @see Connection::commit()
|
||||||
*/
|
*/
|
||||||
public function commit() {
|
public function commit()
|
||||||
|
{
|
||||||
krumo('DBArrayConnection commit ');
|
krumo('DBArrayConnection commit ');
|
||||||
die;
|
die;
|
||||||
$this->log("Committing transaction.");
|
$this->log("Committing transaction.");
|
||||||
@@ -599,7 +640,8 @@ class DBArrayConnection implements Connection {
|
|||||||
/**
|
/**
|
||||||
* @see Connection::rollback()
|
* @see Connection::rollback()
|
||||||
*/
|
*/
|
||||||
public function rollback() {
|
public function rollback()
|
||||||
|
{
|
||||||
krumo('DBArrayConnection rollback ');
|
krumo('DBArrayConnection rollback ');
|
||||||
die;
|
die;
|
||||||
$this->log("Rolling back transaction.");
|
$this->log("Rolling back transaction.");
|
||||||
@@ -609,7 +651,8 @@ class DBArrayConnection implements Connection {
|
|||||||
/**
|
/**
|
||||||
* @see Connection::setAutoCommit()
|
* @see Connection::setAutoCommit()
|
||||||
*/
|
*/
|
||||||
public function setAutoCommit($bit) {
|
public function setAutoCommit($bit)
|
||||||
|
{
|
||||||
krumo('DBArrayConnection connect ');
|
krumo('DBArrayConnection connect ');
|
||||||
die;
|
die;
|
||||||
$this->log("Setting autocommit to: " . var_export($bit, true));
|
$this->log("Setting autocommit to: " . var_export($bit, true));
|
||||||
@@ -619,7 +662,8 @@ class DBArrayConnection implements Connection {
|
|||||||
/**
|
/**
|
||||||
* @see Connection::getAutoCommit()
|
* @see Connection::getAutoCommit()
|
||||||
*/
|
*/
|
||||||
public function getAutoCommit() {
|
public function getAutoCommit()
|
||||||
|
{
|
||||||
krumo('DBArrayConnection getAutoCommit ');
|
krumo('DBArrayConnection getAutoCommit ');
|
||||||
die;
|
die;
|
||||||
return $this->childConnection->getAutoCommit();
|
return $this->childConnection->getAutoCommit();
|
||||||
@@ -629,12 +673,12 @@ class DBArrayConnection implements Connection {
|
|||||||
* Private function that logs message using specified logger (if provided).
|
* Private function that logs message using specified logger (if provided).
|
||||||
* @param string $msg Message to log.
|
* @param string $msg Message to log.
|
||||||
*/
|
*/
|
||||||
private function log($msg) {
|
private function log($msg)
|
||||||
|
{
|
||||||
krumo('DBArrayConnection log ');
|
krumo('DBArrayConnection log ');
|
||||||
die;
|
die;
|
||||||
if ($this->logger) {
|
if ($this->logger) {
|
||||||
$this->logger->log($msg);
|
$this->logger->log($msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
111
thirdparty/creole/drivers/mssql/MSSQLConnection.php
vendored
111
thirdparty/creole/drivers/mssql/MSSQLConnection.php
vendored
@@ -46,7 +46,9 @@ include_once 'creole/drivers/mssql/MSSQLResultSet.php';
|
|||||||
* @version $Revision: 1.25 $
|
* @version $Revision: 1.25 $
|
||||||
* @package creole.drivers.mssql
|
* @package creole.drivers.mssql
|
||||||
*/
|
*/
|
||||||
class MSSQLConnection extends ConnectionCommon implements Connection {
|
class MSSQLConnection extends ConnectionCommon implements Connection
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
/** Current database (used in mssql_select_db()). */
|
/** Current database (used in mssql_select_db()). */
|
||||||
private $database;
|
private $database;
|
||||||
@@ -56,8 +58,8 @@ class MSSQLConnection extends ConnectionCommon implements Connection {
|
|||||||
*/
|
*/
|
||||||
function connect($dsninfo, $flags = 0)
|
function connect($dsninfo, $flags = 0)
|
||||||
{
|
{
|
||||||
if (!extension_loaded('mssql') && !extension_loaded('sybase') && !extension_loaded('sybase_ct')) {
|
if (!extension_loaded('mssql') && !extension_loaded('sybase') && !extension_loaded('sybase_ct') && !extension_loaded('sqlsrv')) {
|
||||||
throw new SQLException('mssql extension not loaded');
|
throw new SQLException('mssql/sqlsrv extension not loaded');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->dsn = $dsninfo;
|
$this->dsn = $dsninfo;
|
||||||
@@ -70,37 +72,32 @@ class MSSQLConnection extends ConnectionCommon implements Connection {
|
|||||||
$dbhost = $dsninfo['hostspec'] ? $dsninfo['hostspec'] : 'localhost';
|
$dbhost = $dsninfo['hostspec'] ? $dsninfo['hostspec'] : 'localhost';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MSSQL (http://php.net/manual/en/intro.mssql.php)
|
* Define our sql connect
|
||||||
* These functions allow you to access MS SQL Server database.
|
|
||||||
* This extension is not available anymore on Windows with PHP 5.3 or later.
|
|
||||||
* SQLSRV, an alternative extension for MS SQL connectivity is available from
|
|
||||||
* Microsoft: » http://msdn.microsoft.com/en-us/sqlserver/ff657782.aspx.
|
|
||||||
* http://blogs.msdn.com/b/brian_swan/archive/2010/03/08/mssql-vs-sqlsrv-what-s-the-difference-part-1.aspx
|
|
||||||
*
|
|
||||||
* Alternatively to use the mssql functions in Windows, use php_dblib.dll (FreeTDS) http://www.freetds.org/
|
|
||||||
* e.g. php.ini setting
|
|
||||||
* extension=php_dblib.dll
|
|
||||||
*
|
|
||||||
* php_dblib.dll (FreeTDS) use ':' as the delimiter in all installations.
|
|
||||||
*/
|
*/
|
||||||
/*
|
if (extension_loaded('sqlsrv')) {
|
||||||
if (PHP_OS == "WINNT" || PHP_OS == "WIN32") {
|
$portDelimiter = ", ";
|
||||||
$portDelimiter = ",";
|
if (!empty($dsninfo['port'])) {
|
||||||
} else {
|
$dbhost .= $portDelimiter.$dsninfo['port'];
|
||||||
$portDelimiter = ":";
|
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
$opt = [
|
||||||
|
'UID' => $user,
|
||||||
|
'PWD' => $pw,
|
||||||
|
'Database' => $dsninfo['database']
|
||||||
|
];
|
||||||
|
// SQLSrv is persistent always
|
||||||
|
$conn = sqlsrv_connect($dbhost, $opt);
|
||||||
|
} else {
|
||||||
$portDelimiter = ":";
|
$portDelimiter = ":";
|
||||||
|
|
||||||
if(!empty($dsninfo['port'])) {
|
if (!empty($dsninfo['port'])) {
|
||||||
$dbhost .= $portDelimiter.$dsninfo['port'];
|
$dbhost .= $portDelimiter.$dsninfo['port'];
|
||||||
} else {
|
} else {
|
||||||
if(!strpos($dbhost, "\\")){
|
if (!strpos($dbhost, "\\")) {
|
||||||
$dbhost .= $portDelimiter.'1433';
|
$dbhost .= $portDelimiter.'1433';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$connect_function = $persistent ? 'mssql_pconnect' : 'mssql_connect';
|
$connect_function = $persistent ? 'mssql_pconnect' : 'mssql_connect';
|
||||||
|
|
||||||
if ($dbhost && $user && $pw) {
|
if ($dbhost && $user && $pw) {
|
||||||
$conn = @$connect_function($dbhost, $user, $pw);
|
$conn = @$connect_function($dbhost, $user, $pw);
|
||||||
} elseif ($dbhost && $user) {
|
} elseif ($dbhost && $user) {
|
||||||
@@ -108,14 +105,20 @@ class MSSQLConnection extends ConnectionCommon implements Connection {
|
|||||||
} else {
|
} else {
|
||||||
$conn = @$connect_function($dbhost);
|
$conn = @$connect_function($dbhost);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!$conn) {
|
if (!$conn) {
|
||||||
throw new SQLException('connect failed', mssql_get_last_message());
|
throw new SQLException('connect failed', mssql_get_last_message());
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($dsninfo['database']) {
|
if ($dsninfo['database']) {
|
||||||
|
if (!extension_loaded('sqlsrv')) {
|
||||||
|
// Only do this if not using sqlsrv extension. If using sqlsrv, the database is specified
|
||||||
|
// in the options
|
||||||
if (!@mssql_select_db($dsninfo['database'], $conn)) {
|
if (!@mssql_select_db($dsninfo['database'], $conn)) {
|
||||||
throw new SQLException('No database selected');
|
throw new SQLException('No database selected');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$this->database = $dsninfo['database'];
|
$this->database = $dsninfo['database'];
|
||||||
}
|
}
|
||||||
@@ -172,7 +175,11 @@ class MSSQLConnection extends ConnectionCommon implements Connection {
|
|||||||
*/
|
*/
|
||||||
function close()
|
function close()
|
||||||
{
|
{
|
||||||
|
if (extension_loaded('sqlsrv')) {
|
||||||
|
$ret = @sqlsrv_close($this->dblink);
|
||||||
|
} else {
|
||||||
$ret = @mssql_close($this->dblink);
|
$ret = @mssql_close($this->dblink);
|
||||||
|
}
|
||||||
$this->dblink = null;
|
$this->dblink = null;
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
@@ -183,10 +190,15 @@ class MSSQLConnection extends ConnectionCommon implements Connection {
|
|||||||
function executeQuery($sql, $fetchmode = null)
|
function executeQuery($sql, $fetchmode = null)
|
||||||
{
|
{
|
||||||
$this->lastQuery = $sql;
|
$this->lastQuery = $sql;
|
||||||
|
if (extension_loaded('sqlsrv')) {
|
||||||
|
$result = sqlsrv_query($this->dblink, $sql);
|
||||||
|
} else {
|
||||||
if (!@mssql_select_db($this->database, $this->dblink)) {
|
if (!@mssql_select_db($this->database, $this->dblink)) {
|
||||||
throw new SQLException('No database selected');
|
throw new SQLException('No database selected');
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = @mssql_query($sql, $this->dblink);
|
$result = @mssql_query($sql, $this->dblink);
|
||||||
|
}
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
throw new SQLException('Could not execute query', mssql_get_last_message());
|
throw new SQLException('Could not execute query', mssql_get_last_message());
|
||||||
}
|
}
|
||||||
@@ -198,13 +210,17 @@ class MSSQLConnection extends ConnectionCommon implements Connection {
|
|||||||
*/
|
*/
|
||||||
function executeUpdate($sql)
|
function executeUpdate($sql)
|
||||||
{
|
{
|
||||||
|
if (extension_loaded('sqlsrv')) {
|
||||||
|
$result = sqlsrv_query($this->dblink, $sql);
|
||||||
|
} else {
|
||||||
$this->lastQuery = $sql;
|
$this->lastQuery = $sql;
|
||||||
if (!mssql_select_db($this->database, $this->dblink)) {
|
if (!mssql_select_db($this->database, $this->dblink)) {
|
||||||
throw new SQLException('No database selected');
|
throw new SQLException('No database selected');
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = @mssql_query($sql, $this->dblink);
|
$result = @mssql_query($sql, $this->dblink);
|
||||||
|
}
|
||||||
|
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
throw new SQLException('Could not execute update', mssql_get_last_message(), $sql);
|
throw new SQLException('Could not execute update', mssql_get_last_message(), $sql);
|
||||||
}
|
}
|
||||||
@@ -220,7 +236,11 @@ class MSSQLConnection extends ConnectionCommon implements Connection {
|
|||||||
*/
|
*/
|
||||||
protected function beginTrans()
|
protected function beginTrans()
|
||||||
{
|
{
|
||||||
|
if (extension_loaded('sqlsrv')) {
|
||||||
|
$result = sqlsrv_begin_transaction($this->dblink);
|
||||||
|
} else {
|
||||||
$result = @mssql_query('BEGIN TRAN', $this->dblink);
|
$result = @mssql_query('BEGIN TRAN', $this->dblink);
|
||||||
|
}
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
throw new SQLException('Could not begin transaction', mssql_get_last_message());
|
throw new SQLException('Could not begin transaction', mssql_get_last_message());
|
||||||
}
|
}
|
||||||
@@ -233,10 +253,14 @@ class MSSQLConnection extends ConnectionCommon implements Connection {
|
|||||||
*/
|
*/
|
||||||
protected function commitTrans()
|
protected function commitTrans()
|
||||||
{
|
{
|
||||||
|
if (extension_loaded('sqlsrv')) {
|
||||||
|
$result = sqlsrv_commit($this->dblink);
|
||||||
|
} else {
|
||||||
if (!@mssql_select_db($this->database, $this->dblink)) {
|
if (!@mssql_select_db($this->database, $this->dblink)) {
|
||||||
throw new SQLException('No database selected');
|
throw new SQLException('No database selected');
|
||||||
}
|
}
|
||||||
$result = @mssql_query('COMMIT TRAN', $this->dblink);
|
$result = @mssql_query('COMMIT TRAN', $this->dblink);
|
||||||
|
}
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
throw new SQLException('Could not commit transaction', mssql_get_last_message());
|
throw new SQLException('Could not commit transaction', mssql_get_last_message());
|
||||||
}
|
}
|
||||||
@@ -249,10 +273,14 @@ class MSSQLConnection extends ConnectionCommon implements Connection {
|
|||||||
*/
|
*/
|
||||||
protected function rollbackTrans()
|
protected function rollbackTrans()
|
||||||
{
|
{
|
||||||
|
if (extension_loaded('sqlsrv')) {
|
||||||
|
$result = sqlsrv_rollback($this->dblink);
|
||||||
|
} else {
|
||||||
if (!@mssql_select_db($this->database, $this->dblink)) {
|
if (!@mssql_select_db($this->database, $this->dblink)) {
|
||||||
throw new SQLException('no database selected');
|
throw new SQLException('no database selected');
|
||||||
}
|
}
|
||||||
$result = @mssql_query('ROLLBACK TRAN', $this->dblink);
|
$result = @mssql_query('ROLLBACK TRAN', $this->dblink);
|
||||||
|
}
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
throw new SQLException('Could not rollback transaction', mssql_get_last_message());
|
throw new SQLException('Could not rollback transaction', mssql_get_last_message());
|
||||||
}
|
}
|
||||||
@@ -267,6 +295,16 @@ class MSSQLConnection extends ConnectionCommon implements Connection {
|
|||||||
*/
|
*/
|
||||||
function getUpdateCount()
|
function getUpdateCount()
|
||||||
{
|
{
|
||||||
|
if (extension_loaded('sqlsrv')) {
|
||||||
|
$res = sqlsrv_query($this->dblink, 'select @@rowcount');
|
||||||
|
$ar = @sqlsrv_fetch_array($res);
|
||||||
|
if (!$ar) {
|
||||||
|
$result = 0;
|
||||||
|
} else {
|
||||||
|
@sqlsrv_free_stmt($res);
|
||||||
|
$result = $ar[0];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
$res = @mssql_query('select @@rowcount', $this->dblink);
|
$res = @mssql_query('select @@rowcount', $this->dblink);
|
||||||
if (!$res) {
|
if (!$res) {
|
||||||
throw new SQLException('Unable to get affected row count', mssql_get_last_message());
|
throw new SQLException('Unable to get affected row count', mssql_get_last_message());
|
||||||
@@ -278,6 +316,8 @@ class MSSQLConnection extends ConnectionCommon implements Connection {
|
|||||||
@mssql_free_result($res);
|
@mssql_free_result($res);
|
||||||
$result = $ar[0];
|
$result = $ar[0];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
@@ -292,11 +332,30 @@ class MSSQLConnection extends ConnectionCommon implements Connection {
|
|||||||
*/
|
*/
|
||||||
function prepareCall($sql)
|
function prepareCall($sql)
|
||||||
{
|
{
|
||||||
require_once 'creole/drivers/mssql/MSSQLCallableStatement.php';
|
if (extension_loaded('sqlsrv')) {
|
||||||
|
throw new SQLException("Callable statements not supported using the sqlsrv extension and this version of Creole.");
|
||||||
|
} else {
|
||||||
|
require_once 'creole/drivers/mssql/SQLCallableStatement.php';
|
||||||
$stmt = mssql_init($sql);
|
$stmt = mssql_init($sql);
|
||||||
if (!$stmt) {
|
if (!$stmt) {
|
||||||
throw new SQLException('Unable to prepare statement', mssql_get_last_message(), $sql);
|
throw new SQLException('Unable to prepare statement', mssql_get_last_message(), $sql);
|
||||||
}
|
}
|
||||||
return new MSSQLCallableStatement($this, $stmt);
|
return new MSSQLCallableStatement($this, $stmt);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stub to support mssql_get_last_message for sqlsrv extension
|
||||||
|
*/
|
||||||
|
if (!function_exists('mssql_get_last_message') && extension_loaded('sqlsrv')) {
|
||||||
|
function mssql_get_last_message()
|
||||||
|
{
|
||||||
|
$errors = sqlsrv_errors();
|
||||||
|
if (count($errors)) {
|
||||||
|
return $errors[0]['message'];
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -33,7 +33,9 @@ require_once 'creole/common/ResultSetCommon.php';
|
|||||||
* @version $Revision: 1.21 $
|
* @version $Revision: 1.21 $
|
||||||
* @package creole.drivers.mssql
|
* @package creole.drivers.mssql
|
||||||
*/
|
*/
|
||||||
class MSSQLResultSet extends ResultSetCommon implements ResultSet {
|
class MSSQLResultSet extends ResultSetCommon implements ResultSet
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Offset at which to start reading rows.
|
* Offset at which to start reading rows.
|
||||||
@@ -104,15 +106,27 @@ class MSSQLResultSet extends ResultSetCommon implements ResultSet {
|
|||||||
function next()
|
function next()
|
||||||
{
|
{
|
||||||
// support emulated LIMIT
|
// support emulated LIMIT
|
||||||
if ( $this->limit > 0 && ($this->cursorPos >= $this->limit) ) {
|
if ($this->limit > 0 && ($this->cursorPos >= $this->limit)) {
|
||||||
$this->afterLast();
|
$this->afterLast();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if ($this->result === true ) {
|
if ($this->result === true) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (extension_loaded('sqlsrv')) {
|
||||||
|
// The modes for fetching are different when using sqlsrv. So we'll translate the mode
|
||||||
|
// as needed
|
||||||
|
$mode = SQLSRV_FETCH_BOTH;
|
||||||
|
if ($this->fetchmode == ResultSet::FETCHMODE_ASSOC) {
|
||||||
|
$mode = SQLSRV_FETCH_ASSOC;
|
||||||
|
} elseif ($this->fetchmode == ResultSet::FETCHMODE_NUM) {
|
||||||
|
$mode = SQLSRV_FETCH_NUMERIC;
|
||||||
|
}
|
||||||
|
$this->fields = sqlsrv_fetch_array($this->result, $mode);
|
||||||
|
} else {
|
||||||
$this->fields = mssql_fetch_array($this->result, $this->fetchmode);
|
$this->fields = mssql_fetch_array($this->result, $this->fetchmode);
|
||||||
|
}
|
||||||
|
|
||||||
if (!$this->fields) {
|
if (!$this->fields) {
|
||||||
if ($errmsg = mssql_get_last_message()) {
|
if ($errmsg = mssql_get_last_message()) {
|
||||||
@@ -123,17 +137,6 @@ class MSSQLResultSet extends ResultSetCommon implements ResultSet {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//else {
|
|
||||||
// if (is_array($this->fields)) {
|
|
||||||
// foreach ($this->fields as $sKey => $sValue) {
|
|
||||||
// if (function_exists('mb_detect_encoding')) {
|
|
||||||
// if (strtoupper(mb_detect_encoding($sValue)) == 'UTF-8') {
|
|
||||||
// $this->fields[$sKey] = utf8_encode($sValue);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
if ($this->fetchmode === ResultSet::FETCHMODE_ASSOC && $this->lowerAssocCase) {
|
if ($this->fetchmode === ResultSet::FETCHMODE_ASSOC && $this->lowerAssocCase) {
|
||||||
$this->fields = array_change_key_case($this->fields, CASE_LOWER);
|
$this->fields = array_change_key_case($this->fields, CASE_LOWER);
|
||||||
@@ -149,7 +152,12 @@ class MSSQLResultSet extends ResultSetCommon implements ResultSet {
|
|||||||
*/
|
*/
|
||||||
function getRecordCount()
|
function getRecordCount()
|
||||||
{
|
{
|
||||||
|
if (extension_loaded('sqlsrv')) {
|
||||||
|
$rows = @sqlsrv_num_rows($this->result);
|
||||||
|
} else {
|
||||||
$rows = @mssql_num_rows($this->result);
|
$rows = @mssql_num_rows($this->result);
|
||||||
|
}
|
||||||
|
|
||||||
if ($rows === null) {
|
if ($rows === null) {
|
||||||
throw new SQLException('Error getting record count', mssql_get_last_message());
|
throw new SQLException('Error getting record count', mssql_get_last_message());
|
||||||
}
|
}
|
||||||
@@ -163,11 +171,14 @@ class MSSQLResultSet extends ResultSetCommon implements ResultSet {
|
|||||||
*/
|
*/
|
||||||
function close()
|
function close()
|
||||||
{
|
{
|
||||||
|
if (extension_loaded('sqlsrv')) {
|
||||||
|
$ret = @sqlsrv_free_stmt($this->result);
|
||||||
|
} else {
|
||||||
$ret = @mssql_free_result($this->result);
|
$ret = @mssql_free_result($this->result);
|
||||||
|
}
|
||||||
$this->result = false;
|
$this->result = false;
|
||||||
$this->fields = array();
|
$this->fields = array();
|
||||||
$this->limit = 0;
|
$this->limit = 0;
|
||||||
$this->offset = 0;
|
$this->offset = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,8 @@ require_once 'creole/metadata/DatabaseInfo.php';
|
|||||||
* @version $Revision: 1.11 $
|
* @version $Revision: 1.11 $
|
||||||
* @package creole.drivers.mssql.metadata
|
* @package creole.drivers.mssql.metadata
|
||||||
*/
|
*/
|
||||||
class MSSQLDatabaseInfo extends DatabaseInfo {
|
class MSSQLDatabaseInfo extends DatabaseInfo
|
||||||
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws SQLException
|
* @throws SQLException
|
||||||
@@ -41,11 +42,17 @@ class MSSQLDatabaseInfo extends DatabaseInfo {
|
|||||||
$dsn = $this->conn->getDSN();
|
$dsn = $this->conn->getDSN();
|
||||||
|
|
||||||
|
|
||||||
|
if (extension_loaded('sqlsrv')) {
|
||||||
|
$result = sqlsrv_query(
|
||||||
|
"SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE' AND TABLE_NAME <> 'dtproperties'",
|
||||||
|
$this->conn->getResource()
|
||||||
|
);
|
||||||
|
} else {
|
||||||
if (!@mssql_select_db($this->dbname, $this->conn->getResource())) {
|
if (!@mssql_select_db($this->dbname, $this->conn->getResource())) {
|
||||||
throw new SQLException('No database selected');
|
throw new SQLException('No database selected');
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = mssql_query("SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE' AND TABLE_NAME <> 'dtproperties'", $this->conn->getResource());
|
$result = mssql_query("SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE' AND TABLE_NAME <> 'dtproperties'", $this->conn->getResource());
|
||||||
|
}
|
||||||
|
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
throw new SQLException("Could not list tables", mssql_get_last_message());
|
throw new SQLException("Could not list tables", mssql_get_last_message());
|
||||||
@@ -65,5 +72,4 @@ class MSSQLDatabaseInfo extends DatabaseInfo {
|
|||||||
{
|
{
|
||||||
// there are no sequences -- afaik -- in MSSQL.
|
// there are no sequences -- afaik -- in MSSQL.
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
1
thirdparty/pear/DB.php
vendored
1
thirdparty/pear/DB.php
vendored
@@ -356,6 +356,7 @@ class DB
|
|||||||
function &connect($dsn, $options = array())
|
function &connect($dsn, $options = array())
|
||||||
{
|
{
|
||||||
$dsninfo = DB::parseDSN($dsn);
|
$dsninfo = DB::parseDSN($dsn);
|
||||||
|
$dsninfo['phptype'] = $dsninfo['phptype'] === 'mysql' ? 'mysqli' : $dsninfo['phptype'];
|
||||||
$type = $dsninfo['phptype'];
|
$type = $dsninfo['phptype'];
|
||||||
|
|
||||||
if (!is_array($options)) {
|
if (!is_array($options)) {
|
||||||
|
|||||||
4
thirdparty/pear/DB/common.php
vendored
4
thirdparty/pear/DB/common.php
vendored
@@ -955,7 +955,7 @@ class DB_common extends PEAR
|
|||||||
if (DB::isError($result) || $result === DB_OK) {
|
if (DB::isError($result) || $result === DB_OK) {
|
||||||
return $result;
|
return $result;
|
||||||
} else {
|
} else {
|
||||||
$tmp =& new DB_result($this, $result);
|
$tmp = new DB_result($this, $result);
|
||||||
return $tmp;
|
return $tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1147,7 +1147,7 @@ class DB_common extends PEAR
|
|||||||
if (DB::isError($result) || $result === DB_OK) {
|
if (DB::isError($result) || $result === DB_OK) {
|
||||||
return $result;
|
return $result;
|
||||||
} else {
|
} else {
|
||||||
$tmp =& new DB_result($this, $result);
|
$tmp = new DB_result($this, $result);
|
||||||
return $tmp;
|
return $tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
1056
thirdparty/pear/PEAR.php
vendored
1056
thirdparty/pear/PEAR.php
vendored
File diff suppressed because it is too large
Load Diff
55
thirdparty/propel/Propel.php
vendored
55
thirdparty/propel/Propel.php
vendored
@@ -40,7 +40,8 @@ include_once 'adapter/DBAdapter.php';
|
|||||||
* @version $Revision: 601 $
|
* @version $Revision: 601 $
|
||||||
* @package propel
|
* @package propel
|
||||||
*/
|
*/
|
||||||
class Propel {
|
class Propel
|
||||||
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A constant for <code>default</code>.
|
* A constant for <code>default</code>.
|
||||||
@@ -146,8 +147,8 @@ class Propel {
|
|||||||
* @throws PropelException Any exceptions caught during processing will be
|
* @throws PropelException Any exceptions caught during processing will be
|
||||||
* rethrown wrapped into a PropelException.
|
* rethrown wrapped into a PropelException.
|
||||||
*/
|
*/
|
||||||
public static function initialize() {
|
public static function initialize()
|
||||||
|
{
|
||||||
if (self::$configuration === null) {
|
if (self::$configuration === null) {
|
||||||
throw new PropelException("Propel cannot be initialized without "
|
throw new PropelException("Propel cannot be initialized without "
|
||||||
. "a valid configuration. Please check the log files "
|
. "a valid configuration. Please check the log files "
|
||||||
@@ -171,7 +172,6 @@ class Propel {
|
|||||||
self::$configuration = $originalConf;
|
self::$configuration = $originalConf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// reset the connection map (this should enable runtime changes of connection params)
|
// reset the connection map (this should enable runtime changes of connection params)
|
||||||
self::$connectionMap = array();
|
self::$connectionMap = array();
|
||||||
self::initAdapters(self::$configuration);
|
self::initAdapters(self::$configuration);
|
||||||
@@ -181,7 +181,7 @@ class Propel {
|
|||||||
// map builders may be registered w/ Propel before Propel has
|
// map builders may be registered w/ Propel before Propel has
|
||||||
// been initialized; in this case they are stored in a static
|
// been initialized; in this case they are stored in a static
|
||||||
// var of this class & now can be propertly initialized.
|
// var of this class & now can be propertly initialized.
|
||||||
foreach(self::$mapBuilders as $mbClass) {
|
foreach (self::$mapBuilders as $mbClass) {
|
||||||
BasePeer::getMapBuilder($mbClass);
|
BasePeer::getMapBuilder($mbClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -199,14 +199,14 @@ class Propel {
|
|||||||
* @throws PropelException Any exceptions caught during processing will be
|
* @throws PropelException Any exceptions caught during processing will be
|
||||||
* rethrown wrapped into a PropelException.
|
* rethrown wrapped into a PropelException.
|
||||||
*/
|
*/
|
||||||
private static function initAdapters($configuration) {
|
private static function initAdapters($configuration)
|
||||||
|
{
|
||||||
self::$adapterMap = array();
|
self::$adapterMap = array();
|
||||||
|
|
||||||
$c = isset($configuration['datasources']) ? $configuration['datasources'] : null;
|
$c = isset($configuration['datasources']) ? $configuration['datasources'] : null;
|
||||||
if (!empty($c)) {
|
if (!empty($c)) {
|
||||||
try {
|
try {
|
||||||
foreach($c as $handle => $properties) {
|
foreach ($c as $handle => $properties) {
|
||||||
if (is_array($properties) && isset($properties['adapter'])) {
|
if (is_array($properties) && isset($properties['adapter'])) {
|
||||||
$db = DBAdapter::factory($properties['adapter']);
|
$db = DBAdapter::factory($properties['adapter']);
|
||||||
// register the adapter for this name
|
// register the adapter for this name
|
||||||
@@ -230,7 +230,7 @@ class Propel {
|
|||||||
*/
|
*/
|
||||||
public static function krumo()
|
public static function krumo()
|
||||||
{
|
{
|
||||||
krumo ( self::$configuration);
|
krumo(self::$configuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -300,7 +300,8 @@ class Propel {
|
|||||||
* section in the passed-in runtime configuration.
|
* section in the passed-in runtime configuration.
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected static function configureLogging() {
|
protected static function configureLogging()
|
||||||
|
{
|
||||||
if (self::$logger === null) {
|
if (self::$logger === null) {
|
||||||
if (isset(self::$configuration['log']) && is_array(self::$configuration['log']) && count(self::$configuration['log'])) {
|
if (isset(self::$configuration['log']) && is_array(self::$configuration['log']) && count(self::$configuration['log'])) {
|
||||||
include_once 'Log.php'; // PEAR Log class
|
include_once 'Log.php'; // PEAR Log class
|
||||||
@@ -368,11 +369,9 @@ class Propel {
|
|||||||
*/
|
*/
|
||||||
public static function log($message, $level = self::LOG_DEBUG)
|
public static function log($message, $level = self::LOG_DEBUG)
|
||||||
{
|
{
|
||||||
if(self::hasLogger())
|
if (self::hasLogger()) {
|
||||||
{
|
|
||||||
$logger = self::logger();
|
$logger = self::logger();
|
||||||
switch($level)
|
switch ($level) {
|
||||||
{
|
|
||||||
case self::LOG_EMERG:
|
case self::LOG_EMERG:
|
||||||
return $logger->log($message, $level);
|
return $logger->log($message, $level);
|
||||||
case self::LOG_ALERT:
|
case self::LOG_ALERT:
|
||||||
@@ -404,8 +403,8 @@ class Propel {
|
|||||||
* @return DatabaseMap The named <code>DatabaseMap</code>.
|
* @return DatabaseMap The named <code>DatabaseMap</code>.
|
||||||
* @throws PropelException - if database map is null or propel was not initialized properly.
|
* @throws PropelException - if database map is null or propel was not initialized properly.
|
||||||
*/
|
*/
|
||||||
public static function getDatabaseMap($name = null) {
|
public static function getDatabaseMap($name = null)
|
||||||
|
{
|
||||||
if ($name === null) {
|
if ($name === null) {
|
||||||
$name = self::getDefaultDB();
|
$name = self::getDefaultDB();
|
||||||
if ($name === null) {
|
if ($name === null) {
|
||||||
@@ -474,22 +473,21 @@ class Propel {
|
|||||||
* @return Connection A database connection
|
* @return Connection A database connection
|
||||||
* @throws PropelException - if no conneciton params, or SQLException caught when trying to connect.
|
* @throws PropelException - if no conneciton params, or SQLException caught when trying to connect.
|
||||||
*/
|
*/
|
||||||
public static function getConnection($name = null) {
|
public static function getConnection($name = null)
|
||||||
|
{
|
||||||
if ($name === null) {
|
if ($name === null) {
|
||||||
$name = self::getDefaultDB();
|
$name = self::getDefaultDB();
|
||||||
}
|
}
|
||||||
$con = isset(self::$connectionMap[$name]) ? self::$connectionMap[$name] : null;
|
$con = isset(self::$connectionMap[$name]) ? self::$connectionMap[$name] : null;
|
||||||
if ($con === null || $name === 'dbarray') {
|
if ($con === null || $name === 'dbarray') {
|
||||||
|
|
||||||
$dsn = isset(self::$configuration['datasources'][$name]['connection']) ? self::$configuration['datasources'][$name]['connection'] : null;
|
$dsn = isset(self::$configuration['datasources'][$name]['connection']) ? self::$configuration['datasources'][$name]['connection'] : null;
|
||||||
if ($dsn === null) {
|
if ($dsn === null) {
|
||||||
if(isset($_SESSION['PROCESS'])) {
|
if (isset($_SESSION['PROCESS'])) {
|
||||||
/** Added By Erik Amaru <erik@colosa.com *******************************
|
/***********************************************************************
|
||||||
* @date: 27-05-08 11:48 *
|
* @date: 27-05-08 11:48 *
|
||||||
* @Description: this was added for the additional database connections *
|
* @Description: this was added for the additional database connections *
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
$oDbConnections = new DbConnections($_SESSION['PROCESS']);
|
DbConnections::loadAdditionalConnections();
|
||||||
$oDbConnections->loadAdditionalConnections();
|
|
||||||
$dsn = isset(self::$configuration['datasources'][$name]['connection']) ? self::$configuration['datasources'][$name]['connection'] : null;
|
$dsn = isset(self::$configuration['datasources'][$name]['connection']) ? self::$configuration['datasources'][$name]['connection'] : null;
|
||||||
} else {
|
} else {
|
||||||
throw new PropelException("No connection params set for " . $name);
|
throw new PropelException("No connection params set for " . $name);
|
||||||
@@ -501,6 +499,8 @@ class Propel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// set Connection Creole default mysqli
|
||||||
|
$dsn = str_replace('mysql:', 'mysqli:', $dsn);
|
||||||
$con = Creole::getConnection($dsn);
|
$con = Creole::getConnection($dsn);
|
||||||
} catch (SQLException $e) {
|
} catch (SQLException $e) {
|
||||||
throw new PropelException($e);
|
throw new PropelException($e);
|
||||||
@@ -558,7 +558,8 @@ class Propel {
|
|||||||
* @param string $class dot-path to clas (e.g. path.to.my.ClassName).
|
* @param string $class dot-path to clas (e.g. path.to.my.ClassName).
|
||||||
* @return string unqualified classname
|
* @return string unqualified classname
|
||||||
*/
|
*/
|
||||||
public static function import($path) {
|
public static function import($path)
|
||||||
|
{
|
||||||
|
|
||||||
// extract classname
|
// extract classname
|
||||||
if (($pos = strrpos($path, '.')) === false) {
|
if (($pos = strrpos($path, '.')) === false) {
|
||||||
@@ -599,7 +600,7 @@ class Propel {
|
|||||||
|
|
||||||
foreach (self::$connectionMap as $cnn) {
|
foreach (self::$connectionMap as $cnn) {
|
||||||
if (get_class($cnn) != "DBArrayConnection") {
|
if (get_class($cnn) != "DBArrayConnection") {
|
||||||
if(isset($cnn->lastQuery)){
|
if (isset($cnn->lastQuery)) {
|
||||||
if (gettype($cnn->getResource()) == "resource" && $cnn->isConnected() && $cnn->lastQuery != $lastQuery) {
|
if (gettype($cnn->getResource()) == "resource" && $cnn->isConnected() && $cnn->lastQuery != $lastQuery) {
|
||||||
$cnn->close();
|
$cnn->close();
|
||||||
}
|
}
|
||||||
@@ -624,7 +625,7 @@ class Propel {
|
|||||||
}
|
}
|
||||||
/*----------------------------------********---------------------------------*/
|
/*----------------------------------********---------------------------------*/
|
||||||
|
|
||||||
if (! empty(self::$configuration['datasources'][$name]['connection'])) {
|
if (!empty(self::$configuration['datasources'][$name]['connection'])) {
|
||||||
return self::getConnection($name);
|
return self::getConnection($name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -634,10 +635,10 @@ class Propel {
|
|||||||
|
|
||||||
$defaultDbName = substr($name, 0, strrpos($name, '_'));
|
$defaultDbName = substr($name, 0, strrpos($name, '_'));
|
||||||
|
|
||||||
if (! empty(self::$configuration['datasources'][$defaultDbName]['connection'])) {
|
if (!empty(self::$configuration['datasources'][$defaultDbName]['connection'])) {
|
||||||
return self::getConnection($defaultDbName);
|
return self::getConnection($defaultDbName);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new PropelException('Error, database connection named "'.$name.'" is not defined for Propel.');
|
throw new PropelException('Error, database connection named "' . $name . '" is not defined for Propel.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
7
thirdparty/smarty/BUGS
vendored
7
thirdparty/smarty/BUGS
vendored
@@ -1,7 +0,0 @@
|
|||||||
Smarty is supported only in PHP 4.0.6 or later.
|
|
||||||
|
|
||||||
Smarty versions previous to 2.0 require the PEAR libraries. Be sure to include
|
|
||||||
the path to the PEAR libraries in your php include_path. Config_file.class.php
|
|
||||||
uses the PEAR library for its error handling routines. PEAR comes with the PHP
|
|
||||||
distribution. Unix users check /usr/local/lib/php, windows users check
|
|
||||||
C:/php/pear.
|
|
||||||
458
thirdparty/smarty/COPYING.lib
vendored
458
thirdparty/smarty/COPYING.lib
vendored
@@ -1,458 +0,0 @@
|
|||||||
GNU LESSER GENERAL PUBLIC LICENSE
|
|
||||||
Version 2.1, February 1999
|
|
||||||
|
|
||||||
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
|
|
||||||
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
Everyone is permitted to copy and distribute verbatim copies
|
|
||||||
of this license document, but changing it is not allowed.
|
|
||||||
|
|
||||||
[This is the first released version of the Lesser GPL. It also counts
|
|
||||||
as the successor of the GNU Library Public License, version 2, hence
|
|
||||||
the version number 2.1.]
|
|
||||||
|
|
||||||
Preamble
|
|
||||||
|
|
||||||
The licenses for most software are designed to take away your
|
|
||||||
freedom to share and change it. By contrast, the GNU General Public
|
|
||||||
Licenses are intended to guarantee your freedom to share and change
|
|
||||||
free software--to make sure the software is free for all its users.
|
|
||||||
|
|
||||||
This license, the Lesser General Public License, applies to some
|
|
||||||
specially designated software packages--typically libraries--of the
|
|
||||||
Free Software Foundation and other authors who decide to use it. You
|
|
||||||
can use it too, but we suggest you first think carefully about whether
|
|
||||||
this license or the ordinary General Public License is the better
|
|
||||||
strategy to use in any particular case, based on the explanations below.
|
|
||||||
|
|
||||||
When we speak of free software, we are referring to freedom of use,
|
|
||||||
not price. Our General Public Licenses are designed to make sure that
|
|
||||||
you have the freedom to distribute copies of free software (and charge
|
|
||||||
for this service if you wish); that you receive source code or can get
|
|
||||||
it if you want it; that you can change the software and use pieces of
|
|
||||||
it in new free programs; and that you are informed that you can do
|
|
||||||
these things.
|
|
||||||
|
|
||||||
To protect your rights, we need to make restrictions that forbid
|
|
||||||
distributors to deny you these rights or to ask you to surrender these
|
|
||||||
rights. These restrictions translate to certain responsibilities for
|
|
||||||
you if you distribute copies of the library or if you modify it.
|
|
||||||
|
|
||||||
For example, if you distribute copies of the library, whether gratis
|
|
||||||
or for a fee, you must give the recipients all the rights that we gave
|
|
||||||
you. You must make sure that they, too, receive or can get the source
|
|
||||||
code. If you link other code with the library, you must provide
|
|
||||||
complete object files to the recipients, so that they can relink them
|
|
||||||
with the library after making changes to the library and recompiling
|
|
||||||
it. And you must show them these terms so they know their rights.
|
|
||||||
|
|
||||||
We protect your rights with a two-step method: (1) we copyright the
|
|
||||||
library, and (2) we offer you this license, which gives you legal
|
|
||||||
permission to copy, distribute and/or modify the library.
|
|
||||||
|
|
||||||
To protect each distributor, we want to make it very clear that
|
|
||||||
there is no warranty for the free library. Also, if the library is
|
|
||||||
modified by someone else and passed on, the recipients should know
|
|
||||||
that what they have is not the original version, so that the original
|
|
||||||
author's reputation will not be affected by problems that might be
|
|
||||||
introduced by others.
|
|
||||||
|
|
||||||
Finally, software patents pose a constant threat to the existence of
|
|
||||||
any free program. We wish to make sure that a company cannot
|
|
||||||
effectively restrict the users of a free program by obtaining a
|
|
||||||
restrictive license from a patent holder. Therefore, we insist that
|
|
||||||
any patent license obtained for a version of the library must be
|
|
||||||
consistent with the full freedom of use specified in this license.
|
|
||||||
|
|
||||||
Most GNU software, including some libraries, is covered by the
|
|
||||||
ordinary GNU General Public License. This license, the GNU Lesser
|
|
||||||
General Public License, applies to certain designated libraries, and
|
|
||||||
is quite different from the ordinary General Public License. We use
|
|
||||||
this license for certain libraries in order to permit linking those
|
|
||||||
libraries into non-free programs.
|
|
||||||
|
|
||||||
When a program is linked with a library, whether statically or using
|
|
||||||
a shared library, the combination of the two is legally speaking a
|
|
||||||
combined work, a derivative of the original library. The ordinary
|
|
||||||
General Public License therefore permits such linking only if the
|
|
||||||
entire combination fits its criteria of freedom. The Lesser General
|
|
||||||
Public License permits more lax criteria for linking other code with
|
|
||||||
the library.
|
|
||||||
|
|
||||||
We call this license the "Lesser" General Public License because it
|
|
||||||
does Less to protect the user's freedom than the ordinary General
|
|
||||||
Public License. It also provides other free software developers Less
|
|
||||||
of an advantage over competing non-free programs. These disadvantages
|
|
||||||
are the reason we use the ordinary General Public License for many
|
|
||||||
libraries. However, the Lesser license provides advantages in certain
|
|
||||||
special circumstances.
|
|
||||||
|
|
||||||
For example, on rare occasions, there may be a special need to
|
|
||||||
encourage the widest possible use of a certain library, so that it becomes
|
|
||||||
a de-facto standard. To achieve this, non-free programs must be
|
|
||||||
allowed to use the library. A more frequent case is that a free
|
|
||||||
library does the same job as widely used non-free libraries. In this
|
|
||||||
case, there is little to gain by limiting the free library to free
|
|
||||||
software only, so we use the Lesser General Public License.
|
|
||||||
|
|
||||||
In other cases, permission to use a particular library in non-free
|
|
||||||
programs enables a greater number of people to use a large body of
|
|
||||||
free software. For example, permission to use the GNU C Library in
|
|
||||||
non-free programs enables many more people to use the whole GNU
|
|
||||||
operating system, as well as its variant, the GNU/Linux operating
|
|
||||||
system.
|
|
||||||
|
|
||||||
Although the Lesser General Public License is Less protective of the
|
|
||||||
users' freedom, it does ensure that the user of a program that is
|
|
||||||
linked with the Library has the freedom and the wherewithal to run
|
|
||||||
that program using a modified version of the Library.
|
|
||||||
|
|
||||||
The precise terms and conditions for copying, distribution and
|
|
||||||
modification follow. Pay close attention to the difference between a
|
|
||||||
"work based on the library" and a "work that uses the library". The
|
|
||||||
former contains code derived from the library, whereas the latter must
|
|
||||||
be combined with the library in order to run.
|
|
||||||
|
|
||||||
GNU LESSER GENERAL PUBLIC LICENSE
|
|
||||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
|
||||||
|
|
||||||
0. This License Agreement applies to any software library or other
|
|
||||||
program which contains a notice placed by the copyright holder or
|
|
||||||
other authorized party saying it may be distributed under the terms of
|
|
||||||
this Lesser General Public License (also called "this License").
|
|
||||||
Each licensee is addressed as "you".
|
|
||||||
|
|
||||||
A "library" means a collection of software functions and/or data
|
|
||||||
prepared so as to be conveniently linked with application programs
|
|
||||||
(which use some of those functions and data) to form executables.
|
|
||||||
|
|
||||||
The "Library", below, refers to any such software library or work
|
|
||||||
which has been distributed under these terms. A "work based on the
|
|
||||||
Library" means either the Library or any derivative work under
|
|
||||||
copyright law: that is to say, a work containing the Library or a
|
|
||||||
portion of it, either verbatim or with modifications and/or translated
|
|
||||||
straightforwardly into another language. (Hereinafter, translation is
|
|
||||||
included without limitation in the term "modification".)
|
|
||||||
|
|
||||||
"Source code" for a work means the preferred form of the work for
|
|
||||||
making modifications to it. For a library, complete source code means
|
|
||||||
all the source code for all modules it contains, plus any associated
|
|
||||||
interface definition files, plus the scripts used to control compilation
|
|
||||||
and installation of the library.
|
|
||||||
|
|
||||||
Activities other than copying, distribution and modification are not
|
|
||||||
covered by this License; they are outside its scope. The act of
|
|
||||||
running a program using the Library is not restricted, and output from
|
|
||||||
such a program is covered only if its contents constitute a work based
|
|
||||||
on the Library (independent of the use of the Library in a tool for
|
|
||||||
writing it). Whether that is true depends on what the Library does
|
|
||||||
and what the program that uses the Library does.
|
|
||||||
|
|
||||||
1. You may copy and distribute verbatim copies of the Library's
|
|
||||||
complete source code as you receive it, in any medium, provided that
|
|
||||||
you conspicuously and appropriately publish on each copy an
|
|
||||||
appropriate copyright notice and disclaimer of warranty; keep intact
|
|
||||||
all the notices that refer to this License and to the absence of any
|
|
||||||
warranty; and distribute a copy of this License along with the
|
|
||||||
Library.
|
|
||||||
|
|
||||||
You may charge a fee for the physical act of transferring a copy,
|
|
||||||
and you may at your option offer warranty protection in exchange for a
|
|
||||||
fee.
|
|
||||||
|
|
||||||
2. You may modify your copy or copies of the Library or any portion
|
|
||||||
of it, thus forming a work based on the Library, and copy and
|
|
||||||
distribute such modifications or work under the terms of Section 1
|
|
||||||
above, provided that you also meet all of these conditions:
|
|
||||||
|
|
||||||
a) The modified work must itself be a software library.
|
|
||||||
|
|
||||||
b) You must cause the files modified to carry prominent notices
|
|
||||||
stating that you changed the files and the date of any change.
|
|
||||||
|
|
||||||
c) You must cause the whole of the work to be licensed at no
|
|
||||||
charge to all third parties under the terms of this License.
|
|
||||||
|
|
||||||
d) If a facility in the modified Library refers to a function or a
|
|
||||||
table of data to be supplied by an application program that uses
|
|
||||||
the facility, other than as an argument passed when the facility
|
|
||||||
is invoked, then you must make a good faith effort to ensure that,
|
|
||||||
in the event an application does not supply such function or
|
|
||||||
table, the facility still operates, and performs whatever part of
|
|
||||||
its purpose remains meaningful.
|
|
||||||
|
|
||||||
(For example, a function in a library to compute square roots has
|
|
||||||
a purpose that is entirely well-defined independent of the
|
|
||||||
application. Therefore, Subsection 2d requires that any
|
|
||||||
application-supplied function or table used by this function must
|
|
||||||
be optional: if the application does not supply it, the square
|
|
||||||
root function must still compute square roots.)
|
|
||||||
|
|
||||||
These requirements apply to the modified work as a whole. If
|
|
||||||
identifiable sections of that work are not derived from the Library,
|
|
||||||
and can be reasonably considered independent and separate works in
|
|
||||||
themselves, then this License, and its terms, do not apply to those
|
|
||||||
sections when you distribute them as separate works. But when you
|
|
||||||
distribute the same sections as part of a whole which is a work based
|
|
||||||
on the Library, the distribution of the whole must be on the terms of
|
|
||||||
this License, whose permissions for other licensees extend to the
|
|
||||||
entire whole, and thus to each and every part regardless of who wrote
|
|
||||||
it.
|
|
||||||
|
|
||||||
Thus, it is not the intent of this section to claim rights or contest
|
|
||||||
your rights to work written entirely by you; rather, the intent is to
|
|
||||||
exercise the right to control the distribution of derivative or
|
|
||||||
collective works based on the Library.
|
|
||||||
|
|
||||||
In addition, mere aggregation of another work not based on the Library
|
|
||||||
with the Library (or with a work based on the Library) on a volume of
|
|
||||||
a storage or distribution medium does not bring the other work under
|
|
||||||
the scope of this License.
|
|
||||||
|
|
||||||
3. You may opt to apply the terms of the ordinary GNU General Public
|
|
||||||
License instead of this License to a given copy of the Library. To do
|
|
||||||
this, you must alter all the notices that refer to this License, so
|
|
||||||
that they refer to the ordinary GNU General Public License, version 2,
|
|
||||||
instead of to this License. (If a newer version than version 2 of the
|
|
||||||
ordinary GNU General Public License has appeared, then you can specify
|
|
||||||
that version instead if you wish.) Do not make any other change in
|
|
||||||
these notices.
|
|
||||||
|
|
||||||
Once this change is made in a given copy, it is irreversible for
|
|
||||||
that copy, so the ordinary GNU General Public License applies to all
|
|
||||||
subsequent copies and derivative works made from that copy.
|
|
||||||
|
|
||||||
This option is useful when you wish to copy part of the code of
|
|
||||||
the Library into a program that is not a library.
|
|
||||||
|
|
||||||
4. You may copy and distribute the Library (or a portion or
|
|
||||||
derivative of it, under Section 2) in object code or executable form
|
|
||||||
under the terms of Sections 1 and 2 above provided that you accompany
|
|
||||||
it with the complete corresponding machine-readable source code, which
|
|
||||||
must be distributed under the terms of Sections 1 and 2 above on a
|
|
||||||
medium customarily used for software interchange.
|
|
||||||
|
|
||||||
If distribution of object code is made by offering access to copy
|
|
||||||
from a designated place, then offering equivalent access to copy the
|
|
||||||
source code from the same place satisfies the requirement to
|
|
||||||
distribute the source code, even though third parties are not
|
|
||||||
compelled to copy the source along with the object code.
|
|
||||||
|
|
||||||
5. A program that contains no derivative of any portion of the
|
|
||||||
Library, but is designed to work with the Library by being compiled or
|
|
||||||
linked with it, is called a "work that uses the Library". Such a
|
|
||||||
work, in isolation, is not a derivative work of the Library, and
|
|
||||||
therefore falls outside the scope of this License.
|
|
||||||
|
|
||||||
However, linking a "work that uses the Library" with the Library
|
|
||||||
creates an executable that is a derivative of the Library (because it
|
|
||||||
contains portions of the Library), rather than a "work that uses the
|
|
||||||
library". The executable is therefore covered by this License.
|
|
||||||
Section 6 states terms for distribution of such executables.
|
|
||||||
|
|
||||||
When a "work that uses the Library" uses material from a header file
|
|
||||||
that is part of the Library, the object code for the work may be a
|
|
||||||
derivative work of the Library even though the source code is not.
|
|
||||||
Whether this is true is especially significant if the work can be
|
|
||||||
linked without the Library, or if the work is itself a library. The
|
|
||||||
threshold for this to be true is not precisely defined by law.
|
|
||||||
|
|
||||||
If such an object file uses only numerical parameters, data
|
|
||||||
structure layouts and accessors, and small macros and small inline
|
|
||||||
functions (ten lines or less in length), then the use of the object
|
|
||||||
file is unrestricted, regardless of whether it is legally a derivative
|
|
||||||
work. (Executables containing this object code plus portions of the
|
|
||||||
Library will still fall under Section 6.)
|
|
||||||
|
|
||||||
Otherwise, if the work is a derivative of the Library, you may
|
|
||||||
distribute the object code for the work under the terms of Section 6.
|
|
||||||
Any executables containing that work also fall under Section 6,
|
|
||||||
whether or not they are linked directly with the Library itself.
|
|
||||||
|
|
||||||
6. As an exception to the Sections above, you may also combine or
|
|
||||||
link a "work that uses the Library" with the Library to produce a
|
|
||||||
work containing portions of the Library, and distribute that work
|
|
||||||
under terms of your choice, provided that the terms permit
|
|
||||||
modification of the work for the customer's own use and reverse
|
|
||||||
engineering for debugging such modifications.
|
|
||||||
|
|
||||||
You must give prominent notice with each copy of the work that the
|
|
||||||
Library is used in it and that the Library and its use are covered by
|
|
||||||
this License. You must supply a copy of this License. If the work
|
|
||||||
during execution displays copyright notices, you must include the
|
|
||||||
copyright notice for the Library among them, as well as a reference
|
|
||||||
directing the user to the copy of this License. Also, you must do one
|
|
||||||
of these things:
|
|
||||||
|
|
||||||
a) Accompany the work with the complete corresponding
|
|
||||||
machine-readable source code for the Library including whatever
|
|
||||||
changes were used in the work (which must be distributed under
|
|
||||||
Sections 1 and 2 above); and, if the work is an executable linked
|
|
||||||
with the Library, with the complete machine-readable "work that
|
|
||||||
uses the Library", as object code and/or source code, so that the
|
|
||||||
user can modify the Library and then relink to produce a modified
|
|
||||||
executable containing the modified Library. (It is understood
|
|
||||||
that the user who changes the contents of definitions files in the
|
|
||||||
Library will not necessarily be able to recompile the application
|
|
||||||
to use the modified definitions.)
|
|
||||||
|
|
||||||
b) Use a suitable shared library mechanism for linking with the
|
|
||||||
Library. A suitable mechanism is one that (1) uses at run time a
|
|
||||||
copy of the library already present on the user's computer system,
|
|
||||||
rather than copying library functions into the executable, and (2)
|
|
||||||
will operate properly with a modified version of the library, if
|
|
||||||
the user installs one, as long as the modified version is
|
|
||||||
interface-compatible with the version that the work was made with.
|
|
||||||
|
|
||||||
c) Accompany the work with a written offer, valid for at
|
|
||||||
least three years, to give the same user the materials
|
|
||||||
specified in Subsection 6a, above, for a charge no more
|
|
||||||
than the cost of performing this distribution.
|
|
||||||
|
|
||||||
d) If distribution of the work is made by offering access to copy
|
|
||||||
from a designated place, offer equivalent access to copy the above
|
|
||||||
specified materials from the same place.
|
|
||||||
|
|
||||||
e) Verify that the user has already received a copy of these
|
|
||||||
materials or that you have already sent this user a copy.
|
|
||||||
|
|
||||||
For an executable, the required form of the "work that uses the
|
|
||||||
Library" must include any data and utility programs needed for
|
|
||||||
reproducing the executable from it. However, as a special exception,
|
|
||||||
the materials to be distributed need not include anything that is
|
|
||||||
normally distributed (in either source or binary form) with the major
|
|
||||||
components (compiler, kernel, and so on) of the operating system on
|
|
||||||
which the executable runs, unless that component itself accompanies
|
|
||||||
the executable.
|
|
||||||
|
|
||||||
It may happen that this requirement contradicts the license
|
|
||||||
restrictions of other proprietary libraries that do not normally
|
|
||||||
accompany the operating system. Such a contradiction means you cannot
|
|
||||||
use both them and the Library together in an executable that you
|
|
||||||
distribute.
|
|
||||||
|
|
||||||
7. You may place library facilities that are a work based on the
|
|
||||||
Library side-by-side in a single library together with other library
|
|
||||||
facilities not covered by this License, and distribute such a combined
|
|
||||||
library, provided that the separate distribution of the work based on
|
|
||||||
the Library and of the other library facilities is otherwise
|
|
||||||
permitted, and provided that you do these two things:
|
|
||||||
|
|
||||||
a) Accompany the combined library with a copy of the same work
|
|
||||||
based on the Library, uncombined with any other library
|
|
||||||
facilities. This must be distributed under the terms of the
|
|
||||||
Sections above.
|
|
||||||
|
|
||||||
b) Give prominent notice with the combined library of the fact
|
|
||||||
that part of it is a work based on the Library, and explaining
|
|
||||||
where to find the accompanying uncombined form of the same work.
|
|
||||||
|
|
||||||
8. You may not copy, modify, sublicense, link with, or distribute
|
|
||||||
the Library except as expressly provided under this License. Any
|
|
||||||
attempt otherwise to copy, modify, sublicense, link with, or
|
|
||||||
distribute the Library is void, and will automatically terminate your
|
|
||||||
rights under this License. However, parties who have received copies,
|
|
||||||
or rights, from you under this License will not have their licenses
|
|
||||||
terminated so long as such parties remain in full compliance.
|
|
||||||
|
|
||||||
9. You are not required to accept this License, since you have not
|
|
||||||
signed it. However, nothing else grants you permission to modify or
|
|
||||||
distribute the Library or its derivative works. These actions are
|
|
||||||
prohibited by law if you do not accept this License. Therefore, by
|
|
||||||
modifying or distributing the Library (or any work based on the
|
|
||||||
Library), you indicate your acceptance of this License to do so, and
|
|
||||||
all its terms and conditions for copying, distributing or modifying
|
|
||||||
the Library or works based on it.
|
|
||||||
|
|
||||||
10. Each time you redistribute the Library (or any work based on the
|
|
||||||
Library), the recipient automatically receives a license from the
|
|
||||||
original licensor to copy, distribute, link with or modify the Library
|
|
||||||
subject to these terms and conditions. You may not impose any further
|
|
||||||
restrictions on the recipients' exercise of the rights granted herein.
|
|
||||||
You are not responsible for enforcing compliance by third parties with
|
|
||||||
this License.
|
|
||||||
|
|
||||||
11. If, as a consequence of a court judgment or allegation of patent
|
|
||||||
infringement or for any other reason (not limited to patent issues),
|
|
||||||
conditions are imposed on you (whether by court order, agreement or
|
|
||||||
otherwise) that contradict the conditions of this License, they do not
|
|
||||||
excuse you from the conditions of this License. If you cannot
|
|
||||||
distribute so as to satisfy simultaneously your obligations under this
|
|
||||||
License and any other pertinent obligations, then as a consequence you
|
|
||||||
may not distribute the Library at all. For example, if a patent
|
|
||||||
license would not permit royalty-free redistribution of the Library by
|
|
||||||
all those who receive copies directly or indirectly through you, then
|
|
||||||
the only way you could satisfy both it and this License would be to
|
|
||||||
refrain entirely from distribution of the Library.
|
|
||||||
|
|
||||||
If any portion of this section is held invalid or unenforceable under any
|
|
||||||
particular circumstance, the balance of the section is intended to apply,
|
|
||||||
and the section as a whole is intended to apply in other circumstances.
|
|
||||||
|
|
||||||
It is not the purpose of this section to induce you to infringe any
|
|
||||||
patents or other property right claims or to contest validity of any
|
|
||||||
such claims; this section has the sole purpose of protecting the
|
|
||||||
integrity of the free software distribution system which is
|
|
||||||
implemented by public license practices. Many people have made
|
|
||||||
generous contributions to the wide range of software distributed
|
|
||||||
through that system in reliance on consistent application of that
|
|
||||||
system; it is up to the author/donor to decide if he or she is willing
|
|
||||||
to distribute software through any other system and a licensee cannot
|
|
||||||
impose that choice.
|
|
||||||
|
|
||||||
This section is intended to make thoroughly clear what is believed to
|
|
||||||
be a consequence of the rest of this License.
|
|
||||||
|
|
||||||
12. If the distribution and/or use of the Library is restricted in
|
|
||||||
certain countries either by patents or by copyrighted interfaces, the
|
|
||||||
original copyright holder who places the Library under this License may add
|
|
||||||
an explicit geographical distribution limitation excluding those countries,
|
|
||||||
so that distribution is permitted only in or among countries not thus
|
|
||||||
excluded. In such case, this License incorporates the limitation as if
|
|
||||||
written in the body of this License.
|
|
||||||
|
|
||||||
13. The Free Software Foundation may publish revised and/or new
|
|
||||||
versions of the Lesser General Public License from time to time.
|
|
||||||
Such new versions will be similar in spirit to the present version,
|
|
||||||
but may differ in detail to address new problems or concerns.
|
|
||||||
|
|
||||||
Each version is given a distinguishing version number. If the Library
|
|
||||||
specifies a version number of this License which applies to it and
|
|
||||||
"any later version", you have the option of following the terms and
|
|
||||||
conditions either of that version or of any later version published by
|
|
||||||
the Free Software Foundation. If the Library does not specify a
|
|
||||||
license version number, you may choose any version ever published by
|
|
||||||
the Free Software Foundation.
|
|
||||||
|
|
||||||
14. If you wish to incorporate parts of the Library into other free
|
|
||||||
programs whose distribution conditions are incompatible with these,
|
|
||||||
write to the author to ask for permission. For software which is
|
|
||||||
copyrighted by the Free Software Foundation, write to the Free
|
|
||||||
Software Foundation; we sometimes make exceptions for this. Our
|
|
||||||
decision will be guided by the two goals of preserving the free status
|
|
||||||
of all derivatives of our free software and of promoting the sharing
|
|
||||||
and reuse of software generally.
|
|
||||||
|
|
||||||
NO WARRANTY
|
|
||||||
|
|
||||||
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
|
||||||
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
|
||||||
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
|
||||||
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
|
|
||||||
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
|
|
||||||
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
|
||||||
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
|
||||||
|
|
||||||
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
|
|
||||||
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
|
||||||
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
|
|
||||||
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
|
|
||||||
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
|
|
||||||
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
|
|
||||||
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
|
|
||||||
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
|
||||||
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
|
||||||
DAMAGES.
|
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
|
||||||
8667
thirdparty/smarty/ChangeLog
vendored
8667
thirdparty/smarty/ChangeLog
vendored
File diff suppressed because it is too large
Load Diff
284
thirdparty/smarty/FAQ
vendored
284
thirdparty/smarty/FAQ
vendored
@@ -1,284 +0,0 @@
|
|||||||
QUESTION INDEX
|
|
||||||
--------------
|
|
||||||
|
|
||||||
GENERAL
|
|
||||||
|
|
||||||
Q: What is Smarty?
|
|
||||||
Q: What's the difference between Smarty and other template engines?
|
|
||||||
Q: What do you mean "Compiled PHP Scripts" ?
|
|
||||||
Q: Why can't I just use PHPA (http://php-accelerator.co.uk) or Zend Cache?
|
|
||||||
Q: Why does smarty have a built in cache? Wouldn't it be better to handle this
|
|
||||||
in a separate class?
|
|
||||||
Q: Is Smarty faster than <insert other PHP template engine>?
|
|
||||||
Q: How can I be sure to get the best performance from Smarty?
|
|
||||||
Q: Do you have a mailing list?
|
|
||||||
Q: Can you change the mailing list so reply-to sends to the list and not the
|
|
||||||
user?
|
|
||||||
|
|
||||||
TROUBLESHOOTING
|
|
||||||
|
|
||||||
Q: Smarty doesn't work.
|
|
||||||
Q: I get the following error when running Smarty:
|
|
||||||
Warning: Smarty error: problem creating directory "templates_c/239/239105369"
|
|
||||||
in /path/to/Smarty.class.php on line 542
|
|
||||||
Q: I get the following error when running Smarty:
|
|
||||||
Warning: Wrong parameter count for preg_replace() in
|
|
||||||
Smarty.class.php on line 371
|
|
||||||
Q: I get this error when passing variables to {include}:
|
|
||||||
Fatal error: Call to undefined function: get_defined_vars() in
|
|
||||||
/path/to/Smarty/templates_c/index.tpl.php on line 8
|
|
||||||
Q: I get PHP errors in my {if} tag logic.
|
|
||||||
Q: I'm changing my php code and/or templates, and my results are not getting
|
|
||||||
updated.
|
|
||||||
Q: I'm running Windows 2000 and I get blank content. My compiled PHP files are
|
|
||||||
also zero length.
|
|
||||||
Q: The template goes into an infinite loop when I include included templates
|
|
||||||
that pass local variables
|
|
||||||
Q: Javascript is causing Smarty errors in my templates.
|
|
||||||
Q: I get "SAFE MODE Restriction in effect. ..."-errors when running smarty.
|
|
||||||
|
|
||||||
MISC
|
|
||||||
|
|
||||||
Q: Can I use Macromedia's Dreamweaver to edit my templates?
|
|
||||||
Q: Dreamweaver is urlencoding the template delimiters when they are in a SRC or
|
|
||||||
HREF link. How do I get around this?
|
|
||||||
|
|
||||||
HOWTO
|
|
||||||
|
|
||||||
Q: How do I generate different cache files per template based on arguments
|
|
||||||
passed to the page?
|
|
||||||
Q: How do I pass a template variable as a parameter? {function param={$varname}}
|
|
||||||
does not work.
|
|
||||||
Q: How do I include cached template(s) within a non-cached template?
|
|
||||||
|
|
||||||
|
|
||||||
GENERAL
|
|
||||||
-------
|
|
||||||
|
|
||||||
Q: What is Smarty?
|
|
||||||
A: Smarty is a template engine for PHP... but be aware this isn't just another
|
|
||||||
PHP template engine. It's much more than that.
|
|
||||||
|
|
||||||
Q: What's the difference between Smarty and other template engines?
|
|
||||||
A: Most other template engines for PHP provide basic variable substitution and
|
|
||||||
dynamic block functionality. Smarty takes a step further to be a "smart"
|
|
||||||
template engine, adding features such as configuration files, template
|
|
||||||
functions, variable modifiers (see the docs!) and making all of this
|
|
||||||
functionality as easy as possible to use for both programmers and template
|
|
||||||
designers. Smarty also compiles the templates into PHP scripts, eliminating
|
|
||||||
the need to parse the templates on every invocation, making Smarty extremely
|
|
||||||
scalable and manageable for large application needs.
|
|
||||||
|
|
||||||
Q: What do you mean "Compiled PHP Scripts" ?
|
|
||||||
A: Smarty reads the template files and creates PHP scripts from them. Once
|
|
||||||
these PHP scripts are created, Smarty executes these, never having to parse
|
|
||||||
the template files again. If you change a template file, Smarty will
|
|
||||||
recreate the PHP script for it. All this is done automatically by Smarty.
|
|
||||||
Template designers never need to mess with the generated PHP scripts or even
|
|
||||||
know of their existance. (NOTE: you can turn off this compile checking step
|
|
||||||
in Smarty for increased performance.)
|
|
||||||
|
|
||||||
Q: Why can't I just use PHPA (http://php-accelerator.co.uk) or Zend Cache?
|
|
||||||
A: You certainly can, and we highly recommend it! What PHPA does is caches
|
|
||||||
compiled bytecode of your PHP scripts in shared memory or in a file. This
|
|
||||||
speeds up server response and saves the compilation step. Smarty creates PHP
|
|
||||||
scripts, which PHPA will cache nicely. Now, Smarty's built-in cache is
|
|
||||||
something completely different. It caches the _output_ of the template
|
|
||||||
contents. For example, if you have a template that requires several database
|
|
||||||
queries, Smarty can cache this output, saving the need to call the database
|
|
||||||
every time. Smarty and PHPA (or Zend Cache) complement each other nicely. If
|
|
||||||
performance is of the utmost importance, we would recommend using one of
|
|
||||||
these with any PHP application, using Smarty or not. As you can see in the
|
|
||||||
benchmarks, Smartys performance _really_ excels in combination with a PHP
|
|
||||||
accelerator.
|
|
||||||
|
|
||||||
Q: Why does Smarty have a built in cache? Wouldn't it be better to handle this
|
|
||||||
in a separate class?
|
|
||||||
A: Smarty's caching functionality is tightly integrated with the template
|
|
||||||
engine, making it quite a bit more flexible than a simple caching wrapper.
|
|
||||||
For instance, you can cache select portions of a template page. Let's say
|
|
||||||
you have a polling box on your site. With Smarty, you can leave the poll
|
|
||||||
dynamic and cache the rest of the page. You can also pass templates
|
|
||||||
multiple cache ids, meaning that a template can have several caches
|
|
||||||
depending on URL, cookies, etc.
|
|
||||||
|
|
||||||
Q: Is Smarty faster than <insert other PHP template engine>?
|
|
||||||
A: See the benchmark page for some performance comparisons. Smarty's approach
|
|
||||||
to templates is a bit different from some languages: it compiles templates
|
|
||||||
into PHP scripts instead of parsing them on each invocation. This usually
|
|
||||||
results in great performance gains, especially with complex templates.
|
|
||||||
Coupled with the built-in caching of Smarty templates, the performance is
|
|
||||||
outstanding.
|
|
||||||
|
|
||||||
Q: How can I be sure to get the best performance from Smarty?
|
|
||||||
A: Be sure you set $compile_check=false once your templates are initially
|
|
||||||
compiled. This will skip the unneeded step of testing if the template has
|
|
||||||
changed since it was last compiled. If you have complex pages that don't
|
|
||||||
change too often, turn on the caching engine and adjust your application so
|
|
||||||
it doesn't do unnecessary work (like db calls) if a cached page is
|
|
||||||
available. See the documentation for examples.
|
|
||||||
|
|
||||||
Q: Do you have a mailing list?
|
|
||||||
A: We have a few mailing lists. "general" for you to share your ideas or ask
|
|
||||||
questions, "dev" for those interested in the development efforts of Smarty,
|
|
||||||
and "cvs" for those that would like to track the updates made in the cvs
|
|
||||||
repository.
|
|
||||||
|
|
||||||
send a blank e-mail message to:
|
|
||||||
smarty-general-subscribe@lists.php.net (subscribe to the general list)
|
|
||||||
smarty-general-unsubscribe@lists.php.net (unsubscribe from the general list)
|
|
||||||
smarty-general-digest-subscribe@lists.php.net (subscribe to digest)
|
|
||||||
smarty-general-digest-unsubscribe@lists.php.net (unsubscribe from digest)
|
|
||||||
smarty-dev-subscribe@lists.php.net (subscribe to the dev list)
|
|
||||||
smarty-dev-unsubscribe@lists.php.net (unsubscribe from the dev list)
|
|
||||||
smarty-cvs-subscribe@lists.php.net (subscribe to the cvs list)
|
|
||||||
smarty-cvs-unsubscribe@lists.php.net (unsubscribe from the cvs list)
|
|
||||||
You can also browse the mailing list archives at
|
|
||||||
http://marc.theaimsgroup.com/?l=smarty&r=1&w=2
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Q: Can you change the mailing list so Reply-To sends to the list and not the
|
|
||||||
user?
|
|
||||||
A: Yes we could, but no we won't. Use "Reply-All" in your e-mail client to send
|
|
||||||
to the list. http://www.unicom.com/pw/reply-to-harmful.html
|
|
||||||
|
|
||||||
TROUBLESHOOTING
|
|
||||||
---------------
|
|
||||||
|
|
||||||
Q: Smarty doesn't work.
|
|
||||||
A: You must be using PHP 4.0.6 or later if you use any version of Smarty
|
|
||||||
past 2.0.1. Read the BUGS file for more info.
|
|
||||||
|
|
||||||
Q: I get the following error when running Smarty:
|
|
||||||
Warning: Smarty error: problem creating directory "templates_c/239/239105369"
|
|
||||||
in /path/to/Smarty.class.php on line 542
|
|
||||||
A: Your web server user does not have permission to write to the templates_c
|
|
||||||
directory, or is unable to create the templates_c directory. Be sure the
|
|
||||||
templates_c directory exists in the location defined in Smarty.class.php,
|
|
||||||
and the web server user can write to it. If you do not know the web server
|
|
||||||
user, chmod 777 the templates_c directory, reload the page, then check the
|
|
||||||
file ownership of the files created in templates_c. Or, you can check the
|
|
||||||
httpd.conf (usually in /usr/local/apache/conf) file for this setting:
|
|
||||||
User nobody
|
|
||||||
Group nobody
|
|
||||||
|
|
||||||
Q: I get the following error when running Smarty: Warning: Wrong parameter
|
|
||||||
count for preg_replace() in Smarty.class.php on line 371
|
|
||||||
A: preg_replace had a parameter added in PHP 4.0.2 that Smarty
|
|
||||||
requires. Upgrade to at least 4.0.6 to fix all known PHP issues with
|
|
||||||
Smarty.
|
|
||||||
|
|
||||||
Q: I get this error when passing variables to {include}:
|
|
||||||
Fatal error: Call to undefined function: get_defined_vars() in
|
|
||||||
/path/to/Smarty/templates_c/index.tpl.php on line 8
|
|
||||||
A: get_defined_vars() was added to PHP 4.0.4. If you plan on passing
|
|
||||||
variables to included templates, you will need PHP 4.0.6 or later.
|
|
||||||
|
|
||||||
Q: I get PHP errors in my {if} tag logic.
|
|
||||||
A: All conditional qualifiers must be separated by spaces. This syntax will not
|
|
||||||
work: {if $name=="Wilma"} You must instead do this: {if $name == "Wilma"}.
|
|
||||||
The reason for this is syntax ambiguity. Both "==" and "eq" are equivalent
|
|
||||||
in the template parser, so something like {if $nameeq"Wilma"} wouldn't be
|
|
||||||
parsable by the tokenizer.
|
|
||||||
|
|
||||||
Q: I'm changing my php code and/or templates, and my results are not getting
|
|
||||||
updated.
|
|
||||||
A: This may be the result of your compile or cache settings. If you are
|
|
||||||
changing your php code, your templates will not necessarily get recompiled
|
|
||||||
to reflect the changes. Use $force_compile during develpment to avoid these
|
|
||||||
situations. Also turn off caching during development when you aren't
|
|
||||||
specifically testing it. You can also remove everything from your
|
|
||||||
compile_dir and cache_dir and reload the page to be sure everything gets
|
|
||||||
regenerated.
|
|
||||||
|
|
||||||
Q: I'm running Windows 2000 and I get blank content. My compiled PHP files are
|
|
||||||
also zero length.
|
|
||||||
A: There seems to be a problem with some W2k machines and exclusive file
|
|
||||||
locking. Comment out the flock() call in _write_file to get around this,
|
|
||||||
although be aware this could possibly cause a problem with simultaneous
|
|
||||||
writes to a file, especially with caching turned on. NOTE: As of Smarty
|
|
||||||
1.4.0, a workaround was put in place that should solve this.
|
|
||||||
|
|
||||||
Q: The template goes into an infinite loop when I include included templates
|
|
||||||
that pass local variables
|
|
||||||
A: This was fixed in 1.3.2 (new global attribute)
|
|
||||||
|
|
||||||
Q: Javascript is causing Smarty errors in my templates.
|
|
||||||
A: Surround your javascript with {literal}{/literal} tags. See the docs.
|
|
||||||
|
|
||||||
Q: I get "SAFE MODE Restriction in effect. ..."-errors when running smarty.
|
|
||||||
A: Use $smarty->use_sub_dirs = false when running php in safe mode.
|
|
||||||
|
|
||||||
MISC
|
|
||||||
----
|
|
||||||
|
|
||||||
Q: Can I use Macromedia's Dreamweaver to edit my templates?
|
|
||||||
A: Certainly. You might want to change your tag delimiters from {} to something
|
|
||||||
that resembles valid HTML, like <!--{ }--> or <{ }> or something similar.
|
|
||||||
This way the editor won't view the template tags as errors.
|
|
||||||
|
|
||||||
Q: Dreamweaver is urlencoding the template delimiters when they are in a SRC or
|
|
||||||
HREF link. How do I get around this?
|
|
||||||
A: In Edit - Properties - Rewrite HTML you can specify if Dreamweaver should
|
|
||||||
change special letters to %-equivalent or not. The default is on which
|
|
||||||
produces this error.
|
|
||||||
|
|
||||||
HOWTO
|
|
||||||
-----
|
|
||||||
|
|
||||||
Q: How do I generate different cache files per template based on arguments
|
|
||||||
passed to the page?
|
|
||||||
A: Use your $REQUEST_URI as the cache_id when fetching the page:
|
|
||||||
|
|
||||||
global $REQUEST_URI; // if not already present
|
|
||||||
$smarty->display('index.tpl',$REQUEST_URI);
|
|
||||||
|
|
||||||
This will create a separate cache file for each unique URL when you call
|
|
||||||
index.tpl. See the documentation for display() and fetch()
|
|
||||||
|
|
||||||
Q: How do I pass a template variable as a parameter? {function param={$varname}}
|
|
||||||
does not work.
|
|
||||||
A: {function param=$varname} (You cannot nest template delimiters.)
|
|
||||||
|
|
||||||
Q: How do I include cached template(s) within a non-cached template?
|
|
||||||
A: One way to do it:
|
|
||||||
|
|
||||||
$smarty->caching = true;
|
|
||||||
$tpl1 = $smarty->fetch("internal1.tpl");
|
|
||||||
$tpl2 = $smarty->fetch("internal2.tpl");
|
|
||||||
$tpl3 = $smarty->fetch("internal3.tpl");
|
|
||||||
|
|
||||||
$smarty->assign("tpl1_contents",$tpl1);
|
|
||||||
$smarty->assign("tpl2_contents",$tpl2);
|
|
||||||
$smarty->assign("tpl3_contents",$tpl3);
|
|
||||||
|
|
||||||
$smarty->caching = false;
|
|
||||||
$smarty->display('index.tpl');
|
|
||||||
|
|
||||||
index.tpl
|
|
||||||
---------
|
|
||||||
|
|
||||||
<table>
|
|
||||||
<tr>
|
|
||||||
<td>{$tpl1_contents}</td>
|
|
||||||
<td>{$tpl2_contents}</td>
|
|
||||||
<td>{$tpl3_contents}</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Another approach:
|
|
||||||
|
|
||||||
You could write a custom insert function to fetch your internal
|
|
||||||
templates:
|
|
||||||
|
|
||||||
<table>
|
|
||||||
<tr>
|
|
||||||
<td>{insert name=fetch_tpl tpl="internal1.tpl"}</td>
|
|
||||||
<td>{insert name=fetch_tpl tpl="internal2.tpl"}</td>
|
|
||||||
<td>{insert name=fetch_tpl tpl="internal3.tpl"}</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
29
thirdparty/smarty/INSTALL
vendored
29
thirdparty/smarty/INSTALL
vendored
@@ -1,29 +0,0 @@
|
|||||||
REQUIREMENTS:
|
|
||||||
|
|
||||||
Smarty requires PHP 4.0.6 or later.
|
|
||||||
See the on-line documentation for complete install instructions.
|
|
||||||
|
|
||||||
INSTALLATION (quick):
|
|
||||||
|
|
||||||
* copy the files under the libs/ directory to a directory that is in your PHP
|
|
||||||
include_path, or set the SMARTY_DIR constant and put them in this directory.
|
|
||||||
(if you upgrade from versions before 2.5.0 be aware that up to Smarty 2.4.2
|
|
||||||
all necessary files where in the distribution's root directory, but are now
|
|
||||||
in libs/.)
|
|
||||||
|
|
||||||
* for each application using Smarty, create a "templates", "configs", and a
|
|
||||||
"templates_c" directory, be sure to set the appropriate directory settings in
|
|
||||||
Smarty for them. If they are located in the same directory as your
|
|
||||||
application, they shouldn't need to be modified. Be sure the "templates_c"
|
|
||||||
directory is writable by your web server user (usually nobody). chown
|
|
||||||
nobody:nobody templates_c; chmod 700 templates_c You can also chmod 777 this
|
|
||||||
directory, but be aware of security issues for multi-user systems. If you are
|
|
||||||
using Smarty's built-in caching, create a "cache" directory and also chown
|
|
||||||
nobody:nobody.
|
|
||||||
|
|
||||||
* setup your php and template files. A good working example is in the on-line
|
|
||||||
documentation.
|
|
||||||
|
|
||||||
* TECHNICAL NOTE: If you do not have access to the php.ini file, you can change
|
|
||||||
non-server settings (such as your include_path) with the ini_set() command.
|
|
||||||
example: ini_set("include_path",".:/usr/local/lib/php");
|
|
||||||
1013
thirdparty/smarty/NEWS
vendored
1013
thirdparty/smarty/NEWS
vendored
File diff suppressed because it is too large
Load Diff
103
thirdparty/smarty/QUICK_START
vendored
103
thirdparty/smarty/QUICK_START
vendored
@@ -1,103 +0,0 @@
|
|||||||
This is a simple guide to get Smarty setup and running quickly. The online
|
|
||||||
documentation includes a very thorough explanation of a Smarty installation.
|
|
||||||
This guide is meant to be a quick and painless way of getting Smarty working,
|
|
||||||
and nothing more. The guide assumes you are familiar with the UNIX system
|
|
||||||
environment. Windows users will need to make adjustments where necessary.
|
|
||||||
|
|
||||||
INSTALL SMARTY LIBRARY FILES
|
|
||||||
|
|
||||||
Copy the Smarty library files to your system. In our example, we place them in
|
|
||||||
/usr/local/lib/php/Smarty/
|
|
||||||
|
|
||||||
$> cd YOUR_DOWNLOAD_DIRECTORY
|
|
||||||
$> gtar -ztvf Smarty-2.6.7.tar.gz
|
|
||||||
$> mkdir /usr/local/lib/php/Smarty
|
|
||||||
$> cp -r Smarty-2.6.7/libs/* /usr/local/lib/php/Smarty
|
|
||||||
|
|
||||||
You should now have the following file structure:
|
|
||||||
|
|
||||||
/usr/local/lib/php/Smarty/
|
|
||||||
Config_File.class.php
|
|
||||||
debug.tpl
|
|
||||||
internals/
|
|
||||||
plugins/
|
|
||||||
Smarty.class.php
|
|
||||||
Smarty_Compiler.class.php
|
|
||||||
|
|
||||||
|
|
||||||
SETUP SMARTY DIRECTORIES
|
|
||||||
|
|
||||||
You will need four directories setup for Smarty to work. These files are for
|
|
||||||
templates, compiled templates, cached templates and config files. You may or
|
|
||||||
may not use caching or config files, but it is a good idea to set them up
|
|
||||||
anyways. It is also recommended to place them outside of the web server
|
|
||||||
document root. The web server PHP user will need write access to the cache and
|
|
||||||
compile directories as well.
|
|
||||||
|
|
||||||
In our example, the document root is /web/www.domain.com/docs and the
|
|
||||||
web server username is "nobody". We will keep our Smarty files under
|
|
||||||
/web/www.domain.com/smarty
|
|
||||||
|
|
||||||
$> cd /web/www.domain.com
|
|
||||||
$> mkdir smarty
|
|
||||||
$> mkdir smarty/templates
|
|
||||||
$> mkdir smarty/templates_c
|
|
||||||
$> mkdir smarty/cache
|
|
||||||
$> mkdir smarty/configs
|
|
||||||
$> chown nobody:nobody smarty/templates_c
|
|
||||||
$> chown nobody:nobody smarty/cache
|
|
||||||
$> chmod 775 smarty/templates_c
|
|
||||||
$> chmod 775 smarty/cache
|
|
||||||
|
|
||||||
|
|
||||||
SETUP SMARTY PHP SCRIPTS
|
|
||||||
|
|
||||||
Now we setup our application in the document root:
|
|
||||||
|
|
||||||
$> cd /web/www.domain.com/docs
|
|
||||||
$> mkdir myapp
|
|
||||||
$> cd myapp
|
|
||||||
$> vi index.php
|
|
||||||
|
|
||||||
Edit the index.php file to look like the following:
|
|
||||||
|
|
||||||
<?php
|
|
||||||
|
|
||||||
// put full path to Smarty.class.php
|
|
||||||
require('/usr/local/lib/php/Smarty/Smarty.class.php');
|
|
||||||
$smarty = new Smarty();
|
|
||||||
|
|
||||||
$smarty->template_dir = '/web/www.domain.com/smarty/templates';
|
|
||||||
$smarty->compile_dir = '/web/www.domain.com/smarty/templates_c';
|
|
||||||
$smarty->cache_dir = '/web/www.domain.com/smarty/cache';
|
|
||||||
$smarty->config_dir = '/web/www.domain.com/smarty/configs';
|
|
||||||
|
|
||||||
$smarty->assign('name', 'Ned');
|
|
||||||
$smarty->display('index.tpl');
|
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
||||||
|
|
||||||
SETUP SMARTY TEMPLATE
|
|
||||||
|
|
||||||
$> vi /web/www.domain.com/smarty/templates/index.tpl
|
|
||||||
|
|
||||||
Edit the index.tpl file with the following:
|
|
||||||
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>Smarty</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
Hello, {$name}!
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Now go to your new application through the web browser,
|
|
||||||
http://www.domain.com/myapp/index.php in our example. You should see the text
|
|
||||||
"Hello Ned!" in your browser.
|
|
||||||
|
|
||||||
Once you get this far, you can continue on to the Smarty Crash Course to learn
|
|
||||||
a few more simple things, or on to the documentation to learn it all.
|
|
||||||
80
thirdparty/smarty/README
vendored
80
thirdparty/smarty/README
vendored
@@ -1,80 +0,0 @@
|
|||||||
NAME:
|
|
||||||
|
|
||||||
Smarty - the PHP compiling template engine
|
|
||||||
|
|
||||||
VERSION: 2.6.0
|
|
||||||
|
|
||||||
AUTHORS:
|
|
||||||
|
|
||||||
Monte Ohrt <monte at ohrt dot com>
|
|
||||||
Andrei Zmievski <andrei@php.net>
|
|
||||||
|
|
||||||
MAILING LISTS:
|
|
||||||
|
|
||||||
We have a few mailing lists. "general" for you to share your ideas or ask
|
|
||||||
questions, "dev" for those interested in the development efforts of Smarty,
|
|
||||||
and "cvs" for those that would like to track the updates made in the cvs
|
|
||||||
repository.
|
|
||||||
|
|
||||||
send a blank e-mail message to:
|
|
||||||
smarty-general-subscribe@lists.php.net (subscribe to the general list)
|
|
||||||
smarty-general-unsubscribe@lists.php.net (unsubscribe from the general list)
|
|
||||||
smarty-general-digest-subscribe@lists.php.net (subscribe to digest)
|
|
||||||
smarty-general-digest-unsubscribe@lists.php.net (unsubscribe from digest)
|
|
||||||
smarty-dev-subscribe@lists.php.net (subscribe to the dev list)
|
|
||||||
smarty-dev-unsubscribe@lists.php.net (unsubscribe from the dev list)
|
|
||||||
smarty-cvs-subscribe@lists.php.net (subscribe to the cvs list)
|
|
||||||
smarty-cvs-unsubscribe@lists.php.net (unsubscribe from the cvs list)
|
|
||||||
You can also browse the mailing list archives at
|
|
||||||
http://marc.theaimsgroup.com/?l=smarty&r=1&w=2
|
|
||||||
|
|
||||||
SYNOPSIS:
|
|
||||||
|
|
||||||
require("Smarty.class.php");
|
|
||||||
|
|
||||||
$smarty = new Smarty;
|
|
||||||
|
|
||||||
$smarty->assign("Title","My Homepage");
|
|
||||||
$smarty->assign("Names",array("John","Gary","Gregg","James"));
|
|
||||||
|
|
||||||
$smarty->display("index.tpl");
|
|
||||||
|
|
||||||
|
|
||||||
DESCRIPTION:
|
|
||||||
|
|
||||||
What is Smarty?
|
|
||||||
|
|
||||||
Smarty is a template engine for PHP. Many other template engines for PHP
|
|
||||||
provide basic variable substitution and dynamic block functionality.
|
|
||||||
Smarty takes a step further to be a "smart" template engine, adding
|
|
||||||
features such as configuration files, template functions, and variable
|
|
||||||
modifiers, and making all of this functionality as easy as possible to
|
|
||||||
use for both programmers and template designers. Smarty also converts
|
|
||||||
the templates into PHP scripts, eliminating the need to parse the
|
|
||||||
templates on every invocation. This makes Smarty extremely scalable and
|
|
||||||
manageable for large application needs.
|
|
||||||
|
|
||||||
Some of Smarty's features:
|
|
||||||
|
|
||||||
* it is extremely fast
|
|
||||||
* no template parsing overhead, only compiles once.
|
|
||||||
* it is smart about recompiling only the template files that have
|
|
||||||
changed.
|
|
||||||
* the template language is remarkably extensible via the plugin
|
|
||||||
architecture.
|
|
||||||
* configurable template delimiter tag syntax, so you can use
|
|
||||||
{}, {{}}, <!--{}-->, or whatever you like.
|
|
||||||
* built-in caching of template output.
|
|
||||||
* arbitrary template sources (filesystem, databases, etc.)
|
|
||||||
* template if/elseif/else/endif constructs are passed to the PHP parser,
|
|
||||||
so the if syntax can be as simple or as complex as you like.
|
|
||||||
* unlimited nesting of sections, conditionals, etc. allowed
|
|
||||||
* it is possible to embed PHP code right in your template files,
|
|
||||||
although not recommended and doubtfully needed since the engine
|
|
||||||
is so customizable.
|
|
||||||
* and many more.
|
|
||||||
|
|
||||||
COPYRIGHT:
|
|
||||||
Copyright (c) 2001-2005 New Digital Group, Inc. All rights reserved.
|
|
||||||
This software is released under the GNU Lesser General Public License.
|
|
||||||
Please read the disclaimer at the top of the Smarty.class.php file.
|
|
||||||
428
thirdparty/smarty/RELEASE_NOTES
vendored
428
thirdparty/smarty/RELEASE_NOTES
vendored
@@ -1,428 +0,0 @@
|
|||||||
2.6.7
|
|
||||||
-----
|
|
||||||
|
|
||||||
Those using Smarty with security enabled: a hole was found that allowed PHP code to be executed from within a template file. This has been fixed and you are engouraged to upgrade immediately. Note that this hole does NOT affect the security of your web server or PHP applications, only the ability for someone editing a template to execute PHP code. Other changes in this release can be found in the NEWS file.
|
|
||||||
|
|
||||||
2.5.0
|
|
||||||
-----
|
|
||||||
|
|
||||||
Very minor adjustments since RC2, see the NEWS file for details.
|
|
||||||
|
|
||||||
2.5.0-RC2
|
|
||||||
---------
|
|
||||||
|
|
||||||
Many fixes since the RC1 release. This one is as close to production quality as
|
|
||||||
they come, so this will be the last release before 2.5.0. The SGML documentation
|
|
||||||
files have also been removed from the tarball. If you want them, get them from
|
|
||||||
the CVS repository.
|
|
||||||
|
|
||||||
2.5.0-RC1
|
|
||||||
---------
|
|
||||||
|
|
||||||
Release Candidate 1. All $smarty vars can now be dynamic, such as
|
|
||||||
$smarty.get.$foo. A new class function get_function_object() gets you a
|
|
||||||
reference to an assigned object, useful within your own custom functions.
|
|
||||||
append() can now merge as well as append with a third optional attribute. A new
|
|
||||||
class function get_config_vars() was added, and get_template_vars() can now be
|
|
||||||
used to get individual vars. Full variable syntax is now supported within
|
|
||||||
double quotes via a backtick (`) syntax. Files created by smarty are now
|
|
||||||
written to a tmp file then renamed to avoid file lock retention. html_radios,
|
|
||||||
html_checkboxes, html_table, html_image, nl2br functions added, see the NEWS
|
|
||||||
file for full details.
|
|
||||||
|
|
||||||
2.4.2
|
|
||||||
-----
|
|
||||||
Another point release. Added support for dynamic object reference syntax
|
|
||||||
($foo->$bar), support for full variable syntax within quotes ("$foo[0].bar"),
|
|
||||||
and other minor fixes. See the NEWS file for full details.
|
|
||||||
|
|
||||||
2.4.1
|
|
||||||
-----
|
|
||||||
|
|
||||||
This is basically a point release, cleaning up a few things caught
|
|
||||||
in the 2.4.0 release. See the NEWS file for full details.
|
|
||||||
|
|
||||||
2.4.0
|
|
||||||
-----
|
|
||||||
|
|
||||||
Smarty now supports the ability to access objects within the templates. Two
|
|
||||||
methods are available, one which closely follows Smartys conventions, and
|
|
||||||
another that follows more traditional object syntax for those familiar with
|
|
||||||
PHP.
|
|
||||||
|
|
||||||
The internal compiling engine has also undergone some major work. The regex
|
|
||||||
parsing was rewritten to be much more strict, more secure and more
|
|
||||||
maintainable. Config files are now compiled, which can speed up pages quite a
|
|
||||||
bit that use config files extensively. Assigned variables are no longer
|
|
||||||
extracted to PHP namespace, saving an extract call for every template. There is
|
|
||||||
now support for applying modifiers to static values and functions. You can now
|
|
||||||
access constants with $smarty.const.VAR. See the NEWS file for complete
|
|
||||||
changes.
|
|
||||||
|
|
||||||
2.3.1
|
|
||||||
-----
|
|
||||||
|
|
||||||
The mtime on compiled files will now match the source files, in the case where
|
|
||||||
the source file may not get the current timestamp, recompiling will still work
|
|
||||||
as expected. Proper support for open_basedir has been added, so Smarty should
|
|
||||||
work correctly in safe mode. Added a few new features such as textformat block
|
|
||||||
function, strip variable modifier and optgroup support for html_options. Also
|
|
||||||
other minor bug fixes, see the Change Log.
|
|
||||||
|
|
||||||
2.3.0
|
|
||||||
-----
|
|
||||||
|
|
||||||
Smarty now has a {debug} template function that brings up the debugging console
|
|
||||||
right where {debug} is called, regardless of $debugging settings. This works a
|
|
||||||
little different than turning on $debugging in the sense that it shows all the
|
|
||||||
template variables available at the time {debug} is called, including local
|
|
||||||
scope vars. It does not show the templates names however, since this
|
|
||||||
executed during runtime of the template.
|
|
||||||
|
|
||||||
You can now supply an expire time when clearing cache or compile files. This is
|
|
||||||
mostly useful for removing stale files via the API.
|
|
||||||
|
|
||||||
Plugins now stop execution upon error, instead of outputting a warning and
|
|
||||||
continuing.
|
|
||||||
|
|
||||||
Two new API functions, assign_by_ref() and append_by_ref() were added. They
|
|
||||||
allow assigning template variables by reference. This can make a significant
|
|
||||||
performance gain, especially if you are assigning large arrays of data. PHP 5.0
|
|
||||||
will do this implicitly, so these functions are basically workarounds.
|
|
||||||
|
|
||||||
Several misc bug fixes, see the Change Log for information.
|
|
||||||
|
|
||||||
|
|
||||||
2.2.0
|
|
||||||
-----
|
|
||||||
|
|
||||||
Smarty now allows an array of paths for the $plugin_dir class variable. The
|
|
||||||
directories will be searched in the order they are given, so for efficiency keep
|
|
||||||
the most-used plugins at the top. Also, absolute paths to the plugin directories are
|
|
||||||
more efficient than relying on the PHP include_path.
|
|
||||||
|
|
||||||
Cache files can now be grouped with the cache_id. See the documentation under
|
|
||||||
the new "Caching" section for details. compile_id also respects the same
|
|
||||||
grouping syntax. The cache/compile file structure changed, so be sure to clear
|
|
||||||
out all your cache and compile files when upgrading Smarty. Also if you are
|
|
||||||
using PHP-accelerator, restart apache. I've seen some quirky things happen if
|
|
||||||
the phpa files do not get cleared (known issue with phpa and parent
|
|
||||||
class-member changes, so just clear 'em.)
|
|
||||||
|
|
||||||
Smarty now correctly respects the PHP include_path for $template_dir, $compile_dir,
|
|
||||||
$cache_dir, $config_dir and $plugin_dir. Be aware that relying on the
|
|
||||||
include_path is an overhead, try to use absolute pathnames when possible
|
|
||||||
(or relative to working directory.)
|
|
||||||
|
|
||||||
Documentation has been updated and rearranged a bit. Most notably, the
|
|
||||||
installation instructions are completely revamped, and a new Caching section
|
|
||||||
explains Smarty's caching in detail along with the new grouping functionality.
|
|
||||||
|
|
||||||
Many misc. bug fixes and enhancements, see the full ChangeLog (NEWS file) for
|
|
||||||
details.
|
|
||||||
|
|
||||||
2.1.1
|
|
||||||
-----
|
|
||||||
|
|
||||||
There was a bug with template paths and the include_path, this has been fixed.
|
|
||||||
Also register_outputfilter() did not work, this is fixed. A new template
|
|
||||||
function named "cycle" has been added to the distribution, nice for cycling
|
|
||||||
through a list (or array) of values.
|
|
||||||
|
|
||||||
2.1.0
|
|
||||||
-----
|
|
||||||
|
|
||||||
This release has quite a few new features and fixes. Most notable are the
|
|
||||||
introduction of block functions, so you can write plugins that work on a block
|
|
||||||
of text with {func}{/func} notation. Also output filters were added, so you can
|
|
||||||
apply a function against the output of your templates. This differs from the
|
|
||||||
postfilter function, which works on the compiled template at compile time, and
|
|
||||||
output filters work on the template output at runtime.
|
|
||||||
|
|
||||||
Many other features and bug fixes are noted in the NEWS file.
|
|
||||||
|
|
||||||
|
|
||||||
2.0.1
|
|
||||||
-----
|
|
||||||
|
|
||||||
This is a point release, fixing a few bugs and cleaning things up. A plugin
|
|
||||||
was renamed, the dash "-" was removed from compiled template and cached file
|
|
||||||
names. If you're upgrading, you might want to clear them out first. See the
|
|
||||||
ChangeLog for details.
|
|
||||||
|
|
||||||
2.0.0
|
|
||||||
-----
|
|
||||||
|
|
||||||
This release is a huge milestone for Smarty. Most notable new things are a
|
|
||||||
plugin architecture, removal of PEAR dependency, and optimizations that
|
|
||||||
drastically improve the performance of Smarty in most cases.
|
|
||||||
|
|
||||||
The plugin architecture allows modifiers, custom functions, compiler functions,
|
|
||||||
prefilters, postfilters, resources, and insert functions to be added by
|
|
||||||
simply dropping a file into the plugins directory. Once dropped in, they are
|
|
||||||
automatically registered by the template engine. This makes user-contributed
|
|
||||||
plugins easy to manage, as well as the internal workings of Smarty easy to
|
|
||||||
control and customize. This new architecture depends on the __FILE__ constant,
|
|
||||||
which contains the full path to the executing script. Some older versions of
|
|
||||||
PHP incorrectly gave the script name and not the full filesystem path. Be sure
|
|
||||||
your version of PHP populates __FILE__ correctly. If you use custom template
|
|
||||||
resource functions, the format of these changed with the plugin architecture.
|
|
||||||
Be sure to update your functions accordingly. See the template resource section
|
|
||||||
of the documentation.
|
|
||||||
|
|
||||||
The PEAR dependancy was removed from Smarty. The Config_File class that comes
|
|
||||||
with Smarty was actually what needed PEAR for error handling which Smarty didn't
|
|
||||||
use, but now everything is self-contained.
|
|
||||||
|
|
||||||
Performance improvements are graphed on the benchmark page, you will see that
|
|
||||||
overall performance has been sped up by as much as 80% in some cases.
|
|
||||||
|
|
||||||
Smarty-cached pages now support If-Modified-Since headers, meaning that if a
|
|
||||||
cached template page has not changed since the last request, a "304 Not
|
|
||||||
Modified" header will be sent instead of resending the same page. This is
|
|
||||||
disabled by default, change the setting of $cache_modified_check.
|
|
||||||
|
|
||||||
|
|
||||||
1.5.2
|
|
||||||
-----
|
|
||||||
|
|
||||||
Mostly bug fixes, added a default template resource handler.
|
|
||||||
|
|
||||||
|
|
||||||
1.5.1
|
|
||||||
-----
|
|
||||||
|
|
||||||
Critical bug fix release. If you use caching, you'll need to upgrade.
|
|
||||||
|
|
||||||
|
|
||||||
1.5.0
|
|
||||||
-----
|
|
||||||
|
|
||||||
Several feature enhancements were made to this version, most notably the
|
|
||||||
{foreach ...} command which is an alternative to {section ...} with an easier
|
|
||||||
syntax for looping through a single array of values. Several functions were
|
|
||||||
enhanced so that the output can be automatically assigned to a template
|
|
||||||
variable instead of displayed (assign attribute). Cache files can now be
|
|
||||||
controlled with a custom function as an alternative to the built-in file based
|
|
||||||
method. Many code cleanups and bug fixed went into this release as well.
|
|
||||||
|
|
||||||
|
|
||||||
1.4.6
|
|
||||||
-----
|
|
||||||
|
|
||||||
The behavior with caching and compile_check has been slightly enhanced. If
|
|
||||||
caching is enabled AND compile_check is enabled, the cache will immediately get
|
|
||||||
regenerated if _any_ involved template or config file is updated. This imposes
|
|
||||||
a slight performance hit because it must check all the files for changes, so be
|
|
||||||
sure to run live sites with caching enabled and compile_check disabled for best
|
|
||||||
performance. If you update a template or config file, simply turn on
|
|
||||||
compile_check, load the page, then turn it back off. This will update the cache
|
|
||||||
file with the new content. This is accomplished by maintaining a list of
|
|
||||||
included/loaded templates and config files at the beginning of the cache file.
|
|
||||||
Therefore it is advisable to remove all cache files after upgrading to 1.4.6
|
|
||||||
(although not absolutely necessary, old cache files will regenerate)
|
|
||||||
|
|
||||||
The debug console now has script timing and array values printed. You MUST
|
|
||||||
update your debug.tpl file with this version of Smarty. Also, the new debug.tpl
|
|
||||||
will not work with older versions of Smarty.
|
|
||||||
|
|
||||||
|
|
||||||
1.4.5
|
|
||||||
-----
|
|
||||||
|
|
||||||
Mostly bug fixes and minor improvements. Added compile id for separate compiled
|
|
||||||
versions of the same script. The directory format and filename convention for
|
|
||||||
the files in templates_c has changed, so you may want to remove all of the
|
|
||||||
existing ones before you upgrade.
|
|
||||||
|
|
||||||
|
|
||||||
1.4.4
|
|
||||||
-----
|
|
||||||
|
|
||||||
A few bug fixes, new section looping attributes and properties, debugging
|
|
||||||
console function for control via URL, and overLib integration and access
|
|
||||||
to request variables from within the template.
|
|
||||||
|
|
||||||
|
|
||||||
1.4.3
|
|
||||||
-----
|
|
||||||
|
|
||||||
This release has a few bug fixes and several enhancements. Smarty now supports
|
|
||||||
template security for third-party template editing. These features disallow the
|
|
||||||
ability for someone to execute commands or PHP code from the template language.
|
|
||||||
Smarty also now has a built-in debugging console, which is a javascript pop-up
|
|
||||||
window that displays all the included template names and assigned variables.
|
|
||||||
|
|
||||||
|
|
||||||
1.4.2
|
|
||||||
-----
|
|
||||||
|
|
||||||
This was mostly one bug fix with variable scoping within included templates
|
|
||||||
and a few documentation changes and updates. See the ChangeLog file for full
|
|
||||||
details.
|
|
||||||
|
|
||||||
|
|
||||||
1.4.1
|
|
||||||
-----
|
|
||||||
|
|
||||||
It seems that the EX_LOCK logic from the previous release didn't fix all the
|
|
||||||
problems with windows platforms. Hopefully this one does. It basically
|
|
||||||
disables file locking on windows, so there is a potential that two programs
|
|
||||||
could write over the same file at the same time, fyi.
|
|
||||||
|
|
||||||
The reset is minor bug fixes, please refer to the ChangeLog file.
|
|
||||||
|
|
||||||
|
|
||||||
1.4.0
|
|
||||||
-----
|
|
||||||
|
|
||||||
IMPORTANT NOTICE
|
|
||||||
|
|
||||||
Smarty now has a new syntax for accessing elements within section loops. The
|
|
||||||
new syntax is easier to use and nicely handles data structures of any
|
|
||||||
complexity. Consequently, this breaks the old syntax.
|
|
||||||
|
|
||||||
Here is an example of the syntax change:
|
|
||||||
|
|
||||||
old syntax:
|
|
||||||
{$sec1/sec2/sec3/customer.phone}
|
|
||||||
|
|
||||||
new syntax:
|
|
||||||
{$customer[$sec1][$sec2][$sec3].phone}
|
|
||||||
|
|
||||||
The section names used to come first, followed by the variable name. Now the
|
|
||||||
variable name always comes first, followed by the section names in brackets.
|
|
||||||
You can access variable indexes anywhere, depending on how you passed the
|
|
||||||
variables in.
|
|
||||||
|
|
||||||
To fix your current templates, we have provided a script that will adjust the
|
|
||||||
syntax for you. Located in misc/fix_vars.php, run this script from the the
|
|
||||||
command line, giving each template as an argument. Be sure to use absolute
|
|
||||||
pathnames, or pathnames relative to the executing script. Probably the easiest
|
|
||||||
way to do this is to copy the fix_vars.php script into your template directory
|
|
||||||
and run 'php -q fix_vars.php *.tpl' Be sure you have proper write permission,
|
|
||||||
and backup your scripts first to be safe! The examples in the 1.4.0
|
|
||||||
documentation have been updated to reflect the changes.
|
|
||||||
|
|
||||||
cd /path/to/templates
|
|
||||||
cp /path/to/fix_vars.php .
|
|
||||||
find . -name "*.tpl" -exec php -q ./fix_vars.php {} \;
|
|
||||||
|
|
||||||
NEW AND IMPROVED COMPILATION PROCESS
|
|
||||||
|
|
||||||
Smarty 1.4.0 also has a new compilation process. Instead of compiling all the
|
|
||||||
templates up front, it now compiles them at runtime. This has several
|
|
||||||
advantages. First of all, there is no longer a need to have a single template
|
|
||||||
directory. You can now have arbitrary template sources, such as multiple
|
|
||||||
directories or even database calls. This also speeds the performance of Smarty
|
|
||||||
when $compile_check is enabled, since it is only checking the template that is
|
|
||||||
being executed instead of everything found in the template directory. The
|
|
||||||
$tpl_file_ext is no longer needed, but kept for backward compatability.
|
|
||||||
Templates can now be named anything you like with any extension.
|
|
||||||
|
|
||||||
MINOR FIXES
|
|
||||||
|
|
||||||
A workaround for LOCK_EX on Windows systems was added, and changed a couple of
|
|
||||||
file permissions for better security on public servers.
|
|
||||||
|
|
||||||
$show_info_header is now defaulted to false instead of true. This header causes
|
|
||||||
problems when displaying content other than HTML, so now you must explicitly
|
|
||||||
set this flag to true to show the header information (or change the default in
|
|
||||||
your copy of Smarty.)
|
|
||||||
|
|
||||||
Documentation is written in docbook format. I updated the docbook -> HTML
|
|
||||||
generating software & style-sheets, and consequently the examples are no longer
|
|
||||||
in a different background color. If anyone wants to contribute a better
|
|
||||||
stylesheet or help with documentation, drop me a line. <monte at ohrt dot com>
|
|
||||||
|
|
||||||
CHANGES/ENHANCEMENTS/UPDATES
|
|
||||||
|
|
||||||
date_format, html_select_date and html_select_time used to require a unix
|
|
||||||
timestamp as the format of the date passed into the template. Smarty is now a
|
|
||||||
bit smarter at this. It will take a unix timestamp, a mysql timestamp, or any
|
|
||||||
date string that is parsable by strtotime, such as 10/01/2001 or 2001-10-01,
|
|
||||||
etc. Just give some formats a try and see what works.
|
|
||||||
|
|
||||||
Smarty now has template prefilters, meaning that you can run your templates
|
|
||||||
through custom functions before they are compiled. This is good for things like
|
|
||||||
removing unwanted comments, keeping an eye on words or functionality people are
|
|
||||||
putting in templates, translating XML -> HTML, etc. See the register_prefilter
|
|
||||||
documentation for more info.
|
|
||||||
|
|
||||||
Another addition are the so-called compiler functions. These are custom
|
|
||||||
functions registered by the user that are executed at compilation time of the
|
|
||||||
template. They can be used to inject PHP code or time-sensitive static content
|
|
||||||
into the compiled template.
|
|
||||||
|
|
||||||
The run-time custom functions are now passed the Smarty object as the second
|
|
||||||
parameter. This can be used, for example, to assign or clear template variables
|
|
||||||
from inside the custom function.
|
|
||||||
|
|
||||||
clear_compile_dir() was added for clearing out compiled versions of your
|
|
||||||
templates. Not something normally needed, but you may have a need for this if
|
|
||||||
you have $compile_check set to false and you periodically update templates via
|
|
||||||
some automated process. As of 1.4.0, uncompiled templates _always_ get
|
|
||||||
compiled regardless of $compile_check setting, although they won't be checked
|
|
||||||
for recompile if $compile_check is set to false.
|
|
||||||
|
|
||||||
You can now refer to properties of objects assigned from PHP by using the '->'
|
|
||||||
symbol and specifying the property name after it, e.g. $foo->bar.
|
|
||||||
|
|
||||||
{php}{/php} tags were added to embed php into the templates. Not normally
|
|
||||||
needed, but some circumstances may call for it. Check out the "componentized
|
|
||||||
templates" tip in the documentation for an example.
|
|
||||||
|
|
||||||
{capture}{/capture} and {counter} functions were added. See the documentation
|
|
||||||
for a complete description and examples.
|
|
||||||
|
|
||||||
UPGRADE NOTES
|
|
||||||
|
|
||||||
The format of the files created in the $compile_dir are now a bit different.
|
|
||||||
The compiled template filename is the template resource name url-encoded.
|
|
||||||
Therefore, all compiled files are now in the top directory of $compile_dir.
|
|
||||||
This was done to make way for arbitrary template resources. Each compiled
|
|
||||||
template also has a header that states what template resource was used to
|
|
||||||
create it. From a unix command prompt, you can use "head -2 *" to see the first
|
|
||||||
two lines of each file.
|
|
||||||
|
|
||||||
When upgrading to 1.4.0, you will want to clear out all your old files in the
|
|
||||||
$compile_dir. If you have $compile_check set to false and the compiled template
|
|
||||||
does not yet exist, it will compile it regardless of this setting. This way you
|
|
||||||
can clear out the $compile_dir and not worry about setting $compile_check to
|
|
||||||
true to get the inital compilation under way.
|
|
||||||
|
|
||||||
|
|
||||||
1.3.2
|
|
||||||
-----
|
|
||||||
|
|
||||||
Smarty now has (an optional) header prepended to the output of the Smarty
|
|
||||||
templates. This displays the Smarty version and the date/time when the page was
|
|
||||||
generated. This is useful for debugging your cache routines, and purely
|
|
||||||
informational so there is evidence that the page was generated by Smarty. Set
|
|
||||||
$show_info_header to false to disable it.
|
|
||||||
|
|
||||||
{config_load ...} performance was tuned by placing the loaded variables into a
|
|
||||||
global array, so basically a config file is read from the file system and
|
|
||||||
placed into a php array structure only once, no matter how many times it is
|
|
||||||
called in any of the templates. The scope of the loaded variables has changed a
|
|
||||||
bit as well. Variables loaded by config_load used to be treated as global
|
|
||||||
variables, meaning that parent templates (templates that included the current
|
|
||||||
template) could see them. Now the default behavior is such that loaded
|
|
||||||
variables are only visible by the current template and child templates (all
|
|
||||||
templates included after the {config_load ...} is called.) To mimic the
|
|
||||||
original behavior, provide the attribute "global=yes" like so: {config_load
|
|
||||||
file="mystuff.conf" global=yes}. Now when you load in mystuff.conf, the
|
|
||||||
variables will be visible to parent templates (merged with any existing config
|
|
||||||
variables.)
|
|
||||||
|
|
||||||
A formatting attribute was added to the {math ...} function, adding the ability
|
|
||||||
to control the format of the output. Use the same formatting syntax as the PHP
|
|
||||||
function sprintf().
|
|
||||||
|
|
||||||
{html_select_time ...} was added, a custom function that works much like
|
|
||||||
{html_select_date ...} except it displays time elements instead of dates.
|
|
||||||
|
|
||||||
A few custom modifiers were added: count_characters, count_words,
|
|
||||||
count_sentences, count_paragraphs. All pretty self-explanatory.
|
|
||||||
|
|
||||||
/* vim: set et: */
|
|
||||||
10
thirdparty/smarty/TODO
vendored
10
thirdparty/smarty/TODO
vendored
@@ -1,10 +0,0 @@
|
|||||||
* handle asp style tags in $php_handler
|
|
||||||
* fix all E_NOTICE warnings
|
|
||||||
* make simple math easier
|
|
||||||
* caching all but parts of the template
|
|
||||||
* change plugins so $smarty variable always comes first
|
|
||||||
* get cache ttl with function call
|
|
||||||
FIX: make inserts use normal functions before plugins
|
|
||||||
UPD: change it so that if template comes from some resource,
|
|
||||||
that resource stays as the default, no need to specify it
|
|
||||||
in includes.
|
|
||||||
5
thirdparty/smarty/demo/configs/test.conf
vendored
5
thirdparty/smarty/demo/configs/test.conf
vendored
@@ -1,5 +0,0 @@
|
|||||||
title = Welcome to Smarty!
|
|
||||||
cutoff_size = 40
|
|
||||||
|
|
||||||
[setup]
|
|
||||||
bold = true
|
|
||||||
25
thirdparty/smarty/demo/index.php
vendored
25
thirdparty/smarty/demo/index.php
vendored
@@ -1,25 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
require '../libs/Smarty.class.php';
|
|
||||||
|
|
||||||
$smarty = new Smarty;
|
|
||||||
|
|
||||||
$smarty->compile_check = true;
|
|
||||||
$smarty->debugging = true;
|
|
||||||
|
|
||||||
$smarty->assign("Name","Fred Irving Johnathan Bradley Peppergill");
|
|
||||||
$smarty->assign("FirstName",array("John","Mary","James","Henry"));
|
|
||||||
$smarty->assign("LastName",array("Doe","Smith","Johnson","Case"));
|
|
||||||
$smarty->assign("Class",array(array("A","B","C","D"), array("E", "F", "G", "H"),
|
|
||||||
array("I", "J", "K", "L"), array("M", "N", "O", "P")));
|
|
||||||
|
|
||||||
$smarty->assign("contacts", array(array("phone" => "1", "fax" => "2", "cell" => "3"),
|
|
||||||
array("phone" => "555-4444", "fax" => "555-3333", "cell" => "760-1234")));
|
|
||||||
|
|
||||||
$smarty->assign("option_values", array("NY","NE","KS","IA","OK","TX"));
|
|
||||||
$smarty->assign("option_output", array("New York","Nebraska","Kansas","Iowa","Oklahoma","Texas"));
|
|
||||||
$smarty->assign("option_selected", "NE");
|
|
||||||
|
|
||||||
$smarty->display('index.tpl');
|
|
||||||
|
|
||||||
?>
|
|
||||||
2
thirdparty/smarty/demo/templates/footer.tpl
vendored
2
thirdparty/smarty/demo/templates/footer.tpl
vendored
@@ -1,2 +0,0 @@
|
|||||||
</BODY>
|
|
||||||
</HTML>
|
|
||||||
6
thirdparty/smarty/demo/templates/header.tpl
vendored
6
thirdparty/smarty/demo/templates/header.tpl
vendored
@@ -1,6 +0,0 @@
|
|||||||
<HTML>
|
|
||||||
<HEAD>
|
|
||||||
{popup_init src="/javascripts/overlib.js"}
|
|
||||||
<TITLE>{$title} - {$Name}</TITLE>
|
|
||||||
</HEAD>
|
|
||||||
<BODY bgcolor="#ffffff">
|
|
||||||
81
thirdparty/smarty/demo/templates/index.tpl
vendored
81
thirdparty/smarty/demo/templates/index.tpl
vendored
@@ -1,81 +0,0 @@
|
|||||||
{config_load file=test.conf section="setup"}
|
|
||||||
{include file="header.tpl" title=foo}
|
|
||||||
|
|
||||||
<PRE>
|
|
||||||
|
|
||||||
{* bold and title are read from the config file *}
|
|
||||||
{if #bold#}<b>{/if}
|
|
||||||
{* capitalize the first letters of each word of the title *}
|
|
||||||
Title: {#title#|capitalize}
|
|
||||||
{if #bold#}</b>{/if}
|
|
||||||
|
|
||||||
The current date and time is {$smarty.now|date_format:"%Y-%m-%d %H:%M:%S"}
|
|
||||||
|
|
||||||
The value of global assigned variable $SCRIPT_NAME is {$SCRIPT_NAME}
|
|
||||||
|
|
||||||
Example of accessing server environment variable SERVER_NAME: {$smarty.server.SERVER_NAME}
|
|
||||||
|
|
||||||
The value of {ldelim}$Name{rdelim} is <b>{$Name}</b>
|
|
||||||
|
|
||||||
variable modifier example of {ldelim}$Name|upper{rdelim}
|
|
||||||
|
|
||||||
<b>{$Name|upper}</b>
|
|
||||||
|
|
||||||
|
|
||||||
An example of a section loop:
|
|
||||||
|
|
||||||
{section name=outer loop=$FirstName}
|
|
||||||
{if $smarty.section.outer.index is odd by 2}
|
|
||||||
{$smarty.section.outer.rownum} . {$FirstName[outer]} {$LastName[outer]}
|
|
||||||
{else}
|
|
||||||
{$smarty.section.outer.rownum} * {$FirstName[outer]} {$LastName[outer]}
|
|
||||||
{/if}
|
|
||||||
{sectionelse}
|
|
||||||
none
|
|
||||||
{/section}
|
|
||||||
|
|
||||||
An example of section looped key values:
|
|
||||||
|
|
||||||
{section name=sec1 loop=$contacts}
|
|
||||||
phone: {$contacts[sec1].phone}<br>
|
|
||||||
fax: {$contacts[sec1].fax}<br>
|
|
||||||
cell: {$contacts[sec1].cell}<br>
|
|
||||||
{/section}
|
|
||||||
<p>
|
|
||||||
|
|
||||||
testing strip tags
|
|
||||||
{strip}
|
|
||||||
<table border=0>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<A HREF="{$SCRIPT_NAME}">
|
|
||||||
<font color="red">This is a test </font>
|
|
||||||
</A>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
{/strip}
|
|
||||||
|
|
||||||
</PRE>
|
|
||||||
|
|
||||||
This is an example of the html_select_date function:
|
|
||||||
|
|
||||||
<form>
|
|
||||||
{html_select_date start_year=1998 end_year=2010}
|
|
||||||
</form>
|
|
||||||
|
|
||||||
This is an example of the html_select_time function:
|
|
||||||
|
|
||||||
<form>
|
|
||||||
{html_select_time use_24_hours=false}
|
|
||||||
</form>
|
|
||||||
|
|
||||||
This is an example of the html_options function:
|
|
||||||
|
|
||||||
<form>
|
|
||||||
<select name=states>
|
|
||||||
{html_options values=$option_values selected=$option_selected output=$option_output}
|
|
||||||
</select>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
{include file="footer.tpl"}
|
|
||||||
389
thirdparty/smarty/libs/Config_File.class.php
vendored
389
thirdparty/smarty/libs/Config_File.class.php
vendored
@@ -1,389 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Config_File class.
|
|
||||||
*
|
|
||||||
* This library 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 2.1 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library 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 library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
*
|
|
||||||
* @link http://smarty.php.net/
|
|
||||||
* @version 2.6.18
|
|
||||||
* @copyright Copyright: 2001-2005 New Digital Group, Inc.
|
|
||||||
* @author Andrei Zmievski <andrei@php.net>
|
|
||||||
* @access public
|
|
||||||
* @package Smarty
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* $Id: Config_File.class.php,v 1.88 2007/03/06 10:40:06 messju Exp $ */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Config file reading class
|
|
||||||
* @package Smarty
|
|
||||||
*/
|
|
||||||
class Config_File {
|
|
||||||
/**#@+
|
|
||||||
* Options
|
|
||||||
* @var boolean
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* Controls whether variables with the same name overwrite each other.
|
|
||||||
*/
|
|
||||||
var $overwrite = true;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Controls whether config values of on/true/yes and off/false/no get
|
|
||||||
* converted to boolean values automatically.
|
|
||||||
*/
|
|
||||||
var $booleanize = true;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Controls whether hidden config sections/vars are read from the file.
|
|
||||||
*/
|
|
||||||
var $read_hidden = true;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Controls whether or not to fix mac or dos formatted newlines.
|
|
||||||
* If set to true, \r or \r\n will be changed to \n.
|
|
||||||
*/
|
|
||||||
var $fix_newlines = true;
|
|
||||||
/**#@-*/
|
|
||||||
|
|
||||||
/** @access private */
|
|
||||||
var $_config_path = "";
|
|
||||||
var $_config_data = array();
|
|
||||||
/**#@-*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs a new config file class.
|
|
||||||
*
|
|
||||||
* @param string $config_path (optional) path to the config files
|
|
||||||
*/
|
|
||||||
function Config_File($config_path = NULL)
|
|
||||||
{
|
|
||||||
if (isset($config_path))
|
|
||||||
$this->set_path($config_path);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the path where configuration files can be found.
|
|
||||||
*
|
|
||||||
* @param string $config_path path to the config files
|
|
||||||
*/
|
|
||||||
function set_path($config_path)
|
|
||||||
{
|
|
||||||
if (!empty($config_path)) {
|
|
||||||
if (!is_string($config_path) || !file_exists($config_path) || !is_dir($config_path)) {
|
|
||||||
$this->_trigger_error_msg("Bad config file path '$config_path'");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(substr($config_path, -1) != DIRECTORY_SEPARATOR) {
|
|
||||||
$config_path .= DIRECTORY_SEPARATOR;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->_config_path = $config_path;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves config info based on the file, section, and variable name.
|
|
||||||
*
|
|
||||||
* @param string $file_name config file to get info for
|
|
||||||
* @param string $section_name (optional) section to get info for
|
|
||||||
* @param string $var_name (optional) variable to get info for
|
|
||||||
* @return string|array a value or array of values
|
|
||||||
*/
|
|
||||||
function get($file_name, $section_name = NULL, $var_name = NULL)
|
|
||||||
{
|
|
||||||
if (empty($file_name)) {
|
|
||||||
$this->_trigger_error_msg('Empty config file name');
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
$file_name = $this->_config_path . $file_name;
|
|
||||||
if (!isset($this->_config_data[$file_name]))
|
|
||||||
$this->load_file($file_name, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($var_name)) {
|
|
||||||
if (empty($section_name)) {
|
|
||||||
return $this->_config_data[$file_name]["vars"][$var_name];
|
|
||||||
} else {
|
|
||||||
if(isset($this->_config_data[$file_name]["sections"][$section_name]["vars"][$var_name]))
|
|
||||||
return $this->_config_data[$file_name]["sections"][$section_name]["vars"][$var_name];
|
|
||||||
else
|
|
||||||
return array();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (empty($section_name)) {
|
|
||||||
return (array)$this->_config_data[$file_name]["vars"];
|
|
||||||
} else {
|
|
||||||
if(isset($this->_config_data[$file_name]["sections"][$section_name]["vars"]))
|
|
||||||
return (array)$this->_config_data[$file_name]["sections"][$section_name]["vars"];
|
|
||||||
else
|
|
||||||
return array();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves config info based on the key.
|
|
||||||
*
|
|
||||||
* @param $file_name string config key (filename/section/var)
|
|
||||||
* @return string|array same as get()
|
|
||||||
* @uses get() retrieves information from config file and returns it
|
|
||||||
*/
|
|
||||||
function &get_key($config_key)
|
|
||||||
{
|
|
||||||
list($file_name, $section_name, $var_name) = explode('/', $config_key, 3);
|
|
||||||
$result = &$this->get($file_name, $section_name, $var_name);
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get all loaded config file names.
|
|
||||||
*
|
|
||||||
* @return array an array of loaded config file names
|
|
||||||
*/
|
|
||||||
function get_file_names()
|
|
||||||
{
|
|
||||||
return array_keys($this->_config_data);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get all section names from a loaded file.
|
|
||||||
*
|
|
||||||
* @param string $file_name config file to get section names from
|
|
||||||
* @return array an array of section names from the specified file
|
|
||||||
*/
|
|
||||||
function get_section_names($file_name)
|
|
||||||
{
|
|
||||||
$file_name = $this->_config_path . $file_name;
|
|
||||||
if (!isset($this->_config_data[$file_name])) {
|
|
||||||
$this->_trigger_error_msg("Unknown config file '$file_name'");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
return array_keys($this->_config_data[$file_name]["sections"]);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get all global or section variable names.
|
|
||||||
*
|
|
||||||
* @param string $file_name config file to get info for
|
|
||||||
* @param string $section_name (optional) section to get info for
|
|
||||||
* @return array an array of variables names from the specified file/section
|
|
||||||
*/
|
|
||||||
function get_var_names($file_name, $section = NULL)
|
|
||||||
{
|
|
||||||
if (empty($file_name)) {
|
|
||||||
$this->_trigger_error_msg('Empty config file name');
|
|
||||||
return;
|
|
||||||
} else if (!isset($this->_config_data[$file_name])) {
|
|
||||||
$this->_trigger_error_msg("Unknown config file '$file_name'");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty($section))
|
|
||||||
return array_keys($this->_config_data[$file_name]["vars"]);
|
|
||||||
else
|
|
||||||
return array_keys($this->_config_data[$file_name]["sections"][$section]["vars"]);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Clear loaded config data for a certain file or all files.
|
|
||||||
*
|
|
||||||
* @param string $file_name file to clear config data for
|
|
||||||
*/
|
|
||||||
function clear($file_name = NULL)
|
|
||||||
{
|
|
||||||
if ($file_name === NULL)
|
|
||||||
$this->_config_data = array();
|
|
||||||
else if (isset($this->_config_data[$file_name]))
|
|
||||||
$this->_config_data[$file_name] = array();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Load a configuration file manually.
|
|
||||||
*
|
|
||||||
* @param string $file_name file name to load
|
|
||||||
* @param boolean $prepend_path whether current config path should be
|
|
||||||
* prepended to the filename
|
|
||||||
*/
|
|
||||||
function load_file($file_name, $prepend_path = true)
|
|
||||||
{
|
|
||||||
if ($prepend_path && $this->_config_path != "")
|
|
||||||
$config_file = $this->_config_path . $file_name;
|
|
||||||
else
|
|
||||||
$config_file = $file_name;
|
|
||||||
|
|
||||||
ini_set('track_errors', true);
|
|
||||||
$fp = @fopen($config_file, "r");
|
|
||||||
if (!is_resource($fp)) {
|
|
||||||
$this->_trigger_error_msg("Could not open config file '$config_file'");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$contents = ($size = filesize($config_file)) ? fread($fp, $size) : '';
|
|
||||||
fclose($fp);
|
|
||||||
|
|
||||||
$this->_config_data[$config_file] = $this->parse_contents($contents);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Store the contents of a file manually.
|
|
||||||
*
|
|
||||||
* @param string $config_file file name of the related contents
|
|
||||||
* @param string $contents the file-contents to parse
|
|
||||||
*/
|
|
||||||
function set_file_contents($config_file, $contents)
|
|
||||||
{
|
|
||||||
$this->_config_data[$config_file] = $this->parse_contents($contents);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* parse the source of a configuration file manually.
|
|
||||||
*
|
|
||||||
* @param string $contents the file-contents to parse
|
|
||||||
*/
|
|
||||||
function parse_contents($contents)
|
|
||||||
{
|
|
||||||
if($this->fix_newlines) {
|
|
||||||
// fix mac/dos formatted newlines
|
|
||||||
$contents = preg_replace('!\r\n?!', "\n", $contents);
|
|
||||||
}
|
|
||||||
|
|
||||||
$config_data = array();
|
|
||||||
$config_data['sections'] = array();
|
|
||||||
$config_data['vars'] = array();
|
|
||||||
|
|
||||||
/* reference to fill with data */
|
|
||||||
$vars =& $config_data['vars'];
|
|
||||||
|
|
||||||
/* parse file line by line */
|
|
||||||
preg_match_all('!^.*\r?\n?!m', $contents, $match);
|
|
||||||
$lines = $match[0];
|
|
||||||
for ($i=0, $count=count($lines); $i<$count; $i++) {
|
|
||||||
$line = $lines[$i];
|
|
||||||
if (empty($line)) continue;
|
|
||||||
|
|
||||||
if ( substr($line, 0, 1) == '[' && preg_match('!^\[(.*?)\]!', $line, $match) ) {
|
|
||||||
/* section found */
|
|
||||||
if (substr($match[1], 0, 1) == '.') {
|
|
||||||
/* hidden section */
|
|
||||||
if ($this->read_hidden) {
|
|
||||||
$section_name = substr($match[1], 1);
|
|
||||||
} else {
|
|
||||||
/* break reference to $vars to ignore hidden section */
|
|
||||||
unset($vars);
|
|
||||||
$vars = array();
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$section_name = $match[1];
|
|
||||||
}
|
|
||||||
if (!isset($config_data['sections'][$section_name]))
|
|
||||||
$config_data['sections'][$section_name] = array('vars' => array());
|
|
||||||
$vars =& $config_data['sections'][$section_name]['vars'];
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (preg_match('/^\s*(\.?\w+)\s*=\s*(.*)/s', $line, $match)) {
|
|
||||||
/* variable found */
|
|
||||||
$var_name = rtrim($match[1]);
|
|
||||||
if (strpos($match[2], '"""') === 0) {
|
|
||||||
/* handle multiline-value */
|
|
||||||
$lines[$i] = substr($match[2], 3);
|
|
||||||
$var_value = '';
|
|
||||||
while ($i<$count) {
|
|
||||||
if (($pos = strpos($lines[$i], '"""')) === false) {
|
|
||||||
$var_value .= $lines[$i++];
|
|
||||||
} else {
|
|
||||||
/* end of multiline-value */
|
|
||||||
$var_value .= substr($lines[$i], 0, $pos);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$booleanize = false;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
/* handle simple value */
|
|
||||||
$var_value = preg_replace('/^([\'"])(.*)\1$/', '\2', rtrim($match[2]));
|
|
||||||
$booleanize = $this->booleanize;
|
|
||||||
|
|
||||||
}
|
|
||||||
$this->_set_config_var($vars, $var_name, $var_value, $booleanize);
|
|
||||||
}
|
|
||||||
/* else unparsable line / means it is a comment / means ignore it */
|
|
||||||
}
|
|
||||||
return $config_data;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**#@+ @access private */
|
|
||||||
/**
|
|
||||||
* @param array &$container
|
|
||||||
* @param string $var_name
|
|
||||||
* @param mixed $var_value
|
|
||||||
* @param boolean $booleanize determines whether $var_value is converted to
|
|
||||||
* to true/false
|
|
||||||
*/
|
|
||||||
function _set_config_var(&$container, $var_name, $var_value, $booleanize)
|
|
||||||
{
|
|
||||||
if (substr($var_name, 0, 1) == '.') {
|
|
||||||
if (!$this->read_hidden)
|
|
||||||
return;
|
|
||||||
else
|
|
||||||
$var_name = substr($var_name, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!preg_match("/^[a-zA-Z_]\w*$/", $var_name)) {
|
|
||||||
$this->_trigger_error_msg("Bad variable name '$var_name'");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($booleanize) {
|
|
||||||
if (preg_match("/^(on|true|yes)$/i", $var_value))
|
|
||||||
$var_value = true;
|
|
||||||
else if (preg_match("/^(off|false|no)$/i", $var_value))
|
|
||||||
$var_value = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isset($container[$var_name]) || $this->overwrite)
|
|
||||||
$container[$var_name] = $var_value;
|
|
||||||
else {
|
|
||||||
settype($container[$var_name], 'array');
|
|
||||||
$container[$var_name][] = $var_value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @uses trigger_error() creates a PHP warning/error
|
|
||||||
* @param string $error_msg
|
|
||||||
* @param integer $error_type one of
|
|
||||||
*/
|
|
||||||
function _trigger_error_msg($error_msg, $error_type = E_USER_WARNING)
|
|
||||||
{
|
|
||||||
trigger_error("Config_File error: $error_msg", $error_type);
|
|
||||||
}
|
|
||||||
/**#@-*/
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
||||||
1958
thirdparty/smarty/libs/Smarty.class.php
vendored
1958
thirdparty/smarty/libs/Smarty.class.php
vendored
File diff suppressed because it is too large
Load Diff
2341
thirdparty/smarty/libs/Smarty_Compiler.class.php
vendored
2341
thirdparty/smarty/libs/Smarty_Compiler.class.php
vendored
File diff suppressed because it is too large
Load Diff
157
thirdparty/smarty/libs/debug.tpl
vendored
157
thirdparty/smarty/libs/debug.tpl
vendored
@@ -1,157 +0,0 @@
|
|||||||
{* Smarty *}
|
|
||||||
{* debug.tpl, last updated version 2.1.0 *}
|
|
||||||
{assign_debug_info}
|
|
||||||
{capture assign=debug_output}
|
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
|
||||||
<head>
|
|
||||||
<title>Smarty Debug Console</title>
|
|
||||||
{literal}
|
|
||||||
<style type="text/css">
|
|
||||||
/* <![CDATA[ */
|
|
||||||
body, h1, h2, td, th, p {
|
|
||||||
font-family: sans-serif;
|
|
||||||
font-weight: normal;
|
|
||||||
font-size: 0.9em;
|
|
||||||
margin: 1px;
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
h1 {
|
|
||||||
margin: 0;
|
|
||||||
text-align: left;
|
|
||||||
padding: 2px;
|
|
||||||
background-color: #f0c040;
|
|
||||||
color: black;
|
|
||||||
font-weight: bold;
|
|
||||||
font-size: 1.2em;
|
|
||||||
}
|
|
||||||
|
|
||||||
h2 {
|
|
||||||
background-color: #9B410E;
|
|
||||||
color: white;
|
|
||||||
text-align: left;
|
|
||||||
font-weight: bold;
|
|
||||||
padding: 2px;
|
|
||||||
border-top: 1px solid black;
|
|
||||||
}
|
|
||||||
|
|
||||||
body {
|
|
||||||
background: black;
|
|
||||||
}
|
|
||||||
|
|
||||||
p, table, div {
|
|
||||||
background: #f0ead8;
|
|
||||||
}
|
|
||||||
|
|
||||||
p {
|
|
||||||
margin: 0;
|
|
||||||
font-style: italic;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
table {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
th, td {
|
|
||||||
font-family: monospace;
|
|
||||||
vertical-align: top;
|
|
||||||
text-align: left;
|
|
||||||
width: 50%;
|
|
||||||
}
|
|
||||||
|
|
||||||
td {
|
|
||||||
color: green;
|
|
||||||
}
|
|
||||||
|
|
||||||
.odd {
|
|
||||||
background-color: #eeeeee;
|
|
||||||
}
|
|
||||||
|
|
||||||
.even {
|
|
||||||
background-color: #fafafa;
|
|
||||||
}
|
|
||||||
|
|
||||||
.exectime {
|
|
||||||
font-size: 0.8em;
|
|
||||||
font-style: italic;
|
|
||||||
}
|
|
||||||
|
|
||||||
#table_assigned_vars th {
|
|
||||||
color: blue;
|
|
||||||
}
|
|
||||||
|
|
||||||
#table_config_vars th {
|
|
||||||
color: maroon;
|
|
||||||
}
|
|
||||||
/* ]]> */
|
|
||||||
</style>
|
|
||||||
{/literal}
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<h1>Smarty Debug Console</h1>
|
|
||||||
|
|
||||||
<h2>included templates & config files (load time in seconds)</h2>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
{section name=templates loop=$_debug_tpls}
|
|
||||||
{section name=indent loop=$_debug_tpls[templates].depth} {/section}
|
|
||||||
<font color={if $_debug_tpls[templates].type eq "template"}brown{elseif $_debug_tpls[templates].type eq "insert"}black{else}green{/if}>
|
|
||||||
{$_debug_tpls[templates].filename|escape:html}</font>
|
|
||||||
{if isset($_debug_tpls[templates].exec_time)}
|
|
||||||
<span class="exectime">
|
|
||||||
({$_debug_tpls[templates].exec_time|string_format:"%.5f"})
|
|
||||||
{if %templates.index% eq 0}(total){/if}
|
|
||||||
</span>
|
|
||||||
{/if}
|
|
||||||
<br />
|
|
||||||
{sectionelse}
|
|
||||||
<p>no templates included</p>
|
|
||||||
{/section}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<h2>assigned template variables</h2>
|
|
||||||
|
|
||||||
<table id="table_assigned_vars">
|
|
||||||
{section name=vars loop=$_debug_keys}
|
|
||||||
<tr class="{cycle values="odd,even"}">
|
|
||||||
<th>{ldelim}${$_debug_keys[vars]|escape:'html'}{rdelim}</th>
|
|
||||||
<td>{$_debug_vals[vars]|@debug_print_var}</td></tr>
|
|
||||||
{sectionelse}
|
|
||||||
<tr><td><p>no template variables assigned</p></td></tr>
|
|
||||||
{/section}
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<h2>assigned config file variables (outer template scope)</h2>
|
|
||||||
|
|
||||||
<table id="table_config_vars">
|
|
||||||
{section name=config_vars loop=$_debug_config_keys}
|
|
||||||
<tr class="{cycle values="odd,even"}">
|
|
||||||
<th>{ldelim}#{$_debug_config_keys[config_vars]|escape:'html'}#{rdelim}</th>
|
|
||||||
<td>{$_debug_config_vals[config_vars]|@debug_print_var}</td></tr>
|
|
||||||
{sectionelse}
|
|
||||||
<tr><td><p>no config vars assigned</p></td></tr>
|
|
||||||
{/section}
|
|
||||||
</table>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
{/capture}
|
|
||||||
{if isset($_smarty_debug_output) and $_smarty_debug_output eq "html"}
|
|
||||||
{$debug_output}
|
|
||||||
{else}
|
|
||||||
<script type="text/javascript">
|
|
||||||
// <![CDATA[
|
|
||||||
if ( self.name == '' ) {ldelim}
|
|
||||||
var title = 'Console';
|
|
||||||
{rdelim}
|
|
||||||
else {ldelim}
|
|
||||||
var title = 'Console_' + self.name;
|
|
||||||
{rdelim}
|
|
||||||
_smarty_console = window.open("",title.value,"width=680,height=600,resizable,scrollbars=yes");
|
|
||||||
_smarty_console.document.write('{$debug_output|escape:'javascript'}');
|
|
||||||
_smarty_console.document.close();
|
|
||||||
// ]]>
|
|
||||||
</script>
|
|
||||||
{/if}
|
|
||||||
@@ -1,67 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Smarty plugin
|
|
||||||
* @package Smarty
|
|
||||||
* @subpackage plugins
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* assemble filepath of requested plugin
|
|
||||||
*
|
|
||||||
* @param string $type
|
|
||||||
* @param string $name
|
|
||||||
* @return string|false
|
|
||||||
*/
|
|
||||||
function smarty_core_assemble_plugin_filepath($params, &$smarty)
|
|
||||||
{
|
|
||||||
static $_filepaths_cache = array();
|
|
||||||
|
|
||||||
$_plugin_filename = $params['type'] . '.' . $params['name'] . '.php';
|
|
||||||
if (isset($_filepaths_cache[$_plugin_filename])) {
|
|
||||||
return $_filepaths_cache[$_plugin_filename];
|
|
||||||
}
|
|
||||||
$_return = false;
|
|
||||||
|
|
||||||
foreach ((array)$smarty->plugins_dir as $_plugin_dir) {
|
|
||||||
|
|
||||||
$_plugin_filepath = $_plugin_dir . DIRECTORY_SEPARATOR . $_plugin_filename;
|
|
||||||
|
|
||||||
// see if path is relative
|
|
||||||
if (!preg_match("/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/", $_plugin_dir)) {
|
|
||||||
$_relative_paths[] = $_plugin_dir;
|
|
||||||
// relative path, see if it is in the SMARTY_DIR
|
|
||||||
if (@is_readable(SMARTY_DIR . $_plugin_filepath)) {
|
|
||||||
$_return = SMARTY_DIR . $_plugin_filepath;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// try relative to cwd (or absolute)
|
|
||||||
if (@is_readable($_plugin_filepath)) {
|
|
||||||
$_return = $_plugin_filepath;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if($_return === false) {
|
|
||||||
// still not found, try PHP include_path
|
|
||||||
if(isset($_relative_paths)) {
|
|
||||||
foreach ((array)$_relative_paths as $_plugin_dir) {
|
|
||||||
|
|
||||||
$_plugin_filepath = $_plugin_dir . DIRECTORY_SEPARATOR . $_plugin_filename;
|
|
||||||
|
|
||||||
$_params = array('file_path' => $_plugin_filepath);
|
|
||||||
require_once(SMARTY_CORE_DIR . 'core.get_include_path.php');
|
|
||||||
if(smarty_core_get_include_path($_params, $smarty)) {
|
|
||||||
$_return = $_params['new_file_path'];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$_filepaths_cache[$_plugin_filename] = $_return;
|
|
||||||
return $_return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* vim: set expandtab: */
|
|
||||||
|
|
||||||
?>
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Smarty plugin
|
|
||||||
* @package Smarty
|
|
||||||
* @subpackage plugins
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Smarty assign_smarty_interface core plugin
|
|
||||||
*
|
|
||||||
* Type: core<br>
|
|
||||||
* Name: assign_smarty_interface<br>
|
|
||||||
* Purpose: assign the $smarty interface variable
|
|
||||||
* @param array Format: null
|
|
||||||
* @param Smarty
|
|
||||||
*/
|
|
||||||
function smarty_core_assign_smarty_interface($params, &$smarty)
|
|
||||||
{
|
|
||||||
if (isset($smarty->_smarty_vars) && isset($smarty->_smarty_vars['request'])) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$_globals_map = array('g' => 'HTTP_GET_VARS',
|
|
||||||
'p' => 'HTTP_POST_VARS',
|
|
||||||
'c' => 'HTTP_COOKIE_VARS',
|
|
||||||
's' => 'HTTP_SERVER_VARS',
|
|
||||||
'e' => 'HTTP_ENV_VARS');
|
|
||||||
|
|
||||||
$_smarty_vars_request = array();
|
|
||||||
|
|
||||||
foreach (preg_split('!!', strtolower($smarty->request_vars_order)) as $_c) {
|
|
||||||
if (isset($_globals_map[$_c])) {
|
|
||||||
$_smarty_vars_request = array_merge($_smarty_vars_request, $GLOBALS[$_globals_map[$_c]]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$_smarty_vars_request = @array_merge($_smarty_vars_request, $GLOBALS['HTTP_SESSION_VARS']);
|
|
||||||
|
|
||||||
$smarty->_smarty_vars['request'] = $_smarty_vars_request;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* vim: set expandtab: */
|
|
||||||
|
|
||||||
?>
|
|
||||||
@@ -1,79 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Smarty plugin
|
|
||||||
* @package Smarty
|
|
||||||
* @subpackage plugins
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* create full directory structure
|
|
||||||
*
|
|
||||||
* @param string $dir
|
|
||||||
*/
|
|
||||||
|
|
||||||
// $dir
|
|
||||||
|
|
||||||
function smarty_core_create_dir_structure($params, &$smarty)
|
|
||||||
{
|
|
||||||
if (!file_exists($params['dir'])) {
|
|
||||||
$_open_basedir_ini = ini_get('open_basedir');
|
|
||||||
|
|
||||||
if (DIRECTORY_SEPARATOR=='/') {
|
|
||||||
/* unix-style paths */
|
|
||||||
$_dir = $params['dir'];
|
|
||||||
$_dir_parts = preg_split('!/+!', $_dir, -1, PREG_SPLIT_NO_EMPTY);
|
|
||||||
$_new_dir = (substr($_dir, 0, 1)=='/') ? '/' : getcwd().'/';
|
|
||||||
if($_use_open_basedir = !empty($_open_basedir_ini)) {
|
|
||||||
$_open_basedirs = explode(':', $_open_basedir_ini);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
/* other-style paths */
|
|
||||||
$_dir = str_replace('\\','/', $params['dir']);
|
|
||||||
$_dir_parts = preg_split('!/+!', $_dir, -1, PREG_SPLIT_NO_EMPTY);
|
|
||||||
if (preg_match('!^((//)|([a-zA-Z]:/))!', $_dir, $_root_dir)) {
|
|
||||||
/* leading "//" for network volume, or "[letter]:/" for full path */
|
|
||||||
$_new_dir = $_root_dir[1];
|
|
||||||
/* remove drive-letter from _dir_parts */
|
|
||||||
if (isset($_root_dir[3])) array_shift($_dir_parts);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
$_new_dir = str_replace('\\', '/', getcwd()).'/';
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if($_use_open_basedir = !empty($_open_basedir_ini)) {
|
|
||||||
$_open_basedirs = explode(';', str_replace('\\', '/', $_open_basedir_ini));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* all paths use "/" only from here */
|
|
||||||
foreach ($_dir_parts as $_dir_part) {
|
|
||||||
$_new_dir .= $_dir_part;
|
|
||||||
|
|
||||||
if ($_use_open_basedir) {
|
|
||||||
// do not attempt to test or make directories outside of open_basedir
|
|
||||||
$_make_new_dir = false;
|
|
||||||
foreach ($_open_basedirs as $_open_basedir) {
|
|
||||||
if (substr($_new_dir, 0, strlen($_open_basedir)) == $_open_basedir) {
|
|
||||||
$_make_new_dir = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$_make_new_dir = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($_make_new_dir && !file_exists($_new_dir) && !@mkdir($_new_dir, $smarty->_dir_perms) && !is_dir($_new_dir)) {
|
|
||||||
$smarty->trigger_error("problem creating directory '" . $_new_dir . "'");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
$_new_dir .= '/';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* vim: set expandtab: */
|
|
||||||
|
|
||||||
?>
|
|
||||||
@@ -1,61 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Smarty plugin
|
|
||||||
* @package Smarty
|
|
||||||
* @subpackage plugins
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Smarty debug_console function plugin
|
|
||||||
*
|
|
||||||
* Type: core<br>
|
|
||||||
* Name: display_debug_console<br>
|
|
||||||
* Purpose: display the javascript debug console window
|
|
||||||
* @param array Format: null
|
|
||||||
* @param Smarty
|
|
||||||
*/
|
|
||||||
function smarty_core_display_debug_console($params, &$smarty)
|
|
||||||
{
|
|
||||||
// we must force compile the debug template in case the environment
|
|
||||||
// changed between separate applications.
|
|
||||||
|
|
||||||
if(empty($smarty->debug_tpl)) {
|
|
||||||
// set path to debug template from SMARTY_DIR
|
|
||||||
$smarty->debug_tpl = SMARTY_DIR . 'debug.tpl';
|
|
||||||
if($smarty->security && is_file($smarty->debug_tpl)) {
|
|
||||||
$smarty->secure_dir[] = realpath($smarty->debug_tpl);
|
|
||||||
}
|
|
||||||
$smarty->debug_tpl = 'file:' . SMARTY_DIR . 'debug.tpl';
|
|
||||||
}
|
|
||||||
|
|
||||||
$_ldelim_orig = $smarty->left_delimiter;
|
|
||||||
$_rdelim_orig = $smarty->right_delimiter;
|
|
||||||
|
|
||||||
$smarty->left_delimiter = '{';
|
|
||||||
$smarty->right_delimiter = '}';
|
|
||||||
|
|
||||||
$_compile_id_orig = $smarty->_compile_id;
|
|
||||||
$smarty->_compile_id = null;
|
|
||||||
|
|
||||||
$_compile_path = $smarty->_get_compile_path($smarty->debug_tpl);
|
|
||||||
if ($smarty->_compile_resource($smarty->debug_tpl, $_compile_path))
|
|
||||||
{
|
|
||||||
ob_start();
|
|
||||||
$smarty->_include($_compile_path);
|
|
||||||
$_results = ob_get_contents();
|
|
||||||
ob_end_clean();
|
|
||||||
} else {
|
|
||||||
$_results = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
$smarty->_compile_id = $_compile_id_orig;
|
|
||||||
|
|
||||||
$smarty->left_delimiter = $_ldelim_orig;
|
|
||||||
$smarty->right_delimiter = $_rdelim_orig;
|
|
||||||
|
|
||||||
return $_results;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* vim: set expandtab: */
|
|
||||||
|
|
||||||
?>
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Smarty plugin
|
|
||||||
* @package Smarty
|
|
||||||
* @subpackage plugins
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get path to file from include_path
|
|
||||||
*
|
|
||||||
* @param string $file_path
|
|
||||||
* @param string $new_file_path
|
|
||||||
* @return boolean
|
|
||||||
* @staticvar array|null
|
|
||||||
*/
|
|
||||||
|
|
||||||
// $file_path, &$new_file_path
|
|
||||||
|
|
||||||
function smarty_core_get_include_path(&$params, &$smarty)
|
|
||||||
{
|
|
||||||
static $_path_array = null;
|
|
||||||
|
|
||||||
if(!isset($_path_array)) {
|
|
||||||
$_ini_include_path = ini_get('include_path');
|
|
||||||
|
|
||||||
if(strstr($_ini_include_path,';')) {
|
|
||||||
// windows pathnames
|
|
||||||
$_path_array = explode(';',$_ini_include_path);
|
|
||||||
} else {
|
|
||||||
$_path_array = explode(':',$_ini_include_path);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
foreach ($_path_array as $_include_path) {
|
|
||||||
if (@is_readable($_include_path . DIRECTORY_SEPARATOR . $params['file_path'])) {
|
|
||||||
$params['new_file_path'] = $_include_path . DIRECTORY_SEPARATOR . $params['file_path'];
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* vim: set expandtab: */
|
|
||||||
|
|
||||||
?>
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Smarty plugin
|
|
||||||
* @package Smarty
|
|
||||||
* @subpackage plugins
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get seconds and microseconds
|
|
||||||
* @return double
|
|
||||||
*/
|
|
||||||
function smarty_core_get_microtime($params, &$smarty)
|
|
||||||
{
|
|
||||||
$mtime = microtime();
|
|
||||||
$mtime = explode(" ", $mtime);
|
|
||||||
$mtime = (double)($mtime[1]) + (double)($mtime[0]);
|
|
||||||
return ($mtime);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* vim: set expandtab: */
|
|
||||||
|
|
||||||
?>
|
|
||||||
@@ -1,80 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Smarty plugin
|
|
||||||
* @package Smarty
|
|
||||||
* @subpackage plugins
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves PHP script resource
|
|
||||||
*
|
|
||||||
* sets $php_resource to the returned resource
|
|
||||||
* @param string $resource
|
|
||||||
* @param string $resource_type
|
|
||||||
* @param $php_resource
|
|
||||||
* @return boolean
|
|
||||||
*/
|
|
||||||
|
|
||||||
function smarty_core_get_php_resource(&$params, &$smarty)
|
|
||||||
{
|
|
||||||
|
|
||||||
$params['resource_base_path'] = $smarty->trusted_dir;
|
|
||||||
$smarty->_parse_resource_name($params, $smarty);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Find out if the resource exists.
|
|
||||||
*/
|
|
||||||
|
|
||||||
if ($params['resource_type'] == 'file') {
|
|
||||||
$_readable = false;
|
|
||||||
if(file_exists($params['resource_name']) && is_readable($params['resource_name'])) {
|
|
||||||
$_readable = true;
|
|
||||||
} else {
|
|
||||||
// test for file in include_path
|
|
||||||
$_params = array('file_path' => $params['resource_name']);
|
|
||||||
require_once(SMARTY_CORE_DIR . 'core.get_include_path.php');
|
|
||||||
if(smarty_core_get_include_path($_params, $smarty)) {
|
|
||||||
$_include_path = $_params['new_file_path'];
|
|
||||||
$_readable = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if ($params['resource_type'] != 'file') {
|
|
||||||
$_template_source = null;
|
|
||||||
$_readable = is_callable($smarty->_plugins['resource'][$params['resource_type']][0][0])
|
|
||||||
&& call_user_func_array($smarty->_plugins['resource'][$params['resource_type']][0][0],
|
|
||||||
array($params['resource_name'], &$_template_source, &$smarty));
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Set the error function, depending on which class calls us.
|
|
||||||
*/
|
|
||||||
if (method_exists($smarty, '_syntax_error')) {
|
|
||||||
$_error_funcc = '_syntax_error';
|
|
||||||
} else {
|
|
||||||
$_error_funcc = 'trigger_error';
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($_readable) {
|
|
||||||
if ($smarty->security) {
|
|
||||||
require_once(SMARTY_CORE_DIR . 'core.is_trusted.php');
|
|
||||||
if (!smarty_core_is_trusted($params, $smarty)) {
|
|
||||||
$smarty->$_error_funcc('(secure mode) ' . $params['resource_type'] . ':' . $params['resource_name'] . ' is not trusted');
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$smarty->$_error_funcc($params['resource_type'] . ':' . $params['resource_name'] . ' is not readable');
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($params['resource_type'] == 'file') {
|
|
||||||
$params['php_resource'] = $params['resource_name'];
|
|
||||||
} else {
|
|
||||||
$params['php_resource'] = $_template_source;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* vim: set expandtab: */
|
|
||||||
|
|
||||||
?>
|
|
||||||
@@ -1,59 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Smarty plugin
|
|
||||||
* @package Smarty
|
|
||||||
* @subpackage plugins
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* determines if a resource is secure or not.
|
|
||||||
*
|
|
||||||
* @param string $resource_type
|
|
||||||
* @param string $resource_name
|
|
||||||
* @return boolean
|
|
||||||
*/
|
|
||||||
|
|
||||||
// $resource_type, $resource_name
|
|
||||||
|
|
||||||
function smarty_core_is_secure($params, &$smarty)
|
|
||||||
{
|
|
||||||
if (!$smarty->security || $smarty->security_settings['INCLUDE_ANY']) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($params['resource_type'] == 'file') {
|
|
||||||
$_rp = realpath($params['resource_name']);
|
|
||||||
if (isset($params['resource_base_path'])) {
|
|
||||||
foreach ((array)$params['resource_base_path'] as $curr_dir) {
|
|
||||||
if ( ($_cd = realpath($curr_dir)) !== false &&
|
|
||||||
strncmp($_rp, $_cd, strlen($_cd)) == 0 &&
|
|
||||||
substr($_rp, strlen($_cd), 1) == DIRECTORY_SEPARATOR ) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!empty($smarty->secure_dir)) {
|
|
||||||
foreach ((array)$smarty->secure_dir as $curr_dir) {
|
|
||||||
if ( ($_cd = realpath($curr_dir)) !== false) {
|
|
||||||
if($_cd == $_rp) {
|
|
||||||
return true;
|
|
||||||
} elseif (strncmp($_rp, $_cd, strlen($_cd)) == 0 &&
|
|
||||||
substr($_rp, strlen($_cd), 1) == DIRECTORY_SEPARATOR) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// resource is not on local file system
|
|
||||||
return call_user_func_array(
|
|
||||||
$smarty->_plugins['resource'][$params['resource_type']][0][2],
|
|
||||||
array($params['resource_name'], &$smarty));
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* vim: set expandtab: */
|
|
||||||
|
|
||||||
?>
|
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Smarty plugin
|
|
||||||
* @package Smarty
|
|
||||||
* @subpackage plugins
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* determines if a resource is trusted or not
|
|
||||||
*
|
|
||||||
* @param string $resource_type
|
|
||||||
* @param string $resource_name
|
|
||||||
* @return boolean
|
|
||||||
*/
|
|
||||||
|
|
||||||
// $resource_type, $resource_name
|
|
||||||
|
|
||||||
function smarty_core_is_trusted($params, &$smarty)
|
|
||||||
{
|
|
||||||
$_smarty_trusted = false;
|
|
||||||
if ($params['resource_type'] == 'file') {
|
|
||||||
if (!empty($smarty->trusted_dir)) {
|
|
||||||
$_rp = realpath($params['resource_name']);
|
|
||||||
foreach ((array)$smarty->trusted_dir as $curr_dir) {
|
|
||||||
if (!empty($curr_dir) && is_readable ($curr_dir)) {
|
|
||||||
$_cd = realpath($curr_dir);
|
|
||||||
if (strncmp($_rp, $_cd, strlen($_cd)) == 0
|
|
||||||
&& substr($_rp, strlen($_cd), 1) == DIRECTORY_SEPARATOR ) {
|
|
||||||
$_smarty_trusted = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
// resource is not on local file system
|
|
||||||
$_smarty_trusted = call_user_func_array($smarty->_plugins['resource'][$params['resource_type']][0][3],
|
|
||||||
array($params['resource_name'], $smarty));
|
|
||||||
}
|
|
||||||
|
|
||||||
return $_smarty_trusted;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* vim: set expandtab: */
|
|
||||||
|
|
||||||
?>
|
|
||||||
@@ -1,125 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Smarty plugin
|
|
||||||
* @package Smarty
|
|
||||||
* @subpackage plugins
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Load requested plugins
|
|
||||||
*
|
|
||||||
* @param array $plugins
|
|
||||||
*/
|
|
||||||
|
|
||||||
// $plugins
|
|
||||||
|
|
||||||
function smarty_core_load_plugins($params, &$smarty)
|
|
||||||
{
|
|
||||||
|
|
||||||
foreach ($params['plugins'] as $_plugin_info) {
|
|
||||||
list($_type, $_name, $_tpl_file, $_tpl_line, $_delayed_loading) = $_plugin_info;
|
|
||||||
$_plugin = &$smarty->_plugins[$_type][$_name];
|
|
||||||
|
|
||||||
/*
|
|
||||||
* We do not load plugin more than once for each instance of Smarty.
|
|
||||||
* The following code checks for that. The plugin can also be
|
|
||||||
* registered dynamically at runtime, in which case template file
|
|
||||||
* and line number will be unknown, so we fill them in.
|
|
||||||
*
|
|
||||||
* The final element of the info array is a flag that indicates
|
|
||||||
* whether the dynamically registered plugin function has been
|
|
||||||
* checked for existence yet or not.
|
|
||||||
*/
|
|
||||||
if (isset($_plugin)) {
|
|
||||||
if (empty($_plugin[3])) {
|
|
||||||
if (!is_callable($_plugin[0])) {
|
|
||||||
$smarty->_trigger_fatal_error("[plugin] $_type '$_name' is not implemented", $_tpl_file, $_tpl_line, __FILE__, __LINE__);
|
|
||||||
} else {
|
|
||||||
$_plugin[1] = $_tpl_file;
|
|
||||||
$_plugin[2] = $_tpl_line;
|
|
||||||
$_plugin[3] = true;
|
|
||||||
if (!isset($_plugin[4])) $_plugin[4] = true; /* cacheable */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
} else if ($_type == 'insert') {
|
|
||||||
/*
|
|
||||||
* For backwards compatibility, we check for insert functions in
|
|
||||||
* the symbol table before trying to load them as a plugin.
|
|
||||||
*/
|
|
||||||
$_plugin_func = 'insert_' . $_name;
|
|
||||||
if (function_exists($_plugin_func)) {
|
|
||||||
$_plugin = array($_plugin_func, $_tpl_file, $_tpl_line, true, false);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$_plugin_file = $smarty->_get_plugin_filepath($_type, $_name);
|
|
||||||
|
|
||||||
if (! $_found = ($_plugin_file != false)) {
|
|
||||||
$_message = "could not load plugin file '$_type.$_name.php'\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If plugin file is found, it -must- provide the properly named
|
|
||||||
* plugin function. In case it doesn't, simply output the error and
|
|
||||||
* do not fall back on any other method.
|
|
||||||
*/
|
|
||||||
if ($_found) {
|
|
||||||
include_once $_plugin_file;
|
|
||||||
|
|
||||||
$_plugin_func = 'smarty_' . $_type . '_' . $_name;
|
|
||||||
if (!function_exists($_plugin_func)) {
|
|
||||||
$smarty->_trigger_fatal_error("[plugin] function $_plugin_func() not found in $_plugin_file", $_tpl_file, $_tpl_line, __FILE__, __LINE__);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
* In case of insert plugins, their code may be loaded later via
|
|
||||||
* 'script' attribute.
|
|
||||||
*/
|
|
||||||
else if ($_type == 'insert' && $_delayed_loading) {
|
|
||||||
$_plugin_func = 'smarty_' . $_type . '_' . $_name;
|
|
||||||
$_found = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Plugin specific processing and error checking.
|
|
||||||
*/
|
|
||||||
if (!$_found) {
|
|
||||||
if ($_type == 'modifier') {
|
|
||||||
/*
|
|
||||||
* In case modifier falls back on using PHP functions
|
|
||||||
* directly, we only allow those specified in the security
|
|
||||||
* context.
|
|
||||||
*/
|
|
||||||
if ($smarty->security && !in_array($_name, $smarty->security_settings['MODIFIER_FUNCS'])) {
|
|
||||||
$_message = "(secure mode) modifier '$_name' is not allowed";
|
|
||||||
} else {
|
|
||||||
if (!function_exists($_name)) {
|
|
||||||
$_message = "modifier '$_name' is not implemented";
|
|
||||||
} else {
|
|
||||||
$_plugin_func = $_name;
|
|
||||||
$_found = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if ($_type == 'function') {
|
|
||||||
/*
|
|
||||||
* This is a catch-all situation.
|
|
||||||
*/
|
|
||||||
$_message = "unknown tag - '$_name'";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($_found) {
|
|
||||||
$smarty->_plugins[$_type][$_name] = array($_plugin_func, $_tpl_file, $_tpl_line, true, true);
|
|
||||||
} else {
|
|
||||||
// output error
|
|
||||||
$smarty->_trigger_fatal_error('[plugin] ' . $_message, $_tpl_file, $_tpl_line, __FILE__, __LINE__);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* vim: set expandtab: */
|
|
||||||
|
|
||||||
?>
|
|
||||||
@@ -1,74 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Smarty plugin
|
|
||||||
* @package Smarty
|
|
||||||
* @subpackage plugins
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* load a resource plugin
|
|
||||||
*
|
|
||||||
* @param string $type
|
|
||||||
*/
|
|
||||||
|
|
||||||
// $type
|
|
||||||
|
|
||||||
function smarty_core_load_resource_plugin($params, &$smarty)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* Resource plugins are not quite like the other ones, so they are
|
|
||||||
* handled differently. The first element of plugin info is the array of
|
|
||||||
* functions provided by the plugin, the second one indicates whether
|
|
||||||
* all of them exist or not.
|
|
||||||
*/
|
|
||||||
|
|
||||||
$_plugin = &$smarty->_plugins['resource'][$params['type']];
|
|
||||||
if (isset($_plugin)) {
|
|
||||||
if (!$_plugin[1] && count($_plugin[0])) {
|
|
||||||
$_plugin[1] = true;
|
|
||||||
foreach ($_plugin[0] as $_plugin_func) {
|
|
||||||
if (!is_callable($_plugin_func)) {
|
|
||||||
$_plugin[1] = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$_plugin[1]) {
|
|
||||||
$smarty->_trigger_fatal_error("[plugin] resource '" . $params['type'] . "' is not implemented", null, null, __FILE__, __LINE__);
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$_plugin_file = $smarty->_get_plugin_filepath('resource', $params['type']);
|
|
||||||
$_found = ($_plugin_file != false);
|
|
||||||
|
|
||||||
if ($_found) { /*
|
|
||||||
* If the plugin file is found, it -must- provide the properly named
|
|
||||||
* plugin functions.
|
|
||||||
*/
|
|
||||||
include_once($_plugin_file);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Locate functions that we require the plugin to provide.
|
|
||||||
*/
|
|
||||||
$_resource_ops = array('source', 'timestamp', 'secure', 'trusted');
|
|
||||||
$_resource_funcs = array();
|
|
||||||
foreach ($_resource_ops as $_op) {
|
|
||||||
$_plugin_func = 'smarty_resource_' . $params['type'] . '_' . $_op;
|
|
||||||
if (!function_exists($_plugin_func)) {
|
|
||||||
$smarty->_trigger_fatal_error("[plugin] function $_plugin_func() not found in $_plugin_file", null, null, __FILE__, __LINE__);
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
$_resource_funcs[] = $_plugin_func;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$smarty->_plugins['resource'][$params['type']] = array($_resource_funcs, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* vim: set expandtab: */
|
|
||||||
|
|
||||||
?>
|
|
||||||
@@ -1,71 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Smarty plugin
|
|
||||||
* @package Smarty
|
|
||||||
* @subpackage plugins
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Replace cached inserts with the actual results
|
|
||||||
*
|
|
||||||
* @param string $results
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
function smarty_core_process_cached_inserts($params, &$smarty)
|
|
||||||
{
|
|
||||||
preg_match_all('!'.$smarty->_smarty_md5.'{insert_cache (.*)}'.$smarty->_smarty_md5.'!Uis',
|
|
||||||
$params['results'], $match);
|
|
||||||
list($cached_inserts, $insert_args) = $match;
|
|
||||||
|
|
||||||
for ($i = 0, $for_max = count($cached_inserts); $i < $for_max; $i++) {
|
|
||||||
if ($smarty->debugging) {
|
|
||||||
$_params = array();
|
|
||||||
require_once(SMARTY_CORE_DIR . 'core.get_microtime.php');
|
|
||||||
$debug_start_time = smarty_core_get_microtime($_params, $smarty);
|
|
||||||
}
|
|
||||||
|
|
||||||
$args = unserialize($insert_args[$i]);
|
|
||||||
$name = $args['name'];
|
|
||||||
|
|
||||||
if (isset($args['script'])) {
|
|
||||||
$_params = array('resource_name' => $smarty->_dequote($args['script']));
|
|
||||||
require_once(SMARTY_CORE_DIR . 'core.get_php_resource.php');
|
|
||||||
if(!smarty_core_get_php_resource($_params, $smarty)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
$resource_type = $_params['resource_type'];
|
|
||||||
$php_resource = $_params['php_resource'];
|
|
||||||
|
|
||||||
|
|
||||||
if ($resource_type == 'file') {
|
|
||||||
$smarty->_include($php_resource, true);
|
|
||||||
} else {
|
|
||||||
$smarty->_eval($php_resource);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$function_name = $smarty->_plugins['insert'][$name][0];
|
|
||||||
if (empty($args['assign'])) {
|
|
||||||
$replace = $function_name($args, $smarty);
|
|
||||||
} else {
|
|
||||||
$smarty->assign($args['assign'], $function_name($args, $smarty));
|
|
||||||
$replace = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
$params['results'] = substr_replace($params['results'], $replace, strpos($params['results'], $cached_inserts[$i]), strlen($cached_inserts[$i]));
|
|
||||||
if ($smarty->debugging) {
|
|
||||||
$_params = array();
|
|
||||||
require_once(SMARTY_CORE_DIR . 'core.get_microtime.php');
|
|
||||||
$smarty->_smarty_debug_info[] = array('type' => 'insert',
|
|
||||||
'filename' => 'insert_'.$name,
|
|
||||||
'depth' => $smarty->_inclusion_depth,
|
|
||||||
'exec_time' => smarty_core_get_microtime($_params, $smarty) - $debug_start_time);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $params['results'];
|
|
||||||
}
|
|
||||||
|
|
||||||
/* vim: set expandtab: */
|
|
||||||
|
|
||||||
?>
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Smarty plugin
|
|
||||||
* @package Smarty
|
|
||||||
* @subpackage plugins
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Replace nocache-tags by results of the corresponding non-cacheable
|
|
||||||
* functions and return it
|
|
||||||
*
|
|
||||||
* @param string $compiled_tpl
|
|
||||||
* @param string $cached_source
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
|
|
||||||
function smarty_core_process_compiled_include($params, &$smarty)
|
|
||||||
{
|
|
||||||
$_cache_including = $smarty->_cache_including;
|
|
||||||
$smarty->_cache_including = true;
|
|
||||||
|
|
||||||
$_return = $params['results'];
|
|
||||||
|
|
||||||
foreach ($smarty->_cache_info['cache_serials'] as $_include_file_path=>$_cache_serial) {
|
|
||||||
$smarty->_include($_include_file_path, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($smarty->_cache_serials as $_include_file_path=>$_cache_serial) {
|
|
||||||
$_return = preg_replace_callback('!(\{nocache\:('.$_cache_serial.')#(\d+)\})!s',
|
|
||||||
array(&$smarty, '_process_compiled_include_callback'),
|
|
||||||
$_return);
|
|
||||||
}
|
|
||||||
$smarty->_cache_including = $_cache_including;
|
|
||||||
return $_return;
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
||||||
@@ -1,101 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Smarty plugin
|
|
||||||
* @package Smarty
|
|
||||||
* @subpackage plugins
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* read a cache file, determine if it needs to be
|
|
||||||
* regenerated or not
|
|
||||||
*
|
|
||||||
* @param string $tpl_file
|
|
||||||
* @param string $cache_id
|
|
||||||
* @param string $compile_id
|
|
||||||
* @param string $results
|
|
||||||
* @return boolean
|
|
||||||
*/
|
|
||||||
|
|
||||||
// $tpl_file, $cache_id, $compile_id, &$results
|
|
||||||
|
|
||||||
function smarty_core_read_cache_file(&$params, &$smarty)
|
|
||||||
{
|
|
||||||
static $content_cache = array();
|
|
||||||
|
|
||||||
if ($smarty->force_compile) {
|
|
||||||
// force compile enabled, always regenerate
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($content_cache[$params['tpl_file'].','.$params['cache_id'].','.$params['compile_id']])) {
|
|
||||||
list($params['results'], $smarty->_cache_info) = $content_cache[$params['tpl_file'].','.$params['cache_id'].','.$params['compile_id']];
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($smarty->cache_handler_func)) {
|
|
||||||
// use cache_handler function
|
|
||||||
call_user_func_array($smarty->cache_handler_func,
|
|
||||||
array('read', &$smarty, &$params['results'], $params['tpl_file'], $params['cache_id'], $params['compile_id'], null));
|
|
||||||
} else {
|
|
||||||
// use local cache file
|
|
||||||
$_auto_id = $smarty->_get_auto_id($params['cache_id'], $params['compile_id']);
|
|
||||||
$_cache_file = $smarty->_get_auto_filename($smarty->cache_dir, $params['tpl_file'], $_auto_id);
|
|
||||||
$params['results'] = $smarty->_read_file($_cache_file);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty($params['results'])) {
|
|
||||||
// nothing to parse (error?), regenerate cache
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$_contents = $params['results'];
|
|
||||||
$_info_start = strpos($_contents, "\n") + 1;
|
|
||||||
$_info_len = (int)substr($_contents, 0, $_info_start - 1);
|
|
||||||
$_cache_info = unserialize(substr($_contents, $_info_start, $_info_len));
|
|
||||||
$params['results'] = substr($_contents, $_info_start + $_info_len);
|
|
||||||
|
|
||||||
if ($smarty->caching == 2 && isset ($_cache_info['expires'])){
|
|
||||||
// caching by expiration time
|
|
||||||
if ($_cache_info['expires'] > -1 && (time() > $_cache_info['expires'])) {
|
|
||||||
// cache expired, regenerate
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// caching by lifetime
|
|
||||||
if ($smarty->cache_lifetime > -1 && (time() - $_cache_info['timestamp'] > $smarty->cache_lifetime)) {
|
|
||||||
// cache expired, regenerate
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($smarty->compile_check) {
|
|
||||||
$_params = array('get_source' => false, 'quiet'=>true);
|
|
||||||
foreach (array_keys($_cache_info['template']) as $_template_dep) {
|
|
||||||
$_params['resource_name'] = $_template_dep;
|
|
||||||
if (!$smarty->_fetch_resource_info($_params) || $_cache_info['timestamp'] < $_params['resource_timestamp']) {
|
|
||||||
// template file has changed, regenerate cache
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($_cache_info['config'])) {
|
|
||||||
$_params = array('resource_base_path' => $smarty->config_dir, 'get_source' => false, 'quiet'=>true);
|
|
||||||
foreach (array_keys($_cache_info['config']) as $_config_dep) {
|
|
||||||
$_params['resource_name'] = $_config_dep;
|
|
||||||
if (!$smarty->_fetch_resource_info($_params) || $_cache_info['timestamp'] < $_params['resource_timestamp']) {
|
|
||||||
// config file has changed, regenerate cache
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$content_cache[$params['tpl_file'].','.$params['cache_id'].','.$params['compile_id']] = array($params['results'], $_cache_info);
|
|
||||||
|
|
||||||
$smarty->_cache_info = $_cache_info;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* vim: set expandtab: */
|
|
||||||
|
|
||||||
?>
|
|
||||||
@@ -1,71 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Smarty plugin
|
|
||||||
* @package Smarty
|
|
||||||
* @subpackage plugins
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* delete an automagically created file by name and id
|
|
||||||
*
|
|
||||||
* @param string $auto_base
|
|
||||||
* @param string $auto_source
|
|
||||||
* @param string $auto_id
|
|
||||||
* @param integer $exp_time
|
|
||||||
* @return boolean
|
|
||||||
*/
|
|
||||||
|
|
||||||
// $auto_base, $auto_source = null, $auto_id = null, $exp_time = null
|
|
||||||
|
|
||||||
function smarty_core_rm_auto($params, &$smarty)
|
|
||||||
{
|
|
||||||
if (!@is_dir($params['auto_base']))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if(!isset($params['auto_id']) && !isset($params['auto_source'])) {
|
|
||||||
$_params = array(
|
|
||||||
'dirname' => $params['auto_base'],
|
|
||||||
'level' => 0,
|
|
||||||
'exp_time' => $params['exp_time']
|
|
||||||
);
|
|
||||||
require_once(SMARTY_CORE_DIR . 'core.rmdir.php');
|
|
||||||
$_res = smarty_core_rmdir($_params, $smarty);
|
|
||||||
} else {
|
|
||||||
$_tname = $smarty->_get_auto_filename($params['auto_base'], $params['auto_source'], $params['auto_id']);
|
|
||||||
|
|
||||||
if(isset($params['auto_source'])) {
|
|
||||||
if (isset($params['extensions'])) {
|
|
||||||
$_res = false;
|
|
||||||
foreach ((array)$params['extensions'] as $_extension)
|
|
||||||
$_res |= $smarty->_unlink($_tname.$_extension, $params['exp_time']);
|
|
||||||
} else {
|
|
||||||
$_res = $smarty->_unlink($_tname, $params['exp_time']);
|
|
||||||
}
|
|
||||||
} elseif ($smarty->use_sub_dirs) {
|
|
||||||
$_params = array(
|
|
||||||
'dirname' => $_tname,
|
|
||||||
'level' => 1,
|
|
||||||
'exp_time' => $params['exp_time']
|
|
||||||
);
|
|
||||||
require_once(SMARTY_CORE_DIR . 'core.rmdir.php');
|
|
||||||
$_res = smarty_core_rmdir($_params, $smarty);
|
|
||||||
} else {
|
|
||||||
// remove matching file names
|
|
||||||
$_handle = opendir($params['auto_base']);
|
|
||||||
$_res = true;
|
|
||||||
while (false !== ($_filename = readdir($_handle))) {
|
|
||||||
if($_filename == '.' || $_filename == '..') {
|
|
||||||
continue;
|
|
||||||
} elseif (substr($params['auto_base'] . DIRECTORY_SEPARATOR . $_filename, 0, strlen($_tname)) == $_tname) {
|
|
||||||
$_res &= (bool)$smarty->_unlink($params['auto_base'] . DIRECTORY_SEPARATOR . $_filename, $params['exp_time']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $_res;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* vim: set expandtab: */
|
|
||||||
|
|
||||||
?>
|
|
||||||
54
thirdparty/smarty/libs/internals/core.rmdir.php
vendored
54
thirdparty/smarty/libs/internals/core.rmdir.php
vendored
@@ -1,54 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Smarty plugin
|
|
||||||
* @package Smarty
|
|
||||||
* @subpackage plugins
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* delete a dir recursively (level=0 -> keep root)
|
|
||||||
* WARNING: no tests, it will try to remove what you tell it!
|
|
||||||
*
|
|
||||||
* @param string $dirname
|
|
||||||
* @param integer $level
|
|
||||||
* @param integer $exp_time
|
|
||||||
* @return boolean
|
|
||||||
*/
|
|
||||||
|
|
||||||
// $dirname, $level = 1, $exp_time = null
|
|
||||||
|
|
||||||
function smarty_core_rmdir($params, &$smarty)
|
|
||||||
{
|
|
||||||
if(!isset($params['level'])) { $params['level'] = 1; }
|
|
||||||
if(!isset($params['exp_time'])) { $params['exp_time'] = null; }
|
|
||||||
|
|
||||||
if($_handle = @opendir($params['dirname'])) {
|
|
||||||
|
|
||||||
while (false !== ($_entry = readdir($_handle))) {
|
|
||||||
if ($_entry != '.' && $_entry != '..') {
|
|
||||||
if (@is_dir($params['dirname'] . DIRECTORY_SEPARATOR . $_entry)) {
|
|
||||||
$_params = array(
|
|
||||||
'dirname' => $params['dirname'] . DIRECTORY_SEPARATOR . $_entry,
|
|
||||||
'level' => $params['level'] + 1,
|
|
||||||
'exp_time' => $params['exp_time']
|
|
||||||
);
|
|
||||||
smarty_core_rmdir($_params, $smarty);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$smarty->_unlink($params['dirname'] . DIRECTORY_SEPARATOR . $_entry, $params['exp_time']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
closedir($_handle);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($params['level']) {
|
|
||||||
return @rmdir($params['dirname']);
|
|
||||||
}
|
|
||||||
return (bool)$_handle;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* vim: set expandtab: */
|
|
||||||
|
|
||||||
?>
|
|
||||||
@@ -1,71 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Smarty plugin
|
|
||||||
* @package Smarty
|
|
||||||
* @subpackage plugins
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handle insert tags
|
|
||||||
*
|
|
||||||
* @param array $args
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
function smarty_core_run_insert_handler($params, &$smarty)
|
|
||||||
{
|
|
||||||
|
|
||||||
require_once(SMARTY_CORE_DIR . 'core.get_microtime.php');
|
|
||||||
if ($smarty->debugging) {
|
|
||||||
$_params = array();
|
|
||||||
$_debug_start_time = smarty_core_get_microtime($_params, $smarty);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($smarty->caching) {
|
|
||||||
$_arg_string = serialize($params['args']);
|
|
||||||
$_name = $params['args']['name'];
|
|
||||||
if (!isset($smarty->_cache_info['insert_tags'][$_name])) {
|
|
||||||
$smarty->_cache_info['insert_tags'][$_name] = array('insert',
|
|
||||||
$_name,
|
|
||||||
$smarty->_plugins['insert'][$_name][1],
|
|
||||||
$smarty->_plugins['insert'][$_name][2],
|
|
||||||
!empty($params['args']['script']) ? true : false);
|
|
||||||
}
|
|
||||||
return $smarty->_smarty_md5."{insert_cache $_arg_string}".$smarty->_smarty_md5;
|
|
||||||
} else {
|
|
||||||
if (isset($params['args']['script'])) {
|
|
||||||
$_params = array('resource_name' => $smarty->_dequote($params['args']['script']));
|
|
||||||
require_once(SMARTY_CORE_DIR . 'core.get_php_resource.php');
|
|
||||||
if(!smarty_core_get_php_resource($_params, $smarty)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($_params['resource_type'] == 'file') {
|
|
||||||
$smarty->_include($_params['php_resource'], true);
|
|
||||||
} else {
|
|
||||||
$smarty->_eval($_params['php_resource']);
|
|
||||||
}
|
|
||||||
unset($params['args']['script']);
|
|
||||||
}
|
|
||||||
|
|
||||||
$_funcname = $smarty->_plugins['insert'][$params['args']['name']][0];
|
|
||||||
$_content = $_funcname($params['args'], $smarty);
|
|
||||||
if ($smarty->debugging) {
|
|
||||||
$_params = array();
|
|
||||||
require_once(SMARTY_CORE_DIR . 'core.get_microtime.php');
|
|
||||||
$smarty->_smarty_debug_info[] = array('type' => 'insert',
|
|
||||||
'filename' => 'insert_'.$params['args']['name'],
|
|
||||||
'depth' => $smarty->_inclusion_depth,
|
|
||||||
'exec_time' => smarty_core_get_microtime($_params, $smarty) - $_debug_start_time);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($params['args']["assign"])) {
|
|
||||||
$smarty->assign($params['args']["assign"], $_content);
|
|
||||||
} else {
|
|
||||||
return $_content;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* vim: set expandtab: */
|
|
||||||
|
|
||||||
?>
|
|
||||||
@@ -1,50 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Smarty plugin
|
|
||||||
* @package Smarty
|
|
||||||
* @subpackage plugins
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* called for included php files within templates
|
|
||||||
*
|
|
||||||
* @param string $smarty_file
|
|
||||||
* @param string $smarty_assign variable to assign the included template's
|
|
||||||
* output into
|
|
||||||
* @param boolean $smarty_once uses include_once if this is true
|
|
||||||
* @param array $smarty_include_vars associative array of vars from
|
|
||||||
* {include file="blah" var=$var}
|
|
||||||
*/
|
|
||||||
|
|
||||||
// $file, $assign, $once, $_smarty_include_vars
|
|
||||||
|
|
||||||
function smarty_core_smarty_include_php($params, &$smarty)
|
|
||||||
{
|
|
||||||
$_params = array('resource_name' => $params['smarty_file']);
|
|
||||||
require_once(SMARTY_CORE_DIR . 'core.get_php_resource.php');
|
|
||||||
smarty_core_get_php_resource($_params, $smarty);
|
|
||||||
$_smarty_resource_type = $_params['resource_type'];
|
|
||||||
$_smarty_php_resource = $_params['php_resource'];
|
|
||||||
|
|
||||||
if (!empty($params['smarty_assign'])) {
|
|
||||||
ob_start();
|
|
||||||
if ($_smarty_resource_type == 'file') {
|
|
||||||
$smarty->_include($_smarty_php_resource, $params['smarty_once'], $params['smarty_include_vars']);
|
|
||||||
} else {
|
|
||||||
$smarty->_eval($_smarty_php_resource, $params['smarty_include_vars']);
|
|
||||||
}
|
|
||||||
$smarty->assign($params['smarty_assign'], ob_get_contents());
|
|
||||||
ob_end_clean();
|
|
||||||
} else {
|
|
||||||
if ($_smarty_resource_type == 'file') {
|
|
||||||
$smarty->_include($_smarty_php_resource, $params['smarty_once'], $params['smarty_include_vars']);
|
|
||||||
} else {
|
|
||||||
$smarty->_eval($_smarty_php_resource, $params['smarty_include_vars']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* vim: set expandtab: */
|
|
||||||
|
|
||||||
?>
|
|
||||||
@@ -1,96 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Smarty plugin
|
|
||||||
* @package Smarty
|
|
||||||
* @subpackage plugins
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Prepend the cache information to the cache file
|
|
||||||
* and write it
|
|
||||||
*
|
|
||||||
* @param string $tpl_file
|
|
||||||
* @param string $cache_id
|
|
||||||
* @param string $compile_id
|
|
||||||
* @param string $results
|
|
||||||
* @return true|null
|
|
||||||
*/
|
|
||||||
|
|
||||||
// $tpl_file, $cache_id, $compile_id, $results
|
|
||||||
|
|
||||||
function smarty_core_write_cache_file($params, &$smarty)
|
|
||||||
{
|
|
||||||
|
|
||||||
// put timestamp in cache header
|
|
||||||
$smarty->_cache_info['timestamp'] = time();
|
|
||||||
if ($smarty->cache_lifetime > -1){
|
|
||||||
// expiration set
|
|
||||||
$smarty->_cache_info['expires'] = $smarty->_cache_info['timestamp'] + $smarty->cache_lifetime;
|
|
||||||
} else {
|
|
||||||
// cache will never expire
|
|
||||||
$smarty->_cache_info['expires'] = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// collapse nocache.../nocache-tags
|
|
||||||
if (preg_match_all('!\{(/?)nocache\:[0-9a-f]{32}#\d+\}!', $params['results'], $match, PREG_PATTERN_ORDER)) {
|
|
||||||
// remove everything between every pair of outermost noache.../nocache-tags
|
|
||||||
// and replace it by a single nocache-tag
|
|
||||||
// this new nocache-tag will be replaced by dynamic contents in
|
|
||||||
// smarty_core_process_compiled_includes() on a cache-read
|
|
||||||
|
|
||||||
$match_count = count($match[0]);
|
|
||||||
$results = preg_split('!(\{/?nocache\:[0-9a-f]{32}#\d+\})!', $params['results'], -1, PREG_SPLIT_DELIM_CAPTURE);
|
|
||||||
|
|
||||||
$level = 0;
|
|
||||||
$j = 0;
|
|
||||||
for ($i=0, $results_count = count($results); $i < $results_count && $j < $match_count; $i++) {
|
|
||||||
if ($results[$i] == $match[0][$j]) {
|
|
||||||
// nocache tag
|
|
||||||
if ($match[1][$j]) { // closing tag
|
|
||||||
$level--;
|
|
||||||
unset($results[$i]);
|
|
||||||
} else { // opening tag
|
|
||||||
if ($level++ > 0) unset($results[$i]);
|
|
||||||
}
|
|
||||||
$j++;
|
|
||||||
} elseif ($level > 0) {
|
|
||||||
unset($results[$i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$params['results'] = implode('', $results);
|
|
||||||
}
|
|
||||||
$smarty->_cache_info['cache_serials'] = $smarty->_cache_serials;
|
|
||||||
|
|
||||||
// prepend the cache header info into cache file
|
|
||||||
$_cache_info = serialize($smarty->_cache_info);
|
|
||||||
$params['results'] = strlen($_cache_info) . "\n" . $_cache_info . $params['results'];
|
|
||||||
|
|
||||||
if (!empty($smarty->cache_handler_func)) {
|
|
||||||
// use cache_handler function
|
|
||||||
call_user_func_array($smarty->cache_handler_func,
|
|
||||||
array('write', &$smarty, &$params['results'], $params['tpl_file'], $params['cache_id'], $params['compile_id'], null));
|
|
||||||
} else {
|
|
||||||
// use local cache file
|
|
||||||
|
|
||||||
if(!@is_writable($smarty->cache_dir)) {
|
|
||||||
// cache_dir not writable, see if it exists
|
|
||||||
if(!@is_dir($smarty->cache_dir)) {
|
|
||||||
$smarty->trigger_error('the $cache_dir \'' . $smarty->cache_dir . '\' does not exist, or is not a directory.', E_USER_ERROR);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
$smarty->trigger_error('unable to write to $cache_dir \'' . realpath($smarty->cache_dir) . '\'. Be sure $cache_dir is writable by the web server user.', E_USER_ERROR);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$_auto_id = $smarty->_get_auto_id($params['cache_id'], $params['compile_id']);
|
|
||||||
$_cache_file = $smarty->_get_auto_filename($smarty->cache_dir, $params['tpl_file'], $_auto_id);
|
|
||||||
$_params = array('filename' => $_cache_file, 'contents' => $params['results'], 'create_dirs' => true);
|
|
||||||
require_once(SMARTY_CORE_DIR . 'core.write_file.php');
|
|
||||||
smarty_core_write_file($_params, $smarty);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* vim: set expandtab: */
|
|
||||||
|
|
||||||
?>
|
|
||||||
@@ -1,91 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Smarty plugin
|
|
||||||
* @package Smarty
|
|
||||||
* @subpackage plugins
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Extract non-cacheable parts out of compiled template and write it
|
|
||||||
*
|
|
||||||
* @param string $compile_path
|
|
||||||
* @param string $template_compiled
|
|
||||||
* @return boolean
|
|
||||||
*/
|
|
||||||
|
|
||||||
function smarty_core_write_compiled_include($params, &$smarty)
|
|
||||||
{
|
|
||||||
$_tag_start = 'if \(\$this->caching && \!\$this->_cache_including\)\: echo \'\{nocache\:('.$params['cache_serial'].')#(\d+)\}\'; endif;';
|
|
||||||
$_tag_end = 'if \(\$this->caching && \!\$this->_cache_including\)\: echo \'\{/nocache\:(\\2)#(\\3)\}\'; endif;';
|
|
||||||
|
|
||||||
preg_match_all('!('.$_tag_start.'(.*)'.$_tag_end.')!Us',
|
|
||||||
$params['compiled_content'], $_match_source, PREG_SET_ORDER);
|
|
||||||
|
|
||||||
// no nocache-parts found: done
|
|
||||||
if (count($_match_source)==0) return;
|
|
||||||
|
|
||||||
// convert the matched php-code to functions
|
|
||||||
$_include_compiled = "<?php /* Smarty version ".$smarty->_version.", created on ".strftime("%Y-%m-%d %H:%M:%S")."\n";
|
|
||||||
$_include_compiled .= " compiled from " . strtr(urlencode($params['resource_name']), array('%2F'=>'/', '%3A'=>':')) . " */\n\n";
|
|
||||||
|
|
||||||
$_compile_path = $params['include_file_path'];
|
|
||||||
|
|
||||||
$smarty->_cache_serials[$_compile_path] = $params['cache_serial'];
|
|
||||||
$_include_compiled .= "\$this->_cache_serials['".$_compile_path."'] = '".$params['cache_serial']."';\n\n?>";
|
|
||||||
|
|
||||||
$_include_compiled .= $params['plugins_code'];
|
|
||||||
$_include_compiled .= "<?php";
|
|
||||||
|
|
||||||
$this_varname = ((double)phpversion() >= 5.0) ? '_smarty' : 'this';
|
|
||||||
for ($_i = 0, $_for_max = count($_match_source); $_i < $_for_max; $_i++) {
|
|
||||||
$_match =& $_match_source[$_i];
|
|
||||||
$source = $_match[4];
|
|
||||||
if ($this_varname == '_smarty') {
|
|
||||||
/* rename $this to $_smarty in the sourcecode */
|
|
||||||
$tokens = token_get_all('<?php ' . $_match[4]);
|
|
||||||
|
|
||||||
/* remove trailing <?php */
|
|
||||||
$open_tag = '';
|
|
||||||
while ($tokens) {
|
|
||||||
$token = array_shift($tokens);
|
|
||||||
if (is_array($token)) {
|
|
||||||
$open_tag .= $token[1];
|
|
||||||
} else {
|
|
||||||
$open_tag .= $token;
|
|
||||||
}
|
|
||||||
if ($open_tag == '<?php ') break;
|
|
||||||
}
|
|
||||||
|
|
||||||
for ($i=0, $count = count($tokens); $i < $count; $i++) {
|
|
||||||
if (is_array($tokens[$i])) {
|
|
||||||
if ($tokens[$i][0] == T_VARIABLE && $tokens[$i][1] == '$this') {
|
|
||||||
$tokens[$i] = '$' . $this_varname;
|
|
||||||
} else {
|
|
||||||
$tokens[$i] = $tokens[$i][1];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$source = implode('', $tokens);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* add function to compiled include */
|
|
||||||
$_include_compiled .= "
|
|
||||||
function _smarty_tplfunc_$_match[2]_$_match[3](&\$$this_varname)
|
|
||||||
{
|
|
||||||
$source
|
|
||||||
}
|
|
||||||
|
|
||||||
";
|
|
||||||
}
|
|
||||||
$_include_compiled .= "\n\n?>\n";
|
|
||||||
|
|
||||||
$_params = array('filename' => $_compile_path,
|
|
||||||
'contents' => $_include_compiled, 'create_dirs' => true);
|
|
||||||
|
|
||||||
require_once(SMARTY_CORE_DIR . 'core.write_file.php');
|
|
||||||
smarty_core_write_file($_params, $smarty);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
?>
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Smarty plugin
|
|
||||||
* @package Smarty
|
|
||||||
* @subpackage plugins
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* write the compiled resource
|
|
||||||
*
|
|
||||||
* @param string $compile_path
|
|
||||||
* @param string $compiled_content
|
|
||||||
* @return true
|
|
||||||
*/
|
|
||||||
function smarty_core_write_compiled_resource($params, &$smarty)
|
|
||||||
{
|
|
||||||
if(!@is_writable($smarty->compile_dir)) {
|
|
||||||
// compile_dir not writable, see if it exists
|
|
||||||
if(!@is_dir($smarty->compile_dir)) {
|
|
||||||
$smarty->trigger_error('the $compile_dir \'' . $smarty->compile_dir . '\' does not exist, or is not a directory.', E_USER_ERROR);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
$smarty->trigger_error('unable to write to $compile_dir \'' . realpath($smarty->compile_dir) . '\'. Be sure $compile_dir is writable by the web server user.', E_USER_ERROR);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$_params = array('filename' => $params['compile_path'], 'contents' => $params['compiled_content'], 'create_dirs' => true);
|
|
||||||
require_once(SMARTY_CORE_DIR . 'core.write_file.php');
|
|
||||||
smarty_core_write_file($_params, $smarty);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* vim: set expandtab: */
|
|
||||||
|
|
||||||
?>
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Smarty plugin
|
|
||||||
* @package Smarty
|
|
||||||
* @subpackage plugins
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* write out a file to disk
|
|
||||||
*
|
|
||||||
* @param string $filename
|
|
||||||
* @param string $contents
|
|
||||||
* @param boolean $create_dirs
|
|
||||||
* @return boolean
|
|
||||||
*/
|
|
||||||
function smarty_core_write_file($params, &$smarty)
|
|
||||||
{
|
|
||||||
$_dirname = dirname($params['filename']);
|
|
||||||
|
|
||||||
if ($params['create_dirs']) {
|
|
||||||
$_params = array('dir' => $_dirname);
|
|
||||||
require_once(SMARTY_CORE_DIR . 'core.create_dir_structure.php');
|
|
||||||
smarty_core_create_dir_structure($_params, $smarty);
|
|
||||||
}
|
|
||||||
|
|
||||||
// write to tmp file, then rename it to avoid file locking race condition
|
|
||||||
$_tmp_file = tempnam($_dirname, 'wrt');
|
|
||||||
|
|
||||||
if (!($fd = @fopen($_tmp_file, 'wb'))) {
|
|
||||||
$_tmp_file = $_dirname . DIRECTORY_SEPARATOR . uniqid('wrt');
|
|
||||||
if (!($fd = @fopen($_tmp_file, 'wb'))) {
|
|
||||||
$smarty->trigger_error("problem writing temporary file '$_tmp_file'");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fwrite($fd, $params['contents']);
|
|
||||||
fclose($fd);
|
|
||||||
|
|
||||||
if (DIRECTORY_SEPARATOR == '\\' || !@rename($_tmp_file, $params['filename'])) {
|
|
||||||
// On platforms and filesystems that cannot overwrite with rename()
|
|
||||||
// delete the file before renaming it -- because windows always suffers
|
|
||||||
// this, it is short-circuited to avoid the initial rename() attempt
|
|
||||||
@unlink($params['filename']);
|
|
||||||
@rename($_tmp_file, $params['filename']);
|
|
||||||
}
|
|
||||||
@chmod($params['filename'], $smarty->_file_perms);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* vim: set expandtab: */
|
|
||||||
|
|
||||||
?>
|
|
||||||
103
thirdparty/smarty/libs/plugins/block.textformat.php
vendored
103
thirdparty/smarty/libs/plugins/block.textformat.php
vendored
@@ -1,103 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Smarty plugin
|
|
||||||
* @package Smarty
|
|
||||||
* @subpackage plugins
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Smarty {textformat}{/textformat} block plugin
|
|
||||||
*
|
|
||||||
* Type: block function<br>
|
|
||||||
* Name: textformat<br>
|
|
||||||
* Purpose: format text a certain way with preset styles
|
|
||||||
* or custom wrap/indent settings<br>
|
|
||||||
* @link http://smarty.php.net/manual/en/language.function.textformat.php {textformat}
|
|
||||||
* (Smarty online manual)
|
|
||||||
* @param array
|
|
||||||
* <pre>
|
|
||||||
* Params: style: string (email)
|
|
||||||
* indent: integer (0)
|
|
||||||
* wrap: integer (80)
|
|
||||||
* wrap_char string ("\n")
|
|
||||||
* indent_char: string (" ")
|
|
||||||
* wrap_boundary: boolean (true)
|
|
||||||
* </pre>
|
|
||||||
* @author Monte Ohrt <monte at ohrt dot com>
|
|
||||||
* @param string contents of the block
|
|
||||||
* @param Smarty clever simulation of a method
|
|
||||||
* @return string string $content re-formatted
|
|
||||||
*/
|
|
||||||
function smarty_block_textformat($params, $content, &$smarty)
|
|
||||||
{
|
|
||||||
if (is_null($content)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$style = null;
|
|
||||||
$indent = 0;
|
|
||||||
$indent_first = 0;
|
|
||||||
$indent_char = ' ';
|
|
||||||
$wrap = 80;
|
|
||||||
$wrap_char = "\n";
|
|
||||||
$wrap_cut = false;
|
|
||||||
$assign = null;
|
|
||||||
|
|
||||||
foreach ($params as $_key => $_val) {
|
|
||||||
switch ($_key) {
|
|
||||||
case 'style':
|
|
||||||
case 'indent_char':
|
|
||||||
case 'wrap_char':
|
|
||||||
case 'assign':
|
|
||||||
$$_key = (string)$_val;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'indent':
|
|
||||||
case 'indent_first':
|
|
||||||
case 'wrap':
|
|
||||||
$$_key = (int)$_val;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'wrap_cut':
|
|
||||||
$$_key = (bool)$_val;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
$smarty->trigger_error("textformat: unknown attribute '$_key'");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($style == 'email') {
|
|
||||||
$wrap = 72;
|
|
||||||
}
|
|
||||||
|
|
||||||
// split into paragraphs
|
|
||||||
$_paragraphs = preg_split('![\r\n][\r\n]!',$content);
|
|
||||||
$_output = '';
|
|
||||||
|
|
||||||
for($_x = 0, $_y = count($_paragraphs); $_x < $_y; $_x++) {
|
|
||||||
if ($_paragraphs[$_x] == '') {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
// convert mult. spaces & special chars to single space
|
|
||||||
$_paragraphs[$_x] = preg_replace(array('!\s+!','!(^\s+)|(\s+$)!'), array(' ',''), $_paragraphs[$_x]);
|
|
||||||
// indent first line
|
|
||||||
if($indent_first > 0) {
|
|
||||||
$_paragraphs[$_x] = str_repeat($indent_char, $indent_first) . $_paragraphs[$_x];
|
|
||||||
}
|
|
||||||
// wordwrap sentences
|
|
||||||
$_paragraphs[$_x] = wordwrap($_paragraphs[$_x], $wrap - $indent, $wrap_char, $wrap_cut);
|
|
||||||
// indent lines
|
|
||||||
if($indent > 0) {
|
|
||||||
$_paragraphs[$_x] = preg_replace('!^!m', str_repeat($indent_char, $indent), $_paragraphs[$_x]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$_output = implode($wrap_char . $wrap_char, $_paragraphs);
|
|
||||||
|
|
||||||
return $assign ? $smarty->assign($assign, $_output) : $_output;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* vim: set expandtab: */
|
|
||||||
|
|
||||||
?>
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Smarty plugin
|
|
||||||
* @package Smarty
|
|
||||||
* @subpackage plugins
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Smarty {assign} compiler function plugin
|
|
||||||
*
|
|
||||||
* Type: compiler function<br>
|
|
||||||
* Name: assign<br>
|
|
||||||
* Purpose: assign a value to a template variable
|
|
||||||
* @link http://smarty.php.net/manual/en/language.custom.functions.php#LANGUAGE.FUNCTION.ASSIGN {assign}
|
|
||||||
* (Smarty online manual)
|
|
||||||
* @author Monte Ohrt <monte at ohrt dot com> (initial author)
|
|
||||||
* @auther messju mohr <messju at lammfellpuschen dot de> (conversion to compiler function)
|
|
||||||
* @param string containing var-attribute and value-attribute
|
|
||||||
* @param Smarty_Compiler
|
|
||||||
*/
|
|
||||||
function smarty_compiler_assign($tag_attrs, &$compiler)
|
|
||||||
{
|
|
||||||
$_params = $compiler->_parse_attrs($tag_attrs);
|
|
||||||
|
|
||||||
if (!isset($_params['var'])) {
|
|
||||||
$compiler->_syntax_error("assign: missing 'var' parameter", E_USER_WARNING);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isset($_params['value'])) {
|
|
||||||
$compiler->_syntax_error("assign: missing 'value' parameter", E_USER_WARNING);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
return "\$this->assign({$_params['var']}, {$_params['value']});";
|
|
||||||
}
|
|
||||||
|
|
||||||
/* vim: set expandtab: */
|
|
||||||
|
|
||||||
?>
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Smarty plugin
|
|
||||||
* @package Smarty
|
|
||||||
* @subpackage plugins
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Smarty {assign_debug_info} function plugin
|
|
||||||
*
|
|
||||||
* Type: function<br>
|
|
||||||
* Name: assign_debug_info<br>
|
|
||||||
* Purpose: assign debug info to the template<br>
|
|
||||||
* @author Monte Ohrt <monte at ohrt dot com>
|
|
||||||
* @param array unused in this plugin, this plugin uses {@link Smarty::$_config},
|
|
||||||
* {@link Smarty::$_tpl_vars} and {@link Smarty::$_smarty_debug_info}
|
|
||||||
* @param Smarty
|
|
||||||
*/
|
|
||||||
function smarty_function_assign_debug_info($params, &$smarty)
|
|
||||||
{
|
|
||||||
$assigned_vars = $smarty->_tpl_vars;
|
|
||||||
ksort($assigned_vars);
|
|
||||||
if (@is_array($smarty->_config[0])) {
|
|
||||||
$config_vars = $smarty->_config[0];
|
|
||||||
ksort($config_vars);
|
|
||||||
$smarty->assign("_debug_config_keys", array_keys($config_vars));
|
|
||||||
$smarty->assign("_debug_config_vals", array_values($config_vars));
|
|
||||||
}
|
|
||||||
|
|
||||||
$included_templates = $smarty->_smarty_debug_info;
|
|
||||||
|
|
||||||
$smarty->assign("_debug_keys", array_keys($assigned_vars));
|
|
||||||
$smarty->assign("_debug_vals", array_values($assigned_vars));
|
|
||||||
|
|
||||||
$smarty->assign("_debug_tpls", $included_templates);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* vim: set expandtab: */
|
|
||||||
|
|
||||||
?>
|
|
||||||
@@ -1,142 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Smarty plugin
|
|
||||||
* @package Smarty
|
|
||||||
* @subpackage plugins
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Smarty {config_load} function plugin
|
|
||||||
*
|
|
||||||
* Type: function<br>
|
|
||||||
* Name: config_load<br>
|
|
||||||
* Purpose: load config file vars
|
|
||||||
* @link http://smarty.php.net/manual/en/language.function.config.load.php {config_load}
|
|
||||||
* (Smarty online manual)
|
|
||||||
* @author Monte Ohrt <monte at ohrt dot com>
|
|
||||||
* @author messju mohr <messju at lammfellpuschen dot de> (added use of resources)
|
|
||||||
* @param array Format:
|
|
||||||
* <pre>
|
|
||||||
* array('file' => required config file name,
|
|
||||||
* 'section' => optional config file section to load
|
|
||||||
* 'scope' => local/parent/global
|
|
||||||
* 'global' => overrides scope, setting to parent if true)
|
|
||||||
* </pre>
|
|
||||||
* @param Smarty
|
|
||||||
*/
|
|
||||||
function smarty_function_config_load($params, &$smarty)
|
|
||||||
{
|
|
||||||
if ($smarty->debugging) {
|
|
||||||
$_params = array();
|
|
||||||
require_once(SMARTY_CORE_DIR . 'core.get_microtime.php');
|
|
||||||
$_debug_start_time = smarty_core_get_microtime($_params, $smarty);
|
|
||||||
}
|
|
||||||
|
|
||||||
$_file = isset($params['file']) ? $smarty->_dequote($params['file']) : null;
|
|
||||||
$_section = isset($params['section']) ? $smarty->_dequote($params['section']) : null;
|
|
||||||
$_scope = isset($params['scope']) ? $smarty->_dequote($params['scope']) : 'global';
|
|
||||||
$_global = isset($params['global']) ? $smarty->_dequote($params['global']) : false;
|
|
||||||
|
|
||||||
if (!isset($_file) || strlen($_file) == 0) {
|
|
||||||
$smarty->trigger_error("missing 'file' attribute in config_load tag", E_USER_ERROR, __FILE__, __LINE__);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($_scope)) {
|
|
||||||
if ($_scope != 'local' &&
|
|
||||||
$_scope != 'parent' &&
|
|
||||||
$_scope != 'global') {
|
|
||||||
$smarty->trigger_error("invalid 'scope' attribute value", E_USER_ERROR, __FILE__, __LINE__);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if ($_global) {
|
|
||||||
$_scope = 'parent';
|
|
||||||
} else {
|
|
||||||
$_scope = 'local';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$_params = array('resource_name' => $_file,
|
|
||||||
'resource_base_path' => $smarty->config_dir,
|
|
||||||
'get_source' => false);
|
|
||||||
$smarty->_parse_resource_name($_params);
|
|
||||||
$_file_path = $_params['resource_type'] . ':' . $_params['resource_name'];
|
|
||||||
if (isset($_section))
|
|
||||||
$_compile_file = $smarty->_get_compile_path($_file_path.'|'.$_section);
|
|
||||||
else
|
|
||||||
$_compile_file = $smarty->_get_compile_path($_file_path);
|
|
||||||
|
|
||||||
if($smarty->force_compile || !file_exists($_compile_file)) {
|
|
||||||
$_compile = true;
|
|
||||||
} elseif ($smarty->compile_check) {
|
|
||||||
$_params = array('resource_name' => $_file,
|
|
||||||
'resource_base_path' => $smarty->config_dir,
|
|
||||||
'get_source' => false);
|
|
||||||
$_compile = $smarty->_fetch_resource_info($_params) &&
|
|
||||||
$_params['resource_timestamp'] > filemtime($_compile_file);
|
|
||||||
} else {
|
|
||||||
$_compile = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if($_compile) {
|
|
||||||
// compile config file
|
|
||||||
if(!is_object($smarty->_conf_obj)) {
|
|
||||||
require_once SMARTY_DIR . $smarty->config_class . '.class.php';
|
|
||||||
$smarty->_conf_obj = new $smarty->config_class();
|
|
||||||
$smarty->_conf_obj->overwrite = $smarty->config_overwrite;
|
|
||||||
$smarty->_conf_obj->booleanize = $smarty->config_booleanize;
|
|
||||||
$smarty->_conf_obj->read_hidden = $smarty->config_read_hidden;
|
|
||||||
$smarty->_conf_obj->fix_newlines = $smarty->config_fix_newlines;
|
|
||||||
}
|
|
||||||
|
|
||||||
$_params = array('resource_name' => $_file,
|
|
||||||
'resource_base_path' => $smarty->config_dir,
|
|
||||||
$_params['get_source'] = true);
|
|
||||||
if (!$smarty->_fetch_resource_info($_params)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$smarty->_conf_obj->set_file_contents($_file, $_params['source_content']);
|
|
||||||
$_config_vars = array_merge($smarty->_conf_obj->get($_file),
|
|
||||||
$smarty->_conf_obj->get($_file, $_section));
|
|
||||||
if(function_exists('var_export')) {
|
|
||||||
$_output = '<?php $_config_vars = ' . var_export($_config_vars, true) . '; ?>';
|
|
||||||
} else {
|
|
||||||
$_output = '<?php $_config_vars = unserialize(\'' . strtr(serialize($_config_vars),array('\''=>'\\\'', '\\'=>'\\\\')) . '\'); ?>';
|
|
||||||
}
|
|
||||||
$_params = (array('compile_path' => $_compile_file, 'compiled_content' => $_output, 'resource_timestamp' => $_params['resource_timestamp']));
|
|
||||||
require_once(SMARTY_CORE_DIR . 'core.write_compiled_resource.php');
|
|
||||||
smarty_core_write_compiled_resource($_params, $smarty);
|
|
||||||
} else {
|
|
||||||
include($_compile_file);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($smarty->caching) {
|
|
||||||
$smarty->_cache_info['config'][$_file] = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
$smarty->_config[0]['vars'] = @array_merge($smarty->_config[0]['vars'], $_config_vars);
|
|
||||||
$smarty->_config[0]['files'][$_file] = true;
|
|
||||||
|
|
||||||
if ($_scope == 'parent') {
|
|
||||||
$smarty->_config[1]['vars'] = @array_merge($smarty->_config[1]['vars'], $_config_vars);
|
|
||||||
$smarty->_config[1]['files'][$_file] = true;
|
|
||||||
} else if ($_scope == 'global') {
|
|
||||||
for ($i = 1, $for_max = count($smarty->_config); $i < $for_max; $i++) {
|
|
||||||
$smarty->_config[$i]['vars'] = @array_merge($smarty->_config[$i]['vars'], $_config_vars);
|
|
||||||
$smarty->_config[$i]['files'][$_file] = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($smarty->debugging) {
|
|
||||||
$_params = array();
|
|
||||||
require_once(SMARTY_CORE_DIR . 'core.get_microtime.php');
|
|
||||||
$smarty->_smarty_debug_info[] = array('type' => 'config',
|
|
||||||
'filename' => $_file.' ['.$_section.'] '.$_scope,
|
|
||||||
'depth' => $smarty->_inclusion_depth,
|
|
||||||
'exec_time' => smarty_core_get_microtime($_params, $smarty) - $_debug_start_time);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* vim: set expandtab: */
|
|
||||||
|
|
||||||
?>
|
|
||||||
@@ -1,80 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Smarty plugin
|
|
||||||
* @package Smarty
|
|
||||||
* @subpackage plugins
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Smarty {counter} function plugin
|
|
||||||
*
|
|
||||||
* Type: function<br>
|
|
||||||
* Name: counter<br>
|
|
||||||
* Purpose: print out a counter value
|
|
||||||
* @author Monte Ohrt <monte at ohrt dot com>
|
|
||||||
* @link http://smarty.php.net/manual/en/language.function.counter.php {counter}
|
|
||||||
* (Smarty online manual)
|
|
||||||
* @param array parameters
|
|
||||||
* @param Smarty
|
|
||||||
* @return string|null
|
|
||||||
*/
|
|
||||||
function smarty_function_counter($params, &$smarty)
|
|
||||||
{
|
|
||||||
static $counters = array();
|
|
||||||
|
|
||||||
$name = (isset($params['name'])) ? $params['name'] : 'default';
|
|
||||||
if (!isset($counters[$name])) {
|
|
||||||
$counters[$name] = array(
|
|
||||||
'start'=>1,
|
|
||||||
'skip'=>1,
|
|
||||||
'direction'=>'up',
|
|
||||||
'count'=>1
|
|
||||||
);
|
|
||||||
}
|
|
||||||
$counter =& $counters[$name];
|
|
||||||
|
|
||||||
if (isset($params['start'])) {
|
|
||||||
$counter['start'] = $counter['count'] = (int)$params['start'];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($params['assign'])) {
|
|
||||||
$counter['assign'] = $params['assign'];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($counter['assign'])) {
|
|
||||||
$smarty->assign($counter['assign'], $counter['count']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($params['print'])) {
|
|
||||||
$print = (bool)$params['print'];
|
|
||||||
} else {
|
|
||||||
$print = empty($counter['assign']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($print) {
|
|
||||||
$retval = $counter['count'];
|
|
||||||
} else {
|
|
||||||
$retval = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($params['skip'])) {
|
|
||||||
$counter['skip'] = $params['skip'];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($params['direction'])) {
|
|
||||||
$counter['direction'] = $params['direction'];
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($counter['direction'] == "down")
|
|
||||||
$counter['count'] -= $counter['skip'];
|
|
||||||
else
|
|
||||||
$counter['count'] += $counter['skip'];
|
|
||||||
|
|
||||||
return $retval;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* vim: set expandtab: */
|
|
||||||
|
|
||||||
?>
|
|
||||||
102
thirdparty/smarty/libs/plugins/function.cycle.php
vendored
102
thirdparty/smarty/libs/plugins/function.cycle.php
vendored
@@ -1,102 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Smarty plugin
|
|
||||||
* @package Smarty
|
|
||||||
* @subpackage plugins
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Smarty {cycle} function plugin
|
|
||||||
*
|
|
||||||
* Type: function<br>
|
|
||||||
* Name: cycle<br>
|
|
||||||
* Date: May 3, 2002<br>
|
|
||||||
* Purpose: cycle through given values<br>
|
|
||||||
* Input:
|
|
||||||
* - name = name of cycle (optional)
|
|
||||||
* - values = comma separated list of values to cycle,
|
|
||||||
* or an array of values to cycle
|
|
||||||
* (this can be left out for subsequent calls)
|
|
||||||
* - reset = boolean - resets given var to true
|
|
||||||
* - print = boolean - print var or not. default is true
|
|
||||||
* - advance = boolean - whether or not to advance the cycle
|
|
||||||
* - delimiter = the value delimiter, default is ","
|
|
||||||
* - assign = boolean, assigns to template var instead of
|
|
||||||
* printed.
|
|
||||||
*
|
|
||||||
* Examples:<br>
|
|
||||||
* <pre>
|
|
||||||
* {cycle values="#eeeeee,#d0d0d0d"}
|
|
||||||
* {cycle name=row values="one,two,three" reset=true}
|
|
||||||
* {cycle name=row}
|
|
||||||
* </pre>
|
|
||||||
* @link http://smarty.php.net/manual/en/language.function.cycle.php {cycle}
|
|
||||||
* (Smarty online manual)
|
|
||||||
* @author Monte Ohrt <monte at ohrt dot com>
|
|
||||||
* @author credit to Mark Priatel <mpriatel@rogers.com>
|
|
||||||
* @author credit to Gerard <gerard@interfold.com>
|
|
||||||
* @author credit to Jason Sweat <jsweat_php@yahoo.com>
|
|
||||||
* @version 1.3
|
|
||||||
* @param array
|
|
||||||
* @param Smarty
|
|
||||||
* @return string|null
|
|
||||||
*/
|
|
||||||
function smarty_function_cycle($params, &$smarty)
|
|
||||||
{
|
|
||||||
static $cycle_vars;
|
|
||||||
|
|
||||||
$name = (empty($params['name'])) ? 'default' : $params['name'];
|
|
||||||
$print = (isset($params['print'])) ? (bool)$params['print'] : true;
|
|
||||||
$advance = (isset($params['advance'])) ? (bool)$params['advance'] : true;
|
|
||||||
$reset = (isset($params['reset'])) ? (bool)$params['reset'] : false;
|
|
||||||
|
|
||||||
if (!in_array('values', array_keys($params))) {
|
|
||||||
if(!isset($cycle_vars[$name]['values'])) {
|
|
||||||
$smarty->trigger_error("cycle: missing 'values' parameter");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if(isset($cycle_vars[$name]['values'])
|
|
||||||
&& $cycle_vars[$name]['values'] != $params['values'] ) {
|
|
||||||
$cycle_vars[$name]['index'] = 0;
|
|
||||||
}
|
|
||||||
$cycle_vars[$name]['values'] = $params['values'];
|
|
||||||
}
|
|
||||||
|
|
||||||
$cycle_vars[$name]['delimiter'] = (isset($params['delimiter'])) ? $params['delimiter'] : ',';
|
|
||||||
|
|
||||||
if(is_array($cycle_vars[$name]['values'])) {
|
|
||||||
$cycle_array = $cycle_vars[$name]['values'];
|
|
||||||
} else {
|
|
||||||
$cycle_array = explode($cycle_vars[$name]['delimiter'],$cycle_vars[$name]['values']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!isset($cycle_vars[$name]['index']) || $reset ) {
|
|
||||||
$cycle_vars[$name]['index'] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($params['assign'])) {
|
|
||||||
$print = false;
|
|
||||||
$smarty->assign($params['assign'], $cycle_array[$cycle_vars[$name]['index']]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if($print) {
|
|
||||||
$retval = $cycle_array[$cycle_vars[$name]['index']];
|
|
||||||
} else {
|
|
||||||
$retval = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if($advance) {
|
|
||||||
if ( $cycle_vars[$name]['index'] >= count($cycle_array) -1 ) {
|
|
||||||
$cycle_vars[$name]['index'] = 0;
|
|
||||||
} else {
|
|
||||||
$cycle_vars[$name]['index']++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $retval;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* vim: set expandtab: */
|
|
||||||
|
|
||||||
?>
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Smarty plugin
|
|
||||||
* @package Smarty
|
|
||||||
* @subpackage plugins
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Smarty {debug} function plugin
|
|
||||||
*
|
|
||||||
* Type: function<br>
|
|
||||||
* Name: debug<br>
|
|
||||||
* Date: July 1, 2002<br>
|
|
||||||
* Purpose: popup debug window
|
|
||||||
* @link http://smarty.php.net/manual/en/language.function.debug.php {debug}
|
|
||||||
* (Smarty online manual)
|
|
||||||
* @author Monte Ohrt <monte at ohrt dot com>
|
|
||||||
* @version 1.0
|
|
||||||
* @param array
|
|
||||||
* @param Smarty
|
|
||||||
* @return string output from {@link Smarty::_generate_debug_output()}
|
|
||||||
*/
|
|
||||||
function smarty_function_debug($params, &$smarty)
|
|
||||||
{
|
|
||||||
if (isset($params['output'])) {
|
|
||||||
$smarty->assign('_smarty_debug_output', $params['output']);
|
|
||||||
}
|
|
||||||
require_once(SMARTY_CORE_DIR . 'core.display_debug_console.php');
|
|
||||||
return smarty_core_display_debug_console(null, $smarty);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* vim: set expandtab: */
|
|
||||||
|
|
||||||
?>
|
|
||||||
49
thirdparty/smarty/libs/plugins/function.eval.php
vendored
49
thirdparty/smarty/libs/plugins/function.eval.php
vendored
@@ -1,49 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Smarty plugin
|
|
||||||
* @package Smarty
|
|
||||||
* @subpackage plugins
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Smarty {eval} function plugin
|
|
||||||
*
|
|
||||||
* Type: function<br>
|
|
||||||
* Name: eval<br>
|
|
||||||
* Purpose: evaluate a template variable as a template<br>
|
|
||||||
* @link http://smarty.php.net/manual/en/language.function.eval.php {eval}
|
|
||||||
* (Smarty online manual)
|
|
||||||
* @author Monte Ohrt <monte at ohrt dot com>
|
|
||||||
* @param array
|
|
||||||
* @param Smarty
|
|
||||||
*/
|
|
||||||
function smarty_function_eval($params, &$smarty)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (!isset($params['var'])) {
|
|
||||||
$smarty->trigger_error("eval: missing 'var' parameter");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if($params['var'] == '') {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$smarty->_compile_source('evaluated template', $params['var'], $_var_compiled);
|
|
||||||
|
|
||||||
ob_start();
|
|
||||||
$smarty->_eval('?>' . $_var_compiled);
|
|
||||||
$_contents = ob_get_contents();
|
|
||||||
ob_end_clean();
|
|
||||||
|
|
||||||
if (!empty($params['assign'])) {
|
|
||||||
$smarty->assign($params['assign'], $_contents);
|
|
||||||
} else {
|
|
||||||
return $_contents;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* vim: set expandtab: */
|
|
||||||
|
|
||||||
?>
|
|
||||||
221
thirdparty/smarty/libs/plugins/function.fetch.php
vendored
221
thirdparty/smarty/libs/plugins/function.fetch.php
vendored
@@ -1,221 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Smarty plugin
|
|
||||||
* @package Smarty
|
|
||||||
* @subpackage plugins
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Smarty {fetch} plugin
|
|
||||||
*
|
|
||||||
* Type: function<br>
|
|
||||||
* Name: fetch<br>
|
|
||||||
* Purpose: fetch file, web or ftp data and display results
|
|
||||||
* @link http://smarty.php.net/manual/en/language.function.fetch.php {fetch}
|
|
||||||
* (Smarty online manual)
|
|
||||||
* @author Monte Ohrt <monte at ohrt dot com>
|
|
||||||
* @param array
|
|
||||||
* @param Smarty
|
|
||||||
* @return string|null if the assign parameter is passed, Smarty assigns the
|
|
||||||
* result to a template variable
|
|
||||||
*/
|
|
||||||
function smarty_function_fetch($params, &$smarty)
|
|
||||||
{
|
|
||||||
if (empty($params['file'])) {
|
|
||||||
$smarty->_trigger_fatal_error("[plugin] parameter 'file' cannot be empty");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$content = '';
|
|
||||||
if ($smarty->security && !preg_match('!^(http|ftp)://!i', $params['file'])) {
|
|
||||||
$_params = array('resource_type' => 'file', 'resource_name' => $params['file']);
|
|
||||||
require_once(SMARTY_CORE_DIR . 'core.is_secure.php');
|
|
||||||
if(!smarty_core_is_secure($_params, $smarty)) {
|
|
||||||
$smarty->_trigger_fatal_error('[plugin] (secure mode) fetch \'' . $params['file'] . '\' is not allowed');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// fetch the file
|
|
||||||
if($fp = @fopen($params['file'],'r')) {
|
|
||||||
while(!feof($fp)) {
|
|
||||||
$content .= fgets ($fp,4096);
|
|
||||||
}
|
|
||||||
fclose($fp);
|
|
||||||
} else {
|
|
||||||
$smarty->_trigger_fatal_error('[plugin] fetch cannot read file \'' . $params['file'] . '\'');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// not a local file
|
|
||||||
if(preg_match('!^http://!i',$params['file'])) {
|
|
||||||
// http fetch
|
|
||||||
if($uri_parts = parse_url($params['file'])) {
|
|
||||||
// set defaults
|
|
||||||
$host = $server_name = $uri_parts['host'];
|
|
||||||
$timeout = 30;
|
|
||||||
$accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*";
|
|
||||||
$agent = "Smarty Template Engine ".$smarty->_version;
|
|
||||||
$referer = "";
|
|
||||||
$uri = !empty($uri_parts['path']) ? $uri_parts['path'] : '/';
|
|
||||||
$uri .= !empty($uri_parts['query']) ? '?' . $uri_parts['query'] : '';
|
|
||||||
$_is_proxy = false;
|
|
||||||
if(empty($uri_parts['port'])) {
|
|
||||||
$port = 80;
|
|
||||||
} else {
|
|
||||||
$port = $uri_parts['port'];
|
|
||||||
}
|
|
||||||
if(!empty($uri_parts['user'])) {
|
|
||||||
$user = $uri_parts['user'];
|
|
||||||
}
|
|
||||||
if(!empty($uri_parts['pass'])) {
|
|
||||||
$pass = $uri_parts['pass'];
|
|
||||||
}
|
|
||||||
// loop through parameters, setup headers
|
|
||||||
foreach($params as $param_key => $param_value) {
|
|
||||||
switch($param_key) {
|
|
||||||
case "file":
|
|
||||||
case "assign":
|
|
||||||
case "assign_headers":
|
|
||||||
break;
|
|
||||||
case "user":
|
|
||||||
if(!empty($param_value)) {
|
|
||||||
$user = $param_value;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "pass":
|
|
||||||
if(!empty($param_value)) {
|
|
||||||
$pass = $param_value;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "accept":
|
|
||||||
if(!empty($param_value)) {
|
|
||||||
$accept = $param_value;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "header":
|
|
||||||
if(!empty($param_value)) {
|
|
||||||
if(!preg_match('![\w\d-]+: .+!',$param_value)) {
|
|
||||||
$smarty->_trigger_fatal_error("[plugin] invalid header format '".$param_value."'");
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
$extra_headers[] = $param_value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "proxy_host":
|
|
||||||
if(!empty($param_value)) {
|
|
||||||
$proxy_host = $param_value;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "proxy_port":
|
|
||||||
if(!preg_match('!\D!', $param_value)) {
|
|
||||||
$proxy_port = (int) $param_value;
|
|
||||||
} else {
|
|
||||||
$smarty->_trigger_fatal_error("[plugin] invalid value for attribute '".$param_key."'");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "agent":
|
|
||||||
if(!empty($param_value)) {
|
|
||||||
$agent = $param_value;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "referer":
|
|
||||||
if(!empty($param_value)) {
|
|
||||||
$referer = $param_value;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "timeout":
|
|
||||||
if(!preg_match('!\D!', $param_value)) {
|
|
||||||
$timeout = (int) $param_value;
|
|
||||||
} else {
|
|
||||||
$smarty->_trigger_fatal_error("[plugin] invalid value for attribute '".$param_key."'");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$smarty->_trigger_fatal_error("[plugin] unrecognized attribute '".$param_key."'");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(!empty($proxy_host) && !empty($proxy_port)) {
|
|
||||||
$_is_proxy = true;
|
|
||||||
$fp = fsockopen($proxy_host,$proxy_port,$errno,$errstr,$timeout);
|
|
||||||
} else {
|
|
||||||
$fp = fsockopen($server_name,$port,$errno,$errstr,$timeout);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!$fp) {
|
|
||||||
$smarty->_trigger_fatal_error("[plugin] unable to fetch: $errstr ($errno)");
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
if($_is_proxy) {
|
|
||||||
fputs($fp, 'GET ' . $params['file'] . " HTTP/1.0\r\n");
|
|
||||||
} else {
|
|
||||||
fputs($fp, "GET $uri HTTP/1.0\r\n");
|
|
||||||
}
|
|
||||||
if(!empty($host)) {
|
|
||||||
fputs($fp, "Host: $host\r\n");
|
|
||||||
}
|
|
||||||
if(!empty($accept)) {
|
|
||||||
fputs($fp, "Accept: $accept\r\n");
|
|
||||||
}
|
|
||||||
if(!empty($agent)) {
|
|
||||||
fputs($fp, "User-Agent: $agent\r\n");
|
|
||||||
}
|
|
||||||
if(!empty($referer)) {
|
|
||||||
fputs($fp, "Referer: $referer\r\n");
|
|
||||||
}
|
|
||||||
if(isset($extra_headers) && is_array($extra_headers)) {
|
|
||||||
foreach($extra_headers as $curr_header) {
|
|
||||||
fputs($fp, $curr_header."\r\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(!empty($user) && !empty($pass)) {
|
|
||||||
fputs($fp, "Authorization: BASIC ".base64_encode("$user:$pass")."\r\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
fputs($fp, "\r\n");
|
|
||||||
while(!feof($fp)) {
|
|
||||||
$content .= fgets($fp,4096);
|
|
||||||
}
|
|
||||||
fclose($fp);
|
|
||||||
$csplit = explode("\r\n\r\n",$content,2);
|
|
||||||
|
|
||||||
$content = $csplit[1];
|
|
||||||
|
|
||||||
if(!empty($params['assign_headers'])) {
|
|
||||||
$smarty->assign($params['assign_headers'],explode("\r\n",$csplit[0]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$smarty->_trigger_fatal_error("[plugin] unable to parse URL, check syntax");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// ftp fetch
|
|
||||||
if($fp = @fopen($params['file'],'r')) {
|
|
||||||
while(!feof($fp)) {
|
|
||||||
$content .= fgets ($fp,4096);
|
|
||||||
}
|
|
||||||
fclose($fp);
|
|
||||||
} else {
|
|
||||||
$smarty->_trigger_fatal_error('[plugin] fetch cannot read file \'' . $params['file'] .'\'');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (!empty($params['assign'])) {
|
|
||||||
$smarty->assign($params['assign'],$content);
|
|
||||||
} else {
|
|
||||||
return $content;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* vim: set expandtab: */
|
|
||||||
|
|
||||||
?>
|
|
||||||
@@ -1,143 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Smarty plugin
|
|
||||||
* @package Smarty
|
|
||||||
* @subpackage plugins
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Smarty {html_checkboxes} function plugin
|
|
||||||
*
|
|
||||||
* File: function.html_checkboxes.php<br>
|
|
||||||
* Type: function<br>
|
|
||||||
* Name: html_checkboxes<br>
|
|
||||||
* Date: 24.Feb.2003<br>
|
|
||||||
* Purpose: Prints out a list of checkbox input types<br>
|
|
||||||
* Input:<br>
|
|
||||||
* - name (optional) - string default "checkbox"
|
|
||||||
* - values (required) - array
|
|
||||||
* - options (optional) - associative array
|
|
||||||
* - checked (optional) - array default not set
|
|
||||||
* - separator (optional) - ie <br> or
|
|
||||||
* - output (optional) - the output next to each checkbox
|
|
||||||
* - assign (optional) - assign the output as an array to this variable
|
|
||||||
* Examples:
|
|
||||||
* <pre>
|
|
||||||
* {html_checkboxes values=$ids output=$names}
|
|
||||||
* {html_checkboxes values=$ids name='box' separator='<br>' output=$names}
|
|
||||||
* {html_checkboxes values=$ids checked=$checked separator='<br>' output=$names}
|
|
||||||
* </pre>
|
|
||||||
* @link http://smarty.php.net/manual/en/language.function.html.checkboxes.php {html_checkboxes}
|
|
||||||
* (Smarty online manual)
|
|
||||||
* @author Christopher Kvarme <christopher.kvarme@flashjab.com>
|
|
||||||
* @author credits to Monte Ohrt <monte at ohrt dot com>
|
|
||||||
* @version 1.0
|
|
||||||
* @param array
|
|
||||||
* @param Smarty
|
|
||||||
* @return string
|
|
||||||
* @uses smarty_function_escape_special_chars()
|
|
||||||
*/
|
|
||||||
function smarty_function_html_checkboxes($params, &$smarty)
|
|
||||||
{
|
|
||||||
require_once $smarty->_get_plugin_filepath('shared','escape_special_chars');
|
|
||||||
|
|
||||||
$name = 'checkbox';
|
|
||||||
$values = null;
|
|
||||||
$options = null;
|
|
||||||
$selected = null;
|
|
||||||
$separator = '';
|
|
||||||
$labels = true;
|
|
||||||
$output = null;
|
|
||||||
|
|
||||||
$extra = '';
|
|
||||||
|
|
||||||
foreach($params as $_key => $_val) {
|
|
||||||
switch($_key) {
|
|
||||||
case 'name':
|
|
||||||
case 'separator':
|
|
||||||
$$_key = $_val;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'labels':
|
|
||||||
$$_key = (bool)$_val;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'options':
|
|
||||||
$$_key = (array)$_val;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'values':
|
|
||||||
case 'output':
|
|
||||||
$$_key = array_values((array)$_val);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'checked':
|
|
||||||
case 'selected':
|
|
||||||
$selected = array_map('strval', array_values((array)$_val));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'checkboxes':
|
|
||||||
$smarty->trigger_error('html_checkboxes: the use of the "checkboxes" attribute is deprecated, use "options" instead', E_USER_WARNING);
|
|
||||||
$options = (array)$_val;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'assign':
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
if(!is_array($_val)) {
|
|
||||||
$extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_val).'"';
|
|
||||||
} else {
|
|
||||||
$smarty->trigger_error("html_checkboxes: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isset($options) && !isset($values))
|
|
||||||
return ''; /* raise error here? */
|
|
||||||
|
|
||||||
settype($selected, 'array');
|
|
||||||
$_html_result = array();
|
|
||||||
|
|
||||||
if (isset($options)) {
|
|
||||||
|
|
||||||
foreach ($options as $_key=>$_val)
|
|
||||||
$_html_result[] = smarty_function_html_checkboxes_output($name, $_key, $_val, $selected, $extra, $separator, $labels);
|
|
||||||
|
|
||||||
|
|
||||||
} else {
|
|
||||||
foreach ($values as $_i=>$_key) {
|
|
||||||
$_val = isset($output[$_i]) ? $output[$_i] : '';
|
|
||||||
$_html_result[] = smarty_function_html_checkboxes_output($name, $_key, $_val, $selected, $extra, $separator, $labels);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!empty($params['assign'])) {
|
|
||||||
$smarty->assign($params['assign'], $_html_result);
|
|
||||||
} else {
|
|
||||||
return implode("\n",$_html_result);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function smarty_function_html_checkboxes_output($name, $value, $output, $selected, $extra, $separator, $labels) {
|
|
||||||
$_output = '';
|
|
||||||
if ($labels) $_output .= '<label>';
|
|
||||||
$_output .= '<input type="checkbox" name="'
|
|
||||||
. smarty_function_escape_special_chars($name) . '[]" value="'
|
|
||||||
. smarty_function_escape_special_chars($value) . '"';
|
|
||||||
|
|
||||||
if (in_array((string)$value, $selected)) {
|
|
||||||
$_output .= ' checked="checked"';
|
|
||||||
}
|
|
||||||
$_output .= $extra . ' />' . $output;
|
|
||||||
if ($labels) $_output .= '</label>';
|
|
||||||
$_output .= $separator;
|
|
||||||
|
|
||||||
return $_output;
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
||||||
@@ -1,142 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Smarty plugin
|
|
||||||
* @package Smarty
|
|
||||||
* @subpackage plugins
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Smarty {html_image} function plugin
|
|
||||||
*
|
|
||||||
* Type: function<br>
|
|
||||||
* Name: html_image<br>
|
|
||||||
* Date: Feb 24, 2003<br>
|
|
||||||
* Purpose: format HTML tags for the image<br>
|
|
||||||
* Input:<br>
|
|
||||||
* - file = file (and path) of image (required)
|
|
||||||
* - height = image height (optional, default actual height)
|
|
||||||
* - width = image width (optional, default actual width)
|
|
||||||
* - basedir = base directory for absolute paths, default
|
|
||||||
* is environment variable DOCUMENT_ROOT
|
|
||||||
* - path_prefix = prefix for path output (optional, default empty)
|
|
||||||
*
|
|
||||||
* Examples: {html_image file="/images/masthead.gif"}
|
|
||||||
* Output: <img src="/images/masthead.gif" width=400 height=23>
|
|
||||||
* @link http://smarty.php.net/manual/en/language.function.html.image.php {html_image}
|
|
||||||
* (Smarty online manual)
|
|
||||||
* @author Monte Ohrt <monte at ohrt dot com>
|
|
||||||
* @author credits to Duda <duda@big.hu> - wrote first image function
|
|
||||||
* in repository, helped with lots of functionality
|
|
||||||
* @version 1.0
|
|
||||||
* @param array
|
|
||||||
* @param Smarty
|
|
||||||
* @return string
|
|
||||||
* @uses smarty_function_escape_special_chars()
|
|
||||||
*/
|
|
||||||
function smarty_function_html_image($params, &$smarty)
|
|
||||||
{
|
|
||||||
require_once $smarty->_get_plugin_filepath('shared','escape_special_chars');
|
|
||||||
|
|
||||||
$alt = '';
|
|
||||||
$file = '';
|
|
||||||
$height = '';
|
|
||||||
$width = '';
|
|
||||||
$extra = '';
|
|
||||||
$prefix = '';
|
|
||||||
$suffix = '';
|
|
||||||
$path_prefix = '';
|
|
||||||
$server_vars = ($smarty->request_use_auto_globals) ? $_SERVER : $GLOBALS['HTTP_SERVER_VARS'];
|
|
||||||
$basedir = isset($server_vars['DOCUMENT_ROOT']) ? $server_vars['DOCUMENT_ROOT'] : '';
|
|
||||||
foreach($params as $_key => $_val) {
|
|
||||||
switch($_key) {
|
|
||||||
case 'file':
|
|
||||||
case 'height':
|
|
||||||
case 'width':
|
|
||||||
case 'dpi':
|
|
||||||
case 'path_prefix':
|
|
||||||
case 'basedir':
|
|
||||||
$$_key = $_val;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'alt':
|
|
||||||
if(!is_array($_val)) {
|
|
||||||
$$_key = smarty_function_escape_special_chars($_val);
|
|
||||||
} else {
|
|
||||||
$smarty->trigger_error("html_image: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'link':
|
|
||||||
case 'href':
|
|
||||||
$prefix = '<a href="' . $_val . '">';
|
|
||||||
$suffix = '</a>';
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
if(!is_array($_val)) {
|
|
||||||
$extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_val).'"';
|
|
||||||
} else {
|
|
||||||
$smarty->trigger_error("html_image: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty($file)) {
|
|
||||||
$smarty->trigger_error("html_image: missing 'file' parameter", E_USER_NOTICE);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (substr($file,0,1) == '/') {
|
|
||||||
$_image_path = $basedir . $file;
|
|
||||||
} else {
|
|
||||||
$_image_path = $file;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!isset($params['width']) || !isset($params['height'])) {
|
|
||||||
if(!$_image_data = @getimagesize($_image_path)) {
|
|
||||||
if(!file_exists($_image_path)) {
|
|
||||||
$smarty->trigger_error("html_image: unable to find '$_image_path'", E_USER_NOTICE);
|
|
||||||
return;
|
|
||||||
} else if(!is_readable($_image_path)) {
|
|
||||||
$smarty->trigger_error("html_image: unable to read '$_image_path'", E_USER_NOTICE);
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
$smarty->trigger_error("html_image: '$_image_path' is not a valid image file", E_USER_NOTICE);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($smarty->security &&
|
|
||||||
($_params = array('resource_type' => 'file', 'resource_name' => $_image_path)) &&
|
|
||||||
(require_once(SMARTY_CORE_DIR . 'core.is_secure.php')) &&
|
|
||||||
(!smarty_core_is_secure($_params, $smarty)) ) {
|
|
||||||
$smarty->trigger_error("html_image: (secure) '$_image_path' not in secure directory", E_USER_NOTICE);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!isset($params['width'])) {
|
|
||||||
$width = $_image_data[0];
|
|
||||||
}
|
|
||||||
if(!isset($params['height'])) {
|
|
||||||
$height = $_image_data[1];
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if(isset($params['dpi'])) {
|
|
||||||
if(strstr($server_vars['HTTP_USER_AGENT'], 'Mac')) {
|
|
||||||
$dpi_default = 72;
|
|
||||||
} else {
|
|
||||||
$dpi_default = 96;
|
|
||||||
}
|
|
||||||
$_resize = $dpi_default/$params['dpi'];
|
|
||||||
$width = round($width * $_resize);
|
|
||||||
$height = round($height * $_resize);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $prefix . '<img src="'.$path_prefix.$file.'" alt="'.$alt.'" width="'.$width.'" height="'.$height.'"'.$extra.' />' . $suffix;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* vim: set expandtab: */
|
|
||||||
|
|
||||||
?>
|
|
||||||
@@ -1,122 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Smarty plugin
|
|
||||||
* @package Smarty
|
|
||||||
* @subpackage plugins
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Smarty {html_options} function plugin
|
|
||||||
*
|
|
||||||
* Type: function<br>
|
|
||||||
* Name: html_options<br>
|
|
||||||
* Input:<br>
|
|
||||||
* - name (optional) - string default "select"
|
|
||||||
* - values (required if no options supplied) - array
|
|
||||||
* - options (required if no values supplied) - associative array
|
|
||||||
* - selected (optional) - string default not set
|
|
||||||
* - output (required if not options supplied) - array
|
|
||||||
* Purpose: Prints the list of <option> tags generated from
|
|
||||||
* the passed parameters
|
|
||||||
* @link http://smarty.php.net/manual/en/language.function.html.options.php {html_image}
|
|
||||||
* (Smarty online manual)
|
|
||||||
* @author Monte Ohrt <monte at ohrt dot com>
|
|
||||||
* @param array
|
|
||||||
* @param Smarty
|
|
||||||
* @return string
|
|
||||||
* @uses smarty_function_escape_special_chars()
|
|
||||||
*/
|
|
||||||
function smarty_function_html_options($params, &$smarty)
|
|
||||||
{
|
|
||||||
require_once $smarty->_get_plugin_filepath('shared','escape_special_chars');
|
|
||||||
|
|
||||||
$name = null;
|
|
||||||
$values = null;
|
|
||||||
$options = null;
|
|
||||||
$selected = array();
|
|
||||||
$output = null;
|
|
||||||
|
|
||||||
$extra = '';
|
|
||||||
|
|
||||||
foreach($params as $_key => $_val) {
|
|
||||||
switch($_key) {
|
|
||||||
case 'name':
|
|
||||||
$$_key = (string)$_val;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'options':
|
|
||||||
$$_key = (array)$_val;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'values':
|
|
||||||
case 'output':
|
|
||||||
$$_key = array_values((array)$_val);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'selected':
|
|
||||||
$$_key = array_map('strval', array_values((array)$_val));
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
if(!is_array($_val)) {
|
|
||||||
$extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_val).'"';
|
|
||||||
} else {
|
|
||||||
$smarty->trigger_error("html_options: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isset($options) && !isset($values))
|
|
||||||
return ''; /* raise error here? */
|
|
||||||
|
|
||||||
$_html_result = '';
|
|
||||||
|
|
||||||
if (isset($options)) {
|
|
||||||
|
|
||||||
foreach ($options as $_key=>$_val)
|
|
||||||
$_html_result .= smarty_function_html_options_optoutput($_key, $_val, $selected);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
foreach ($values as $_i=>$_key) {
|
|
||||||
$_val = isset($output[$_i]) ? $output[$_i] : '';
|
|
||||||
$_html_result .= smarty_function_html_options_optoutput($_key, $_val, $selected);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!empty($name)) {
|
|
||||||
$_html_result = '<select name="' . $name . '"' . $extra . '>' . "\n" . $_html_result . '</select>' . "\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
return $_html_result;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function smarty_function_html_options_optoutput($key, $value, $selected) {
|
|
||||||
if(!is_array($value)) {
|
|
||||||
$_html_result = '<option label="' . smarty_function_escape_special_chars($value) . '" value="' .
|
|
||||||
smarty_function_escape_special_chars($key) . '"';
|
|
||||||
if (in_array((string)$key, $selected))
|
|
||||||
$_html_result .= ' selected="selected"';
|
|
||||||
$_html_result .= '>' . smarty_function_escape_special_chars($value) . '</option>' . "\n";
|
|
||||||
} else {
|
|
||||||
$_html_result = smarty_function_html_options_optgroup($key, $value, $selected);
|
|
||||||
}
|
|
||||||
return $_html_result;
|
|
||||||
}
|
|
||||||
|
|
||||||
function smarty_function_html_options_optgroup($key, $values, $selected) {
|
|
||||||
$optgroup_html = '<optgroup label="' . smarty_function_escape_special_chars($key) . '">' . "\n";
|
|
||||||
foreach ($values as $key => $value) {
|
|
||||||
$optgroup_html .= smarty_function_html_options_optoutput($key, $value, $selected);
|
|
||||||
}
|
|
||||||
$optgroup_html .= "</optgroup>\n";
|
|
||||||
return $optgroup_html;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* vim: set expandtab: */
|
|
||||||
|
|
||||||
?>
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user