Merge branch 'release/ConLite_2.1.2'
Dieser Commit ist enthalten in:
Commit
f2327b51db
|
@ -0,0 +1,14 @@
|
|||
/nbproject/private/
|
||||
/data/config/production/config.php
|
||||
/_dev/
|
||||
/conlite/plugins/pluginmanager/_src
|
||||
/.project
|
||||
/_api/
|
||||
/cl-releasetool
|
||||
/data/config/production/config.local.php
|
||||
/cms/data/modules/up-download/
|
||||
/cms/captcha/
|
||||
!/cms/data/modules/
|
||||
/cms/data/modules/*
|
||||
!/cms/data/layouts/
|
||||
/cms/data/layouts/*
|
|
@ -0,0 +1,61 @@
|
|||
################################################################################
|
||||
# ConLite AMR plugin simple rewrite rules set.
|
||||
#
|
||||
# Contains few easy to handle rewrite rules.
|
||||
#
|
||||
# @version 1.0.0
|
||||
# @author Ortwin Pinke <ortwin.pinke@php-backoffice.de>
|
||||
# @author Murat Purc <murat@purc.de>
|
||||
# @copyright 2019 ConLite Team
|
||||
# @link http://www.conlite.org
|
||||
#
|
||||
# Versions before 1.0 copyright 4fb, author Murat Purc
|
||||
#
|
||||
# $Id: htaccess_simple.txt 145 2019-10-25 16:00:47Z oldperl $
|
||||
################################################################################
|
||||
|
||||
#SetEnv CONLITE_ENVIRONMENT development
|
||||
|
||||
<IfModule mod_rewrite.c>
|
||||
|
||||
# Enable rewrite engine
|
||||
RewriteEngine on
|
||||
|
||||
# Specify a base URL-path for the rules
|
||||
RewriteBase /cms
|
||||
|
||||
# Catch some common exploits in query string to get rid of them
|
||||
# NOTE: Conditions to prevent protocols (ftp, http[s]) in query string could
|
||||
# be a disadvantage in some cases
|
||||
RewriteCond %{QUERY_STRING} contenido_path=.*$ [NC,OR]
|
||||
RewriteCond %{QUERY_STRING} cfg\[path\]=.*$ [NC,OR]
|
||||
RewriteCond %{QUERY_STRING} _PHPLIB\[libdir\]=.*$ [NC,OR]
|
||||
RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
|
||||
RewriteCond %{QUERY_STRING} ftp://.*$ [NC,OR]
|
||||
RewriteCond %{QUERY_STRING} http[s]*://.*$ [NC]
|
||||
RewriteRule ^.* - [F,L] # all matching conditions from above will end in nirvana
|
||||
|
||||
# Rewrite request to root to front_content.php
|
||||
RewriteRule ^$ front_content.php [QSA,L]
|
||||
|
||||
# Exclude following request from rewriting
|
||||
# tests for favicon.ico, valid symlinks (-s), not empty files (-l) and folders (-d)
|
||||
RewriteCond %{REQUEST_URI} ^/favicon.ico$ [OR]
|
||||
RewriteCond %{REQUEST_FILENAME} -s [OR]
|
||||
RewriteCond %{REQUEST_FILENAME} -l [OR]
|
||||
RewriteCond %{REQUEST_FILENAME} -d
|
||||
RewriteRule ^.*$ - [NC,L]
|
||||
|
||||
# Pass other requests to front_content.php
|
||||
RewriteRule ^.*$ front_content.php [QSA,NC,L]
|
||||
|
||||
</IfModule>
|
||||
|
||||
# Some rules to compress files.
|
||||
# NOTE: Following settings are not mod rewrite specific, but enabling mod_deflate
|
||||
# for some file types can help to reduce bandwith.
|
||||
<IfModule mod_deflate.c>
|
||||
<FilesMatch "\.(js|css|html|htm|php|xml)$">
|
||||
SetOutputFilter DEFLATE
|
||||
</FilesMatch>
|
||||
</IfModule>
|
84
README.md
84
README.md
|
@ -1 +1,83 @@
|
|||
# ConLite
|
||||
----------------------------------------------------------------------------------------------------
|
||||
This is the readme file for ConLite 2.1.2
|
||||
|
||||
Any help you need you may find by visiting the following links.
|
||||
|
||||
CL-Portal http//conlite.org
|
||||
CL-Forum http://forum.conlite.org
|
||||
CL-Bugtracker http://bugs.conlite.org
|
||||
CL-API-Doc http://conlite.conrepo.org/api/4.8.16CL
|
||||
|
||||
!!! Attention !!!
|
||||
We tried to fix all known bugs of Contenido 4.8 and earlier but cannot give any garanties for that. So use
|
||||
it on your own risk. If you find any bug or have any idea to enhance ConLite, feel free to visit our
|
||||
bugtracker and register at http://bugs.conlite.org
|
||||
Any help and ideas are welcome :)
|
||||
|
||||
** Mini FAQ **
|
||||
|
||||
What is ConLite?
|
||||
|
||||
CL (short for ConLite) is dedicated to close the gap between Contenido 4.8 and the version 4.10.
|
||||
In downloadable 4.8.20 (and former 4.8.15) are still a lot of bugs and some missing feautures and
|
||||
enhancements so one cannot use the version without problems. Our goal is to give you a bugfixed and
|
||||
really stable version of Contenido till the 4.9 or 4.10 is stable. By the way, there are still a lot of big sides
|
||||
build with 4.8.x out there where upgrading to 4.10.x is not possible or cost a lot of money.
|
||||
|
||||
Why i have to use ConLite?
|
||||
|
||||
You don't have to, but feel free to do it. ConLite will show you an easier way to upgrade step by step to Contenido
|
||||
4.10. The new version of Contenido has a lot of changes, so you have to do a lot of work
|
||||
with modules or custom plugins to adapt them to the new version. That's not what ConLite does nor will
|
||||
do in the future. ConLite will do changes step by step, or better version by version to adapt your
|
||||
4.8.x or higher installation to work with the new 4.9 of Contenido. And ConLite will try to give you a
|
||||
stable and bugfixed Content-Management-System in the future.
|
||||
|
||||
Who are the people behind ConLite?
|
||||
|
||||
The Team behind the CL-version are some well known guys from CONTENIDO-forum, working since many years with
|
||||
and within CONTENIDO core or coding modules and plugins for CONTENIDO.
|
||||
And we love CONTENIDO :)
|
||||
|
||||
|
||||
** Copyright **
|
||||
|
||||
The copyright for the code of CONTENIDO still remains to 4fb and the named coders for all codes coming
|
||||
from 4.8.15 and/or from svn- or git-repository of CONTENDIO.
|
||||
All ads, enhancements or new parts, coded by the CL-Team are copyright by their named coders or
|
||||
by CL-Team and conlite.org.
|
||||
|
||||
|
||||
** Know Bugs **
|
||||
FS#25 - Collision with pre-installed AMR after Migration
|
||||
!!! Attention !!!
|
||||
If you want to upgrade with an installed AMR-plugin, uninstall AMR before upgrade.
|
||||
We will include a fix for that in one of the next versions of CL
|
||||
|
||||
|
||||
** History / Changelog **
|
||||
ConLite 2.1.2
|
||||
ConLite 2.1.1
|
||||
ConLite 2.1.0
|
||||
* see https://gitport.de/ConLite/ConLite/milestones
|
||||
|
||||
ConLite 2.0
|
||||
ConLite 1.0
|
||||
* old svn history lost
|
||||
|
||||
CONTENIDO 4.8.16 CL
|
||||
* 20 Bug Report genericdb: urlencode() expects parameter 1 to be string ...
|
||||
* 16 Enhancement RSS-Reader austauschen/überarbeiten
|
||||
* 31 Optimization Test CL installation with newest PHP and SQL on XAMPP
|
||||
* 3 Bug Report Genericdb caching not working
|
||||
* 37 Bug Report Upgrade: valid_from and valid_to fields are set to NULL
|
||||
* 33 Bug Report Missing include.subnav_blank.php
|
||||
* 22 Bug Report Modul xhtml which is not choosable in modularea
|
||||
* 10 Optimization Generate API-Doc
|
||||
* 34 Bug Report Error when searching article with no criteria
|
||||
* 24 Bug Report No reset of subnavigation if a layout is deleted
|
||||
* 15 Optimization Add CL readme file
|
||||
* 13 Bug Report FEUser-Plugins valide_to and valide_from saving wrong t ...
|
||||
* 9 Enhancement Check all translations (i18n)
|
||||
* 8 Bug Report adapt genericdb from 4.8.17 CL
|
||||
* 5 Bug Report Buttontranslations missing or wrong
|
78
README_.txt
78
README_.txt
|
@ -1,78 +0,0 @@
|
|||
$Id$
|
||||
----------------------------------------------------------------------------------------------------
|
||||
This is the readme file for ConLite 2.1
|
||||
|
||||
Any help you need you may find by visiting the following links.
|
||||
|
||||
CL-Portal http//conlite.org
|
||||
CL-Forum http://forum.conlite.org
|
||||
CL-Bugtracker http://bugs.conlite.org
|
||||
CL-API-Doc http://conlite.conrepo.org/api/4.8.16CL
|
||||
|
||||
!!! Attention !!!
|
||||
We tried to fix all known bugs of 4.8.15 and earlier but cannot give any garanties for that. So use
|
||||
it on your own risk. If you find any bug or have any idea to enhance ConLite, feel free to visit our
|
||||
bugtracker and register at http://bugs.conlite.org
|
||||
Any help and ideas are welcome :)
|
||||
|
||||
** Mini FAQ **
|
||||
|
||||
What is ConLite (-Edition) of CONTENIDO?
|
||||
|
||||
CL (short for ConLite) is dedicated to close the gap between CONTENIDO 4.8.15 and the version 4.9.
|
||||
In downloadable 4.8.20 (and former 4.8.15) are still a lot of bugs and some missing feautures and
|
||||
enhancements so one cannot use the version without problems. Our goal is to give you a bugfixed and
|
||||
really stable version of CONTENIDO till the 4.9 is stable. By the way, there are still a lot of big sides
|
||||
build with 4.8.x out there where upgrading to 4.9.x is not possible or cost a lot of money.
|
||||
|
||||
Why i have to use ConLite?
|
||||
|
||||
You don't have to, but feel free to do it. ConLite will show you an easier way to upgrade to CONTENIDO
|
||||
4.9. The new version of CONTENIDO will have a lot of changes, so you have to do a lot of work
|
||||
with modules or custom plugins to adapt them to the new version. That's not what ConLite does nor will
|
||||
do in the future. ConLite will do changes step by step, or better version by version to adapt your
|
||||
4.8.15 or higher installation to work with the new 4.9 of CONTENIDO. And ConLite will try to give you a
|
||||
stable and bugfixed CONTENIDO 4.8.x in the future.
|
||||
|
||||
Who are the people behind ConLite?
|
||||
|
||||
The Team behind the CL-version are some well known guys from CONTENIDO-forum, working since many years with
|
||||
and within CONTENIDO core or coding modules and plugins for CONTENIDO.
|
||||
And we love CONTENIDO :)
|
||||
|
||||
|
||||
** Copyright **
|
||||
|
||||
The copyright for the code of CONTENIDO still remains to 4fb and the named coders for all codes coming
|
||||
from 4.8.15 and/or from svn-repository of CONTENDIO.
|
||||
All ads, enhancements or new parts, coded by the CL-Team are copyright by their named coders or
|
||||
by CL-Team and conlite.org.
|
||||
|
||||
|
||||
** Know Bugs **
|
||||
FS#25 - Collision with pre-installed AMR after Migration
|
||||
!!! Attention !!!
|
||||
If you want to upgrade with an installed AMR-plugin, uninstall AMR before upgrade.
|
||||
We will include a fix for that in one of the next versions of CL
|
||||
|
||||
|
||||
** History / Changelog **
|
||||
|
||||
ConLite 1.0
|
||||
|
||||
CONTENIDO 4.8.16 CL
|
||||
20 Bug Report genericdb: urlencode() expects parameter 1 to be string ...
|
||||
16 Enhancement RSS-Reader austauschen/überarbeiten
|
||||
31 Optimization Test CL installation with newest PHP and SQL on XAMPP
|
||||
3 Bug Report Genericdb caching not working
|
||||
37 Bug Report Upgrade: valid_from and valid_to fields are set to NULL
|
||||
33 Bug Report Missing include.subnav_blank.php
|
||||
22 Bug Report Modul xhtml which is not choosable in modularea
|
||||
10 Optimization Generate API-Doc
|
||||
34 Bug Report Error when searching article with no criteria
|
||||
24 Bug Report No reset of subnavigation if a layout is deleted
|
||||
15 Optimization Add CL readme file
|
||||
13 Bug Report FEUser-Plugins valide_to and valide_from saving wrong t ...
|
||||
9 Enhancement Check all translations (i18n)
|
||||
8 Bug Report adapt genericdb from 4.8.17 CL
|
||||
5 Bug Report Buttontranslations missing or wrong
|
|
@ -0,0 +1,4 @@
|
|||
# Ignore everything in this directory
|
||||
*
|
||||
# Except this file
|
||||
!.gitignore
|
|
@ -0,0 +1 @@
|
|||
|
|
@ -0,0 +1,2 @@
|
|||
/local
|
||||
/localhost
|
|
@ -0,0 +1 @@
|
|||
|
|
@ -0,0 +1 @@
|
|||
|
|
@ -0,0 +1 @@
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Project:
|
||||
* Contenido Content Management System
|
||||
|
@ -42,7 +43,6 @@
|
|||
* @link http://www.contenido.org
|
||||
* @since file available since contenido release <= 4.6
|
||||
*/
|
||||
|
||||
if (!defined("CON_FRAMEWORK")) {
|
||||
define("CON_FRAMEWORK", true);
|
||||
}
|
||||
|
@ -59,11 +59,10 @@ cInclude("includes", "functions.con2.php");
|
|||
cInclude("includes", "functions.api.php");
|
||||
cInclude("includes", "functions.pathresolver.php");
|
||||
|
||||
if ($cfg["use_pseudocron"] == true)
|
||||
{
|
||||
if ($cfg["use_pseudocron"] == true) {
|
||||
/* Include cronjob-Emulator */
|
||||
$oldpwd = getcwd();
|
||||
chdir($cfg["path"]["contenido"].$cfg["path"]["cronjobs"]);
|
||||
chdir($cfg["path"]["contenido"] . $cfg["path"]["cronjobs"]);
|
||||
cInclude("includes", "pseudo-cron.inc.php");
|
||||
chdir($oldpwd);
|
||||
}
|
||||
|
@ -73,16 +72,13 @@ if ($cfg["use_pseudocron"] == true)
|
|||
* PHPLIB application development toolkit
|
||||
* @see http://sourceforge.net/projects/phplib
|
||||
*/
|
||||
if ($contenido)
|
||||
{
|
||||
if ($contenido) {
|
||||
//Backend
|
||||
page_open(array ('sess' => 'Contenido_Session', 'auth' => 'Contenido_Challenge_Crypt_Auth', 'perm' => 'Contenido_Perm'));
|
||||
i18nInit($cfg["path"]["contenido"].$cfg["path"]["locale"], $belang);
|
||||
}
|
||||
else
|
||||
{
|
||||
page_open(array('sess' => 'Contenido_Session', 'auth' => 'Contenido_Challenge_Crypt_Auth', 'perm' => 'Contenido_Perm'));
|
||||
i18nInit($cfg["path"]["contenido"] . $cfg["path"]["locale"], $belang);
|
||||
} else {
|
||||
//Frontend
|
||||
page_open(array ('sess' => 'Contenido_Frontend_Session', 'auth' => 'Contenido_Frontend_Challenge_Crypt_Auth', 'perm' => 'Contenido_Perm'));
|
||||
page_open(array('sess' => 'Contenido_Frontend_Session', 'auth' => 'Contenido_Frontend_Challenge_Crypt_Auth', 'perm' => 'Contenido_Perm'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -106,20 +102,19 @@ $sess->register("errsite_idcat");
|
|||
$sess->register("errsite_idart");
|
||||
$sess->register("encoding");
|
||||
|
||||
if ($cfgClient["set"] != "set")
|
||||
{
|
||||
if ($cfgClient["set"] != "set") {
|
||||
rereadClients();
|
||||
}
|
||||
|
||||
# Check if this request is for a compressed file
|
||||
if ($_GET['action'] == 'get_compressed') {
|
||||
# Get the calling parameters
|
||||
$sFilename = ((isset($_GET['f'])) ? $_GET['f'] : $_GET['amp;f']);
|
||||
$sContentType = ((isset($_GET['c'])) ? $_GET['c'] : $_GET['amp;c']);
|
||||
|
||||
$sFilename = ((isset($_GET['f'])) ? $_GET['f'] : $_GET['amp;f']);
|
||||
$sContentType = ((isset($_GET['c'])) ? $_GET['c'] : $_GET['amp;c']);
|
||||
|
||||
# Output the file using the class output() function
|
||||
Output_Compressor::output($cfgClient[$client]['path']['frontend'] . 'cache/', $sFilename, $sContentType);
|
||||
|
||||
|
||||
# Don't do anything else
|
||||
exit();
|
||||
}
|
||||
|
@ -127,8 +122,7 @@ if ($_GET['action'] == 'get_compressed') {
|
|||
// Call hook after plugins are loaded, added by Murat Purc, 2008-09-07
|
||||
CEC_Hook::execute('Contenido.Frontend.AfterLoadPlugins');
|
||||
|
||||
if (!isset($encoding) || !is_array($encoding) || count($encoding) == 0)
|
||||
{
|
||||
if (!isset($encoding) || !is_array($encoding) || count($encoding) == 0) {
|
||||
// get encodings of all languages
|
||||
$encoding = array();
|
||||
$sql = "SELECT idlang, encoding FROM " . $cfg["tab"]["lang"];
|
||||
|
@ -152,18 +146,18 @@ Contenido_Url::getInstance()->getUrlBuilder()->setHttpBasePath($cfgClient[$clien
|
|||
if (!isset($lang)) {
|
||||
|
||||
// if there is an entry load_lang in frontend/config.php use it, else use the first language of this client
|
||||
if(isset($load_lang)){
|
||||
if (isset($load_lang)) {
|
||||
// load_client is set in frontend/config.php
|
||||
$lang = $load_lang;
|
||||
}else{
|
||||
} else {
|
||||
|
||||
$sql = "SELECT
|
||||
B.idlang
|
||||
FROM
|
||||
".$cfg["tab"]["clients_lang"]." AS A,
|
||||
".$cfg["tab"]["lang"]." AS B
|
||||
" . $cfg["tab"]["clients_lang"] . " AS A,
|
||||
" . $cfg["tab"]["lang"] . " AS B
|
||||
WHERE
|
||||
A.idclient='".Contenido_Security::toInteger($client)."' AND
|
||||
A.idclient='" . Contenido_Security::toInteger($client) . "' AND
|
||||
A.idlang = B.idlang
|
||||
LIMIT
|
||||
0,1";
|
||||
|
@ -175,11 +169,12 @@ if (!isset($lang)) {
|
|||
}
|
||||
}
|
||||
|
||||
if (!$sess->is_registered("lang") ) $sess->register("lang");
|
||||
if (!$sess->is_registered("client") ) $sess->register("client");
|
||||
if (!$sess->is_registered("lang"))
|
||||
$sess->register("lang");
|
||||
if (!$sess->is_registered("client"))
|
||||
$sess->register("client");
|
||||
|
||||
if (isset ($username))
|
||||
{
|
||||
if (isset($username)) {
|
||||
$auth->login_if(true);
|
||||
}
|
||||
|
||||
|
@ -192,8 +187,7 @@ header("Content-Type: text/html; charset={$encoding[$lang]}");
|
|||
* if http global logout is set e.g. front_content.php?logout=true
|
||||
* log out the current user.
|
||||
*/
|
||||
if (isset ($logout))
|
||||
{
|
||||
if (isset($logout)) {
|
||||
$auth->logout(true);
|
||||
$auth->unauth(true);
|
||||
$auth->auth["uname"] = "nobody";
|
||||
|
@ -202,8 +196,7 @@ if (isset ($logout))
|
|||
/*
|
||||
* local configuration
|
||||
*/
|
||||
if (file_exists("config.local.php"))
|
||||
{
|
||||
if (file_exists("config.local.php")) {
|
||||
@ include ("config.local.php");
|
||||
}
|
||||
|
||||
|
@ -211,32 +204,26 @@ if (file_exists("config.local.php"))
|
|||
* If the path variable was passed, try to resolve it to a Category Id
|
||||
* e.g. front_content.php?path=/company/products/
|
||||
*/
|
||||
if (isset($path) && strlen($path) > 1)
|
||||
{
|
||||
if (isset($path) && strlen($path) > 1) {
|
||||
/* Which resolve method is configured? */
|
||||
if ($cfg["urlpathresolve"] == true)
|
||||
{
|
||||
if ($cfg["urlpathresolve"] == true) {
|
||||
|
||||
$iLangCheck = 0;
|
||||
$idcat = prResolvePathViaURLNames($path, $iLangCheck);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$iLangCheck = 0;
|
||||
|
||||
$idcat = prResolvePathViaCategoryNames($path, $iLangCheck);
|
||||
if(($lang != $iLangCheck) && ((int)$iLangCheck != 0)){
|
||||
if (($lang != $iLangCheck) && ((int) $iLangCheck != 0)) {
|
||||
$lang = $iLangCheck;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// error page
|
||||
$aParams = array (
|
||||
'client' => $client, 'idcat' => $errsite_idcat[$client], 'idart' => $errsite_idart[$client],
|
||||
'lang' => $lang, 'error'=> '1'
|
||||
$aParams = array(
|
||||
'client' => $client, 'idcat' => $errsite_idcat[$client], 'idart' => $errsite_idart[$client],
|
||||
'lang' => $lang, 'error' => '1'
|
||||
);
|
||||
$errsite = 'Location: ' . Contenido_Url::getInstance()->buildRedirect($aParams);
|
||||
|
||||
|
@ -246,66 +233,58 @@ $errsite = 'Location: ' . Contenido_Url::getInstance()->buildRedirect($aParams);
|
|||
* Note: These variables can be set via http globals e.g. front_content.php?idcat=41&idart=34&idcatart=35&idartlang=42
|
||||
* If not the values will be computed.
|
||||
*/
|
||||
if ($idart && !$idcat && !$idcatart)
|
||||
{
|
||||
if ($idart && !$idcat && !$idcatart) {
|
||||
/* Try to fetch the first idcat */
|
||||
$sql = "SELECT idcat FROM ".$cfg["tab"]["cat_art"]." WHERE idart = '".Contenido_Security::toInteger($idart)."'";
|
||||
$sql = "SELECT idcat FROM " . $cfg["tab"]["cat_art"] . " WHERE idart = '" . Contenido_Security::toInteger($idart) . "'";
|
||||
$db->query($sql);
|
||||
|
||||
if ($db->next_record())
|
||||
{
|
||||
if ($db->next_record()) {
|
||||
$idcat = $db->f("idcat");
|
||||
}
|
||||
}
|
||||
|
||||
unset ($code);
|
||||
unset ($markscript);
|
||||
unset($code);
|
||||
unset($markscript);
|
||||
|
||||
if (!$idcatart)
|
||||
{
|
||||
if (!$idart)
|
||||
{
|
||||
if (!$idcat)
|
||||
{
|
||||
if (!$idcatart) {
|
||||
if (!$idart) {
|
||||
if (!$idcat) {
|
||||
# Note: In earlier Contenido versions the information if an article is startarticle of a category has been stored
|
||||
# in relation con_cat_art.
|
||||
if ($cfg["is_start_compatible"] == true)
|
||||
{
|
||||
if ($cfg["is_start_compatible"] == true) {
|
||||
$sql = "SELECT
|
||||
idart,
|
||||
B.idcat
|
||||
FROM
|
||||
".$cfg["tab"]["cat_art"]." AS A,
|
||||
".$cfg["tab"]["cat_tree"]." AS B,
|
||||
".$cfg["tab"]["cat"]." AS C
|
||||
" . $cfg["tab"]["cat_art"] . " AS A,
|
||||
" . $cfg["tab"]["cat_tree"] . " AS B,
|
||||
" . $cfg["tab"]["cat"] . " AS C
|
||||
WHERE
|
||||
A.idcat=B.idcat AND
|
||||
B.idcat=C.idcat AND
|
||||
is_start='1' AND
|
||||
idclient='".Contenido_Security::toInteger($client)."'
|
||||
idclient='" . Contenido_Security::toInteger($client) . "'
|
||||
ORDER BY
|
||||
idtree ASC";
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
# Note: Now the information if an article is startarticle of a category is stored in relation con_cat_lang.
|
||||
$sql = "SELECT
|
||||
A.idart,
|
||||
B.idcat
|
||||
FROM
|
||||
".$cfg["tab"]["cat_art"]." AS A,
|
||||
".$cfg["tab"]["cat_tree"]." AS B,
|
||||
".$cfg["tab"]["cat"]." AS C,
|
||||
".$cfg["tab"]["cat_lang"]." AS D,
|
||||
".$cfg["tab"]["art_lang"]." AS E
|
||||
" . $cfg["tab"]["cat_art"] . " AS A,
|
||||
" . $cfg["tab"]["cat_tree"] . " AS B,
|
||||
" . $cfg["tab"]["cat"] . " AS C,
|
||||
" . $cfg["tab"]["cat_lang"] . " AS D,
|
||||
" . $cfg["tab"]["art_lang"] . " AS E
|
||||
WHERE
|
||||
A.idcat=B.idcat AND
|
||||
B.idcat=C.idcat AND
|
||||
D.startidartlang = E.idartlang AND
|
||||
D.idlang='".Contenido_Security::toInteger($lang)."' AND
|
||||
D.idlang='" . Contenido_Security::toInteger($lang) . "' AND
|
||||
E.idart=A.idart AND
|
||||
E.idlang='".Contenido_Security::toInteger($lang)."' AND
|
||||
idclient='".Contenido_Security::toInteger($client)."'
|
||||
E.idlang='" . Contenido_Security::toInteger($lang) . "' AND
|
||||
idclient='" . Contenido_Security::toInteger($client) . "'
|
||||
ORDER BY
|
||||
idtree ASC";
|
||||
}
|
||||
|
@ -316,40 +295,34 @@ if (!$idcatart)
|
|||
$idart = $db->f("idart");
|
||||
$idcat = $db->f("idcat");
|
||||
} else {
|
||||
if($contenido) {
|
||||
if ($contenido) {
|
||||
cInclude("includes", "functions.i18n.php");
|
||||
die(i18n("No start article for this category"));
|
||||
} else {
|
||||
if($error == 1) {
|
||||
if ($error == 1) {
|
||||
die("Fatal error: Could not display error page. Error to display was: 'No start article in this category'");
|
||||
} else {
|
||||
header($errsite);
|
||||
exit;
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$idart = -1;
|
||||
if ($cfg["is_start_compatible"] == true)
|
||||
{
|
||||
$sql = "SELECT idart FROM ".$cfg["tab"]["cat_art"]." WHERE idcat='".Contenido_Security::toInteger($idcat)."' AND is_start='1'";
|
||||
if ($cfg["is_start_compatible"] == true) {
|
||||
$sql = "SELECT idart FROM " . $cfg["tab"]["cat_art"] . " WHERE idcat='" . Contenido_Security::toInteger($idcat) . "' AND is_start='1'";
|
||||
$db->query($sql);
|
||||
|
||||
if ($db->next_record())
|
||||
{
|
||||
if ($db->next_record()) {
|
||||
$idart = $db->f("idart");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql = "SELECT startidartlang FROM ".$cfg["tab"]["cat_lang"]." WHERE idcat='".Contenido_Security::toInteger($idcat)."' AND idlang='".Contenido_Security::toInteger($lang)."'";
|
||||
} else {
|
||||
$sql = "SELECT startidartlang FROM " . $cfg["tab"]["cat_lang"] . " WHERE idcat='" . Contenido_Security::toInteger($idcat) . "' AND idlang='" . Contenido_Security::toInteger($lang) . "'";
|
||||
$db->query($sql);
|
||||
|
||||
if ($db->next_record())
|
||||
{
|
||||
if ($db->f("startidartlang") != 0)
|
||||
{
|
||||
$sql = "SELECT idart FROM ".$cfg["tab"]["art_lang"]." WHERE idartlang='".Contenido_Security::toInteger($db->f("startidartlang"))."'";
|
||||
if ($db->next_record()) {
|
||||
if ($db->f("startidartlang") != 0) {
|
||||
$sql = "SELECT idart FROM " . $cfg["tab"]["art_lang"] . " WHERE idartlang='" . Contenido_Security::toInteger($db->f("startidartlang")) . "'";
|
||||
$db->query($sql);
|
||||
$db->next_record();
|
||||
$idart = $db->f("idart");
|
||||
|
@ -357,36 +330,26 @@ if (!$idcatart)
|
|||
}
|
||||
}
|
||||
|
||||
if ($idart != -1)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($idart != -1) {
|
||||
|
||||
} else {
|
||||
// error message in backend
|
||||
if ($contenido)
|
||||
{
|
||||
if ($contenido) {
|
||||
cInclude("includes", "functions.i18n.php");
|
||||
die(i18n("No start article for this category"));
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($error == 1)
|
||||
{
|
||||
} else {
|
||||
if ($error == 1) {
|
||||
echo "Fatal error: Could not display error page. Error to display was: 'No start article in this category'";
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
header($errsite);
|
||||
exit;
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql = "SELECT idcat, idart FROM ".$cfg["tab"]["cat_art"]." WHERE idcatart='".Contenido_Security::toInteger($idcatart)."'";
|
||||
} else {
|
||||
$sql = "SELECT idcat, idart FROM " . $cfg["tab"]["cat_art"] . " WHERE idcatart='" . Contenido_Security::toInteger($idcatart) . "'";
|
||||
|
||||
$db->query($sql);
|
||||
$db->next_record();
|
||||
|
@ -396,9 +359,8 @@ else
|
|||
}
|
||||
|
||||
/* Get idcatart */
|
||||
if (0 != $idart && 0 != $idcat)
|
||||
{
|
||||
$sql = "SELECT idcatart FROM ".$cfg["tab"]["cat_art"]." WHERE idart = '".Contenido_Security::toInteger($idart)."' AND idcat = '".Contenido_Security::toInteger($idcat)."'";
|
||||
if (0 != $idart && 0 != $idcat) {
|
||||
$sql = "SELECT idcatart FROM " . $cfg["tab"]["cat_art"] . " WHERE idart = '" . Contenido_Security::toInteger($idart) . "' AND idcat = '" . Contenido_Security::toInteger($idcat) . "'";
|
||||
|
||||
$db->query($sql);
|
||||
$db->next_record();
|
||||
|
@ -408,10 +370,9 @@ if (0 != $idart && 0 != $idcat)
|
|||
|
||||
$idartlang = getArtLang($idart, $lang);
|
||||
|
||||
if ($idartlang === false)
|
||||
{
|
||||
if ($idartlang === false) {
|
||||
header($errsite);
|
||||
exit;
|
||||
exit;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -427,8 +388,6 @@ if ($cfg["cache"]["disable"] != '1') {
|
|||
$oCacheHandler->start($iStartTime); // $iStartTime ist optional und ist die startzeit des scriptes, z. b. am anfang von fron_content.php
|
||||
}
|
||||
// END: concache
|
||||
|
||||
|
||||
##############################################
|
||||
# BACKEND / FRONTEND EDITING
|
||||
##############################################
|
||||
|
@ -443,44 +402,39 @@ if ($cfg["cache"]["disable"] != '1') {
|
|||
* The reason is to avoid cross-site scripting errors in the backend, if the backend domain differs from
|
||||
* the frontend domain.
|
||||
*/
|
||||
if ($contenido)
|
||||
{
|
||||
if ($contenido) {
|
||||
$perm->load_permissions();
|
||||
|
||||
/* Change mode edit / view */
|
||||
if (isset ($changeview))
|
||||
{
|
||||
if (isset($changeview)) {
|
||||
$sess->register("view");
|
||||
$view = $changeview;
|
||||
}
|
||||
|
||||
$col = new InUseCollection;
|
||||
|
||||
if ($overrideid != "" && $overridetype != "")
|
||||
{
|
||||
if ($overrideid != "" && $overridetype != "") {
|
||||
$col->removeItemMarks($overridetype, $overrideid);
|
||||
}
|
||||
/* Remove all own marks */
|
||||
$col->removeSessionMarks($sess->id);
|
||||
/* If the override flag is set, override a specific InUseItem */
|
||||
|
||||
list ($inUse, $message) = $col->checkAndMark("article", $idartlang, true, i18n("Article is in use by %s (%s)"), true, $cfg['path']['contenido_fullhtml']."external/backendedit/front_content.php?changeview=edit&action=con_editart&idartlang=$idartlang&type=$type&typenr=$typenr&idart=$idart&idcat=$idcat&idcatart=$idcatart&client=$client&lang=$lang");
|
||||
list ($inUse, $message) = $col->checkAndMark("article", $idartlang, true, i18n("Article is in use by %s (%s)"), true, $cfg['path']['contenido_fullhtml'] . "external/backendedit/front_content.php?changeview=edit&action=con_editart&idartlang=$idartlang&type=$type&typenr=$typenr&idart=$idart&idcat=$idcat&idcatart=$idcatart&client=$client&lang=$lang");
|
||||
|
||||
$sHtmlInUse = '';
|
||||
$sHtmlInUseMessage = '';
|
||||
if ($inUse == true)
|
||||
{
|
||||
if ($inUse == true) {
|
||||
$disabled = 'disabled="disabled"';
|
||||
$sHtmlInUseCss = '<link rel="stylesheet" type="text/css" href="'.$cfg['path']['contenido_fullhtml'].'styles/inuse.css" />';
|
||||
$sHtmlInUseCss = '<link rel="stylesheet" type="text/css" href="' . $cfg['path']['contenido_fullhtml'] . 'styles/inuse.css" />';
|
||||
$sHtmlInUseMessage = $message;
|
||||
}
|
||||
|
||||
$sql = "SELECT locked FROM ".$cfg["tab"]["art_lang"]." WHERE idart='".Contenido_Security::toInteger($idart)."' AND idlang = '".Contenido_Security::toInteger($lang)."'";
|
||||
$sql = "SELECT locked FROM " . $cfg["tab"]["art_lang"] . " WHERE idart='" . Contenido_Security::toInteger($idart) . "' AND idlang = '" . Contenido_Security::toInteger($lang) . "'";
|
||||
$db->query($sql);
|
||||
$db->next_record();
|
||||
$locked = $db->f("locked");
|
||||
if ($locked == 1)
|
||||
{
|
||||
if ($locked == 1) {
|
||||
$inUse = true;
|
||||
$disabled = 'disabled="disabled"';
|
||||
}
|
||||
|
@ -488,47 +442,40 @@ if ($contenido)
|
|||
// CEC to check if the user has permission to edit articles in this category
|
||||
CEC_Hook::setBreakCondition(false, true); // break at "false", default value "true"
|
||||
$allow = CEC_Hook::executeWhileBreakCondition(
|
||||
'Contenido.Frontend.AllowEdit', $lang, $idcat, $idart, $auth->auth['uid']
|
||||
'Contenido.Frontend.AllowEdit', $lang, $idcat, $idart, $auth->auth['uid']
|
||||
);
|
||||
|
||||
if ($perm->have_perm_area_action_item("con_editcontent", "con_editart", $idcat) && $inUse == false && $allow == true)
|
||||
{
|
||||
if ($perm->have_perm_area_action_item("con_editcontent", "con_editart", $idcat) && $inUse == false && $allow == true) {
|
||||
/* Create buttons for editing */
|
||||
$edit_preview = '<table cellspacing="0" cellpadding="4" border="0">';
|
||||
|
||||
if ($view == "edit")
|
||||
{
|
||||
if ($view == "edit") {
|
||||
$edit_preview = '<tr>
|
||||
<td width="18">
|
||||
<a title="Preview" style="font-family: Verdana; font-size: 10px; color: #000000; text-decoration: none" href="'.$sess->url("front_content.php?changeview=prev&idcat=$idcat&idart=$idart").'"><img src="'.$cfg["path"]["contenido_fullhtml"].$cfg["path"]["images"].'but_preview.gif" alt="Preview" title="Preview" border="0"></a>
|
||||
<a title="Preview" style="font-family: Verdana; font-size: 10px; color: #000000; text-decoration: none" href="' . $sess->url("front_content.php?changeview=prev&idcat=$idcat&idart=$idart") . '"><img src="' . $cfg["path"]["contenido_fullhtml"] . $cfg["path"]["images"] . 'but_preview.gif" alt="Preview" title="Preview" border="0"></a>
|
||||
</td>
|
||||
<td width="18">
|
||||
<a title="Preview" style="font-family: Verdana; font-size: 10px; color: #000000; text-decoration: none" href="'.$sess->url("front_content.php?changeview=prev&idcat=$idcat&idart=$idart").'">Preview</a>
|
||||
<a title="Preview" style="font-family: Verdana; font-size: 10px; color: #000000; text-decoration: none" href="' . $sess->url("front_content.php?changeview=prev&idcat=$idcat&idart=$idart") . '">Preview</a>
|
||||
</td>
|
||||
</tr>';
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$edit_preview = '<tr>
|
||||
<td width="18">
|
||||
<a title="Preview" style="font-family: Verdana; font-size: 10px; color: #000000; text-decoration: none" href="'.$sess->url("front_content.php?changeview=edit&idcat=$idcat&idart=$idart").'"><img src="'.$cfg["path"]["contenido_fullhtml"].$cfg["path"]["images"].'but_edit.gif" alt="Preview" title="Preview" border="0"></a>
|
||||
<a title="Preview" style="font-family: Verdana; font-size: 10px; color: #000000; text-decoration: none" href="' . $sess->url("front_content.php?changeview=edit&idcat=$idcat&idart=$idart") . '"><img src="' . $cfg["path"]["contenido_fullhtml"] . $cfg["path"]["images"] . 'but_edit.gif" alt="Preview" title="Preview" border="0"></a>
|
||||
</td>
|
||||
<td width="18">
|
||||
<a title="Preview" style="font-family: Verdana; font-size: 10px; color: #000000; text-decoration: none" href="'.$sess->url("front_content.php?changeview=edit&idcat=$idcat&idart=$idart").'">Edit</a>
|
||||
<a title="Preview" style="font-family: Verdana; font-size: 10px; color: #000000; text-decoration: none" href="' . $sess->url("front_content.php?changeview=edit&idcat=$idcat&idart=$idart") . '">Edit</a>
|
||||
</td>
|
||||
</tr>';
|
||||
}
|
||||
|
||||
/* Display articles */
|
||||
if ($cfg["is_start_compatible"] == true)
|
||||
{
|
||||
$sql = "SELECT idart, is_start FROM ".$cfg["tab"]["cat_art"]." WHERE idcat='".Contenido_Security::toInteger($idcat)."' ORDER BY idart";
|
||||
if ($cfg["is_start_compatible"] == true) {
|
||||
$sql = "SELECT idart, is_start FROM " . $cfg["tab"]["cat_art"] . " WHERE idcat='" . Contenido_Security::toInteger($idcat) . "' ORDER BY idart";
|
||||
|
||||
$db->query($sql);
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql = "SELECT idart FROM ".$cfg["tab"]["cat_art"]." WHERE idcat='".Contenido_Security::toInteger($idcat)."' ORDER BY idart";
|
||||
} else {
|
||||
$sql = "SELECT idart FROM " . $cfg["tab"]["cat_art"] . " WHERE idcat='" . Contenido_Security::toInteger($idcat) . "' ORDER BY idart";
|
||||
|
||||
$db->query($sql);
|
||||
}
|
||||
|
@ -537,53 +484,41 @@ if ($contenido)
|
|||
|
||||
$edit_preview .= '<tr><td colspan="2"><table cellspacing="0" cellpadding="2" border="0"></tr><td style="font-family: verdana; font-size:10; color:#000000; text-decoration:none">Articles in category:<br>';
|
||||
|
||||
while ($db->next_record() && ($db->affected_rows() != 1))
|
||||
{
|
||||
while ($db->next_record() && ($db->affected_rows() != 1)) {
|
||||
|
||||
$class = "font-family:'Verdana'; font-size:10; color:#000000; text-decoration: underline; font-weight:normal";
|
||||
if (!isset ($idart))
|
||||
{
|
||||
if (isStartArticle(getArtLang($idart, $lang), $idcat, $lang))
|
||||
{
|
||||
if (!isset($idart)) {
|
||||
if (isStartArticle(getArtLang($idart, $lang), $idcat, $lang)) {
|
||||
$class = "font-family: verdana; font-size:10; color:#000000; text-decoration: underline ;font-weight:bold";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($idart == $db->f("idart"))
|
||||
{
|
||||
} else {
|
||||
if ($idart == $db->f("idart")) {
|
||||
$class = "font-family: verdana; font-size:10; color:#000000; text-decoration: underline; font-weight:bold";
|
||||
}
|
||||
}
|
||||
|
||||
$edit_preview .= "<a style=\"$class\" href=\"".$sess->url("front_content.php?idart=".$db->f("idart")."&idcat=$idcat")."\">$a</a> ";
|
||||
$a ++;
|
||||
$edit_preview .= "<a style=\"$class\" href=\"" . $sess->url("front_content.php?idart=" . $db->f("idart") . "&idcat=$idcat") . "\">$a</a> ";
|
||||
$a++;
|
||||
}
|
||||
|
||||
$edit_preview .= '</td></tr></table></td></tr></table>';
|
||||
|
||||
}
|
||||
|
||||
} // end if $contenido
|
||||
|
||||
|
||||
/* If mode is 'edit' and user has permission to edit articles in the current category */
|
||||
if ($inUse == false && $allow == true && $view == "edit" && ($perm->have_perm_area_action_item("con_editcontent", "con_editart", $idcat)))
|
||||
{
|
||||
if ($inUse == false && $allow == true && $view == "edit" && ($perm->have_perm_area_action_item("con_editcontent", "con_editart", $idcat))) {
|
||||
cInclude("includes", "functions.tpl.php");
|
||||
cInclude("includes", "functions.con.php");
|
||||
include ($cfg["path"]["contenido"].$cfg["path"]["includes"]."include.con_editcontent.php");
|
||||
}
|
||||
else
|
||||
{
|
||||
include ($cfg["path"]["contenido"] . $cfg["path"]["includes"] . "include.con_editcontent.php");
|
||||
} else {
|
||||
|
||||
##############################################
|
||||
# FRONTEND VIEW
|
||||
##############################################
|
||||
|
||||
/* Mark submenuitem 'Preview' in the Contenido Backend (Area: Contenido --> Articles --> Preview) */
|
||||
if ($contenido)
|
||||
{
|
||||
if ($contenido) {
|
||||
$markscript = markSubMenuItem(4, true);
|
||||
}
|
||||
|
||||
|
@ -593,10 +528,10 @@ else
|
|||
$sql = "SELECT
|
||||
createcode
|
||||
FROM
|
||||
".$cfg["tab"]["cat_art"]."
|
||||
" . $cfg["tab"]["cat_art"] . "
|
||||
WHERE
|
||||
idcat = '".Contenido_Security::toInteger($idcat)."' AND
|
||||
idart = '".Contenido_Security::toInteger($idart)."'";
|
||||
idcat = '" . Contenido_Security::toInteger($idcat) . "' AND
|
||||
idart = '" . Contenido_Security::toInteger($idart) . "'";
|
||||
|
||||
$db->query($sql);
|
||||
$db->next_record();
|
||||
|
@ -606,44 +541,36 @@ else
|
|||
##############################################
|
||||
|
||||
/* Check if code is expired, create new code if needed */
|
||||
if($db->f("createcode") == 0 && $force == 0 && $cfg['dceModEdit']['use'] !== true && $cfg['dceLayEdit']['use'] !== true) {
|
||||
$sql = "SELECT code FROM ".$cfg["tab"]["code"]." WHERE idcatart = '".Contenido_Security::toInteger($idcatart)."' AND idlang = '".Contenido_Security::toInteger($lang)."'";
|
||||
if ($db->f("createcode") == 0 && $force == 0 && $cfg['dceModEdit']['use'] !== true && $cfg['dceLayEdit']['use'] !== true) {
|
||||
$sql = "SELECT code FROM " . $cfg["tab"]["code"] . " WHERE idcatart = '" . Contenido_Security::toInteger($idcatart) . "' AND idlang = '" . Contenido_Security::toInteger($lang) . "'";
|
||||
$db->query($sql);
|
||||
|
||||
if ($db->num_rows() == 0)
|
||||
{
|
||||
if ($db->num_rows() == 0) {
|
||||
/* Include here for performance reasons */
|
||||
cInclude("includes", "functions.tpl.php");
|
||||
|
||||
conGenerateCode($idcat, $idart, $lang, $client);
|
||||
|
||||
$sql = "SELECT code FROM ".$cfg["tab"]["code"]." WHERE idcatart = '".Contenido_Security::toInteger($idcatart)."' AND idlang = '".Contenido_Security::toInteger($lang)."'";
|
||||
$sql = "SELECT code FROM " . $cfg["tab"]["code"] . " WHERE idcatart = '" . Contenido_Security::toInteger($idcatart) . "' AND idlang = '" . Contenido_Security::toInteger($lang) . "'";
|
||||
$db->query($sql);
|
||||
}
|
||||
|
||||
if ($db->next_record())
|
||||
{
|
||||
if ($db->next_record()) {
|
||||
$code = stripslashes($db->f("code"));
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
if ($contenido)
|
||||
$code = "echo \"No code available.\";";
|
||||
else
|
||||
{
|
||||
if ($error == 1)
|
||||
{
|
||||
else {
|
||||
if ($error == 1) {
|
||||
echo "Fatal error: Could not display error page. Error to display was: 'No code available'";
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
header($errsite);
|
||||
exit;
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$sql = "DELETE FROM ".$cfg["tab"]["code"]." WHERE idcatart = '".Contenido_Security::toInteger($idcatart)."'";
|
||||
$sql = "DELETE FROM " . $cfg["tab"]["code"] . " WHERE idcatart = '" . Contenido_Security::toInteger($idcatart) . "'";
|
||||
$db->query($sql);
|
||||
|
||||
cInclude("includes", "functions.con.php");
|
||||
|
@ -652,7 +579,7 @@ else
|
|||
|
||||
conGenerateCode($idcat, $idart, $lang, $client);
|
||||
|
||||
$sql = "SELECT code FROM ".$cfg["tab"]["code"]." WHERE idcatart = '".Contenido_Security::toInteger($idcatart)."' AND idlang = '".Contenido_Security::toInteger($lang)."'";
|
||||
$sql = "SELECT code FROM " . $cfg["tab"]["code"] . " WHERE idcatart = '" . Contenido_Security::toInteger($idcatart) . "' AND idlang = '" . Contenido_Security::toInteger($lang) . "'";
|
||||
|
||||
$db->query($sql);
|
||||
$db->next_record();
|
||||
|
@ -670,7 +597,7 @@ else
|
|||
}
|
||||
|
||||
/* Check if category is public */
|
||||
$sql = "SELECT public FROM ".$cfg["tab"]["cat_lang"]." WHERE idcat='".Contenido_Security::toInteger($idcat)."' AND idlang='".Contenido_Security::toInteger($lang)."'";
|
||||
$sql = "SELECT public FROM " . $cfg["tab"]["cat_lang"] . " WHERE idcat='" . Contenido_Security::toInteger($idcat) . "' AND idlang='" . Contenido_Security::toInteger($lang) . "'";
|
||||
|
||||
$db->query($sql);
|
||||
$db->next_record();
|
||||
|
@ -680,80 +607,68 @@ else
|
|||
##############################################
|
||||
# protected categories
|
||||
##############################################
|
||||
if ($public == 0)
|
||||
{
|
||||
if ($auth->auth["uid"] == "nobody")
|
||||
{
|
||||
$sql = "SELECT user_id, value FROM ".$cfg["tab"]["user_prop"]." WHERE type='frontend' and name='allowed_ip'";
|
||||
if ($public == 0) {
|
||||
if ($auth->auth["uid"] == "nobody") {
|
||||
$sql = "SELECT user_id, value FROM " . $cfg["tab"]["user_prop"] . " WHERE type='frontend' and name='allowed_ip'";
|
||||
$db->query($sql);
|
||||
|
||||
while ($db->next_record())
|
||||
{
|
||||
while ($db->next_record()) {
|
||||
$user_id = $db->f("user_id");
|
||||
|
||||
$range = urldecode($db->f("value"));
|
||||
$slash = strpos($range, "/");
|
||||
|
||||
if ($slash == false)
|
||||
{
|
||||
if ($slash == false) {
|
||||
$netmask = "255.255.255.255";
|
||||
$network = $range;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$network = substr($range, 0, $slash);
|
||||
$netmask = substr($range, $slash +1, strlen($range) - $slash -1);
|
||||
$netmask = substr($range, $slash + 1, strlen($range) - $slash - 1);
|
||||
}
|
||||
|
||||
if (IP_match($network, $netmask, $_SERVER["REMOTE_ADDR"]))
|
||||
{
|
||||
if (IP_match($network, $netmask, $_SERVER["REMOTE_ADDR"])) {
|
||||
$sql = "SELECT idright
|
||||
FROM ".$cfg["tab"]["rights"]." AS A,
|
||||
".$cfg["tab"]["actions"]." AS B,
|
||||
".$cfg["tab"]["area"]." AS C
|
||||
WHERE B.name = 'front_allow' AND C.name = 'str' AND A.user_id = '".Contenido_Security::escapeDB($user_id, $db2)."' AND A.idcat = '".Contenido_Security::toInteger($idcat)."'
|
||||
FROM " . $cfg["tab"]["rights"] . " AS A,
|
||||
" . $cfg["tab"]["actions"] . " AS B,
|
||||
" . $cfg["tab"]["area"] . " AS C
|
||||
WHERE B.name = 'front_allow' AND C.name = 'str' AND A.user_id = '" . Contenido_Security::escapeDB($user_id, $db2) . "' AND A.idcat = '" . Contenido_Security::toInteger($idcat) . "'
|
||||
AND A.idarea = C.idarea AND B.idaction = A.idaction";
|
||||
|
||||
$db2 = new DB_Contenido;
|
||||
$db2->query($sql);
|
||||
|
||||
if ($db2->num_rows() > 0)
|
||||
{
|
||||
if ($db2->num_rows() > 0) {
|
||||
$auth->auth["uid"] = $user_id;
|
||||
$validated = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($validated != 1)
|
||||
{
|
||||
if ($validated != 1) {
|
||||
// CEC to check category access
|
||||
CEC_Hook::setBreakCondition(true, false); // break at "true", default value "false"
|
||||
$allow = CEC_Hook::executeWhileBreakCondition(
|
||||
'Contenido.Frontend.CategoryAccess', $lang, $idcat, $auth->auth['uid']
|
||||
'Contenido.Frontend.CategoryAccess', $lang, $idcat, $auth->auth['uid']
|
||||
);
|
||||
$auth->login_if(!$allow);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
// CEC to check category access
|
||||
CEC_Hook::setBreakCondition(true, false); // break at "true", default value "false"
|
||||
$allow = CEC_Hook::executeWhileBreakCondition(
|
||||
'Contenido.Frontend.CategoryAccess', $lang, $idcat, $auth->auth['uid']
|
||||
'Contenido.Frontend.CategoryAccess', $lang, $idcat, $auth->auth['uid']
|
||||
);
|
||||
|
||||
/*
|
||||
added 2008-11-18 Timo Trautmann
|
||||
in backendeditmode also check if logged in backenduser has permission to view preview of page
|
||||
*/
|
||||
added 2008-11-18 Timo Trautmann
|
||||
in backendeditmode also check if logged in backenduser has permission to view preview of page
|
||||
*/
|
||||
if ($allow == false && $contenido && $perm->have_perm_area_action_item("con_editcontent", "con_editart", $idcat)) {
|
||||
$allow = true;
|
||||
}
|
||||
|
||||
if (!$allow)
|
||||
{
|
||||
if (!$allow) {
|
||||
header($errsite);
|
||||
exit;
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -767,24 +682,18 @@ else
|
|||
/*
|
||||
* Check if an article is start article of the category
|
||||
*/
|
||||
if ($cfg["is_start_compatible"] == true)
|
||||
{
|
||||
$sql = "SELECT is_start FROM ".$cfg["tab"]["cat_art"]." WHERE idcatart='".Contenido_Security::toInteger($idcatart)."'";
|
||||
if ($cfg["is_start_compatible"] == true) {
|
||||
$sql = "SELECT is_start FROM " . $cfg["tab"]["cat_art"] . " WHERE idcatart='" . Contenido_Security::toInteger($idcatart) . "'";
|
||||
$db->query($sql);
|
||||
$db->next_record();
|
||||
$isstart = $db->f("is_start");
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql = "SELECT startidartlang FROM ".$cfg["tab"]["cat_lang"]." WHERE idcat='".Contenido_Security::toInteger($idcat)."' AND idlang = '".Contenido_Security::toInteger($lang)."'";
|
||||
} else {
|
||||
$sql = "SELECT startidartlang FROM " . $cfg["tab"]["cat_lang"] . " WHERE idcat='" . Contenido_Security::toInteger($idcat) . "' AND idlang = '" . Contenido_Security::toInteger($lang) . "'";
|
||||
$db->query($sql);
|
||||
$db->next_record();
|
||||
if ($db->f("idartlang") == $idartlang)
|
||||
{
|
||||
if ($db->f("idartlang") == $idartlang) {
|
||||
$isstart = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$isstart = 0;
|
||||
}
|
||||
}
|
||||
|
@ -792,18 +701,15 @@ else
|
|||
##############################################
|
||||
# time management
|
||||
##############################################
|
||||
$sql = "SELECT timemgmt FROM ".$cfg["tab"]["art_lang"]." WHERE idart='".Contenido_Security::toInteger($idart)."' AND idlang = '".Contenido_Security::toInteger($lang)."'";
|
||||
$sql = "SELECT timemgmt FROM " . $cfg["tab"]["art_lang"] . " WHERE idart='" . Contenido_Security::toInteger($idart) . "' AND idlang = '" . Contenido_Security::toInteger($lang) . "'";
|
||||
$db->query($sql);
|
||||
$db->next_record();
|
||||
|
||||
if (($db->f("timemgmt") == "1") && ($isstart != 1))
|
||||
{
|
||||
$sql = "SELECT online, redirect, redirect_url FROM ".$cfg["tab"]["art_lang"]." WHERE idart='".Contenido_Security::toInteger($idart)."' AND idlang = '".Contenido_Security::toInteger($lang)."'
|
||||
if (($db->f("timemgmt") == "1") && ($isstart != 1)) {
|
||||
$sql = "SELECT online, redirect, redirect_url FROM " . $cfg["tab"]["art_lang"] . " WHERE idart='" . Contenido_Security::toInteger($idart) . "' AND idlang = '" . Contenido_Security::toInteger($lang) . "'
|
||||
AND NOW() > datestart AND NOW() < dateend";
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql = "SELECT online, redirect, redirect_url FROM ".$cfg["tab"]["art_lang"]." WHERE idart='".Contenido_Security::toInteger($idart)."' AND idlang = '".Contenido_Security::toInteger($lang)."'";
|
||||
} else {
|
||||
$sql = "SELECT online, redirect, redirect_url FROM " . $cfg["tab"]["art_lang"] . " WHERE idart='" . Contenido_Security::toInteger($idart) . "' AND idlang = '" . Contenido_Security::toInteger($lang) . "'";
|
||||
}
|
||||
|
||||
$db->query($sql);
|
||||
|
@ -813,15 +719,14 @@ else
|
|||
$redirect = $db->f("redirect");
|
||||
$redirect_url = $db->f("redirect_url");
|
||||
|
||||
@ eval ("\$"."redirect_url = \"$redirect_url\";"); // transform variables
|
||||
@ eval("\$" . "redirect_url = \"$redirect_url\";"); // transform variables
|
||||
|
||||
$insert_base = getEffectiveSetting('generator', 'basehref', "true");
|
||||
|
||||
/*
|
||||
* generate base url
|
||||
*/
|
||||
if ($insert_base == "true")
|
||||
{
|
||||
if ($insert_base == "true") {
|
||||
$is_XHTML = getEffectiveSetting('generator', 'xhtml', "false");
|
||||
|
||||
$str_base_uri = $cfgClient[$client]["path"]["htmlpath"];
|
||||
|
@ -830,21 +735,19 @@ else
|
|||
$str_base_uri = CEC_Hook::executeAndReturn('Contenido.Frontend.BaseHrefGeneration', $str_base_uri);
|
||||
|
||||
if ($is_XHTML == "true") {
|
||||
$baseCode = '<base href="'.$str_base_uri.'" />';
|
||||
$baseCode = '<base href="' . $str_base_uri . '" />';
|
||||
} else {
|
||||
$baseCode = '<base href="'.$str_base_uri.'">';
|
||||
$baseCode = '<base href="' . $str_base_uri . '">';
|
||||
}
|
||||
|
||||
$code = str_ireplace_once("<head>", "<head>\n".$baseCode, $code);
|
||||
$code = str_ireplace_once("<head>", "<head>\n" . $baseCode, $code);
|
||||
}
|
||||
|
||||
/*
|
||||
* Handle online (offline) articles
|
||||
*/
|
||||
if ($online)
|
||||
{
|
||||
if ($redirect == '1' && $redirect_url != '')
|
||||
{
|
||||
if ($online) {
|
||||
if ($redirect == '1' && $redirect_url != '') {
|
||||
page_close();
|
||||
/*
|
||||
* Redirect to the URL defined in article properties
|
||||
|
@ -860,12 +763,9 @@ else
|
|||
}
|
||||
header("Location: $redirect_url");
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($cfg["debug"]["codeoutput"])
|
||||
{
|
||||
echo "<textarea>".clHtmlSpecialChars($code)."</textarea>";
|
||||
} else {
|
||||
if ($cfg["debug"]["codeoutput"]) {
|
||||
echo "<textarea>" . clHtmlSpecialChars($code) . "</textarea>";
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -876,11 +776,11 @@ else
|
|||
|
||||
$aExclude = explode(',', getEffectiveSetting('frontend.no_outputbuffer', 'idart', ''));
|
||||
if (in_array(Contenido_Security::toInteger($idart), $aExclude)) {
|
||||
eval ("?>\n".$code."\n<?php\n");
|
||||
eval("?>\n" . $code . "\n<?php\n");
|
||||
} else {
|
||||
// write html output into output buffer and assign it to an variable
|
||||
ob_start();
|
||||
eval ("?>\n".$code."\n<?php\n");
|
||||
eval("?>\n" . $code . "\n<?php\n");
|
||||
$htmlCode = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
|
@ -893,26 +793,17 @@ else
|
|||
// print output
|
||||
echo $htmlCode;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
# if user is in the backend display offline articles
|
||||
if ($contenido)
|
||||
{
|
||||
eval ("?>\n".$code."\n<?php\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($error == 1)
|
||||
{
|
||||
if ($contenido) {
|
||||
eval("?>\n" . $code . "\n<?php\n");
|
||||
} else {
|
||||
if ($error == 1) {
|
||||
echo "Fatal error: Could not display error page. Error to display was: 'No contenido session variable set. Probable error cause: Start article in this category is not set on-line.'";
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
header($errsite);
|
||||
exit;
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -934,13 +825,11 @@ if ($cfg["cache"]["disable"] != '1') {
|
|||
/*
|
||||
* configuration settings after the site is displayed.
|
||||
*/
|
||||
if (file_exists("config.after.php"))
|
||||
{
|
||||
if (file_exists("config.after.php")) {
|
||||
@ include ("config.after.php");
|
||||
}
|
||||
|
||||
if (isset ($savedlang))
|
||||
{
|
||||
if (isset($savedlang)) {
|
||||
$lang = $savedlang;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
/class.input.helper.php
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Project:
|
||||
* Contenido Content Management System
|
||||
|
@ -26,548 +27,504 @@
|
|||
*
|
||||
* $Id$:
|
||||
*/
|
||||
|
||||
if(!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
if (!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
}
|
||||
|
||||
// Select box with additional functions for category and article selection
|
||||
class cHTMLInputSelectElement extends cHTMLSelectElement
|
||||
{
|
||||
/**
|
||||
* Constructor. Creates an HTML select field (aka "DropDown").
|
||||
*
|
||||
* @param string $sName Name of the element
|
||||
* @param int $iWidth Width of the select element
|
||||
* @param string $sID ID of the element
|
||||
* @param string $bDisabled Item disabled flag (non-empty to set disabled)
|
||||
* @param int $iTabIndex Tab index for form elements
|
||||
* @param string $sAccesskey Key to access the field
|
||||
*
|
||||
* @return none
|
||||
**/
|
||||
function __construct ($sName, $iWidth = "", $sID = "", $bDisabled = false, $iTabIndex = null, $sAccessKey = "")
|
||||
{
|
||||
cHTMLSelectElement :: __construct($sName, $iWidth, $sID, $bDisabled, $iTabIndex, $sAccessKey);
|
||||
}
|
||||
class cHTMLInputSelectElement extends cHTMLSelectElement {
|
||||
|
||||
/**
|
||||
* Constructor. Creates an HTML select field (aka "DropDown").
|
||||
*
|
||||
* @param string $sName Name of the element
|
||||
* @param int $iWidth Width of the select element
|
||||
* @param string $sID ID of the element
|
||||
* @param string $bDisabled Item disabled flag (non-empty to set disabled)
|
||||
* @param int $iTabIndex Tab index for form elements
|
||||
* @param string $sAccesskey Key to access the field
|
||||
*
|
||||
* @return none
|
||||
* */
|
||||
function __construct($sName, $iWidth = "", $sID = "", $bDisabled = false, $iTabIndex = null, $sAccessKey = "") {
|
||||
cHTMLSelectElement :: __construct($sName, $iWidth, $sID, $bDisabled, $iTabIndex, $sAccessKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function addArticles. Adds articles to select box values.
|
||||
*
|
||||
* @param int $iIDCat idcat of the category to be listed
|
||||
* @param bool $bColored Add color information to option elements
|
||||
* @param bool $bArtOnline If true, only online articles will be added
|
||||
* @param string $sSpaces Just some " " to show data hierarchically (used in conjunction with addCategories)
|
||||
*
|
||||
* @return int Number of items added
|
||||
**/
|
||||
function addArticles ($iIDCat, $bColored = false, $bArtOnline = true, $sSpaces = "")
|
||||
{
|
||||
global $cfg, $lang;
|
||||
/**
|
||||
* Function addArticles. Adds articles to select box values.
|
||||
*
|
||||
* @param int $iIDCat idcat of the category to be listed
|
||||
* @param bool $bColored Add color information to option elements
|
||||
* @param bool $bArtOnline If true, only online articles will be added
|
||||
* @param string $sSpaces Just some " " to show data hierarchically (used in conjunction with addCategories)
|
||||
*
|
||||
* @return int Number of items added
|
||||
* */
|
||||
function addArticles($iIDCat, $bColored = false, $bArtOnline = true, $sSpaces = "") {
|
||||
global $cfg, $lang;
|
||||
|
||||
$oDB = new DB_Contenido;
|
||||
$oDB = new DB_Contenido;
|
||||
|
||||
if (is_numeric($iIDCat) && $iIDCat > 0)
|
||||
{
|
||||
$sSQL = "SELECT tblArtLang.title AS title, tblArtLang.idartlang AS idartlang, tblCatArt.idcat AS idcat, ";
|
||||
$sSQL .= "tblCatArt.idcatart AS idcatart, tblCatArt.is_start AS isstart, tblArtLang.online AS online, ";
|
||||
$sSQL .= "tblCatLang.startidartlang as idstartartlang ";
|
||||
$sSQL .= "FROM ".$cfg["tab"]["art_lang"]." AS tblArtLang, ".$cfg["tab"]["cat_art"]." AS tblCatArt, ";
|
||||
$sSQL .= $cfg["tab"]["cat_lang"]." AS tblCatLang ";
|
||||
$sSQL .= "WHERE tblCatArt.idcat = '".Contenido_Security::toInteger($iIDCat)."' AND tblCatLang.idcat = tblCatArt.idcat AND tblCatLang.idlang = tblArtLang.idlang AND ";
|
||||
if (is_numeric($iIDCat) && $iIDCat > 0) {
|
||||
$sSQL = "SELECT tblArtLang.title AS title, tblArtLang.idartlang AS idartlang, tblCatArt.idcat AS idcat, ";
|
||||
$sSQL .= "tblCatArt.idcatart AS idcatart, tblCatArt.is_start AS isstart, tblArtLang.online AS online, ";
|
||||
$sSQL .= "tblCatLang.startidartlang as idstartartlang ";
|
||||
$sSQL .= "FROM " . $cfg["tab"]["art_lang"] . " AS tblArtLang, " . $cfg["tab"]["cat_art"] . " AS tblCatArt, ";
|
||||
$sSQL .= $cfg["tab"]["cat_lang"] . " AS tblCatLang ";
|
||||
$sSQL .= "WHERE tblCatArt.idcat = '" . Contenido_Security::toInteger($iIDCat) . "' AND tblCatLang.idcat = tblCatArt.idcat AND tblCatLang.idlang = tblArtLang.idlang AND ";
|
||||
|
||||
if ($bArtOnline) {
|
||||
$sSQL .= "tblArtLang.online = '1' AND ";
|
||||
}
|
||||
if ($bArtOnline) {
|
||||
$sSQL .= "tblArtLang.online = '1' AND ";
|
||||
}
|
||||
|
||||
$sSQL .= "tblArtLang.idart = tblCatArt.idart AND tblArtLang.idlang = '".Contenido_Security::escapeDB($lang, $oDB)."' ";
|
||||
if ($cfg["is_start_compatible"] == true) {
|
||||
$sSQL .= "ORDER BY tblCatArt.is_start DESC, tblArtLang.title"; // Getting start article as first article
|
||||
} else {
|
||||
$sSQL .= "ORDER BY tblArtLang.title";
|
||||
}
|
||||
$sSQL .= "tblArtLang.idart = tblCatArt.idart AND tblArtLang.idlang = '" . Contenido_Security::escapeDB($lang, $oDB) . "' ";
|
||||
if ($cfg["is_start_compatible"] == true) {
|
||||
$sSQL .= "ORDER BY tblCatArt.is_start DESC, tblArtLang.title"; // Getting start article as first article
|
||||
} else {
|
||||
$sSQL .= "ORDER BY tblArtLang.title";
|
||||
}
|
||||
|
||||
$oDB->query($sSQL);
|
||||
$oDB->query($sSQL);
|
||||
|
||||
$iCount = $oDB->num_rows();
|
||||
if ($iCount == 0) {
|
||||
return 0;
|
||||
} else {
|
||||
$iCounter = count($this->_options);
|
||||
while ($oDB->next_record())
|
||||
{
|
||||
// Generate new option element
|
||||
$oOption = new cHTMLOptionElement($sSpaces." ".substr(urldecode($oDB->f("title")), 0, 32), $oDB->f("idcatart"));
|
||||
$iCount = $oDB->num_rows();
|
||||
if ($iCount == 0) {
|
||||
return 0;
|
||||
} else {
|
||||
$iCounter = count($this->_options);
|
||||
while ($oDB->next_record()) {
|
||||
// Generate new option element
|
||||
$oOption = new cHTMLOptionElement($sSpaces . " " . substr(urldecode($oDB->f("title")), 0, 32), $oDB->f("idcatart"));
|
||||
|
||||
if ($bColored)
|
||||
{
|
||||
$bIsStartArticle = false;
|
||||
if ($cfg["is_start_compatible"] == true && $oDB->f("isstart") == 1) {
|
||||
// Compatible mode and "start article" flag is set
|
||||
$bIsStartArticle = true;
|
||||
} else if ($cfg["is_start_compatible"] != true && $oDB->f("idstartartlang") == $oDB->f("idartlang")) {
|
||||
// No compatible mode and current article is start article (idstartartlang is the same for all records within a category)
|
||||
$bIsStartArticle = true;
|
||||
}
|
||||
if ($bColored) {
|
||||
$bIsStartArticle = false;
|
||||
if ($cfg["is_start_compatible"] == true && $oDB->f("isstart") == 1) {
|
||||
// Compatible mode and "start article" flag is set
|
||||
$bIsStartArticle = true;
|
||||
} else if ($cfg["is_start_compatible"] != true && $oDB->f("idstartartlang") == $oDB->f("idartlang")) {
|
||||
// No compatible mode and current article is start article (idstartartlang is the same for all records within a category)
|
||||
$bIsStartArticle = true;
|
||||
}
|
||||
|
||||
if ($bIsStartArticle)
|
||||
{
|
||||
if ($oDB->f("online") == 0) {
|
||||
// Start article, but offline -> red
|
||||
$oOption->setStyle("color: #ff0000;");
|
||||
} else {
|
||||
// Start article -> blue
|
||||
$oOption->setStyle("color: #0000ff;");
|
||||
}
|
||||
} else if ($oDB->f("online") == 0) {
|
||||
// Offline article -> grey
|
||||
$oOption->setStyle("color: #666666;");
|
||||
}
|
||||
}
|
||||
if ($bIsStartArticle) {
|
||||
if ($oDB->f("online") == 0) {
|
||||
// Start article, but offline -> red
|
||||
$oOption->setStyle("color: #ff0000;");
|
||||
} else {
|
||||
// Start article -> blue
|
||||
$oOption->setStyle("color: #0000ff;");
|
||||
}
|
||||
} else if ($oDB->f("online") == 0) {
|
||||
// Offline article -> grey
|
||||
$oOption->setStyle("color: #666666;");
|
||||
}
|
||||
}
|
||||
|
||||
// Add option element to the list
|
||||
$this->addOptionElement($iCounter, $oOption);
|
||||
$iCounter++;
|
||||
}
|
||||
return $iCount;
|
||||
}
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
// Add option element to the list
|
||||
$this->addOptionElement($iCounter, $oOption);
|
||||
$iCounter++;
|
||||
}
|
||||
return $iCount;
|
||||
}
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function addCategories. Adds category elements (optionally including articles) to select box values.
|
||||
* Note: Using "with articles" adds the articles also - but the categories will get a negative value!
|
||||
* There is no way to distinguish between a category id and an article id...
|
||||
*
|
||||
* @param int $iMaxLevel Max. level shown (to be exact: except this level)
|
||||
* @param bool $bColored Add color information to option elements
|
||||
* @param bool $bCatVisible If true, only add idcat as value, if cat is visible
|
||||
* @param bool $bCatPublic If true, only add idcat as value, if cat is public
|
||||
* @param bool $bWithArt Add also articles per category
|
||||
* @param bool $bArtOnline If true, show only online articles
|
||||
*
|
||||
* @return int Number of items added
|
||||
**/
|
||||
function addCategories ($iMaxLevel = 0, $bColored = false, $bCatVisible = true, $bCatPublic = true,
|
||||
$bWithArt = false, $bArtOnline = true)
|
||||
{
|
||||
global $cfg, $client, $lang;
|
||||
/**
|
||||
* Function addCategories. Adds category elements (optionally including articles) to select box values.
|
||||
* Note: Using "with articles" adds the articles also - but the categories will get a negative value!
|
||||
* There is no way to distinguish between a category id and an article id...
|
||||
*
|
||||
* @param int $iMaxLevel Max. level shown (to be exact: except this level)
|
||||
* @param bool $bColored Add color information to option elements
|
||||
* @param bool $bCatVisible If true, only add idcat as value, if cat is visible
|
||||
* @param bool $bCatPublic If true, only add idcat as value, if cat is public
|
||||
* @param bool $bWithArt Add also articles per category
|
||||
* @param bool $bArtOnline If true, show only online articles
|
||||
*
|
||||
* @return int Number of items added
|
||||
* */
|
||||
function addCategories($iMaxLevel = 0, $bColored = false, $bCatVisible = true, $bCatPublic = true,
|
||||
$bWithArt = false, $bArtOnline = true) {
|
||||
global $cfg, $client, $lang;
|
||||
|
||||
$oDB = new DB_Contenido;
|
||||
$oDB = new DB_Contenido;
|
||||
|
||||
$sSQL = "SELECT tblCat.idcat AS idcat, tblCatLang.name AS name, ";
|
||||
$sSQL .= "tblCatLang.visible AS visible, tblCatLang.public AS public, tblCatTree.level AS level ";
|
||||
$sSQL .= "FROM ".$cfg["tab"]["cat"]." AS tblCat, ".$cfg["tab"]["cat_lang"]." AS tblCatLang, ";
|
||||
$sSQL .= $cfg["tab"]["cat_tree"]." AS tblCatTree ";
|
||||
$sSQL .= "WHERE tblCat.idclient = '".Contenido_Security::escapeDB($client, $oDB)."' AND tblCatLang.idlang = '".Contenido_Security::escapeDB($lang, $oDB)."' AND ";
|
||||
$sSQL .= "tblCatLang.idcat = tblCat.idcat AND tblCatTree.idcat = tblCat.idcat ";
|
||||
$sSQL = "SELECT tblCat.idcat AS idcat, tblCatLang.name AS name, ";
|
||||
$sSQL .= "tblCatLang.visible AS visible, tblCatLang.public AS public, tblCatTree.level AS level ";
|
||||
$sSQL .= "FROM " . $cfg["tab"]["cat"] . " AS tblCat, " . $cfg["tab"]["cat_lang"] . " AS tblCatLang, ";
|
||||
$sSQL .= $cfg["tab"]["cat_tree"] . " AS tblCatTree ";
|
||||
$sSQL .= "WHERE tblCat.idclient = '" . Contenido_Security::escapeDB($client, $oDB) . "' AND tblCatLang.idlang = '" . Contenido_Security::escapeDB($lang, $oDB) . "' AND ";
|
||||
$sSQL .= "tblCatLang.idcat = tblCat.idcat AND tblCatTree.idcat = tblCat.idcat ";
|
||||
|
||||
if ($iMaxLevel > 0) {
|
||||
$sSQL .= "AND tblCatTree.level < '".Contenido_Security::escapeDB($iMaxLevel, $oDB)."' ";
|
||||
}
|
||||
$sSQL .= "ORDER BY tblCatTree.idtree";
|
||||
if ($iMaxLevel > 0) {
|
||||
$sSQL .= "AND tblCatTree.level < '" . Contenido_Security::escapeDB($iMaxLevel, $oDB) . "' ";
|
||||
}
|
||||
$sSQL .= "ORDER BY tblCatTree.idtree";
|
||||
|
||||
$oDB->query($sSQL);
|
||||
$oDB->query($sSQL);
|
||||
|
||||
$iCount = $oDB->num_rows();
|
||||
if ($iCount == 0) {
|
||||
return false;
|
||||
} else {
|
||||
$iCounter = count($this->_options);
|
||||
while ($oDB->next_record())
|
||||
{
|
||||
$sSpaces = "";
|
||||
$sStyle = "";
|
||||
$iID = $oDB->f("idcat");
|
||||
$iCount = $oDB->num_rows();
|
||||
if ($iCount == 0) {
|
||||
return false;
|
||||
} else {
|
||||
$iCounter = count($this->_options);
|
||||
while ($oDB->next_record()) {
|
||||
$sSpaces = "";
|
||||
$sStyle = "";
|
||||
$iID = $oDB->f("idcat");
|
||||
|
||||
for ($i = 0; $i < $oDB->f("level"); $i++) {
|
||||
$sSpaces .= " ";
|
||||
}
|
||||
for ($i = 0; $i < $oDB->f("level"); $i++) {
|
||||
$sSpaces .= " ";
|
||||
}
|
||||
|
||||
// Generate new option element
|
||||
if (($bCatVisible && $oDB->f("visible") == 0) ||
|
||||
($bCatPublic && $oDB->f("public") == 0)) {
|
||||
// If category has to be visible or public and it isn't, don't add value
|
||||
$sValue = "";
|
||||
} else if ($bWithArt) {
|
||||
// If article will be added, set negative idcat as value
|
||||
$sValue = "-".$iID;
|
||||
} else {
|
||||
// Show only categories - and everything is fine...
|
||||
$sValue = $iID;
|
||||
}
|
||||
$oOption = new cHTMLOptionElement($sSpaces."> ".urldecode($oDB->f("name")), $sValue);
|
||||
// Generate new option element
|
||||
if (($bCatVisible && $oDB->f("visible") == 0) || ($bCatPublic && $oDB->f("public") == 0)) {
|
||||
// If category has to be visible or public and it isn't, don't add value
|
||||
$sValue = "";
|
||||
} else if ($bWithArt) {
|
||||
// If article will be added, set negative idcat as value
|
||||
$sValue = "-" . $iID;
|
||||
} else {
|
||||
// Show only categories - and everything is fine...
|
||||
$sValue = $iID;
|
||||
}
|
||||
$oOption = new cHTMLOptionElement($sSpaces . "> " . urldecode($oDB->f("name")), $sValue);
|
||||
|
||||
// Coloring option element, restricted shows grey color
|
||||
$oOption->setStyle("background-color: #EFEFEF");
|
||||
if ($bColored && ($oDB->f("visible") == 0 || $oDB->f("public") == 0)) {
|
||||
$oOption->setStyle("color: #666666;");
|
||||
}
|
||||
// Coloring option element, restricted shows grey color
|
||||
$oOption->setStyle("background-color: #EFEFEF");
|
||||
if ($bColored && ($oDB->f("visible") == 0 || $oDB->f("public") == 0)) {
|
||||
$oOption->setStyle("color: #666666;");
|
||||
}
|
||||
|
||||
// Add option element to the list
|
||||
$this->addOptionElement($iCounter, $oOption);
|
||||
// Add option element to the list
|
||||
$this->addOptionElement($iCounter, $oOption);
|
||||
|
||||
if ($bWithArt) {
|
||||
$iArticles = $this->addArticles($iID, $bColored, $bArtOnline, $sSpaces);
|
||||
$iCount += $iArticles;
|
||||
}
|
||||
$iCounter = count($this->_options);
|
||||
}
|
||||
}
|
||||
return $iCount;
|
||||
}
|
||||
if ($bWithArt) {
|
||||
$iArticles = $this->addArticles($iID, $bColored, $bArtOnline, $sSpaces);
|
||||
$iCount += $iArticles;
|
||||
}
|
||||
$iCounter = count($this->_options);
|
||||
}
|
||||
}
|
||||
return $iCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function addTypesFromArt. Adds types and type ids which are available for the specified article
|
||||
*
|
||||
* @param int $iIDCatArt Article id
|
||||
* @param string $sTypeRange Komma separated list of Contenido type ids which may be in the resulting list (e.g. '1','17','28')
|
||||
*
|
||||
* @return int Number of items added
|
||||
**/
|
||||
function addTypesFromArt ($iIDCatArt, $sTypeRange = "")
|
||||
{
|
||||
global $cfg, $lang;
|
||||
/**
|
||||
* Function addTypesFromArt. Adds types and type ids which are available for the specified article
|
||||
*
|
||||
* @param int $iIDCatArt Article id
|
||||
* @param string $sTypeRange Komma separated list of Contenido type ids which may be in the resulting list (e.g. '1','17','28')
|
||||
*
|
||||
* @return int Number of items added
|
||||
* */
|
||||
function addTypesFromArt($iIDCatArt, $sTypeRange = "") {
|
||||
global $cfg, $lang;
|
||||
|
||||
$oDB = new DB_Contenido;
|
||||
$oDB = new DB_Contenido;
|
||||
|
||||
if (is_numeric($iIDCatArt) && $iIDCatArt > 0)
|
||||
{
|
||||
$sSQL = "SELECT tblContent.typeid AS typeid, tblContent.idtype AS idtype, tblType.type AS type, tblType.description AS description, ";
|
||||
$sSQL .= "tblContent.value AS value ";
|
||||
$sSQL .= "FROM ".$cfg["tab"]["content"]." AS tblContent, ".$cfg["tab"]["art_lang"]." AS tblArtLang, ";
|
||||
$sSQL .= $cfg["tab"]["cat_art"]." AS tblCatArt, ".$cfg["tab"]["type"]." AS tblType ";
|
||||
$sSQL .= "WHERE tblContent.idtype = tblType.idtype AND tblContent.idartlang = tblArtLang.idartlang AND ";
|
||||
$sSQL .= "tblArtLang.idart = tblCatArt.idart AND tblArtLang.idlang = '". Contenido_Security::escapeDB($lang, $oDB)."' AND tblCatArt.idcatart = '". Contenido_Security::toInteger($iIDCatArt)."' ";
|
||||
if (is_numeric($iIDCatArt) && $iIDCatArt > 0) {
|
||||
$sSQL = "SELECT tblContent.typeid AS typeid, tblContent.idtype AS idtype, tblType.type AS type, tblType.description AS description, ";
|
||||
$sSQL .= "tblContent.value AS value ";
|
||||
$sSQL .= "FROM " . $cfg["tab"]["content"] . " AS tblContent, " . $cfg["tab"]["art_lang"] . " AS tblArtLang, ";
|
||||
$sSQL .= $cfg["tab"]["cat_art"] . " AS tblCatArt, " . $cfg["tab"]["type"] . " AS tblType ";
|
||||
$sSQL .= "WHERE tblContent.idtype = tblType.idtype AND tblContent.idartlang = tblArtLang.idartlang AND ";
|
||||
$sSQL .= "tblArtLang.idart = tblCatArt.idart AND tblArtLang.idlang = '" . Contenido_Security::escapeDB($lang, $oDB) . "' AND tblCatArt.idcatart = '" . Contenido_Security::toInteger($iIDCatArt) . "' ";
|
||||
|
||||
if ($sTypeRange != "") {
|
||||
$sSQL .= "AND tblContent.idtype IN (". Contenido_Security::escapeDB($sTypeRange, $oDB).") ";
|
||||
}
|
||||
if ($sTypeRange != "") {
|
||||
$sSQL .= "AND tblContent.idtype IN (" . Contenido_Security::escapeDB($sTypeRange, $oDB) . ") ";
|
||||
}
|
||||
|
||||
$sql .= "ORDER BY tblContent.idtype, tblContent.typeid";
|
||||
$sql .= "ORDER BY tblContent.idtype, tblContent.typeid";
|
||||
|
||||
$oDB->query($sSQL);
|
||||
$oDB->query($sSQL);
|
||||
|
||||
$iCount = $oDB->num_rows();
|
||||
if ($iCount == 0) {
|
||||
return false;
|
||||
} else {
|
||||
while ($oDB->next_record())
|
||||
{
|
||||
$sTypeIdentifier = "tblData.idtype = '".$oDB->f('idtype')."' AND tblData.typeid = '".$oDB->f('typeid')."'";
|
||||
$iCount = $oDB->num_rows();
|
||||
if ($iCount == 0) {
|
||||
return false;
|
||||
} else {
|
||||
while ($oDB->next_record()) {
|
||||
$sTypeIdentifier = "tblData.idtype = '" . $oDB->f('idtype') . "' AND tblData.typeid = '" . $oDB->f('typeid') . "'";
|
||||
|
||||
// Generate new option element
|
||||
$oOption = new cHTMLOptionElement($oDB->f('type')."[".$oDB->f('typeid')."]: ".substr(strip_tags(urldecode($oDB->f("value"))), 0, 50), $sTypeIdentifier);
|
||||
// Generate new option element
|
||||
$oOption = new cHTMLOptionElement($oDB->f('type') . "[" . $oDB->f('typeid') . "]: " . substr(strip_tags(urldecode($oDB->f("value"))), 0, 50), $sTypeIdentifier);
|
||||
|
||||
// Add option element to the list
|
||||
$this->addOptionElement($sTypeIdentifier, $oOption);
|
||||
}
|
||||
return $iCount;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// Add option element to the list
|
||||
$this->addOptionElement($sTypeIdentifier, $oOption);
|
||||
}
|
||||
return $iCount;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Selects specified elements as selected
|
||||
*
|
||||
* @param array $aElements Array with "values" of the cHTMLOptionElement to set
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
function setSelected($aElements) {
|
||||
if (is_array($this->_options) && is_array($aElements)) {
|
||||
foreach ($this->_options as $sKey => $oOption) {
|
||||
if (in_array($oOption->getAttribute("value"), $aElements)) {
|
||||
$oOption->setSelected(true);
|
||||
$this->_options[$sKey] = $oOption;
|
||||
} else {
|
||||
$oOption->setSelected(false);
|
||||
$this->_options[$sKey] = $oOption;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Selects specified elements as selected
|
||||
*
|
||||
* @param array $aElements Array with "values" of the cHTMLOptionElement to set
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
function setSelected($aElements)
|
||||
{
|
||||
if (is_array($this->_options) && is_array($aElements))
|
||||
{
|
||||
foreach ($this->_options as $sKey => $oOption)
|
||||
{
|
||||
if (in_array($oOption->getAttribute("value"), $aElements))
|
||||
{
|
||||
$oOption->setSelected(true);
|
||||
$this->_options[$sKey] = $oOption;
|
||||
} else {
|
||||
$oOption->setSelected(false);
|
||||
$this->_options[$sKey] = $oOption;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class UI_Config_Table
|
||||
{
|
||||
var $_sTplCellCode;
|
||||
var $_sTplTableFile;
|
||||
|
||||
var $_sWidth;
|
||||
var $_sBorder;
|
||||
var $_sBorderColor;
|
||||
var $_bSolidBorder;
|
||||
var $_sPadding;
|
||||
var $_aCells;
|
||||
var $_aCellAlignment;
|
||||
var $_aCellVAlignment;
|
||||
var $_aCellColSpan;
|
||||
var $_aCellClass;
|
||||
var $_aRowBgColor;
|
||||
var $_aRowExtra;
|
||||
var $_bAddMultiSelJS;
|
||||
|
||||
var $_sColorLight;
|
||||
var $_sColorDark;
|
||||
class UI_Config_Table {
|
||||
|
||||
function __construct()
|
||||
{
|
||||
global $cfg;
|
||||
var $_sTplCellCode;
|
||||
var $_sTplTableFile;
|
||||
var $_sWidth;
|
||||
var $_sBorder;
|
||||
var $_sBorderColor;
|
||||
var $_bSolidBorder;
|
||||
var $_sPadding;
|
||||
var $_aCells;
|
||||
var $_aCellAlignment;
|
||||
var $_aCellVAlignment;
|
||||
var $_aCellColSpan;
|
||||
var $_aCellClass;
|
||||
var $_aRowBgColor;
|
||||
var $_aRowExtra;
|
||||
var $_bAddMultiSelJS;
|
||||
var $_sColorLight;
|
||||
var $_sColorDark;
|
||||
|
||||
$this->_sPadding = 2;
|
||||
$this->_sBorder = 0;
|
||||
$this->_sBorderColor = $cfg['color']['table_border'];
|
||||
$this->_sTplCellCode = ' <td align="{ALIGN}" valign="{VALIGN}" class="{CLASS}" colspan="{COLSPAN}" style="{EXTRA}white-space:nowrap;" nowrap="nowrap">{CONTENT}</td>'."\n";
|
||||
$this->_sTplTableFile = $cfg['path']['contenido'].$cfg['path']['templates'].$cfg['templates']['generic_list'];
|
||||
$this->_sColorLight = $cfg['color']['table_light'];
|
||||
$this->_sColorDark = $cfg['color']['table_dark'];
|
||||
}
|
||||
function __construct() {
|
||||
global $cfg;
|
||||
|
||||
function setCellTemplate($sCode)
|
||||
{
|
||||
$this->_sTplCellCode = $sCode;
|
||||
}
|
||||
$this->_sPadding = 2;
|
||||
$this->_sBorder = 0;
|
||||
$this->_sBorderColor = $cfg['color']['table_border'];
|
||||
$this->_sTplCellCode = ' <td align="{ALIGN}" valign="{VALIGN}" class="{CLASS}" colspan="{COLSPAN}" style="{EXTRA}white-space:nowrap;" nowrap="nowrap">{CONTENT}</td>' . "\n";
|
||||
$this->_sTplTableFile = $cfg['path']['contenido'] . $cfg['path']['templates'] . $cfg['templates']['generic_list'];
|
||||
$this->_sColorLight = $cfg['color']['table_light'];
|
||||
$this->_sColorDark = $cfg['color']['table_dark'];
|
||||
}
|
||||
|
||||
function setCellTemplate($sCode) {
|
||||
$this->_sTplCellCode = $sCode;
|
||||
}
|
||||
|
||||
function setTableTemplateFile($sPath)
|
||||
{
|
||||
$this->_sTplTableFile = $sPath;
|
||||
}
|
||||
|
||||
function setLightColor($sColor)
|
||||
{
|
||||
$this->_sColorLight = $sColor;
|
||||
}
|
||||
|
||||
function setDarkColor($sColor)
|
||||
{
|
||||
$this->_sColorDark = $sColor;
|
||||
}
|
||||
function setTableTemplateFile($sPath) {
|
||||
$this->_sTplTableFile = $sPath;
|
||||
}
|
||||
|
||||
function setAddMultiSelJS($bEnabled = true)
|
||||
{
|
||||
$this->_bAddMultiSelJS = (bool)$bEnabled;
|
||||
}
|
||||
function setLightColor($sColor) {
|
||||
$this->_sColorLight = $sColor;
|
||||
}
|
||||
|
||||
function setWidth ($sWidth)
|
||||
{
|
||||
$this->_sWidth = $sWidth;
|
||||
}
|
||||
|
||||
function setPadding ($sPadding)
|
||||
{
|
||||
$this->_sPadding = $sPadding;
|
||||
}
|
||||
function setDarkColor($sColor) {
|
||||
$this->_sColorDark = $sColor;
|
||||
}
|
||||
|
||||
function setBorder ($sBorder)
|
||||
{
|
||||
$this->_sBorder = $sBorder;
|
||||
}
|
||||
function setAddMultiSelJS($bEnabled = true) {
|
||||
$this->_bAddMultiSelJS = (bool) $bEnabled;
|
||||
}
|
||||
|
||||
function setBorderColor ($sBorderColor)
|
||||
{
|
||||
$this->_sBorderColor = $sBorderColor;
|
||||
}
|
||||
|
||||
function setSolidBorder ($bSolidBorder = true)
|
||||
{
|
||||
$this->_bSolidBorder = (bool)$bSolidBorder;
|
||||
}
|
||||
function setWidth($sWidth) {
|
||||
$this->_sWidth = $sWidth;
|
||||
}
|
||||
|
||||
function setCell ($sRow, $sCell, $sContent)
|
||||
{
|
||||
$this->_aCells[$sRow][$sCell] = $sContent;
|
||||
$this->_aCellAlignment[$sRow][$sCell] = "";
|
||||
}
|
||||
function setPadding($sPadding) {
|
||||
$this->_sPadding = $sPadding;
|
||||
}
|
||||
|
||||
function setCellAlignment ($sRow, $sCell, $sAlignment)
|
||||
{
|
||||
$this->_aCellAlignment[$sRow][$sCell] = $sAlignment;
|
||||
}
|
||||
function setBorder($sBorder) {
|
||||
$this->_sBorder = $sBorder;
|
||||
}
|
||||
|
||||
function setCellVAlignment ($sRow, $sCell, $sAlignment)
|
||||
{
|
||||
$this->_aCellVAlignment[$sRow][$sCell] = $sAlignment;
|
||||
}
|
||||
function setBorderColor($sBorderColor) {
|
||||
$this->_sBorderColor = $sBorderColor;
|
||||
}
|
||||
|
||||
function setCellColspan ($sRow, $sCell, $iColSpan)
|
||||
{
|
||||
$this->_aCellColSpan[$sRow][$sCell] = $iColSpan;
|
||||
}
|
||||
function setSolidBorder($bSolidBorder = true) {
|
||||
$this->_bSolidBorder = (bool) $bSolidBorder;
|
||||
}
|
||||
|
||||
function setCellClass ($sRow, $sCell, $sClass)
|
||||
{
|
||||
$this->_aCellClass[$sRow][$sCell] = $sClass;
|
||||
}
|
||||
function setCell($sRow, $sCell, $sContent) {
|
||||
$this->_aCells[$sRow][$sCell] = $sContent;
|
||||
$this->_aCellAlignment[$sRow][$sCell] = "";
|
||||
}
|
||||
|
||||
function setRowBgColor ($sRow, $sColor)
|
||||
{
|
||||
$this->_aRowBgColor[$sRow] = $sColor;
|
||||
}
|
||||
|
||||
function setRowExtra ($sRow, $sExtra)
|
||||
{
|
||||
$this->_aRowExtra[$sRow] = $sExtra;
|
||||
}
|
||||
function setCellAlignment($sRow, $sCell, $sAlignment) {
|
||||
$this->_aCellAlignment[$sRow][$sCell] = $sAlignment;
|
||||
}
|
||||
|
||||
function _addMultiSelJS()
|
||||
{
|
||||
// Trick: To save multiple selections in <select>-Element, add some JS which saves the
|
||||
// selection, comma separated in a hidden input field on change.
|
||||
function setCellVAlignment($sRow, $sCell, $sAlignment) {
|
||||
$this->_aCellVAlignment[$sRow][$sCell] = $sAlignment;
|
||||
}
|
||||
|
||||
// Try ... catch prevents error messages, if function is added more than once
|
||||
// if (!fncUpdateSel) in JS has not worked...
|
||||
function setCellColspan($sRow, $sCell, $iColSpan) {
|
||||
$this->_aCellColSpan[$sRow][$sCell] = $iColSpan;
|
||||
}
|
||||
|
||||
$sSkript = ' <script type="text/javascript"><!--'."\n".
|
||||
' try {'."\n".
|
||||
' function fncUpdateSel(sSelectBox, sStorage)'."\n".
|
||||
' {'."\n".
|
||||
' var sSelection = "";'."\n".
|
||||
' var oSelectBox = document.getElementsByName(sSelectBox)[0];'."\n".
|
||||
' var oStorage = document.getElementsByName(sStorage)[0];'."\n".
|
||||
' '."\n".
|
||||
' if (oSelectBox && oStorage)'."\n".
|
||||
' {'."\n".
|
||||
' for (i = 0; i < oSelectBox.length; i++)'."\n".
|
||||
' {'."\n".
|
||||
' if(oSelectBox.options[i].selected == true)'."\n".
|
||||
' {'."\n".
|
||||
' if (sSelection != "")'."\n".
|
||||
' sSelection = sSelection + ",";'."\n".
|
||||
' sSelection = sSelection + oSelectBox.options[i].value;'."\n".
|
||||
' }'."\n".
|
||||
' }'."\n".
|
||||
' oStorage.value = sSelection;'."\n".
|
||||
' }'."\n".
|
||||
' }'."\n".
|
||||
' } catch (e) { }'."\n".
|
||||
' //--></script>'."\n";
|
||||
function setCellClass($sRow, $sCell, $sClass) {
|
||||
$this->_aCellClass[$sRow][$sCell] = $sClass;
|
||||
}
|
||||
|
||||
return $sSkript;
|
||||
}
|
||||
|
||||
function render($bPrint = false)
|
||||
{
|
||||
$oTable = new Template;
|
||||
$oTable->reset();
|
||||
function setRowBgColor($sRow, $sColor) {
|
||||
$this->_aRowBgColor[$sRow] = $sColor;
|
||||
}
|
||||
|
||||
$oTable->set('s', 'CELLPADDING', $this->_sPadding);
|
||||
$oTable->set('s', 'BORDER', $this->_sBorder);
|
||||
$oTable->set('s', 'BORDERCOLOR', $this->_sBorderColor);
|
||||
function setRowExtra($sRow, $sExtra) {
|
||||
$this->_aRowExtra[$sRow] = $sExtra;
|
||||
}
|
||||
|
||||
$iColCount = 0;
|
||||
$bDark = false;
|
||||
$sBgColor = "";
|
||||
$bMultiSelJSAdded = false;
|
||||
if (is_array($this->_aCells))
|
||||
{
|
||||
foreach ($this->_aCells as $sRow => $aCells)
|
||||
{
|
||||
$iColCount++;
|
||||
//$bDark = !$bDark;
|
||||
$sLine = "";
|
||||
$iCount = 0;
|
||||
|
||||
foreach ($aCells as $sCell => $sData)
|
||||
{
|
||||
$iCount++;
|
||||
$sTplCell = $this->_sTplCellCode;
|
||||
function _addMultiSelJS() {
|
||||
// Trick: To save multiple selections in <select>-Element, add some JS which saves the
|
||||
// selection, comma separated in a hidden input field on change.
|
||||
// Try ... catch prevents error messages, if function is added more than once
|
||||
// if (!fncUpdateSel) in JS has not worked...
|
||||
|
||||
if ($this->_bSolidBorder)
|
||||
{
|
||||
if ($iCount < count($aCells))
|
||||
{
|
||||
if ($iColCount < count($this->_aCells)) {
|
||||
$sTplCell = str_replace('{EXTRA}', 'border: 0px; border-right: 1px; border-bottom: 1px; border-color: '.$this->_sBorderColor.'; border-style: solid;', $sTplCell);
|
||||
} else {
|
||||
$sTplCell = str_replace('{EXTRA}', 'border: 0px; border-right: 1px; border-color: '.$this->_sBorderColor.'; border-style: solid;', $sTplCell);
|
||||
}
|
||||
} else if ($iColCount < count($this->_aCells)) {
|
||||
$sTplCell = str_replace('{EXTRA}', 'border: 0px; border-bottom: 1px; border-color: '.$this->_sBorderColor.'; border-style: solid;', $sTplCell);
|
||||
} else {
|
||||
$sTplCell = str_replace('{EXTRA}', '', $sTplCell);
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->_aCellAlignment[$sRow][$sCell] != "") {
|
||||
$sTplCell = str_replace('{ALIGN}', $this->_aCellAlignment[$sRow][$sCell], $sTplCell);
|
||||
} else {
|
||||
$sTplCell = str_replace('{ALIGN}', 'left', $sTplCell);
|
||||
}
|
||||
|
||||
if ($this->_aCellVAlignment[$sRow][$sCell] != "") {
|
||||
$sTplCell = str_replace('{VALIGN}', $this->_aCellVAlignment[$sRow][$sCell], $sTplCell);
|
||||
} else {
|
||||
$sTplCell = str_replace('{VALIGN}', 'top', $sTplCell);
|
||||
}
|
||||
$sSkript = ' <script type="text/javascript"><!--' . "\n" .
|
||||
' try {' . "\n" .
|
||||
' function fncUpdateSel(sSelectBox, sStorage)' . "\n" .
|
||||
' {' . "\n" .
|
||||
' var sSelection = "";' . "\n" .
|
||||
' var oSelectBox = document.getElementsByName(sSelectBox)[0];' . "\n" .
|
||||
' var oStorage = document.getElementsByName(sStorage)[0];' . "\n" .
|
||||
' ' . "\n" .
|
||||
' if (oSelectBox && oStorage)' . "\n" .
|
||||
' {' . "\n" .
|
||||
' for (i = 0; i < oSelectBox.length; i++)' . "\n" .
|
||||
' {' . "\n" .
|
||||
' if(oSelectBox.options[i].selected == true)' . "\n" .
|
||||
' {' . "\n" .
|
||||
' if (sSelection != "")' . "\n" .
|
||||
' sSelection = sSelection + ",";' . "\n" .
|
||||
' sSelection = sSelection + oSelectBox.options[i].value;' . "\n" .
|
||||
' }' . "\n" .
|
||||
' }' . "\n" .
|
||||
' oStorage.value = sSelection;' . "\n" .
|
||||
' }' . "\n" .
|
||||
' }' . "\n" .
|
||||
' } catch (e) { }' . "\n" .
|
||||
' //--></script>' . "\n";
|
||||
|
||||
if ($this->_aCellColSpan[$sRow][$sCell] != "") {
|
||||
$sTplCell = str_replace('{COLSPAN}', $this->_aCellColSpan[$sRow][$sCell], $sTplCell);
|
||||
} else {
|
||||
$sTplCell = str_replace('{COLSPAN}', '1', $sTplCell);
|
||||
}
|
||||
return $sSkript;
|
||||
}
|
||||
|
||||
if ($this->_aCellClass[$sRow][$sCell] != "") {
|
||||
$sTplCell = str_replace('{CLASS}', $this->_aCellClass[$sRow][$sCell], $sTplCell);
|
||||
} else {
|
||||
$sTplCell = str_replace('{CLASS}', 'text', $sTplCell);
|
||||
}
|
||||
function render($bPrint = false) {
|
||||
$oTable = new Template;
|
||||
$oTable->reset();
|
||||
|
||||
// Multi selection javascript
|
||||
if ($this->_bAddMultiSelJS) {
|
||||
$sData = $this->_addMultiSelJS() . $sData;
|
||||
$this->_bAddMultiSelJS = false;
|
||||
}
|
||||
$oTable->set('s', 'CELLPADDING', $this->_sPadding);
|
||||
$oTable->set('s', 'BORDER', $this->_sBorder);
|
||||
$oTable->set('s', 'BORDERCOLOR', $this->_sBorderColor);
|
||||
|
||||
$iColCount = 0;
|
||||
$bDark = false;
|
||||
$sBgColor = "";
|
||||
$bMultiSelJSAdded = false;
|
||||
if (is_array($this->_aCells)) {
|
||||
foreach ($this->_aCells as $sRow => $aCells) {
|
||||
$iColCount++;
|
||||
//$bDark = !$bDark;
|
||||
$sLine = "";
|
||||
$iCount = 0;
|
||||
|
||||
foreach ($aCells as $sCell => $sData) {
|
||||
$iCount++;
|
||||
$sTplCell = $this->_sTplCellCode;
|
||||
|
||||
if ($this->_bSolidBorder) {
|
||||
if ($iCount < count($aCells)) {
|
||||
if ($iColCount < count($this->_aCells)) {
|
||||
$sTplCell = str_replace('{EXTRA}', 'border: 0px; border-right: 1px; border-bottom: 1px; border-color: ' . $this->_sBorderColor . '; border-style: solid;', $sTplCell);
|
||||
} else {
|
||||
$sTplCell = str_replace('{EXTRA}', 'border: 0px; border-right: 1px; border-color: ' . $this->_sBorderColor . '; border-style: solid;', $sTplCell);
|
||||
}
|
||||
} else if ($iColCount < count($this->_aCells)) {
|
||||
$sTplCell = str_replace('{EXTRA}', 'border: 0px; border-bottom: 1px; border-color: ' . $this->_sBorderColor . '; border-style: solid;', $sTplCell);
|
||||
} else {
|
||||
$sTplCell = str_replace('{EXTRA}', '', $sTplCell);
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->_aCellAlignment[$sRow][$sCell] != "") {
|
||||
$sTplCell = str_replace('{ALIGN}', $this->_aCellAlignment[$sRow][$sCell], $sTplCell);
|
||||
} else {
|
||||
$sTplCell = str_replace('{ALIGN}', 'left', $sTplCell);
|
||||
}
|
||||
|
||||
if ($this->_aCellVAlignment[$sRow][$sCell] != "") {
|
||||
$sTplCell = str_replace('{VALIGN}', $this->_aCellVAlignment[$sRow][$sCell], $sTplCell);
|
||||
} else {
|
||||
$sTplCell = str_replace('{VALIGN}', 'top', $sTplCell);
|
||||
}
|
||||
|
||||
if ($this->_aCellColSpan[$sRow][$sCell] != "") {
|
||||
$sTplCell = str_replace('{COLSPAN}', $this->_aCellColSpan[$sRow][$sCell], $sTplCell);
|
||||
} else {
|
||||
$sTplCell = str_replace('{COLSPAN}', '1', $sTplCell);
|
||||
}
|
||||
|
||||
if ($this->_aCellClass[$sRow][$sCell] != "") {
|
||||
$sTplCell = str_replace('{CLASS}', $this->_aCellClass[$sRow][$sCell], $sTplCell);
|
||||
} else {
|
||||
$sTplCell = str_replace('{CLASS}', 'text', $sTplCell);
|
||||
}
|
||||
|
||||
// Multi selection javascript
|
||||
if ($this->_bAddMultiSelJS) {
|
||||
$sData = $this->_addMultiSelJS() . $sData;
|
||||
$this->_bAddMultiSelJS = false;
|
||||
}
|
||||
|
||||
$sTplCell = str_replace('{CONTENT}', $sData, $sTplCell);
|
||||
$sLine .= $sTplCell;
|
||||
}
|
||||
|
||||
// Row
|
||||
$oTable->set('d', 'ROWS', $sLine);
|
||||
|
||||
if ($this->_aRowBgColor[$sRow] != "") {
|
||||
$sBgColor = $this->_aRowBgColor[$sRow];
|
||||
} else if ($sBgColor == $this->_sColorLight) {
|
||||
$sBgColor = $this->_sColorDark;
|
||||
} else {
|
||||
$sBgColor = $this->_sColorLight;
|
||||
}
|
||||
$oTable->set('d', 'BGCOLOR', $sBgColor);
|
||||
|
||||
if ($this->_aRowExtra[$sRow] != "") {
|
||||
$oTable->set('d', 'EXTRA', $this->_aRowExtra[$sRow]);
|
||||
} else {
|
||||
$oTable->set('d', 'EXTRA', '');
|
||||
}
|
||||
|
||||
$oTable->next();
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->_sWidth) {
|
||||
// Table: Width
|
||||
$oTable->set('s', 'EXTRA', 'width: ' . $this->_sWidth . ';');
|
||||
} else {
|
||||
$oTable->set('s', 'EXTRA', '');
|
||||
}
|
||||
$sRendered = $oTable->generate($this->_sTplTableFile, true, false);
|
||||
|
||||
if ($bPrint == true) {
|
||||
echo $sRendered;
|
||||
} else {
|
||||
return $sRendered;
|
||||
}
|
||||
}
|
||||
|
||||
$sTplCell = str_replace('{CONTENT}', $sData, $sTplCell);
|
||||
$sLine .= $sTplCell;
|
||||
}
|
||||
|
||||
// Row
|
||||
$oTable->set('d', 'ROWS', $sLine);
|
||||
|
||||
if ($this->_aRowBgColor[$sRow] != "") {
|
||||
$sBgColor = $this->_aRowBgColor[$sRow];
|
||||
} else if ($sBgColor == $this->_sColorLight) {
|
||||
$sBgColor = $this->_sColorDark;
|
||||
} else {
|
||||
$sBgColor = $this->_sColorLight;
|
||||
}
|
||||
$oTable->set('d', 'BGCOLOR', $sBgColor);
|
||||
|
||||
if ($this->_aRowExtra[$sRow] != "") {
|
||||
$oTable->set('d', 'EXTRA', $this->_aRowExtra[$sRow]);
|
||||
} else {
|
||||
$oTable->set('d', 'EXTRA', '');
|
||||
}
|
||||
|
||||
$oTable->next();
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->_sWidth) {
|
||||
// Table: Width
|
||||
$oTable->set('s', 'EXTRA', 'width: '.$this->_sWidth.';');
|
||||
} else {
|
||||
$oTable->set('s', 'EXTRA', '');
|
||||
}
|
||||
$sRendered = $oTable->generate($this->_sTplTableFile, true, false);
|
||||
|
||||
if ($bPrint == true) {
|
||||
echo $sRendered;
|
||||
} else {
|
||||
return $sRendered;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,859 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* Project:
|
||||
* Spider IT Deutschland ConLite and Contenido Extensions
|
||||
*
|
||||
* Description:
|
||||
* File with useful helper functions
|
||||
*
|
||||
* Requirements:
|
||||
* @con_php_req 5
|
||||
*
|
||||
* @package Frontend
|
||||
* @author René Mansveld <R.Mansveld@Spider-IT.de>
|
||||
* @copyright Spider IT Deutschland <www.Spider-IT.de>
|
||||
* @license MIT <http://en.wikipedia.org/wiki/MIT_License> <http://de.wikipedia.org/wiki/MIT-Lizenz>
|
||||
* (see below)
|
||||
* @link http://www.Spider-IT.de
|
||||
* @link http://www.conlite.org
|
||||
* @link http://www.contenido.org
|
||||
*
|
||||
* @file spider-it.functions.inc.php
|
||||
* @version 1.2
|
||||
* @date 2012-11-21
|
||||
*
|
||||
* {@internal
|
||||
* created 2012-09-14
|
||||
* modified 2012-10-10
|
||||
* modified 2012-10-14
|
||||
* modified 2012-10-22
|
||||
* modified 2012-10-24
|
||||
* modified 2012-10-30
|
||||
* modified 2012-11-21
|
||||
*
|
||||
* $Id$:
|
||||
* }
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2012 Spider IT Deutschland
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
|
||||
* documentation files (the "Software"), to deal in the Software without restriction, including without
|
||||
* limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
||||
* Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
||||
* TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*
|
||||
* Hiermit wird unentgeltlich, jeder Person, die eine Kopie der Software und der zugehörigen Dokumentationen (die
|
||||
* "Software") erhält, die Erlaubnis erteilt, sie uneingeschränkt zu benutzen, inklusive und ohne Ausnahme, dem
|
||||
* Recht, sie zu verwenden, kopieren, ändern, fusionieren, verlegen, verbreiten, unterlizenzieren und/oder zu
|
||||
* verkaufen, und Personen, die diese Software erhalten, diese Rechte zu geben, unter den folgenden Bedingungen:
|
||||
*
|
||||
* Der obige Urheberrechtsvermerk und dieser Erlaubnisvermerk sind in allen Kopien oder Teilkopien der Software
|
||||
* beizulegen.
|
||||
*
|
||||
* DIE SOFTWARE WIRD OHNE JEDE AUSDRÜCKLICHE ODER IMPLIZIERTE GARANTIE BEREITGESTELLT, EINSCHLIESSLICH DER GARANTIE
|
||||
* ZUR BENUTZUNG FÜR DEN VORGESEHENEN ODER EINEM BESTIMMTEN ZWECK SOWIE JEGLICHER RECHTSVERLETZUNG, JEDOCH NICHT
|
||||
* DARAUF BESCHRÄNKT. IN KEINEM FALL SIND DIE AUTOREN ODER COPYRIGHTINHABER FÜR JEGLICHEN SCHADEN ODER SONSTIGE
|
||||
* ANSPRÜCHE HAFTBAR ZU MACHEN, OB INFOLGE DER ERFÜLLUNG EINES VERTRAGES, EINES DELIKTES ODER ANDERS IM ZUSAMMENHANG
|
||||
* MIT DER SOFTWARE ODER SONSTIGER VERWENDUNG DER SOFTWARE ENTSTANDEN.
|
||||
*/
|
||||
|
||||
# Functions in this file:
|
||||
# debug()
|
||||
# sitCascadedArraySort()
|
||||
# sitConvertCmykJpgToSrgbJpg()
|
||||
# sitExplodeAssociative()
|
||||
# sitExplodeCascading()
|
||||
# sitExplodeLines()
|
||||
# sitGetFilesInDirectory()
|
||||
# sitGetImageDescription()
|
||||
# sitGetRemoteContentToFile()
|
||||
# sitGetSubdirs()
|
||||
# sitImgScale()
|
||||
# sitMoveAllUploadFiles()
|
||||
# sitSafeStringEscape()
|
||||
# sitSendHtmlMail()
|
||||
# sitSetClientProperty()
|
||||
# sitTeaserText()
|
||||
|
||||
if (!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
}
|
||||
|
||||
# debug()
|
||||
#
|
||||
# Zeigt Debugging-Informationen auf der Webseite
|
||||
#
|
||||
# Parameter:
|
||||
# $value - Der anzuzeigende Wert
|
||||
# $type - Der Typ des Wertes (optional)
|
||||
# Möglichkeiten:
|
||||
# '' - Text / Array / Object
|
||||
# 'sql' - SQL-Anweisungen (Aufruf sollte nach $db->query() erfolgen)
|
||||
#
|
||||
# Der Wert wird aufbereitet per echo auf der Webseite
|
||||
# ausgegeben, wobei die Funktion selbstständig zwischen
|
||||
# einzelnen Werte, Arrays und Objekte unterscheidet.
|
||||
# Der 2. Parameter $type dient besondere Fälle, wie z.B.
|
||||
# 'sql' für SQL-Anweisungen, welche dann individuell
|
||||
# aufbereitet werden.
|
||||
function debug($value, $type = '') {
|
||||
global $db, $debug;
|
||||
|
||||
if ($debug) {
|
||||
echo '<div style="font-size: 14px;">';
|
||||
switch (strtolower($type)) {
|
||||
case 'sql':
|
||||
echo '<pre style="margin-top: 0px;">' . str_replace(array(str_repeat(chr(32), 4), chr(9)), '', $value) . '</pre>Records: ' . intval(@$db->num_rows());
|
||||
break;
|
||||
default:
|
||||
if (is_array($value)) {
|
||||
echo '<pre>'; var_dump($value); echo '</pre>';
|
||||
} elseif (is_object($value)) {
|
||||
echo 'Object:<pre style="margin-top: 0px;">'; var_dump($value); echo '</pre>';
|
||||
} else {
|
||||
echo $value;
|
||||
}
|
||||
break;
|
||||
}
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
# sitCascadedArraySort()
|
||||
#
|
||||
# Sortiert ein kaskadiertes Array nach Spalten
|
||||
#
|
||||
# Parameter:
|
||||
# Zu sortierendes Array
|
||||
# Liste aus Feldnamen, Sortierarten und Sortierrichtungen (siehe
|
||||
# array_multisort, de.php.net/manual/de/function.array-multisort.php)
|
||||
#
|
||||
# Sortiert ein mehrdimentionales Array nach den angegebenen Spalten
|
||||
# nach den vorgegebenen Sortierarten und -richtungen (je Spalte anzugeben)
|
||||
# Beispiel:
|
||||
# $x = sitCascadedArraySort($x, 'Name', SORT_STRING, SORT_ASC, 'Vorname', SORT_STRING, SORT_ASC);
|
||||
function sitCascadedArraySort() {
|
||||
$args = func_get_args();
|
||||
$marray = array_shift($args);
|
||||
if (count($marray)) {
|
||||
$msortline = 'return(array_multisort(';
|
||||
foreach ($args as $arg) {
|
||||
$i ++;
|
||||
if (is_string($arg)) {
|
||||
foreach ($marray as $row) {
|
||||
$sortarr[$i][] = $row[$arg];
|
||||
}
|
||||
} else {
|
||||
$sortarr[$i] = $arg;
|
||||
}
|
||||
$msortline .= '$sortarr['.$i.'],';
|
||||
}
|
||||
$msortline .= '$marray));';
|
||||
eval($msortline);
|
||||
}
|
||||
return $marray;
|
||||
}
|
||||
|
||||
# sitConvertCmykJpgToSrgbJpg()
|
||||
#
|
||||
# Wandelt JPG-Bilder mit CMYK Farbprofil in sRGB Farbprofil um
|
||||
#
|
||||
# Parameter:
|
||||
# $path - Kompletter Pfad zum Bild
|
||||
#
|
||||
# Da der Internet Explorer keine JPG-Bilder (.jpg / .jpeg) mit CMYK Farbprofil
|
||||
# darstellen kann, müssen diese Bilder in das sRGB Farbprofil (für das Web)
|
||||
# umgewandelt werden. Diese Funktion prüft das Bild und wandelt es ggf. um.
|
||||
function sitConvertCmykJpgToSrgbJpg($path) {
|
||||
if ((strtolower(substr($path, -4)) == '.jpg') || (strtolower(substr($path, -5)) == '.jpeg')) {
|
||||
exec('identify -verbose ' . $path . ' >' . $path . '.txt');
|
||||
$tmp = file($path . '.txt');
|
||||
unlink($path . '.txt');
|
||||
for ($i = 0, $n = count($tmp); $i < $n; $i ++) {
|
||||
$a = explode(':', $tmp[$i]);
|
||||
if (trim($a[0]) == 'Colorspace') {
|
||||
if (strpos($a[1], 'RGB') === false) {
|
||||
# Bild ist in CMYK
|
||||
exec('convert ' . $path . ' -profile sRGB.icc -colorspace sRGB ' . $path . '.jpg');
|
||||
unlink($path);
|
||||
rename($path . '.jpg', $path);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# sitExplodeAssociative()
|
||||
#
|
||||
# Zerlegt eine Zeichenfolge in ein assoziatives Array.
|
||||
#
|
||||
# Parameter:
|
||||
# $delimiter - Array mit Trennzeichen zum Zerlegen der Zeichenfolge
|
||||
# $string - Zu zerlegende Zeichenfolge
|
||||
#
|
||||
# Das erste Trennzeichen bildet das Array, das zweite Trennzeichen
|
||||
# splittet auf Key und Value.
|
||||
function sitExplodeAssociative($delimiters = array(), $string = '') {
|
||||
$tmp = explode($delimiters[0], $string);
|
||||
$ret = array();
|
||||
for ($i = 0, $n = count($tmp); $i < $n; $i ++) {
|
||||
$t = explode($delimiters[1], $tmp[$i]);
|
||||
$ret[$t[0]] = $t[1];
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
# sitExplodeCascading()
|
||||
#
|
||||
# Zerlegt eine Zeichenfolge in ein kaskadiertes Array.
|
||||
#
|
||||
# Parameter:
|
||||
# $delimiter - Array mit Trennzeichen zum Zerlegen der Zeichenfolge
|
||||
# $string - Zu zerlegende Zeichenfolge
|
||||
#
|
||||
# Das erste Trennzeichen bildet das Hauptarray, jedes weitere
|
||||
# Trennzeichen darin ein Unterarray (mehrere Ebenen).
|
||||
function sitExplodeCascading($delimiters = array(), $string = '') {
|
||||
$tmp = explode($delimiters[0], $string);
|
||||
array_shift($delimiters);
|
||||
for ($i = 0, $n = count($tmp); $i < $n; $i ++) {
|
||||
$tmp[$i] = sitMultipleExplode($delimiters, $tmp[$i]);
|
||||
}
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
# sitExplodeLines()
|
||||
#
|
||||
# Zerlegt einen Text in einzelnen Zeilen
|
||||
#
|
||||
# Parameter:
|
||||
# $string - Zu zerlegende Zeichenfolge
|
||||
#
|
||||
# Zerlegt den Text unabhängig der Zeilenumbruchart in ein Array
|
||||
# mit den einzelnen Zeilen.
|
||||
function sitExplodeLines($string) {
|
||||
return explode("\n", str_replace("\r\n", "\n", $string));
|
||||
}
|
||||
|
||||
# sitGetFilesInDirectory()
|
||||
#
|
||||
# Liest Dateien in ein Verzeichnis
|
||||
#
|
||||
# Parameter:
|
||||
# $path - Kompletter Pfad des zu lesenden Verzeichnisses
|
||||
# $filter - Filter für gefundenen Dateien (optional)
|
||||
# $sort - Sortierreihenfolge (optional)
|
||||
#
|
||||
# Liest die Dateien in ein Verzeichnis und filtert und sortiert diese bei Bedarf.
|
||||
# $filter kann ein Array mit mehrere Filter sein, z.B. array('*.jp*g', '*.gif', '*.png').
|
||||
# $sort kann 'asc', 'desc', SORT_ASC oder SORT_DESC sein, oder weggelassen werden.
|
||||
function sitGetFilesInDirectory($path, $filter = '*', $sort = '') {
|
||||
define('FNM_CASEFOLD', 16);
|
||||
$aFiles = array();
|
||||
if (is_dir($path)) {
|
||||
if (!is_array($filter)) {
|
||||
$filter = array($filter);
|
||||
}
|
||||
if ($oDir = opendir($path)) {
|
||||
while (($sFile = readdir($oDir)) !== false) {
|
||||
if (is_dir($path . $sFile)) {
|
||||
continue;
|
||||
} else {
|
||||
for ($i = 0, $n = count($filter); $i < $n; $i ++) {
|
||||
if (fnmatch($filter[$i], $sFile, FNM_CASEFOLD)) {
|
||||
$aFiles[] = $sFile;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir($oDir);
|
||||
if (strlen($sort)) {
|
||||
sort($aFiles, SORT_STRING);
|
||||
if (($sort == 'desc') || ($sort == SORT_DESC)) {
|
||||
$aFiles = array_reverse($aFiles);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $aFiles;
|
||||
}
|
||||
|
||||
# sitGetImageDescription()
|
||||
#
|
||||
# Liest die Bildbeschreibung aus der Datenbank
|
||||
#
|
||||
# Parameter:
|
||||
# $idupl - ID des Bildeintrags in der Datenbank
|
||||
#
|
||||
# Liest die zum Bild gehörenden Beschreibung entweder aus der Tabelle ..._upl_meta
|
||||
# oder (falls leer) aus der Tabelle ..._upl und liefert diese zurück.
|
||||
function sitGetImageDescription($idupl) {
|
||||
global $db, $cfg;
|
||||
|
||||
$sDesc = '';
|
||||
$sql = 'SELECT description
|
||||
FROM ' . $cfg['tab']['upl_meta'] . '
|
||||
WHERE (idupl=' . $idupl . ')';
|
||||
$db->query($sql);
|
||||
if ($db->next_record()) {
|
||||
$sDesc = urldecode(str_replace(array('%0D%0A', '%0D', '%0A'), '<br />', $db->f('description')));
|
||||
}
|
||||
if (strlen(trim($sDesc)) == 0) {
|
||||
$sql = 'SELECT description
|
||||
FROM ' . $cfg['tab']['upl'] . '
|
||||
WHERE (idupl=' . $idupl . ')';
|
||||
$db->query($sql);
|
||||
if ($db->next_record()) {
|
||||
$sDesc = $db->f('description');
|
||||
}
|
||||
}
|
||||
return $sDesc;
|
||||
}
|
||||
|
||||
# sitGetRemoteContentToFile()
|
||||
#
|
||||
# Holt entfernten Inhalt ab und speichert diesen lokal
|
||||
#
|
||||
# Parameter:
|
||||
# $url - Die Adresse von wo der Inhalt geholt werden soll
|
||||
# $file - Die Datei in der gespeichert werden soll (inkl. Pfad)
|
||||
# $errno - Die Fehlernummer (Rückgabe)
|
||||
# $errmsg - Die Fehlerbeschreibung (Rückgabe)
|
||||
#
|
||||
# Die Daten (Webseite, Bild, Feed usw) werden per cURL geholt,
|
||||
# wobei Weiterleitungen gefolgt werden.
|
||||
# Diese Methode ist unabhängig von allow_url_fopen und verarbeitet
|
||||
# auch Anfragen per https (SSL).
|
||||
function sitGetRemoteContentToFile($url, $file, $errno, $errmsg) {
|
||||
$options = array(
|
||||
CURLOPT_RETURNTRANSFER => true, // return web page
|
||||
CURLOPT_HEADER => false, // don't return headers
|
||||
CURLOPT_FOLLOWLOCATION => true, // follow redirects
|
||||
CURLOPT_ENCODING => "", // handle compressed
|
||||
CURLOPT_USERAGENT => "spider", // who am i
|
||||
CURLOPT_AUTOREFERER => true, // set referer on redirect
|
||||
CURLOPT_CONNECTTIMEOUT => 10, // timeout on connect
|
||||
CURLOPT_TIMEOUT => 10, // timeout on response
|
||||
CURLOPT_MAXREDIRS => 10, // stop after 10 redirects
|
||||
);
|
||||
|
||||
$ch = curl_init($url);
|
||||
curl_setopt_array($ch, $options);
|
||||
$content = curl_exec($ch);
|
||||
$errno = curl_errno($ch);
|
||||
$errmsg = curl_error($ch);
|
||||
$header = curl_getinfo($ch);
|
||||
curl_close($ch);
|
||||
|
||||
if (($errno == 0) && ($header['http_code'] == 200)) {
|
||||
# Content in Datei speichern
|
||||
if ($fp = fopen($file, 'w')) {
|
||||
fputs($fp, $content);
|
||||
fclose($fp);
|
||||
return true;
|
||||
} else {
|
||||
$errno = -1;
|
||||
$errmsg = 'Can\'t write to file ' . $file;
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
# sitGetSubdirs()
|
||||
#
|
||||
# Listet Unterverzeichnisse eines Verzeichnisses
|
||||
#
|
||||
# Parameter:
|
||||
# $dir - Übergeordnetes Verzeichnis
|
||||
# $levels - Anzahl Ebenen an Unterverzeichnisse die mit aufgelistet werden sollen
|
||||
# $__dirs - interner Parameter für Rekursion
|
||||
#
|
||||
# Listet die Unterverzeichnisse eines Verzeichnisses inkl. aller Unterverzeichnisse
|
||||
# bis zu der angegebenen Anzahl an Ebenen (die Tiefe).
|
||||
function sitGetSubdirs($dir, $levels = 1, $__dirs = array()) {
|
||||
$a = array();
|
||||
$p = opendir($dir);
|
||||
while (($s = readdir($p)) !== false) {
|
||||
if (($s == '.') || ($s == '..')) {
|
||||
continue;
|
||||
}
|
||||
if (is_dir($dir . ((substr($dir, -1) == '/') ? '' : '/') . $s)) {
|
||||
$a[] = $dir . ((substr($dir, -1) == '/') ? '' : '/') . $s . '/';
|
||||
}
|
||||
}
|
||||
closedir($p);
|
||||
sort($a, SORT_STRING);
|
||||
for ($i = 0; $i < count($a); $i ++) {
|
||||
$__dirs[] = $a[$i];
|
||||
if ($levels > 1) {
|
||||
$__dirs = sitGetSubdirs($a[$i], ($levels - 1), $__dirs);
|
||||
}
|
||||
}
|
||||
return $__dirs;
|
||||
}
|
||||
|
||||
# sitImgScale()
|
||||
#
|
||||
# Skaliert oder zoomt ein Bild auch mit Transparenz
|
||||
#
|
||||
# Parameter:
|
||||
# $img - Pfad und Dateiname der Originaldatei relativ zum Mandantenverzeichnis
|
||||
# $maxX - Maximale Breite des neuen Bildes
|
||||
# $maxY - Maximale Höhe des neuen Bildes
|
||||
# $crop - Bild darf beschnitten werden (optional)
|
||||
# $expand - Bild darf vergrößert werden
|
||||
# $cacheTime - Ältere Version nutzen oder überschreiben
|
||||
# $wantHQ - Bild soll in hoher Qualität sein
|
||||
# $quality - Qualität bei JPG und GIF
|
||||
# $keepType - Dateityp beibehalten
|
||||
# $fixedSize - Zielbild wird auf angegebene Größe erstellt und transparent (GIF und PNG) gefüllt
|
||||
# $fixedBG - Bei $fixedSize und JPG wird dies die Hintergrundfarbe des umgebenden Bereichs
|
||||
#
|
||||
# Erstellt im cache Verzeichnis eine skalierte Version des Originalbildes
|
||||
# wie auch die Con-Funktion capiImgScale(), aber behält Transparenz in GIF
|
||||
# und PNG Bilder bei. Der zusätzliche Parameter $fixedSize ermöglicht es,
|
||||
# das Zielbild mit fixe Abmessungen zu erstellen und das skalierte Bild
|
||||
# darin zu zentrieren, wobei der umgebenden Bereich bei GIF und PNG Bilder
|
||||
# transparent, bei JPG Bilder mit der in $fixedBG angegebenen Farbe gefüllt
|
||||
# wird. Ist $fixedBG nicht angegeben, wird weiß (#FFF) angenommen.
|
||||
function sitImgScale($img, $maxX = 0, $maxY = 0, $crop = false, $expand = false, $cacheTime = 10, $wantHQ = true, $quality = 75, $keepType = false, $fixedSize = false, $fixedBG = 'FFFFFF') {
|
||||
global $cfgClient, $client, $lang;
|
||||
|
||||
if (($maxX <= 0) && ($maxY <= 0)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
# Cache
|
||||
$md5 = capiImgScaleGetMD5CacheFile($img, $maxX, $maxY, $crop, $expand);
|
||||
list($oWidth, $oHeight, $oType) = @getimagesize($cfgClient[$client]['path']['frontend'] . $img);
|
||||
switch ($oType) {
|
||||
case IMAGETYPE_GIF:
|
||||
$cfileName = $md5 . '.gif';
|
||||
break;
|
||||
case IMAGETYPE_JPEG:
|
||||
if ($keepType) {
|
||||
$cfileName = $md5 . '.jpg';
|
||||
} else {
|
||||
$cfileName = $md5 . '.png';
|
||||
}
|
||||
break;
|
||||
case IMAGETYPE_PNG:
|
||||
$cfileName = $md5 . '.png';
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
$cacheFile = $cfgClient[$client]['path']['frontend'] . 'cache/' . $cfileName;
|
||||
$webFile = $cfgClient[$client]['path']['htmlpath'] . 'cache/' . $cfileName;
|
||||
if (file_exists($cacheFile)) {
|
||||
if ($cacheTime == 0) {
|
||||
# Datei läuft nicht ab, also direkt ausgeben
|
||||
return $webFile;
|
||||
} elseif ((filemtime($cacheFile) + (60 * $cacheTime)) < time()) {
|
||||
# Datei ist abgelaufen
|
||||
unlink($cacheFile);
|
||||
} else {
|
||||
# Datei ist noch nicht abgelaufen
|
||||
return $webFile;
|
||||
}
|
||||
}
|
||||
|
||||
# Bild neu aufbauen
|
||||
$nLeft = 0;
|
||||
$nTop = 0;
|
||||
$nWidth = 0;
|
||||
$nHeight = 0;
|
||||
if ($fixedSize) {
|
||||
$iWidth = $maxX;
|
||||
$iHeight = $maxY;
|
||||
# Abmessung und Position in neues Bild berechnen
|
||||
if (($oWidth > $maxX) || ($oHeight > $maxY) || ($expand)) {
|
||||
# Bild ist größer oder soll vergrößert werden
|
||||
if ($crop) {
|
||||
$faktor = max($maxX / $oWidth, $maxY / $oHeight);
|
||||
} else {
|
||||
$faktor = min($maxX / $oWidth, $maxY / $oHeight);
|
||||
}
|
||||
if ($faktor == ($maxX / $oWidth)) {
|
||||
$nLeft = 0;
|
||||
$nWidth = $maxX;
|
||||
$nHeight = floor($oHeight * $faktor);
|
||||
$nTop = floor(($maxY - $nHeight) / 2);
|
||||
} else {
|
||||
$nTop = 0;
|
||||
$nHeight = $maxY;
|
||||
$nWidth = floor($oWidth * $faktor);
|
||||
$nLeft = floor(($maxX - $nWidth) / 2);
|
||||
}
|
||||
} else {
|
||||
$nLeft = floor(($maxX - $oWidth) / 2);
|
||||
$nTop = floor(($maxY / $oHeight) / 2);
|
||||
$nWidth = $oWidth;
|
||||
$nHeight = $oHeight;
|
||||
}
|
||||
} else {
|
||||
# Abmessung des neuen Bildes berechnen
|
||||
if (($oWidth > $maxX) || ($oHeight > $maxY) || ($expand)) {
|
||||
if ($crop) {
|
||||
$faktor = max($maxX / $oWidth, $maxY / $oHeight);
|
||||
} else {
|
||||
$faktor = min($maxX / $oWidth, $maxY / $oHeight);
|
||||
}
|
||||
if ($faktor == ($maxX / $oWidth)) {
|
||||
$nWidth = $maxX;
|
||||
$nHeight = floor($oHeight * $faktor);
|
||||
$iWidth = $maxX;
|
||||
$iHeight = (($nHeight > $maxY) ? $maxY : $nHeight);
|
||||
$nTop = (($nHeight > $maxY) ? floor(($maxY - $nHeight) / 2) : 0);
|
||||
} else {
|
||||
$nHeight = $maxY;
|
||||
$nWidth = floor($oWidth * $faktor);
|
||||
$iHeight = $maxY;
|
||||
$iWidth = (($nWidth > $maxX) ? $maxX : $nWidth);
|
||||
$nLeft = (($nWidth > $maxX) ? floor(($maxX - $nWidth) / 2) : 0);
|
||||
}
|
||||
} else {
|
||||
# Bild ist kleiner und soll nicht vergrößert werden
|
||||
$iWidth = $nWidth = $oWidth;
|
||||
$iHeight = $nHeight = $oHeight;
|
||||
}
|
||||
}
|
||||
# Bild einlesen
|
||||
switch ($oType) {
|
||||
case IMAGETYPE_GIF:
|
||||
$image = imagecreatefromgif($img);
|
||||
break;
|
||||
case IMAGETYPE_JPEG:
|
||||
$image = imagecreatefromjpeg($img);
|
||||
break;
|
||||
case IMAGETYPE_PNG:
|
||||
$image = imagecreatefrompng($img);
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
# Neues Bild erzeugen und Hintergrundfarbe einstellen
|
||||
$nImage = imagecreatetruecolor($iWidth, $iHeight);
|
||||
if (($oType == IMAGETYPE_GIF) || ($oType == IMAGETYPE_PNG)) {
|
||||
$transIdx = imagecolortransparent($image);
|
||||
if ($transIdx >= 0) {
|
||||
# Es gibt eine transparente Farbe (GIF oder PNG8)
|
||||
$transColor = imagecolorsforindex($image, $transIdx);
|
||||
$transIdx = imagecolorallocate($nImage, $transColor['red'], $transColor['green'], $transColor['blue']);
|
||||
imagefill($nImage, 0, 0, $transIdx);
|
||||
imagecolortransparent($nImage, $transIdx);
|
||||
} elseif ($oType == IMAGETYPE_PNG) {
|
||||
# Ein PNG24 kriegt ein transparenter Hintergrund per Alpha-Kanal
|
||||
imagealphablending($nImage, false);
|
||||
$oColor = imagecolorallocatealpha($nImage, 0, 0, 0, 127);
|
||||
imagefill($nImage, 0, 0, $oColor);
|
||||
imagesavealpha($nImage, true);
|
||||
}
|
||||
} else {
|
||||
$debug = 1;
|
||||
if ($keepType) {
|
||||
# Andere Bilder (JPG) kriegen eine Hintergrundfarbe
|
||||
$oColor = imagecolorallocate($nImage, hexdec(substr($fixedBG, 0, 2)), hexdec(substr($fixedBG, 2, 2)), hexdec(substr($fixedBG, 4, 2)));
|
||||
#debug('imagecolorallocate($nImage, ' . hexdec(substr($fixedBG, 0, 2)) . ', ' . hexdec(substr($fixedBG, 2, 2)) . ', ' . hexdec(substr($fixedBG, 4, 2)) . ') = ' . $oColor);
|
||||
# imagefill($nImage, 0, 0, $oColor);
|
||||
imagefilledrectangle($nImage, 0, 0, $iWidth, $iHeight, $oColor);
|
||||
} else {
|
||||
# JPG-Bilder werden in PNG24 umgewandelt
|
||||
$oType = IMAGETYPE_PNG;
|
||||
imagealphablending($nImage, false);
|
||||
$oColor = imagecolorallocatealpha($nImage, 0, 0, 0, 127);
|
||||
# imagefill($nImage, 0, 0, $oColor);
|
||||
imagefilledRectangle($nImage, 0, 0, $iWidth, $iHeight, $oColor);
|
||||
imagesavealpha($nImage, true);
|
||||
}
|
||||
}
|
||||
# Das Originalbild skaliert hinein kopieren
|
||||
imagecopyresampled($nImage, $image, $nLeft, $nTop, 0, 0, $nWidth, $nHeight, $oWidth, $oHeight);
|
||||
# Das neue Bild speichern
|
||||
switch ($oType) {
|
||||
case IMAGETYPE_GIF:
|
||||
imagegif($nImage, $cacheFile);
|
||||
break;
|
||||
case IMAGETYPE_JPEG:
|
||||
imagejpeg($nImage, $cacheFile);
|
||||
break;
|
||||
case IMAGETYPE_PNG:
|
||||
imagepng($nImage, $cacheFile);
|
||||
break;
|
||||
}
|
||||
# Aufräumen
|
||||
imagedestroy($image);
|
||||
imagedestroy($nImage);
|
||||
# Pfad zurück liefern
|
||||
return $webFile;
|
||||
}
|
||||
|
||||
# sitMoveAllUploadFiles()
|
||||
#
|
||||
# Verschiebt alle Dateien eines Verzeichnisses
|
||||
#
|
||||
# Parameter:
|
||||
# $source - Quellverzeichnis
|
||||
# $dest - Zielverzeichnis
|
||||
#
|
||||
# Verschiebt alle Dateien eines Verzeichnisses im Upload-Bereich (unter /upload/)
|
||||
# und passt die Einträge in der Datenbank entsprechend an.
|
||||
function sitMoveAllUploadFiles($source, $dest) {
|
||||
global $cfgClient, $client, $db, $cfg;
|
||||
|
||||
$source .= ((substr($source, -1) == '/') ? '' : '/');
|
||||
$dest .= ((substr($dest, -1) == '/') ? '' : '/');
|
||||
|
||||
$a = array();
|
||||
$p = opendir($cfgClient[$client]['upl']['path'] . $source);
|
||||
while (($s = readdir($p)) !== false) {
|
||||
if (is_dir($cfgClient[$client]['upl']['path'] . $source . $s)) {
|
||||
continue;
|
||||
} elseif (strlen($s) > 2) {
|
||||
$a[] = $s;
|
||||
}
|
||||
}
|
||||
for ($i = 0, $n = count($a); $i < $n; $i ++) {
|
||||
rename($cfgClient[$client]['upl']['path'] . $source . $a[$i], $cfgClient[$client]['upl']['path'] . $dest . $a[$i]);
|
||||
$sql = 'UPDATE ' . $cfg['tab']['upl'] . '
|
||||
SET dirname = "' . $dest . '"
|
||||
WHERE ((dirname="' . $source . '")
|
||||
AND (filename="' . $a[$i] . '"))';
|
||||
$db->query($sql);
|
||||
}
|
||||
}
|
||||
|
||||
# sitSafeStringEscape()
|
||||
#
|
||||
# Escaped eine Zeichenfolge für SQL-Anweisungen
|
||||
#
|
||||
# Parameter:
|
||||
# $string - Zu escapenden Zeichenfolge
|
||||
#
|
||||
# Escaped eine Zeichenfolge so, dass diese sicher in die Datenbank eingetragen
|
||||
# werden kann.
|
||||
function sitSafeStringEscape($string) {
|
||||
$escapeCount = 0;
|
||||
$targetString = '';
|
||||
for($offset = 0; $offset < strlen($string); $offset ++) {
|
||||
switch ($c = $string{$offset}) {
|
||||
case "'":
|
||||
if ($escapeCount % 2 == 0) {
|
||||
$targetString .= "\\";
|
||||
}
|
||||
$escapeCount = 0;
|
||||
$targetString .= $c;
|
||||
break;
|
||||
case '"':
|
||||
if ($escapeCount % 2 == 0) {
|
||||
$targetString .= "\\";
|
||||
}
|
||||
$escapeCount = 0;
|
||||
$targetString .= $c;
|
||||
break;
|
||||
case '\\':
|
||||
$escapeCount ++ ;
|
||||
$targetString .= $c;
|
||||
break;
|
||||
default:
|
||||
$escapeCount = 0;
|
||||
$targetString .= $c;
|
||||
}
|
||||
}
|
||||
return $targetString;
|
||||
}
|
||||
|
||||
# sitSendHtmlMail()
|
||||
#
|
||||
# Sendet eine HTML-Mail mit HTML- und Textteil
|
||||
#
|
||||
# Parameter:
|
||||
# $html - HTML-Teil der Mail
|
||||
# $subject - Betreffzeile der Mail
|
||||
# $receipients - Array von Empfänger ('name' und 'email', mehrere möglich)
|
||||
# $attachments - Dateipfad oder Array von Dateipfade für Anhänge (optional)
|
||||
# $sname - Absendername (optional)
|
||||
# $smail - Absenderadresse (optional)
|
||||
# $mailer - Versandmethode ('mail' / 'qmail' / 'sendmail' / 'smtp') (optional)
|
||||
# $sserver - SMTP-Server Adresse (optional)
|
||||
# $slogin - SMTP Login (optional)
|
||||
# $spass - SMTP Passwort (optional)
|
||||
# $sport - SMTP Port (optional)
|
||||
#
|
||||
# Sendet eine HTML-Mail mit HTML- und Textteil an einen oder mehrere Empfänger
|
||||
# mit keinen oder mehrere Anhänge und liefert den Erfolgsstatus zurück.
|
||||
# Die Angaben zum Absender und den Mailer werden, sofern sie nicht mit angegeben
|
||||
# sind, aus den Mandanten- bzw. Systemeinstellungen ausgelesen.
|
||||
# - email - absende-name
|
||||
# - email - absender-email
|
||||
# - email - mailer
|
||||
# - email - smtp-server
|
||||
# - email - smtp-login
|
||||
# - email - smtp-passwort
|
||||
# - email - smtp-port - 25
|
||||
# Die Empfänger werden als Array aus Name(n) und Email-Adresse(n) übergeben.
|
||||
# Beispiel 1: array('name' => 'xyz', 'email' => 'xyz@abc.de');
|
||||
# Beispiel 2: array(array('name' => 'xyz', 'email' => 'xyz@abc.de'), array('name'...
|
||||
function sitSendHtmlMail($html, $subject, $receipients, $attachments = '', $sname = '', $smail = '', $mailer = '', $sserver = '', $slogin = '', $spass = '', $sport = '') {
|
||||
# Eingaben ergänzen
|
||||
if (!is_array($attachments)) {
|
||||
$attachments = array($attachments);
|
||||
}
|
||||
$sname = ((strlen($sname)) ? $sname : getEffectiveSetting('email', 'absender-name'));
|
||||
$smail = ((strlen($smail)) ? $smail : getEffectiveSetting('email', 'absender-email'));
|
||||
if (strlen($sname) == 0) {
|
||||
$sname = $smail;
|
||||
}
|
||||
$mailer = strtolower(((strlen($mailer)) ? $mailer : getEffectiveSetting('email', 'mailer')));
|
||||
if (strlen($mailer) == 0) {
|
||||
$mailer = 'mail';
|
||||
}
|
||||
if ($mailer == 'smtp') {
|
||||
$sserver = ((strlen($sserver)) ? $sserver : getEffectiveSetting('email', 'smtp-server'));
|
||||
$slogin = ((strlen($slogin)) ? $slogin : getEffectiveSetting('email', 'smtp-login'));
|
||||
$spass = ((strlen($spass)) ? $spass : getEffectiveSetting('email', 'smtp-passwort'));
|
||||
$sport = intval(((strlen($sport)) ? $sport : getEffectiveSetting('email', 'smtp-port')));
|
||||
if ($sport == 0) {
|
||||
$sport = 25;
|
||||
}
|
||||
}
|
||||
# Prüfen, ob genügend Angaben vorliegen
|
||||
if ((strlen($html) == 0) || (strlen($subject) == 0)) {
|
||||
return false;
|
||||
}
|
||||
if ((!is_array($receipients)) || ((strlen($receipients['email']) == 0) && (strlen($receipients[0]['email']) == 0))) {
|
||||
return false;
|
||||
}
|
||||
if (strlen($smail) == 0) {
|
||||
return false;
|
||||
}
|
||||
if (($mailer == 'smtp') && ((strlen($sserver) == 0) || (strlen($slogin) == 0) || (strlen($spass) == 0))) {
|
||||
return false;
|
||||
}
|
||||
# Mail aufbereiten und versenden
|
||||
$oMail = new PHPMailer();
|
||||
$oMail->IsHTML(true);
|
||||
$oMail->Mailer = $mailer;
|
||||
if ($mailer == 'smtp') {
|
||||
$oMail->SMTPAuth = true;
|
||||
$oMail->Host = $sserver;
|
||||
$oMail->Port = $sport;
|
||||
$oMail->Username = $slogin;
|
||||
$oMail->Password = $spass;
|
||||
}
|
||||
$oMail->Subject = $subject;
|
||||
$oMail->From = $smail;
|
||||
$oMail->FromName = $sname;
|
||||
if (is_array($receipients[0])) {
|
||||
for ($i = 0, $n = count($receipients); $i < $n; $i ++) {
|
||||
if (strlen($receipients[$i]['email'])) {
|
||||
$oMail->AddAddress($receipients[$i]['email'], ((strlen($receipients[$i]['name'])) ? $receipients[$i]['name'] : $receipients[$i]['email']));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$oMail->AddAddress($receipients['email'], ((strlen($receipients['name'])) ? $receipients['name'] : $receipients['email']));
|
||||
}
|
||||
$oMail->Body = $html;
|
||||
# Nur-Text-Bereich -->
|
||||
$sMsg = substr($html, strpos($html, '<body'));
|
||||
$sMsg = str_replace(array("\n", '</p>', '<br />', '<br>'), array('', "</p>\n\n", "\n", "\n"), $sMsg);
|
||||
$sMsg = trim(strip_tags($sMsg));
|
||||
$sMsg = explode("\n", $sMsg);
|
||||
for ($i = 0, $n = count($sMsg); $i < $n; $i ++) {
|
||||
$sMsg[$i] = trim($sMsg[$i]);
|
||||
}
|
||||
$sMsg = implode("\n", $sMsg);
|
||||
$sMsg = html_entity_decode($sMsg);
|
||||
$sMsg = capiStrReplaceDiacritics($sMsg);
|
||||
# <-- Nur-Text-Bereich
|
||||
$oMail->AltBody = $sMsg;
|
||||
for ($i = 0, $n = count($attachments); $i < $n; $i ++) {
|
||||
if (is_file($attachments[$i])) {
|
||||
$oMail->AddAttachment($attachments[$i]);
|
||||
}
|
||||
}
|
||||
$oMail->WordWrap = 76;
|
||||
return $oMail->Send();
|
||||
}
|
||||
|
||||
# sitSetClientProperty()
|
||||
#
|
||||
# Speichert eine Mandanteneinstellung
|
||||
#
|
||||
# Parameter:
|
||||
# $type - Typ des Entrags (Text)
|
||||
# $name - Name des Eintrags
|
||||
# $value - Wert des Eintrags (Text)
|
||||
#
|
||||
# Speichert ein Eintrag in den Mandanteneinstellungen, überschreibt dabei
|
||||
# eine gleichnamige vorhandene Einstellung.
|
||||
function sitSetClientProperty($type, $name, $value) {
|
||||
global $client, $cfg;
|
||||
|
||||
if ((strlen($type)) && (strlen($name))) {
|
||||
$type = sitSafeStringEscape($type);
|
||||
$name = sitSafeStringEscape($name);
|
||||
$value = sitSafeStringEscape($value);
|
||||
$db = new DB_Contenido();
|
||||
$sql = 'SELECT value
|
||||
FROM ' . $cfg['tab']['properties'] . '
|
||||
WHERE ((idclient=' . $client . ')
|
||||
AND (itemtype="clientsetting")
|
||||
AND (type="' . $type . '")
|
||||
AND (name="' . $name . '"))';
|
||||
$db->query($sql);
|
||||
if ($db->next_record()) {
|
||||
$sql = 'UPDATE ' . $cfg['tab']['properties'] . '
|
||||
SET value = "' . $value . '",
|
||||
modified = "' . date('Y-m-d H:i:n') . '",
|
||||
modifiedby = "' . $auth->auth['uid'] . '"
|
||||
WHERE ((idclient=' . $client . ')
|
||||
AND (itemtype="clientsetting")
|
||||
AND (type="' . $type . '")
|
||||
AND (name="' . $name . '"))';
|
||||
} else {
|
||||
$sql = 'INSERT INTO ' . $cfg['tab']['properties'] . ' (idclient, itemtype, itemid, type, name, value, author, created, modified, modifiedby)
|
||||
VALUES (' . $client . ', "clientsetting", 1, "' . $type . '", "' . $name . '", "' . $value . '", "' . $auth->auth['uid'] . '", "' . date('Y-m-d H:i:n') . '", "' . date('Y-m-d H:i:n') . '", "' . $auth->auth['uid'] . '")';
|
||||
}
|
||||
$db->query($sql);
|
||||
}
|
||||
}
|
||||
|
||||
# sitTeaserText()
|
||||
#
|
||||
# Teasert einen Text an
|
||||
#
|
||||
# Parameter:
|
||||
# $text - Zu teasernden Text
|
||||
# $maxlength - Maximale Länge des Textes
|
||||
#
|
||||
# Der Text wird auf die maximale Anzahl Zeichen gekürzt, wobei der Schnitt nicht
|
||||
# mitten im Wort erfolgt, sondern davor.
|
||||
# Zuvor werden aus dem Text noch alle HTML-Tags entfernt.
|
||||
# Wenn der Text gekürzt wird (nur wenn der Text länger als der maximalen Anzahl
|
||||
# Zeichen ist), wird ein HTML-Zeichen … (...) angehängt.
|
||||
function sitTeaserText($text, $maxlength) {
|
||||
$sText1 = strip_tags(str_replace(array("\r\n", "\n"), ' ', $text));
|
||||
$sText2 = capiStrTrimAfterWord($sText1, intval($maxlength));
|
||||
if (strlen($sText2) < strlen($sText1)) {
|
||||
$sText2 .= '…';
|
||||
}
|
||||
return $sText2;
|
||||
}
|
||||
?>
|
|
@ -0,0 +1,4 @@
|
|||
# Ignore everything in this directory
|
||||
*
|
||||
# Except this file
|
||||
!.gitignore
|
|
@ -0,0 +1,4 @@
|
|||
# Ignore everything in this directory
|
||||
*
|
||||
# Except this file
|
||||
!.gitignore
|
|
@ -0,0 +1,4 @@
|
|||
# Ignore everything in this directory
|
||||
*
|
||||
# Except this file
|
||||
!.gitignore
|
|
@ -0,0 +1,4 @@
|
|||
# Ignore everything in this directory
|
||||
*
|
||||
# Except this file
|
||||
!.gitignore
|
|
@ -0,0 +1,4 @@
|
|||
# Ignore everything in this directory
|
||||
*
|
||||
# Except this file
|
||||
!.gitignore
|
|
@ -1,4 +0,0 @@
|
|||
[Dolphin]
|
||||
Timestamp=2016,9,20,14,42,23
|
||||
Version=3
|
||||
ViewMode=1
|
|
@ -186,6 +186,8 @@ class Contenido_UrlBuilder_MR extends Contenido_UrlBuilder
|
|||
// get pretty url parts
|
||||
$oMRUrlStack = ModRewriteUrlStack::getInstance();
|
||||
$aPretty = $oMRUrlStack->getPrettyUrlParts('front_content.php?' . $sQuery);
|
||||
|
||||
ModRewriteDebugger::add($aPretty, 'Contenido_UrlBuilder_MR::_buildUrl() getPrettyUrlParts');
|
||||
|
||||
// get all non contenido related query parameter
|
||||
$sQuery = $this->_createUrlQueryPart($aParams);
|
||||
|
@ -209,6 +211,9 @@ class Contenido_UrlBuilder_MR extends Contenido_UrlBuilder
|
|||
$aParts[] = $sPath;
|
||||
}
|
||||
$sPath = implode('/', $aParts) . '/';
|
||||
|
||||
ModRewriteDebugger::add($aParts, 'Contenido_UrlBuilder_MR::_buildUrl() $aParts');
|
||||
ModRewriteDebugger::add($sPath, 'Contenido_UrlBuilder_MR::_buildUrl() $sPath');
|
||||
|
||||
// get pagename part of the url
|
||||
$sArticle = $this->_getArticleName($aPretty, $aParams);
|
||||
|
@ -343,7 +348,7 @@ class Contenido_UrlBuilder_MR extends Contenido_UrlBuilder
|
|||
*/
|
||||
private function _getPath(array $aPretty)
|
||||
{
|
||||
$sPath = (isset($aPretty['urlpath'])) ? $aPretty['urlpath'] : '';
|
||||
$sPath = (!empty($aPretty['urlpath'])) ? $aPretty['urlpath'] : '';
|
||||
|
||||
// check start directory settings
|
||||
if ($this->_aMrCfg['startfromroot'] == 0 && (strlen($sPath) > 0)) {
|
||||
|
|
|
@ -6,17 +6,15 @@
|
|||
* Description:
|
||||
* Base Class for all cHTML Elements
|
||||
*
|
||||
* @category ConLite
|
||||
* @package Core
|
||||
* @subpackage cHTML
|
||||
* @version $Rev$
|
||||
* @since 2.0
|
||||
* @author Ortwin Pinke <o.pinke@conlite.org>
|
||||
* @copyright (c) 2012, conlite.org
|
||||
* @license http://www.gnu.de/documents/gpl.en.html GPL v3 (english version)
|
||||
* @license http://www.gnu.de/documents/gpl.de.html GPL v3 (deutsche Version)
|
||||
* @link http://www.conlite.org ConLite.org
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
// security check
|
||||
|
|
|
@ -6,17 +6,15 @@
|
|||
* Description:
|
||||
* cHTML Meta
|
||||
*
|
||||
* @category ConLite
|
||||
* @package Core
|
||||
* @subpackage cHTML
|
||||
* @version $Rev$
|
||||
* @since 2.0
|
||||
* @author Ortwin Pinke <o.pinke@conlite.org>
|
||||
* @copyright (c) 2015, conlite.org
|
||||
* @license http://www.gnu.de/documents/gpl.en.html GPL v3 (english version)
|
||||
* @license http://www.gnu.de/documents/gpl.de.html GPL v3 (deutsche Version)
|
||||
* @link http://www.conlite.org ConLite.org
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
// security check
|
||||
|
|
|
@ -7,17 +7,15 @@
|
|||
* Description:
|
||||
* cHTML List Element
|
||||
*
|
||||
* @category ConLite
|
||||
* @package Core
|
||||
* @subpackage cHTML
|
||||
* @version $Rev$
|
||||
* @since 2.0
|
||||
* @author Ortwin Pinke <o.pinke@conlite.org>
|
||||
* @copyright (c) 2015, conlite.org
|
||||
* @license http://www.gnu.de/documents/gpl.en.html GPL v3 (english version)
|
||||
* @license http://www.gnu.de/documents/gpl.de.html GPL v3 (deutsche Version)
|
||||
* @link http://www.conlite.org ConLite.org
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
// security check
|
||||
defined('CON_FRAMEWORK') or die('Illegal call');
|
||||
|
|
|
@ -6,17 +6,15 @@
|
|||
* Description:
|
||||
* cHTML List
|
||||
*
|
||||
* @category ConLite
|
||||
* @package Core
|
||||
* @subpackage cHTML
|
||||
* @version $Rev$
|
||||
* @since 2.0
|
||||
* @author Ortwin Pinke <o.pinke@conlite.org>
|
||||
* @copyright (c) 2015, conlite.org
|
||||
* @license http://www.gnu.de/documents/gpl.en.html GPL v3 (english version)
|
||||
* @license http://www.gnu.de/documents/gpl.de.html GPL v3 (deutsche Version)
|
||||
* @link http://www.conlite.org ConLite.org
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
// security check
|
||||
|
|
|
@ -6,17 +6,15 @@
|
|||
* Description:
|
||||
* cHTML Meta
|
||||
*
|
||||
* @category ConLite
|
||||
* @package Core
|
||||
* @subpackage cHTML
|
||||
* @version $Rev$
|
||||
* @since 2.0
|
||||
* @author Ortwin Pinke <o.pinke@conlite.org>
|
||||
* @copyright (c) 2015, conlite.org
|
||||
* @license http://www.gnu.de/documents/gpl.en.html GPL v3 (english version)
|
||||
* @license http://www.gnu.de/documents/gpl.de.html GPL v3 (deutsche Version)
|
||||
* @link http://www.conlite.org ConLite.org
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
// security check
|
||||
|
|
|
@ -1,7 +1,28 @@
|
|||
<?php
|
||||
/**
|
||||
* Article Collector Class
|
||||
*
|
||||
* This is an helper class to collect articles for article list etc.
|
||||
*
|
||||
* @category ConLite
|
||||
* @package Core
|
||||
* @subpackage clHelper
|
||||
* @since 2.1
|
||||
* @author Ortwin Pinke <o.pinke@conlite.org>
|
||||
* @copyright (c) 2019, conlite.org
|
||||
* @license http://www.gnu.de/documents/gpl.en.html GPL v3 (english version)
|
||||
* @license http://www.gnu.de/documents/gpl.de.html GPL v3 (deutsche Version)
|
||||
* @link http://www.conlite.org ConLite.org
|
||||
*/
|
||||
|
||||
defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
|
||||
|
||||
|
||||
/**
|
||||
* Class Article Collector
|
||||
*
|
||||
* @author Ortwin Pinke <o.pinke@conlite.org>
|
||||
*/
|
||||
class cArticleCollector implements SeekableIterator, Countable {
|
||||
|
||||
/**
|
||||
|
|
|
@ -327,7 +327,7 @@ class clDbBackup {
|
|||
}
|
||||
$f = @fopen($this->_sLogFile, 'a+');
|
||||
if (is_resource($f)) {
|
||||
@fputs($f, date("m.d.Y g:ia") . " " . $_SERVER['REMOTE_ADDR'] . " " . $sMessage . "\n");
|
||||
@fputs($f, date("d.m.Y g:ia") . " " . $_SERVER['REMOTE_ADDR'] . " " . $sMessage . "\n");
|
||||
@fclose($f);
|
||||
}
|
||||
}
|
||||
|
|
Datei-Diff unterdrückt, da er zu groß ist
Diff laden
|
@ -191,7 +191,7 @@ class HtmlParser {
|
|||
if ($this->iHtmlTextIndex >= $this->iHtmlTextLength) {
|
||||
return -1;
|
||||
}
|
||||
return $this->iHtmlText{$this->iHtmlTextIndex};
|
||||
return $this->iHtmlText[$this->iHtmlTextIndex];
|
||||
}
|
||||
|
||||
function moveNext() {
|
||||
|
|
|
@ -0,0 +1,405 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This file contains the multi byte wrapper class for strings.
|
||||
*
|
||||
* @package Core
|
||||
* @subpackage Util
|
||||
* @author Frederic Schneider <frederic.schneider@4fb.de>
|
||||
* @author Marcus Gnaß <marcus.gnass@4fb.de>
|
||||
* @copyright four for business AG <www.4fb.de>
|
||||
* @license http://www.contenido.org/license/LIZENZ.txt
|
||||
* @link http://www.4fb.de
|
||||
* @link http://www.contenido.org
|
||||
*/
|
||||
|
||||
defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
|
||||
|
||||
/**
|
||||
* Wrapper class for mbstring functions to be used with strings.
|
||||
*
|
||||
* Each method is a wrapper for a mbstring function that implements a fallback
|
||||
* to the regular string function if the mbstring function does not exist
|
||||
* or the mbstring extension itself is not available.
|
||||
*
|
||||
* @package Core
|
||||
* @subpackage Util
|
||||
* @todo add mb_chr(), mb_ord()
|
||||
*/
|
||||
class cStringMultiByteWrapper {
|
||||
|
||||
/**
|
||||
* Checks if a given mbstring function exists.
|
||||
*
|
||||
* Caches informations about existing mbstring functions for better
|
||||
* performance.
|
||||
*
|
||||
* @param string $functionName
|
||||
* @return bool
|
||||
*/
|
||||
protected static function _functionExists($functionName) {
|
||||
static $cache;
|
||||
if (!isset($cache)) {
|
||||
$cache = array();
|
||||
foreach (array(
|
||||
'mb_strtolower', 'mb_strtoupper', 'mb_strlen', 'mb_substr',
|
||||
'mb_substr_count', 'mb_send_mail', 'mb_strpos', 'mb_strrpos', 'mb_stripos',
|
||||
'mb_strripos', 'mb_stristr', 'mb_strrchr'
|
||||
) as $function) {
|
||||
$cache[$function] = function_exists($function);
|
||||
}
|
||||
}
|
||||
return isset($cache[$functionName]) ? $cache[$functionName] : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines multi byte encoding to be used for various mbstring functions.
|
||||
*
|
||||
* If NULL is given the encoding for the current language is used
|
||||
* which tends to be awfully slow as it requires a database lookup!
|
||||
*
|
||||
* If none could be determined the current set encoding is used.
|
||||
*
|
||||
* @param string|null $encoding
|
||||
* - give a string to use a specific encoding
|
||||
* - give null to use the encoding of the current language
|
||||
* @return string
|
||||
*/
|
||||
protected static function _getEncoding($encoding = null) {
|
||||
if (!is_string($encoding)) {
|
||||
$encoding = mb_internal_encoding();
|
||||
}
|
||||
return $encoding;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a string lowercase
|
||||
*
|
||||
* @param string $string
|
||||
* The string being lowercased
|
||||
* @param string|null $encoding
|
||||
* encoding parameter, standard: cRegistry::getEncoding()
|
||||
* @return string
|
||||
* with all alphabetic characters converted to lowercases
|
||||
* @link http://php.net/manual/de/function.mb-strtolower.php
|
||||
*/
|
||||
public static function toLowerCase($string, $encoding = null) {
|
||||
if (self::_functionExists('mb_strtolower')) {
|
||||
$result = mb_strtolower($string, self::_getEncoding($encoding));
|
||||
} else {
|
||||
$result = strtolower($string);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a string uppercase
|
||||
*
|
||||
* @param string $string
|
||||
* The string being uppercased
|
||||
* @param string|null $encoding
|
||||
* encoding parameter, standard: cRegistry::getEncoding()
|
||||
* @return string
|
||||
* with all alphabetic characters converted to uppercases
|
||||
* @link http://php.net/manual/de/function.mb-strtoupper.php
|
||||
*/
|
||||
public static function toUpperCase($string, $encoding = null) {
|
||||
if (self::_functionExists('mb_strtoupper')) {
|
||||
$result = mb_strtoupper($string, self::_getEncoding($encoding));
|
||||
} else {
|
||||
$result = strtoupper($string);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get string length
|
||||
*
|
||||
* @param string $string
|
||||
* The string being checked for length
|
||||
* @param string|null $encoding
|
||||
* encoding parameter, standard: cRegistry::getEncoding()
|
||||
* @return int
|
||||
* Returns the number of characters
|
||||
* @link http://php.net/manual/de/function.mb-strlen.php
|
||||
*/
|
||||
public static function getStringLength($string, $encoding = null) {
|
||||
if (self::_functionExists('mb_strlen')) {
|
||||
$result = mb_strlen($string, self::_getEncoding($encoding));
|
||||
} else {
|
||||
$result = strlen($string);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get string length
|
||||
*
|
||||
* @param string $string
|
||||
* The string to extract the substring form
|
||||
* @param int $start
|
||||
* @param int $length [Optional]
|
||||
* Maximum number of characters to use from $string, standard is NULL
|
||||
* @param string|null $encoding
|
||||
* encoding parameter, standard: cRegistry::getEncoding()
|
||||
* @return string
|
||||
* Returns the number of characters
|
||||
* @link http://php.net/manual/de/function.mb-substr.php
|
||||
*/
|
||||
public static function getPartOfString($string, $start, $length = null, $encoding = null) {
|
||||
if (self::_functionExists('mb_substr')) {
|
||||
$result = mb_substr($string, $start, $length, self::_getEncoding($encoding));
|
||||
} else {
|
||||
$result = substr($string, $start, $length);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Count the number of substring occurences
|
||||
*
|
||||
* @param string $haystack
|
||||
* The string being checked
|
||||
* @param string $needle
|
||||
* The string being found
|
||||
* @param string|null $encoding
|
||||
* encoding parameter, standard: cRegistry::getEncoding()
|
||||
* @return int
|
||||
* The number of times the needle substring occurs in the haystack string.
|
||||
* @link http://php.net/manual/de/function.mb-substr-count.php
|
||||
*/
|
||||
public static function countSubstring($haystack, $needle, $encoding = null) {
|
||||
if (self::_functionExists('mb_substr_count')) {
|
||||
$result = mb_substr_count($haystack, $needle, self::_getEncoding($encoding));
|
||||
} else {
|
||||
$result = substr_count($haystack, $needle);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send encoded mail
|
||||
*
|
||||
* @param string $to
|
||||
* The mail addresses being sent to (multiple recipents comma separated)
|
||||
* @param string $subject
|
||||
* The subject of the mail
|
||||
* @param string $message
|
||||
* The message of the mail
|
||||
* @param string $additional_headers [Optional]
|
||||
* @param string $additional_parameter [Optional]
|
||||
* @return boolean
|
||||
* true or false
|
||||
* @link http://php.net/manual/de/function.mb-send-mail.php
|
||||
*/
|
||||
public static function mail($to, $subject, $message, $additional_headers = null, $additional_parameter = null) {
|
||||
if (self::_functionExists('mb_send_mail')) {
|
||||
$result = mb_send_mail($to, $subject, $message, $additional_headers, $additional_parameter);
|
||||
} else {
|
||||
$result = mail($to, $subject, $message, $additional_headers, $additional_parameter);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the position of first occurence of string in a string
|
||||
*
|
||||
* @param string $haystack
|
||||
* @param string $needle
|
||||
* @param integer $offset [Optional]
|
||||
* @param string|null $encoding
|
||||
* encoding parameter, standard: cRegistry::getEncoding()
|
||||
* @return int
|
||||
* Returns the numeric position of the first occurrence of needle in the haystack string
|
||||
* @link http://php.net/manual/de/function.mb-strpos.php
|
||||
*/
|
||||
public static function findFirstPos($haystack, $needle, $offset = 0, $encoding = null) {
|
||||
if (self::_functionExists('mb_strpos')) {
|
||||
$result = mb_strpos($haystack, $needle, $offset, self::_getEncoding($encoding));
|
||||
} else {
|
||||
$result = strpos($haystack, $needle, $offset);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the position of last occurence of string in a string
|
||||
*
|
||||
* @param string $haystack
|
||||
* @param string $needle
|
||||
* @param integer $offset [Optional]
|
||||
* @param string|null $encoding
|
||||
* encoding parameter, standard: cRegistry::getEncoding()
|
||||
* @return int
|
||||
* Returns the numeric position of the last occurrence of needle in the haystack string
|
||||
* @link http://php.net/manual/de/function.mb-strrpos.php
|
||||
*/
|
||||
public static function findLastPos($haystack, $needle, $offset = 0, $encoding = null) {
|
||||
if (self::_functionExists('mb_strrpos')) {
|
||||
$result = mb_strrpos($haystack, $needle, $offset, self::_getEncoding($encoding));
|
||||
} else {
|
||||
$result = strrpos($haystack, $needle, $offset);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds position of first occurrence of a string within another, case insensitive
|
||||
*
|
||||
* @param string $haystack
|
||||
* @param string $needle
|
||||
* @param integer $offset [Optional]
|
||||
* @param string|null $encoding
|
||||
* encoding parameter, standard: cRegistry::getEncoding()
|
||||
* @return int
|
||||
* Returns the numeric position of the first occurrence of needle in the haystack string
|
||||
* @link http://php.net/manual/de/function.mb-stripos.php
|
||||
*/
|
||||
public static function findFirstPosCI($haystack, $needle, $offset = 0, $encoding = null) {
|
||||
if (self::_functionExists('mb_stripos')) {
|
||||
$result = mb_stripos($haystack, $needle, $offset, self::_getEncoding($encoding));
|
||||
} else {
|
||||
$result = stripos($haystack, $needle, $offset);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds position of last occurrence of a string within another, case insensitive
|
||||
*
|
||||
* @param string $haystack
|
||||
* @param string $needle
|
||||
* @param integer $offset [Optional]
|
||||
* @param string|null $encoding
|
||||
* encoding parameter, standard: cRegistry::getEncoding()
|
||||
* @return int
|
||||
* Returns the numeric position of the last occurrence of needle in the haystack string
|
||||
* @link http://php.net/manual/de/function.mb-strripos.php
|
||||
*/
|
||||
public static function findLastPosCI($haystack, $needle, $offset = 0, $encoding = null) {
|
||||
if (self::_functionExists('mb_strripos')) {
|
||||
$result = mb_strripos($haystack, $needle, $offset, self::_getEncoding($encoding));
|
||||
} else {
|
||||
$result = strripos($haystack, $needle, $offset);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds first occurrence of a string within another, case insensitive
|
||||
*
|
||||
* @param string $haystack
|
||||
* @param string $needle
|
||||
* @param boolean $before_needle [Optional]
|
||||
* @param string|null $encoding
|
||||
* encoding parameter, standard: cRegistry::getEncoding()
|
||||
* @return string
|
||||
* Returns the portion of haystack, or FALSE if needle is not found.
|
||||
* @link http://php.net/manual/de/function.mb-stristr.php
|
||||
*/
|
||||
public static function findFirstOccurrenceCI($haystack, $needle, $before_needle = false, $encoding = null) {
|
||||
if (self::_functionExists('mb_stristr')) {
|
||||
$result = mb_stristr($haystack, $needle, $before_needle, self::_getEncoding($encoding));
|
||||
} else {
|
||||
$result = stristr($haystack, $needle, $before_needle);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds first occurrence of a string within another, case insensitive
|
||||
*
|
||||
* @param string $haystack
|
||||
* @param string $needle
|
||||
* @param boolean $part [Optional]
|
||||
* @param string|null $encoding
|
||||
* encoding parameter, standard: cRegistry::getEncoding()
|
||||
* @return string
|
||||
* Returns the portion of haystack, or FALSE if needle is not found.
|
||||
* @link http://php.net/manual/de/function.mb-strrchr.php
|
||||
*/
|
||||
public static function findLastOccurrence($haystack, $needle, $part = false, $encoding = null) {
|
||||
if (self::_functionExists('mb_strrchr')) {
|
||||
$result = mb_strrchr($haystack, $needle, $part, self::_getEncoding($encoding));
|
||||
} elseif (!$part) {
|
||||
$result = strrchr($haystack, $needle);
|
||||
} else {
|
||||
// TODO strrchr canot handle $part = true
|
||||
$result = null;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Regular expression match
|
||||
*
|
||||
* @param string $pattern
|
||||
* @param string $string
|
||||
* @param array $regs [Optional]
|
||||
* @return int
|
||||
* @link http://php.net/manual/de/function.mb-ereg.php
|
||||
*/
|
||||
public static function ereg($pattern, $string, &$regs = array()) {
|
||||
// TODO provide fallback multibyte extension is missing
|
||||
return mb_ereg($pattern, $string, $regs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Regular expression match ignoring case
|
||||
*
|
||||
* @param string $pattern
|
||||
* @param string $string
|
||||
* @param array $regs [Optional]
|
||||
* @return int Returns the byte length of the matched string if a match for pattern was found in string
|
||||
* @link http://php.net/manual/de/function.mb-eregi.php
|
||||
*/
|
||||
public static function eregi($pattern, $string, &$regs = array()) {
|
||||
// TODO provide fallback multibyte extension is missing
|
||||
return mb_eregi($pattern, $string, $regs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace regular expression
|
||||
*
|
||||
* @param string $pattern
|
||||
* @param string $replacement
|
||||
* @param string $string
|
||||
* @param string $option [Optional]
|
||||
* @return false|string Returns the byte length of the matched string if a match for pattern was found in string
|
||||
* @link http://php.net/manual/de/function.mb-ereg-replace.php
|
||||
*/
|
||||
public static function ereg_replace($pattern, $replacement, $string, $option = 'msr') {
|
||||
// TODO provide fallback multibyte extension is missing
|
||||
return mb_ereg_replace($pattern, $replacement, $string, $option);
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace regular expression ignoring case
|
||||
*
|
||||
* @param string $pattern
|
||||
* @param string $replacement
|
||||
* @param string $string
|
||||
* @param string $option [Optional]
|
||||
* @return false|string Returns the byte length of the matched string if a match for pattern was found in string
|
||||
* @link http://php.net/manual/de/function.mb-eregi-replace.php
|
||||
*/
|
||||
public static function eregi_replace($pattern, $replacement, $string, $option = 'msr') {
|
||||
// TODO provide fallback multibyte extension is missing
|
||||
return mb_eregi_replace($pattern, $replacement, $string, $option);
|
||||
}
|
||||
|
||||
/**
|
||||
* Split string using regular expression
|
||||
*
|
||||
* @param string $pattern
|
||||
* @param string $string
|
||||
* @param integer $limit [Optional]
|
||||
* @return string[] The result as an array
|
||||
* @link http://php.net/manual/de/function.mb-split.php
|
||||
*/
|
||||
public static function split($pattern, $string, $limit = -1) {
|
||||
// TODO provide fallback multibyte extension is missing
|
||||
return mb_split($pattern, $string, $limit);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,718 @@
|
|||
<?php
|
||||
/**
|
||||
* This file contains the string utility class.
|
||||
*
|
||||
* @package Core
|
||||
* @subpackage Util
|
||||
* @author Murat Purc <murat@purc.de>
|
||||
* @copyright four for business AG <www.4fb.de>
|
||||
* @license http://www.contenido.org/license/LIZENZ.txt
|
||||
* @link http://www.4fb.de
|
||||
* @link http://www.contenido.org
|
||||
*/
|
||||
|
||||
defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
|
||||
|
||||
/**
|
||||
* String helper class.
|
||||
*
|
||||
* @package Core
|
||||
* @subpackage Util
|
||||
*/
|
||||
class cString extends cStringMultiByteWrapper {
|
||||
|
||||
/**
|
||||
* Replaces a string only once.
|
||||
*
|
||||
* Caution: This function only takes strings as parameters, not arrays!
|
||||
*
|
||||
* @param string $find
|
||||
* String to find
|
||||
* @param string $replace
|
||||
* String to replace
|
||||
* @param string $subject
|
||||
* String to process
|
||||
* @return string
|
||||
* Processed string
|
||||
*/
|
||||
public static function iReplaceOnce($find, $replace, $subject) {
|
||||
$start = parent::findFirstPos(parent::toLowerCase($subject), parent::toLowerCase($find));
|
||||
|
||||
if ($start === false) {
|
||||
return $subject;
|
||||
}
|
||||
|
||||
$end = $start + parent::getStringLength($find);
|
||||
$first = parent::getPartOfString($subject, 0, $start);
|
||||
$last = parent::getPartOfString($subject, $end, parent::getStringLength($subject) - $end);
|
||||
|
||||
$result = $first . $replace . $last;
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces a string only once, in reverse direction.
|
||||
*
|
||||
* Caution: This function only takes strings as parameters, not arrays!
|
||||
*
|
||||
* @param string $find
|
||||
* String to find
|
||||
* @param string $replace
|
||||
* String to replace
|
||||
* @param string $subject
|
||||
* String to process
|
||||
* @return string
|
||||
* Processed string
|
||||
*/
|
||||
public static function iReplaceOnceReverse($find, $replace, $subject) {
|
||||
$start = self::posReverse(parent::toLowerCase($subject), parent::toLowerCase($find));
|
||||
|
||||
if ($start === false) {
|
||||
return $subject;
|
||||
}
|
||||
|
||||
$end = $start + parent::getStringLength($find);
|
||||
|
||||
$first = parent::getPartOfString($subject, 0, $start);
|
||||
$last = parent::getPartOfString($subject, $end, parent::getStringLength($subject) - $end);
|
||||
|
||||
$result = $first . $replace . $last;
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds a string position in reverse direction.
|
||||
*
|
||||
* NOTE: The original cString::findLastPos-function of PHP4 only finds a single character
|
||||
* as needle.
|
||||
*
|
||||
* @param string $haystack
|
||||
* String to search in
|
||||
* @param string $needle
|
||||
* String to search for
|
||||
* @param int $start [optional]
|
||||
* Offset
|
||||
* @return int
|
||||
* String position
|
||||
*/
|
||||
public static function posReverse($haystack, $needle, $start = 0) {
|
||||
$tempPos = parent::findFirstPos($haystack, $needle, $start);
|
||||
|
||||
if ($tempPos === false) {
|
||||
if ($start == 0) {
|
||||
// Needle not in string at all
|
||||
return false;
|
||||
} else {
|
||||
// No more occurances found
|
||||
return $start - parent::getStringLength($needle);
|
||||
}
|
||||
} else {
|
||||
// Find the next occurance
|
||||
return self::posReverse($haystack, $needle, $tempPos + parent::getStringLength($needle));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds slashes to passed variable or array.
|
||||
*
|
||||
* @param string|array $value
|
||||
* Either a string or a multi-dimensional array of values
|
||||
* @return string|array
|
||||
*/
|
||||
public static function addSlashes($value) {
|
||||
$value = is_array($value) ? array_map(array('cString', 'addSlashes'), $value) : addslashes($value);
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes slashes from passed variable or array.
|
||||
*
|
||||
* @param string|array $value
|
||||
* Either a string or a multi-dimensional array of values
|
||||
* @return string|array
|
||||
*/
|
||||
public static function stripSlashes($value) {
|
||||
$value = is_array($value) ? array_map(array('cString', 'stripSlashes'), $value) : stripslashes($value);
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the string haystack ends with needle.
|
||||
*
|
||||
* @param string $haystack
|
||||
* The string to check
|
||||
* @param string $needle
|
||||
* The string with which it should end
|
||||
* @return bool
|
||||
*/
|
||||
public static function endsWith($haystack, $needle) {
|
||||
$length = parent::getStringLength($needle);
|
||||
if ($length == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return parent::getPartOfString($haystack, -$length) === $needle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if needle can be found in haystack.
|
||||
*
|
||||
* @param string $haystack
|
||||
* String to be searched
|
||||
* @param string $needle
|
||||
* String to search for
|
||||
* @return bool
|
||||
*/
|
||||
public static function contains($haystack, $needle) {
|
||||
return !(parent::findFirstPos($haystack, $needle) === false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of PHP 5.3's strstr with beforeNeedle.
|
||||
*
|
||||
* @param string $haystack
|
||||
* String to be searched
|
||||
* @param string $needle
|
||||
* String to search for
|
||||
* @param bool $beforeNeedle [optional]
|
||||
* If true, return everything BEFORE needle
|
||||
* @return string
|
||||
* @link http://php.net/manual/de/function.mb-strstr.php
|
||||
* @link http://php.net/manual/de/function.strstr.php
|
||||
*/
|
||||
public static function strstr($haystack, $needle, $beforeNeedle = false) {
|
||||
|
||||
if (!$beforeNeedle) {
|
||||
if (self::_functionExists('mb_strstr')) {
|
||||
return mb_strstr($haystack, $needle);
|
||||
} else {
|
||||
return strstr($haystack, $needle);
|
||||
}
|
||||
} else {
|
||||
return strtok($haystack, $needle);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function checks if a given format is accepted by php's date function.
|
||||
*
|
||||
* @param string $format
|
||||
* format according to date function specification
|
||||
* @return bool
|
||||
* true if format is correct, false otherwise
|
||||
*/
|
||||
public static function validateDateFormat($format) {
|
||||
// try to create a DateTime instance based on php's date function format specification
|
||||
// return true if date is valid (no wrong format)
|
||||
return false !== DateTime::createFromFormat($format, date($format, time()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract a number from a string.
|
||||
*
|
||||
* @param string $string
|
||||
* String var by reference
|
||||
* @return string
|
||||
*/
|
||||
public static function extractNumber(&$string) {
|
||||
$string = preg_replace('/[^0-9]/', '', $string);
|
||||
return $string;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns whether a string is UTF-8 encoded or not.
|
||||
*
|
||||
* @param string $input
|
||||
* @return bool
|
||||
*/
|
||||
public static function isUtf8($input) {
|
||||
$len = parent::getStringLength($input);
|
||||
|
||||
for ($i = 0; $i < $len; $i++) {
|
||||
$char = ord($input[$i]);
|
||||
|
||||
if ($char < 0x80) {
|
||||
// ASCII char
|
||||
continue;
|
||||
} else if (($char & 0xE0) === 0xC0 && $char > 0xC1) {
|
||||
// 2 byte long char
|
||||
$n = 1;
|
||||
} else if (($char & 0xF0) === 0xE0) {
|
||||
// 3 byte long char
|
||||
$n = 2;
|
||||
} else if (($char & 0xF8) === 0xF0 && $char < 0xF5) {
|
||||
// 4 byte long char
|
||||
$n = 3;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
for ($j = 0; $j < $n; $j++) {
|
||||
$i++;
|
||||
|
||||
if ($i == $len || (ord($input[$i]) & 0xC0) !== 0x80) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks if a value is alphanumeric.
|
||||
*
|
||||
* @param mixed $test
|
||||
* Value to test
|
||||
* @param bool $umlauts [optional]
|
||||
* Use german umlauts
|
||||
* @return bool
|
||||
* Value is alphanumeric
|
||||
*/
|
||||
public static function isAlphanumeric($test, $umlauts = true) {
|
||||
if ($umlauts == true) {
|
||||
$match = "/^[a-z0-9ÄäÖöÜüß ]+$/i";
|
||||
} else {
|
||||
$match = "/^[a-z0-9 ]+$/i";
|
||||
}
|
||||
|
||||
return preg_match($match, $test);
|
||||
}
|
||||
|
||||
/**
|
||||
* Trims a string to a given length and makes sure that all words up to
|
||||
* $maxlen are preserved, without exceeding $maxlen.
|
||||
*
|
||||
* Warning: Currently, this function uses a regular ASCII-Whitespace to do
|
||||
* the separation test. If you are using ' ' to create spaces, this
|
||||
* function will fail.
|
||||
*
|
||||
* Example:
|
||||
* $string = "This is a simple test";
|
||||
* echo cString::trimAfterWord($string, 15);
|
||||
*
|
||||
* This would output "This is a", since this function respects word
|
||||
* boundaries and doesn't operate beyond the limit given by $maxlen.
|
||||
*
|
||||
* @param string $string
|
||||
* The string to operate on
|
||||
* @param int $maxlen
|
||||
* The maximum number of characters
|
||||
* @return string
|
||||
* The resulting string
|
||||
*/
|
||||
public static function trimAfterWord($string, $maxlen) {
|
||||
// If the string is smaller than the maximum lenght, it makes no sense to
|
||||
// process it any further. Return it.
|
||||
if (parent::getStringLength($string) < $maxlen) {
|
||||
return $string;
|
||||
}
|
||||
|
||||
// If the character after the $maxlen position is a space, we can return
|
||||
// the string until $maxlen.
|
||||
if (parent::getPartOfString($string, $maxlen, 1) == ' ') {
|
||||
return parent::getPartOfString($string, 0, $maxlen);
|
||||
}
|
||||
|
||||
// Cut the string up to $maxlen so we can use cString::findLastPos (reverse str position)
|
||||
$cutted_string = parent::getPartOfString($string, 0, $maxlen);
|
||||
|
||||
// Extract the end of the last word
|
||||
$last_word_position = cString::findLastPos($cutted_string, ' ');
|
||||
|
||||
return parent::getPartOfString($cutted_string, 0, $last_word_position);
|
||||
}
|
||||
|
||||
/**
|
||||
* Trims a string to a specific length.
|
||||
*
|
||||
* If the string is longer than $maxlen, dots are inserted ("...") right
|
||||
* before $maxlen.
|
||||
*
|
||||
* Example:
|
||||
* $string = "This is a simple test";
|
||||
* echo cString::trimHard ($string, 15);
|
||||
*
|
||||
* This would output "This is a si...", since the string is longer than
|
||||
* $maxlen and the resulting string matches 15 characters including the dots.
|
||||
*
|
||||
* @param string $string
|
||||
* The string to operate on
|
||||
* @param int $maxlen
|
||||
* The maximum number of characters
|
||||
* @param string $fillup [optional]
|
||||
* @return string
|
||||
* The resulting string
|
||||
*/
|
||||
public static function trimHard($string, $maxlen, $fillup = '...') {
|
||||
// If the string is smaller than the maximum lenght, it makes no sense to
|
||||
// process it any further. Return it.
|
||||
if (parent::getStringLength($string) < $maxlen) {
|
||||
return $string;
|
||||
}
|
||||
|
||||
// Calculate the maximum text length
|
||||
$maximum_text_length = $maxlen - parent::getStringLength($fillup);
|
||||
|
||||
// If text length is over zero cut it
|
||||
if ($maximum_text_length > 0) {
|
||||
if (preg_match('/(*UTF8)^.{0,' . $maximum_text_length . '}/', $string, $result_array)) {
|
||||
$cutted_string = $result_array[0];
|
||||
} else if (preg_match('/^.{0,' . $maximum_text_length . '}/u', $string, $result_array)) {
|
||||
$cutted_string = $result_array[0];
|
||||
} else {
|
||||
$cutted_string = parent::getPartOfString($string, 0, $maximum_text_length);
|
||||
}
|
||||
} else {
|
||||
$cutted_string = $string;
|
||||
}
|
||||
|
||||
// Append the fillup string
|
||||
$cutted_string .= $fillup;
|
||||
|
||||
return $cutted_string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Trims a string to a approximate length preserving sentence boundaries.
|
||||
*
|
||||
* The algorithm inside calculates the sentence length to the previous and
|
||||
* next sentences. The distance to the next sentence which is smaller will
|
||||
* be taken to trim the string to match the approximate length parameter.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* $string = "This contains two sentences. ";
|
||||
* $string .= "Lets play around with them. ";
|
||||
*
|
||||
* echo cString::trimSentence($string, 40);
|
||||
* echo cString::trimSentence($string, 50);
|
||||
*
|
||||
* The first example would only output the first sentence, the second
|
||||
* example both sentences.
|
||||
*
|
||||
* Explanation:
|
||||
*
|
||||
* To match the given max length closely, the function calculates the
|
||||
* distance to the next and previous sentences. Using the maxlength of 40
|
||||
* characters, the distance to the previous sentence would be 8 characters,
|
||||
* and to the next sentence it would be 19 characters. Therefore, only the
|
||||
* previous sentence is displayed.
|
||||
*
|
||||
* The second example displays the second sentence also, since the distance
|
||||
* to the next sentence is only 9 characters, but to the previous it is 18
|
||||
* characters.
|
||||
*
|
||||
* If you specify the boolean flag "$hard", the limit parameter creates a
|
||||
* hard limit instead of calculating the distance.
|
||||
*
|
||||
* This function ensures that at least one sentence is returned.
|
||||
*
|
||||
* @param string $string
|
||||
* The string to operate on
|
||||
* @param int $approxlen
|
||||
* The approximate number of characters
|
||||
* @param bool $hard [optional]
|
||||
* If true, use a hard limit for the number of characters
|
||||
* @return string
|
||||
* The resulting string
|
||||
*/
|
||||
public static function trimSentence($string, $approxlen, $hard = false) {
|
||||
// If the string is smaller than the maximum lenght, it makes no sense to
|
||||
// process it any further. Return it.
|
||||
if (parent::getStringLength($string) < $approxlen) {
|
||||
return $string;
|
||||
}
|
||||
|
||||
// Find out the start of the next sentence
|
||||
$next_sentence_start = parent::findFirstPos($string, '.', $approxlen);
|
||||
|
||||
// If there's no next sentence (somebody forgot the dot?), set it to the end
|
||||
// of the string.
|
||||
if ($next_sentence_start === false) {
|
||||
$next_sentence_start = parent::getStringLength($string);
|
||||
}
|
||||
|
||||
// Cut the previous sentence so we can use cString::findLastPos
|
||||
$previous_sentence_cutted = parent::getPartOfString($string, 0, $approxlen);
|
||||
|
||||
// Get out the previous sentence start
|
||||
$previous_sentence_start = cString::findLastPos($previous_sentence_cutted, '.');
|
||||
|
||||
// If the sentence doesn't contain a dot, use the text start.
|
||||
if ($previous_sentence_start === false) {
|
||||
$previous_sentence_start = 0;
|
||||
}
|
||||
|
||||
// If we have a hard limit, we only want to process everything before
|
||||
// $approxlen
|
||||
if (($hard == true) && ($next_sentence_start > $approxlen)) {
|
||||
return parent::getPartOfString($string, 0, $previous_sentence_start + 1);
|
||||
}
|
||||
|
||||
// Calculate next and previous sentence distances
|
||||
$distance_previous_sentence = $approxlen - $previous_sentence_start;
|
||||
$distance_next_sentence = $next_sentence_start - $approxlen;
|
||||
|
||||
// Sanity: Return at least one sentence.
|
||||
$sanity = parent::getPartOfString($string, 0, $previous_sentence_start + 1);
|
||||
|
||||
if (parent::findFirstPos($sanity, '.') === false) {
|
||||
return parent::getPartOfString($string, 0, $next_sentence_start + 1);
|
||||
}
|
||||
|
||||
// Decide wether the next or previous sentence is nearer
|
||||
if ($distance_previous_sentence > $distance_next_sentence) {
|
||||
return parent::getPartOfString($string, 0, $next_sentence_start + 1);
|
||||
} else {
|
||||
return parent::getPartOfString($string, 0, $previous_sentence_start + 1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts diactritics to english characters whenever possible.
|
||||
*
|
||||
* For german umlauts, this function converts the umlauts to their ASCII
|
||||
* equivalents (e.g. ä => ae).
|
||||
*
|
||||
* For more information about diacritics, refer to
|
||||
* http://en.wikipedia.org/wiki/Diacritic
|
||||
*
|
||||
* For other languages, the diacritic marks are removed, if possible.
|
||||
*
|
||||
* @param string $string
|
||||
* The string to operate on
|
||||
* @param string $sourceEncoding [optional; default: UTF-8]
|
||||
* The source encoding
|
||||
* @param string $targetEncoding [optional; default: UTF-8]
|
||||
* The target encoding
|
||||
*
|
||||
* @return string
|
||||
* The resulting string
|
||||
* @throws cInvalidArgumentException
|
||||
*/
|
||||
public static function replaceDiacritics($string, $sourceEncoding = 'UTF-8', $targetEncoding = 'UTF-8') {
|
||||
if ($sourceEncoding != 'UTF-8') {
|
||||
$string = self::recodeString($string, $sourceEncoding, "UTF-8");
|
||||
}
|
||||
|
||||
// replace regular german umlauts and other common characters with
|
||||
// diacritics
|
||||
static $search, $replace;
|
||||
if (!isset($search)) {
|
||||
$search = array(
|
||||
'Ä',
|
||||
'Ö',
|
||||
'Ü',
|
||||
'ä',
|
||||
'ö',
|
||||
'ü',
|
||||
'ß',
|
||||
'Á',
|
||||
'À',
|
||||
'Â',
|
||||
'á',
|
||||
'à',
|
||||
'â',
|
||||
'É',
|
||||
'È',
|
||||
'Ê',
|
||||
'é',
|
||||
'è',
|
||||
'ê',
|
||||
'Í',
|
||||
'Ì',
|
||||
'Î',
|
||||
'í',
|
||||
'ì',
|
||||
'î',
|
||||
'Ó',
|
||||
'Ò',
|
||||
'Ô',
|
||||
'ó',
|
||||
'ò',
|
||||
'ô',
|
||||
'Ú',
|
||||
'Ù',
|
||||
'Û',
|
||||
'ú',
|
||||
'ù',
|
||||
'û'
|
||||
);
|
||||
$replace = array(
|
||||
'Ae',
|
||||
'Oe',
|
||||
'Ue',
|
||||
'ae',
|
||||
'oe',
|
||||
'ue',
|
||||
'ss',
|
||||
'A',
|
||||
'A',
|
||||
'A',
|
||||
'a',
|
||||
'a',
|
||||
'a',
|
||||
'E',
|
||||
'E',
|
||||
'E',
|
||||
'e',
|
||||
'e',
|
||||
'e',
|
||||
'I',
|
||||
'I',
|
||||
'I',
|
||||
'i',
|
||||
'i',
|
||||
'i',
|
||||
'O',
|
||||
'O',
|
||||
'O',
|
||||
'o',
|
||||
'o',
|
||||
'o',
|
||||
'U',
|
||||
'U',
|
||||
'U',
|
||||
'u',
|
||||
'u',
|
||||
'u'
|
||||
);
|
||||
}
|
||||
$string = str_replace($search, $replace, $string);
|
||||
|
||||
// TODO: Additional converting
|
||||
|
||||
return self::recodeString($string, "UTF-8", $targetEncoding);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a string to another encoding.
|
||||
*
|
||||
* This function tries to detect which function to use (either recode or
|
||||
* iconv).
|
||||
*
|
||||
* If $sourceEncoding and $targetEncoding are the same, this function
|
||||
* returns immediately.
|
||||
*
|
||||
* For more information about encodings, refer to
|
||||
* http://en.wikipedia.org/wiki/Character_encoding
|
||||
*
|
||||
* For more information about the supported encodings in recode, refer to
|
||||
* http://www.delorie.com/gnu/docs/recode/recode_toc.html
|
||||
*
|
||||
* Note: depending on whether recode or iconv is used, the supported
|
||||
* charsets differ. The following ones are commonly used and are most likely
|
||||
* supported by both converters:
|
||||
*
|
||||
* - ISO-8859-1 to ISO-8859-15
|
||||
* - ASCII
|
||||
* - UTF-8
|
||||
*
|
||||
* @todo Check if the charset names are the same for both converters
|
||||
* @todo Implement a converter and charset checker to ensure compilance.
|
||||
*
|
||||
* @param string $string
|
||||
* The string to operate on
|
||||
* @param string $sourceEncoding
|
||||
* The source encoding
|
||||
* @param string $targetEncoding
|
||||
* The target encoding (if false, use source encoding)
|
||||
*
|
||||
* @return string
|
||||
* The resulting string
|
||||
* @throws cInvalidArgumentException
|
||||
*/
|
||||
public static function recodeString($string, $sourceEncoding, $targetEncoding) {
|
||||
// If sourceEncoding and targetEncoding are the same, return
|
||||
if (parent::toLowerCase($sourceEncoding) == parent::toLowerCase($targetEncoding)) {
|
||||
return $string;
|
||||
}
|
||||
|
||||
// Check for the "recode" support
|
||||
if (function_exists('recode')) {
|
||||
$sResult = recode_string("$sourceEncoding..$targetEncoding", $string);
|
||||
return $sResult;
|
||||
}
|
||||
|
||||
// Check for the "iconv" support
|
||||
if (function_exists('iconv')) {
|
||||
$sResult = iconv($sourceEncoding, $targetEncoding, $string);
|
||||
return $sResult;
|
||||
}
|
||||
|
||||
// No charset converters found; return with warning
|
||||
cWarning(__FILE__, __LINE__, 'cString::recodeString could not find either recode or iconv to do charset conversion.');
|
||||
return $string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes or converts all "evil" URL characters.
|
||||
*
|
||||
* This function removes or converts all characters which can make an URL
|
||||
* invalid.
|
||||
*
|
||||
* Clean characters include:
|
||||
* - All characters between 32 and 126 which are not alphanumeric and
|
||||
* aren't one of the following: _-.
|
||||
*
|
||||
* @param string $string
|
||||
* The string to operate on
|
||||
* @param bool $replace [optional]
|
||||
* If true, all "unclean" characters are replaced
|
||||
*
|
||||
* @return string
|
||||
* The resulting string
|
||||
* @throws cInvalidArgumentException
|
||||
*/
|
||||
public static function cleanURLCharacters($string, $replace = false) {
|
||||
$string = self::replaceDiacritics($string);
|
||||
$string = str_replace(' ', '-', $string);
|
||||
$string = str_replace('/', '-', $string);
|
||||
$string = str_replace('&', '-', $string);
|
||||
$string = str_replace('+', '-', $string);
|
||||
|
||||
$iStrLen = parent::getStringLength($string);
|
||||
|
||||
$sResultString = '';
|
||||
|
||||
for ($i = 0; $i < $iStrLen; $i++) {
|
||||
$sChar = parent::getPartOfString($string, $i, 1);
|
||||
|
||||
if (preg_match('/^[a-z0-9]*$/i', $sChar) || $sChar == '-' || $sChar == '_' || $sChar == '.') {
|
||||
$sResultString .= $sChar;
|
||||
} else {
|
||||
if ($replace == true) {
|
||||
$sResultString .= '_';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $sResultString;
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalizes line endings in passed string.
|
||||
*
|
||||
* @param string $string
|
||||
* @param string $lineEnding [optional]
|
||||
* Feasible values are "\n", "\r" or "\r\n"
|
||||
* @return string
|
||||
*/
|
||||
public static function normalizeLineEndings($string, $lineEnding = "\n") {
|
||||
if ($lineEnding !== "\n" && $lineEnding !== "\r" && $lineEnding !== "\r\n") {
|
||||
$lineEnding = "\n";
|
||||
}
|
||||
|
||||
$string = str_replace("\r\n", "\n", $string);
|
||||
$string = str_replace("\r", "\n", $string);
|
||||
if ($lineEnding !== "\n") {
|
||||
$string = str_replace("\n", $lineEnding, $string);
|
||||
}
|
||||
|
||||
return $string;
|
||||
}
|
||||
}
|
|
@ -46,6 +46,36 @@ class cRegistry {
|
|||
return $cfg['path']['contenido_fullhtml'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Function which returns path after the last possible place changing via
|
||||
* configuration file.
|
||||
* The path point to the current client
|
||||
*
|
||||
* @author konstantinos.katikakis
|
||||
* @return string
|
||||
* path
|
||||
*/
|
||||
public static function getFrontendPath() {
|
||||
$cfgClient = self::getClientConfig();
|
||||
$client = self::getClientId();
|
||||
return $cfgClient[$client]['path']['frontend'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Function which returns URL after the last possible place changing via
|
||||
* configuration file.
|
||||
* The path point to the current client
|
||||
*
|
||||
* @author konstantinos.katikakis
|
||||
* @return string
|
||||
* URL
|
||||
*/
|
||||
public static function getFrontendUrl() {
|
||||
$cfgClient = self::getClientConfig();
|
||||
$client = self::getClientId();
|
||||
return $cfgClient[$client]['path']['htmlpath'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the client configuration array stored in the global variable
|
||||
* "cfgClient".
|
||||
|
|
|
@ -10,7 +10,8 @@
|
|||
* @con_php_req 5.0
|
||||
*
|
||||
*
|
||||
* @package Contenido Backend includes
|
||||
* @package Core
|
||||
* @subpackage Backend
|
||||
* @version 1.0.2
|
||||
* @author Timo A. Hummel
|
||||
* @copyright four for business AG <www.4fb.de>
|
||||
|
|
|
@ -133,6 +133,8 @@ function dbUpgradeTable($db, $table, $field, $type, $null, $key, $default, $extr
|
|||
} else {
|
||||
$parameter['DEFAULT'] = "DEFAULT '" . Contenido_Security::escapeDB($default, $db) . "'";
|
||||
}
|
||||
} else {
|
||||
$parameter['DEFAULT'] = '';
|
||||
}
|
||||
|
||||
if (!dbTableExists($db, $table)) {
|
||||
|
@ -145,7 +147,7 @@ function dbUpgradeTable($db, $table, $field, $type, $null, $key, $default, $extr
|
|||
// Remove auto_increment
|
||||
$structure = dbGetColumns($db, $table);
|
||||
|
||||
if ($structure[$field]["Extra"] == "auto_increment") {
|
||||
if (isset($structure[$field]) && !empty($structure[$field]["Extra"]) && $structure[$field]["Extra"] == "auto_increment") {
|
||||
if ($structure[$field]['NULL'] == "") {
|
||||
$structure[$field]['NULL'] = "NOT NULL";
|
||||
}
|
||||
|
|
|
@ -396,6 +396,7 @@ function getLanguagesByClient($client) {
|
|||
function getLanguageNamesByClient($client) {
|
||||
global $db;
|
||||
global $cfg;
|
||||
$list = [];
|
||||
|
||||
$sql = "SELECT
|
||||
a.idlang AS idlang,
|
||||
|
@ -1238,7 +1239,7 @@ function buildCategorySelect($sName, $sValue, $sLevel = 0, $sStyle = "") {
|
|||
foreach ($categories as $tmpidcat => $props) {
|
||||
$spaces = " ";
|
||||
|
||||
for ($i = 0; $i < $props["level"]; $i ++) {
|
||||
for ($i = 0; $i < $props["level"]; $i++) {
|
||||
$spaces .= " ";
|
||||
}
|
||||
|
||||
|
@ -1282,7 +1283,7 @@ function human_readable_size($number) {
|
|||
$n = (float) $number; //Appears to be necessary to avoid rounding
|
||||
while ($n >= $base) {
|
||||
$n /= (float) $base;
|
||||
$usesuf ++;
|
||||
$usesuf++;
|
||||
}
|
||||
|
||||
$places = 2 - floor(log10($n));
|
||||
|
@ -1315,7 +1316,7 @@ function array_csort() { //coded by Ichier2003
|
|||
$msortline = "return(array_multisort(";
|
||||
$i = 0;
|
||||
foreach ($args as $arg) {
|
||||
$i ++;
|
||||
$i++;
|
||||
if (is_string($arg)) {
|
||||
foreach ($marray as $row) {
|
||||
$a = strtoupper($row[$arg]);
|
||||
|
@ -1327,7 +1328,9 @@ function array_csort() { //coded by Ichier2003
|
|||
$msortline .= "\$sortarr[" . $i . "],";
|
||||
}
|
||||
$msortline .= "\$marray));";
|
||||
@ eval($msortline);
|
||||
if(is_array($marray) && count($marray) > 0) {
|
||||
@ eval($msortline);
|
||||
}
|
||||
return $marray;
|
||||
}
|
||||
|
||||
|
@ -1689,7 +1692,7 @@ function createRandomName($nameLength) {
|
|||
$Vouel = 'aeiou';
|
||||
$Name = "";
|
||||
|
||||
for ($index = 1; $index <= $nameLength; $index ++) {
|
||||
for ($index = 1; $index <= $nameLength; $index++) {
|
||||
if ($index % 3 == 0) {
|
||||
$randomNumber = rand(1, strlen($Vouel));
|
||||
$Name .= substr($Vouel, $randomNumber - 1, 1);
|
||||
|
|
|
@ -30,11 +30,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
// set constant value depending on get_magic_quotes_gpc status
|
||||
define('CONTENIDO_STRIPSLASHES', (get_magic_quotes_gpc() == 0));
|
||||
|
||||
|
||||
// PHP5 with register_long_arrays off?
|
||||
if (!isset($HTTP_POST_VARS) && isset($_POST)) {
|
||||
$HTTP_POST_VARS = & $_POST;
|
||||
|
@ -48,54 +43,11 @@ if (!isset($HTTP_POST_VARS) && isset($_POST)) {
|
|||
}
|
||||
}
|
||||
|
||||
// simulate get_magic_quotes_gpc on if turned off
|
||||
if (CONTENIDO_STRIPSLASHES) {
|
||||
|
||||
/**
|
||||
* Adds slashes to passed variable
|
||||
*
|
||||
* @param mixed $value Either a string or a multi-dimensional array of values
|
||||
* @return array
|
||||
*/
|
||||
function addslashes_deep($value)
|
||||
{
|
||||
$value = is_array($value) ? array_map('addslashes_deep', $value) : addslashes($value);
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes slashes from passed variable.
|
||||
*
|
||||
* @param mixed $value Either a string or a multi-dimensional array of values
|
||||
* @return array
|
||||
*/
|
||||
function stripslashes_deep($value)
|
||||
{
|
||||
$value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value);
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
$_POST = array_map('addslashes_deep', $_POST);
|
||||
$_GET = array_map('addslashes_deep', $_GET);
|
||||
$_COOKIE = array_map('addslashes_deep', $_COOKIE);
|
||||
|
||||
$cfg['simulate_magic_quotes'] = true;
|
||||
} else {
|
||||
$cfg['simulate_magic_quotes'] = false;
|
||||
}
|
||||
|
||||
if (!isset($_REQUEST) || $cfg['simulate_magic_quotes']) {
|
||||
/* Register post,get and cookie variables into $_REQUEST */
|
||||
$_REQUEST = array_merge($_GET, $_POST, $_COOKIE);
|
||||
}
|
||||
|
||||
// this should be the default setting, but only for PHP older than 5.3.0
|
||||
if (!CONTENIDO_STRIPSLASHES && (version_compare(PHP_VERSION, '5.3.0', '<'))) {
|
||||
@set_magic_quotes_runtime(0);
|
||||
}
|
||||
|
||||
// register globals
|
||||
$types_to_register = array ('GET', 'POST', 'COOKIE', 'SESSION', 'SERVER');
|
||||
foreach ($types_to_register as $global_type) {
|
||||
|
@ -115,6 +67,4 @@ foreach ($types_to_register as $global_type) {
|
|||
// save memory
|
||||
unset ($types_to_register, $global_type, $arr);
|
||||
|
||||
$FORM = $_REQUEST;
|
||||
|
||||
?>
|
||||
$FORM = $_REQUEST;
|
|
@ -754,7 +754,7 @@ if (isset($bDebug) && $bDebug === true) {
|
|||
var_dump($navigationTree);
|
||||
echo '</pre>';
|
||||
}
|
||||
if (count($navigationTree[0])) {
|
||||
if (is_array($navigationTree[0]) && count($navigationTree[0])) {
|
||||
$sCategories = showTree(0, $aWholelist);
|
||||
}
|
||||
|
||||
|
|
|
@ -131,7 +131,7 @@ if(!$perm->have_perm_area_action($area))
|
|||
}
|
||||
|
||||
$years = array();
|
||||
for ($i = 2000; $i < 2020; $i++)
|
||||
for ($i = 2000; $i < 2030; $i++)
|
||||
{
|
||||
$years[$i] = $i;
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ if (!defined('CL_ENVIRONMENT')) {
|
|||
*/
|
||||
if (!defined('CL_VERSION')) {
|
||||
|
||||
define('CL_VERSION', '2.1.1');
|
||||
define('CL_VERSION', '2.1.2');
|
||||
|
||||
}
|
||||
|
||||
|
|
Datei-Diff unterdrückt, da er zu groß ist
Diff laden
Binäre Datei nicht angezeigt.
Datei-Diff unterdrückt, da er zu groß ist
Diff laden
Datei-Diff unterdrückt, da er zu groß ist
Diff laden
|
@ -0,0 +1,7 @@
|
|||
/cl-linkchecker
|
||||
/cl-mod-rewrite
|
||||
/cl-newsletter
|
||||
/cl-workflow
|
||||
/org.conlite.twig
|
||||
/smarty
|
||||
/phpbo.cookie_consent
|
|
@ -0,0 +1,212 @@
|
|||
<?php
|
||||
/**
|
||||
* Project:
|
||||
* Contenido Content Management System
|
||||
*
|
||||
* Description:
|
||||
* Extractor for plugin archive files
|
||||
*
|
||||
* Requirements:
|
||||
* @con_php_req 5.0
|
||||
*
|
||||
*
|
||||
* @package Contenido Backend plugins
|
||||
* @version 1.0.0
|
||||
* @author Dominik Ziegler
|
||||
* @copyright four for business AG <www.4fb.de>
|
||||
* @license http://www.contenido.org/license/LIZENZ.txt
|
||||
* @link http://www.4fb.de
|
||||
* @link http://www.contenido.org
|
||||
* @since file available since contenido release 4.8.7
|
||||
*
|
||||
* {@internal
|
||||
* created 2008-06-06
|
||||
* modified 2008-07-03, Frederic Schneider, add security fix
|
||||
*
|
||||
* $Id: Contenido_ArchiveExtractor.class.php 7 2015-06-23 11:01:26Z oldperl $:
|
||||
* }}
|
||||
*
|
||||
*/
|
||||
|
||||
if(!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
}
|
||||
|
||||
plugin_include('pluginmanager', 'classes/Exceptions/Contenido_ArchiveExtractor_Exception.php');
|
||||
//cInclude('pear', 'PHP/Archive.php');
|
||||
cInclude('pear', 'File/Archive.php');
|
||||
|
||||
class Contenido_ArchiveExtractor {
|
||||
|
||||
/**
|
||||
* The archive file
|
||||
* @var string
|
||||
*/
|
||||
protected $sSource = "";
|
||||
|
||||
/**
|
||||
* The destination path
|
||||
* @var string
|
||||
*/
|
||||
protected $sDestination = "";
|
||||
|
||||
/**
|
||||
* List of all files in the archive
|
||||
* @var array
|
||||
*/
|
||||
protected $aFileList = array();
|
||||
|
||||
/**
|
||||
* The absolute path
|
||||
* @var string
|
||||
*/
|
||||
protected $sAbsPath = "";
|
||||
|
||||
/**
|
||||
* Constructor of ArchiveExtractor, load the file list
|
||||
* @access public
|
||||
* @param string $sSource
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($sSource) {
|
||||
global $cfg;
|
||||
|
||||
$this->sSource = (string) $sSource;
|
||||
|
||||
if (file_exists($sSource)) {
|
||||
|
||||
$sTrailingSlash = substr($this->sSource, -1);
|
||||
|
||||
if( $sTrailingSlash != DIRECTORY_SEPARATOR) {
|
||||
$this->sSource = $this->sSource . DIRECTORY_SEPARATOR;
|
||||
}
|
||||
|
||||
// generate absolute path to the plugin manager directory
|
||||
$this->sAbsPath = $cfg['path']['contenido'] . $cfg['path']['plugins'] . "pluginmanager" . DIRECTORY_SEPARATOR;
|
||||
|
||||
$this->getFileList();
|
||||
|
||||
} else {
|
||||
throw new Contenido_ArchiveExtractor_Exception("Source file does not exists");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function setErrorHandling($mode, $options) {
|
||||
PEAR::setErrorHandling($mode, $options); // use temporary the error handler of PEAR
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the path where the extractor extracts the archive files
|
||||
* @access public
|
||||
* @param string $sDestination
|
||||
* @return void
|
||||
*/
|
||||
public function setDestinationPath($sDestination) {
|
||||
|
||||
if (!is_dir($sDestination)) {
|
||||
$bMakeDirectory = mkdir($sDestination, 0777);
|
||||
|
||||
if ($bMakeDirectory != true) {
|
||||
throw new Contenido_ArchiveExtractor_Exception("Can not set destination path: directoy is not writable");
|
||||
}
|
||||
|
||||
$this->sDestination = (string) $sDestination;
|
||||
|
||||
} else {
|
||||
throw new Contenido_ArchiveExtractor_Exception("Destination already exists");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts the whole archive
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function extractArchive() {
|
||||
|
||||
if ($this->sDestination != "") {
|
||||
File_Archive::extract($this->sSource, $this->sDestination);
|
||||
} else {
|
||||
throw new Contenido_ArchiveExtractor_Exception("Extraction failed: no destination path setted");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the file list of the archive
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function getFileList(){
|
||||
$objArchiveReader = File_Archive::read($this->sSource);
|
||||
$this->aFileList = $objArchiveReader->getFileList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract only one specific file from archive
|
||||
* @access public
|
||||
* @param string $sFilename
|
||||
* @return void
|
||||
*/
|
||||
public function extractArchiveFile($sFilename) {
|
||||
|
||||
$sFilename = (string) $sFilename;
|
||||
$sExtractFile = $this->sSource . $sFilename;
|
||||
|
||||
if ($this->sDestination != "") {
|
||||
File_Archive::extract($sExtractFile, $this->sDestination);
|
||||
} else {
|
||||
throw new Contenido_ArchiveExtractor_Exception("Extraction failed: no destination path setted");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the archives file list
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getArchiveFileList() {
|
||||
return $this->aFileList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a specific file exists in archive
|
||||
* @access public
|
||||
* @param string $sFilename
|
||||
* @return boolean
|
||||
*/
|
||||
public function existsInArchive($sFilename) {
|
||||
|
||||
$aFileList = $this->getArchiveFileList();
|
||||
|
||||
if (in_array($sFilename, $aFileList)) {
|
||||
$bFileCheck = true;
|
||||
} else {
|
||||
$bFileCheck = false;
|
||||
}
|
||||
|
||||
return $bFileCheck;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts a specific file from archive and return its content to use it in a variable
|
||||
* @access public
|
||||
* @param string $sFilename
|
||||
* @return string
|
||||
*/
|
||||
public function extractArchiveFileToVariable($sFilename) {
|
||||
|
||||
$sFilename = (string) $sFilename;
|
||||
$sExtractFile = $this->sSource . $sFilename;
|
||||
|
||||
File_Archive::extract($sExtractFile, File_Archive::toVariable($sReturn));
|
||||
return $sReturn;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
|
@ -0,0 +1,143 @@
|
|||
<?php
|
||||
|
||||
if(!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
}
|
||||
|
||||
class pimPluginArchiveExtractor {
|
||||
|
||||
/**
|
||||
* The extractor initializer
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $_extractor = 0;
|
||||
|
||||
/**
|
||||
* The temp dir
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $tempDir = '';
|
||||
|
||||
/**
|
||||
* The archive file
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_source = '';
|
||||
|
||||
/**
|
||||
* The destination path
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_destination = '';
|
||||
|
||||
/**
|
||||
* The absolute path
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_absPath = '';
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $source
|
||||
* @param string $filename
|
||||
* @throws pimException
|
||||
*/
|
||||
public function __construct($source, $filename) {
|
||||
$cfg = cRegistry::getConfig();
|
||||
|
||||
// initialzing ziparchive
|
||||
$this->_extractor = new ZipArchive();
|
||||
|
||||
// path to temp directory
|
||||
$this->tempDir = $source;
|
||||
|
||||
// temp directory with zip archive
|
||||
$this->_source = (string) $source . (string) $filename;
|
||||
|
||||
if (file_exists($source)) {
|
||||
// generate absolute path to the plugin manager directory
|
||||
$this->_absPath = $cfg['path']['contenido'] . $cfg['path']['plugins'] . 'pluginmanager' . DIRECTORY_SEPARATOR;
|
||||
|
||||
// open the zip archive
|
||||
$this->_extractor->open($this->_source);
|
||||
} else {
|
||||
throw new pimException('Source file does not exists');
|
||||
}
|
||||
}
|
||||
|
||||
public function closeArchive() {
|
||||
$this->_extractor->close();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $destination
|
||||
* @throws pimException
|
||||
*/
|
||||
public function setDestinationPath($destination) {
|
||||
if (!is_dir($destination)) {
|
||||
$makeDirectory = mkdir($destination, 0777);
|
||||
if ($makeDirectory != true) {
|
||||
throw new pimException('Can not set destination path: directoy is not writable');
|
||||
}
|
||||
$this->_destination = (string) $destination;
|
||||
} else {
|
||||
throw new pimException('Destination already exists');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @throws pimException
|
||||
*/
|
||||
public function extractArchive() {
|
||||
if ($this->_destination != '') {
|
||||
$this->_extractor->extractTo($this->_destination);
|
||||
} else {
|
||||
throw new pimException('Extraction failed: no destination path setted');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $filename
|
||||
* @param boolean $content
|
||||
* @return type
|
||||
*/
|
||||
public function extractArchiveFileToVariable($filename, $content = true) {
|
||||
$filename = (string) $filename;
|
||||
$this->_extractor->extractTo($this->tempDir, $filename);
|
||||
|
||||
if ($content) {
|
||||
return file_get_contents($this->tempDir . $filename);
|
||||
} else {
|
||||
return $this->tempDir . $filename;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function destroyTempFiles() {
|
||||
|
||||
// remove plugin.xml if exists
|
||||
if (file_exists($this->tempDir . 'cl_plugin.xml')) {
|
||||
unlink($this->tempDir . 'cl_plugin.xml');
|
||||
}
|
||||
|
||||
// remove plugin_install.sql if exists
|
||||
if (file_exists($this->tempDir . 'plugin_install.sql')) {
|
||||
unlink($this->tempDir . 'plugin_install.sql');
|
||||
}
|
||||
|
||||
// remove temporary plugin dir if exists
|
||||
if (file_exists($this->_source)) {
|
||||
unlink($this->_source);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
|
||||
class pimSqlParser {
|
||||
|
||||
public static function removeComments($sSqlData) {
|
||||
$sRegEx = '@(([\'"]).*?[^\\\]\2)|((?:\#|--).*?$|/\*(?:[^/*]|/(?!\*)|\*(?!/)|(?R))*\*\/)\s*|(?<=;)\s+@ms';
|
||||
|
||||
$sCleanSqlData = trim(preg_replace($sRegEx, '$1', $sSqlData));
|
||||
|
||||
//Eventually remove the last ;
|
||||
if(strrpos($sCleanSqlData, ";") === strlen($sCleanSqlData) - 1) {
|
||||
$sCleanSqlData = substr($sCleanSqlData, 0, strlen($sCleanSqlData) - 1);
|
||||
}
|
||||
|
||||
return $sCleanSqlData;
|
||||
}
|
||||
|
||||
public static function replacePlaceholder($sData) {
|
||||
return str_replace(pimSetupBase::PIM_SQL_PLACEHOLDER, cRegistry::getConfigValue('sql', 'sqlprefix')."_pi", $sData);
|
||||
}
|
||||
|
||||
public static function parse($sSqlData) {
|
||||
$aSingleQueries = array();
|
||||
$sSqlData = pimSqlParser::replacePlaceholder($sSqlData);
|
||||
// Processing the SQL file content
|
||||
$lines = explode("\n", $sSqlData);
|
||||
|
||||
$sQuery = "";
|
||||
|
||||
// Parsing the SQL file content
|
||||
foreach ($lines as $sql_line):
|
||||
$sql_line = trim($sql_line);
|
||||
if($sql_line === "") continue;
|
||||
else if(strpos($sql_line, "--") === 0) continue;
|
||||
else if(strpos($sql_line, "#") === 0) continue;
|
||||
|
||||
$sQuery .= $sql_line;
|
||||
// Checking whether the line is a valid statement
|
||||
if (preg_match("/(.*);/", $sql_line)) {
|
||||
$sQuery = trim($sQuery);
|
||||
$sQuery = substr($sQuery, 0, strlen($sQuery) - 1);
|
||||
|
||||
$sQuery = pimSqlParser::removeComments($sQuery);
|
||||
|
||||
//store this query
|
||||
$aSingleQueries[] = $sQuery;
|
||||
//reset the variable
|
||||
$sQuery = "";
|
||||
}
|
||||
|
||||
endforeach;
|
||||
|
||||
return $aSingleQueries;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
/**
|
||||
* $Id: class.pim.ajax.php 29 2016-10-18 11:27:53Z oldperl $:
|
||||
*/
|
||||
|
||||
if(!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
}
|
||||
|
||||
abstract class pimAjax{
|
||||
|
||||
/**
|
||||
* constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the ajax request named bei param and returns an answer string
|
||||
* child class has to overwrite this method
|
||||
*
|
||||
* @param string $Request requested ajax action
|
||||
* @return string String send back to requesting page
|
||||
*/
|
||||
abstract public function handle($Request);
|
||||
}
|
||||
?>
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
// security check
|
||||
defined('CON_FRAMEWORK') or die('Illegal call');
|
||||
|
||||
|
||||
class pimPluginDummy {
|
||||
|
||||
public function __construct() {
|
||||
;
|
||||
}
|
||||
|
||||
public function get($what) {
|
||||
$return = FALSE;
|
||||
switch($what) {
|
||||
case 'folder':
|
||||
$return = 'pluginmanager';
|
||||
break;
|
||||
|
||||
case 'active':
|
||||
$return = TRUE;
|
||||
break;
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
public function isLoaded() {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -0,0 +1,271 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* @version $Rev: 39 $
|
||||
*
|
||||
* $Id: class.pim.plugin.handler.php 39 2018-01-10 07:49:57Z oldperl $
|
||||
*/
|
||||
if (!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
}
|
||||
|
||||
class pimPluginHandler {
|
||||
|
||||
protected $_iPluginId = 0;
|
||||
protected $_oPlugin = NULL;
|
||||
protected $_bIsLoaded = FALSE;
|
||||
protected $_sPluginPath;
|
||||
|
||||
/**
|
||||
* holds the xml of plugin.xml
|
||||
* @var SimpleXMLElement
|
||||
*/
|
||||
protected $_oPiXml = NULL;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var DomDocument
|
||||
*/
|
||||
protected $_oDomDocument;
|
||||
protected $_xsd = 'plugins/pluginmanager/xml/plugin_info.xsd';
|
||||
protected $_bValid = FALSE;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->_oDomDocument = new DOMDocument();
|
||||
$this->_oDomDocument->preserveWhiteSpace = FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param int $iPluginId
|
||||
* @return boolean
|
||||
*/
|
||||
public function loadPluginFromDb($iPluginId) {
|
||||
$this->_oPlugin = new pimPlugin($iPluginId);
|
||||
if ($this->_oPlugin->isLoaded()) {
|
||||
$this->_iPluginId = $this->_oPlugin->get('idplugin');
|
||||
$this->_sPluginPath = cRegistry::getBackendPath()
|
||||
. cRegistry::getConfigValue('path', 'plugins')
|
||||
. $this->_oPlugin->get('folder')
|
||||
. "/";
|
||||
return TRUE;
|
||||
}
|
||||
$this->_oPlugin = NULL;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $sPluginFolderName
|
||||
* @return boolean
|
||||
*/
|
||||
public function installPlugin($sPluginFolderName) {
|
||||
$iNewPluginId = 0;
|
||||
if (empty($sPluginFolderName)) {
|
||||
return FALSE;
|
||||
}
|
||||
$pluginPath = cRegistry::getBackendPath()
|
||||
. cRegistry::getConfigValue('path', 'plugins')
|
||||
. $sPluginFolderName
|
||||
. "/";
|
||||
|
||||
if (is_null($this->getCfgXmlObject())) {
|
||||
$sPiCfg = $pluginPath . 'cl_plugin.xml';
|
||||
if (is_dir($pluginPath) && file_exists($sPiCfg)) {
|
||||
$this->loadXmlFile($sPiCfg);
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
$oPluginInstaller = new pimSetupPluginInstall();
|
||||
$oPluginInstaller->setXsdFile($this->_xsd);
|
||||
$oPluginInstaller->setXmlObject($this->getCfgXmlObject());
|
||||
$oPluginInstaller->setPluginPath($pluginPath);
|
||||
$this->_iPluginId = $oPluginInstaller->installPlugin();
|
||||
if ($this->_iPluginId > 0) {
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $sHandleSql
|
||||
* @return boolean
|
||||
*/
|
||||
public function uninstallPlugin($sHandleSql) {
|
||||
$oPluginUninstall = new pimSetupPluginUninstall();
|
||||
$oPluginUninstall->setPluginPath($this->_sPluginPath);
|
||||
return $oPluginUninstall->uninstallPlugin($this->_iPluginId, $sHandleSql);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getPluginId() {
|
||||
return $this->_iPluginId;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $sFile
|
||||
* @return boolean
|
||||
*/
|
||||
public function loadXmlFile($sFile) {
|
||||
$this->_oDomDocument->load($sFile);
|
||||
if ($this->_validateXml()) {
|
||||
$this->_oPiXml = simplexml_load_string($this->_oDomDocument->C14N());
|
||||
}
|
||||
return (is_a($this->_oPiXml, "SimpleXMLElement")) ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return object|null
|
||||
*/
|
||||
public function getCfgXmlObject() {
|
||||
if (is_object($this->_oPiXml)) {
|
||||
return $this->_oPiXml;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getPiGeneralArray() {
|
||||
$aGeneral = array();
|
||||
if (is_object($this->_oPiXml)) {
|
||||
$aGeneral = $this->_xml2Array($this->_oPiXml->general);
|
||||
if($aDependencies = $this->_getDepencyArray()) {
|
||||
foreach ($aDependencies as $aDependency) {
|
||||
|
||||
}
|
||||
}
|
||||
$aGeneral['dependencies'] = print_r($aDependencies, TRUE);
|
||||
}
|
||||
return $aGeneral;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns generated list entry (li) for plugin or empty string
|
||||
*
|
||||
* @param int $iPluginId
|
||||
* @return string
|
||||
*/
|
||||
public function getInfoInstalled($iPluginId) {
|
||||
$oPlugin = new pimPlugin($iPluginId);
|
||||
if ($oPlugin->isLoaded()) {
|
||||
$oView = new pimView();
|
||||
$oView->setMultiVariables($oPlugin->toArray());
|
||||
$aLang = array(
|
||||
'LANG_FOLDERNAME' => i18n("Foldername", "pluginmanager"),
|
||||
'LANG_AUTHOR' => i18n("Author", "pluginmanager"),
|
||||
'LANG_CONTACT' => i18n("Contact", "pluginmanager"),
|
||||
'LANG_LICENSE' => i18n("License", "pluginmanager"),
|
||||
'LANG_INSTALLED' => i18n('Installed since', 'pluginmanager'),
|
||||
'LANG_DEPENDENCIES' => i18n("Dependencies", "pluginmanager"),
|
||||
'LANG_WRITEABLE' => i18n("Writable", "pluginmanager"),
|
||||
'LANG_INSTALL' => i18n("Install", "pluginmanager"),
|
||||
'LANG_REMOVE' => i18n("Remove", "pluginmanager"),
|
||||
'LANG_UPDATE' => i18n('Update', 'pluginmanager'),
|
||||
'LANG_UPDATE_CHOOSE' => i18n('Please choose your new file', 'pluginmanager'),
|
||||
'LANG_UPDATE_UPLOAD' => i18n('Update', 'pluginmanager'),
|
||||
'LANG_REMOVE_SQL' => i18n('Execute uninstall.sql', 'pluginmanager')
|
||||
);
|
||||
$oView->setMultiVariables($aLang);
|
||||
// nav sub placeholder, @Todo: fill with content
|
||||
$oView->set('s', 'NAVSUB', '');
|
||||
// enable / disable functionality
|
||||
$activeStatus = $oPlugin->get('active');
|
||||
$oButton = new cHTMLButton('toggle_active');
|
||||
$oButton->setID("but-toggle-plugin-" . $oPlugin->get("idplugin"));
|
||||
$oButton->setClass("pimImgBut");
|
||||
$oButton->setMode('image');
|
||||
$oButtonLabel = new cHTMLLabel("placeholder", $oButton->getID());
|
||||
$oButtonLabel->setClass("pimButLabel");
|
||||
if ($activeStatus == 1) {
|
||||
$oButton->setAlt("Click to toggle status");
|
||||
$oButton->setImageSource('images/online.gif');
|
||||
$oButtonLabel->setLabelText(i18n("Plugin is active", "pluginmanager"));
|
||||
} else {
|
||||
$oButton->setImageSource('images/offline.gif');
|
||||
$oButtonLabel->setLabelText(i18n("Plugin not active", "pluginmanager"));
|
||||
}
|
||||
$oView->set('s', 'BUT_ACTIVESTATUS', $oButton->render() . ' ' . $oButtonLabel->render());
|
||||
|
||||
// update button - not used right now
|
||||
$oView->set('s', 'BUT_UPDATE_PLUGIN', '');
|
||||
|
||||
// uninstall
|
||||
$oDelBut = new cHTMLButton('uninstall_plugin');
|
||||
$oDelBut->setImageSource('images/but_cancel.gif');
|
||||
$oDelBut->setID("but-uninstall-plugin-" . $oPlugin->get("idplugin"));
|
||||
$oDelBut->setClass("pimImgBut");
|
||||
$oDelBut->setMode('image');
|
||||
$oDelSqlCheckbox = new cHTMLCheckbox("delete_sql", "TRUE");
|
||||
$oDelSqlCheckbox->setStyle("display: inline-block;");
|
||||
$sDelSqlTxt = " " . sprintf(i18n("(%s remove database tables)", "pluginmanager"), $oDelSqlCheckbox->toHtml(FALSE));
|
||||
$oDelButLabel = new cHTMLLabel("placeholder", $oDelBut->getID());
|
||||
$oDelButLabel->setClass("pimButLabel");
|
||||
$oDelButLabel->setLabelText(i18n("Uninstall Plugin", "pluginmanager") . $sDelSqlTxt);
|
||||
$oView->set('s', 'BUT_UNINSTALL_PLUGIN', $oDelBut->render() . ' ' . $oDelButLabel->render());
|
||||
|
||||
$oView->setTemplate('pi_manager_installed_plugins.html');
|
||||
return $oView->getRendered(1);
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
protected function _getDepencyArray() {
|
||||
$aDependencies = array();
|
||||
$aAttributes = array();
|
||||
$iCountDependencies = count($this->_oPiXml->dependencies);
|
||||
if($iCountDependencies > 0) {
|
||||
for ($i = 0; $i < $iCountDependencies; $i++) {
|
||||
$sPluginName = cSecurity::escapeString($this->_oPiXml->dependencies[$i]->depend);
|
||||
foreach ($this->_oPiXml->dependencies[$i]->depend->attributes() as $sKey => $sValue) {
|
||||
$aAttributes[$sKey] = cSecurity::escapeString($sValue);
|
||||
}
|
||||
$aDependencies[$i]["name"] = $sPluginName;
|
||||
$aDependencies[$i] = array_merge($aDependencies[$i],$aAttributes);
|
||||
}
|
||||
return $aDependencies;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return boolean
|
||||
* @throws pimXmlStructureException
|
||||
*/
|
||||
private function _validateXml() {
|
||||
if ($this->_oDomDocument->schemaValidate($this->_xsd)) {
|
||||
$this->_bValid = true;
|
||||
return true;
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param xml $xml
|
||||
* @return array
|
||||
*/
|
||||
private function _xml2Array($xml) {
|
||||
$string = json_encode($xml);
|
||||
$array = json_decode($string, true);
|
||||
return $array;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
// security check
|
||||
defined('CON_FRAMEWORK') or die('Illegal call');
|
||||
|
||||
/**
|
||||
* Description of class.pim.plugin
|
||||
*
|
||||
* @author Ortwin Pinke <o.pinke@php-backoffice.de>
|
||||
*/
|
||||
class pimPluginCollection extends ItemCollection {
|
||||
|
||||
public function __construct() {
|
||||
global $cfg;
|
||||
parent::__construct($cfg['tab']['plugins'], 'idplugin');
|
||||
$this->_setItemClass("pimPlugin");
|
||||
}
|
||||
}
|
||||
|
||||
class pimPlugin extends Item {
|
||||
|
||||
public function __construct($mId = false) {
|
||||
global $cfg;
|
||||
parent::__construct($cfg['tab']['plugins'], 'idplugin');
|
||||
|
||||
if ($mId !== false) {
|
||||
$this->loadByPrimaryKey($mId);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -0,0 +1,58 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
// security check
|
||||
defined('CON_FRAMEWORK') or die('Illegal call');
|
||||
|
||||
/**
|
||||
* Description of class.pim.plugin
|
||||
*
|
||||
* @author Ortwin Pinke <o.pinke@php-backoffice.de>
|
||||
*/
|
||||
class pimPluginRelationCollection extends ItemCollection {
|
||||
|
||||
const REL_AREA = 'area';
|
||||
const REL_ACTION = 'action';
|
||||
const REL_NAVS = 'navs';
|
||||
const REL_CTYPE = 'ctype';
|
||||
|
||||
public function __construct() {
|
||||
global $cfg;
|
||||
parent::__construct($cfg['tab']['plugins_rel'], 'idpluginrelation');
|
||||
$this->_setItemClass("pimPluginRelation");
|
||||
}
|
||||
|
||||
public function create($idItem, $idPlugin, $type) {
|
||||
// create a new entry
|
||||
$item = parent::create();
|
||||
$item->set('iditem', $idItem);
|
||||
$item->set('idplugin', $idPlugin);
|
||||
$item->set('type', $type);
|
||||
|
||||
$item->store();
|
||||
return $item;
|
||||
}
|
||||
|
||||
public function getRelations($idPlugin, $type=NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
public function deleteRelations($idPlugin, $type=NULL) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
class pimPluginRelation extends Item {
|
||||
|
||||
public function __construct($mId = false) {
|
||||
global $cfg;
|
||||
parent::__construct($cfg['tab']['plugins_rel'], 'idpluginrelation');
|
||||
|
||||
if ($mId !== false) {
|
||||
$this->loadByPrimaryKey($mId);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -0,0 +1,83 @@
|
|||
<?php
|
||||
/**
|
||||
* Project:
|
||||
* Contenido Content Management System
|
||||
*
|
||||
* Description:
|
||||
* Backend View of Contenido PluginManager
|
||||
*
|
||||
* Requirements:
|
||||
* @con_php_req 5.0
|
||||
*
|
||||
*
|
||||
* @package Contenido Backend plugins
|
||||
* @version 1.0.0
|
||||
* @author Rudi Bieller
|
||||
* @copyright four for business AG <www.4fb.de>
|
||||
* @license http://www.contenido.org/license/LIZENZ.txt
|
||||
* @link http://www.4fb.de
|
||||
* @link http://www.contenido.org
|
||||
* @since file available since contenido release 4.8.7
|
||||
*
|
||||
* {@internal
|
||||
* created 2008-03-17
|
||||
* modified 2008-07-04, Frederic Schneider, add security fix and tpl settings
|
||||
*
|
||||
* $Id: class.pim.view.php 11 2015-07-14 12:34:24Z oldperl $:
|
||||
* }}
|
||||
*
|
||||
*/
|
||||
|
||||
if(!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
}
|
||||
|
||||
class pimView extends Template{
|
||||
|
||||
protected $sPathToTpl;
|
||||
protected $bIsGenerated;
|
||||
protected $_sTplPath;
|
||||
|
||||
public function __construct($tags = false, $parser = false) {
|
||||
$this->reset();
|
||||
$this->set('s', 'SESSID', cRegistry::getSessionId());
|
||||
$this->bIsGenerated = false;
|
||||
$this->_sTplPath = dirname(dirname(__FILE__)).DIRECTORY_SEPARATOR."templates".DIRECTORY_SEPARATOR;
|
||||
parent::__construct($tags, $parser);
|
||||
}
|
||||
|
||||
public function setTemplate($sTplName) {
|
||||
$this->sPathToTpl = $this->_sTplPath.$sTplName;
|
||||
}
|
||||
|
||||
public function setMultiVariables($aVariables) {
|
||||
if(is_array($aVariables)) {
|
||||
foreach($aVariables as $sName=>$sContent) {
|
||||
if(is_numeric($sName)) {
|
||||
continue;
|
||||
}
|
||||
$this->setVariable($sContent, strtoupper($sName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function setVariable($sVariable, $sName = '') {
|
||||
if(empty($sName)) {
|
||||
$sName = strtoupper($$sVariable);
|
||||
}
|
||||
$this->set('s', $sName, $sVariable);
|
||||
}
|
||||
|
||||
public function getRendered($mode = '') {
|
||||
$this->bIsGenerated = true;
|
||||
return $this->generate($this->sPathToTpl, $mode);
|
||||
}
|
||||
|
||||
public function __destruct() {
|
||||
if ($this->bIsGenerated === false) {
|
||||
$this->generate($this->sPathToTpl, true, false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
|
@ -0,0 +1,104 @@
|
|||
<?php
|
||||
/**
|
||||
* $Id:$
|
||||
*/
|
||||
|
||||
if (!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
}
|
||||
|
||||
|
||||
class PluginmanagerAjax extends pimAjax {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $Request
|
||||
* @return string
|
||||
*/
|
||||
public function handle($Request) {
|
||||
$sString = '';
|
||||
switch ($Request) {
|
||||
|
||||
// toggle active/inactive of plugins
|
||||
case 'toggle_active':
|
||||
if(!isset($_POST['plugin_id']) || empty($_POST['plugin_id'])) {
|
||||
$sString = "Error:missing plugin id! (Err20)";
|
||||
break;
|
||||
}
|
||||
$iPluginId = (int) $_POST['plugin_id'];
|
||||
$oPlugin = new pimPlugin($iPluginId);
|
||||
if($oPlugin->isLoaded()) {
|
||||
$iCurrentStat = (int) $oPlugin->get('active');
|
||||
$iNewStat = ($iCurrentStat == 1)?0:1;
|
||||
$oPlugin->set('active', $iNewStat);
|
||||
if($oPlugin->store()) {
|
||||
$sString = "Ok:".$iNewStat;
|
||||
if($iNewStat) {
|
||||
$sString .= ":".i18n("Plugin is active", "pluginmanager");
|
||||
} else {
|
||||
$sString .= ":".i18n("Plugin not active", "pluginmanager");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
$sString = "Error:no changes! (Err21)";
|
||||
break;
|
||||
|
||||
// save sortorder of plugins
|
||||
case 'pim_save_sort':
|
||||
parse_str($_REQUEST['plugins'], $aPlugins);
|
||||
//print_r($aPlugins['plugin']);
|
||||
if(is_array($aPlugins['plugin']) && count($aPlugins['plugin']) > 0) {
|
||||
foreach($aPlugins['plugin'] as $sortorder=>$pluginid) {
|
||||
$oPlugin = new pimPlugin($pluginid);
|
||||
$oPlugin->set('executionorder', $sortorder);
|
||||
$oPlugin->store();
|
||||
}
|
||||
}
|
||||
$sString = "Ok:executionorder saved";
|
||||
break;
|
||||
|
||||
// install plugin with existing source in plugin dir
|
||||
case 'pim_install':
|
||||
//sleep(3);
|
||||
$iNewPluginId = 0;
|
||||
$sPluginPath = cRegistry::getBackendPath()
|
||||
.cRegistry::getConfigValue('path', 'plugins')
|
||||
.Contenido_Security::escapeDB($_POST['plugin_folder']).DIRECTORY_SEPARATOR;
|
||||
|
||||
if(is_dir($sPluginPath) && is_readable($sPluginPath."cl_plugin.xml")) {
|
||||
$oPluginHandler = new pimPluginHandler();
|
||||
if($oPluginHandler->loadXmlFile($sPluginPath."cl_plugin.xml")) {
|
||||
if($oPluginHandler->installPlugin(Contenido_Security::escapeDB($_POST['plugin_folder']))) {
|
||||
$iNewPluginId = $oPluginHandler->getPluginId();
|
||||
if($iNewPluginId > 0) {
|
||||
$sString = "Ok:".$iNewPluginId.":Plugin successfully installed!";
|
||||
} else {
|
||||
$sString = "Error:".$iNewPluginId.":Plugin not installed! (Err10)";
|
||||
}
|
||||
} else {
|
||||
$sString = "Error:0:Plugin not installed! (Err12)";
|
||||
}
|
||||
} else {
|
||||
$sString = "Error:0:Plugin xml-file missing or not correct! (Err13)";
|
||||
}
|
||||
break;
|
||||
}
|
||||
$sString = "Error:0:Plugin folder missing or no readable xml-file found! (Err14)";
|
||||
break;
|
||||
|
||||
// return info about installed plugin
|
||||
case 'pim_get_info_installed':
|
||||
$oPluginHandler = new pimPluginHandler();
|
||||
$sString = $oPluginHandler->getInfoInstalled((int) $_POST['plugin_id']);
|
||||
break;
|
||||
|
||||
//if action is unknown generate error message
|
||||
default:
|
||||
$sString = "Unknown Ajax Action! (Err01)";
|
||||
break;
|
||||
}
|
||||
return $sString;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
if(!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
}
|
||||
|
||||
class pimExeption extends Exception {
|
||||
|
||||
protected $_log_exception = true;
|
||||
protected $_logger = NULL;
|
||||
|
||||
public function __construct($message, $code = 0, Exception $previous = NULL) {
|
||||
parent::__construct($message, $code, $previous);
|
||||
|
||||
// create a logger class and save it for all logging purposes
|
||||
$writer = cLogWriter::factory("File", array(
|
||||
'destination' => cRegistry::getConfigValue('path', 'data')
|
||||
. 'logs/exception.log'
|
||||
));
|
||||
$this->_logger = new cLog($writer);
|
||||
|
||||
// determine if exception should be logged
|
||||
if (false === $this->_log_exception
|
||||
&& !is_null(cRegistry::getConfigValue('debug', 'log_exeptions'))) {
|
||||
$this->_log_exception = cRegistry::getConfigValue('debug', 'log_exeptions');
|
||||
}
|
||||
|
||||
// log the exception if it should be logged
|
||||
if (true === $this->_log_exception) {
|
||||
$this->log();
|
||||
}
|
||||
}
|
||||
|
||||
public function log() {
|
||||
// construct the log message with all infos and write it via the logger
|
||||
$logMessage = get_class($this) . ' thrown at line ' . $this->getLine() . ' of file ' . $this->getFile() . ".\r\n";
|
||||
$logMessage .= 'Exception message: ' . $this->getMessage() . "\r\n";
|
||||
$logMessage .= "Call stack:\r\n";
|
||||
$logMessage .= $this->getTraceAsString();
|
||||
$logMessage .= "\r\n";
|
||||
$this->_logger->log($logMessage);
|
||||
}
|
||||
}
|
||||
|
||||
class pimXmlStructureException extends pimExeption {
|
||||
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
if(!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
abstract class pluginHandlerAbstract implements Plugins {
|
||||
|
||||
/**
|
||||
* Holds path to plugin dir
|
||||
* @var string
|
||||
*/
|
||||
protected static $_piPath;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected static $_piUrl;
|
||||
|
||||
/**
|
||||
* Holds template name
|
||||
* @var string
|
||||
*/
|
||||
protected static $_piTemplate = "default";
|
||||
|
||||
/**
|
||||
* Returns the name of the plugin directory
|
||||
* @return string
|
||||
*/
|
||||
public static function getName() {
|
||||
return basename(self::_getDir());
|
||||
}
|
||||
/**
|
||||
* Returns the absolute server path
|
||||
* @return string
|
||||
*/
|
||||
public static function getPath() {
|
||||
return self::_getDir().DIRECTORY_SEPARATOR;
|
||||
}
|
||||
|
||||
public static function getIncludesPath() {
|
||||
return self::_getDir().DIRECTORY_SEPARATOR."includes".DIRECTORY_SEPARATOR;
|
||||
}
|
||||
|
||||
public static function getTplPath() {
|
||||
return self::_getDir().DIRECTORY_SEPARATOR."templates".DIRECTORY_SEPARATOR.self::$_piTemplate.DIRECTORY_SEPARATOR;
|
||||
}
|
||||
|
||||
public static function getUrl() {
|
||||
;
|
||||
}
|
||||
|
||||
protected static function _getDir() {
|
||||
if(empty(self::$_piPath)) {
|
||||
$oReflector = new ReflectionClass(get_called_class());
|
||||
self::$_piPath = dirname(dirname($oReflector->getFileName()));
|
||||
}
|
||||
return self::$_piPath;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
if(!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
interface Plugins {
|
||||
|
||||
public static function getPath();
|
||||
public static function getUrl();
|
||||
public static function getIncludesPath();
|
||||
public static function getTplPath();
|
||||
}
|
|
@ -0,0 +1,357 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class pimSetupBase {
|
||||
|
||||
/**
|
||||
* name of plugin info xml file
|
||||
*/
|
||||
const PIM_XML_FILENAME = "cl_plugin.xml";
|
||||
|
||||
/**
|
||||
* placeholder for sql prefix
|
||||
*/
|
||||
const PIM_SQL_PLACEHOLDER = "!PREFIX!";
|
||||
|
||||
/**
|
||||
*
|
||||
* @var int mode of setup
|
||||
*/
|
||||
public static $mode;
|
||||
|
||||
/**
|
||||
* plugin general infos
|
||||
* @var SimpleXMLElement
|
||||
*/
|
||||
public static $XmlGeneral;
|
||||
|
||||
/**
|
||||
* plugin requirements
|
||||
* @var SimpleXMLElement
|
||||
*/
|
||||
public static $XmlRequirements;
|
||||
|
||||
/**
|
||||
* plugin depencies
|
||||
* @var SimpleXMLElement
|
||||
*/
|
||||
public static $XmlDependencies;
|
||||
|
||||
/**
|
||||
* areas for plugin
|
||||
* @var SimpleXMLElement
|
||||
*/
|
||||
public static $XmlArea;
|
||||
|
||||
/**
|
||||
* actions for plugin
|
||||
* @var SimpleXMLElement
|
||||
*/
|
||||
public static $XmlActions;
|
||||
|
||||
/**
|
||||
* frames for plugin - frame and framefile entries
|
||||
* @var SimpleXMLElement
|
||||
*/
|
||||
public static $XmlFrames;
|
||||
|
||||
/**
|
||||
* nav main entry
|
||||
* @var SimpleXMLElement
|
||||
*/
|
||||
public static $XmlNavMain;
|
||||
|
||||
/**
|
||||
* nav sub entries
|
||||
* @var SimpleXMLElement
|
||||
*/
|
||||
public static $XmlNavSub;
|
||||
|
||||
/**
|
||||
* content type(s) for plugin
|
||||
* @var SimpleXMLElement
|
||||
*/
|
||||
public static $XmlContentType;
|
||||
|
||||
/**
|
||||
* whole xml object from info xml
|
||||
* @var SimpleXMLElement
|
||||
*/
|
||||
protected $_oXml = NULL;
|
||||
protected $_xmlDefault = 'plugins/pluginmanager/xml/plugin_default.xml';
|
||||
protected $_aXmlDefaultIndex;
|
||||
protected $_aXmlDefaultValues;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_sXsdPath;
|
||||
|
||||
/**
|
||||
* db-tables and table-ids used
|
||||
* @var array
|
||||
*/
|
||||
protected $_aTables = array(
|
||||
'actions' => 'idaction',
|
||||
'area' => 'idarea',
|
||||
'files' => 'idfile',
|
||||
'framefiles' => 'idframefile',
|
||||
'nav_main' => 'idnavm',
|
||||
'nav_sub' => 'idnavs',
|
||||
'plugins' => 'idplugin'
|
||||
);
|
||||
|
||||
/**
|
||||
* holds db object
|
||||
* @var DB_ConLite
|
||||
*/
|
||||
protected $_oDb;
|
||||
protected $_aSql = array();
|
||||
protected $_iPiId = 0;
|
||||
protected $_iCntQueries = 0;
|
||||
protected $_iClient;
|
||||
protected $_aRelations;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var pimPluginCollection
|
||||
*/
|
||||
protected $_PimPluginCollection;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var pimPluginRelationCollection
|
||||
*/
|
||||
protected $_PimPluginRelationCollection;
|
||||
protected $_sPluginPath;
|
||||
|
||||
public function __construct() {
|
||||
$this->_oDb = new DB_ConLite();
|
||||
$this->_iClient = cRegistry::getClientId();
|
||||
$this->_xmlParseIntoStruct();
|
||||
|
||||
$this->_PimPluginCollection = new pimPluginCollection();
|
||||
$this->_PimPluginRelationCollection = new pimPluginRelationCollection();
|
||||
|
||||
//print_r($this->_getAttrForTag("area"));
|
||||
}
|
||||
|
||||
public function setPluginPath($sPath) {
|
||||
$this->_sPluginPath = $sPath;
|
||||
}
|
||||
|
||||
public function getPluginPath() {
|
||||
return $this->_sPluginPath;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function doQueries() {
|
||||
if (!is_array($this->_aSql) || count($this->_aSql) <= 0) {
|
||||
return TRUE;
|
||||
}
|
||||
$iQueries = count($this->_aSql);
|
||||
|
||||
if ($iQueries > 0 && is_a($this->_oDb, "DB_ConLite")) {
|
||||
foreach ($this->_aSql as $sSql) {
|
||||
try {
|
||||
$this->_oDb->query($sSql);
|
||||
} catch (Exception $exc) {
|
||||
self::error($exc->getTraceAsString());
|
||||
}
|
||||
$this->_iCntQueries++;
|
||||
}
|
||||
if ($iQueries == $this->_iCntQueries) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
public function undoQueries() {
|
||||
|
||||
}
|
||||
|
||||
public function setXmlObject($oXml, $bSplit = TRUE) {
|
||||
if (is_object($oXml)) {
|
||||
$this->_oXml = & $oXml;
|
||||
}
|
||||
|
||||
if ($bSplit) {
|
||||
$this->_setXml();
|
||||
}
|
||||
}
|
||||
|
||||
public function setXsdFile($sFile) {
|
||||
$this->_sXsdPath = $sFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns next id for given table
|
||||
*
|
||||
* @param string $sTable
|
||||
* @return int the next usable table id
|
||||
*/
|
||||
protected function _getNextId($sTable) {
|
||||
cInclude("includes", "functions.database.php");
|
||||
dbUpdateSequence(cRegistry::getConfigValue("tab", "sequence"), cRegistry::getConfigValue('tab', $sTable), cRegistry::getDb());
|
||||
|
||||
$iNextId = $this->_oDb->nextid(cRegistry::getConfigValue('tab', $sTable));
|
||||
// id must be over 10.000
|
||||
if ($iNextId < 10000) {
|
||||
$iNextId = 10000;
|
||||
}
|
||||
|
||||
// added ten
|
||||
$iNextId = $iNextId + 10;
|
||||
|
||||
// how long is the number?
|
||||
$iResultStrlen = strlen($iNextId);
|
||||
|
||||
// removed the last number
|
||||
$iNextId = substr($iNextId, 0, $iResultStrlen - 1);
|
||||
|
||||
return Contenido_Security::toInteger($iNextId . 0); // last number is always a zero
|
||||
}
|
||||
|
||||
protected function _getAttrForTag($sTag) {
|
||||
foreach ($this->_aXmlDefaultValues as $Key => $aValue) {
|
||||
if ($aValue['tag'] === strtoupper($sTag) && $aValue['type'] === "complete") {
|
||||
if (isset($aValue['attributes']) && is_array($aValue['attributes'])) {
|
||||
return array_change_key_case($aValue['attributes']);
|
||||
}
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
protected function _getPluginSql() {
|
||||
$sSqlFile = $this->_sPluginPath . static::SQL_FILE;
|
||||
if (file_exists($sSqlFile) && is_readable($sSqlFile)) {
|
||||
$this->_aSql = pimSqlParser::parse(file_get_contents($sSqlFile));
|
||||
} else if (!is_array($this->_aSql)) {
|
||||
$this->_aSql = array();
|
||||
}
|
||||
}
|
||||
|
||||
protected static function error($sMessage, $iPiId = NULL) {
|
||||
if (!is_null($iPiId)) {
|
||||
$oUnInstall = new pimSetupPluginUninstall();
|
||||
$oUnInstall->uninstallPlugin($iPiId, '');
|
||||
}
|
||||
print "Error:0:" . $sMessage;
|
||||
die();
|
||||
}
|
||||
|
||||
protected function _getRelations() {
|
||||
$aTmpArray = array();
|
||||
$this->_PimPluginRelationCollection->setWhere('idplugin', $this->_iPiId);
|
||||
$this->_PimPluginRelationCollection->query();
|
||||
if ($this->_PimPluginRelationCollection->count() > 0) {
|
||||
while ($oPluginRelation = $this->_PimPluginRelationCollection->next()) {
|
||||
if (isset($aTmpArray[$oPluginRelation->get('type')]) && is_array($aTmpArray[$oPluginRelation->get('type')])) {
|
||||
array_push($aTmpArray[$oPluginRelation->get('type')], $oPluginRelation->get('iditem'));
|
||||
} else {
|
||||
$aTmpArray[$oPluginRelation->get('type')] = array($oPluginRelation->get('iditem'));
|
||||
}
|
||||
}
|
||||
$this->_aRelations = $aTmpArray;
|
||||
unset($aTmpArray);
|
||||
}
|
||||
}
|
||||
|
||||
protected function _deleteRelations() {
|
||||
$iDeletetRelations = $this->_PimPluginRelationCollection->deleteByWhereClause("idplugin = " . $this->_iPiId);
|
||||
}
|
||||
|
||||
protected function _deleteRelationEntries() {
|
||||
$oDb = new DB_ConLite();
|
||||
foreach ($this->_aRelations as $sType => $aIds) {
|
||||
$sSQL = 'DELETE FROM ' . cRegistry::getConfigValue('tab', $sType) . ' WHERE ' . $this->_aTables[$sType] . ' IN (' . implode(',', $aIds) . ')';
|
||||
if ($oDb->query($sSQL) == FALSE) {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
unset($oDb);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
protected function _updateSortOrder() {
|
||||
if(!isset($_REQUEST['new_position'])) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$oPluginColl = new pimPluginCollection();
|
||||
$oPluginColl->setWhere("executionorder", (int) $_REQUEST['new_position'], ">=");
|
||||
$oPluginColl->query();
|
||||
if($oPluginColl->count() > 0) {
|
||||
/* @var $oPlugin cApiPlugin */
|
||||
while ($oPlugin = $oPluginColl->next()) {
|
||||
$iOrder = $oPlugin->get("executionorder");
|
||||
$oPlugin->set("executionorder", $iOrder++);
|
||||
$oPlugin->store();
|
||||
}
|
||||
}
|
||||
return (int) $_REQUEST['new_position'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Set temporary xml content to static variables
|
||||
*
|
||||
* @param string $xml
|
||||
*/
|
||||
private function _setXml() {
|
||||
//simplexml_tree($this->_oXml);
|
||||
// General plugin informations
|
||||
self::$XmlGeneral = $this->_oXml->general;
|
||||
|
||||
// Plugin requirements
|
||||
self::$XmlRequirements = $this->_oXml->requirements;
|
||||
|
||||
// Plugin dependencies
|
||||
self::$XmlDependencies = $this->_oXml->dependencies;
|
||||
|
||||
// CONTENIDO areas: *_area
|
||||
self::$XmlArea = $this->_oXml->conlite->areas;
|
||||
|
||||
// CONTENIDO actions: *_actions
|
||||
self::$XmlActions = $this->_oXml->conlite->actions;
|
||||
|
||||
// CONTENIDO frames: *_frame_files and *_files
|
||||
self::$XmlFrames = $this->_oXml->conlite->frames;
|
||||
|
||||
// CONTENIDO main navigations: *_nav_main
|
||||
self::$XmlNavMain = $this->_oXml->conlite->nav_main;
|
||||
|
||||
// CONTENIDO sub navigations: *_nav_sub
|
||||
self::$XmlNavSub = $this->_oXml->conlite->nav_sub;
|
||||
|
||||
// CONTENIDO Content Types: *_type
|
||||
self::$XmlContentType = $this->_oXml->content_types;
|
||||
}
|
||||
|
||||
private function _xmlParseIntoStruct() {
|
||||
$sData = implode("", file($this->_xmlDefault));
|
||||
$oParser = xml_parser_create();
|
||||
xml_parse_into_struct($oParser, $sData, $this->_aXmlDefaultValues, $this->_aXmlDefaultIndex);
|
||||
xml_parser_free($oParser);
|
||||
}
|
||||
|
||||
private function _updateSequence($table = false) {
|
||||
global $db, $cfg;
|
||||
if (!$table) {
|
||||
$sql = "SHOW TABLES";
|
||||
$db->query($sql);
|
||||
while ($db->next_record()) {
|
||||
dbUpdateSequence($cfg['sql']['sqlprefix'] . "_sequence", $db->f(0));
|
||||
}
|
||||
} else {
|
||||
dbUpdateSequence($cfg['sql']['sqlprefix'] . "_sequence", $table);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,427 @@
|
|||
<?php
|
||||
|
||||
if (!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
}
|
||||
|
||||
class pimSetupPluginInstall extends pimSetupBase {
|
||||
|
||||
const SQL_FILE = "plugin_install.sql";
|
||||
|
||||
/**
|
||||
*
|
||||
* @var pimPlugin
|
||||
*/
|
||||
private $_oPlugin;
|
||||
//helper arrays
|
||||
private $_aAreas = array();
|
||||
private $_aInstalledAreas;
|
||||
private $_aInstalledNavMain;
|
||||
private $_aInstalledNavSub;
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$this->_initInstalledAreasArray();
|
||||
}
|
||||
|
||||
public function installPlugin() {
|
||||
if (is_null($this->_oXml)) {
|
||||
cWarning(__FILE__, __LINE__, "installPlugin: No plugin xml loaded!");
|
||||
return 0;
|
||||
}
|
||||
$this->_installCheckUuid();
|
||||
$this->_installCheckRequirements();
|
||||
|
||||
$oPiColl = new pimPluginCollection();
|
||||
$this->_oPlugin = $oPiColl->createNewItem();
|
||||
if ($this->_oPlugin->isLoaded()) {
|
||||
$this->_iPiId = $this->_oPlugin->get('idplugin');
|
||||
$this->_insertDbEntries();
|
||||
$this->_getPluginSql();
|
||||
if ($this->doQueries()) {
|
||||
$this->_oPlugin->set('idclient', $this->_iClient, FALSE);
|
||||
$this->_oPlugin->set('name', Contenido_Security::escapeDB(self::$XmlGeneral->plugin_name));
|
||||
$this->_oPlugin->set('description', Contenido_Security::escapeDB(self::$XmlGeneral->description));
|
||||
$this->_oPlugin->set('author', Contenido_Security::escapeDB(self::$XmlGeneral->author));
|
||||
$this->_oPlugin->set('copyright', Contenido_Security::escapeDB(self::$XmlGeneral->copyright));
|
||||
$this->_oPlugin->set('mail', Contenido_Security::escapeDB(self::$XmlGeneral->mail));
|
||||
$this->_oPlugin->set('website', Contenido_Security::escapeDB(self::$XmlGeneral->website));
|
||||
$this->_oPlugin->set('version', Contenido_Security::escapeDB(self::$XmlGeneral->version));
|
||||
$this->_oPlugin->set('folder', Contenido_Security::escapeDB(self::$XmlGeneral->plugin_foldername));
|
||||
$this->_oPlugin->set('uuid', Contenido_Security::escapeDB(self::$XmlGeneral->uuid));
|
||||
$this->_oPlugin->set('executionorder', $this->_updateSortOrder(), FALSE);
|
||||
$this->_oPlugin->set('installed', date('Y-m-d H:i:s'), FALSE);
|
||||
$this->_oPlugin->set('active', (int) self::$XmlGeneral['active'], FALSE);
|
||||
|
||||
if ($this->_oPlugin->store()) {
|
||||
//echo "stored: ".$this->_iPiId;
|
||||
return $this->_iPiId;
|
||||
}
|
||||
} else {
|
||||
$this->_removeEmptyPlugin();
|
||||
}
|
||||
}
|
||||
// something went wrong, return 0
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected function _insertDbEntries() {
|
||||
$this->_addAreas();
|
||||
$this->_addActions();
|
||||
$this->_addFrames();
|
||||
$this->_addNavMain();
|
||||
$this->_addNavSub();
|
||||
}
|
||||
|
||||
protected function _addRelation($iIdItem, $sType) {
|
||||
$oPluginRelation = $this->_PimPluginRelationCollection->createNewItem();
|
||||
$oPluginRelation->set('iditem', $iIdItem, FALSE);
|
||||
$oPluginRelation->set('idplugin', $this->_iPiId, FALSE);
|
||||
$oPluginRelation->set('type', $sType);
|
||||
$oPluginRelation->store();
|
||||
unset($oPluginRelation);
|
||||
}
|
||||
|
||||
private function _addAreas() {
|
||||
$aAttributes = array();
|
||||
$aDefaultAttr = array(
|
||||
'menuless' => 0,
|
||||
'parent' => 0,
|
||||
'relevant' => 1
|
||||
);
|
||||
|
||||
$iCountAreas = count(self::$XmlArea->area);
|
||||
if ($iCountAreas > 0) {
|
||||
$oAreaColl = new cApiAreaCollection();
|
||||
for ($i = 0; $i < $iCountAreas; $i++) {
|
||||
$sName = Contenido_Security::escapeDB(self::$XmlArea->area[$i], $this->oDb);
|
||||
// build attributes
|
||||
foreach (self::$XmlArea->area[$i]->attributes() as $sKey => $sValue) {
|
||||
$aAttributes[$sKey] = (string) $sValue;
|
||||
}
|
||||
$aAttributes = array_merge($aDefaultAttr, $aAttributes);
|
||||
/* @var $oArea cApiArea */
|
||||
$oArea = $oAreaColl->createNewItem($this->_getNextId("area"));
|
||||
$oArea->set('parent_id', Contenido_Security::escapeDB($aAttributes['parent'], $this->oDb));
|
||||
$oArea->set('name', $sName);
|
||||
$oArea->set('menuless', Contenido_Security::toInteger($aAttributes['menuless']));
|
||||
$oArea->set('relevant', 1, FALSE);
|
||||
$oArea->set('online', 1, FALSE);
|
||||
if ($oArea->store()) {
|
||||
$iIdItem = $oArea->get($oArea->primaryKey);
|
||||
$this->_aAreas[$sName] = $iIdItem;
|
||||
$this->_aInstalledAreas[] = $sName;
|
||||
$this->_addRelation($iIdItem, 'area');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function _addActions() {
|
||||
$aAttributes = array();
|
||||
$aDefaultAttr = array(
|
||||
'relevant' => 1
|
||||
);
|
||||
|
||||
$iCountActions = count(self::$XmlActions->action);
|
||||
if ($iCountActions > 0) {
|
||||
$oActionColl = new cApiActionCollection();
|
||||
for ($i = 0; $i < $iCountActions; $i++) {
|
||||
$sName = Contenido_Security::escapeDB(self::$XmlActions->action[$i], $this->_oDb);
|
||||
foreach (self::$XmlActions->action[$i]->attributes() as $sKey => $sValue) {
|
||||
$aAttributes[$sKey] = cSecurity::escapeString($sValue);
|
||||
}
|
||||
$aAttributes = array_merge($aDefaultAttr, array_filter($aAttributes));
|
||||
if (!in_array($aAttributes['area'], $this->_aInstalledAreas)) {
|
||||
parent::error(sprintf(i18n('Defined area <strong>%s</strong> are not found on your ConLite installation. Please contact your plugin author.', 'pluginmanager'), $aAttributes['area']));
|
||||
}
|
||||
/* @var $oAction cApiAction */
|
||||
$oAction = $oActionColl->createNewItem($this->_getNextId("actions"));
|
||||
if ($oAction->isLoaded()) {
|
||||
$oAction->set("idarea", $this->_getIdForArea($aAttributes['area']));
|
||||
$oAction->set("name", $sName);
|
||||
$oAction->set("code", '');
|
||||
$oAction->set("location", '');
|
||||
$oAction->set("relevant", (int) $aAttributes['relevant']);
|
||||
if ($oAction->store()) {
|
||||
$this->_addRelation($oAction->get('idaction'), 'actions');
|
||||
}
|
||||
}
|
||||
//$oAction = $oActionColl->create($aAttributes['area'], $sName, '', '', $aAttributes['relevant']);
|
||||
//$this->_addRelation($oAction->get('idaction'), 'actions');
|
||||
}
|
||||
unset($oActionColl);
|
||||
unset($oAction);
|
||||
}
|
||||
}
|
||||
|
||||
private function _addFrames() {
|
||||
$aAttributes = array();
|
||||
$aDefaultAttr = array();
|
||||
|
||||
$iCountFrames = count(self::$XmlFrames->frame);
|
||||
if ($iCountFrames > 0) {
|
||||
$oFrameFileColl = new cApiFrameFileCollection();
|
||||
$oFileColl = new cApiFileCollection();
|
||||
|
||||
for ($i = 0; $i < $iCountFrames; $i++) {
|
||||
// Build attributes with security checks
|
||||
foreach (self::$XmlFrames->frame[$i]->attributes() as $sKey => $sValue) {
|
||||
$aAttributes[$sKey] = cSecurity::escapeString($sValue);
|
||||
}
|
||||
$aAttributes = array_merge($aDefaultAttr, array_filter($aAttributes));
|
||||
|
||||
// Check for valid area
|
||||
if (!array_key_exists($aAttributes['area'], $this->_aAreas) && !in_array($aAttributes['area'], $this->_aInstalledAreas)) {
|
||||
parent::error(sprintf(i18n('Defined area <strong>%s</strong> are not found on your ConLite installation. Please contact your plugin author.', 'pluginmanager'), $aAttributes['area']));
|
||||
}
|
||||
|
||||
/* @var $oFile cApiFile */
|
||||
$oFile = $oFileColl->createNewItem($this->_getNextId("files"));
|
||||
if ($oFile->isLoaded()) {
|
||||
$this->_addRelation($oFile->get('idfile'), 'files');
|
||||
|
||||
$oFile->set("idarea", $this->_getIdForArea($aAttributes['area']));
|
||||
$oFile->set("filename", $aAttributes['name']);
|
||||
$oFile->set("filetype", cSecurity::escapeString($aAttributes['filetype']));
|
||||
|
||||
if ($oFile->store()) {
|
||||
if (!empty($aAttributes['frameId'])) {
|
||||
/* @var $oFrameFile cApiFrameFile */
|
||||
$oFrameFile = $oFrameFileColl->createNewItem($this->_getNextId("framefiles"));
|
||||
if ($oFrameFile->isLoaded()) {
|
||||
$this->_addRelation($oFrameFile->get('idframefile'), 'framefiles');
|
||||
|
||||
$oFrameFile->set("idarea", $this->_getIdForArea($aAttributes['area']));
|
||||
$oFrameFile->set("idframe", (int) $aAttributes['frameId'], FALSE);
|
||||
$oFrameFile->set("idfile", (int) $oFile->get('idfile'), FALSE);
|
||||
|
||||
$oFrameFile->store();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
unset($oFrameFileColl);
|
||||
unset($oFileColl);
|
||||
unset($oFile);
|
||||
unset($oFrameFile);
|
||||
}
|
||||
}
|
||||
|
||||
private function _addNavMain() {
|
||||
$aAttributes = array();
|
||||
|
||||
$iCountNavMain = count(self::$XmlNavMain->nav);
|
||||
if ($iCountNavMain > 0) {
|
||||
$oNavMainColl = new cApiNavMainCollection();
|
||||
|
||||
for ($i = 0; $i < $iCountNavMain; $i++) {
|
||||
$sLocation = cSecurity::escapeString(self::$XmlNavMain->nav[$i]);
|
||||
if (empty($sLocation)) {
|
||||
parent::error(i18n('There seem to be an empty main navigation entry in plugin.xml. Please contact your plugin author.', 'pluginmanager'), $this->_iPiId);
|
||||
}
|
||||
|
||||
// Build attributes with security checks
|
||||
foreach (self::$XmlNavMain->nav[$i]->attributes() as $sKey => $sValue) {
|
||||
$aAttributes[$sKey] = cSecurity::escapeString($sValue);
|
||||
}
|
||||
|
||||
/* @var $oNavMain cApiNavMain */
|
||||
$oNavMain = $oNavMainColl->createNewItem($this->_getNextId("nav_main"));
|
||||
if($oNavMain->isLoaded()) {
|
||||
$this->_addRelation($oNavMain->get('idnavm'), 'nav_main');
|
||||
|
||||
$oNavMain->set("location", $sLocation, FALSE);
|
||||
$oNavMain->set("name", cSecurity::escapeString($aAttributes['name']));
|
||||
|
||||
$oNavMain->store();
|
||||
}
|
||||
}
|
||||
unset($oNavMainColl);
|
||||
unset($oNavMain);
|
||||
}
|
||||
}
|
||||
|
||||
private function _addNavSub() {
|
||||
$aAttributes = array();
|
||||
$this->_initInstalledNavMainArray();
|
||||
$iCountNavSub = count(self::$XmlNavSub->nav);
|
||||
|
||||
if ($iCountNavSub > 0) {
|
||||
$oNavSubColl = new cApiNavSubCollection();
|
||||
|
||||
for ($i = 0; $i < $iCountNavSub; $i++) {
|
||||
$sLocation = cSecurity::escapeString(self::$XmlNavSub->nav[$i]);
|
||||
|
||||
if (empty($sLocation)) {
|
||||
parent::error(i18n('There seem to be an empty sub navigation entry in plugin.xml. Please contact your plugin author.', 'pluginmanager'), $this->_iPiId);
|
||||
}
|
||||
|
||||
// Build attributes with security checks
|
||||
foreach (self::$XmlNavSub->nav[$i]->attributes() as $sKey => $sValue) {
|
||||
$aAttributes[$sKey] = cSecurity::escapeString($sValue);
|
||||
}
|
||||
/* @var $oNavSub cApiNavSub */
|
||||
$oNavSub = $oNavSubColl->createNewItem($this->_getNextId("nav_sub"));
|
||||
if ($oNavSub->isLoaded()) {
|
||||
$this->_addRelation($oNavSub->get('idnavs'), 'nav_sub');
|
||||
|
||||
$oNavSub->set("idnavm", $this->_getIdForNavMain($aAttributes['navm']));
|
||||
$oNavSub->set("idarea", $this->_getIdForArea($aAttributes['area']));
|
||||
$oNavSub->set("level", (int) $aAttributes['level']);
|
||||
$oNavSub->set("location", $sLocation, FALSE);
|
||||
$oNavSub->set("online", 1, FALSE);
|
||||
|
||||
$oNavSub->store();
|
||||
}
|
||||
}
|
||||
unset($oNavSubColl);
|
||||
unset($oNavSub);
|
||||
}
|
||||
}
|
||||
|
||||
private function _removeEmptyPlugin() {
|
||||
if (empty($this->_iPiId)) {
|
||||
return FALSE;
|
||||
}
|
||||
$this->_getRelations();
|
||||
if (count($this->_aRelations) > 0) {
|
||||
$this->_deleteRelationEntries();
|
||||
$this->_deleteRelations();
|
||||
}
|
||||
$this->_PimPluginCollection->delete($this->_iPiId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check uuId: You can install a plugin only for one time
|
||||
*/
|
||||
private function _installCheckUuid() {
|
||||
$this->_PimPluginCollection->setWhere('uuid', self::$XmlGeneral->uuid);
|
||||
$this->_PimPluginCollection->query();
|
||||
if ($this->_PimPluginCollection->count() > 0) {
|
||||
parent::error(i18n('You can install this plugin only for one time.', 'pluginmanager'));
|
||||
}
|
||||
}
|
||||
|
||||
private function _installCheckRequirements() {
|
||||
|
||||
// Check min ConLite version
|
||||
if (version_compare(CL_VERSION, self::$XmlRequirements->conlite->attributes()->minversion, '<')) {
|
||||
parent::error(sprintf(i18n('You have to install ConLite <strong>%s</strong> or higher to install this plugin!', 'pluginmanager'), self::$XmlRequirements->conlite->attributes()->minversion));
|
||||
}
|
||||
|
||||
// Check max ConLite version
|
||||
if (self::$XmlRequirements->conlite->attributes()->maxversion) {
|
||||
if (version_compare(CL_VERSION, self::$XmlRequirements->conlite->attributes()->maxversion, '>')) {
|
||||
parent::error(sprintf(i18n('Your current ConLite version is to new - max ConLite version %s', 'pluginmanager'), self::$XmlRequirements->conlite->attributes()->maxversion));
|
||||
}
|
||||
}
|
||||
|
||||
// Check PHP version
|
||||
if (version_compare(phpversion(), self::$XmlRequirements->attributes()->php, '<')) {
|
||||
parent::error(sprintf(i18n('You have to install PHP <strong>%s</strong> or higher to install this plugin!', 'pluginmanager'), self::$XmlRequirements->attributes()->php));
|
||||
}
|
||||
|
||||
/* @todo check and implement other requirement checks
|
||||
// Check extensions
|
||||
if (count(parent::$XmlRequirements->extension) != 0) {
|
||||
|
||||
for ($i = 0; $i < count(parent::$XmlRequirements->extension); $i++) {
|
||||
|
||||
if (!extension_loaded(parent::$XmlRequirements->extension[$i]->attributes()->name)) {
|
||||
parent::error(sprintf(i18n('The plugin could not find the PHP extension <strong>%s</strong>. Because this is required by the plugin, it can not be installed.', 'pim'), parent::$XmlRequirements->extension[$i]->attributes()->name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check classes
|
||||
if (count(parent::$XmlRequirements->class) != 0) {
|
||||
|
||||
for ($i = 0; $i < count(parent::$XmlRequirements->class); $i++) {
|
||||
|
||||
if (!class_exists(parent::$XmlRequirements->class[$i]->attributes()->name)) {
|
||||
parent::error(sprintf(i18n('The plugin could not find the class <strong>%s</strong>. Because this is required by the plugin, it can not be installed.', 'pim'), parent::$XmlRequirements->class[$i]->attributes()->name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check functions
|
||||
if (count(parent::$XmlRequirements->function) != 0) {
|
||||
|
||||
for ($i = 0; $i < count(parent::$XmlRequirements->function); $i++) {
|
||||
|
||||
if (!function_exists(parent::$XmlRequirements->function[$i]->attributes()->name)) {
|
||||
parent::error(sprintf(i18n('The plugin could not find the function <strong>%s</strong>. Because this is required by the plugin, it can not be installed.', 'pim'), parent::$XmlRequirements->function[$i]->attributes()->name));
|
||||
}
|
||||
}
|
||||
}
|
||||
*
|
||||
*/
|
||||
}
|
||||
|
||||
private function _initInstalledAreasArray() {
|
||||
$this->_aInstalledAreas = array();
|
||||
$oAreaColl = new cApiAreaCollection();
|
||||
$oAreaColl->select();
|
||||
//$oAreaColl->query();
|
||||
/* @var $oArea cApiArea */
|
||||
while ($oArea = $oAreaColl->next()) {
|
||||
$this->_aInstalledAreas[] = $oArea->get('name');
|
||||
}
|
||||
//print_r($this->_aInstalledAreas);
|
||||
}
|
||||
|
||||
private function _initInstalledNavMainArray() {
|
||||
$this->_aInstalledNavMain = array();
|
||||
$oNavMainColl = new cApiNavMainCollection();
|
||||
$oNavMainColl->select();
|
||||
//$oNavMainColl->query();
|
||||
/* @var $oArea cApiArea */
|
||||
while ($oNavMain = $oNavMainColl->next()) {
|
||||
$this->_aInstalledNavMain[$oNavMain->get('name')] = $oNavMain->get('idnavm');
|
||||
}
|
||||
}
|
||||
|
||||
private function _initInstalledNavSubArray() {
|
||||
$this->_aInstalledNavSub = array();
|
||||
$oNavSubColl = new cApiNavSubCollection();
|
||||
$oNavMainColl->select();
|
||||
//$oNavSubColl->query();
|
||||
/* @var $oArea cApiArea */
|
||||
while ($oNavSub = $oNavSubColl->next()) {
|
||||
$this->_aInstalledNavMain[$oNavSub->get('idnavsub')] = $oNavSub->get('name');
|
||||
}
|
||||
}
|
||||
|
||||
private function _getIdForArea($sArea) {
|
||||
if (array_key_exists($sArea, $this->_aAreas)) {
|
||||
return $this->_aAreas[$sArea];
|
||||
}
|
||||
|
||||
if (in_array($sArea, $this->_aInstalledAreas)) {
|
||||
$oArea = new cApiArea();
|
||||
$oArea->loadBy("name", $sArea);
|
||||
if ($oArea->isLoaded()) {
|
||||
return $oArea->get($oArea->primaryKey);
|
||||
}
|
||||
}
|
||||
parent::error(sprintf(i18n('Defined area <strong>%s</strong> not found on your ConLite installation. Please contact your plugin author.', "pluginmanager"), $sArea), $this->_iPiId);
|
||||
}
|
||||
|
||||
private function _getIdForNavMain($sNavMain) {
|
||||
if($sNavMain == "0") {
|
||||
return $sNavMain;
|
||||
}
|
||||
if (array_key_exists($sNavMain, $this->_aInstalledNavMain)) {
|
||||
return $this->_aInstalledNavMain[$sNavMain];
|
||||
}
|
||||
parent::error(sprintf(i18n('Defined nav main <strong>%s</strong> not found on your ConLite installation. Please contact your plugin author.', "pluginmanager"), $sNavMain), $this->_iPiId);
|
||||
}
|
||||
|
||||
public function __destruct() {
|
||||
//echo "<pre>";
|
||||
//print_r($this->_aAreas);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
class pimSetupPluginUninstall extends pimSetupBase {
|
||||
|
||||
const SQL_FILE = "plugin_uninstall.sql";
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function uninstallPlugin($iIdPlugin, $sDeleteSql) {
|
||||
// first check if plugin is installed in db
|
||||
$oPlugin = new pimPlugin($iIdPlugin);
|
||||
if($oPlugin->isLoaded()) { // plugin exists in db
|
||||
$this->_iPiId = (int) $iIdPlugin;
|
||||
$this->_getRelations();
|
||||
if(is_array($this->_aRelations) && count($this->_aRelations) > 0) {
|
||||
if($this->_deleteRelationEntries()) {
|
||||
$this->_deleteRelations();
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if($sDeleteSql == "delete") {
|
||||
$this->_getPluginSql();
|
||||
}
|
||||
|
||||
if($this->doQueries()) {
|
||||
return $this->_PimPluginCollection->delete($iIdPlugin);
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
}
|
Binäre Datei nicht angezeigt.
Nachher Breite: | Höhe: | Größe: 4.2 KiB |
Binäre Datei nicht angezeigt.
Nachher Breite: | Höhe: | Größe: 4.3 KiB |
Binäre Datei nicht angezeigt.
Nachher Breite: | Höhe: | Größe: 4.3 KiB |
Binäre Datei nicht angezeigt.
Nachher Breite: | Höhe: | Größe: 4.5 KiB |
|
@ -0,0 +1,101 @@
|
|||
/**
|
||||
*
|
||||
* @package pluginmanager
|
||||
* @version $Rev:$
|
||||
* @author Ortwin Pinke
|
||||
*
|
||||
* $Id:$
|
||||
*/
|
||||
|
||||
#addplugin {
|
||||
border: 1px solid #B5B5B5;
|
||||
border-top: 0px;
|
||||
height: 40px;
|
||||
padding: 8px;
|
||||
margin-left: 10px;
|
||||
width: 650px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.plugininfo {
|
||||
width: 550px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
hr {
|
||||
border-color: #B5B5B5;
|
||||
line-leight: 1em;
|
||||
}
|
||||
|
||||
ul#pimPluginsInstalled, ul#pimPluginsExtracted {
|
||||
max-width: 550px;
|
||||
list-style-type: none;
|
||||
margin: 0;
|
||||
padding: 5px;
|
||||
margin-top: 10px;
|
||||
background: #eee;
|
||||
}
|
||||
|
||||
ul#pimPluginsInstalled li, ul#pimPluginsExtracted li {
|
||||
margin: 0 5px 5px 5px;
|
||||
padding: 5px;
|
||||
font-size: 1.2em;
|
||||
}
|
||||
|
||||
ul#pimPluginsInstalled li>div .pimHeadline, ul#pimPluginsExtracted li>div .pimHeadline {
|
||||
cursor: move;
|
||||
}
|
||||
|
||||
.ui-state-highlight {
|
||||
height: 1.5em;
|
||||
line-height: 1.2em;
|
||||
background-color: #eee;
|
||||
}
|
||||
|
||||
ul#pimPluginsInstalled li:nth-of-type(even) {
|
||||
background-color: #dddddd;
|
||||
}
|
||||
|
||||
.loadie {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
background-color: #000;
|
||||
width: 0;
|
||||
height: 4px;
|
||||
-webkit-transition: width 0.5s ease-out;
|
||||
box-shadow: 0px 1px 5px rgba(0,0,0,0.25);
|
||||
}
|
||||
|
||||
#pimmsg {
|
||||
font-family:Arial, Helvetica, sans-serif;
|
||||
font-size:13px;
|
||||
margin: 10px 0px;
|
||||
padding:15px 10px 15px 50px;
|
||||
background-repeat: no-repeat;
|
||||
background-position: 10px center;
|
||||
box-shadow: 10px 10px 10px grey;
|
||||
border: 1px solid grey;
|
||||
}
|
||||
|
||||
.info, .success, .warning, .error, .validation {}
|
||||
.info {
|
||||
color: #00529B;
|
||||
background-color: #BDE5F8;
|
||||
background-image: url('images/info.png');
|
||||
}
|
||||
.success {
|
||||
color: #4F8A10;
|
||||
background-color: #DFF2BF;
|
||||
background-image:url('images/success.png');
|
||||
}
|
||||
.warning {
|
||||
color: #9F6000;
|
||||
background-color: #FEEFB3;
|
||||
background-image: url('images/warning.png');
|
||||
}
|
||||
.error {
|
||||
color: #D8000C;
|
||||
background-color: #FFBABA;
|
||||
background-image: url('images/error.png');
|
||||
}
|
Binäre Datei nicht angezeigt.
|
@ -0,0 +1,42 @@
|
|||
INSERT INTO `cl_area` (`idarea`, `parent_id`, `name`, `relevant`, `online`, `menuless`) VALUES ('10000', '0', 'pluginmanager', '1', '1', '1');
|
||||
INSERT INTO `cl_files` (`idfile`, `idarea`, `filename`, `filetype`) VALUES ('10000', '10000', 'pluginmanager/includes/include.right_bottom.php', 'main');
|
||||
INSERT INTO `cl_frame_files` (`idframefile`, `idarea`, `idframe`, `idfile`) VALUES ('10000', '10000', '4', '10000');
|
||||
INSERT INTO `cl_actions` (`idaction`, `idarea`, `alt_name`, `name`, `code`, `location`, `relevant`) VALUES ('10000', '10000', '', 'pluginmanager', '', '', '1');
|
||||
INSERT INTO `cl_nav_sub` (`idnavs`, `idnavm`, `idarea`, `level`, `location`, `online`) VALUES ('10000', '5', '10000', '0', 'pluginmanager/xml/plugin.xml;navigation/administration/pluginmanager/main', '1');
|
||||
|
||||
|
||||
--
|
||||
-- Table structure for table `cl_plugins`
|
||||
--
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `cl_plugins` (
|
||||
`idplugin` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`idclient` int(11) DEFAULT NULL,
|
||||
`name` varchar(255) NOT NULL,
|
||||
`description` text NOT NULL,
|
||||
`author` varchar(255) NOT NULL,
|
||||
`copyright` varchar(255) NOT NULL,
|
||||
`mail` varchar(255) NOT NULL,
|
||||
`website` varchar(255) NOT NULL,
|
||||
`version` varchar(10) NOT NULL,
|
||||
`folder` varchar(255) NOT NULL,
|
||||
`uuid` varchar(255) NOT NULL,
|
||||
`executionorder` int(11) NOT NULL DEFAULT '0',
|
||||
`installed` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
|
||||
`active` tinyint(1) DEFAULT NULL,
|
||||
PRIMARY KEY (`idplugin`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `cl_plugins_rel`
|
||||
--
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `cl_plugins_rel` (
|
||||
`idpluginrelation` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`iditem` int(11) NOT NULL,
|
||||
`idplugin` int(11) NOT NULL,
|
||||
`type` varchar(8) NOT NULL DEFAULT 'area',
|
||||
PRIMARY KEY (`idpluginrelation`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
Binäre Datei nicht angezeigt.
|
@ -0,0 +1,2 @@
|
|||
find . \( -path "./_module" -o -path "./_src" -o -path "./docs" \) -prune ! -type d -o -iname "*.php" -o -iname "*.html" > ./locale/potfiles.txt
|
||||
xgettext --from-code=utf-8 --keyword=i18n -f ./locale/potfiles.txt -o ./locale/pluginmanager.pot
|
Datei-Diff unterdrückt, da er zu groß ist
Diff laden
|
@ -0,0 +1,57 @@
|
|||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* A predicate is an object that can evaluate to true or false depending on the
|
||||
* file currently read by a File_Archive_Reader
|
||||
*
|
||||
* @see File_Archive_Reader_Filter
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* @category File Formats
|
||||
* @package File_Archive
|
||||
* @author Vincent Lascaux <vincentlascaux@php.net>
|
||||
* @copyright 1997-2005 The PHP Group
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
||||
* @version CVS: $Id: Predicate.php 2 2010-11-23 14:32:26Z oldperl $
|
||||
* @link http://pear.php.net/package/File_Archive
|
||||
*/
|
||||
|
||||
require_once "File/Archive/Reader.php";
|
||||
|
||||
/**
|
||||
* A predicate is an object that can evaluate to true or false depending on the
|
||||
* file currently read by a File_Archive_Reader
|
||||
*
|
||||
* @see File_Archive_Reader_Filter
|
||||
*/
|
||||
class File_Archive_Predicate
|
||||
{
|
||||
/**
|
||||
* Indicates whether the current file from the reader should be kept
|
||||
*
|
||||
* @param File_Archive_Reader $source Reader which will be filtered
|
||||
* @return bool False if the current file must be filtered out
|
||||
*/
|
||||
function isTrue(&$source)
|
||||
{
|
||||
return PEAR::raiseError("Predicat abstract function call");
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -0,0 +1,87 @@
|
|||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* Evaluates to true iif all predicates given as constructor parameters evaluate
|
||||
* to true
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* @category File Formats
|
||||
* @package File_Archive
|
||||
* @author Vincent Lascaux <vincentlascaux@php.net>
|
||||
* @copyright 1997-2005 The PHP Group
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
||||
* @version CVS: $Id: And.php 2 2010-11-23 14:32:26Z oldperl $
|
||||
* @link http://pear.php.net/package/File_Archive
|
||||
*/
|
||||
|
||||
require_once "File/Archive/Predicate.php";
|
||||
|
||||
/**
|
||||
* Evaluates to true iif all predicates given as constructor parameters evaluate
|
||||
* to true
|
||||
*
|
||||
* Example:
|
||||
* new File_Archive_Predicate_And($pred1, $pred2, $pred3)
|
||||
*
|
||||
* @see File_Archive_Predicate, File_Archive_Reader_Filter
|
||||
*/
|
||||
class File_Archive_Predicate_And extends File_Archive_Predicate
|
||||
{
|
||||
/**
|
||||
* @var Array List of File_Archive_Predicate objects given as an argument
|
||||
* @access private
|
||||
*/
|
||||
var $preds;
|
||||
|
||||
/**
|
||||
* Build the predicate using the optional File_Archive_Predicates given as
|
||||
* arguments
|
||||
*
|
||||
* Example:
|
||||
* new File_Archive_Predicate_And($pred1, $pred2, $pred3)
|
||||
*/
|
||||
function File_Archive_Predicate_And()
|
||||
{
|
||||
$this->preds = func_get_args();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new predicate to the list
|
||||
*
|
||||
* @param File_Archive_Predicate The predicate to add
|
||||
*/
|
||||
function addPredicate($pred)
|
||||
{
|
||||
$this->preds[] = $pred;
|
||||
}
|
||||
/**
|
||||
* @see File_Archive_Predicate::isTrue()
|
||||
*/
|
||||
function isTrue(&$source)
|
||||
{
|
||||
foreach ($this->preds as $p) {
|
||||
if (!$p->isTrue($source)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -0,0 +1,52 @@
|
|||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* Evaluates to true only once, and then always to false
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* @category File Formats
|
||||
* @package File_Archive
|
||||
* @author Vincent Lascaux <vincentlascaux@php.net>
|
||||
* @copyright 1997-2005 The PHP Group
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
||||
* @version CVS: $Id: Current.php 2 2010-11-23 14:32:26Z oldperl $
|
||||
* @link http://pear.php.net/package/File_Archive
|
||||
*/
|
||||
|
||||
require_once "File/Archive/Predicate.php";
|
||||
|
||||
/**
|
||||
* Evaluates to true only once, and then always to false
|
||||
*/
|
||||
class File_Archive_Predicate_Current extends File_Archive_Predicate
|
||||
{
|
||||
var $value = true;
|
||||
|
||||
/**
|
||||
* @see File_Archive_Predicate::isTrue()
|
||||
*/
|
||||
function isTrue(&$source)
|
||||
{
|
||||
$tmp = $this->value;
|
||||
$this->value = false;
|
||||
return $tmp;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -0,0 +1,88 @@
|
|||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* Custom predicate built by supplying a string expression
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* @category File Formats
|
||||
* @package File_Archive
|
||||
* @author Vincent Lascaux <vincentlascaux@php.net>
|
||||
* @copyright 1997-2005 The PHP Group
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
||||
* @version CVS: $Id: Custom.php 2 2010-11-23 14:32:26Z oldperl $
|
||||
* @link http://pear.php.net/package/File_Archive
|
||||
*/
|
||||
|
||||
require_once "File/Archive/Predicate.php";
|
||||
|
||||
/**
|
||||
* Custom predicate built by supplying a string expression
|
||||
*
|
||||
* Example:
|
||||
* new File_Archive_Predicate_Custom("return strlen($name)<100;")
|
||||
* new File_Archive_Predicate_Custom("strlen($name)<100;")
|
||||
* new File_Archive_Predicate_Custom("strlen($name)<100")
|
||||
* new File_Archive_Predicate_Custom("strlen($source->getFilename())<100")
|
||||
*
|
||||
* @see File_Archive_Predicate, File_Archive_Reader_Filter
|
||||
*/
|
||||
class File_Archive_Predicate_Custom extends File_Archive_Predicate
|
||||
{
|
||||
var $expression;
|
||||
var $useName;
|
||||
var $useStat;
|
||||
var $useMIME;
|
||||
|
||||
/**
|
||||
* @param string $expression PHP code that evaluates too a boolean
|
||||
* It can use the $source variable. If return is ommited, it will be
|
||||
* added to the begining of the expression. A ; will also be added at
|
||||
* the end so that you don't need to write it
|
||||
*/
|
||||
function File_Archive_Predicate_Custom($expression)
|
||||
{
|
||||
$this->expression = $expression.";";
|
||||
if (strpos($this->expression, "return") === false) {
|
||||
$this->expression = "return ".$this->expression;
|
||||
}
|
||||
$this->useName = (strpos($this->expression, '$name') !== false);
|
||||
$this->useStat = (strpos($this->expression, '$stat') !== false);
|
||||
$this->useMIME = (strpos($this->expression, '$mime') !== false);
|
||||
}
|
||||
/**
|
||||
* @see File_Archive_Predicate::isTrue()
|
||||
*/
|
||||
function isTrue(&$source)
|
||||
{
|
||||
if ($this->useName) {
|
||||
$name = $source->getFilename();
|
||||
}
|
||||
if ($this->useStat) {
|
||||
$stat = $source->getStat();
|
||||
$size = $stat[7];
|
||||
$time = (isset($stat[9]) ? $stat[9] : null);
|
||||
}
|
||||
if ($this->useMIME) {
|
||||
$mime = $source->getMIME();
|
||||
}
|
||||
return (bool)eval($this->expression);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -0,0 +1,116 @@
|
|||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* Evaluates to true if a for the files for which a newer version
|
||||
* can be found in a specified archive
|
||||
* Comparison is by default made on dates of the files, or position
|
||||
* in the archive (if two files have the same date or the date of a
|
||||
* file is not specified).
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* @category File Formats
|
||||
* @package File_Archive
|
||||
* @author Vincent Lascaux <vincentlascaux@php.net>
|
||||
* @copyright 1997-2005 The PHP Group
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
||||
* @version CVS: $Id: Duplicate.php 2 2010-11-23 14:32:26Z oldperl $
|
||||
* @link http://pear.php.net/package/File_Archive
|
||||
*/
|
||||
|
||||
require_once "File/Archive/Predicate.php";
|
||||
|
||||
/**
|
||||
* Evaluates to true if a for the files for which a newer version
|
||||
* can be found in a specified archive
|
||||
* Comparison is by default made on dates of the files, or position
|
||||
* in the archive (if two files have the same date or the date of a
|
||||
* file is not specified).
|
||||
*/
|
||||
class File_Archive_Predicate_Duplicate extends File_Archive_Predicate
|
||||
{
|
||||
/**
|
||||
* @var array Key is the filename, value is an array of date (index 0) and
|
||||
* position in the archive (index) 1 of the newest entry with this filename
|
||||
*/
|
||||
var $newest = array();
|
||||
|
||||
/**
|
||||
* @var int The current position of the file in the source
|
||||
*/
|
||||
var $pos = 0;
|
||||
|
||||
/**
|
||||
* @param File_Archive_Reader $source The source will be inspected to find
|
||||
* the date of old files
|
||||
* The predicate should then be used on the same source to remove the
|
||||
* old duplicate files
|
||||
*/
|
||||
function File_Archive_Predicate_Duplicate(&$source)
|
||||
{
|
||||
//Ensure we are at the begining of the file
|
||||
$source->close();
|
||||
$pos = 0;
|
||||
while ($source->next()) {
|
||||
$filename = $source->getFilename();
|
||||
$stat = $source->getStat();
|
||||
$value = isset($this->newest[$filename]) ? $this->newest[$filename] : null;
|
||||
|
||||
if ($value === null ||
|
||||
$this->compare($stat[9], $value[0]) >= 0
|
||||
) {
|
||||
$this->newest[$filename] = array($stat[9], $pos);
|
||||
}
|
||||
$pos++;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare the dates of two files. null is considered infinitely old
|
||||
*
|
||||
* @return int < 0 if $a can be considered older than $b
|
||||
* = 0 if $a and $b can be considered same age
|
||||
* > 0 if $a can be considered newer than $b
|
||||
*/
|
||||
function compare($a, $b) {
|
||||
return ($a === null ? -1 : $a) - ($b === null ? -1 : $b);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see File_Archive_Predicate::isTrue()
|
||||
*/
|
||||
function isTrue(&$source)
|
||||
{
|
||||
$filename = $source->getFilename();
|
||||
$stat = $source->getStat();
|
||||
$value = isset($this->newest[$filename]) ? $this->newest[$filename] : null;
|
||||
if ($value === null) {
|
||||
$delete = false;
|
||||
} else {
|
||||
$comp = $this->compare($stat[9], $value[0]);
|
||||
|
||||
$delete = $comp < 0 ||
|
||||
($comp == 0 && $this->pos != $value[1]);
|
||||
|
||||
}
|
||||
$this->pos++;
|
||||
return $delete;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -0,0 +1,59 @@
|
|||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* Keep only the files which name follow a given regular expression
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* @category File Formats
|
||||
* @package File_Archive
|
||||
* @author Vincent Lascaux <vincentlascaux@php.net>
|
||||
* @copyright 1997-2005 The PHP Group
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
||||
* @version CVS: $Id: Ereg.php 2 2010-11-23 14:32:26Z oldperl $
|
||||
* @link http://pear.php.net/package/File_Archive
|
||||
*/
|
||||
|
||||
require_once "File/Archive/Predicate.php";
|
||||
|
||||
/**
|
||||
* Keep only the files which name follow a given regular expression
|
||||
*
|
||||
* @see File_Archive_Predicate, File_Archive_Reader_Filter ereg
|
||||
*/
|
||||
class File_Archive_Predicate_Ereg extends File_Archive_Predicate
|
||||
{
|
||||
var $ereg;
|
||||
|
||||
/**
|
||||
* @param string $ereg is the regular expression
|
||||
*/
|
||||
function File_Archive_Predicate_Ereg($ereg)
|
||||
{
|
||||
$this->ereg = $ereg;
|
||||
}
|
||||
/**
|
||||
* @see File_Archive_Predicate::isTrue()
|
||||
*/
|
||||
function isTrue(&$source)
|
||||
{
|
||||
return (bool)ereg($this->ereg, $source->getFilename());
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -0,0 +1,61 @@
|
|||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* Keep only the files which name follow a given case insensitive regular
|
||||
* expression
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* @category File Formats
|
||||
* @package File_Archive
|
||||
* @author Vincent Lascaux <vincentlascaux@php.net>
|
||||
* @copyright 1997-2005 The PHP Group
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
||||
* @version CVS: $Id: Eregi.php 2 2010-11-23 14:32:26Z oldperl $
|
||||
* @link http://pear.php.net/package/File_Archive
|
||||
*/
|
||||
|
||||
require_once "File/Archive/Predicate.php";
|
||||
|
||||
/**
|
||||
* Keep only the files which name follow a given case insensitive regular
|
||||
* expression
|
||||
*
|
||||
* @see File_Archive_Predicate, File_Archive_Reader_Filter eregi
|
||||
*/
|
||||
class File_Archive_Predicate_Eregi extends File_Archive_Predicate
|
||||
{
|
||||
var $ereg;
|
||||
|
||||
/**
|
||||
* @param string $ereg is the regular expression
|
||||
*/
|
||||
function File_Archive_Predicate_Eregi($ereg)
|
||||
{
|
||||
$this->ereg = $ereg;
|
||||
}
|
||||
/**
|
||||
* @see File_Archive_Predicate::isTrue()
|
||||
*/
|
||||
function isTrue(&$source)
|
||||
{
|
||||
return (bool)eregi($this->ereg, $source->getFilename());
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -0,0 +1,71 @@
|
|||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* Keep only the files that have a specific extension
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* @category File Formats
|
||||
* @package File_Archive
|
||||
* @author Vincent Lascaux <vincentlascaux@php.net>
|
||||
* @copyright 1997-2005 The PHP Group
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
||||
* @version CVS: $Id: Extension.php 2 2010-11-23 14:32:26Z oldperl $
|
||||
* @link http://pear.php.net/package/File_Archive
|
||||
*/
|
||||
|
||||
require_once "File/Archive/Predicate.php";
|
||||
|
||||
/**
|
||||
* Keep only the files that have a specific extension
|
||||
*
|
||||
* @see File_Archive_Predicate, File_Archive_Reader_Filter
|
||||
*/
|
||||
class File_Archive_Predicate_Extension extends File_Archive_Predicate
|
||||
{
|
||||
var $extensions;
|
||||
|
||||
/**
|
||||
* @param $extensions array or comma separated string of allowed extensions
|
||||
*/
|
||||
function File_Archive_Predicate_Extension($extensions)
|
||||
{
|
||||
if (is_string($extensions)) {
|
||||
$this->extensions = explode(",",$extensions);
|
||||
} else {
|
||||
$this->extensions = $extensions;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @see File_Archive_Predicate::isTrue()
|
||||
*/
|
||||
function isTrue(&$source)
|
||||
{
|
||||
$filename = $source->getFilename();
|
||||
$pos = strrpos($filename, '.');
|
||||
$extension = "";
|
||||
if ($pos !== FALSE) {
|
||||
$extension = strtolower(substr($filename, $pos+1));
|
||||
}
|
||||
$result = in_array($extension, $this->extensions);
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* Always evaluate to false
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* @category File Formats
|
||||
* @package File_Archive
|
||||
* @author Vincent Lascaux <vincentlascaux@php.net>
|
||||
* @copyright 1997-2005 The PHP Group
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
||||
* @version CVS: $Id: False.php 2 2010-11-23 14:32:26Z oldperl $
|
||||
* @link http://pear.php.net/package/File_Archive
|
||||
*/
|
||||
|
||||
require_once "File/Archive/Predicate.php";
|
||||
|
||||
/**
|
||||
* Always evaluate to false
|
||||
*
|
||||
* @see File_Archive_Predicate, File_Archive_Reader_Filter
|
||||
*/
|
||||
class File_Archive_Predicate_False extends File_Archive_Predicate
|
||||
{
|
||||
/**
|
||||
* @see File_Archive_Predicate::isTrue()
|
||||
*/
|
||||
function isTrue(&$source) { return false; }
|
||||
}
|
||||
|
||||
?>
|
|
@ -0,0 +1,62 @@
|
|||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* Evaluates to true if the index is in a given array of indexes
|
||||
* The array has the indexes in key (so you may want to call
|
||||
* array_flip if your array has indexes as value)
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* @category File Formats
|
||||
* @package File_Archive
|
||||
* @author Vincent Lascaux <vincentlascaux@php.net>
|
||||
* @copyright 1997-2005 The PHP Group
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
||||
* @version CVS: $Id: Index.php 2 2010-11-23 14:32:26Z oldperl $
|
||||
* @link http://pear.php.net/package/File_Archive
|
||||
*/
|
||||
|
||||
require_once "File/Archive/Predicate.php";
|
||||
|
||||
/**
|
||||
* Evaluates to true if the index is in a given array of indexes
|
||||
* The array has the indexes in key (so you may want to call
|
||||
* array_flip if your array has indexes as value)
|
||||
*/
|
||||
class File_Archive_Predicate_Index extends File_Archive_Predicate
|
||||
{
|
||||
var $indexes;
|
||||
var $pos = 0;
|
||||
|
||||
/**
|
||||
* @param $extensions array or comma separated string of allowed extensions
|
||||
*/
|
||||
function File_Archive_Predicate_Index($indexes)
|
||||
{
|
||||
$this->indexes = $indexes;
|
||||
}
|
||||
/**
|
||||
* @see File_Archive_Predicate::isTrue()
|
||||
*/
|
||||
function isTrue(&$source)
|
||||
{
|
||||
return isset($this->indexes[$this->pos++]);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -0,0 +1,75 @@
|
|||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* Keep only the files that have a specific MIME type
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* @category File Formats
|
||||
* @package File_Archive
|
||||
* @author Vincent Lascaux <vincentlascaux@php.net>
|
||||
* @copyright 1997-2005 The PHP Group
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
||||
* @version CVS: $Id: MIME.php 2 2010-11-23 14:32:26Z oldperl $
|
||||
* @link http://pear.php.net/package/File_Archive
|
||||
*/
|
||||
|
||||
require_once "File/Archive/Predicate.php";
|
||||
require_once "MIME/Type.php";
|
||||
|
||||
/**
|
||||
* Keep only the files that have a specific MIME type
|
||||
*
|
||||
* @see File_Archive_Predicate, File_Archive_Reader_Filter
|
||||
*/
|
||||
class File_Archive_Predicate_MIME extends File_Archive_Predicate
|
||||
{
|
||||
var $mimes;
|
||||
|
||||
/**
|
||||
* @param $extensions array or comma separated string of allowed extensions
|
||||
*/
|
||||
function File_Archive_Predicate_MIME($mimes)
|
||||
{
|
||||
if (is_string($mimes)) {
|
||||
$this->mimes = explode(",",$mimes);
|
||||
} else {
|
||||
$this->mimes = $mimes;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @see File_Archive_Predicate::isTrue()
|
||||
*/
|
||||
function isTrue(&$source)
|
||||
{
|
||||
$sourceMIME = $source->getMIME();
|
||||
foreach ($this->mimes as $mime) {
|
||||
if (MIME_Type::isWildcard($mime)) {
|
||||
$result = MIME_Type::wildcardMatch($mime, $sourceMIME);
|
||||
} else {
|
||||
$result = ($mime == $sourceMIME);
|
||||
}
|
||||
if ($result !== false) {
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -0,0 +1,63 @@
|
|||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* Remove the URLs with a too high number of nested directories
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* @category File Formats
|
||||
* @package File_Archive
|
||||
* @author Vincent Lascaux <vincentlascaux@php.net>
|
||||
* @copyright 1997-2005 The PHP Group
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
||||
* @version CVS: $Id: MaxDepth.php 2 2010-11-23 14:32:26Z oldperl $
|
||||
* @link http://pear.php.net/package/File_Archive
|
||||
*/
|
||||
|
||||
require_once "File/Archive/Predicate.php";
|
||||
|
||||
/**
|
||||
* Remove the URLs with a too high number of nested directories
|
||||
*
|
||||
* @see File_Archive_Predicate, File_Archive_Reader_Filter
|
||||
*/
|
||||
class File_Archive_Predicate_MaxDepth extends File_Archive_Predicate
|
||||
{
|
||||
var $maxDepth;
|
||||
|
||||
/**
|
||||
* @param int $maxDepth Maximal number of folders before the actual file in
|
||||
* $source->getFilename().
|
||||
* '1/2/3/4/foo.txt' will be accepted with $maxDepth == 4 and
|
||||
* rejected with $maxDepth == 5
|
||||
*/
|
||||
function File_Archive_Predicate_MaxDepth($maxDepth)
|
||||
{
|
||||
$this->maxDepth = $maxDepth;
|
||||
}
|
||||
/**
|
||||
* @see File_Archive_Predicate::isTrue()
|
||||
*/
|
||||
function isTrue(&$source)
|
||||
{
|
||||
$url = parse_url($source->getFilename());
|
||||
return substr_count($url['path'], '/') <= $this->maxDepth ;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -0,0 +1,59 @@
|
|||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* Keep only the files larger than a given size
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* @category File Formats
|
||||
* @package File_Archive
|
||||
* @author Vincent Lascaux <vincentlascaux@php.net>
|
||||
* @copyright 1997-2005 The PHP Group
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
||||
* @version CVS: $Id: MinSize.php 2 2010-11-23 14:32:26Z oldperl $
|
||||
* @link http://pear.php.net/package/File_Archive
|
||||
*/
|
||||
|
||||
require_once "File/Archive/Predicate.php";
|
||||
|
||||
/**
|
||||
* Keep only the files larger than a given size
|
||||
*
|
||||
* @see File_Archive_Predicate, File_Archive_Reader_Filter
|
||||
*/
|
||||
class File_Archive_Predicate_MinSize extends File_Archive_Predicate
|
||||
{
|
||||
var $minSize = 0;
|
||||
|
||||
/**
|
||||
* @param int $minSize minimal size of the file (in Bytes)
|
||||
*/
|
||||
function File_Archive_Predicate_MinSize($minSize)
|
||||
{
|
||||
$this->minSize = $minSize;
|
||||
}
|
||||
/**
|
||||
* @see File_Archive_Predicate::isTrue()
|
||||
*/
|
||||
function isTrue(&$source)
|
||||
{
|
||||
$stat = $source->getStat();
|
||||
return !isset($stat[7]) || $stat[7]>=$this->minSize;
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -0,0 +1,63 @@
|
|||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* Keep only the files modified after a given date (or with unknown modification
|
||||
* date)
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* @category File Formats
|
||||
* @package File_Archive
|
||||
* @author Vincent Lascaux <vincentlascaux@php.net>
|
||||
* @copyright 1997-2005 The PHP Group
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
||||
* @version CVS: $Id: MinTime.php 2 2010-11-23 14:32:26Z oldperl $
|
||||
* @link http://pear.php.net/package/File_Archive
|
||||
*/
|
||||
|
||||
require_once "File/Archive/Predicate.php";
|
||||
|
||||
/**
|
||||
* Keep only the files modified after a given date (or with unknown modification
|
||||
* date)
|
||||
*
|
||||
* @see File_Archive_Predicate, File_Archive_Reader_Filter
|
||||
*/
|
||||
class File_Archive_Predicate_MinTime extends File_Archive_Predicate
|
||||
{
|
||||
var $minTime = 0;
|
||||
|
||||
/**
|
||||
* @param int $minTime Unix timestamp of the minimal modification date of
|
||||
* the files
|
||||
*/
|
||||
function File_Archive_Predicate_MinTime($minTime)
|
||||
{
|
||||
$this->minTime = $minTime;
|
||||
|
||||
}
|
||||
/**
|
||||
* @see File_Archive_Predicate::isTrue()
|
||||
*/
|
||||
function isTrue(&$source)
|
||||
{
|
||||
$stat = $source->getStat();
|
||||
return !isset($stat[9]) || $stat[9]>=$this->minTime;
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* Evaluates to true iif the predicate given in parameter evaluates to false
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* @category File Formats
|
||||
* @package File_Archive
|
||||
* @author Vincent Lascaux <vincentlascaux@php.net>
|
||||
* @copyright 1997-2005 The PHP Group
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
||||
* @version CVS: $Id: Not.php 2 2010-11-23 14:32:26Z oldperl $
|
||||
* @link http://pear.php.net/package/File_Archive
|
||||
*/
|
||||
|
||||
require_once "File/Archive/Predicate.php";
|
||||
|
||||
/**
|
||||
* Evaluates to true iif the predicate given in parameter evaluates to false
|
||||
*
|
||||
* @see File_Archive_Predicate, File_Archive_Reader_Filter
|
||||
*/
|
||||
class File_Archive_Predicate_Not extends File_Archive_Predicate
|
||||
{
|
||||
var $pred;
|
||||
function File_Archive_Predicate_Not($pred)
|
||||
{
|
||||
$this->pred = $pred;
|
||||
}
|
||||
/**
|
||||
* @see File_Archive_Predicate::isTrue()
|
||||
*/
|
||||
function isTrue(&$source)
|
||||
{
|
||||
return !$this->pred->isTrue($source);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -0,0 +1,85 @@
|
|||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* Evaluates to true iif one at least of the predicates
|
||||
* given as constructor parameters evaluate to true
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* @category File Formats
|
||||
* @package File_Archive
|
||||
* @author Vincent Lascaux <vincentlascaux@php.net>
|
||||
* @copyright 1997-2005 The PHP Group
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
||||
* @version CVS: $Id: Or.php 2 2010-11-23 14:32:26Z oldperl $
|
||||
* @link http://pear.php.net/package/File_Archive
|
||||
*/
|
||||
|
||||
require_once "File/Archive/Predicate.php";
|
||||
|
||||
/**
|
||||
* Evaluates to true iif one at least of the predicates
|
||||
* given as constructor parameters evaluate to true
|
||||
*
|
||||
* @see File_Archive_Predicate, File_Archive_Reader_Filter
|
||||
*/
|
||||
class File_Archive_Predicate_Or extends File_Archive_Predicate
|
||||
{
|
||||
/**
|
||||
* @var Array List of File_Archive_Predicate objects given as an argument
|
||||
* @access private
|
||||
*/
|
||||
var $preds;
|
||||
|
||||
/**
|
||||
* Build the predicate using the optional File_Archive_Predicates given as
|
||||
* arguments
|
||||
*
|
||||
* Example:
|
||||
* new File_Archive_Predicate_And($pred1, $pred2, $pred3)
|
||||
*/
|
||||
function File_Archive_Predicate_And()
|
||||
{
|
||||
$this->preds = func_get_args();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new predicate to the list
|
||||
*
|
||||
* @param File_Archive_Predicate The predicate to add
|
||||
*/
|
||||
function addPredicate($pred)
|
||||
{
|
||||
$this->preds[] = $pred;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see File_Archive_Predicate::isTrue()
|
||||
*/
|
||||
function isTrue(&$source)
|
||||
{
|
||||
foreach ($this->preds as $p) {
|
||||
if ($p->isTrue($source)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* Always evaluate to true
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* @category File Formats
|
||||
* @package File_Archive
|
||||
* @author Vincent Lascaux <vincentlascaux@php.net>
|
||||
* @copyright 1997-2005 The PHP Group
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
||||
* @version CVS: $Id: True.php 2 2010-11-23 14:32:26Z oldperl $
|
||||
* @link http://pear.php.net/package/File_Archive
|
||||
*/
|
||||
|
||||
require_once "File/Archive/Predicate.php";
|
||||
|
||||
/**
|
||||
* Always evaluate to true
|
||||
*/
|
||||
class File_Archive_Predicate_True extends File_Archive_Predicate
|
||||
{
|
||||
/**
|
||||
* @see File_Archive_Predicate::isTrue()
|
||||
*/
|
||||
function isTrue(&$source) { return true; }
|
||||
}
|
||||
|
||||
?>
|
|
@ -0,0 +1,427 @@
|
|||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* Abstract base class for all the readers
|
||||
*
|
||||
* A reader is a compilation of serveral files that can be read
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* @category File Formats
|
||||
* @package File_Archive
|
||||
* @author Vincent Lascaux <vincentlascaux@php.net>
|
||||
* @copyright 1997-2005 The PHP Group
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
||||
* @version CVS: $Id: Reader.php 2 2010-11-23 14:32:26Z oldperl $
|
||||
* @link http://pear.php.net/package/File_Archive
|
||||
*/
|
||||
|
||||
require_once "PEAR.php";
|
||||
|
||||
/**
|
||||
* Abstract base class for all the readers
|
||||
*
|
||||
* A reader is a compilation of serveral files that can be read
|
||||
*/
|
||||
class File_Archive_Reader
|
||||
{
|
||||
/**
|
||||
* Move to the next file or folder in the reader
|
||||
*
|
||||
* @return bool false iif no more files are available
|
||||
*/
|
||||
function next()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Move to the next file whose name is in directory $filename
|
||||
* or is exactly $filename
|
||||
*
|
||||
* @param string $filename Name of the file to find in the archive
|
||||
* @param bool $close If true, close the reader and search from the first file
|
||||
* @return bool whether the file was found in the archive or not
|
||||
*/
|
||||
function select($filename, $close = true)
|
||||
{
|
||||
$std = $this->getStandardURL($filename);
|
||||
if (substr($std, -1)=='/') {
|
||||
$std = substr($std, 0, -1);
|
||||
}
|
||||
|
||||
if ($close) {
|
||||
$error = $this->close();
|
||||
if (PEAR::isError($error)) {
|
||||
return $error;
|
||||
}
|
||||
}
|
||||
while (($error = $this->next()) === true) {
|
||||
$sourceName = $this->getFilename();
|
||||
if (
|
||||
empty($std) ||
|
||||
|
||||
//$std is a file
|
||||
$std == $sourceName ||
|
||||
|
||||
//$std is a directory
|
||||
(strncmp($std.'/', $sourceName, strlen($std)+1) == 0 &&
|
||||
strlen($sourceName) > strlen($std)+1)
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return $error;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the standard path
|
||||
* Changes \ to /
|
||||
* Removes the .. and . from the URL
|
||||
* @param string $path a valid URL that may contain . or .. and \
|
||||
* @static
|
||||
*/
|
||||
function getStandardURL($path)
|
||||
{
|
||||
if ($path == '.') {
|
||||
return '';
|
||||
}
|
||||
$std = str_replace("\\", "/", $path);
|
||||
while ($std != ($std = preg_replace("/[^\/:?]+\/\.\.\//", "", $std))) ;
|
||||
$std = str_replace("/./", "", $std);
|
||||
if (strncmp($std, "./", 2) == 0) {
|
||||
/**
|
||||
* If return value is going to be / (root on POSIX)
|
||||
*/
|
||||
if (substr($std, 2) === '/') {
|
||||
return $std;
|
||||
}
|
||||
return substr($std, 2);
|
||||
} else {
|
||||
return $std;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the file currently read by the reader
|
||||
*
|
||||
* Warning: undefined behaviour if no call to next have been
|
||||
* done or if last call to next has returned false
|
||||
*
|
||||
* @return string Name of the current file
|
||||
*/
|
||||
function getFilename()
|
||||
{
|
||||
return PEAR::raiseError("Reader abstract function call (getFilename)");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of filenames from the current pos to the end of the source
|
||||
* The source will be closed after having called this function
|
||||
* This function goes through the whole archive (which may be slow).
|
||||
* If you intend to work on the reader, doing it in one pass would be faster
|
||||
*
|
||||
* @return array filenames from the current pos to the end of the source
|
||||
*/
|
||||
function getFileList()
|
||||
{
|
||||
$result = array();
|
||||
while ( ($error = $this->next()) === true) {
|
||||
$result[] = $this->getFilename();
|
||||
}
|
||||
$this->close();
|
||||
if (PEAR::isError($error)) {
|
||||
return $error;
|
||||
} else {
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of statistics about the file
|
||||
* (see the PHP stat function for more information)
|
||||
*
|
||||
* The returned array may be empty, even if readers should try
|
||||
* their best to return as many data as possible
|
||||
*/
|
||||
function getStat() { return array(); }
|
||||
|
||||
/**
|
||||
* Returns the MIME associated with the current file
|
||||
* The default function does that by looking at the extension of the file
|
||||
*/
|
||||
function getMime()
|
||||
{
|
||||
require_once "File/Archive/Reader/MimeList.php";
|
||||
return File_Archive_Reader_GetMime($this->getFilename());
|
||||
}
|
||||
|
||||
/**
|
||||
* If the current file of the archive is a physical file,
|
||||
*
|
||||
* @return the name of the physical file containing the data
|
||||
* or null if no such file exists
|
||||
*
|
||||
* The data filename may not be the same as the filename.
|
||||
*/
|
||||
function getDataFilename() { return null; }
|
||||
|
||||
/**
|
||||
* Reads some data from the current file
|
||||
* If the end of the file is reached, returns null
|
||||
* If $length is not specified, reads up to the end of the file
|
||||
* If $length is specified reads up to $length
|
||||
*/
|
||||
function getData($length = -1)
|
||||
{
|
||||
return PEAR::raiseError("Reader abstract function call (getData)");
|
||||
}
|
||||
|
||||
/**
|
||||
* Skip some data and returns how many bytes have been skipped
|
||||
* This is strictly equivalent to
|
||||
* return strlen(getData($length))
|
||||
* But could be far more efficient
|
||||
*/
|
||||
function skip($length = -1)
|
||||
{
|
||||
$data = $this->getData($length);
|
||||
if (PEAR::isError($data)) {
|
||||
return $data;
|
||||
} else {
|
||||
return strlen($data);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Move the current position back of a given amount of bytes.
|
||||
* Not all readers may implement this function (a PEAR error will
|
||||
* be returned if the reader can't rewind)
|
||||
*
|
||||
* @param int $length number of bytes to seek before the current pos
|
||||
* or -1 to move back to the begining of the current file
|
||||
* @return the number of bytes really rewinded (which may be less than
|
||||
* $length if the current pos is less than $length
|
||||
*/
|
||||
function rewind($length = -1)
|
||||
{
|
||||
return PEAR::raiseError('Rewind function is not implemented on this reader');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current offset in the current file
|
||||
*/
|
||||
function tell()
|
||||
{
|
||||
$offset = $this->rewind();
|
||||
$this->skip($offset);
|
||||
return $offset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Put back the reader in the state it was before the first call
|
||||
* to next()
|
||||
*/
|
||||
function close()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends the current file to the Writer $writer
|
||||
* The data will be sent by chunks of at most $bufferSize bytes
|
||||
* If $bufferSize <= 0 (default), the blockSize option is used
|
||||
*/
|
||||
function sendData(&$writer, $bufferSize = 0)
|
||||
{
|
||||
if (PEAR::isError($writer)) {
|
||||
return $writer;
|
||||
}
|
||||
if ($bufferSize <= 0) {
|
||||
$bufferSize = File_Archive::getOption('blockSize');
|
||||
}
|
||||
|
||||
$filename = $this->getDataFilename();
|
||||
if ($filename !== null) {
|
||||
$error = $writer->writeFile($filename);
|
||||
if (PEAR::isError($error)) {
|
||||
return $error;
|
||||
}
|
||||
} else {
|
||||
while (($data = $this->getData($bufferSize)) !== null) {
|
||||
if (PEAR::isError($data)) {
|
||||
return $data;
|
||||
}
|
||||
$error = $writer->writeData($data);
|
||||
if (PEAR::isError($error)) {
|
||||
return $error;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends the whole reader to $writer and close the reader
|
||||
*
|
||||
* @param File_Archive_Writer $writer Where to write the files of the reader
|
||||
* @param bool $autoClose If true, close $writer at the end of the function.
|
||||
* Default value is true
|
||||
* @param int $bufferSize Size of the chunks that will be sent to the writer
|
||||
* If $bufferSize <= 0 (default value), the blockSize option is used
|
||||
*/
|
||||
function extract(&$writer, $autoClose = true, $bufferSize = 0)
|
||||
{
|
||||
if (PEAR::isError($writer)) {
|
||||
$this->close();
|
||||
return $writer;
|
||||
}
|
||||
|
||||
while (($error = $this->next()) === true) {
|
||||
if ($writer->newFileNeedsMIME()) {
|
||||
$mime = $this->getMime();
|
||||
} else {
|
||||
$mime = null;
|
||||
}
|
||||
|
||||
$error = $writer->newFile(
|
||||
$this->getFilename(),
|
||||
$this->getStat(),
|
||||
$mime
|
||||
);
|
||||
if (PEAR::isError($error)) {
|
||||
break;
|
||||
}
|
||||
$error = $this->sendData($writer, $bufferSize);
|
||||
if (PEAR::isError($error)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
$this->close();
|
||||
if ($autoClose) {
|
||||
$writer->close();
|
||||
}
|
||||
if (PEAR::isError($error)) {
|
||||
return $error;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract only one file (given by the URL)
|
||||
*
|
||||
* @param string $filename URL of the file to extract from this
|
||||
* @param File_Archive_Writer $writer Where to write the file
|
||||
* @param bool $autoClose If true, close $writer at the end of the function
|
||||
* Default value is true
|
||||
* @param int $bufferSize Size of the chunks that will be sent to the writer
|
||||
* If $bufferSize <= 0 (default value), the blockSize option is used
|
||||
*/
|
||||
function extractFile($filename, &$writer,
|
||||
$autoClose = true, $bufferSize = 0)
|
||||
{
|
||||
if (PEAR::isError($writer)) {
|
||||
return $writer;
|
||||
}
|
||||
|
||||
if (($error = $this->select($filename)) === true) {
|
||||
$result = $this->sendData($writer, $bufferSize);
|
||||
if (!PEAR::isError($result)) {
|
||||
$result = true;
|
||||
}
|
||||
} else if ($error === false) {
|
||||
$result = PEAR::raiseError("File $filename not found");
|
||||
} else {
|
||||
$result = $error;
|
||||
}
|
||||
if ($autoClose) {
|
||||
$error = $writer->close();
|
||||
if (PEAR::isError($error)) {
|
||||
return $error;
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a writer that allows appending files to the archive
|
||||
* After having called makeAppendWriter, $this is closed and should not be
|
||||
* used until the returned writer is closed.
|
||||
*
|
||||
* @return a writer that will allow to append files to an existing archive
|
||||
* @see makeWriter
|
||||
*/
|
||||
function makeAppendWriter()
|
||||
{
|
||||
require_once "File/Archive/Predicate/False.php";
|
||||
return $this->makeWriterRemoveFiles(new File_Archive_Predicate_False());
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a writer that has the same properties as the one returned by
|
||||
* makeAppendWriter, but after having removed all the files that follow a
|
||||
* given predicate.
|
||||
* After a call to makeWriterRemoveFiles, $this is closed and should not
|
||||
* be used until the returned writer is closed
|
||||
*
|
||||
* @param File_Archive_Predicate $pred the predicate verified by removed files
|
||||
* @return File_Archive_Writer that allows to append files to the archive
|
||||
*/
|
||||
function makeWriterRemoveFiles($pred)
|
||||
{
|
||||
return PEAR::raiseError("Reader abstract function call (makeWriterRemoveFiles)");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a writer that removes the current file
|
||||
* This is a syntaxic sugar for makeWriterRemoveFiles(new File_Archive_Predicate_Current());
|
||||
*/
|
||||
function makeWriterRemove()
|
||||
{
|
||||
require_once "File/Archive/Predicate/Current.php";
|
||||
return $this->makeWriterRemoveFiles(new File_Archive_Predicate_Current());
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the current file from the reader
|
||||
*/
|
||||
function remove()
|
||||
{
|
||||
$writer = $this->makeWriterRemove();
|
||||
if (PEAR::isError($writer)) {
|
||||
return $writer;
|
||||
}
|
||||
$writer->close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a writer that has the same properties as the one returned by makeWriter, but after
|
||||
* having removed a block of data from the current file. The writer will append data to the current file
|
||||
* no data (other than the block) will be removed
|
||||
*
|
||||
* @param array Lengths of the blocks. The first one will be discarded, the second one kept, the third
|
||||
* one discarded... If the sum of the blocks is less than the size of the file, the comportment is the
|
||||
* same as if a last block was set in the array to reach the size of the file
|
||||
* if $length is -1, the file is truncated from the specified pos
|
||||
* It is possible to specify blocks of size 0
|
||||
* @param int $seek relative pos of the block
|
||||
*/
|
||||
function makeWriterRemoveBlocks($blocks, $seek = 0)
|
||||
{
|
||||
return PEAR::raiseError("Reader abstract function call (makeWriterRemoveBlocks)");
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -0,0 +1,387 @@
|
|||
<?php
|
||||
/**
|
||||
* Read a file saved in Ar file format
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* @category File Formats
|
||||
* @package File_Archive
|
||||
* @author Pablo Fischer <pablo@pablo.com.mx>
|
||||
* @copyright 1997-2005 The PHP Group
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
||||
* @version CVS: $Id:
|
||||
* @link http://pear.php.net/package/File_Archive
|
||||
*/
|
||||
|
||||
require_once "File/Archive/Reader/Archive.php";
|
||||
|
||||
/**
|
||||
* Read an Ar archive
|
||||
*/
|
||||
class File_Archive_Reader_Ar extends File_Archive_Reader_Archive
|
||||
{
|
||||
/**
|
||||
* @var int The number of files to read to reach the end of the
|
||||
* current ar file
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
var $_nbBytesLeft = 0;
|
||||
|
||||
/**
|
||||
* @var int The size of the header in number of bytes
|
||||
* The header is not always 60 bytes since it sometimes
|
||||
* contains a long filename
|
||||
* @access private
|
||||
*/
|
||||
var $_header = 0;
|
||||
|
||||
/**
|
||||
* @var boolean Flag set if their is a 1 byte footer after the data
|
||||
* of the current ar file
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
var $_footer = false;
|
||||
|
||||
/**
|
||||
* @var boolean Flag that has tell us if we have read the header of the
|
||||
* current file
|
||||
* @access private
|
||||
*/
|
||||
var $_alreadyRead = false;
|
||||
|
||||
/**
|
||||
* @var string Name of the file being read
|
||||
* @access private
|
||||
*/
|
||||
var $_currentFilename = null;
|
||||
|
||||
/**
|
||||
* @var string Stat properties of the file being read
|
||||
* It has: name, utime, uid, gid, mode, size and data
|
||||
* @access private
|
||||
*/
|
||||
var $_currentStat = null;
|
||||
|
||||
/**
|
||||
* @see File_Archive_Reader::getFilename()
|
||||
*/
|
||||
function getFilename()
|
||||
{
|
||||
return $this->_currentFilename;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see File_Archive_Reader::close()
|
||||
*/
|
||||
function close()
|
||||
{
|
||||
$this->_currentFilename = null;
|
||||
$this->_currentStat = null;
|
||||
$this->_nbBytesLeft = 0;
|
||||
$this->_header = 0;
|
||||
$this->_footer = false;
|
||||
$this->_alreadyRead = false;
|
||||
return parent::close();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see File_Archive_Reader::getStat()
|
||||
*/
|
||||
function getStat()
|
||||
{
|
||||
return $this->_currentStat;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see File_Archive_Reader::next()
|
||||
*/
|
||||
function next()
|
||||
{
|
||||
$error = parent::next();
|
||||
if ($error !== true) {
|
||||
return $error;
|
||||
}
|
||||
|
||||
$this->source->skip(
|
||||
$this->_nbBytesLeft + ($this->_footer ? 1 : 0)
|
||||
);
|
||||
|
||||
$filename = $this->source->getDataFilename();
|
||||
|
||||
if (!$this->_alreadyRead) {
|
||||
$header = $this->source->getData(8);
|
||||
if ($header != "!<arch>\n") {
|
||||
return PEAR::raiseError("File {$filename} is not a valid Ar file format (starts with $header)");
|
||||
}
|
||||
$this->_alreadyRead = true;
|
||||
}
|
||||
|
||||
|
||||
$name = $this->source->getData(16);
|
||||
$mtime = $this->source->getData(12);
|
||||
$uid = $this->source->getData(6);
|
||||
$gid = $this->source->getData(6);
|
||||
$mode = $this->source->getData(8);
|
||||
$size = $this->source->getData(10);
|
||||
$delim = $this->source->getData(2);
|
||||
|
||||
if ($delim === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// All files inside should have more than 0 bytes of size
|
||||
if ($size < 0) {
|
||||
return PEAR::raiseError("Files must be at least one byte long");
|
||||
}
|
||||
|
||||
$this->_footer = ($size % 2 == 1);
|
||||
|
||||
// if the filename starts with a length, then just read the bytes of it
|
||||
if (preg_match("/\#1\/(\d+)/", $name, $matches)) {
|
||||
$this->_header = 60 + $matches[1];
|
||||
$name = $this->source->getData($matches[1]);
|
||||
$size -= $matches[1];
|
||||
} else {
|
||||
// strip trailing spaces in name, so we can distinguish spaces in a filename with padding
|
||||
$this->_header = 60;
|
||||
$name = preg_replace ("/\s+$/", "", $name);
|
||||
}
|
||||
|
||||
$this->_nbBytesLeft = $size;
|
||||
if (empty($name) || empty($mtime) || empty($uid) ||
|
||||
empty($gid) || empty($mode) || empty($size)) {
|
||||
return PEAR::raiseError("An ar field is empty");
|
||||
}
|
||||
|
||||
$this->_currentFilename = $this->getStandardURL($name);
|
||||
$this->_currentStat = array(
|
||||
2 => $mode,
|
||||
'mode' => $mode,
|
||||
4 => $uid,
|
||||
'uid' => $uid,
|
||||
5 => $gid,
|
||||
'gid' => $gid,
|
||||
7 => $size,
|
||||
'size' => $size,
|
||||
9 => $mtime,
|
||||
'mtime' => $mtime
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see File_Archive_Reader::getData()
|
||||
*/
|
||||
function getData($length = -1)
|
||||
{
|
||||
if ($length == -1) {
|
||||
$length = $this->_nbBytesLeft;
|
||||
} else {
|
||||
$length = min($length, $this->_nbBytesLeft);
|
||||
}
|
||||
if ($length == 0) {
|
||||
return null;
|
||||
} else {
|
||||
$this->_nbBytesLeft -= $length;
|
||||
$data = $this->source->getData($length);
|
||||
if (PEAR::isError($data)) {
|
||||
return $data;
|
||||
}
|
||||
if (strlen($data) != $length) {
|
||||
return PEAR::raiseError('Unexpected end of Ar archive');
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see File_Archive_Reader::skip
|
||||
*/
|
||||
function skip($length = -1)
|
||||
{
|
||||
if ($length == -1) {
|
||||
$length = $this->_nbBytesLeft;
|
||||
} else {
|
||||
$length = min($length, $this->_nbBytesLeft);
|
||||
}
|
||||
if ($length == 0) {
|
||||
return 0;
|
||||
} else {
|
||||
$this->_nbBytesLeft -= $length;
|
||||
$skipped = $this->source->skip($length);
|
||||
if (PEAR::isError($skipped)) {
|
||||
return $skipped;
|
||||
}
|
||||
if ($skipped != $length) {
|
||||
return PEAR::raiseError('Unexpected end of Ar archive');
|
||||
}
|
||||
return $skipped;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see File_Archive_Reader::rewind
|
||||
*/
|
||||
function rewind($length = -1)
|
||||
{
|
||||
if ($length == -1) {
|
||||
$length = $this->_currentStat[7] - $this->_nbBytesLeft;
|
||||
} else {
|
||||
$length = min($length, $this->_currentStat[7] - $this->_nbBytesLeft);
|
||||
}
|
||||
if ($length == 0) {
|
||||
return 0;
|
||||
} else {
|
||||
$rewinded = $this->source->rewind($length);
|
||||
if (!PEAR::isError($rewinded)) {
|
||||
$this->_nbBytesLeft += $rewinded;
|
||||
}
|
||||
return $rewinded;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see File_Archive_Reader::tell()
|
||||
*/
|
||||
function tell()
|
||||
{
|
||||
return $this->_currentStat[7] - $this->_nbBytesLeft;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see File_Archive_Reader::makeWriterRemoveFiles()
|
||||
*/
|
||||
function makeWriterRemoveFiles($pred)
|
||||
{
|
||||
require_once "File/Archive/Writer/Ar.php";
|
||||
|
||||
$blocks = array();
|
||||
$seek = null;
|
||||
$gap = 0;
|
||||
if ($this->_currentFilename !== null && $pred->isTrue($this)) {
|
||||
$seek = $this->_header + $this->_currentStat[7] + ($this->_footer ? 1 : 0);
|
||||
$blocks[] = $seek; //Remove this file
|
||||
}
|
||||
|
||||
while (($error = $this->next()) === true) {
|
||||
$size = $this->_header + $this->_currentStat[7] + ($this->_footer ? 1 : 0);
|
||||
if ($pred->isTrue($this)) {
|
||||
if ($seek === null) {
|
||||
$seek = $size;
|
||||
$blocks[] = $size;
|
||||
} else if ($gap > 0) {
|
||||
$blocks[] = $gap; //Don't remove the files between the gap
|
||||
$blocks[] = $size;
|
||||
$seek += $size;
|
||||
} else {
|
||||
$blocks[count($blocks)-1] += $size; //Also remove this file
|
||||
$seek += $size;
|
||||
}
|
||||
$gap = 0;
|
||||
} else {
|
||||
if ($seek !== null) {
|
||||
$seek += $size;
|
||||
$gap += $size;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($seek === null) {
|
||||
$seek = 0;
|
||||
} else {
|
||||
if ($gap == 0) {
|
||||
array_pop($blocks);
|
||||
} else {
|
||||
$blocks[] = $gap;
|
||||
}
|
||||
}
|
||||
|
||||
$writer = new File_Archive_Writer_Ar(null,
|
||||
$this->source->makeWriterRemoveBlocks($blocks, -$seek)
|
||||
);
|
||||
$this->close();
|
||||
return $writer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see File_Archive_Reader::makeWriterRemoveBlocks()
|
||||
*/
|
||||
function makeWriterRemoveBlocks($blocks, $seek = 0)
|
||||
{
|
||||
if ($this->_currentStat === null) {
|
||||
return PEAR::raiseError('No file selected');
|
||||
}
|
||||
|
||||
$blockPos = $this->_currentStat[7] - $this->_nbBytesLeft + $seek;
|
||||
|
||||
$this->rewind();
|
||||
$keep = false;
|
||||
|
||||
$data = $this->getData($blockPos);
|
||||
foreach ($blocks as $length) {
|
||||
if ($keep) {
|
||||
$data .= $this->getData($length);
|
||||
} else {
|
||||
$this->skip($length);
|
||||
}
|
||||
$keep = !$keep;
|
||||
}
|
||||
if ($keep) {
|
||||
$data .= $this->getData();
|
||||
}
|
||||
|
||||
$filename = $this->_currentFilename;
|
||||
$stat = $this->_currentStat;
|
||||
|
||||
$writer = $this->makeWriterRemove();
|
||||
if (PEAR::isError($writer)) {
|
||||
return $writer;
|
||||
}
|
||||
|
||||
unset($stat[7]);
|
||||
$writer->newFile($filename, $stat);
|
||||
$writer->writeData($data);
|
||||
return $writer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see File_Archive_Reader::makeAppendWriter
|
||||
*/
|
||||
function makeAppendWriter()
|
||||
{
|
||||
require_once "File/Archive/Writer/Ar.php";
|
||||
|
||||
while (($error = $this->next()) === true) { }
|
||||
if (PEAR::isError($error)) {
|
||||
$this->close();
|
||||
return $error;
|
||||
}
|
||||
|
||||
$innerWriter = $this->source->makeWriterRemoveBlocks(array());
|
||||
if (PEAR::isError($innerWriter)) {
|
||||
return $innerWriter;
|
||||
}
|
||||
|
||||
unset($this->source);
|
||||
$this->close();
|
||||
|
||||
return new File_Archive_Writer_Ar(null, $innerWriter);
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -0,0 +1,98 @@
|
|||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* Base class for all the archive readers (that read from a single file)
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* @category File Formats
|
||||
* @package File_Archive
|
||||
* @author Vincent Lascaux <vincentlascaux@php.net>
|
||||
* @copyright 1997-2005 The PHP Group
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
||||
* @version CVS: $Id: Archive.php 2 2010-11-23 14:32:26Z oldperl $
|
||||
* @link http://pear.php.net/package/File_Archive
|
||||
*/
|
||||
|
||||
require_once "File/Archive/Reader.php";
|
||||
|
||||
/**
|
||||
* Base class for all the archive readers (that read from a single file)
|
||||
*/
|
||||
class File_Archive_Reader_Archive extends File_Archive_Reader
|
||||
{
|
||||
/**
|
||||
* @var File_Archive_Reader Single file source that contains the archive
|
||||
* to uncompress
|
||||
* @access protected
|
||||
*/
|
||||
var $source = null;
|
||||
|
||||
/**
|
||||
* @var bool Indicate whether the $source is currently opened
|
||||
* @access private
|
||||
*/
|
||||
var $sourceOpened = false;
|
||||
|
||||
/**
|
||||
* The source was let in this state at the end
|
||||
*
|
||||
* @var bool Indicate whether the $source was given opened
|
||||
* @access private
|
||||
*/
|
||||
var $sourceInitiallyOpened;
|
||||
|
||||
//ABSTRACT
|
||||
/**
|
||||
* @see File_Archive_Reader::next()
|
||||
*
|
||||
* Open the source if necessary
|
||||
*/
|
||||
function next()
|
||||
{
|
||||
if (!$this->sourceOpened && ($error = $this->source->next()) !== true) {
|
||||
return $error;
|
||||
}
|
||||
|
||||
$this->sourceOpened = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
//PUBLIC
|
||||
function File_Archive_Reader_Archive(&$source, $sourceOpened = false)
|
||||
{
|
||||
$this->source =& $source;
|
||||
$this->sourceOpened = $this->sourceInitiallyOpened = $sourceOpened;
|
||||
}
|
||||
/**
|
||||
* Close the source if it was given closed in the constructor
|
||||
*
|
||||
* @see File_Archive_Reader::close()
|
||||
*/
|
||||
function close()
|
||||
{
|
||||
if (!$this->sourceInitiallyOpened && $this->sourceOpened) {
|
||||
$this->sourceOpened = false;
|
||||
if ($this->source !== null) {
|
||||
return $this->source->close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -0,0 +1,254 @@
|
|||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* Uncompress a file that was compressed in the Bzip2 format
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* @category File Formats
|
||||
* @package File_Archive
|
||||
* @author Vincent Lascaux <vincentlascaux@php.net>
|
||||
* @copyright 1997-2005 The PHP Group
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
||||
* @version CVS: $Id: Bzip2.php 2 2010-11-23 14:32:26Z oldperl $
|
||||
* @link http://pear.php.net/package/File_Archive
|
||||
*/
|
||||
|
||||
require_once "File/Archive/Reader/Archive.php";
|
||||
require_once "File/Archive/Writer/Files.php";
|
||||
|
||||
/**
|
||||
* Uncompress a file that was compressed in the Bzip2 format
|
||||
*/
|
||||
class File_Archive_Reader_Bzip2 extends File_Archive_Reader_Archive
|
||||
{
|
||||
var $nbRead = 0;
|
||||
var $bzfile = null;
|
||||
var $tmpName = null;
|
||||
var $filePos = 0;
|
||||
|
||||
/**
|
||||
* @see File_Archive_Reader::close()
|
||||
*/
|
||||
function close($innerClose = true)
|
||||
{
|
||||
if ($this->bzfile !== null)
|
||||
bzclose($this->bzfile);
|
||||
if ($this->tmpName !== null)
|
||||
unlink($this->tmpName);
|
||||
|
||||
$this->bzfile = null;
|
||||
$this->tmpName = null;
|
||||
$this->nbRead = 0;
|
||||
$this->filePos = 0;
|
||||
return parent::close($innerClose);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see File_Archive_Reader::next()
|
||||
*/
|
||||
function next()
|
||||
{
|
||||
if (!parent::next()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->nbRead++;
|
||||
if ($this->nbRead > 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$dataFilename = $this->source->getDataFilename();
|
||||
if ($dataFilename !== null)
|
||||
{
|
||||
$this->tmpName = null;
|
||||
$this->bzfile = @bzopen($dataFilename, 'r');
|
||||
if ($this->bzfile === false) {
|
||||
return PEAR::raiseError("bzopen failed to open $dataFilename");
|
||||
}
|
||||
} else {
|
||||
$this->tmpName = tempnam(File_Archive::getOption('tmpDirectory'), 'far');
|
||||
|
||||
//Generate the tmp data
|
||||
$dest = new File_Archive_Writer_Files();
|
||||
$dest->newFile($this->tmpName);
|
||||
$this->source->sendData($dest);
|
||||
$dest->close();
|
||||
|
||||
$this->bzfile = bzopen($this->tmpName, 'r');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* Return the name of the single file contained in the archive
|
||||
* deduced from the name of the archive (the extension is removed)
|
||||
*
|
||||
* @see File_Archive_Reader::getFilename()
|
||||
*/
|
||||
function getFilename()
|
||||
{
|
||||
$name = $this->source->getFilename();
|
||||
$pos = strrpos($name, ".");
|
||||
if ($pos === false || $pos === 0) {
|
||||
return $name;
|
||||
} else {
|
||||
return substr($name, 0, $pos);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @see File_Archive_Reader::getData()
|
||||
*/
|
||||
function getData($length = -1)
|
||||
{
|
||||
if ($length == -1) {
|
||||
$data = '';
|
||||
do {
|
||||
$newData = bzread($this->bzfile);
|
||||
$data .= $newData;
|
||||
} while ($newData != '');
|
||||
$this->filePos += strlen($data);
|
||||
} else if ($length == 0) {
|
||||
return '';
|
||||
} else {
|
||||
$data = '';
|
||||
|
||||
//The loop is here to correct what appears to be a bzread bug
|
||||
while (strlen($data) < $length) {
|
||||
$newData = bzread($this->bzfile, $length - strlen($data));
|
||||
if ($newData == '') {
|
||||
break;
|
||||
}
|
||||
$data .= $newData;
|
||||
}
|
||||
$this->filePos += strlen($data);
|
||||
}
|
||||
|
||||
return $data == '' ? null : $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see File_Archive_Reader::rewind
|
||||
*/
|
||||
function rewind($length = -1)
|
||||
{
|
||||
$before = $this->filePos;
|
||||
|
||||
bzclose($this->bzfile);
|
||||
if ($this->tmpName === null) {
|
||||
$this->bzfile = bzopen($this->source->getDataFilename(), 'r');
|
||||
} else {
|
||||
$this->bzfile = bzopen($this->tmpName, 'r');
|
||||
}
|
||||
$this->filePos = 0;
|
||||
|
||||
if ($length != -1) {
|
||||
$this->skip($before - $length);
|
||||
}
|
||||
return $before - $this->filePos;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see File_Archive_Reader::tell()
|
||||
*/
|
||||
function tell()
|
||||
{
|
||||
return $this->filePos;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see File_Archive_Reader::makeAppendWriter()
|
||||
*/
|
||||
function makeAppendWriter()
|
||||
{
|
||||
return PEAR::raiseError('Unable to append files to a bzip2 archive');
|
||||
}
|
||||
|
||||
/**
|
||||
* @see File_Archive_Reader::makeWriterRemoveFiles()
|
||||
*/
|
||||
function makeWriterRemoveFiles($pred)
|
||||
{
|
||||
return PEAR::raiseError('Unable to remove files from a bzip2 archive');
|
||||
}
|
||||
|
||||
/**
|
||||
* @see File_Archive_Reader::makeWriterRemoveBlocks()
|
||||
*/
|
||||
function makeWriterRemoveBlocks($blocks, $seek = 0)
|
||||
{
|
||||
require_once "File/Archive/Writer/Bzip2.php";
|
||||
|
||||
if ($this->nbRead == 0) {
|
||||
return PEAR::raiseError('No file selected');
|
||||
}
|
||||
|
||||
//Uncompress data to a temporary file
|
||||
$tmp = tmpfile();
|
||||
$expectedPos = $this->filePos + $seek;
|
||||
|
||||
$this->rewind();
|
||||
|
||||
//Read the begining of the file
|
||||
while ($this->filePos < $expectedPos &&
|
||||
($data = $this->getData(min($expectedPos - $this->filePos, 8192))) !== null) {
|
||||
fwrite($tmp, $data);
|
||||
}
|
||||
|
||||
$keep = false;
|
||||
foreach ($blocks as $length) {
|
||||
if ($keep) {
|
||||
$expectedPos = $this->filePos + $length;
|
||||
while ($this->filePos < $expectedPos &&
|
||||
($data = $this->getData(min($expectedPos - $this->filePos, 8192))) !== null) {
|
||||
fwrite($tmp, $data);
|
||||
}
|
||||
} else {
|
||||
$this->skip($length);
|
||||
}
|
||||
$keep = !$keep;
|
||||
}
|
||||
if ($keep) {
|
||||
//Read the end of the file
|
||||
while(($data = $this->getData(8192)) !== null) {
|
||||
fwrite($tmp, $data);
|
||||
}
|
||||
}
|
||||
fseek($tmp, 0);
|
||||
|
||||
//Create the writer
|
||||
$this->source->rewind();
|
||||
$innerWriter = $this->source->makeWriterRemoveBlocks(array()); //Truncate the source
|
||||
unset($this->source);
|
||||
$writer = new File_Archive_Writer_Bzip2(null, $innerWriter);
|
||||
|
||||
//And compress data from the temporary file
|
||||
while (!feof($tmp)) {
|
||||
$data = fread($tmp, 8192);
|
||||
$writer->writeData($data);
|
||||
}
|
||||
fclose($tmp);
|
||||
|
||||
//Do not close inner writer since makeWriter was called
|
||||
$this->close();
|
||||
|
||||
return $writer;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -0,0 +1,262 @@
|
|||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* This reader caches the files of another reader
|
||||
* It allow fast access to files. This is usefull if the access to the reader
|
||||
* is slow (HTTP, FTP...), but will need more IO if the file is only extracted
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* @category File Formats
|
||||
* @package File_Archive
|
||||
* @author Vincent Lascaux <vincentlascaux@php.net>
|
||||
* @copyright 1997-2005 The PHP Group
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
||||
* @version CVS: $Id: Cache.php 2 2010-11-23 14:32:26Z oldperl $
|
||||
* @link http://pear.php.net/package/File_Archive
|
||||
*/
|
||||
|
||||
require_once "File/Archive/Reader.php";
|
||||
|
||||
/**
|
||||
* This reader caches the files of another reader
|
||||
* It allow fast access to files. This is usefull if the access to the reader
|
||||
* is slow (HTTP, FTP...), but will need more IO if the file is only extracted
|
||||
*/
|
||||
class File_Archive_Reader_Cache extends File_Archive_Reader
|
||||
{
|
||||
var $tmpFile;
|
||||
var $files = array();
|
||||
var $pos = 0;
|
||||
var $fromSource = true;
|
||||
var $endOfSource = false;
|
||||
var $source;
|
||||
|
||||
/**
|
||||
* $source is the reader to filter
|
||||
*/
|
||||
function File_Archive_Reader_Cache(&$source)
|
||||
{
|
||||
$this->source =& $source;
|
||||
$this->tmpFile = tmpfile();
|
||||
}
|
||||
|
||||
function _writeEndOfFile()
|
||||
{
|
||||
$bufferSize = File_Archive::getOption('blockSize');
|
||||
while (($data = $this->source->getData($bufferSize))!=null) {
|
||||
fwrite($this->tmpFile, $data);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @see File_Archive_Reader::next()
|
||||
*/
|
||||
function next()
|
||||
{
|
||||
//Write the end of the current file to the temp file
|
||||
if ($this->fromSource && !empty($this->files)) {
|
||||
$this->_writeEndOfFile();
|
||||
}
|
||||
|
||||
if ($this->pos+1 < count($this->files) && !$this->fromSource) {
|
||||
$this->pos++;
|
||||
fseek($this->tmpFile, $this->files[$this->pos]['pos'], SEEK_SET);
|
||||
return true;
|
||||
} else {
|
||||
$this->fromSource = true;
|
||||
if ($this->endOfSource) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$ret = $this->source->next();
|
||||
if ($ret !== true) {
|
||||
$this->endOfSource = true;
|
||||
$this->source->close();
|
||||
return $ret;
|
||||
}
|
||||
|
||||
$this->endOfSource = false;
|
||||
fseek($this->tmpFile, 0, SEEK_END);
|
||||
$this->files[] = array(
|
||||
'name' => $this->source->getFilename(),
|
||||
'stat' => $this->source->getStat(),
|
||||
'mime' => $this->source->getMime(),
|
||||
'pos' => ftell($this->tmpFile)
|
||||
);
|
||||
$this->pos = count($this->files)-1;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see File_Archive_Reader::getFilename()
|
||||
*/
|
||||
function getFilename() { return $this->files[$this->pos]['name']; }
|
||||
/**
|
||||
* @see File_Archive_Reader::getStat()
|
||||
*/
|
||||
function getStat() { return $this->files[$this->pos]['stat']; }
|
||||
/**
|
||||
* @see File_Archive_Reader::getMime()
|
||||
*/
|
||||
function getMime() { return $this->files[$this->pos]['mime']; }
|
||||
/**
|
||||
* @see File_Archive_Reader::getDataFilename()
|
||||
*/
|
||||
function getDataFilename() { return null; }
|
||||
/**
|
||||
* @see File_Archive_Reader::getData()
|
||||
*/
|
||||
function getData($length = -1)
|
||||
{
|
||||
if ($this->fromSource) {
|
||||
$data = $this->source->getData($length);
|
||||
if (PEAR::isError($data)) {
|
||||
return $data;
|
||||
}
|
||||
|
||||
fwrite($this->tmpFile, $data);
|
||||
return $data;
|
||||
} else {
|
||||
if ($length == 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if ($length > 0 && $this->pos+1 < count($this->files)) {
|
||||
$maxSize = $this->files[$this->pos+1]['pos'] - ftell($this->tmpFile);
|
||||
if ($maxSize == 0) {
|
||||
return null;
|
||||
}
|
||||
if ($length > $maxSize) {
|
||||
$length = $maxSize;
|
||||
}
|
||||
return fread($this->tmpFile, $length);
|
||||
} else {
|
||||
$contents = '';
|
||||
$blockSize = File_Archive::getOption('blockSize');
|
||||
while (!feof($this->tmpFile)) {
|
||||
$contents .= fread($this->tmpFile, $blockSize);
|
||||
}
|
||||
return $contents == '' ? null : $contents;
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @see File_Archive_Reader::skip()
|
||||
*/
|
||||
function skip($length = -1)
|
||||
{
|
||||
if ($this->fromSource) {
|
||||
return strlen($this->getData($length));
|
||||
} else {
|
||||
if ($length >= 0 && $this->pos+1 < count($this->files)) {
|
||||
$maxSize = $this->files[$this->pos+1]['pos'] - ftell($this->tmpFile);
|
||||
if ($maxSize == 0) {
|
||||
return null;
|
||||
}
|
||||
if ($length > $maxSize) {
|
||||
$length = $maxSize;
|
||||
}
|
||||
fseek($this->tmpFile, $length, SEEK_CUR);
|
||||
return $length;
|
||||
} else {
|
||||
$before = ftell($this->tmpFile);
|
||||
fseek($this->tmpFile, 0, SEEK_SET);
|
||||
$after = fteel($this->tmpFile);
|
||||
return $after - $before;
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @see File_Archive_Reader::rewind()
|
||||
*/
|
||||
function rewind($length = -1)
|
||||
{
|
||||
if ($this->fromSource) {
|
||||
$this->_writeEndOfFile();
|
||||
$this->fromSource = false;
|
||||
}
|
||||
$before = ftell($this->tmpFile);
|
||||
$pos = $this->files[$this->pos]['pos'];
|
||||
fseek($this->tmpFile, $pos, SEEK_SET);
|
||||
return $pos - $before;
|
||||
}
|
||||
/**
|
||||
* @see File_Archive_Reader::tell()
|
||||
*/
|
||||
function tell()
|
||||
{
|
||||
return ftell($this->tmpFile) - $this->files[$this->pos]['pos'];
|
||||
}
|
||||
/**
|
||||
* @see File_Archive_Reader::close()
|
||||
*/
|
||||
function close()
|
||||
{
|
||||
$this->fromSource = false;
|
||||
$this->pos = 0;
|
||||
fseek($this->tmpFile, 0, SEEK_SET);
|
||||
}
|
||||
function _closeAndReset()
|
||||
{
|
||||
$this->close();
|
||||
|
||||
fclose($this->tmpFile);
|
||||
$this->tmpFile = tmpfile();
|
||||
$this->endOfSource = false;
|
||||
$this->files = array();
|
||||
$this->source->close();
|
||||
}
|
||||
/**
|
||||
* @see File_Archive_Reader::makeAppendWriter()
|
||||
*/
|
||||
function makeAppendWriter()
|
||||
{
|
||||
$writer = $this->source->makeAppendWriter();
|
||||
if (!PEAR::isError($writer)) {
|
||||
$this->_closeAndReset();
|
||||
}
|
||||
|
||||
return $writer;
|
||||
}
|
||||
/**
|
||||
* @see File_Archive_Reader::makeWriterRemoveFiles()
|
||||
*/
|
||||
function makeWriterRemoveFiles($pred)
|
||||
{
|
||||
$writer = $this->source->makeWriterRemoveFiles($pred);
|
||||
if (!PEAR::isError($writer)) {
|
||||
$this->_closeAndReset();
|
||||
}
|
||||
return $writer;
|
||||
}
|
||||
/**
|
||||
* @see File_Archive_Reader::makeWriterRemoveBlocks()
|
||||
*/
|
||||
function makeWriterRemoveBlocks($blocks, $seek = 0)
|
||||
{
|
||||
$writer = $this->source->makeWriterRemoveBlocks($blocks, $seek);
|
||||
if (!PEAR::isError($writer)) {
|
||||
$this->_closeAndReset();
|
||||
}
|
||||
return $writer;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -0,0 +1,136 @@
|
|||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* Add a directory to the public name of all the files of a reader
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* @category File Formats
|
||||
* @package File_Archive
|
||||
* @author Vincent Lascaux <vincentlascaux@php.net>
|
||||
* @copyright 1997-2005 The PHP Group
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
||||
* @version CVS: $Id: ChangeName.php 2 2010-11-23 14:32:26Z oldperl $
|
||||
* @link http://pear.php.net/package/File_Archive
|
||||
*/
|
||||
|
||||
require_once "File/Archive/Reader/Relay.php";
|
||||
|
||||
/**
|
||||
* Base class for readers that need to modify the name of files
|
||||
*/
|
||||
class File_Archive_Reader_ChangeName extends File_Archive_Reader_Relay
|
||||
{
|
||||
/**
|
||||
* Modify the name
|
||||
*
|
||||
* @param string $name Name as in the inner reader
|
||||
* @return string New name as shown by this reader or false is the
|
||||
* file or directory has to be skipped
|
||||
*/
|
||||
function modifyName($name)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Modify the name back to the inner reader naming style
|
||||
* If implemented, unmodifyName(modifyName($name)) should be true
|
||||
*
|
||||
* unmodifyName can be left unimplemented, this may only impact the
|
||||
* efficiency of the select function (a full look up will be done when
|
||||
* something more efficient with an index for example could be used on
|
||||
* the inner reader of the original name is known).
|
||||
*
|
||||
* unmodifyName may be provided some names that where not in the inner reader
|
||||
* and that cannot possibly be the result of modifyName. In this case
|
||||
* unmodifyName must return false.
|
||||
*
|
||||
* @param string $name Name as shown by this reader
|
||||
* @return string Name as in the inner reader, or false if there is no
|
||||
* input such that modifyName would return $name or a file in
|
||||
* a directory called $name
|
||||
*/
|
||||
function unmodifyName($name)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see File_Archive_Reader::getFilename()
|
||||
*/
|
||||
function getFilename()
|
||||
{
|
||||
return $this->getStandardURL($this->modifyName(parent::getFilename()));
|
||||
}
|
||||
/**
|
||||
* @see File_Archive_Reader::getFileList()
|
||||
*/
|
||||
function getFileList()
|
||||
{
|
||||
$list = parent::getFileList();
|
||||
$result = array();
|
||||
foreach ($list as $name) {
|
||||
$result[] = $this->modifyName($name);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
/**
|
||||
* @see File_Archive_Reader::select()
|
||||
*/
|
||||
function select($filename, $close = true)
|
||||
{
|
||||
$name = $this->unmodifyName($filename);
|
||||
if ($name === false) {
|
||||
return false;
|
||||
} else if($name === null) {
|
||||
$std = $this->getStandardURL($filename);
|
||||
if (substr($std, -1)=='/') {
|
||||
$std = substr($std, 0, -1);
|
||||
}
|
||||
|
||||
if ($close) {
|
||||
$error = $this->close();
|
||||
if (PEAR::isError($error)) {
|
||||
return $error;
|
||||
}
|
||||
}
|
||||
while (($error = $this->next()) === true) {
|
||||
$sourceName = $this->getFilename();
|
||||
$sourceName = $this->modifyName($sourceName, $this->isDirectory());
|
||||
$sourceName = $this->getStandardURL($sourceName);
|
||||
if (
|
||||
empty($std) ||
|
||||
|
||||
//$std is a file
|
||||
$std == $sourceName ||
|
||||
|
||||
//$std is a directory
|
||||
(strncmp($std.'/', $sourceName, strlen($std)+1) == 0 &&
|
||||
strlen($sourceName) > strlen($std)+1)
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return $error;
|
||||
} else {
|
||||
return $this->source->select($name, $close);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -0,0 +1,89 @@
|
|||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* Add a directory to the public name of all the files of a reader
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* @category File Formats
|
||||
* @package File_Archive
|
||||
* @author Vincent Lascaux <vincentlascaux@php.net>
|
||||
* @copyright 1997-2005 The PHP Group
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
||||
* @version CVS: $Id: AddDirectory.php 2 2010-11-23 14:32:26Z oldperl $
|
||||
* @link http://pear.php.net/package/File_Archive
|
||||
*/
|
||||
|
||||
require_once "File/Archive/Reader/ChangeName.php";
|
||||
|
||||
/**
|
||||
* Add a directory to the public name of all the files of a reader
|
||||
*
|
||||
* Example:
|
||||
* If archive.tar is a file archive containing files a.txt and foo/b.txt
|
||||
* new File_Archive_Reader_ChangeName_AddDirectory('bar',
|
||||
* new File_Archive_Reader_Tar(
|
||||
* new File_Archive_Reader_File('archive.tar')
|
||||
* )
|
||||
* ) is a reader containing files bar/a.txt and bar/foo/b.txt
|
||||
*/
|
||||
class File_Archive_Reader_ChangeName_AddDirectory extends File_Archive_Reader_ChangeName
|
||||
{
|
||||
var $baseName;
|
||||
function File_Archive_Reader_ChangeName_AddDirectory($baseName, &$source)
|
||||
{
|
||||
// see http://pear.php.net/bugs/bug.php?id=17046&edit=12&patch=AddDirectory.php.patch&revision=1264868437
|
||||
// parent::File_Archive_Reader_ChangeName($source);
|
||||
parent::__construct($source);
|
||||
$this->baseName = $this->getStandardURL($baseName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Modify the name by adding baseName to it
|
||||
*/
|
||||
function modifyName($name)
|
||||
{
|
||||
return $this->baseName.
|
||||
(empty($this->baseName) || empty($name) ? '': '/').
|
||||
$name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove baseName from the name
|
||||
* Return false if the name doesn't start with baseName
|
||||
*/
|
||||
function unmodifyName($name)
|
||||
{
|
||||
if (strncmp($name, $this->baseName.'/', strlen($this->baseName)+1) == 0) {
|
||||
$res = substr($name, strlen($this->baseName)+1);
|
||||
if ($res === false) {
|
||||
return '';
|
||||
} else {
|
||||
return $res;
|
||||
}
|
||||
} else if (empty($this->baseName)) {
|
||||
return $name;
|
||||
} else if ($name == $this->baseName) {
|
||||
return '';
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -0,0 +1,52 @@
|
|||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* Add a directory to the public name of all the files of a reader
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* @category File Formats
|
||||
* @package File_Archive
|
||||
* @author Vincent Lascaux <vincentlascaux@php.net>
|
||||
* @copyright 1997-2005 The PHP Group
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
||||
* @version CVS: $Id: Callback.php 2 2010-11-23 14:32:26Z oldperl $
|
||||
* @link http://pear.php.net/package/File_Archive
|
||||
*/
|
||||
|
||||
require_once "File/Archive/Reader/ChangeName.php";
|
||||
|
||||
/**
|
||||
* Discard the directory structure in a reader
|
||||
*/
|
||||
class File_Archive_Reader_ChangeName_Callback extends File_Archive_Reader_ChangeName
|
||||
{
|
||||
var $function;
|
||||
function File_Archive_Reader_ChangeName_Callback($function, &$source)
|
||||
{
|
||||
parent::File_Archive_Reader_ChangeName($source);
|
||||
$this->function = $function;
|
||||
}
|
||||
|
||||
function modifyName($name)
|
||||
{
|
||||
return call_user_func($function, $name);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -0,0 +1,100 @@
|
|||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* Add a directory to the public name of all the files of a reader
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* @category File Formats
|
||||
* @package File_Archive
|
||||
* @author Vincent Lascaux <vincentlascaux@php.net>
|
||||
* @copyright 1997-2005 The PHP Group
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
||||
* @version CVS: $Id: Directory.php 2 2010-11-23 14:32:26Z oldperl $
|
||||
* @link http://pear.php.net/package/File_Archive
|
||||
*/
|
||||
|
||||
require_once "File/Archive/Reader/ChangeName.php";
|
||||
|
||||
/**
|
||||
* Change a directory name to another
|
||||
*
|
||||
* Example:
|
||||
* If archive.tar is a file archive containing files a.txt and foo/b.txt
|
||||
* new File_Archive_Reader_ChangeName_Directory('foo', 'bar'
|
||||
* new File_Archive_Reader_Tar(
|
||||
* new File_Archive_Reader_File('archive.tar')
|
||||
* )
|
||||
* ) is a reader containing files a.txt and bar/b.txt
|
||||
*/
|
||||
class File_Archive_Reader_ChangeName_Directory extends File_Archive_Reader_ChangeName
|
||||
{
|
||||
var $oldBaseName;
|
||||
var $newBaseName;
|
||||
|
||||
function File_Archive_Reader_ChangeName_Directory
|
||||
($oldBaseName, $newBaseName, &$source)
|
||||
{
|
||||
// parent::File_Archive_Reader_ChangeName($source);
|
||||
parent::__construct($source);
|
||||
$this->oldBaseName = $this->getStandardURL($oldBaseName);
|
||||
if (substr($this->oldBaseName, -1) == '/') {
|
||||
$this->oldBaseName = substr($this->oldBaseName, 0, -1);
|
||||
}
|
||||
|
||||
$this->newBaseName = $this->getStandardURL($newBaseName);
|
||||
if (substr($this->newBaseName, -1) == '/') {
|
||||
$this->newBaseName = substr($this->newBaseName, 0, -1);
|
||||
}
|
||||
}
|
||||
|
||||
function modifyName($name)
|
||||
{
|
||||
if (empty($this->oldBaseName) ||
|
||||
!strncmp($name, $this->oldBaseName.'/', strlen($this->oldBaseName)+1) ||
|
||||
strcmp($name, $this->oldBaseName) == 0) {
|
||||
return $this->newBaseName.
|
||||
(
|
||||
empty($this->newBaseName) ||
|
||||
strlen($name)<=strlen($this->oldBaseName)+1 ?
|
||||
'' : '/'
|
||||
).
|
||||
substr($name, strlen($this->oldBaseName)+1);
|
||||
} else {
|
||||
return $name;
|
||||
}
|
||||
}
|
||||
function unmodifyName($name)
|
||||
{
|
||||
if (empty($this->newBaseName) ||
|
||||
!strncmp($name, $this->newBaseName.'/', strlen($this->newBaseName)+1) ||
|
||||
strcmp($name, $this->newBaseName) == 0) {
|
||||
return $this->oldBaseName.
|
||||
(
|
||||
empty($this->oldBaseName) ||
|
||||
strlen($name)<=strlen($this->newBaseName)+1 ?
|
||||
'' : '/'
|
||||
).
|
||||
substr($name, strlen($this->newBaseName)+1);
|
||||
} else {
|
||||
return $name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -0,0 +1,195 @@
|
|||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* A reader that concatene the data of the files of a source
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* @category File Formats
|
||||
* @package File_Archive
|
||||
* @author Vincent Lascaux <vincentlascaux@php.net>
|
||||
* @copyright 1997-2005 The PHP Group
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
||||
* @version CVS: $Id: Concat.php 2 2010-11-23 14:32:26Z oldperl $
|
||||
* @link http://pear.php.net/package/File_Archive
|
||||
*/
|
||||
|
||||
require_once "File/Archive/Reader/Relay.php";
|
||||
|
||||
/**
|
||||
* This reader provides one single file that is the concatenation of the data of
|
||||
* all the files of another reader
|
||||
*/
|
||||
class File_Archive_Reader_Concat extends File_Archive_Reader
|
||||
{
|
||||
var $source;
|
||||
var $filename;
|
||||
var $stat;
|
||||
var $mime;
|
||||
var $opened = false;
|
||||
var $filePos = 0;
|
||||
|
||||
function File_Archive_Reader_Concat(&$source, $filename,
|
||||
$stat=array(), $mime=null)
|
||||
{
|
||||
$this->source =& $source;
|
||||
$this->filename = $filename;
|
||||
$this->stat = $stat;
|
||||
$this->mime = $mime;
|
||||
|
||||
//Compute the total length
|
||||
$this->stat[7] = 0;
|
||||
while (($error = $source->next()) === true) {
|
||||
$sourceStat = $source->getStat();
|
||||
if (isset($sourceStat[7])) {
|
||||
$this->stat[7] += $sourceStat[7];
|
||||
} else {
|
||||
unset($this->stat[7]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (isset($this->stat[7])) {
|
||||
$this->stat['size'] = $this->stat[7];
|
||||
}
|
||||
if (PEAR::isError($error) || PEAR::isError($source->close())) {
|
||||
die("Error in File_Archive_Reader_Concat constructor ".
|
||||
'('.$error->getMessage().'), cannot continue');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see File_Archive_Reader::next()
|
||||
*/
|
||||
function next()
|
||||
{
|
||||
if (!$this->opened) {
|
||||
return $this->opened = $this->source->next();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @see File_Archive_Reader::getFilename()
|
||||
*/
|
||||
function getFilename() { return $this->filename; }
|
||||
/**
|
||||
* @see File_Archive_Reader::getStat()
|
||||
*/
|
||||
function getStat() { return $this->stat; }
|
||||
/**
|
||||
* @see File_Archive_Reader::getMime()
|
||||
*/
|
||||
function getMime()
|
||||
{
|
||||
return $this->mime==null ? parent::getMime() : $this->mime;
|
||||
}
|
||||
/**
|
||||
* @see File_Archive_Reader::getData()
|
||||
*/
|
||||
function getData($length = -1)
|
||||
{
|
||||
if ($length == 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$result = '';
|
||||
while ($length == -1 || strlen($result)<$length) {
|
||||
$sourceData = $this->source->getData(
|
||||
$length==-1 ? -1 : $length - strlen($result)
|
||||
);
|
||||
if (PEAR::isError($sourceData)) {
|
||||
return $sourceData;
|
||||
}
|
||||
|
||||
if ($sourceData === null) {
|
||||
$error = $this->source->next();
|
||||
if (PEAR::isError($error)) {
|
||||
return $error;
|
||||
}
|
||||
if (!$error) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
$result .= $sourceData;
|
||||
}
|
||||
}
|
||||
$this->filePos += strlen($result);
|
||||
return $result == '' ? null : $result;
|
||||
}
|
||||
/**
|
||||
* @see File_Archive_Reader::skip()
|
||||
*/
|
||||
function skip($length = -1)
|
||||
{
|
||||
$skipped = 0;
|
||||
while ($skipped < $length) {
|
||||
$sourceSkipped = $this->source->skip($length);
|
||||
if (PEAR::isError($sourceSkipped)) {
|
||||
return $skipped;
|
||||
}
|
||||
$skipped += $sourceSkipped;
|
||||
$filePos += $sourceSkipped;
|
||||
if ($sourceSkipped < $length) {
|
||||
$error = $this->source->next();
|
||||
if (PEAR::isError($error)) {
|
||||
return $error;
|
||||
}
|
||||
if (!$error) {
|
||||
return $skipped;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $skipped;
|
||||
}
|
||||
/**
|
||||
* @see File_Archive_Reader::rewind()
|
||||
*/
|
||||
function rewind($length = -1)
|
||||
{
|
||||
//TODO: implement rewind
|
||||
return parent::rewind($length);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see File_Archive_Reader::tell()
|
||||
*/
|
||||
function tell()
|
||||
{
|
||||
return $this->filePos;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see File_Archive_Reader::close()
|
||||
*/
|
||||
function close()
|
||||
{
|
||||
$this->opened = false;
|
||||
$this->filePos = 0;
|
||||
return $this->source->close();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see File_Archive_Reader::makeWriter
|
||||
*/
|
||||
function makeWriter($fileModif = true, $seek = 0)
|
||||
{
|
||||
return $this->source->makeWriter($fileModif, $seek);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -0,0 +1,309 @@
|
|||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* Recursively reads a directory
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* @category File Formats
|
||||
* @package File_Archive
|
||||
* @author Vincent Lascaux <vincentlascaux@php.net>
|
||||
* @copyright 1997-2005 The PHP Group
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
||||
* @version CVS: $Id: Directory.php 2 2010-11-23 14:32:26Z oldperl $
|
||||
* @link http://pear.php.net/package/File_Archive
|
||||
*/
|
||||
|
||||
require_once "File/Archive/Reader/Relay.php";
|
||||
require_once "File/Archive/Reader/File.php";
|
||||
|
||||
/**
|
||||
* Recursively reads a directory
|
||||
*/
|
||||
class File_Archive_Reader_Directory extends File_Archive_Reader_Relay
|
||||
{
|
||||
/**
|
||||
* @var String URL of the directory that must be read
|
||||
* @access private
|
||||
*/
|
||||
var $directory;
|
||||
/**
|
||||
* @var Int The subdirectories will be read up to a depth of maxRecurs
|
||||
* If maxRecurs == 0, the subdirectories will not be read
|
||||
* If maxRecurs == -1, the depth is considered infinite
|
||||
* @access private
|
||||
*/
|
||||
var $maxRecurs;
|
||||
/**
|
||||
* @var Object Handle returned by the openedDirectory function
|
||||
* @access private
|
||||
*/
|
||||
var $directoryHandle = null;
|
||||
|
||||
/**
|
||||
* $directory is the path of the directory that must be read
|
||||
* If $maxRecurs is specified, the subdirectories will be read up to a depth
|
||||
* of $maxRecurs. In particular, if $maxRecurs == 0, the subdirectories
|
||||
* won't be read.
|
||||
*/
|
||||
function File_Archive_Reader_Directory($directory, $symbolic='',
|
||||
$maxRecurs=-1)
|
||||
{
|
||||
parent::File_Archive_Reader_Relay($tmp = null);
|
||||
$this->directory = empty($directory) ? '.' : $directory;
|
||||
$this->symbolic = $this->getStandardURL($symbolic);
|
||||
$this->maxRecurs = $maxRecurs;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see File_Archive_Reader::close()
|
||||
*/
|
||||
function close()
|
||||
{
|
||||
$error = parent::close();
|
||||
|
||||
if ($this->directoryHandle !== null) {
|
||||
closedir($this->directoryHandle);
|
||||
$this->directoryHandle = null;
|
||||
}
|
||||
|
||||
return $error;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see File_Archive_Reader::next()
|
||||
*
|
||||
* The files are returned in the same order as readdir
|
||||
*/
|
||||
function next()
|
||||
{
|
||||
if ($this->directoryHandle === null) {
|
||||
$this->directoryHandle = opendir($this->directory);
|
||||
if (!is_resource($this->directoryHandle)) {
|
||||
return PEAR::raiseError(
|
||||
"Directory {$this->directory} not found"
|
||||
);
|
||||
}
|
||||
$this->source = null;
|
||||
|
||||
if (!empty($this->symbolic))
|
||||
return true;
|
||||
}
|
||||
|
||||
while ($this->source === null ||
|
||||
($error = $this->source->next()) !== true) {
|
||||
|
||||
if ($this->source !== null) {
|
||||
$this->source->close();
|
||||
}
|
||||
|
||||
$file = readdir($this->directoryHandle);
|
||||
if ($file == '.' || $file == '..') {
|
||||
continue;
|
||||
}
|
||||
if ($file === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$current = $this->directory.'/'.$file;
|
||||
if (is_dir($current)) {
|
||||
if ($this->maxRecurs != 0) {
|
||||
$this->source = new File_Archive_Reader_Directory(
|
||||
$current, $file.'/', $this->maxRecurs-1
|
||||
);
|
||||
}
|
||||
|
||||
} else {
|
||||
$this->source = new File_Archive_Reader_File($current, $file);
|
||||
}
|
||||
}
|
||||
|
||||
return $error;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see File_Archive_Reader::getFilename()
|
||||
*/
|
||||
function getFilename()
|
||||
{
|
||||
if ($this->source === null) {
|
||||
return $this->symbolic;
|
||||
} else {
|
||||
return $this->symbolic . parent::getFilename();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @see File_Archive_Reader::getStat()
|
||||
*/
|
||||
function getStat()
|
||||
{
|
||||
if ($this->source === null) {
|
||||
return stat($this->directory);
|
||||
} else {
|
||||
return parent::getStat();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @see File_Archive_Reader::getMime()
|
||||
*/
|
||||
function getMime()
|
||||
{
|
||||
if ($this->source === null) {
|
||||
return '';
|
||||
} else {
|
||||
return parent::getMime();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @see File_Archive_Reader::getDataFilename()
|
||||
*/
|
||||
function getDataFilename()
|
||||
{
|
||||
if ($this->source === null) {
|
||||
return null;
|
||||
} else {
|
||||
return parent::getDataFilename();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @see File_Archive_Reader::getData()
|
||||
*/
|
||||
function getData($length = -1)
|
||||
{
|
||||
if ($this->source === null) {
|
||||
return null;
|
||||
} else {
|
||||
return parent::getData($length);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @see File_Archive_Reader::skip()
|
||||
*/
|
||||
function skip($length = -1)
|
||||
{
|
||||
if ($this->source === null) {
|
||||
return 0;
|
||||
} else {
|
||||
return parent::skip($length);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @see File_Archive_Reader::rewind()
|
||||
*/
|
||||
function rewind($length = -1)
|
||||
{
|
||||
if ($this->source === null) {
|
||||
return 0;
|
||||
} else {
|
||||
return parent::rewind($length);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @see File_Archive_Reader::tell()
|
||||
*/
|
||||
function tell()
|
||||
{
|
||||
if ($this->source === null) {
|
||||
return 0;
|
||||
} else {
|
||||
return parent::tell();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see File_Archive_Reader::makeWriterRemoveFiles()
|
||||
*/
|
||||
function makeWriterRemoveFiles($pred)
|
||||
{
|
||||
if ($source !== null && $pred->isTrue($this)) {
|
||||
$toUnlink = $this->getDataFilename();
|
||||
} else {
|
||||
$toUnlink = null;
|
||||
}
|
||||
|
||||
while ($this->next()) {
|
||||
if ($toUnlink !== null &&
|
||||
!@unlink($toUnlink)) {
|
||||
return PEAR::raiseError("Unable to unlink $toUnlink");
|
||||
}
|
||||
$toUnlink = ($pred->isTrue($this) ? $this->getDataFilename() : null);
|
||||
}
|
||||
if ($toUnlink !== null &&
|
||||
!@unlink("Unable to unlink $toUnlink")) {
|
||||
return PEAR::raiseError($pred);
|
||||
}
|
||||
|
||||
require_once "File/Archive/Writer/Files.php";
|
||||
|
||||
$writer = new File_Archive_Writer_Files($this->directory);
|
||||
$this->close();
|
||||
return $writer;
|
||||
}
|
||||
|
||||
function &getLastSource()
|
||||
{
|
||||
if ($this->source === null ||
|
||||
is_a($this->source, 'File_Archive_Reader_File')) {
|
||||
return $this->source;
|
||||
} else {
|
||||
return $this->source->getLastSource();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see File_Archive_Reader::makeWriterRemoveBlocks()
|
||||
*/
|
||||
function makeWriterRemoveBlocks($blocks, $seek = 0)
|
||||
{
|
||||
$lastSource = &$this->getLastSource();
|
||||
if ($lastSource === null) {
|
||||
return PEAR::raiseError('No file selected');
|
||||
}
|
||||
|
||||
require_once "File/Archive/Writer/Files.php";
|
||||
|
||||
$writer = $lastSource->makeWriterRemoveBlocks($blocks, $seek);
|
||||
if (!PEAR::isError($writer)) {
|
||||
$writer->basePath = $this->directory;
|
||||
$this->close();
|
||||
}
|
||||
|
||||
return $writer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see File_Archive_Reader::makeAppendWriter
|
||||
*/
|
||||
function makeAppendWriter()
|
||||
{
|
||||
require_once "File/Archive/Writer/Files.php";
|
||||
|
||||
if ($this->source === null ||
|
||||
is_a($this->source, 'File_Archive_Reader_File') ) {
|
||||
$writer = new File_Archive_Writer_Files($this->directory);
|
||||
} else {
|
||||
$writer = $this->source->makeAppendWriter($seek);
|
||||
}
|
||||
|
||||
$this->close();
|
||||
|
||||
return $writer;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -0,0 +1,296 @@
|
|||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* Reader that represents a single file
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* @category File Formats
|
||||
* @package File_Archive
|
||||
* @author Vincent Lascaux <vincentlascaux@php.net>
|
||||
* @copyright 1997-2005 The PHP Group
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
||||
* @version CVS: $Id: File.php 2 2010-11-23 14:32:26Z oldperl $
|
||||
* @link http://pear.php.net/package/File_Archive
|
||||
*/
|
||||
|
||||
require_once "File/Archive/Reader.php";
|
||||
require_once "MIME/Type.php";
|
||||
|
||||
/**
|
||||
* Reader that represents a single file
|
||||
*/
|
||||
class File_Archive_Reader_File extends File_Archive_Reader
|
||||
{
|
||||
/**
|
||||
* @var object Handle to the file being read
|
||||
* @access private
|
||||
*/
|
||||
var $handle = null;
|
||||
/**
|
||||
* @var string Name of the physical file being read
|
||||
* @access private
|
||||
*/
|
||||
var $filename;
|
||||
/**
|
||||
* @var string Name of the file returned by the reader
|
||||
* @access private
|
||||
*/
|
||||
var $symbolic;
|
||||
/**
|
||||
* @var array Stats of the file
|
||||
* Will only be set after a call to $this->getStat()
|
||||
* @access private
|
||||
*/
|
||||
var $stat = null;
|
||||
/**
|
||||
* @var string Mime type of the file
|
||||
* Will only be set after a call to $this->getMime()
|
||||
*/
|
||||
var $mime = null;
|
||||
/**
|
||||
* @var boolean Has the file already been read
|
||||
* @access private
|
||||
*/
|
||||
var $alreadyRead = false;
|
||||
|
||||
/**
|
||||
* $filename is the physical file to read
|
||||
* $symbolic is the name declared by the reader
|
||||
* If $symbolic is not specified, $filename is assumed
|
||||
*/
|
||||
function File_Archive_Reader_File($filename, $symbolic = null, $mime = null)
|
||||
{
|
||||
$this->filename = $filename;
|
||||
$this->mime = $mime;
|
||||
if ($symbolic === null) {
|
||||
$this->symbolic = $this->getStandardURL($filename);
|
||||
} else {
|
||||
$this->symbolic = $this->getStandardURL($symbolic);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @see File_Archive_Reader::close()
|
||||
*
|
||||
* Close the file handle
|
||||
*/
|
||||
function close()
|
||||
{
|
||||
$this->alreadyRead = false;
|
||||
if ($this->handle !== null) {
|
||||
fclose($this->handle);
|
||||
$this->handle = null;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @see File_Archive_Reader::next()
|
||||
*
|
||||
* The first time next is called, it will open the file handle and return
|
||||
* true. Then it will return false
|
||||
* Raise an error if the file does not exist
|
||||
*/
|
||||
function next()
|
||||
{
|
||||
if ($this->alreadyRead) {
|
||||
return false;
|
||||
} else {
|
||||
$this->alreadyRead = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @see File_Archive_Reader::getFilename()
|
||||
*/
|
||||
function getFilename() { return $this->symbolic; }
|
||||
/**
|
||||
* @see File_Archive_Reader::getDataFilename()
|
||||
*
|
||||
* Return the name of the file
|
||||
*/
|
||||
function getDataFilename() { return $this->filename; }
|
||||
/**
|
||||
* @see File_Archive_Reader::getStat() stat()
|
||||
*/
|
||||
function getStat()
|
||||
{
|
||||
if ($this->stat === null) {
|
||||
$this->stat = @stat($this->filename);
|
||||
|
||||
//If we can't use the stat function
|
||||
if ($this->stat === false) {
|
||||
$this->stat = array();
|
||||
}
|
||||
}
|
||||
return $this->stat;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see File_Archive_Reader::getMime
|
||||
*/
|
||||
function getMime()
|
||||
{
|
||||
if ($this->mime === null) {
|
||||
PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
|
||||
$this->mime = MIME_Type::autoDetect($this->getDataFilename());
|
||||
PEAR::popErrorHandling();
|
||||
|
||||
if (PEAR::isError($this->mime)) {
|
||||
$this->mime = parent::getMime();
|
||||
}
|
||||
}
|
||||
return $this->mime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens the file if it was not already opened
|
||||
*/
|
||||
function _ensureFileOpened()
|
||||
{
|
||||
if ($this->handle === null) {
|
||||
$this->handle = @fopen($this->filename, "r");
|
||||
|
||||
if (!is_resource($this->handle)) {
|
||||
$this->handle = null;
|
||||
return PEAR::raiseError("Can't open {$this->filename} for reading");
|
||||
}
|
||||
if ($this->handle === false) {
|
||||
$this->handle = null;
|
||||
return PEAR::raiseError("File {$this->filename} not found");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see File_Archive_Reader::getData()
|
||||
*/
|
||||
function getData($length = -1)
|
||||
{
|
||||
$error = $this->_ensureFileOpened();
|
||||
if (PEAR::isError($error)) {
|
||||
return $error;
|
||||
}
|
||||
|
||||
if (feof($this->handle)) {
|
||||
return null;
|
||||
}
|
||||
if ($length == -1) {
|
||||
$contents = '';
|
||||
$blockSize = File_Archive::getOption('blockSize');
|
||||
while (!feof($this->handle)) {
|
||||
$contents .= fread($this->handle, $blockSize);
|
||||
}
|
||||
return $contents;
|
||||
} else {
|
||||
if ($length == 0) {
|
||||
return "";
|
||||
} else {
|
||||
return fread($this->handle, $length);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see File_Archive_Reader::skip()
|
||||
*/
|
||||
function skip($length = -1)
|
||||
{
|
||||
$error = $this->_ensureFileOpened();
|
||||
if (PEAR::isError($error)) {
|
||||
return $error;
|
||||
}
|
||||
|
||||
$before = ftell($this->handle);
|
||||
if (($length == -1 && @fseek($this->handle, 0, SEEK_END) === -1) ||
|
||||
($length >= 0 && @fseek($this->handle, $length, SEEK_CUR) === -1)) {
|
||||
return parent::skip($length);
|
||||
} else {
|
||||
return ftell($this->handle) - $before;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see File_Archive_Reader::rewind
|
||||
*/
|
||||
function rewind($length = -1)
|
||||
{
|
||||
if ($this->handle === null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$before = ftell($this->handle);
|
||||
if (($length == -1 && @fseek($this->handle, 0, SEEK_SET) === -1) ||
|
||||
($length >= 0 && @fseek($this->handle, -$length, SEEK_CUR) === -1)) {
|
||||
return parent::rewind($length);
|
||||
} else {
|
||||
return $before - ftell($this->handle);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see File_Archive_Reader::tell()
|
||||
*/
|
||||
function tell()
|
||||
{
|
||||
if ($this->handle === null) {
|
||||
return 0;
|
||||
} else {
|
||||
return ftell($this->handle);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see File_Archive_Reader::makeWriterRemoveFiles()
|
||||
*/
|
||||
function makeWriterRemoveFiles($pred)
|
||||
{
|
||||
return PEAR::raiseError(
|
||||
'File_Archive_Reader_File represents a single file, you cant remove it');
|
||||
}
|
||||
|
||||
/**
|
||||
* @see File_Archive_Reader::makeWriterRemoveBlocks()
|
||||
*/
|
||||
function makeWriterRemoveBlocks($blocks, $seek = 0)
|
||||
{
|
||||
require_once "File/Archive/Writer/Files.php";
|
||||
|
||||
$writer = new File_Archive_Writer_Files();
|
||||
|
||||
$file = $this->getDataFilename();
|
||||
$pos = $this->tell();
|
||||
$this->close();
|
||||
|
||||
$writer->openFileRemoveBlock($file, $pos + $seek, $blocks);
|
||||
|
||||
return $writer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see File_Archive_Reader::makeAppendWriter
|
||||
*/
|
||||
function makeAppendWriter()
|
||||
{
|
||||
return PEAR::raiseError(
|
||||
'File_Archive_Reader_File represents a single file.'.
|
||||
' makeAppendWriter cant be executed on it'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden Mehr anzeigen
Laden…
In neuem Issue referenzieren