A tumblelog CMS built on AJAX, PHP and MySQL.

plugins.php 6.9KB

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