/** * Outputs cache to the user */ private function get_cache() { qa_report_process_stage('init_page'); qa_db_connect('qa_page_db_fail_handler'); qa_page_queue_pending(); qa_load_state(); qa_check_login_modules(); if (QA_DEBUG_PERFORMANCE) { if (qa_qa_version_below('1.7')) { qa_usage_mark('setup'); } else { //global $qa_usage; //$qa_usage->mark('setup'); null; } } qa_check_page_clicks(); qa_set_form_security_key(); if (!QA_CACHING_FILE) { $contents = $this->get_cache_db(); } else { $contents = $this->get_cache_file(); } $qa_content = array(); // Dummy contents $userid = qa_get_logged_in_userid(); $questionid = qa_request_part(0); $cookieid = qa_cookie_get(true); if (is_numeric($questionid)) { $question = qa_db_select_with_pending(qa_db_full_post_selectspec($userid, $questionid)); if (is_numeric($questionid) && qa_opt('do_count_q_views') && !preg_match("/^(?:POST|PUT)\$/i", $_SERVER["REQUEST_METHOD"]) && !qa_is_http_post() && qa_is_human_probably() && (!$question['views'] || ($question['lastviewip'] != qa_remote_ip_address() || !isset($question['lastviewip'])) && ($question['createip'] != qa_remote_ip_address() || !isset($question['createip'])) && ($question['userid'] != $userid || !isset($question['userid'])) && ($question['cookieid'] != $cookieid || !isset($question['cookieid'])))) { $qa_content['inc_views_postid'] = $questionid; } else { $qa_content['inc_views_postid'] = null; } qa_do_content_stats($qa_content); } if (QA_DEBUG_PERFORMANCE) { ob_start(); if (qa_qa_version_below('1.7')) { qa_usage_output(); } else { global $qa_usage; $qa_usage->output(); } $contents .= ob_get_contents(); ob_end_clean(); } qa_db_disconnect(); header('Content-type: ' . strtr('^type/^format; charset=utf-8', array('^type' => 'text', '^format' => $this->get_cache_file_extension()))); exit($contents); }
function qa_load_plugin_files() { global $qa_plugin_directory, $qa_plugin_urltoroot; $pluginfiles = glob(QA_PLUGIN_DIR . '*/qa-plugin.php'); foreach ($pluginfiles as $pluginfile) { if (file_exists($pluginfile)) { $contents = file_get_contents($pluginfile); if (preg_match('/Plugin[ \\t]*Minimum[ \\t]*Question2Answer[ \\t]*Version\\:[ \\t]*([0-9\\.]+)\\s/i', $contents, $matches)) { if (qa_qa_version_below($matches[1])) { continue; } } // skip plugin which requires a later version of Q2A if (preg_match('/Plugin[ \\t]*Minimum[ \\t]*PHP[ \\t]*Version\\:[ \\t]*([0-9\\.]+)\\s/i', $contents, $matches)) { if (qa_php_version_below($matches[1])) { continue; } } // skip plugin which requires a later version of PHP $qa_plugin_directory = dirname($pluginfile) . '/'; $qa_plugin_urltoroot = substr($qa_plugin_directory, strlen(QA_BASE_DIR)); require_once $pluginfile; $qa_plugin_directory = null; $qa_plugin_urltoroot = null; } } }
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; }
$elementid = 'version_check_' . md5($plugindirectory); $updatehtml = '(<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) . ");"); } else { $updatehtml = ''; } if (strlen(@$metadata['description'])) { $deschtml = qa_html($metadata['description']); } else { $deschtml = ''; } if (isset($pluginoptionmodules[$plugindirectory]) && !$showthisform) { $deschtml .= (strlen($deschtml) ? ' - ' : '') . '<a href="' . qa_admin_plugin_options_path($plugindirectory) . '">' . qa_lang_html('admin/options') . '</a>'; } $pluginhtml = $namehtml . ' ' . $authorhtml . ' ' . $updatehtml . '<br>' . $deschtml . (strlen($deschtml) ? '<br>' : '') . '<small style="color:#666">' . qa_html($plugindirectory) . '</small>'; if (qa_qa_version_below(@$metadata['min_q2a'])) { $pluginhtml = '<strike style="color:#999">' . $pluginhtml . '</strike><br><span style="color:#f00">' . qa_lang_html_sub('admin/requires_q2a_version', qa_html($metadata['min_q2a'])) . '</span>'; } elseif (qa_php_version_below(@$metadata['min_php'])) { $pluginhtml = '<strike style="color:#999">' . $pluginhtml . '</strike><br><span style="color:#f00">' . qa_lang_html_sub('admin/requires_php_version', qa_html($metadata['min_php'])) . '</span>'; } $qa_content['form_plugin_' . $pluginindex] = array('tags' => 'id="' . qa_html($hash) . '"', 'style' => 'tall', 'fields' => array(array('type' => 'custom', 'html' => $pluginhtml))); if ($showthisform && isset($pluginoptionmodules[$plugindirectory])) { foreach ($pluginoptionmodules[$plugindirectory] as $pluginoptionmodule) { $type = $pluginoptionmodule['type']; $name = $pluginoptionmodule['name']; $module = qa_load_module($type, $name); $form = $module->admin_form($qa_content); if (!isset($form['tags'])) { $form['tags'] = 'method="post" action="' . qa_admin_plugin_options_path($plugindirectory) . '"'; } if (!isset($form['style'])) {
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; }