A tumblelog CMS built on AJAX, PHP and MySQL.

plugins.php 7.4KB

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