Beispiel #1
0
/**
* 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;
}
Beispiel #2
0
/**
 * used for the list of plugins in admin/plugins.php
 *
 */
function ADMIN_getListField_plugins($fieldname, $fieldvalue, $A, $icon_arr, $token)
{
    global $_CONF, $LANG_ADMIN, $LANG32;
    $retval = '';
    switch ($fieldname) {
        case 'info_installed':
            $retval = COM_createLink($icon_arr['info'], "{$_CONF['site_admin_url']}/plugins.php?mode=info_installed&pi_name={$A['pi_name']}", array('title' => $LANG32[13]));
            break;
        case 'pi_name':
            $retval = plugin_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}, {$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_load':
            $csrftok = '&amp;' . CSRF_TOKEN . '=' . $token;
            $style = "style='vertical-align: middle;'";
            $upimg = $_CONF['layout_url'] . '/images/admin/up.png';
            $dnimg = $_CONF['layout_url'] . '/images/admin/down.png';
            $url = $_CONF['site_admin_url'] . '/plugins.php?mode=change_load_order&amp;pi_name=' . $A['pi_name'] . $csrftok . '&amp;where=';
            $retval .= COM_CreateLink("<img {$style} alt='+' src='{$upimg}'" . XHTML . ">", $url . 'up', array('title' => $LANG32[44]));
            $retval .= '&nbsp;' . $A['pi_load'] . '&nbsp;';
            $retval .= COM_CreateLink("<img {$style} alt='-' src='{$dnimg}'" . XHTML . ">", $url . 'dn', array('title' => $LANG32[45]));
            break;
        case 'pi_enabled':
            if (!PLG_checkDependencies($A['pi_name'])) {
                $retval = str_replace('<img ', '<img title="' . $LANG32[64] . '" ', $icon_arr['warning']);
            } else {
                $not_present = false;
                if ($A['pi_enabled'] == 1) {
                    $switch = 'enabled';
                    $title = $LANG32[49];
                } else {
                    $switch = 'disabled';
                    $title = $LANG32[48];
                    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}";
                    }
                    $retval = COM_createLink($icon_arr[$switch], $_CONF['site_admin_url'] . '/plugins.php?mode=toggle&amp;pi_name=' . $A['pi_name'] . $csrftoken . $sorting, array('title' => $title));
                }
            }
            break;
        case 'delete':
            $csrftoken = '&amp;' . CSRF_TOKEN . '=' . $token;
            $id = 'uninstall_' . $A['pi_name'];
            // used by JavaScript
            $message = sprintf($LANG32[47], "\\'" . plugin_get_pluginname($A['pi_name']) . "\\'");
            // used by JavaScript
            $url = $_CONF['site_admin_url'] . '/plugins.php?mode=delete&amp;pi_name=' . $A['pi_name'] . $csrftoken;
            $link_args = array('title' => $LANG32[46], 'onclick' => "confirm_action('{$message}', '{$url}&amp;confirmed=1')", 'id' => $id);
            $retval .= COM_CreateLink($icon_arr['deleteitem'], $url, $link_args);
            // If javascript is available, we will be using it to get a confirmation from the user. So we need to hide the default link.
            $retval .= '<script type="text/javascript">document.getElementById("' . $id . '").href = "javascript:void(0);";</script>';
            break;
        default:
            $retval = $fieldvalue;
            break;
    }
    return $retval;
}
Beispiel #3
0
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;
}
Beispiel #4
0
/**
 * used for the list of topics in admin/topic.php
 *
 */
function ADMIN_getListField_topics($fieldname, $fieldvalue, $A, $icon_arr, $token)
{
    global $_CONF, $LANG_ACCESS, $_TABLES, $LANG27, $LANG32;
    $retval = false;
    $access = SEC_hasAccess($A['owner_id'], $A['group_id'], $A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']);
    switch ($fieldname) {
        case 'edit':
            if ($access == 3) {
                $editurl = $_CONF['site_admin_url'] . '/topic.php?mode=edit&amp;tid=' . $A['tid'];
                $retval = COM_createLink($icon_arr['edit'], $editurl);
            }
            break;
        case 'sortnum':
            if ($_CONF['sortmethod'] == 'sortnum') {
                $style = 'style="vertical-align: middle;"';
                $upimg = $_CONF['layout_url'] . '/images/admin/up.png';
                $dnimg = $_CONF['layout_url'] . '/images/admin/down.png';
                $url = $_CONF['site_admin_url'] . '/topic.php?mode=change_sortnum' . '&amp;tid=' . $A['tid'] . '&amp;' . CSRF_TOKEN . '=' . $token . '&amp;where=';
                $retval .= COM_CreateLink("<img {$style} alt=\"+\" src=\"{$upimg}\"" . XHTML . ">", $url . 'up', array('title' => $LANG32[44]));
                $retval .= '&nbsp;' . $fieldvalue . '&nbsp;';
                $retval .= COM_CreateLink("<img {$style} alt=\"-\" src=\"{$dnimg}\"" . XHTML . ">", $url . 'dn', array('title' => $LANG32[45]));
            } else {
                $retval = $fieldvalue;
            }
            break;
        case 'image':
            $retval = '';
            if (!empty($A['imageurl'])) {
                $imageurl = COM_getTopicImageUrl($A['imageurl']);
                $image_tag = '<img src="' . $imageurl . '" width="24" height="24" id="topic-' . $A['tid'] . '" class="admin-topic-image" alt=""' . XHTML . '>';
                $url = $_CONF['site_url'] . '/index.php?topic=' . $A['tid'];
                $retval = COM_createLink($image_tag, $url);
            }
            break;
        case 'topic':
            $default = $A['is_default'] == 1 ? $LANG27[24] : '';
            $level = -1;
            $tid = $A['tid'];
            while ($tid !== TOPIC_ROOT) {
                $tid = DB_getItem($_TABLES['topics'], 'parent_id', "tid = '{$tid}'");
                $level++;
            }
            $level *= 15;
            $content = '<span style="margin-left:' . $level . 'px">' . $fieldvalue . '</span>';
            $url = $_CONF['site_url'] . '/index.php?topic=' . $A['tid'];
            $retval = COM_createLink($content, $url) . $default;
            break;
        case 'access':
            $retval = $LANG_ACCESS['readonly'];
            if ($access == 3) {
                $retval = $LANG_ACCESS['edit'];
            }
            break;
        case 'inherit':
        case 'hidden':
            $yes = empty($LANG27[50]) ? 'Yes' : $LANG27[50];
            $no = empty($LANG27[50]) ? 'No' : $LANG27[51];
            $retval = $fieldvalue == 1 ? $yes : $no;
            break;
        case 'story':
            // Retrieve list of inherited topics
            $tid_list = TOPIC_getChildList($A['tid']);
            // Calculate number of stories in topic, includes any inherited ones
            $sql = "SELECT sid FROM {$_TABLES['stories']}, {$_TABLES['topic_assignments']} ta " . "WHERE (draft_flag = 0) AND (date <= NOW()) " . COM_getPermSQL('AND') . "AND ta.type = 'article' AND ta.id = sid " . "AND (ta.tid IN({$tid_list}) " . "AND (ta.inherit = 1 OR (ta.inherit = 0 AND ta.tid = '{$A['tid']}'))) " . "GROUP BY sid";
            $result = DB_query($sql);
            $nrows = DB_numRows($result);
            $retval = COM_numberFormat($nrows);
            break;
        default:
            $retval = $fieldvalue;
            break;
    }
    return $retval;
}