Skip to content

Commit

Permalink
moved deprecated functions to compatibility file
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.code.sf.net/p/cmsimplexh/code/trunk@1521 4f8f9682-67af-44ce-aacd-401fd16d96b5
  • Loading branch information
cmb69 committed Mar 23, 2015
1 parent e6c7dde commit aae81e7
Show file tree
Hide file tree
Showing 9 changed files with 309 additions and 284 deletions.
4 changes: 4 additions & 0 deletions cmsimple/cms.php
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,10 @@

$pth['folder']['flags'] = $pth['folder']['images'] . 'flags/';

if ($cf['site']['compat']) {
include_once $pth['folder']['cmsimple'] . 'compat.php';
}

/**
* Debug output generated by PHP according to debug mode.
*
Expand Down
299 changes: 299 additions & 0 deletions cmsimple/compat.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,299 @@
<?php

/**
* Backward compatible functionality.
*
* PHP version 5
*
* @category CMSimple_XH
* @package XH
* @author Peter Harteg <peter@harteg.dk>
* @author The CMSimple_XH developers <devs@cmsimple-xh.org>
* @copyright 1999-2009 Peter Harteg
* @copyright 2009-2015 The CMSimple_XH developers <http://cmsimple-xh.org/?The_Team>
* @license http://www.gnu.org/licenses/gpl-3.0.en.html GNU GPLv3
* @version SVN: $Id$
* @link http://cmsimple-xh.org/
*/

/**
* Returns the code to display a photogallery.
*
* @param string $u Autogallery's installation folder.
*
* @global string The URL of the active page.
*
* @return string The (X)HTML.
*
* @deprecated since 1.5.4. Use a gallery plugin instead.
*/
function autogallery($u)
{
global $su;

trigger_error('Function autogallery() is deprecated', E_USER_DEPRECATED);

return preg_replace(
"/.*<!-- autogallery -->(.*)<!-- \/autogallery -->.*/is", '$1',
preg_replace(
"/(option value=\"\?)(p=)/is", '${1}' . $su . '&$2',
preg_replace(
"/(href=\"\?)/is", '${1}' . $su . '&amp;',
preg_replace("/(src=\")(\.)/is", '${1}' . $u . '$2', geturlwp($u))
)
)
);
}

/**
* Returns the canonicalized absolute pathname on success.
* Otherwise returns its input.
*
* @param string $p The file name.
*
* @return string
*
* @deprecated since 1.5.4. Use realpath() instead.
*/
function rp($p)
{
trigger_error('Function rp() is deprecated', E_USER_DEPRECATED);

if (realpath($p) == '') {
return $p;
} else {
return realpath($p);
}
}

/**
* Returns '&' or '&amp;' according to the setting of $cf['xhtml']['amp'].
*
* @return string The (X)HTML.
*
* @global array The configuration of the core.
*
* @deprecated since 1.5.4. Use '&amp;' instead.
*/
function amp()
{
global $cf;

trigger_error('Function amp() is deprecated', E_USER_DEPRECATED);

if ($cf['xhtml']['amp'] == 'true') {
return '&amp;';
} else {
return '&';
}
}

/**
* Returns the link to the guestbook.
*
* @return string The (X)HTML.
*
* @deprecated since 1.5.4
*/
function guestbooklink()
{
trigger_error(
'Function ' . __FUNCTION__ . '() is deprecated', E_USER_DEPRECATED
);
if (function_exists('gblink')) {
return gblink();
}
}

/**
* Returns the link to the copyright and license informations.
*
* @return string The (X)HTML.
*
* @global array The configuration of the core.
* @global string The script name.
*
* @deprecated since 1.5.8
*/
function legallink()
{
global $cf, $sn;

trigger_error(
'Function ' . __FUNCTION__ . '() is deprecated', E_USER_DEPRECATED
);
return '<a href="' . $sn . '?' . uenc($cf['menu']['legal']) . '">'
. $cf['menu']['legal'] . '</a>';
}

/**
* Returns whether the file exists in the download folder
* and is available for download.
*
* @param string $fl The download URL, e.g. ?download=file.ext
*
* @return bool
*
* @global array The paths of system files and folders.
* @global string The script name.
*
* @deprecated since 1.6.
*/
function chkdl($fl)
{
global $pth, $sn;

trigger_error(
'Function ' . __FUNCTION__ . '() is deprecated', E_USER_DEPRECATED
);
$m = false;
if (is_dir($pth['folder']['downloads'])) {
if ($fd = opendir($pth['folder']['downloads'])) {
while (($p = readdir($fd)) == true) {
if (preg_match("/.+\..+$/", $p)) {
if ($fl == $sn . '?download=' . $p) {
$m = true;
}
}
}
closedir($fd);
}
}
return $m;
}

/**
* Returns the content of file $filename, if it does exist, null otherwise.
*
* @param string $fl The file name.
*
* @return string
*
* @deprecated since 1.6
*/
function rf($fl)
{
trigger_error(
'Function ' . __FUNCTION__ . '() is deprecated', E_USER_DEPRECATED
);
if (!file_exists($fl)) {
return;
}
clearstatcache();
return file_get_contents($fl);
}

/**
* Checks wether the file exists, is readable,
* and if $writeable is true, is writeable.
*
* Appends an according message to $e otherwise.
*
* @param string $fl A key of $pth['file'].
* @param bool $writable Whether the file has to writable.
*
* @global array The paths of system files and folders.
* @global array The localization of the core.
*
* @return bool
*
* @deprecated since 1.6.
*/
function chkfile($fl, $writable)
{
global $pth, $tx;

trigger_error(
'Function '. __FUNCTION__ . '() is deprecated', E_USER_DEPRECATED
);

$t = isset($pth['file'][$fl]) ? $pth['file'][$fl] : '';
if ($t == '') {
e('undefined', 'file', $fl);
} elseif (!file_exists($t)) {
e('missing', $fl, $t);
} elseif (!is_readable($t)) {
e('notreadable', $fl, $t);
} elseif (!is_writable($t) && $writable) {
e('notwritable', $fl, $t);
}
}

/**
* Function preCallPlugins() => Pre-Call of Plugins.
*
* All Plugins which are called through a function-call
* can use this. At the moment it is'nt possible to do
* this with class-based plugins. They need to be called
* through standard-CMSimple-Scripting.
*
* Call a plugin: place this in your code (example):
* {{{PLUGIN:pluginfunction('parameters');}}}
*
* Call a built-in function (at the moment only one for
* demonstration):
* {{{HOME}}} or: {{{HOME:name_of_Link}}}
* This creates a link to the first page of your CMSimple-
* Installation.
*
* @param int $pageIndex The page index.
*
* @global bool Whether edit-mode is active.
* @global array The contents of all pages.
* @global int The Index of the active page.
* @global array The URLs of all pages.
*
* @return void
*
* @author mvwd
*
* @since 1.0
*
* @deprecated since 1.6
*/
function preCallPlugins($pageIndex = -1)
{
global $edit, $c, $s, $u;

trigger_error('Function preCallPlugins() is deprecated', E_USER_DEPRECATED);

if (!$edit) {
if ((int) $pageIndex > - 1 && (int) $pageIndex < count($u)) {
$as = $pageIndex;
} else {
$as = $s < 0 ? 0 : $s;
}
$c[$as] = evaluate_plugincall($c[$as]);
}
}

/**
* Appends a message to the logfile.
*
* On failure an according message is appended to $e.
*
* @param string $m The log message.
*
* @return void
*
* @global array The paths of system files and folders.
* @global string Error messages as (X)HTML fragment consisting of LI Elements.
*
* @deprecated since 1.6
*/
function writelog($m)
{
global $pth, $e;

trigger_error(
'Function ' . __FUNCTION__ . '() is deprecated', E_USER_DEPRECATED
);
if ($fh = fopen($pth['file']['log'], "a")) {
fwrite($fh, $m);
fclose($fh);
} else {
e('cntwriteto', 'log', $pth['file']['log']);
}
}

?>
2 changes: 2 additions & 0 deletions cmsimple/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
$cf['security']['frame_options']="";
$cf['site']['template']="mini1";
$cf['site']['timezone']="";
$cf['site']['compat']="true";
$cf['language']['default']="en";
$cf['language']['2nd_lang_names']="cs=Čeština;da=Dansk;de=Deutsch;en=English;es=Español;fi=Suomi;fr=Français;gr=Ελληνικά;hu=Magyar;it=Italiano;nl=Nederlands;no=Norsk;pl=Polski;ru=Русский;se=Svensk;sk=Slovenčina";
$cf['mailform']['email']="";
Expand Down Expand Up @@ -46,4 +47,5 @@
$cf['editmenu']['scroll']="";
$cf['editmenu']['external']="";
$cf['title']['format']="{SITE} &ndash; {PAGE}";

?>

0 comments on commit aae81e7

Please sign in to comment.