/** * Return a sorted array of available themes, [theme name] => [theme name] */ function qa_admin_theme_options() { if (qa_to_override(__FUNCTION__)) { $args = func_get_args(); return qa_call_override(__FUNCTION__, $args); } $metadataUtil = new Q2A_Util_Metadata(); foreach (glob(QA_THEME_DIR . '*', GLOB_ONLYDIR) as $directory) { $theme = basename($directory); $metadata = $metadataUtil->fetchFromAddonPath($directory); if (empty($metadata)) { // limit theme parsing to first 8kB $contents = file_get_contents($directory . '/qa-styles.css', false, null, -1, 8192); $metadata = qa_addon_metadata($contents, 'Theme'); } $options[$theme] = isset($metadata['name']) ? $metadata['name'] : $theme; } asort($options, SORT_STRING); return $options; }
foreach ($rawoptions as $rawoption) { $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> ' . '<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_addon_metadata() qa_optionfield_make_select($optionfield, $themeoptions, $value, 'Classic'); $metadataUtil = new Q2A_Util_Metadata(); $themedirectory = QA_THEME_DIR . $value; $metadata = $metadataUtil->fetchFromAddonPath($themedirectory); if (empty($metadata)) { // limit theme parsing to first 8kB $contents = file_get_contents($themedirectory . '/qa-styles.css', false, null, -1, 8192); $metadata = qa_addon_metadata($contents, 'Theme'); } if (strlen(@$metadata['version'])) { $namehtml = 'v' . qa_html($metadata['version']); } else { $namehtml = ''; } if (strlen(@$metadata['uri'])) { if (!strlen($namehtml)) { $namehtml = qa_html($value);
function qa_load_plugin_files() { global $qa_plugin_directory, $qa_plugin_urltoroot; $pluginfiles = glob(QA_PLUGIN_DIR . '*/qa-plugin.php'); $metadataUtil = new Q2A_Util_Metadata(); foreach ($pluginfiles as $pluginfile) { $pluginDirectory = dirname($pluginfile); $metadata = $metadataUtil->fetchFromAddonPath($pluginDirectory); if (empty($metadata)) { // limit plugin parsing to first 8kB $contents = file_get_contents($pluginfile, false, null, -1, 8192); $metadata = qa_addon_metadata($contents, 'Plugin', true); } // skip plugin which requires a later version of Q2A if (isset($metadata['min_q2a']) && qa_qa_version_below($metadata['min_q2a'])) { continue; } // skip plugin which requires a later version of PHP if (isset($metadata['min_php']) && qa_php_version_below($metadata['min_php'])) { continue; } // these variables are utilized in the qa_register_plugin_* functions $qa_plugin_directory = $pluginDirectory . '/'; $qa_plugin_urltoroot = substr($qa_plugin_directory, strlen(QA_BASE_DIR)); require_once $pluginfile; } $qa_plugin_directory = null; $qa_plugin_urltoroot = null; }
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; } if (!empty($pluginfiles)) { $metadataUtil = new Q2A_Util_Metadata(); $sortedPluginFiles = array(); foreach ($pluginfiles as $pluginFile) { $metadata = $metadataUtil->fetchFromAddonPath(dirname($pluginFile)); if (empty($metadata)) { // limit plugin parsing to first 8kB $contents = file_get_contents($pluginFile, false, null, -1, 8192); $metadata = qa_addon_metadata($contents, 'Plugin'); } $metadata['name'] = isset($metadata['name']) && !empty($metadata['name']) ? qa_html($metadata['name']) : qa_lang_html('admin/unnamed_plugin'); $sortedPluginFiles[$pluginFile] = $metadata; } qa_sort_by($sortedPluginFiles, 'name'); $pluginIndex = -1; foreach ($sortedPluginFiles as $pluginFile => $metadata) { $pluginIndex++;
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. 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 . 'app/admin.php'; $uri = qa_post_text('uri'); $version = qa_post_text('version'); $metadataUtil = new Q2A_Util_Metadata(); $metadata = $metadataUtil->fetchFromUrl($uri); 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');