A tumblelog CMS built on AJAX, PHP and MySQL.

plugins.php 6.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. <?php
  2. if(!defined('entry')) define('entry',true);
  3. /* ===========================
  4. gelato CMS - A PHP based tumblelog CMS
  5. development version
  6. http://www.gelatocms.com/
  7. gelato CMS is a free software licensed under the GPL 2.0
  8. Copyright (C) 2007 by Pedro Santana <pecesama at gmail dot com>
  9. =========================== */
  10. ?>
  11. <?php
  12. require_once('../entry.php');
  13. global $user, $conf, $tumble;
  14. if ($user->isAdmin()) {
  15. $plugins = array();
  16. if ($handle = opendir(Absolute_Path."plugins")) {
  17. while (false !== ($file = readdir($handle))) {
  18. if (substr($file, strlen($file)-4, 4) == ".php") {
  19. $plugins[] = substr($file, 0, strlen($file)-4);
  20. }
  21. }
  22. closedir($handle);
  23. }
  24. $actives = json_decode($conf->active_plugins,1);
  25. $actives = $actives[1];
  26. if(isset($_POST["btnsubmit"])) {
  27. $actives = array();
  28. foreach($_POST['plugins'] as $plugin => $val){
  29. if($val != 'off'){
  30. $file = $plugin.'.php';
  31. $actives[$plugin] = $file;
  32. }
  33. }
  34. if(!$tumble->saveOption(json_encode(array(array('total'=>count($actives)),$actives)), "active_plugins")){
  35. header("Location: ".$conf->urlGelato."/admin/plugins.php?error=1&desc=".$conf->merror);
  36. die();
  37. }
  38. header("Location: ".$conf->urlGelato."/admin/plugins.php?modified=true");
  39. die();
  40. } else {
  41. ?>
  42. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  43. <html xmlns="http://www.w3.org/1999/xhtml">
  44. <head>
  45. <title>gelato :: <?php echo __("Plugins")?></title>
  46. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  47. <meta name="generator" content="gelato cms <?php echo version();?>" />
  48. <link rel="shortcut icon" href="<?php echo $conf->urlGelato;?>/images/favicon.ico" />
  49. <script language="javascript" type="text/javascript" src="<?php echo $conf->urlGelato;?>/admin/scripts/jquery.js"></script>
  50. <script language="javascript" type="text/javascript" src="<?php echo $conf->urlGelato;?>/admin/scripts/tools.js"></script>
  51. <script type="text/javascript">
  52. $(document).ready(function(){
  53. $("#divMessages").fadeOut(5000,function(){
  54. $("#divMessages").css({display:"none"});
  55. });
  56. });
  57. </script>
  58. <style type="text/css" media="screen">
  59. @import "<?php echo $conf->urlGelato;?>/admin/css/style.css";
  60. </style>
  61. </head>
  62. <body>
  63. <div id="div-process" style="display:none;"><?php echo __("Processing request&hellip;")?></div>
  64. <div id="cont">
  65. <div id="head">
  66. <h1><a href="<?php echo $conf->urlGelato;?>/admin/index.php" title="gelato :: <?php echo __("home")?>">gelato cms</a></h1>
  67. <ul id="nav">
  68. <li><a href="<?php echo $conf->urlGelato;?>/" title="<?php echo __("Take me to the tumblelog")?>"><?php echo __("Back to the Tumblelog")?></a></li>
  69. </ul>
  70. </div>
  71. <div id="main">
  72. <div class="box">
  73. <ul class="menu manage">
  74. <h3><?php echo __("Tumblelog options")?></h3>
  75. <li><a href="index.php"><?php echo __("Post")?></a></li>
  76. <li><a href="admin.php"><?php echo __("Users")?></a></li>
  77. <li><a href="settings.php"><?php echo __("Settings")?></a></li>
  78. <li><a href="options.php"><?php echo __("Options")?></a></li>
  79. <li class="selected"><a href="plugins.php"><?php echo __("Plugins")?></a></li>
  80. </ul>
  81. <?php
  82. if (isset($_GET["modified"])) {
  83. if ($_GET["modified"]=="true") {
  84. echo "<div class=\"exito\" id=\"divMessages\">".__("The configuration has been modified successfully.")."</div>";
  85. }
  86. }
  87. if (isset($_GET["error"])) {
  88. if ($_GET["error"]==1) {
  89. echo "<div class=\"error\" id=\"divMessages\"><strong>".__("Error on the database server: ")."</strong>".$_GET["des"]."</div>";
  90. }
  91. }
  92. ?>
  93. <div class="tabla">
  94. <form action="plugins.php" method="post" id="options_form" autocomplete="off" class="newpost">
  95. <fieldset>
  96. <?php
  97. if(count($plugins) == 0){
  98. echo __('You dont have any plugin installed, get some <a href="http://www.gelatocms.com/">here</a>');
  99. }else{
  100. foreach ($plugins as $key => $plugin) {
  101. //FIXME terminar esto asi se lee la info desde el archivo 'a la' WP
  102. /*
  103. $plugin_data = implode( '', file( Absolute_Path."plugins/".$plugin.'.php' ));
  104. preg_match( '|Plugin Name:(.*)$|mi', $plugin_data, $plugin_name );
  105. preg_match( '|Plugin URI:(.*)$|mi', $plugin_data, $plugin_uri );
  106. preg_match( '|Description:(.*)$|mi', $plugin_data, $description );
  107. preg_match( '|Author:(.*)$|mi', $plugin_data, $author_name );
  108. preg_match( '|Author URI:(.*)$|mi', $plugin_data, $author_uri );
  109. if ( preg_match( "|Version:(.*)|i", $plugin_data, $version ))
  110. $version = trim( $version[1] );
  111. else
  112. $version = '';
  113. $plugin_data = array('Name' => trim($plugin_name[1]), 'URI' => trim($plugin_uri[1]), 'Description' => trim($description[1]), 'Author' => trim($author_name[1]), 'Author_uri' => trim($author_uri[1]), 'Version' => $version);
  114. */
  115. $desc = __("There is no info for this plugin jet");
  116. $activated = array_key_exists($plugin, $actives);
  117. ?>
  118. <ul>
  119. <li class="select">
  120. <label for="<?php echo $key;?>" title="<?php echo $desc; ?>" class="help"><?php echo $plugin; ?></label>
  121. <select name="plugins[<?php echo $plugin; ?>]" id="<?php echo $key;?>">
  122. <option value="on" <?php if($activated) echo 'selected="selected"'; ?>><?php echo __("On")?></option>
  123. <option value="off" <?php if(!$activated) echo 'selected="selected"'; ?>><?php echo __("Off")?></option>
  124. </select>
  125. </li>
  126. <?php
  127. }
  128. ?>
  129. </ul>
  130. <?php
  131. }
  132. ?>
  133. </fieldset>
  134. <p>
  135. <input type="submit" name="btnsubmit" id="btnsubmit" value="<?php echo __("Modify")?>" class="submit"/>
  136. </p>
  137. </form>
  138. </div>
  139. <div class="footer-box">&nbsp;</div>
  140. </div>
  141. </div>
  142. <div id="foot">
  143. <a href="http://www.gelatocms.com/" title="gelato CMS">gelato CMS</a> :: PHP/MySQL Tumblelog Content Management System.
  144. </div>
  145. </div>
  146. </body>
  147. </html>
  148. <?php
  149. }
  150. } else {
  151. header("Location: ".$conf->urlGelato."/login.php");
  152. }
  153. ?>