Exemplo n.º 1
0
 function doctype()
 {
     if ($this->request == 'admin/emails') {
         if (qa_post_text('option_notify_admin_a_post')) {
             qa_opt('notify_admin_a_post', (bool) qa_post_text('option_notify_admin_a_post'));
             qa_opt('notify_admin_c_post', (bool) qa_post_text('option_notify_admin_c_post'));
         }
         foreach ($this->content['form']['fields'] as $key => $val) {
             $arr[$key] = $val;
             if ($key == 'notify_admin_q_post') {
                 $arr['notify_admin_a_post'] = array('id' => 'notify_admin_a_post', 'label' => 'Email this address when an answer is posted', 'tags' => 'NAME="option_notify_admin_a_post" ID="option_notify_admin_a_post"', 'value' => qa_opt('notify_admin_a_post'), 'type' => 'checkbox', 'error' => '');
                 $arr['notify_admin_c_post'] = array('id' => 'notify_admin_a_post', 'label' => 'Email this address when a comment is posted', 'tags' => 'NAME="option_notify_admin_c_post" ID="option_notify_admin_c_post"', 'value' => qa_opt('notify_admin_c_post'), 'type' => 'checkbox', 'error' => '');
             }
             $this->content['form']['fields'] = $arr;
         }
     }
     if (qa_opt('admin_plus_notify') && qa_get_logged_in_level() >= QA_USER_LEVEL_ADMIN && (time() - (int) qa_opt('admin_plus_notify_checked')) / 3600 > qa_opt('admin_plus_notify_hours')) {
         qa_opt('admin_plus_notify_checked', time());
         $pluginfiles = glob(QA_PLUGIN_DIR . '*/qa-plugin.php');
         if (count($pluginfiles)) {
             require_once QA_INCLUDE_DIR . 'qa-app-admin.php';
             $cnt = 0;
             foreach ($pluginfiles as $pluginfile) {
                 $plugindirectory = dirname($pluginfile) . '/';
                 $contents = file_get_contents($pluginfile);
                 $metadata = qa_admin_addon_metadata($contents, array('version' => 'Plugin Version', 'update' => 'Plugin Update Check URI'));
                 if (@$metadata['version'] && @$metadata['update']) {
                     $newdata = qa_admin_addon_metadata(qa_retrieve_url($metadata['update']), array('version' => 'Plugin Version', 'uri' => 'Plugin URI'));
                     if (strlen(@$newdata['version']) && strcmp($newdata['version'], $metadata['version'])) {
                         $this->content['notices'][] = qa_notice_form('updates', qa_viewer_html(qa_opt('admin_plus_notify_text'), 'html'));
                         $this->content['script'][] = "<script type=\"text/javascript\">jQuery(document).ready(function(){qa_reveal(document.getElementById('notice_updates'), 'notice');});</script>";
                         break;
                     }
                 }
             }
         }
     }
     qa_html_theme_base::doctype();
 }
        }
    }
}
if (qa_is_http_post() && !qa_check_form_security_code('admin/plugins', qa_post_text('qa_form_security_code'))) {
    $qa_content['error'] = qa_lang_html('misc/form_security_reload');
    $showpluginforms = false;
} else {
    $showpluginforms = true;
}
if (count($pluginfiles)) {
    foreach ($pluginfiles as $pluginindex => $pluginfile) {
        $plugindirectory = dirname($pluginfile) . '/';
        $hash = qa_admin_plugin_directory_hash($plugindirectory);
        $showthisform = $showpluginforms && qa_get('show') == $hash;
        $contents = file_get_contents($pluginfile);
        $metadata = qa_admin_addon_metadata($contents, array('name' => 'Plugin Name', 'uri' => 'Plugin URI', 'description' => 'Plugin Description', 'version' => 'Plugin Version', 'date' => 'Plugin Date', 'author' => 'Plugin Author', 'author_uri' => 'Plugin Author URI', 'license' => 'Plugin License', 'min_q2a' => 'Plugin Minimum Question2Answer Version', 'min_php' => 'Plugin Minimum PHP Version', 'update' => 'Plugin Update Check URI'));
        if (strlen(@$metadata['name'])) {
            $namehtml = qa_html($metadata['name']);
        } else {
            $namehtml = qa_lang_html('admin/unnamed_plugin');
        }
        if (strlen(@$metadata['uri'])) {
            $namehtml = '<a href="' . qa_html($metadata['uri']) . '">' . $namehtml . '</a>';
        }
        $namehtml = '<b>' . $namehtml . '</b>';
        if (strlen(@$metadata['version'])) {
            $namehtml .= ' v' . qa_html($metadata['version']);
        }
        if (strlen(@$metadata['author'])) {
            $authorhtml = qa_html($metadata['author']);
            if (strlen(@$metadata['author_uri'])) {
         $neatoptions[$rawoption] = '<iframe src="' . qa_path_html('url/test/' . QA_URL_TEST_STRING, array('dummy' => '', 'param' => QA_URL_TEST_STRING), null, $rawoption) . '" width="20" height="16" style="vertical-align:middle; border:0" scrolling="no" frameborder="0"></iframe>&nbsp;' . '<small>' . qa_html(urldecode(qa_path('123/why-do-birds-sing', null, '/', $rawoption))) . ($rawoption == QA_URL_FORMAT_NEAT ? strtr(qa_lang_html('admin/neat_urls_note'), array('^1' => '<a href="http://www.question2answer.org/htaccess.php" target="_blank">', '^2' => '</a>')) : '') . '</small>';
     }
     qa_optionfield_make_select($optionfield, $neatoptions, $value, QA_URL_FORMAT_SAFEST);
     $optionfield['type'] = 'select-radio';
     $optionfield['note'] = qa_lang_html_sub('admin/url_format_note', '<span style=" ' . qa_admin_url_test_html() . '/span>');
     break;
 case 'site_theme':
 case 'site_theme_mobile':
     $themeoptions = qa_admin_theme_options();
     if (!isset($themeoptions[$value])) {
         $value = 'Classic';
     }
     // check here because we also need $value for qa_admin_addon_metadata()
     qa_optionfield_make_select($optionfield, $themeoptions, $value, 'Classic');
     $contents = file_get_contents(QA_THEME_DIR . $value . '/qa-styles.css');
     $metadata = qa_admin_addon_metadata($contents, array('uri' => 'Theme URI', 'version' => 'Theme Version', 'date' => 'Theme Date', 'author' => 'Theme Author', 'author_uri' => 'Theme Author URI', 'license' => 'Theme License', 'update' => 'Theme Update Check URI'));
     if (strlen(@$metadata['version'])) {
         $namehtml = 'v' . qa_html($metadata['version']);
     } else {
         $namehtml = '';
     }
     if (strlen(@$metadata['uri'])) {
         if (!strlen($namehtml)) {
             $namehtml = qa_html($value);
         }
         $namehtml = '<a href="' . qa_html($metadata['uri']) . '">' . $namehtml . '</a>';
     }
     if (strlen(@$metadata['author'])) {
         $authorhtml = qa_html($metadata['author']);
         if (strlen(@$metadata['author_uri'])) {
             $authorhtml = '<a href="' . qa_html($metadata['author_uri']) . '">' . $authorhtml . '</a>';
Exemplo n.º 4
0
	as published by the Free Software Foundation; either version 2
	of the License, or (at your option) any later version.
	
	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.

	More about this license: http://www.question2answer.org/license.php
*/
require_once QA_INCLUDE_DIR . 'qa-app-admin.php';
$uri = qa_post_text('uri');
$versionkey = qa_post_text('versionkey');
$urikey = qa_post_text('urikey');
$version = qa_post_text('version');
$metadata = qa_admin_addon_metadata(qa_retrieve_url($uri), array('version' => $versionkey, 'uri' => $urikey, 'min_q2a' => 'Plugin Minimum Question2Answer Version', 'min_php' => 'Plugin Minimum PHP Version'));
if (strlen(@$metadata['version'])) {
    if (strcmp($metadata['version'], $version)) {
        if (qa_qa_version_below(@$metadata['min_q2a'])) {
            $response = strtr(qa_lang_html('admin/version_requires_q2a'), array('^1' => qa_html('v' . $metadata['version']), '^2' => qa_html($metadata['min_q2a'])));
        } elseif (qa_php_version_below(@$metadata['min_php'])) {
            $response = strtr(qa_lang_html('admin/version_requires_php'), array('^1' => qa_html('v' . $metadata['version']), '^2' => qa_html($metadata['min_php'])));
        } else {
            $response = qa_lang_html_sub('admin/version_get_x', qa_html('v' . $metadata['version']));
            if (strlen(@$metadata['uri'])) {
                $response = '<A HREF="' . qa_html($metadata['uri']) . '" STYLE="color:#d00;">' . $response . '</A>';
            }
        }
    } else {
        $response = qa_lang_html('admin/version_latest');
    }
Exemplo n.º 5
0
function ra_installed_plugin()
{
    $tables = qa_db_list_tables_lc();
    $moduletypes = qa_list_module_types();
    $pluginfiles = glob(QA_PLUGIN_DIR . '*/qa-plugin.php');
    foreach ($moduletypes as $type) {
        $modules = qa_load_modules_with($type, 'init_queries');
        foreach ($modules as $name => $module) {
            $queries = $module->init_queries($tables);
            if (!empty($queries)) {
                if (qa_is_http_post()) {
                    qa_redirect('install');
                } else {
                    $qa_content['error'] = strtr(qa_lang_html('admin/module_x_database_init'), array('^1' => qa_html($name), '^2' => qa_html($type), '^3' => '<a href="' . qa_path_html('install') . '">', '^4' => '</a>'));
                }
            }
        }
    }
    if (qa_is_http_post() && !qa_check_form_security_code('admin/plugins', qa_post_text('qa_form_security_code'))) {
        $qa_content['error'] = qa_lang_html('misc/form_security_reload');
        $showpluginforms = false;
    } else {
        $showpluginforms = true;
    }
    $plugin = array();
    if (count($pluginfiles)) {
        foreach ($pluginfiles as $pluginindex => $pluginfile) {
            $plugindirectory = dirname($pluginfile) . '/';
            $hash = qa_admin_plugin_directory_hash($plugindirectory);
            $showthisform = $showpluginforms && qa_get('show') == $hash;
            $contents = file_get_contents($pluginfile);
            $metadata = qa_admin_addon_metadata($contents, array('name' => 'Plugin Name', 'uri' => 'Plugin URI', 'description' => 'Plugin Description', 'version' => 'Plugin Version', 'date' => 'Plugin Date', 'author' => 'Plugin Author', 'author_uri' => 'Plugin Author URI', 'license' => 'Plugin License', 'min_q2a' => 'Plugin Minimum Question2Answer Version', 'min_php' => 'Plugin Minimum PHP Version', 'update' => 'Plugin Update Check URI'));
            if (strlen(@$metadata['name'])) {
                $namehtml = qa_html($metadata['name']);
            } else {
                $namehtml = qa_lang_html('admin/unnamed_plugin');
            }
            $plugin_name = $namehtml;
            if (strlen(@$metadata['uri'])) {
                $plugin_uri = qa_html($metadata['uri']);
            }
            if (strlen(@$metadata['version'])) {
                $plugin_version = qa_html($metadata['version']);
            }
            if (strlen(@$metadata['author'])) {
                $plugin_author = qa_html($metadata['author']);
                if (strlen(@$metadata['author_uri'])) {
                    $plugin_author_url = qa_html($metadata['author_uri']);
                }
            }
            if (strlen(@$metadata['version']) && strlen(@$metadata['update'])) {
                $elementid = 'version_check_' . md5($plugindirectory);
                $plugin_update = '(<span id="' . $elementid . '"></span>)';
                $qa_content['script_onloads'][] = array("qa_version_check(" . qa_js($metadata['update']) . ", 'Plugin Version', " . qa_js($metadata['version'], true) . ", 'Plugin URI', " . qa_js($elementid) . ");");
            }
            if (strlen(@$metadata['description'])) {
                $plugin_description = qa_html($metadata['description']);
            }
            //if (isset($pluginoptionmodules[$plugindirectory]))
            $plugin_option = qa_admin_plugin_options_path($plugindirectory);
            if (qa_qa_version_below(@$metadata['min_q2a'])) {
                $plugin_error = qa_lang_html_sub('admin/requires_q2a_version', qa_html($metadata['min_q2a']));
            } elseif (qa_php_version_below(@$metadata['min_php'])) {
                $plugin_error = qa_lang_html_sub('admin/requires_php_version', qa_html($metadata['min_php']));
            }
            $plugin[] = array('tags' => 'id="' . qa_html($hash) . '"', 'name' => @$plugin_name, 'uri' => @$plugin_uri, 'version' => @$plugin_version, 'author' => @$plugin_author, 'author_url' => @$plugin_author_url, 'update' => @$plugin_update, 'description' => @$plugin_description, 'path' => @$plugindirectory, 'option' => @$plugin_option, 'error' => @$plugin_error, 'fields' => array(array('type' => 'custom')));
        }
    }
    return $plugin;
}