PageRenderTime 24ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 1ms

/admin/lib/functions.php

http://viewpanelblogger.googlecode.com/
PHP | 413 lines | 351 code | 32 blank | 30 comment | 63 complexity | d2920ef99a66ce70c4fe0ab2ad93bb4c MD5 | raw file
  1. <?php
  2. /*******************************************************************************
  3. ********************************************************************************
  4. *** ***
  5. *** Filename: functions.php ***
  6. *** Use: ***
  7. *** Author: Al Wilde ***
  8. *** ***
  9. ********************************************************************************
  10. *******************************************************************************/
  11. //Security Functions
  12. function checkrank($aboverank, $operator = '==') {
  13. $sql = "SELECT rank FROM users WHERE username = '".$_COOKIE['View_Panel_ID']."'";
  14. $query = mysql_query($sql);
  15. while($row = mysql_fetch_array($query)){
  16. $user_rank = $row['rank'];
  17. }
  18. eval ('$rank_check = $aboverank' . $operator . '$user_rank ;') ;
  19. if ($rank_check) {
  20. } else {
  21. header("Location: panel.php?page=accessdenied-show");
  22. }
  23. }
  24. function checklogin() {
  25. }
  26. //Destroy's Directory and all files / folders in it
  27. function destroydir ($dir) {
  28. if ($handle = opendir($dir))
  29. {
  30. $array = array();
  31. while (false !== ($file = readdir($handle))) {
  32. if ($file != "." && $file != "..") {
  33. if(is_dir($dir.$file))
  34. {
  35. if(!@rmdir($dir.$file))
  36. {
  37. destroydir($dir.$file.'/');
  38. }
  39. }
  40. else
  41. {
  42. @unlink($dir.$file);
  43. }
  44. }
  45. }
  46. closedir($handle);
  47. @rmdir($dir);
  48. }
  49. }
  50. function copydir( $source, $target ) {
  51. if ( is_dir( $source ) ) {
  52. @mkdir( $target );
  53. $d = dir( $source );
  54. while ( FALSE !== ( $entry = $d->read() ) ) {
  55. if ( $entry == '.' || $entry == '..' ) {
  56. continue;
  57. }
  58. $Entry = $source . '/' . $entry;
  59. if ( is_dir( $Entry ) ) {
  60. copydir( $Entry, $target . '/' . $entry );
  61. continue;
  62. }
  63. copy( $Entry, $target . '/' . $entry );
  64. }
  65. $d->close();
  66. }else {
  67. copy( $source, $target );
  68. }
  69. }
  70. function installedext($extension) {
  71. $installed = get_loaded_extensions();
  72. foreach($installed as $install) {
  73. if(strtoupper($extension) == strtoupper($install)) {
  74. return true;
  75. }
  76. }
  77. return false;
  78. }
  79. function View_Panel_Page_Lister() {
  80. $result = mysql_query("SELECT * FROM blog_lister");
  81. while($row = mysql_fetch_array($result)) {
  82. echo "<option>".$row['pageName']."</option>";
  83. }
  84. mysql_close($con);
  85. }
  86. function View_Panel_Blog_Lister($output_get = 'blog', $secondget = '') {
  87. $result = mysql_query("SELECT * FROM blog_lister");
  88. echo "<option></option>";
  89. while($row = mysql_fetch_array($result)) {
  90. echo "<option ";
  91. if (isset($_GET['blog'])) {
  92. if ($row['pageName'] == $_GET['blog']) {
  93. echo "selected='selected '";
  94. }
  95. }
  96. echo "value='".$_SERVER['SCRIPT_NAME']."?page=".$_GET[page]."&".$output_get."=".urlencode($row['pageName'])."&".$secondget."'>".$row['pageName']."</option>";
  97. }
  98. mysql_close($con);
  99. }
  100. function View_Panel_Theme_Current($blog) {
  101. $blog = addslashes($blog);
  102. $result = mysql_query("SELECT themeid FROM blog_lister WHERE pageName = '".$blog."'");
  103. while($row = mysql_fetch_array($result)) {
  104. $vp_themeinformation = array("id"=>$row['themeid'],"name"=>$row['themename'],"author"=>$row['themeauthor']);
  105. return($vp_themeinformation);
  106. }
  107. }
  108. function View_Panel_Theme_Lister() {
  109. $result = mysql_query("SELECT * FROM viewpanel_themes");
  110. while($row = mysql_fetch_array($result)) {
  111. echo "<option name='".$row['id']."' name='".$row['themename']."'>".$row['themename']."</option>";
  112. }
  113. }
  114. function get_num_users() {
  115. $result = mysql_query("SELECT * FROM users");
  116. $num_rows = mysql_num_rows($result);
  117. echo "$num_rows\n";
  118. }
  119. function dirsize($path){
  120. /*if(!file_exists($path)) return 0;
  121. if(is_file($path)) return filesize($path);
  122. $ret = 0;
  123. if(empty($path))
  124. {
  125. return false;
  126. echo "Not Supported On Server.";
  127. }
  128. foreach(glob($path."/*") as $fn)
  129. $ret += dirsize($fn);
  130. return $ret." bytes";*/
  131. }
  132. function View_Panel_Get_Siteurl() {
  133. $result = mysql_query("SELECT siteurl FROM vpmainsettings");
  134. while($row = mysql_fetch_array($result)) {
  135. echo $row['siteurl'];
  136. }
  137. }
  138. function View_Panel_Get_Version() {
  139. $current = file_get_contents('http://streeteye.info/viewpanel/versiontracker/viewpanelversiontracker.php');
  140. if ($current == $panelversion) {
  141. return true;
  142. } else {
  143. return false;
  144. }
  145. }
  146. function View_Panel_File_Lister($username = '') {
  147. }
  148. //Blog Functions
  149. function out_intro($border = '0', $introclass = 'introduction') {
  150. include("lib/config.php");
  151. //Get info from the header file (if any)
  152. if (isset($GLOBALS['header_override']['introduction']['border'])) {
  153. $border = $GLOBALS['header_override']['introduction']['border'];
  154. }
  155. if (isset($GLOBALS['header_override']['introduction']['class'])) {
  156. $introclass = $GLOBALS['header_override']['introduction']['class'];
  157. }
  158. mysql_connect($GLOBALS['localdatabase'], $GLOBALS['dbuser'], $GLOBALS['decryptpass']);
  159. mysql_select_db($GLOBALS['$dbname']);
  160. $query = "SELECT introduction FROM introductions WHERE blogname='". $GLOBALS['tablenameclean'] ."'";
  161. $output = mysql_query($query) or die(mysql_error());
  162. while($row = mysql_fetch_array($output)){
  163. $intro_out = stripslashes($row[introduction]);
  164. echo "<table border='".$border."' class='".$introclass."'>";
  165. echo "<tr>";
  166. echo "<td>".$row[introduction]."</td>";
  167. echo "</tr>";
  168. echo "</table>";
  169. }
  170. }
  171. function out_expanded($border = '0', $author = 'Posted by', $date = 'on', $layout_1 = 'post', $layout_2 = 'author', $titleclass = 'posttitle', $postclass = 'blogposts', $author_timeclass = 'authorandtime') {
  172. if (isset($_GET[postid])) {
  173. include("lib/config.php");
  174. //Get info from the header file (if any)
  175. if (isset($GLOBALS['header_override']['expanded']['border'])) {
  176. $border = $GLOBALS['header_override']['expanded']['border'];
  177. }
  178. if (isset($GLOBALS['header_override']['expanded']['author'])) {
  179. $author = $GLOBALS['header_override']['expanded']['author'];
  180. }
  181. if (isset($GLOBALS['header_override']['expanded']['date'])) {
  182. $date = $GLOBALS['header_override']['expanded']['date'];
  183. }
  184. if (isset($GLOBALS['header_override']['expanded']['layout1'])) {
  185. $layout_1 = $GLOBALS['header_override']['expanded']['layout1'];
  186. }
  187. if (isset($GLOBALS['header_override']['expanded']['layout2'])) {
  188. $layout_2 = $GLOBALS['header_override']['expanded']['layout2'];
  189. }
  190. if (isset($GLOBALS['header_override']['expanded']['titleclass'])) {
  191. $titleclass = $GLOBALS['header_override']['expanded']['titleclass'];
  192. }
  193. if (isset($GLOBALS['header_override']['expanded']['postclass'])) {
  194. $postclass = $GLOBALS['header_override']['expanded']['postclass'];
  195. }
  196. if (isset($GLOBALS['header_override']['expanded']['authorandtimeclass'])) {
  197. $author_timeclass = $GLOBALS['header_override']['expanded']['authorandtimeclass'];
  198. }
  199. mysql_connect($GLOBALS['localdatabase'], $GLOBALS['dbuser'], $GLOBALS['decryptpass']);
  200. mysql_select_db($GLOBALS['$dbname']);
  201. $query = "SELECT posttitle,post,author,date FROM ". $GLOBALS['tablenameclean'] ." WHERE id = $_GET[postid]";
  202. $output = mysql_query($query) or die(mysql_error());
  203. while($row = mysql_fetch_array($output)){
  204. $title_out = stripslashes($row[posttitle]);
  205. $content_out = stripslashes($row[post]);
  206. $author_out = stripslashes($row[author]);
  207. echo "<table border='".$border."' class='".$titleclass."'>";
  208. echo "<tr>";
  209. echo "<td>".$title_out."</td>";
  210. echo "</tr>";
  211. echo "</table>";
  212. if ($layout_1 = "post") {
  213. echo "<table border='".$border."' class='".$postclass."'>";
  214. echo "<tr>";
  215. echo "<td>".$content_out."</td>";
  216. echo "</tr>";
  217. echo "</table>";
  218. } else {
  219. $authortime_combine = "".$author." ".$author_out." ".$date." ".$row['date'];
  220. echo "<table border='".$border."' class='".$author_timeclass."'>";
  221. echo "<tr>";
  222. echo "<td>".$authortime_combine."</td>";
  223. echo "</tr>";
  224. echo "</table>";
  225. } if ($layout_2 = "author") {
  226. $authortime_combine = "".$author." ".$author_out." ".$date." ".$row['date'];
  227. echo "<table border='".$border."' class='".$author_timeclass."'>";
  228. echo "<tr>";
  229. echo "<td>".$authortime_combine."</td>";
  230. echo "</tr>";
  231. echo "</table>";
  232. } else {
  233. echo "<table border='".$border."' class='".$postclass."'>";
  234. echo "<tr>";
  235. echo "<td>".$content_out."</td>";
  236. echo "</tr>";
  237. echo "</table>";
  238. }
  239. }
  240. }
  241. }
  242. function out_posts($border = '0', $author = 'Posted by', $date = 'on', $layout_1 = 'post', $layout_2 = 'author', $titleclass = 'posttitle', $postclass = 'blogposts', $author_timeclass = 'authorandtime', $charsper = '40') {
  243. if (!isset($_GET[postid])) {
  244. include("lib/config.php");
  245. //Get info from the header file (if any)
  246. if (isset($GLOBALS['header_override']['postlist']['border'])) {
  247. $border = $GLOBALS['header_override']['postlist']['border'];
  248. }
  249. if (isset($GLOBALS['header_override']['postlist']['author'])) {
  250. $author = $GLOBALS['header_override']['postlist']['author'];
  251. }
  252. if (isset($GLOBALS['header_override']['postlist']['date'])) {
  253. $date = $GLOBALS['header_override']['postlist']['date'];
  254. }
  255. if (isset($GLOBALS['header_override']['postlist']['layout1'])) {
  256. $layout_1 = $GLOBALS['header_override']['postlist']['layout1'];
  257. }
  258. if (isset($GLOBALS['header_override']['postlist']['layout2'])) {
  259. $layout_2 = $GLOBALS['header_override']['postlist']['layout2'];
  260. }
  261. if (isset($GLOBALS['header_override']['postlist']['titleclass'])) {
  262. $titleclass = $GLOBALS['header_override']['postlist']['titleclass'];
  263. }
  264. if (isset($GLOBALS['header_override']['postlist']['postclass'])) {
  265. $postclass = $GLOBALS['header_override']['postlist']['postclass'];
  266. }
  267. if (isset($GLOBALS['header_override']['postlist']['authorandtimeclass'])) {
  268. $author_timeclass = $GLOBALS['header_override']['postlist']['authorandtimeclass'];
  269. }
  270. if (isset($GLOBALS['header_override']['postlist']['characterlimit'])) {
  271. $charsper = $GLOBALS['header_override']['postlist']['characterlimit'];
  272. }
  273. mysql_connect($GLOBALS['localdatabase'], $GLOBALS['dbuser'], $GLOBALS['decryptpass']);
  274. mysql_select_db($GLOBALS['$dbname']);
  275. $query = "SELECT id,posttitle,post,author,date FROM ". $GLOBALS['tablenameclean'] ." ORDER BY id DESC";
  276. $output = mysql_query($query) or die(mysql_error());
  277. while($row = mysql_fetch_array($output)){
  278. $title_out = stripslashes($row[posttitle]);
  279. $content_out = stripslashes($row[post]);
  280. $author_out = stripslashes($row[author]);
  281. $postcontent_fetched = $content_out;
  282. if (strlen($postcontent_fetched) > $charsper) {;
  283. $postcontent_fetched = substr($postcontent_fetched, 0, $charsper);
  284. $postcontent_fetched = $postcontent_fetched."...";
  285. }
  286. echo "<table border='".$border."' class='".$titleclass."'>";
  287. echo "<tr>";
  288. echo "<td>".$title_out."</td>";
  289. echo "</tr>";
  290. echo "</table>";
  291. if ($layout_1 = "post") {
  292. echo "<table border='".$border."' class='".$postclass."'>";
  293. echo "<tr>";
  294. echo "<td>".$postcontent_fetched."</td>";
  295. echo "</tr>";
  296. echo "</table>";
  297. } else {
  298. $authortime_combine = "".$author." ".$author_out." ".$date." ".$row['date'];
  299. echo "<table border='".$border."' class='".$author_timeclass."'>";
  300. echo "<tr>";
  301. echo "<td>".$authortime_combine."</td>";
  302. echo "</tr>";
  303. echo "</table>";
  304. } if ($layout_2 = "author") {
  305. $authortime_combine = "".$author." ".$author_out." ".$date." ".$row['date'];
  306. echo "<table border='".$border."' class='".$author_timeclass."'>";
  307. echo "<tr>";
  308. echo "<td>".$authortime_combine." | <a href='?postid=".$row['id']."'>Readmore</a></td>";
  309. echo "</tr>";
  310. echo "</table>";
  311. } else {
  312. echo "<table border='".$border."' class='".$postclass."'>";
  313. echo "<tr>";
  314. echo "<td>".$postcontent_fetched."</td>";
  315. echo "</tr>";
  316. echo "</table>";
  317. }
  318. }
  319. }
  320. }
  321. function out_blogtitle($headertagstart = '<h1>', $headertagend = '</h1>', $logoimage=NULL) {
  322. //Get info from the header file (if any)
  323. if (isset($GLOBALS['header_override']['blogtitle']['firsttag'])) {
  324. $headertagstart = $GLOBALS['header_override']['introduction']['firsttag'];
  325. }
  326. if (isset($GLOBALS['header_override']['blogtitle']['secondtag'])) {
  327. $headertagend = $GLOBALS['header_override']['introduction']['secondtag'];
  328. }
  329. if (isset($GLOBALS['header_override']['blogtitle']['image'])) {
  330. $logoimage = $GLOBALS['header_override']['introduction']['image'];
  331. }
  332. if (isset($logoimage)) {
  333. echo "<img src='".$logoimage."' />";
  334. } else {
  335. $result = mysql_query("SELECT pageName FROM blog_lister WHERE id = '".$GLOBALS[bloglistertableid]."'");
  336. while($row = mysql_fetch_array($result)) {
  337. echo $headertagstart.$row['pageName'].$headertagend;
  338. }
  339. }
  340. }
  341. function out_blogsubtitle($headertagstart = '<h2>', $headertagend = '</h2>') {
  342. if (isset($GLOBALS['header_override']['subtitle']['firsttag'])) {
  343. $headertagstart = $GLOBALS['header_override']['introduction']['firsttag'];
  344. }
  345. if (isset($GLOBALS['header_override']['subtitle']['secondtag'])) {
  346. $headertagend = $GLOBALS['header_override']['introduction']['secondtag'];
  347. }
  348. $result = mysql_query("SELECT pageDesc FROM blog_lister WHERE id = '".$GLOBALS[bloglistertableid]."'");
  349. while($row = mysql_fetch_array($result)) {
  350. echo $headertagstart.$row['pageDesc'].$headertagend;
  351. }
  352. }
  353. function out_sidebar() {
  354. include("lib/config.php");
  355. mysql_connect($GLOBALS['localdatabase'], $GLOBALS['dbuser'], $GLOBALS['decryptpass']);
  356. mysql_select_db($GLOBALS['$dbname']);
  357. $query = "SELECT id,sidebar FROM sidebars WHERE blogname ='". $GLOBALS['tablenameclean'] ."'";
  358. $output = mysql_query($query) or die(mysql_error());
  359. while($row = mysql_fetch_array($output)){
  360. $sidebar_out = stripslashes($row[sidebar]);
  361. echo $sidebar_out;
  362. }
  363. }
  364. function out_footer($author=NULL, $copyright=NULL) {
  365. $copyright = $GLOBALS['blogname'];
  366. if (isset($GLOBALS['header_override']['footer']['copyright'])) {
  367. $copyright = $GLOBALS['header_override']['footer']['copyright'];
  368. }
  369. echo "Copyright 2010 ".$copyright." | ".$author." | <a href='http://viewpanel.streeteye.info'>Powered by View Panel</a>";
  370. }
  371. function out_navbar($navid = 'navbar') {
  372. echo "<div id='$navid'>
  373. <ul>
  374. <li><a href=''>Home</a></li>
  375. </ul>
  376. </div>";
  377. }
  378. /* function out_loginform () {
  379. } */
  380. ?>