ini_set('session.cache_expire', 20160);
/* 2 weeks */
ini_set('session.gc_maxlifetime', 1209600);
ini_set('session.use_only_cookies', 1);
session_name('planetoid_admin');
session_start();
if (isset($_SESSION['uid']) && isset($_SESSION['ulevel'])) {
    require '../config.php';
    require '../planetoid.php';
    require 'plugins-functions.php';
    $curr_page = basename(__FILE__);
    include 'header.php';
    $info_file_path = "../inc/plugins/" . sql_escape($_GET['dir']) . "/plugin.info";
    $file = fopen($info_file_path, "r");
    $_PLUGIN = fread($file, filesize($info_file_path));
    $_PLUGIN = parse_info_file($_PLUGIN, 'Plugin Info');
    fclose($file);
    ?>
		<div id="page">
			<div id="page-area">
				<?php 
    if ($_GET['done'] == 'true') {
        ?>
				<div id="updated">
					Settings have been saved.
				</div>
				<?php 
    }
    ?>
				<h2><img src="inc/images/loading.gif" id="loading" alt="loading" style="display: none;" />Plugin settings &raquo; <?php 
    echo $_PLUGIN['PluginName'];
Beispiel #2
0
 /**
  * This function allows easy activating and inactivating
  * of plugins and save them inside db
  * @param array $plugin_paths dashboard plugin paths
  * return int affected rows
  */
 public static function store_dashboard_plugins($plugin_paths)
 {
     $tbl_block = Database::get_main_table(TABLE_MAIN_BLOCK);
     $affected_rows = 0;
     // get all plugins path inside plugin directory
     $dashboard_pluginpath = api_get_path(SYS_PLUGIN_PATH) . 'dashboard/';
     $possibleplugins = self::get_posible_dashboard_plugins_path();
     if (count($possibleplugins) > 0) {
         $selected_plugins = array_intersect(array_keys($plugin_paths), $possibleplugins);
         $not_selected_plugins = array_diff($possibleplugins, array_keys($plugin_paths));
         // get blocks id from not selected path
         $not_selected_blocks_id = array();
         foreach ($not_selected_plugins as $plugin) {
             $block_data = self::get_enabled_dashboard_blocks($plugin);
             if (!empty($block_data[$plugin])) {
                 $not_selected_blocks_id[] = $block_data[$plugin]['id'];
             }
         }
         /* clean not selected plugins for extra user data and block data */
         // clean from extra user data
         $field_variable = 'dashboard';
         $extra_user_data = UserManager::get_extra_user_data_by_field_variable($field_variable);
         foreach ($extra_user_data as $key => $user_data) {
             $user_id = $key;
             $user_block_data = self::get_user_block_data($user_id);
             $user_block_id = array_keys($user_block_data);
             // clean disabled block data
             foreach ($user_block_id as $block_id) {
                 if (in_array($block_id, $not_selected_blocks_id)) {
                     unset($user_block_data[$block_id]);
                 }
             }
             // get columns and blocks id for updating extra user data
             $columns = array();
             $user_blocks_id = array();
             foreach ($user_block_data as $data) {
                 $user_blocks_id[$data['block_id']] = true;
                 $columns[$data['block_id']] = $data['column'];
             }
             // update extra user blocks data
             $upd_extra_field = self::store_user_blocks($user_id, $user_blocks_id, $columns);
         }
         // clean from block data
         if (!empty($not_selected_blocks_id)) {
             $sql_check = "SELECT id FROM {$tbl_block} WHERE id IN(" . implode(',', $not_selected_blocks_id) . ")";
             $rs_check = Database::query($sql_check);
             if (Database::num_rows($rs_check) > 0) {
                 $del = "DELETE FROM {$tbl_block} WHERE id IN(" . implode(',', $not_selected_blocks_id) . ")";
                 Database::query($del);
             }
         }
         // store selected plugins
         foreach ($selected_plugins as $testplugin) {
             $selected_path = Database::escape_string($testplugin);
             // check if the path already stored inside block table for updating or adding it
             $sql = "SELECT path FROM {$tbl_block} WHERE path = '{$selected_path}'";
             $rs = Database::query($sql);
             if (Database::num_rows($rs) > 0) {
                 // update
                 $upd = "UPDATE {$tbl_block} SET active = 1 WHERE path = '{$selected_path}'";
                 $result = Database::query($upd);
                 $affected_rows = Database::affected_rows($result);
             } else {
                 // insert
                 $plugin_info_file = $dashboard_pluginpath . $testplugin . "/{$testplugin}.info";
                 $plugin_info = array();
                 if (file_exists($plugin_info_file)) {
                     $plugin_info = parse_info_file($plugin_info_file);
                 }
                 // change keys to lower case
                 $plugin_info = array_change_key_case($plugin_info);
                 // setting variables
                 $plugin_name = $testplugin;
                 $plugin_description = '';
                 $plugin_controller = '';
                 $plugin_path = $testplugin;
                 if (isset($plugin_info['name'])) {
                     $plugin_name = Database::escape_string($plugin_info['name']);
                 }
                 if (isset($plugin_info['description'])) {
                     $plugin_description = Database::escape_string($plugin_info['description']);
                 }
                 if (isset($plugin_info['controller'])) {
                     $plugin_controller = Database::escape_string($plugin_info['controller']);
                 }
                 $ins = "INSERT INTO {$tbl_block}(name, description, path, controller)\n\t\t\t\t\t\t\tVALUES ('{$plugin_name}', '{$plugin_description}', '{$plugin_path}', '{$plugin_controller}')";
                 $result = Database::query($ins);
                 $affected_rows = Database::affected_rows($result);
             }
         }
     }
     return $affected_rows;
 }
function list_info_dir($dir, $info_name)
{
    $list = array();
    if ($handle = opendir($dir)) {
        while (false != ($file = readdir($handle))) {
            $path = $dir . '/' . $file . '/' . $info_name . '.info';
            if (is_dir($dir . '/' . $file) && $file != '.' && $file != '..' && file_exists($path)) {
                $_doc = fopen($path, 'r');
                $doc = fread($_doc, filesize($path));
                $list[] = array(parse_info_file($doc, ucfirst($info_name) . ' Info'), $file);
                fclose($_doc);
            }
        }
        closedir($handle);
    } else {
        return false;
    }
    return $list;
}
Beispiel #4
0
 /**
  * Available plugins not installed
  */
 public function availablePlugins($types = array())
 {
     if (empty($types)) {
         $types = $this->get_plugin_folder_type_list();
     }
     if (is_dir($this->plugin_path) && ($handle_type = opendir($this->plugin_path))) {
         while (FALSE !== ($file = readdir($handle_type))) {
             if (!in_array($file, array('.', '..'))) {
                 $plugin_type_path = $this->plugin_path . SEPARATOR . $file;
                 if (is_dir($plugin_type_path)) {
                     if (in_array(basename($plugin_type_path), $types)) {
                         $handle = opendir($plugin_type_path);
                         while (FALSE !== ($sub_file = readdir($handle))) {
                             if (!in_array($sub_file, array('.', '..'))) {
                                 $info_file = $plugin_type_path . SEPARATOR . $sub_file . SEPARATOR . $sub_file . '.info';
                                 if (file_exists($info_file)) {
                                     $info_file = parse_info_file($info_file);
                                     $info_file['path'] = $plugin_type_path . SEPARATOR . $sub_file . SEPARATOR . $sub_file . '.class.php';
                                     $plugin_list[$file][strtolower($info_file['name'])] = $info_file;
                                     //require_once $info_file['path'];
                                 }
                             }
                         }
                         closedir($handle);
                     }
                 }
             }
         }
         closedir($handle_type);
     }
     //echo '<pre>'; print_r($plugin_list);
     return $plugin_list;
 }
<?php

require '../config.php';
include '../planetoid.php';
$file = curl_get('http://www.planetoid-project.org/versions.info');
if ($file) {
    $l_version = parse_info_file($file, 'Planetoid Versions');
    $V = $l_version['LatestVersion'];
    $SV = $l_version['LatestVersionRevision'];
    $download = $l_version['LatestVersionGetURL'];
    if (PLANETOID_VERSION . PLANETOID_REVISION < $V . $SV) {
        $output = "There is newer version of Planetoid ({$V}.{$SV}), you can get it at <a href=\"{$download}\">{$download}</a>";
    } else {
        $output = "You have the latest version";
    }
} else {
    $output = "Unable to check for updates";
}
if ($_POST['ajax'] == 'true') {
    echo $output;
} else {
    if ($file) {
        header("Location: {$_GET['r_to']}?v={$V}&sv={$SV}&link=" . urlencode($download));
    } else {
        header("Location: {$_GET['r_to']}?e=no-curl");
    }
}