fix typing and doc

Dieser Commit ist enthalten in:
o.pinke 2024-03-11 15:27:47 +01:00
Ursprung 9d5af6dc52
Commit 9adbbdd164
1 geänderte Dateien mit 260 neuen und 186 gelöschten Zeilen

Datei anzeigen

@ -35,7 +35,8 @@ if (!defined('CON_FRAMEWORK')) {
* @author Jan Lengowski <Jan.Lengowski@4fb.de> * @author Jan Lengowski <Jan.Lengowski@4fb.de>
* @copyright four for business AG * @copyright four for business AG
*/ */
function getAvailableContentTypes($idartlang) { function getAvailableContentTypes($idartlang)
{
global $db, $cfg, $a_content, $a_description; global $db, $cfg, $a_content, $a_description;
$sql = "SELECT $sql = "SELECT
@ -63,7 +64,8 @@ function getAvailableContentTypes($idartlang) {
* @param int $idart Article-Id * @param int $idart Article-Id
* @return bool Article assigned to multiple categories * @return bool Article assigned to multiple categories
*/ */
function isArtInMultipleUse($idart) { function isArtInMultipleUse($idart)
{
global $cfg, $client; global $cfg, $client;
$db = new DB_ConLite; $db = new DB_ConLite;
@ -80,7 +82,8 @@ function isArtInMultipleUse($idart) {
* @param bool $umlauts [Use german Umlaute] Optional * @param bool $umlauts [Use german Umlaute] Optional
* @return bool Value is alphanumeric * @return bool Value is alphanumeric
*/ */
function is_alphanumeric($test, $umlauts = true) { function is_alphanumeric($test, $umlauts = true)
{
if ($umlauts == true) { if ($umlauts == true) {
$match = "/^[a-z0-9<><39><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ]+$/i"; $match = "/^[a-z0-9<><39><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ]+$/i";
@ -97,7 +100,8 @@ function is_alphanumeric($test, $umlauts = true) {
* @param int $month * @param int $month
* @return string * @return string
*/ */
function getCanonicalMonth($month) { function getCanonicalMonth($month)
{
switch ($month) { switch ($month) {
case 1 : case 1 :
return (i18n("January")); return (i18n("January"));
@ -144,7 +148,8 @@ function getCanonicalMonth($month) {
* @param int $iDay The day number of date(w) * @param int $iDay The day number of date(w)
* @return string Dayname of current language * @return string Dayname of current language
*/ */
function getCanonicalDay($iDay) { function getCanonicalDay($iDay)
{
switch ($iDay) { switch ($iDay) {
case 1 : case 1 :
return (i18n("Monday")); return (i18n("Monday"));
@ -167,7 +172,8 @@ function getCanonicalDay($iDay) {
case 0 : case 0 :
return (i18n("Sunday")); return (i18n("Sunday"));
break; break;
default: break; default:
break;
} }
} }
@ -177,7 +183,8 @@ function getCanonicalDay($iDay) {
* @param mixed $area Area name * @param mixed $area Area name
* @return int * @return int
*/ */
function getIDForArea($area) { function getIDForArea($area)
{
global $client, $lang, $cfg, $sess; global $client, $lang, $cfg, $sess;
$db = new DB_ConLite; $db = new DB_ConLite;
@ -205,7 +212,8 @@ function getIDForArea($area) {
* @param mixed $area * @param mixed $area
* @return int * @return int
*/ */
function getParentAreaId($area) { function getParentAreaId($area)
{
global $client, $lang, $cfg, $sess; global $client, $lang, $cfg, $sess;
$db = new DB_ConLite; $db = new DB_ConLite;
@ -247,7 +255,8 @@ function getParentAreaId($area) {
* @author Jan Lengowski <Jan.Lengowski@4fb.de> * @author Jan Lengowski <Jan.Lengowski@4fb.de>
* @copyright four for business AG <www.4fb.de> * @copyright four for business AG <www.4fb.de>
*/ */
function markSubMenuItem($menuitem, $return = false) { function markSubMenuItem($menuitem, $return = false)
{
$str = '<script type="text/javascript"> $str = '<script type="text/javascript">
try { try {
@ -289,7 +298,8 @@ function markSubMenuItem($menuitem, $return = false) {
* @author Jan Lengowski <Jan.Lengowski@4fb.de> * @author Jan Lengowski <Jan.Lengowski@4fb.de>
* @copyright four for business AG <www.4fb.de> * @copyright four for business AG <www.4fb.de>
*/ */
function backToMainArea($send) { function backToMainArea($send)
{
if ($send) { if ($send) {
/* Global vars */ /* Global vars */
global $area, $cfg, $db, $sess, $idart, $idcat, $idartlang, $idcatart, $frame; global $area, $cfg, $db, $sess, $idart, $idcat, $idartlang, $idcatart, $frame;
@ -319,7 +329,8 @@ function backToMainArea($send) {
} }
} }
function showLocation($area) { function showLocation($area)
{
global $db; global $db;
global $cfgPath, $lngArea; global $cfgPath, $lngArea;
global $cfg; global $cfg;
@ -361,7 +372,8 @@ function showLocation($area) {
} }
} }
function showTable($tablename) { function showTable($tablename)
{
global $db; global $db;
$sql = "SELECT * FROM $tablename"; $sql = "SELECT * FROM $tablename";
@ -377,12 +389,13 @@ function showTable($tablename) {
/** /**
* Get languages for given client * Get languages for given client
* *
* @deprecated since ConLite version 2.0.0, use method in class cApiLanguageCollection instead
*
* @param int $client * @param int $client
* @return array Array of language ids * @return array Array of language ids
* @deprecated since ConLite version 2.0.0, use method in class cApiLanguageCollection instead
*
*/ */
function getLanguagesByClient($client) { function getLanguagesByClient($client)
{
$oClLangs = new cApiLanguageCollection(); $oClLangs = new cApiLanguageCollection();
return $oClLangs->getClientLanguages($client); return $oClLangs->getClientLanguages($client);
} }
@ -393,7 +406,8 @@ function getLanguagesByClient($client) {
* @param int $client * @param int $client
* @return array List of languages where the key is the language id and value the language name * @return array List of languages where the key is the language id and value the language name
*/ */
function getLanguageNamesByClient($client) { function getLanguageNamesByClient($client)
{
global $db; global $db;
global $cfg; global $cfg;
$list = []; $list = [];
@ -418,7 +432,8 @@ function getLanguageNamesByClient($client) {
return $list; return $list;
} }
function set_magic_quotes_gpc(&$code) { function set_magic_quotes_gpc(&$code)
{
$code = addslashes($code); $code = addslashes($code);
} }
@ -431,7 +446,8 @@ function set_magic_quotes_gpc(&$code) {
* - $arr[0]['idclient'] * - $arr[0]['idclient']
* - $arr[0]['clientname'] * - $arr[0]['clientname']
*/ */
function getAllClientsAndLanguages() { function getAllClientsAndLanguages()
{
global $db, $cfg; global $db, $cfg;
$sql = "SELECT $sql = "SELECT
@ -460,7 +476,8 @@ function getAllClientsAndLanguages() {
return $aRs; return $aRs;
} }
function fakeheader($time) { function fakeheader($time)
{
global $con_time0; global $con_time0;
if (!isset($con_time0)) { if (!isset($con_time0)) {
$con_time0 = $time; $con_time0 = $time;
@ -472,7 +489,8 @@ function fakeheader($time) {
} // end if } // end if
} }
function recursive_copy($from_path, $to_path) { function recursive_copy($from_path, $to_path)
{
$oldumask = umask(0); $oldumask = umask(0);
if (mkdir($to_path, 0777)) { if (mkdir($to_path, 0777)) {
umask($oldumask); umask($oldumask);
@ -502,7 +520,8 @@ function recursive_copy($from_path, $to_path) {
} }
} }
function getmicrotime() { function getmicrotime()
{
list ($usec, $sec) = explode(" ", microtime()); list ($usec, $sec) = explode(" ", microtime());
return ((float)$usec + (float)$sec); return ((float)$usec + (float)$sec);
} }
@ -511,7 +530,8 @@ function getmicrotime() {
As we are probably soon rewriting the As we are probably soon rewriting the
session management, this hack is OK. */ session management, this hack is OK. */
function cleanupSessions() { function cleanupSessions()
{
global $cfg; global $cfg;
$db = new DB_ConLite; $db = new DB_ConLite;
@ -547,7 +567,8 @@ function cleanupSessions() {
} }
} }
function isGroup($uid) { function isGroup($uid)
{
$users = new User; $users = new User;
if ($users->loadUserByUserID($uid) == false) { if ($users->loadUserByUserID($uid) == false) {
@ -557,7 +578,8 @@ function isGroup($uid) {
} }
} }
function getGroupOrUserName($uid) { function getGroupOrUserName($uid)
{
$users = new User; $users = new User;
if ($users->loadUserByUserID($uid) === false) { if ($users->loadUserByUserID($uid) === false) {
@ -628,7 +650,8 @@ function getGroupOrUserName($uid) {
* @return array see above for example * @return array see above for example
* @author Marco Jahn * @author Marco Jahn
*/ */
function getPhpModuleInfo($moduleName) { function getPhpModuleInfo($moduleName)
{
$moduleSettings = array(); $moduleSettings = array();
ob_start(); ob_start();
phpinfo(INFO_MODULES); // get information vor modules phpinfo(INFO_MODULES); // get information vor modules
@ -675,7 +698,8 @@ function getPhpModuleInfo($moduleName) {
return $moduleSettings; return $moduleSettings;
} }
function isValidMail($sEMail, $bStrict = false) { function isValidMail($sEMail, $bStrict = false)
{
if ($bStrict) { if ($bStrict) {
// HerrB (14.02.2008), code posted by Calvini // HerrB (14.02.2008), code posted by Calvini
// See http://www.contenido.org/forum/viewtopic.php?p=106612#106612 // See http://www.contenido.org/forum/viewtopic.php?p=106612#106612
@ -699,7 +723,8 @@ function isValidMail($sEMail, $bStrict = false) {
} }
} }
function htmldecode($string) { function htmldecode($string)
{
$trans_tbl = clGetHtmlTranslationTable(HTML_ENTITIES); $trans_tbl = clGetHtmlTranslationTable(HTML_ENTITIES);
$trans_tbl = array_flip($trans_tbl); $trans_tbl = array_flip($trans_tbl);
$ret = strtr($string, $trans_tbl); $ret = strtr($string, $trans_tbl);
@ -716,7 +741,8 @@ function htmldecode($string) {
* @global DB_ConLite $db * @global DB_ConLite $db
* @global array $cfg * @global array $cfg
*/ */
function rereadClients() { function rereadClients()
{
global $cfgClient; global $cfgClient;
global $errsite_idcat; global $errsite_idcat;
global $errsite_idart; global $errsite_idart;
@ -800,7 +826,8 @@ function rereadClients() {
* @param string $value The value of the item * @param string $value The value of the item
* @param int $idsystemprop The sysprop id, use optional. If set it allows to modify type name and value * @param int $idsystemprop The sysprop id, use optional. If set it allows to modify type name and value
*/ */
function setSystemProperty($type, $name, $value, $idsystemprop = 0) { function setSystemProperty($type, $name, $value, $idsystemprop = 0)
{
global $cfg; global $cfg;
if ($type == "" || $name == "") { if ($type == "" || $name == "") {
return false; return false;
@ -840,7 +867,8 @@ function setSystemProperty($type, $name, $value, $idsystemprop = 0) {
* @param string $type The type of the item * @param string $type The type of the item
* @param string $name The name of the item * @param string $name The name of the item
*/ */
function deleteSystemProperty($type, $name) { function deleteSystemProperty($type, $name)
{
global $cfg; global $cfg;
$db_systemprop = new DB_ConLite; $db_systemprop = new DB_ConLite;
@ -863,7 +891,8 @@ function deleteSystemProperty($type, $name) {
* @param boolean bGetPropId - if true special mode is activated which generates for each property a third array, which also contains idsystemprop value * @param boolean bGetPropId - if true special mode is activated which generates for each property a third array, which also contains idsystemprop value
* @return array * @return array
*/ */
function getSystemProperties($bGetPropId = 0) { function getSystemProperties($bGetPropId = 0)
{
global $cfg; global $cfg;
$db_systemprop = new DB_ConLite; $db_systemprop = new DB_ConLite;
@ -893,7 +922,8 @@ function getSystemProperties($bGetPropId = 0) {
* @param string $name The name of the item * @param string $name The name of the item
* @return mixed boolean false if nothing was found, or * @return mixed boolean false if nothing was found, or
*/ */
function getSystemProperty($sType, $sName) { function getSystemProperty($sType, $sName)
{
$oProperties = new cApiSystemPropertyCollection(); $oProperties = new cApiSystemPropertyCollection();
return $oProperties->getSystemProperty($sType, $sName); return $oProperties->getSystemProperty($sType, $sName);
@ -922,7 +952,8 @@ function getSystemProperty($sType, $sName) {
* @param string $type The type of the item * @param string $type The type of the item
* @return array Value * @return array Value
*/ */
function getSystemPropertiesByType($sType) { function getSystemPropertiesByType($sType)
{
global $cfg; global $cfg;
$aResult = array(); $aResult = array();
@ -953,7 +984,8 @@ function getSystemPropertiesByType($sType) {
* @param string $default Optional default value * @param string $default Optional default value
* @return mixed boolean false if nothing was found * @return mixed boolean false if nothing was found
*/ */
function getEffectiveSetting($type, $name, $default = "") { function getEffectiveSetting($type, $name, $default = "")
{
global $auth, $client, $lang; global $auth, $client, $lang;
if ($auth->auth["uid"] != "nobody") { if ($auth->auth["uid"] != "nobody") {
@ -999,18 +1031,19 @@ function getEffectiveSetting($type, $name, $default = "") {
* *
* You may use default array to preset settings, this will not override found settings * You may use default array to preset settings, this will not override found settings
* *
* @param string $sType
* @param array $aDefault
* @return array
* @global int $client
* @global array $cfg
* @global int $lang
* @version $Rev$ * @version $Rev$
* @author Ortwin Pinke <o.pinke@conlite.org> * @author Ortwin Pinke <o.pinke@conlite.org>
* *
* @global object $auth * @global object $auth
* @global int $client
* @global array $cfg
* @global int $lang
* @param string $sType
* @param array $aDefault
* @return array
*/ */
function getEffectiveSettingsByType($sType, $aDefault = array()) { function getEffectiveSettingsByType($sType, $aDefault = array())
{
global $auth, $client, $cfg, $lang; global $auth, $client, $cfg, $lang;
$aResult = getSystemPropertiesByType($sType); $aResult = getSystemPropertiesByType($sType);
@ -1047,7 +1080,8 @@ function getEffectiveSettingsByType($sType, $aDefault = array()) {
* *
* @return array list of article specifications * @return array list of article specifications
*/ */
function getArtspec() { function getArtspec()
{
global $db, $cfg, $lang, $client; global $db, $cfg, $lang, $client;
$sql = "SELECT artspec, idartspec, online, artspecdefault FROM " . $cfg['tab']['art_spec'] . " $sql = "SELECT artspec, idartspec, online, artspecdefault FROM " . $cfg['tab']['art_spec'] . "
WHERE client='" . Contenido_Security::toInteger($client) . "' AND lang='" . Contenido_Security::toInteger($lang) . "' ORDER BY artspec ASC"; WHERE client='" . Contenido_Security::toInteger($client) . "' AND lang='" . Contenido_Security::toInteger($lang) . "' ORDER BY artspec ASC";
@ -1070,7 +1104,8 @@ function getArtspec() {
* *
* @return void * @return void
*/ */
function addArtspec($artspectext, $online) { function addArtspec($artspectext, $online)
{
global $db, $cfg, $lang, $client; global $db, $cfg, $lang, $client;
if (isset($_POST['idartspec'])) { //update if (isset($_POST['idartspec'])) { //update
@ -1096,7 +1131,8 @@ function addArtspec($artspectext, $online) {
* *
* @return void * @return void
*/ */
function deleteArtspec($idartspec) { function deleteArtspec($idartspec)
{
global $db, $cfg; global $db, $cfg;
$sql = "DELETE FROM " . $cfg['tab']['art_spec'] . " WHERE idartspec = '" . Contenido_Security::toInteger($idartspec) . "'"; $sql = "DELETE FROM " . $cfg['tab']['art_spec'] . " WHERE idartspec = '" . Contenido_Security::toInteger($idartspec) . "'";
$db->query($sql); $db->query($sql);
@ -1115,7 +1151,8 @@ function deleteArtspec($idartspec) {
* *
* @return void * @return void
*/ */
function setArtspecOnline($idartspec, $online) { function setArtspecOnline($idartspec, $online)
{
global $db, $cfg; global $db, $cfg;
$sql = "UPDATE " . $cfg['tab']['art_spec'] . " SET online=" . Contenido_Security::toInteger($online) . " WHERE idartspec=" . Contenido_Security::toInteger($idartspec) . ""; $sql = "UPDATE " . $cfg['tab']['art_spec'] . " SET online=" . Contenido_Security::toInteger($online) . " WHERE idartspec=" . Contenido_Security::toInteger($idartspec) . "";
$db->query($sql); $db->query($sql);
@ -1130,7 +1167,8 @@ function setArtspecOnline($idartspec, $online) {
* *
* @return void * @return void
*/ */
function setArtspecDefault($idartspec) { function setArtspecDefault($idartspec)
{
global $db, $cfg, $lang, $client; global $db, $cfg, $lang, $client;
$sql = "UPDATE " . $cfg['tab']['art_spec'] . " SET artspecdefault=0 WHERE client='" . Contenido_Security::toInteger($client) . "' AND lang='" . Contenido_Security::toInteger($lang) . "'"; $sql = "UPDATE " . $cfg['tab']['art_spec'] . " SET artspecdefault=0 WHERE client='" . Contenido_Security::toInteger($client) . "' AND lang='" . Contenido_Security::toInteger($lang) . "'";
$db->query($sql); $db->query($sql);
@ -1146,7 +1184,8 @@ function setArtspecDefault($idartspec) {
* @param String Value of the SelectBox * @param String Value of the SelectBox
* @return String HTML * @return String HTML
*/ */
function buildArticleSelect($sName, $iIdCat, $sValue) { function buildArticleSelect($sName, $iIdCat, $sValue)
{
global $cfg, $client, $lang, $idcat; global $cfg, $client, $lang, $idcat;
$db = new DB_ConLite; $db = new DB_ConLite;
@ -1184,7 +1223,8 @@ function buildArticleSelect($sName, $iIdCat, $sValue) {
* @param String Optional style informations for select * @param String Optional style informations for select
* @return String HTML * @return String HTML
*/ */
function buildCategorySelect($sName, $sValue, $sLevel = 0, $sStyle = "") { function buildCategorySelect($sName, $sValue, $sLevel = 0, $sStyle = "")
{
global $cfg, $client, $lang, $idcat; global $cfg, $client, $lang, $idcat;
$db = new DB_ConLite; $db = new DB_ConLite;
@ -1259,7 +1299,8 @@ function buildCategorySelect($sName, $sValue, $sLevel = 0, $sStyle = "") {
* @param string $filename Name of the file * @param string $filename Name of the file
* @return extension on success, false if no extension could be extracted. * @return extension on success, false if no extension could be extracted.
*/ */
function getFileExtension($filename) { function getFileExtension($filename)
{
$dotposition = strrpos($filename, "."); $dotposition = strrpos($filename, ".");
if ($dotposition !== false) { if ($dotposition !== false) {
@ -1269,7 +1310,8 @@ function getFileExtension($filename) {
} }
} }
function human_readable_size($number) { function human_readable_size($number)
{
$base = 1024; $base = 1024;
$suffixes = array(" B", " KB", " MB", " GB", " TB", " PB", " EB"); $suffixes = array(" B", " KB", " MB", " GB", " TB", " PB", " EB");
@ -1292,7 +1334,8 @@ function human_readable_size($number) {
* @param array Array to trim * @param array Array to trim
* @return array Trimmed array * @return array Trimmed array
*/ */
function trim_array($array) { function trim_array($array)
{
if (!is_array($array)) { if (!is_array($array)) {
return $array; return $array;
} }
@ -1304,7 +1347,8 @@ function trim_array($array) {
return $array; return $array;
} }
function array_csort() { //coded by Ichier2003 function array_csort()
{ //coded by Ichier2003
$args = func_get_args(); $args = func_get_args();
$marray = array_shift($args); $marray = array_shift($args);
$msortline = "return(array_multisort("; $msortline = "return(array_multisort(";
@ -1339,7 +1383,8 @@ function array_csort() { //coded by Ichier2003
* *
* @return string Processed string * @return string Processed string
*/ */
function str_ireplace_once($find, $replace, $subject) { function str_ireplace_once($find, $replace, $subject)
{
$start = strpos(strtolower($subject), strtolower($find)); $start = strpos(strtolower($subject), strtolower($find));
if ($start === false) { if ($start === false) {
@ -1367,7 +1412,8 @@ function str_ireplace_once($find, $replace, $subject) {
* *
* @return string Processed string * @return string Processed string
*/ */
function str_ireplace_once_reverse($find, $replace, $subject) { function str_ireplace_once_reverse($find, $replace, $subject)
{
$start = str_rpos(strtolower($subject), strtolower($find)); $start = str_rpos(strtolower($subject), strtolower($find));
if ($start === false) { if ($start === false) {
@ -1396,7 +1442,8 @@ function str_ireplace_once_reverse($find, $replace, $subject) {
* *
* @return string Processed string * @return string Processed string
*/ */
function str_rpos($haystack, $needle, $start = 0) { function str_rpos($haystack, $needle, $start = 0)
{
$tempPos = strpos($haystack, $needle, $start); $tempPos = strpos($haystack, $needle, $start);
if ($tempPos === false) { if ($tempPos === false) {
@ -1418,7 +1465,8 @@ function str_rpos($haystack, $needle, $start = 0) {
* *
* @return boolean true if ImageMagick is available * @return boolean true if ImageMagick is available
*/ */
function isImageMagickAvailable() { function isImageMagickAvailable()
{
global $_imagemagickAvailable; global $_imagemagickAvailable;
if (is_bool($_imagemagickAvailable)) { if (is_bool($_imagemagickAvailable)) {
@ -1438,7 +1486,8 @@ function isImageMagickAvailable() {
* *
* @return boolean true if the script is running from the web * @return boolean true if the script is running from the web
*/ */
function isRunningFromWeb() { function isRunningFromWeb()
{
if ($_SERVER["PHP_SELF"] == "" || php_sapi_name() == "cgi" || php_sapi_name() == "cli") { if ($_SERVER["PHP_SELF"] == "" || php_sapi_name() == "cgi" || php_sapi_name() == "cli") {
return false; return false;
} }
@ -1451,7 +1500,8 @@ function isRunningFromWeb() {
* *
* @return string client name * @return string client name
*/ */
function getClientName($idclient) { function getClientName($idclient)
{
global $cfg; global $cfg;
$db = new DB_ConLite; $db = new DB_ConLite;
@ -1467,7 +1517,8 @@ function getClientName($idclient) {
} }
} }
function scanDirectory($sDirectory, $bRecursive = false) { function scanDirectory($sDirectory, $bRecursive = false)
{
if (substr($sDirectory, strlen($sDirectory) - 1, 1) == "/") { if (substr($sDirectory, strlen($sDirectory) - 1, 1) == "/") {
$sDirectory = substr($sDirectory, 0, strlen($sDirectory) - 1); $sDirectory = substr($sDirectory, 0, strlen($sDirectory) - 1);
} }
@ -1523,7 +1574,8 @@ function scanDirectory($sDirectory, $bRecursive = false) {
* @param $entity Name of the directory to scan * @param $entity Name of the directory to scan
* @return string client name * @return string client name
*/ */
function scanPlugins($entity) { function scanPlugins($entity)
{
global $cfg; global $cfg;
$pluginorder = getSystemProperty("plugin", $entity . "-pluginorder"); $pluginorder = getSystemProperty("plugin", $entity . "-pluginorder");
@ -1588,7 +1640,8 @@ function scanPlugins($entity) {
* *
* @param $entity Name of the directory to scan * @param $entity Name of the directory to scan
*/ */
function includePlugins($entity) { function includePlugins($entity)
{
global $cfg; global $cfg;
if (is_array($cfg['plugins'][$entity])) { if (is_array($cfg['plugins'][$entity])) {
@ -1606,7 +1659,8 @@ function includePlugins($entity) {
* *
* @param $entity Name of the directory to scan * @param $entity Name of the directory to scan
*/ */
function callPluginStore($entity) { function callPluginStore($entity)
{
global $cfg; global $cfg;
/* Check out if there are any plugins */ /* Check out if there are any plugins */
@ -1628,7 +1682,8 @@ function callPluginStore($entity) {
} }
} }
function displayPlugin($entity, & $form) { function displayPlugin($entity, &$form)
{
/* TODO: Function can't work, as $feuser is not defined (see $display = /* TODO: Function can't work, as $feuser is not defined (see $display =
* call_user_func($entity."_".$plugin."_display", $feuser);) and plugins need * call_user_func($entity."_".$plugin."_display", $feuser);) and plugins need
* - if data has to be shown - global objects ... * - if data has to be shown - global objects ...
@ -1667,7 +1722,8 @@ function displayPlugin($entity, & $form) {
* @param $nameLength Length of the generated string * @param $nameLength Length of the generated string
* @return string random name * @return string random name
*/ */
function createRandomName($nameLength) { function createRandomName($nameLength)
{
$NameChars = 'abcdefghijklmnopqrstuvwxyz'; $NameChars = 'abcdefghijklmnopqrstuvwxyz';
$Vouel = 'aeiou'; $Vouel = 'aeiou';
$Name = ""; $Name = "";
@ -1697,7 +1753,8 @@ function createRandomName($nameLength) {
* @param $referer Referer (optional) * @param $referer Referer (optional)
* @param $port Port (default: 80) * @param $port Port (default: 80)
*/ */
function sendPostRequest($host, $path, $data, $referer = "", $port = 80) { function sendPostRequest($host, $path, $data, $referer = "", $port = 80)
{
$fp = fsockopen($host, $port); $fp = fsockopen($host, $port);
fputs($fp, "POST $path HTTP/1.1\n"); fputs($fp, "POST $path HTTP/1.1\n");
@ -1717,7 +1774,8 @@ function sendPostRequest($host, $path, $data, $referer = "", $port = 80) {
return $res; return $res;
} }
function is_dbfs($file) { function is_dbfs($file)
{
if (is_null($file)) { if (is_null($file)) {
$file = ''; $file = '';
} }
@ -1726,7 +1784,8 @@ function is_dbfs($file) {
} }
} }
function setHelpContext($area) { function setHelpContext($area)
{
global $cfg; global $cfg;
if ($cfg['help'] == true) { if ($cfg['help'] == true) {
@ -1738,7 +1797,8 @@ function setHelpContext($area) {
return $hc; return $hc;
} }
function define_if($constant, $value) { function define_if($constant, $value)
{
if (!defined($constant)) { if (!defined($constant)) {
define($constant, $value); define($constant, $value);
} }
@ -1756,7 +1816,8 @@ if (!defined('PHP_EOL')) {
} }
} }
function locale_arsort($locale, $array) { function locale_arsort($locale, $array)
{
$oldlocale = setlocale(LC_COLLATE, 0); $oldlocale = setlocale(LC_COLLATE, 0);
setlocale(LC_COLLATE, $locale); setlocale(LC_COLLATE, $locale);
@ -1771,7 +1832,8 @@ function locale_arsort($locale, $array) {
/* Note: If subarrays exists, this function currently returns the key of the array /* Note: If subarrays exists, this function currently returns the key of the array
given by $array, and not from the subarrays (todo: add flag to allow this) */ given by $array, and not from the subarrays (todo: add flag to allow this) */
function array_search_recursive($search, $array, $partial = false, $strict = false) { function array_search_recursive($search, $array, $partial = false, $strict = false)
{
foreach ($array as $key => $value) { foreach ($array as $key => $value) {
if (is_array($value)) { if (is_array($value)) {
$val = array_search_recursive($search, $value, $partial, $strict); $val = array_search_recursive($search, $value, $partial, $strict);
@ -1803,14 +1865,15 @@ function array_search_recursive($search, $array, $partial = false, $strict = fal
/** /**
* cDie: Contenido die-alternative * cDie: Contenido die-alternative
* *
* @author unknown
*
* @param string $file File name (use __FILE__) * @param string $file File name (use __FILE__)
* @param string $line Line number (use __LINE__) * @param string $line Line number (use __LINE__)
* @param string $message Message to display * @param string $message Message to display
* @return void * @return void
* @author unknown
*
*/ */
function cDie($file, $line, $message) { function cDie(string $file, string $line, string $message): void
{
cError($file, $line, $message); cError($file, $line, $message);
die("$file $line: $message"); die("$file $line: $message");
} }
@ -1818,40 +1881,39 @@ function cDie($file, $line, $message) {
/** /**
* cWarning: Contenido warning * cWarning: Contenido warning
* *
* @param $file File name (use __FILE__) * @param string $file File name (use __FILE__)
* @param $line Line number (use __LINE__) * @param string $line Line number (use __LINE__)
* @param $message Message to display * @param string $message Message to display
*/ */
function cWarning($file, $line, $message) { function cWarning(string $file, string $line, string $message): void
{
trigger_error("$file $line: $message", E_USER_WARNING); trigger_error("$file $line: $message", E_USER_WARNING);
} }
/** /**
* cError: Contenido error * cError: Contenido error
* *
* @param $file File name (use __FILE__) * @param string $file File name (use __FILE__)
* @param $line Line number (use __LINE__) * @param string $line Line number (use __LINE__)
* @param $message Message to display * @param string $message Message to display
*/ */
function cError($file, $line, $message) { function cError(string $file, string $line, string $message): void
{
trigger_error("$file $line: $message", E_USER_ERROR); trigger_error("$file $line: $message", E_USER_ERROR);
} }
/** /**
* cDeprecated: Trigger deprecated stuff * cDeprecated: Trigger deprecated stuff
* *
* @author Ortwin Pinke <o.pinke@conlite.org>
* @param string $file File name (use __FILE__) * @param string $file File name (use __FILE__)
* @param string $line Line number (use __LINE__) * @param string $line Line number (use __LINE__)
* @param string $message Message to display * @param string $message Message to display
* @author Ortwin Pinke <o.pinke@conlite.org>
*/ */
function cDeprecated($file, $line, $message) { function cDeprecated(string $file, string $line, string $message): void
if (version_compare(PHP_VERSION, '5.3.0') >= 0) { {
trigger_error($file . " " . $line . ": " . $message, E_USER_DEPRECATED);
} else {
trigger_error("$file $line: $message", E_USER_WARNING); trigger_error("$file $line: $message", E_USER_WARNING);
} }
}
/** /**
* getNamedFrame: Returns the name of the numeric frame given * getNamedFrame: Returns the name of the numeric frame given
@ -1859,7 +1921,8 @@ function cDeprecated($file, $line, $message) {
* @param $frame Frame number * @param $frame Frame number
* @return string Canonical name of the frame * @return string Canonical name of the frame
*/ */
function getNamedFrame($frame) { function getNamedFrame($frame)
{
switch ($frame) { switch ($frame) {
case 1 : case 1 :
return ("left_top"); return ("left_top");
@ -1887,7 +1950,8 @@ function getNamedFrame($frame) {
* *
* @return int uuid for this measure process * @return int uuid for this measure process
*/ */
function startTiming($function, $parameters = array()) { function startTiming($function, $parameters = array())
{
global $_timings, $cfg; global $_timings, $cfg;
if ($cfg["debug"]["functiontiming"] == false) { if ($cfg["debug"]["functiontiming"] == false) {
@ -1915,7 +1979,8 @@ function startTiming($function, $parameters = array()) {
* *
* @param uuid int UUID which has been used for timing * @param uuid int UUID which has been used for timing
*/ */
function endAndLogTiming($uuid) { function endAndLogTiming($uuid)
{
global $_timings, $cfg; global $_timings, $cfg;
if ($cfg["debug"]["functiontiming"] == false) { if ($cfg["debug"]["functiontiming"] == false) {
@ -1959,7 +2024,8 @@ function endAndLogTiming($uuid) {
} }
// @TODO: it's better to create a instance of DB_ConLite class, the class constructor connects also to the database. // @TODO: it's better to create a instance of DB_ConLite class, the class constructor connects also to the database.
function checkMySQLConnectivity() { function checkMySQLConnectivity()
{
global $contenido_host, $contenido_database, $contenido_user, $contenido_password, $cfg; global $contenido_host, $contenido_database, $contenido_user, $contenido_password, $cfg;
if ($cfg["database_extension"] == "mysqli") { if ($cfg["database_extension"] == "mysqli") {
@ -2017,7 +2083,8 @@ function checkMySQLConnectivity() {
} }
} }
function notifyOnError($errortitle, $errormessage) { function notifyOnError($errortitle, $errormessage)
{
global $cfg; global $cfg;
$sFileNotify = $cfg['path']['conlite_logs'] . "notify.txt"; $sFileNotify = $cfg['path']['conlite_logs'] . "notify.txt";
@ -2060,7 +2127,8 @@ function notifyOnError($errortitle, $errormessage) {
* @param multi $mDefault default value * @param multi $mDefault default value
* @return boolean false if no array is given, void otherwise * @return boolean false if no array is given, void otherwise
*/ */
function cInitializeArrayKey(&$aArray, $sKey, $mDefault = "") { function cInitializeArrayKey(&$aArray, $sKey, $mDefault = "")
{
if (!is_array($aArray)) { if (!is_array($aArray)) {
if (isset($aArray)) { if (isset($aArray)) {
return false; return false;
@ -2089,7 +2157,8 @@ function cInitializeArrayKey(&$aArray, $sKey, $mDefault = "") {
* @version 1.0.0 * @version 1.0.0
* @author Holger Librenz * @author Holger Librenz
*/ */
function sendEncodingHeader($db, $cfg, $lang) { function sendEncodingHeader($db, $cfg, $lang)
{
if (array_key_exists("use_encoding", $_GET)) { if (array_key_exists("use_encoding", $_GET)) {
$use_encoding = trim(strip_tags($_GET["use_encoding"])); $use_encoding = trim(strip_tags($_GET["use_encoding"]));
} }
@ -2140,7 +2209,8 @@ function sendEncodingHeader($db, $cfg, $lang) {
* @param string $ip * @param string $ip
* @return boolean * @return boolean
*/ */
function IP_match($network, $mask, $ip) { function IP_match($network, $mask, $ip)
{
bcscale(3); bcscale(3);
$ip_long = ip2long($ip); $ip_long = ip2long($ip);
$mask_long = ip2long($network); $mask_long = ip2long($network);
@ -2173,63 +2243,67 @@ function IP_match($network, $mask, $ip) {
/** /**
* Wrapper for php-function htmlspecialchars * Wrapper for php-function htmlspecialchars
* *
* @author Ortwin Pinke <ortwinpinke@conlite.org>
* @since 2.3.0
* @uses htmlspecialchars php-function
*
* @param string $value * @param string $value
* @param int $flags * @param int $flags
* @param string $encoding default UTF-8 * @param string $encoding default UTF-8
* @return string Returns the converted string * @return string Returns the converted string
* @since 2.3.0
* @uses htmlspecialchars php-function
*
* @author Ortwin Pinke <ortwinpinke@conlite.org>
*/ */
function clHtmlSpecialChars(string $value, ?int $flags = ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401, string $encoding = 'UTF-8') { function clHtmlSpecialChars(string $value, ?int $flags = ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401, string $encoding = 'UTF-8')
{
return htmlspecialchars($value, $flags, $encoding); return htmlspecialchars($value, $flags, $encoding);
} }
/** /**
* Wrapper for php-function html_entity_decode * Wrapper for php-function html_entity_decode
* *
* @author Ortwin Pinke <ortwinpinke@conlite.org>
* @since 2.3.0
* @uses html_entity_decode php-function
*
* @param string $value * @param string $value
* @param int $flags * @param int $flags
* @param string $encoding default UTF-8 * @param string $encoding default UTF-8
* @return string Returns the decoded string * @return string Returns the decoded string
* @since 2.3.0
* @uses html_entity_decode php-function
*
* @author Ortwin Pinke <ortwinpinke@conlite.org>
*/ */
function clHtmlEntityDecode(string $value, ?int $flags = ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401, string $encoding = 'UTF-8') { function clHtmlEntityDecode(string $value, ?int $flags = ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401, string $encoding = 'UTF-8')
{
return html_entity_decode($value, $flags, $encoding); return html_entity_decode($value, $flags, $encoding);
} }
/** /**
* Wrapper for php-function htmlentities * Wrapper for php-function htmlentities
* *
* @author Ortwin Pinke <ortwinpinke@conlite.org>
* @since 2.3.0
* @uses htmlentities php-function
*
* @param string $value * @param string $value
* @param int $flags * @param int $flags
* @param string $encoding default UTF-8 * @param string $encoding default UTF-8
* @return string Returns the converted string * @return string Returns the converted string
* @since 2.3.0
* @uses htmlentities php-function
*
* @author Ortwin Pinke <ortwinpinke@conlite.org>
*/ */
function clHtmlEntities(string $value,?int $flags = ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401, string $encoding = 'UTF-8') { function clHtmlEntities(string $value, ?int $flags = ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401, string $encoding = 'UTF-8')
{
return htmlentities($value, $flags, $encoding); return htmlentities($value, $flags, $encoding);
} }
/** /**
* Wrapper for php-function get_html_translation_table * Wrapper for php-function get_html_translation_table
* *
* @author Ortwin Pinke <ortwinpinke@conlite.org>
* @since 2.3.0
* @uses get_html_translation_table php-function
*
* @param int $table * @param int $table
* @param int $flags * @param int $flags
* @param string $encoding * @param string $encoding
* @return array * @return array
* @since 2.3.0
* @uses get_html_translation_table php-function
*
* @author Ortwin Pinke <ortwinpinke@conlite.org>
*/ */
function clGetHtmlTranslationTable(int $table = HTML_SPECIALCHARS, int $flags = ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401, string $encoding = "UTF-8") { function clGetHtmlTranslationTable(int $table = HTML_SPECIALCHARS, int $flags = ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401, string $encoding = "UTF-8")
{
return get_html_translation_table($table, $flags, $encoding); return get_html_translation_table($table, $flags, $encoding);
} }