コード例 #1
0
ファイル: lib-admin.php プロジェクト: Geeklog-Core/geeklog
/**
 * used to display the entries for the list of uninstalled plugins, in admin/plugins.php
 *
 * @param  string $fieldName
 * @param  string $fieldValue
 * @param  array  $A
 * @param  array  $icon_arr
 * @param  string $selected
 * @return string
 */
function ADMIN_getListField_newplugins($fieldName, $fieldValue, $A, $icon_arr, $selected = '')
{
    global $_CONF, $LANG32;
    switch ($fieldName) {
        case 'info_uninstalled':
            $retval = COM_createLink($icon_arr['info'], "{$_CONF['site_admin_url']}/plugins.php?mode=info_uninstalled&pi_name={$A['pi_name']}", array('title' => $LANG32[13]));
            break;
        case 'pi_version':
            $params = PLG_getParams($A['pi_name']);
            $retval = $params['info']['pi_version'];
            break;
        case 'pi_dependencies':
            if (PLG_checkDependencies($A['pi_name'])) {
                $retval = COM_getTooltip($LANG32[51], PLG_printDependencies($A['pi_name'], $A['pi_gl_version']));
            } else {
                $style = "display: inline; color: #a00; border-bottom: 1px dotted #a00;";
                $retval = COM_getTooltip("<b class='notbold' style='{$style}'>{$LANG32[52]}</b>", PLG_printDependencies($A['pi_name'], $A['pi_gl_version']));
            }
            break;
        case 'install_link':
            if (PLG_checkDependencies($A['pi_name'])) {
                $retval = COM_createLink($icon_arr['install'], $A['install_link'], array('title' => $LANG32[62]));
            } else {
                $retval = str_replace('<img ', '<img title="' . $LANG32[63] . '" ', $icon_arr['unavailable']);
            }
            break;
        default:
            $retval = $fieldValue;
            break;
    }
    return $retval;
}
コード例 #2
0
ファイル: plugins.php プロジェクト: alxstuart/ajfs.me
/**
* Shows the plugin information center for uninstalled plugins
*
* @param    string  $pi_name    Plugin name
* @return   string              HTML for plugin editor form or error message
*
*/
function plugin_info_uninstalled($pi_name)
{
    global $_CONF, $_TABLES, $_USER, $LANG32, $LANG_ADMIN;
    $retval = '';
    if (strlen($pi_name) == 0) {
        $retval .= COM_showMessageText($LANG32[12], $LANG32[13]);
        return $retval;
    }
    // Get data
    $params = PLG_getParams($pi_name);
    // Do template stuff
    $plg_templates = COM_newTemplate($_CONF['path_layout'] . 'admin/plugins');
    $plg_templates->set_file('editor', 'info.thtml');
    $plg_templates->set_var('start_block_editor', COM_startBlock('', '', COM_getBlockTemplate('_admin_block', 'header')));
    $plg_templates->set_var('pi_icon', PLG_getIcon($pi_name));
    $plg_templates->set_var('title', $LANG32[13]);
    $plg_templates->set_var('lang_pluginname', $LANG32[26]);
    $plg_templates->set_var('pi_display_name', plugin_get_pluginname($pi_name));
    $plg_templates->set_var('lang_pluginversion', $LANG32[17]);
    $plg_templates->set_var('pi_version', $params['info']['pi_version']);
    $plg_templates->set_var('lang_pluginhomepage', $LANG32[27]);
    if (!empty($params['info']['pi_homepage'])) {
        $plg_templates->set_var('pi_homepage', COM_CreateLink($params['info']['pi_homepage'], $params['info']['pi_homepage']));
    } else {
        $plg_templates->set_var('pi_homepage', $LANG_ADMIN['na']);
    }
    $pi_deps = PLG_printDependencies($pi_name, $params['info']['pi_gl_version']);
    $plg_templates->set_var('lang_dependencies', $LANG32[50]);
    $plg_templates->set_var('pi_dependencies', $pi_deps);
    $plg_templates->set_var('back', $LANG32[60]);
    $plg_templates->set_var('end_block', COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer')));
    $retval .= $plg_templates->finish($plg_templates->parse('output', 'editor'));
    return $retval;
}
コード例 #3
0
ファイル: index.php プロジェクト: Geeklog-Plugins/monitor
function MONITOR_getListField_plugins($fieldname, $fieldvalue, $A, $icon_arr, $token)
{
    global $_CONF, $_MONITOR_CONF, $LANG_ADMIN, $LANG32, $_TABLES, $ready_plugins, $LANG_MONITOR_1;
    $retval = '';
    switch ($fieldname) {
        case 'pi_name':
            $retval = MONITOR_get_pluginname($A['pi_name']);
            break;
        case 'pi_version':
            $plugin_code_version = PLG_chkVersion($A['pi_name']);
            if (empty($plugin_code_version)) {
                $code_version = $LANG_ADMIN['na'];
            } else {
                $code_version = $plugin_code_version;
            }
            $pi_installed_version = $A['pi_version'];
            if (empty($plugin_code_version) || $pi_installed_version == $code_version) {
                $retval = $pi_installed_version;
            } else {
                $retval = "{$LANG32[37]}: {$pi_installed_version},&nbsp;{$LANG32[36]}: {$plugin_code_version}";
                if ($A['pi_enabled'] == 1) {
                    $retval .= " <b>{$LANG32[38]}</b>";
                    $csrftok = '&amp;' . CSRF_TOKEN . '=' . $token;
                    $style = 'style="vertical-align: middle;"';
                    $img = $_CONF['layout_url'] . '/images/update.png';
                    $img = "<img {$style} alt=\"[" . $LANG32[38] . "]\" src=\"{$img}\"" . XHTML . ">";
                    $url = $_CONF['site_admin_url'] . '/plugins.php?mode=updatethisplugin&amp;pi_name=' . $A['pi_name'] . $csrftok;
                    $retval .= COM_CreateLink($img, $url, array('title' => $LANG32[42]));
                }
            }
            break;
        case 'pi_dependencies':
            if (PLG_checkDependencies($A['pi_name'])) {
                $retval = COM_getTooltip($LANG32[51], PLG_printDependencies($A['pi_name'], $A['pi_gl_version']));
            } else {
                $style = "display: inline; color: #a00; border-bottom: 1px dotted #a00;";
                $retval = COM_getTooltip("<b class='notbold' style='{$style}'>{$LANG32[52]}</b>", PLG_printDependencies($A['pi_name'], $A['pi_gl_version']));
            }
            break;
        case 'pi_update':
            if (!PLG_checkDependencies($A['pi_name'])) {
                $retval = str_replace('<img ', '<img title="' . $LANG32[64] . '" ', $icon_arr['warning']);
            } else {
                $available = false;
                // plugin in repository
                $dependencie = true;
                $not_present = false;
                if ($A['pi_enabled'] == 1) {
                    $title = '';
                    $link = '';
                    $plugin = $A['pi_name'];
                    if (in_array($plugin, $ready_plugins)) {
                        //Check if plugin is in repo
                        $url = GITHUB_REPOSITORY . $plugin . '/releases';
                        //Get last release for this plugin
                        $releases = MONITOR_curlRequestOnGitApi($url);
                        $tag = $releases[0]['tag_name'];
                        if ($tag != '') {
                            $available = true;
                        }
                        //Is release newer
                        $installed_version = DB_getItem($_TABLES['plugins'], 'pi_version', "pi_name = '{$plugin}'");
                        if ($tag != '' && 'v' . $installed_version != $tag) {
                            $update = true;
                            $autoinstall_url = 'https://raw.githubusercontent.com/' . $_MONITOR_CONF['repository'] . '/' . $plugin . '/' . $tag . '/autoinstall.php';
                            $ch = curl_init();
                            curl_setopt($ch, CURLOPT_URL, $autoinstall_url);
                            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
                            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                            $data = curl_exec($ch);
                            curl_close($ch);
                            //Get infos from plugin
                            $data = preg_replace('/\\s+/', '', $data);
                            $gl_version = MONITOR_extract_unit($data, "pi_gl_version'=>'", "',");
                            //Geeklog dependencie
                            if (COM_versionCompare(VERSION, $gl_version, '>=')) {
                                $title = $LANG_MONITOR_1['update_to'] . ' ' . $tag;
                                $link = $_CONF['site_admin_url'] . "/plugins/monitor/index.php?action=update_plugin&amp;plugin={$plugin}";
                            } else {
                                $dependencie = false;
                                $title = $LANG_MONITOR_1['need_upgrade'] . $gl_version . '+ ' . $LANG_MONITOR_1['before_update'] . ' ' . $plugin . ' ' . $tag;
                                $link = "https://www.geeklog.net";
                            }
                        } else {
                            if ($tag == '') {
                                // The plugin is not available in this repo
                                $update = false;
                                if (is_string($releases['message'])) {
                                    $title = $releases['message'];
                                    $link = $releases['documentation_url'];
                                } else {
                                    $title = $LANG_MONITOR_1['not_available'];
                                    $link = "https://github.com/{$_MONITOR_CONF['repository']}";
                                }
                            } else {
                                // The plugin is up to date
                                $update = false;
                            }
                        }
                    } else {
                        $update = false;
                        //Ask plugin author to change this :)
                        $title = $LANG_MONITOR_1['ask_author'];
                        $link = DB_getItem($_TABLES['plugins'], 'pi_homepage', "pi_name = '{$plugin}'");
                    }
                } else {
                    $title = 'Update this plugin';
                    $link = '';
                    $update = true;
                    if (!file_exists($_CONF['path'] . 'plugins/' . $A['pi_name'] . '/functions.inc')) {
                        $not_present = true;
                    }
                }
                if ($not_present) {
                    $retval = str_replace('<img ', '<img title="' . $LANG32[64] . '" ', $icon_arr['unavailable']);
                } else {
                    $sorting = '';
                    $csrftoken = '&amp;' . CSRF_TOKEN . '=' . $token;
                    if (!empty($_GET['order']) && !empty($_GET['direction'])) {
                        // Remember how the list was sorted
                        $ord = trim($_GET['order']);
                        $dir = trim($_GET['direction']);
                        $old = trim($_GET['prevorder']);
                        $sorting = "&amp;order={$ord}&amp;direction={$dir}&amp;prevorder={$old}";
                    }
                    //Icons in update coloumn
                    if (!$update && in_array($plugin, $ready_plugins) && $available) {
                        $retval = str_replace('<img ', $LANG_MONITOR_1['up_to_date'] . ' <img title="' . $LANG_MONITOR_1['up_to_date'] . '" ', $icon_arr['enabled']);
                        $retval = $icon_arr['enabled'] . ' ' . $LANG_MONITOR_1['up_to_date'];
                    } else {
                        if (!$update && in_array($plugin, $ready_plugins) && !$available) {
                            $retval = COM_createLink($icon_arr['info'] . ' ' . $title, $link . $sorting, array('title' => ''));
                        } else {
                            if (!$update && !in_array($plugin, $ready_plugins)) {
                                $retval = COM_createLink($icon_arr['disabled'] . ' ' . $title, $link . $sorting, array('title' => ''));
                            } else {
                                if (!$update) {
                                    $retval = str_replace('<img ', '<img title="' . $LANG_MONITOR_1['no_update'] . '" ', $icon_arr['disabled']);
                                } else {
                                    if ($dependencie == false) {
                                        $retval = COM_createLink($icon_arr['warning'] . ' ' . $title, $link . $sorting, array('title' => ''));
                                    } else {
                                        $retval = COM_createLink($icon_arr['info'] . ' ' . $title, $link . $sorting, array('title' => ''));
                                    }
                                }
                            }
                        }
                    }
                }
            }
            break;
        default:
            $retval = $fieldvalue;
            break;
    }
    return $retval;
}