//
// ------------------------------------------------------------------------ //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation; either version 2 of the License, or //
// (at your option) any later version. //
// //
// You may not change or alter any portion of this comment or credits //
// of supporting developers from this source code or any supporting //
// source code which is considered copyrighted (c) material of the //
// original comment or credit authors. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program; if not, write to the Free Software //
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA //
// ------------------------------------------------------------------------ //
// Author: phppp (D.J.) //
// URL: http://xoopsforge.com, http://xoops.org.cn //
// ------------------------------------------------------------------------- //
//include_once 'cp_functions.php';
function get_xpress_plugin_data( $plugin_file, $markup = true, $translate = true ) {
// We don't need to write to the file, so just open for reading.
$fp = fopen($plugin_file, 'r');
// Pull only the first 8kiB of the file in.
$plugin_data = fread( $fp, 8192 );
// PHP will close file handle, but we are good citizens.
fclose($fp);
preg_match( '|Plugin Name:(.*)$|mi', $plugin_data, $name );
preg_match( '|Plugin URI:(.*)$|mi', $plugin_data, $uri );
preg_match( '|Version:(.*)|i', $plugin_data, $version );
preg_match( '|Description:(.*)$|mi', $plugin_data, $description );
preg_match( '|Author:(.*)$|mi', $plugin_data, $author_name );
preg_match( '|Author URI:(.*)$|mi', $plugin_data, $author_uri );
preg_match( '|Text Domain:(.*)$|mi', $plugin_data, $text_domain );
preg_match( '|Domain Path:(.*)$|mi', $plugin_data, $domain_path );
foreach ( array( 'name', 'uri', 'version', 'description', 'author_name', 'author_uri', 'text_domain', 'domain_path' ) as $field ) {
if ( !empty( ${$field} ) )
${$field} = trim(${$field}[1]);
else
${$field} = '';
}
$plugin_data = array(
'Name' => $name, 'Title' => $name, 'PluginURI' => $uri, 'Description' => $description,
'Author' => $author_name, 'AuthorURI' => $author_uri, 'Version' => $version,
'TextDomain' => $text_domain, 'DomainPath' => $domain_path
);
// if ( $markup || $translate )
// $plugin_data = _get_plugin_data_markup_translate($plugin_data, $markup, $translate);
return $plugin_data;
}
function get_xpress_active_plugin_list($before_str = '')
{
global $xoopsModule;
$xoopsDB =& Database::getInstance();
$mydirname = basename(dirname(dirname(__FILE__)));
$my_dirpath = dirname(dirname(__FILE__));
$prefix = $mydirname;
if ($prefix == 'wordpress') $prefix ='wp';
$wp_prefix = $xoopsDB->prefix($prefix);
$option_table = $wp_prefix . '_options';
$sql = "SELECT option_value FROM $option_table WHERE option_name = 'active_plugins'";
$res = $xoopsDB->query($sql, 0, 0);
if ($res === false){
return ;
} else {
$row = $xoopsDB->fetchArray($res);
$active_plugins = @unserialize($row['option_value']);
$output = '';
foreach($active_plugins as $active_plugin_path){
$file_name = $my_dirpath . '/wp-content/plugins/' . $active_plugin_path;
$active_plugin = get_xpress_plugin_data($file_name);
$output .= $before_str . $active_plugin['Name'] . ': Version ' . $active_plugin['Version'] . ': (' .$active_plugin['PluginURI'] . ') ';
}
return $output;
}
}
function xpress_active_plugin_list($is_report = false)
{
if ($is_report) {
echo "******** " . _AM_XP2_PLUGIN . "********" . " \n";
echo get_xpress_active_plugin_list('') . " \n";
} else {
echo "