api.compat.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <?php
  2. /**
  3. * Returns current date and time in mysql DATETIME view Y-m-d H:i:s
  4. *
  5. * @return string
  6. */
  7. function curdatetime() {
  8. $currenttime = date("Y-m-d H:i:s");
  9. return ($currenttime);
  10. }
  11. /**
  12. * Returns current date in mysql DATETIME view
  13. *
  14. * @return string
  15. */
  16. function curdate() {
  17. $currentdate = date("Y-m-d");
  18. return ($currentdate);
  19. }
  20. /**
  21. * Returns current year-month in mysql DATETIME view
  22. *
  23. * @return string
  24. */
  25. function curmonth() {
  26. $currentmonth = date("Y-m");
  27. return ($currentmonth);
  28. }
  29. /**
  30. * Returns current year
  31. *
  32. * @return string
  33. */
  34. function curyear() {
  35. $currentyear = date("Y");
  36. return ($currentyear);
  37. }
  38. if (!function_exists('__')) {
  39. /**
  40. * Dummy i18n function. Yep in this case it returns the same string.
  41. *
  42. * @param string $str
  43. *
  44. * @return string
  45. */
  46. function __($str) {
  47. return ($str);
  48. }
  49. }
  50. if (!function_exists('show_window')) {
  51. /**
  52. * Dummy replacement function for content output
  53. *
  54. * @param string $title
  55. * @param sting $data
  56. * @param string $align
  57. *
  58. * @return void
  59. */
  60. function show_window($title, $data, $align = "left") {
  61. $result = '
  62. <table width="100%" border="0" id="window">
  63. <tr>
  64. <td align="center">
  65. <b>' . $title . '</b>
  66. </td>
  67. </tr>
  68. <tr>
  69. <td align="' . $align . '">
  70. ' . $data . '
  71. </td>
  72. </tr>
  73. </table>
  74. ';
  75. print($result);
  76. }
  77. }
  78. if (!function_exists('show_error')) {
  79. /**
  80. * Dummy replacement for error notices
  81. *
  82. * @param string $data
  83. *
  84. * @return void
  85. */
  86. function show_error($data) {
  87. show_window('Error', $data);
  88. }
  89. }
  90. /**
  91. * Fast debug output
  92. *
  93. * @param string $data
  94. *
  95. * @return void
  96. */
  97. function deb($data) {
  98. show_window('DEBUG', $data);
  99. }
  100. /**
  101. * Fast debug output of array
  102. *
  103. * @param array $data
  104. *
  105. * @return void
  106. */
  107. function debarr($data) {
  108. $result = print_r($data, true);
  109. $result = '<pre>' . $result . '</pre>';
  110. show_window('DEBUG', $result);
  111. }
  112. if (!function_exists('rcms_redirect')) {
  113. /**
  114. * Dummy redirect function
  115. *
  116. * @param string $url
  117. * @param bool $header
  118. *
  119. * @return void
  120. */
  121. function rcms_redirect($url, $header = false) {
  122. if ($header) {
  123. @header('Location: ' . $url);
  124. } else {
  125. echo '<script language="javascript">document.location.href="' . $url . '";</script>';
  126. }
  127. }
  128. }
  129. if (!function_exists('ispos_array')) {
  130. /**
  131. * Checks for substring in a string or array of strings
  132. *
  133. * @param string $string
  134. * @param string|array $search
  135. *
  136. * @return bool
  137. */
  138. function ispos_array($string, $search) {
  139. if (is_array($search)) {
  140. foreach ($search as $eachStr) {
  141. if (strpos($string, $eachStr) !== false) {
  142. return (true);
  143. }
  144. }
  145. return (false);
  146. } else {
  147. if (strpos($string, $search) === false) {
  148. return (false);
  149. } else {
  150. return (true);
  151. }
  152. }
  153. }
  154. }