PageRenderTime 76ms CodeModel.GetById 35ms RepoModel.GetById 0ms app.codeStats 0ms

/update_07-01-04/includes/theme_functions_include.php

https://github.com/frostzhenya/php
PHP | 246 lines | 201 code | 28 blank | 17 comment | 76 complexity | 69356198e19d3ca68de5e25f84d7edab MD5 | raw file
  1. <?php
  2. /*-------------------------------------------------------+
  3. | PHP-Fusion Content Management System
  4. | Copyright (C) 2002 - 2010 Nick Jones
  5. | http://www.php-fusion.co.uk/
  6. +--------------------------------------------------------+
  7. | Filename: theme_functions_include.php
  8. | Author: Nick Jones (Digitanium)
  9. +--------------------------------------------------------+
  10. | This program is released as free software under the
  11. | Affero GPL license. You can redistribute it and/or
  12. | modify it under the terms of this license which you
  13. | can read by viewing the included agpl.txt or online
  14. | at www.gnu.org/licenses/agpl.html. Removal of this
  15. | copyright header is strictly prohibited without
  16. | written permission from the original author(s).
  17. +--------------------------------------------------------*/
  18. if (!defined("IN_FUSION")) { die("Access Denied"); }
  19. function check_panel_status($side) {
  20. global $settings;
  21. $exclude_list = "";
  22. if ($side == "left") {
  23. if ($settings['exclude_left'] != "") {
  24. $exclude_list = explode("\r\n", $settings['exclude_left']);
  25. }
  26. } elseif ($side == "upper") {
  27. if ($settings['exclude_upper'] != "") {
  28. $exclude_list = explode("\r\n", $settings['exclude_upper']);
  29. }
  30. } elseif ($side == "lower") {
  31. if ($settings['exclude_lower'] != "") {
  32. $exclude_list = explode("\r\n", $settings['exclude_lower']);
  33. }
  34. } elseif ($side == "right") {
  35. if ($settings['exclude_right'] != "") {
  36. $exclude_list = explode("\r\n", $settings['exclude_right']);
  37. }
  38. }
  39. if (is_array($exclude_list)) {
  40. $script_url = explode("/", $_SERVER['PHP_SELF']);
  41. $url_count = count($script_url);
  42. $base_url_count = substr_count(BASEDIR, "/")+1;
  43. $match_url = "";
  44. while ($base_url_count != 0) {
  45. $current = $url_count - $base_url_count;
  46. $match_url .= "/".$script_url[$current];
  47. $base_url_count--;
  48. }
  49. if (!in_array($match_url, $exclude_list) && !in_array($match_url.(FUSION_QUERY ? "?".FUSION_QUERY : ""), $exclude_list)) {
  50. return true;
  51. } else {
  52. return false;
  53. }
  54. } else {
  55. return true;
  56. }
  57. }
  58. function showbanners() {
  59. global $settings;
  60. ob_start();
  61. if ($settings['sitebanner2']) {
  62. eval("?><div style='float: right;'>".stripslashes($settings['sitebanner2'])."</div>\n<?php ");
  63. }
  64. if ($settings['sitebanner1']) {
  65. eval("?>".stripslashes($settings['sitebanner1'])."\n<?php ");
  66. } elseif ($settings['sitebanner']) {
  67. echo "<a href='".$settings['siteurl']."'><img src='".BASEDIR.$settings['sitebanner']."' alt='".$settings['sitename']."' style='border: 0;' /></a>\n";
  68. } else {
  69. echo "<a href='".$settings['siteurl']."'>".$settings['sitename']."</a>\n";
  70. }
  71. $output = ob_get_contents();
  72. ob_end_clean();
  73. return $output;
  74. }
  75. function showsublinks($sep = "&middot;", $class = "") {
  76. $sres = dbquery(
  77. "SELECT link_name, link_url, link_window, link_visibility FROM ".DB_SITE_LINKS."
  78. WHERE link_position='2' OR link_position='3' ORDER BY link_order"
  79. );
  80. if (dbrows($sres)) {
  81. $i = 0;
  82. $res = "<ul>\n";
  83. while ($sdata = dbarray($sres)) {
  84. if ($sdata['link_url'] != "---" && checkgroup($sdata['link_visibility'])) {
  85. $link_target = $sdata['link_window'] == "1" ? " target='_blank'" : "";
  86. $li_class = ($i == 0 ? " class='first-link".($class ? " $class" : "")."'" : ($class ? " class='$class'" : ""));
  87. if (strstr($sdata['link_url'], "http://") || strstr($sdata['link_url'], "https://")) {
  88. $res .= "<li".$li_class.">".$sep."<a href='".$sdata['link_url']."'$link_target><span>".parseubb($sdata['link_name'], "b|i|u|color")."</span></a></li>\n";
  89. } else {
  90. $res .= "<li".$li_class.">".$sep."<a href='".BASEDIR.$sdata['link_url']."'$link_target><span>".parseubb($sdata['link_name'], "b|i|u|color")."</span></a></li>\n";
  91. }
  92. $i++;
  93. }
  94. }
  95. $res .= "</ul>\n";
  96. return $res;
  97. }
  98. }
  99. function showsubdate() {
  100. global $settings;
  101. return ucwords(showdate($settings['subheaderdate'], time()));
  102. }
  103. function newsposter($info, $sep = "", $class = "") {
  104. global $locale; $res = "";
  105. $link_class = $class ? " class='$class' " : "";
  106. $res = THEME_BULLET." <span ".$link_class.">".profile_link($info['user_id'], $info['user_name'], $info['user_status'])."</span> ";
  107. $res .= $locale['global_071'].showdate("newsdate", $info['news_date']);
  108. $res .= $info['news_ext'] == "y" || $info['news_allow_comments'] ? $sep."\n" : "\n";
  109. return "<!--news_poster-->".$res;
  110. }
  111. function newsopts($info, $sep, $class = "") {
  112. global $locale, $settings; $res = "";
  113. $link_class = $class ? " class='$class' " : "";
  114. if (!isset($_GET['readmore']) && $info['news_ext'] == "y") $res = "<a href='news.php?readmore=".$info['news_id']."'".$link_class.">".$locale['global_072']."</a> ".$sep." ";
  115. if ($info['news_allow_comments'] && $settings['comments_enabled'] == "1") { $res .= "<a href='news.php?readmore=".$info['news_id']."#comments'".$link_class.">".$info['news_comments'].($info['news_comments'] == 1 ? $locale['global_073b'] : $locale['global_073'])."</a> ".$sep." "; }
  116. if ($info['news_ext'] == "y" || ($info['news_allow_comments'] && $settings['comments_enabled'] == "1")) { $res .= $info['news_reads'].$locale['global_074']."\n ".$sep; }
  117. $res .= "<a href='print.php?type=N&amp;item_id=".$info['news_id']."'><img src='".get_image("printer")."' alt='".$locale['global_075']."' style='vertical-align:middle;border:0;' /></a>\n";
  118. return "<!--news_opts-->".$res;
  119. }
  120. function newscat($info, $sep = "", $class = "") {
  121. global $locale; $res = "";
  122. $link_class = $class ? " class='$class' " : "";
  123. $res .= $locale['global_079'];
  124. if ($info['cat_id']) {
  125. $res .= "<a href='news_cats.php?cat_id=".$info['cat_id']."'$link_class>".$info['cat_name']."</a>";
  126. } else {
  127. $res .= "<a href='news_cats.php?cat_id=0'$link_class>".$locale['global_080']."</a>";
  128. }
  129. return "<!--news_cat-->".$res." $sep ";
  130. }
  131. function articleposter($info, $sep = "", $class = "") {
  132. global $locale, $settings; $res = "";
  133. $link_class = $class ? " class='$class' " : "";
  134. $res = THEME_BULLET." ".$locale['global_070']."<span ".$link_class.">".profile_link($info['user_id'], $info['user_name'], $info['user_status'])."</span>\n";
  135. $res .= $locale['global_071'].showdate("newsdate", $info['article_date']);
  136. $res .= ($info['article_allow_comments'] && $settings['comments_enabled'] == "1" ? $sep."\n" : "\n");
  137. return "<!--article_poster-->".$res;
  138. }
  139. function articleopts($info, $sep) {
  140. global $locale, $settings; $res = "";
  141. if ($info['article_allow_comments'] && $settings['comments_enabled'] == "1") { $res = "<a href='articles.php?article_id=".$info['article_id']."#comments'>".$info['article_comments'].($info['article_comments'] == 1 ? $locale['global_073b'] : $locale['global_073'])."</a> ".$sep."\n"; }
  142. $res .= $info['article_reads'].$locale['global_074']." ".$sep."\n";
  143. $res .= "<a href='print.php?type=A&amp;item_id=".$info['article_id']."'><img src='".get_image("printer")."' alt='".$locale['global_075']."' style='vertical-align:middle;border:0;' /></a>\n";
  144. return "<!--article_opts-->".$res;
  145. }
  146. function articlecat($info, $sep = "", $class = "") {
  147. global $locale; $res = "";
  148. $link_class = $class ? " class='$class' " : "";
  149. $res .= $locale['global_079'];
  150. if ($info['cat_id']) {
  151. $res .= "<a href='articles.php?cat_id=".$info['cat_id']."'$link_class>".$info['cat_name']."</a>";
  152. } else {
  153. $res .= "<a href='articles.php?cat_id=0'$link_class>".$locale['global_080']."</a>";
  154. }
  155. return "<!--article_cat-->".$res." $sep ";
  156. }
  157. function itemoptions($item_type, $item_id) {
  158. global $locale, $aidlink; $res = "";
  159. if ($item_type == "N") {
  160. if (iADMIN && checkrights($item_type)) { $res .= "<!--article_news_opts--> &middot; <a href='".ADMIN."news.php".$aidlink."&amp;action=edit&amp;news_id=".$item_id."'><img src='".get_image("edit")."' alt='".$locale['global_076']."' title='".$locale['global_076']."' style='vertical-align:middle;border:0;' /></a>\n"; }
  161. } elseif ($item_type == "A") {
  162. if (iADMIN && checkrights($item_type)) { $res .= "<!--article_admin_opts--> &middot; <a href='".ADMIN."articles.php".$aidlink."&amp;action=edit&amp;article_id=".$item_id."'><img src='".get_image("edit")."' alt='".$locale['global_076']."' title='".$locale['global_076']."' style='vertical-align:middle;border:0;' /></a>\n"; }
  163. }
  164. return $res;
  165. }
  166. function showrendertime($queries = true) {
  167. global $locale, $mysql_queries_count;
  168. $res = sprintf($locale['global_172'], substr((get_microtime() - START_TIME),0,4));
  169. $res .= ($queries ? " - $mysql_queries_count ".$locale['global_173'] : "");
  170. return $res;
  171. }
  172. function showcopyright($class = "") {
  173. $link_class = $class ? " class='$class' " : "";
  174. $res = "Powered by <a href='http://www.php-fusion.co.uk'".$link_class.">PHP-Fusion</a> copyright &copy; 2002 - ".date("Y")." by Nick Jones.<br />\n";
  175. $res .= "Released as free software without warranties under <a href='http://www.fsf.org/licensing/licenses/agpl-3.0.html'".$link_class.">GNU Affero GPL</a> v3.\n";
  176. return $res;
  177. }
  178. function showcounter() {
  179. global $locale, $settings;
  180. if ($settings['visitorcounter_enabled']) {
  181. return "<!--counter-->".number_format($settings['counter'])." ".($settings['counter'] == 1 ? $locale['global_170'] : $locale['global_171']);
  182. } else {
  183. return "";
  184. }
  185. }
  186. function panelbutton($state, $bname) {
  187. $bname = preg_replace("/[^a-zA-Z0-9\s]/", "_", $bname);
  188. if (isset($_COOKIE["fusion_box_".$bname])) {
  189. if ($_COOKIE["fusion_box_".$bname] == "none") {
  190. $state = "off";
  191. } else {
  192. $state = "on";
  193. }
  194. }
  195. return "<img src='".get_image("panel_".($state == "on" ? "off" : "on"))."' id='b_$bname' class='panelbutton' alt='' onclick=\"javascript:flipBox('$bname')\" />";
  196. }
  197. function panelstate($state, $bname) {
  198. $bname = preg_replace("/[^a-zA-Z0-9\s]/", "_", $bname);
  199. if (isset($_COOKIE["fusion_box_".$bname])) {
  200. if ($_COOKIE["fusion_box_".$bname] == "none") {
  201. $state = "off";
  202. } else {
  203. $state = "on";
  204. }
  205. }
  206. return "<div id='box_$bname'".($state == "off" ? " style='display:none'" : "").">\n";
  207. }
  208. // v6 compatibility
  209. function opensidex($title, $state = "on") {
  210. openside($title, true, $state);
  211. }
  212. function closesidex() {
  213. closeside();
  214. }
  215. function tablebreak() {
  216. return true;
  217. }
  218. ?>