Source of file api.compat.php
Size: 5,355 Bytes - Last Modified: 2024-04-27T15:26:05+03:00
/tmp/current_snapshot/api/libs/api.compat.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257 | <?php /** * Framework abstraction functions and wrappers for old code backward compatibility */ if (!function_exists('show_error')) { /** * Shows default error notice * * @param string $data */ function show_error($data) { show_window('Error', $data); } } /** * Fast debug text data output * * @param string $data */ function deb($data) { show_window('DEBUG', $data); } /** * Fast debug output of array * * @param string $data */ function debarr($data) { $result = print_r($data, true); $result = '<pre>' . $result . '</pre>'; show_window('DEBUG', $result); } /** * Returns current date and time in mysql DATETIME view * * @return string */ function curdatetime() { $currenttime = date("Y-m-d H:i:s"); return($currenttime); } /** * returns current time in mysql DATETIME view * * @return string */ function curtime() { $currenttime = date("H:i:s"); return($currenttime); } /** * Returns current date in mysql DATETIME view * * @return string */ function curdate() { $currentdate = date("Y-m-d"); return($currentdate); } /** * Returns current year-month in mysql DATETIME view * * @return string */ function curmonth() { $currentmonth = date("Y-m"); return($currentmonth); } /** * Returns previous year-month in mysql DATETIME view * * @return string */ function prevmonth() { $result = date("Y-m", strtotime("-1 months")); return ($result); } /** * Returns current year as just Y * * @return string */ function curyear() { $currentyear = date("Y"); return($currentyear); } /** * Just system logging subroutine * * @param string $event */ function log_register($event) { $admin_login = whoami(); @$ip = $_SERVER['REMOTE_ADDR']; if (!$ip) { $ip = '127.0.0.1'; } $current_time = curdatetime(); $event = mysql_real_escape_string($event); $query = "INSERT INTO `weblogs` (`id`,`date`,`admin`,`ip`,`event`) VALUES(NULL,'" . $current_time . "','" . $admin_login . "','" . $ip . "','" . $event . "')"; nr_query($query); } if (!function_exists('stg_putlogevent')) { /** * stg_putlogevent dummy wrapper for log_register() - only for backward compat * * @param string $event */ function stg_putlogevent($event) { log_register($event); } } if (!function_exists('__')) { /** * Dummy i18n function * * @param string $str * @return string */ function __($str) { return($str); } } if (!function_exists('show_window')) { /** * Replace for system content output * * @param string $title * @param string $data * @param string $align */ function show_window($title, $data, $align = "left") { $result = ' <table width="100%" border="0" id="window"> <tr> <td align="center"> <b>' . $title . '</b> </td> </tr> <tr> <td align="' . $align . '"> ' . $data . ' </td> </tr> </table> '; print($result); } } /** * Check for right via module * * @global object $system * @param string $right * @return bool */ function cfr($right) { global $system; // uncomment following to run phpunit tests (realy ugly hack, i know) // run as: phpunit --bootstrap puboot.php tests // if (empty($system)) {@$system = new rcms_system(); } if ($system->checkForRight($right)) { return(true); } else { return(false); } } /** * Replace for $system->user['username'] * * @global object $system * @return string */ function whoami() { global $system; @$mylogin = $system->user['username']; if (empty($mylogin)) { $mylogin = 'external'; } return($mylogin); } if (!function_exists('rcms_redirect')) { /** * Shows redirection javascript. * * @param string $url * @param bool $header */ function rcms_redirect($url, $header = false) { if ($header) { @header('Location: ' . $url); } else { echo '<script language="javascript">document.location.href="' . $url . '";</script>'; } } } if (!function_exists('each2')) { /** * (PHP 4, PHP 5, PHP 7)<br/> * This function has been DEPRECATED as of PHP 7.2.0, and REMOVED as of PHP 8.0.0. * Return the current key and value pair from an array and advance the array cursor * @link http://php.net/manual/en/function.each.php * @param array $array <p> * The input array. * </p> * @return array the current key and value pair from the array * <i>array</i>. This pair is returned in a four-element * array, with the keys 0, 1, * key, and value. Elements * 0 and key contain the key name of * the array element, and 1 and value * contain the data. * </p> * <p> * If the internal pointer for the array points past the end of the * array contents, <b>each</b> returns * <b>FALSE</b>. */ function each2($arr) { $key = key($arr); $result = ($key === null) ? false : array($key, current($arr), 'key' => $key, 'value' => current($arr)); next($arr); return $result; } } |