Commit 59ad6e0a by Scott

Coding style (default plugins)

parent 9b5766d2
......@@ -20,93 +20,85 @@
More about this license: http://www.question2answer.org/license.php
*/
class qa_basic_adsense {
public function allow_template($template)
{
return ($template!='admin');
}
class qa_basic_adsense
{
public function allow_template($template)
{
return ($template!='admin');
}
public function allow_region($region)
{
return in_array($region, array('main', 'side', 'full'));
}
public function allow_region($region)
{
return in_array($region, array('main', 'side', 'full'));
}
public function admin_form(&$qa_content)
{
$saved=false;
public function admin_form(&$qa_content)
{
$saved=false;
if (qa_clicked('adsense_save_button')) {
$trimchars="=;\"\' \t\r\n"; // prevent common errors by copying and pasting from Javascript
qa_opt('adsense_publisher_id', trim(qa_post_text('adsense_publisher_id_field'), $trimchars));
$saved=true;
}
if (qa_clicked('adsense_save_button')) {
$trimchars="=;\"\' \t\r\n"; // prevent common errors by copying and pasting from Javascript
qa_opt('adsense_publisher_id', trim(qa_post_text('adsense_publisher_id_field'), $trimchars));
$saved=true;
}
return array(
'ok' => $saved ? 'AdSense settings saved' : null,
return array(
'ok' => $saved ? 'AdSense settings saved' : null,
'fields' => array(
array(
'label' => 'AdSense Publisher ID:',
'value' => qa_html(qa_opt('adsense_publisher_id')),
'tags' => 'name="adsense_publisher_id_field"',
'note' => 'Example: <i>pub-1234567890123456</i>',
),
'fields' => array(
array(
'label' => 'AdSense Publisher ID:',
'value' => qa_html(qa_opt('adsense_publisher_id')),
'tags' => 'name="adsense_publisher_id_field"',
'note' => 'Example: <i>pub-1234567890123456</i>',
),
),
'buttons' => array(
array(
'label' => 'Save Changes',
'tags' => 'name="adsense_save_button"',
),
'buttons' => array(
array(
'label' => 'Save Changes',
'tags' => 'name="adsense_save_button"',
),
);
}
),
);
}
public function output_widget($region, $place, $themeobject, $template, $request, $qa_content)
{
$divstyle='';
public function output_widget($region, $place, $themeobject, $template, $request, $qa_content)
{
$divstyle='';
switch ($region) {
case 'full': // Leaderboard
$divstyle='width:728px; margin:0 auto;';
switch ($region) {
case 'full': // Leaderboard
$divstyle='width:728px; margin:0 auto;';
case 'main': // Leaderboard
$width=728;
$height=90;
$format='728x90_as';
break;
case 'main': // Leaderboard
$width=728;
$height=90;
$format='728x90_as';
break;
case 'side': // Wide skyscraper
$width=160;
$height=600;
$format='160x600_as';
break;
}
case 'side': // Wide skyscraper
$width=160;
$height=600;
$format='160x600_as';
break;
}
?>
<div style="<?php echo $divstyle?>">
<script type="text/javascript">
google_ad_client = <?php echo qa_js(qa_opt('adsense_publisher_id'))?>;
google_ad_width = <?php echo qa_js($width)?>;
google_ad_height = <?php echo qa_js($height)?>;
google_ad_format = <?php echo qa_js($format)?>;
google_ad_type = "text_image";
google_ad_channel = "";
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<script type="text/javascript">
google_ad_client = <?php echo qa_js(qa_opt('adsense_publisher_id'))?>;
google_ad_width = <?php echo qa_js($width)?>;
google_ad_height = <?php echo qa_js($height)?>;
google_ad_format = <?php echo qa_js($format)?>;
google_ad_type = "text_image";
google_ad_channel = "";
</script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</div>
<?php
}
}
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
}
......@@ -34,15 +34,10 @@
*/
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../../');
exit;
}
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../../');
exit;
}
qa_register_plugin_module('widget', 'qa-basic-adsense.php', 'qa_basic_adsense', 'Basic AdSense');
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
qa_register_plugin_module('widget', 'qa-basic-adsense.php', 'qa_basic_adsense', 'Basic AdSense');
......@@ -20,218 +20,212 @@
More about this license: http://www.question2answer.org/license.php
*/
class qa_event_logger {
public function init_queries($table_list)
{
if (qa_opt('event_logger_to_database')) {
$tablename=qa_db_add_table_prefix('eventlog');
if (!in_array($tablename, $table_list)) {
require_once QA_INCLUDE_DIR.'app/users.php';
require_once QA_INCLUDE_DIR.'db/maxima.php';
return 'CREATE TABLE ^eventlog ('.
'datetime DATETIME NOT NULL,'.
'ipaddress VARCHAR (15) CHARACTER SET ascii,'.
'userid '.qa_get_mysql_user_column_type().','.
'handle VARCHAR('.QA_DB_MAX_HANDLE_LENGTH.'),'.
'cookieid BIGINT UNSIGNED,'.
'event VARCHAR (20) CHARACTER SET ascii NOT NULL,'.
'params VARCHAR (800) NOT NULL,'.
'KEY datetime (datetime),'.
'KEY ipaddress (ipaddress),'.
'KEY userid (userid),'.
'KEY event (event)'.
') ENGINE=MyISAM DEFAULT CHARSET=utf8';
}
class qa_event_logger
{
public function init_queries($table_list)
{
if (qa_opt('event_logger_to_database')) {
$tablename=qa_db_add_table_prefix('eventlog');
if (!in_array($tablename, $table_list)) {
require_once QA_INCLUDE_DIR.'app/users.php';
require_once QA_INCLUDE_DIR.'db/maxima.php';
return 'CREATE TABLE ^eventlog ('.
'datetime DATETIME NOT NULL,'.
'ipaddress VARCHAR (15) CHARACTER SET ascii,'.
'userid '.qa_get_mysql_user_column_type().','.
'handle VARCHAR('.QA_DB_MAX_HANDLE_LENGTH.'),'.
'cookieid BIGINT UNSIGNED,'.
'event VARCHAR (20) CHARACTER SET ascii NOT NULL,'.
'params VARCHAR (800) NOT NULL,'.
'KEY datetime (datetime),'.
'KEY ipaddress (ipaddress),'.
'KEY userid (userid),'.
'KEY event (event)'.
') ENGINE=MyISAM DEFAULT CHARSET=utf8';
}
}
}
public function admin_form(&$qa_content)
{
public function admin_form(&$qa_content)
{
// Process form input
// Process form input
$saved=false;
$saved=false;
if (qa_clicked('event_logger_save_button')) {
qa_opt('event_logger_to_database', (int)qa_post_text('event_logger_to_database_field'));
qa_opt('event_logger_to_files', qa_post_text('event_logger_to_files_field'));
qa_opt('event_logger_directory', qa_post_text('event_logger_directory_field'));
qa_opt('event_logger_hide_header', !qa_post_text('event_logger_hide_header_field'));
if (qa_clicked('event_logger_save_button')) {
qa_opt('event_logger_to_database', (int)qa_post_text('event_logger_to_database_field'));
qa_opt('event_logger_to_files', qa_post_text('event_logger_to_files_field'));
qa_opt('event_logger_directory', qa_post_text('event_logger_directory_field'));
qa_opt('event_logger_hide_header', !qa_post_text('event_logger_hide_header_field'));
$saved=true;
}
$saved=true;
}
// Check the validity of the currently entered directory (if any)
// Check the validity of the currently entered directory (if any)
$directory=qa_opt('event_logger_directory');
$directory=qa_opt('event_logger_directory');
$note=null;
$error=null;
if (!strlen($directory))
$note='Please specify a directory that is writable by the web server.';
elseif (!file_exists($directory))
$error='This directory cannot be found. Please enter the full path.';
elseif (!is_dir($directory))
$error='This is a file. Please enter the full path of a directory.';
elseif (!is_writable($directory))
$error='This directory is not writable by the web server. Please choose a different directory, use chown/chmod to change permissions, or contact your web hosting company for assistance.';
// Create the form for display
$note=null;
$error=null;
if (!strlen($directory))
$note='Please specify a directory that is writable by the web server.';
elseif (!file_exists($directory))
$error='This directory cannot be found. Please enter the full path.';
elseif (!is_dir($directory))
$error='This is a file. Please enter the full path of a directory.';
elseif (!is_writable($directory))
$error='This directory is not writable by the web server. Please choose a different directory, use chown/chmod to change permissions, or contact your web hosting company for assistance.';
// Create the form for display
qa_set_display_rules($qa_content, array(
'event_logger_directory_display' => 'event_logger_to_files_field',
'event_logger_hide_header_display' => 'event_logger_to_files_field',
));
return array(
'ok' => ($saved && !isset($error)) ? 'Event log settings saved' : null,
'fields' => array(
array(
'label' => 'Log events to <code>'.QA_MYSQL_TABLE_PREFIX.'eventlog</code> database table',
'tags' => 'name="event_logger_to_database_field"',
'value' => qa_opt('event_logger_to_database'),
'type' => 'checkbox',
),
array(
'label' => 'Log events to daily log files',
'tags' => 'name="event_logger_to_files_field" id="event_logger_to_files_field"',
'value' => qa_opt('event_logger_to_files'),
'type' => 'checkbox',
),
array(
'id' => 'event_logger_directory_display',
'label' => 'Directory for log files - enter full path:',
'value' => qa_html($directory),
'tags' => 'name="event_logger_directory_field"',
'note' => $note,
'error' => qa_html($error),
),
array(
'id' => 'event_logger_hide_header_display',
'label' => 'Include header lines at top of each log file',
'type' => 'checkbox',
'tags' => 'name="event_logger_hide_header_field"',
'value' => !qa_opt('event_logger_hide_header'),
),
qa_set_display_rules($qa_content, array(
'event_logger_directory_display' => 'event_logger_to_files_field',
'event_logger_hide_header_display' => 'event_logger_to_files_field',
));
return array(
'ok' => ($saved && !isset($error)) ? 'Event log settings saved' : null,
'fields' => array(
array(
'label' => 'Log events to <code>'.QA_MYSQL_TABLE_PREFIX.'eventlog</code> database table',
'tags' => 'name="event_logger_to_database_field"',
'value' => qa_opt('event_logger_to_database'),
'type' => 'checkbox',
),
'buttons' => array(
array(
'label' => 'Save Changes',
'tags' => 'name="event_logger_save_button"',
),
array(
'label' => 'Log events to daily log files',
'tags' => 'name="event_logger_to_files_field" id="event_logger_to_files_field"',
'value' => qa_opt('event_logger_to_files'),
'type' => 'checkbox',
),
);
}
array(
'id' => 'event_logger_directory_display',
'label' => 'Directory for log files - enter full path:',
'value' => qa_html($directory),
'tags' => 'name="event_logger_directory_field"',
'note' => $note,
'error' => qa_html($error),
),
public function value_to_text($value)
{
if (is_array($value))
$text='array('.count($value).')';
elseif (strlen($value)>40)
$text=substr($value, 0, 38).'...';
else
$text=$value;
array(
'id' => 'event_logger_hide_header_display',
'label' => 'Include header lines at top of each log file',
'type' => 'checkbox',
'tags' => 'name="event_logger_hide_header_field"',
'value' => !qa_opt('event_logger_hide_header'),
),
),
return strtr($text, "\t\n\r", ' ');
}
'buttons' => array(
array(
'label' => 'Save Changes',
'tags' => 'name="event_logger_save_button"',
),
),
);
}
public function process_event($event, $userid, $handle, $cookieid, $params)
{
if (qa_opt('event_logger_to_database')) {
$paramstring='';
public function value_to_text($value)
{
if (is_array($value))
$text='array('.count($value).')';
elseif (strlen($value)>40)
$text=substr($value, 0, 38).'...';
else
$text=$value;
foreach ($params as $key => $value)
$paramstring.=(strlen($paramstring) ? "\t" : '').$key.'='.$this->value_to_text($value);
return strtr($text, "\t\n\r", ' ');
}
qa_db_query_sub(
'INSERT INTO ^eventlog (datetime, ipaddress, userid, handle, cookieid, event, params) '.
'VALUES (NOW(), $, $, $, #, $, $)',
qa_remote_ip_address(), $userid, $handle, $cookieid, $event, $paramstring
);
}
if (qa_opt('event_logger_to_files')) {
public function process_event($event, $userid, $handle, $cookieid, $params)
{
if (qa_opt('event_logger_to_database')) {
$paramstring='';
// Substitute some placeholders if certain information is missing
foreach ($params as $key => $value)
$paramstring.=(strlen($paramstring) ? "\t" : '').$key.'='.$this->value_to_text($value);
if (!strlen($userid))
$userid='no_userid';
qa_db_query_sub(
'INSERT INTO ^eventlog (datetime, ipaddress, userid, handle, cookieid, event, params) '.
'VALUES (NOW(), $, $, $, #, $, $)',
qa_remote_ip_address(), $userid, $handle, $cookieid, $event, $paramstring
);
}
if (!strlen($handle))
$handle='no_handle';
if (qa_opt('event_logger_to_files')) {
if (!strlen($cookieid))
$cookieid='no_cookieid';
// Substitute some placeholders if certain information is missing
$ip=qa_remote_ip_address();
if (!strlen($ip))
$ip='no_ipaddress';
if (!strlen($userid))
$userid='no_userid';
// Build the log file line to be written
if (!strlen($handle))
$handle='no_handle';
$fixedfields=array(
'Date' => date('Y\-m\-d'),
'Time' => date('H\:i\:s'),
'IPaddress' => $ip,
'UserID' => $userid,
'Username' => $handle,
'CookieID' => $cookieid,
'Event' => $event,
);
if (!strlen($cookieid))
$cookieid='no_cookieid';
$fields=$fixedfields;
$ip=qa_remote_ip_address();
if (!strlen($ip))
$ip='no_ipaddress';
foreach ($params as $key => $value)
$fields['param_'.$key]=$key.'='.$this->value_to_text($value);
// Build the log file line to be written
$string=implode("\t", $fields);
$fixedfields=array(
'Date' => date('Y\-m\-d'),
'Time' => date('H\:i\:s'),
'IPaddress' => $ip,
'UserID' => $userid,
'Username' => $handle,
'CookieID' => $cookieid,
'Event' => $event,
);
// Build the full path and file name
$fields=$fixedfields;
$directory=qa_opt('event_logger_directory');
foreach ($params as $key => $value)
$fields['param_'.$key]=$key.'='.$this->value_to_text($value);
if (substr($directory, -1)!='/')
$directory.='/';
$string=implode("\t", $fields);
$filename=$directory.'q2a-log-'.date('Y\-m\-d').'.txt';
// Build the full path and file name
// Open, lock, write, unlock, close (to prevent interference between multiple writes)
$directory=qa_opt('event_logger_directory');
$exists=file_exists($filename);
if (substr($directory, -1)!='/')
$directory.='/';
$file=@fopen($filename, 'a');
$filename=$directory.'q2a-log-'.date('Y\-m\-d').'.txt';
if (is_resource($file)) {
if (flock($file, LOCK_EX)) {
if ( (!$exists) && (filesize($filename)===0) && !qa_opt('event_logger_hide_header') )
$string="Question2Answer ".QA_VERSION." log file generated by Event Logger plugin.\n".
"This file is formatted as tab-delimited text with UTF-8 encoding.\n\n".
implode("\t", array_keys($fixedfields))."\textras...\n\n".$string;
// Open, lock, write, unlock, close (to prevent interference between multiple writes)
fwrite($file, $string."\n");
flock($file, LOCK_UN);
}
$exists=file_exists($filename);
fclose($file);
$file=@fopen($filename, 'a');
if (is_resource($file)) {
if (flock($file, LOCK_EX)) {
if ( (!$exists) && (filesize($filename)===0) && !qa_opt('event_logger_hide_header') )
$string="Question2Answer ".QA_VERSION." log file generated by Event Logger plugin.\n".
"This file is formatted as tab-delimited text with UTF-8 encoding.\n\n".
implode("\t", array_keys($fixedfields))."\textras...\n\n".$string;
fwrite($file, $string."\n");
flock($file, LOCK_UN);
}
fclose($file);
}
}
}
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
}
......@@ -34,15 +34,10 @@
*/
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../../');
exit;
}
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../../');
exit;
}
qa_register_plugin_module('event', 'qa-event-logger.php', 'qa_event_logger', 'Event Logger');
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
qa_register_plugin_module('event', 'qa-event-logger.php', 'qa_event_logger', 'Event Logger');
......@@ -20,11 +20,6 @@
More about this license: http://www.question2answer.org/license.php
*/
return array(
'page_title' => 'Example plugin page (US English)',
);
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
return array(
'page_title' => 'Example plugin page (US English)',
);
......@@ -20,11 +20,6 @@
More about this license: http://www.question2answer.org/license.php
*/
return array(
'page_title' => 'Example plugin page (UK English)',
);
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
return array(
'page_title' => 'Example plugin page (UK English)',
);
......@@ -20,85 +20,79 @@
More about this license: http://www.question2answer.org/license.php
*/
class qa_example_page {
class qa_example_page
{
private $directory;
private $urltoroot;
private $directory;
private $urltoroot;
public function load_module($directory, $urltoroot)
{
$this->directory=$directory;
$this->urltoroot=$urltoroot;
}
public function load_module($directory, $urltoroot)
{
$this->directory=$directory;
$this->urltoroot=$urltoroot;
}
public function suggest_requests() // for display in admin interface
{
return array(
array(
'title' => 'Example',
'request' => 'example-plugin-page',
'nav' => 'M', // 'M'=main, 'F'=footer, 'B'=before main, 'O'=opposite main, null=none
),
);
}
public function suggest_requests() // for display in admin interface
{
return array(
array(
'title' => 'Example',
'request' => 'example-plugin-page',
'nav' => 'M', // 'M'=main, 'F'=footer, 'B'=before main, 'O'=opposite main, null=none
),
);
}
public function match_request($request)
{
return $request == 'example-plugin-page';
}
public function match_request($request)
{
return $request == 'example-plugin-page';
}
public function process_request($request)
{
$qa_content=qa_content_prepare();
$qa_content['title']=qa_lang_html('example_page/page_title');
$qa_content['error']='An example error';
$qa_content['custom']='Some <b>custom html</b>';
public function process_request($request)
{
$qa_content=qa_content_prepare();
$qa_content['form']=array(
'tags' => 'method="post" action="'.qa_self_html().'"',
$qa_content['title']=qa_lang_html('example_page/page_title');
$qa_content['error']='An example error';
$qa_content['custom']='Some <b>custom html</b>';
'style' => 'wide',
$qa_content['form']=array(
'tags' => 'method="post" action="'.qa_self_html().'"',
'ok' => qa_post_text('okthen') ? 'You clicked OK then!' : null,
'style' => 'wide',
'title' => 'Form title',
'ok' => qa_post_text('okthen') ? 'You clicked OK then!' : null,
'fields' => array(
'request' => array(
'label' => 'The request',
'tags' => 'name="request"',
'value' => qa_html($request),
'error' => qa_html('Another error'),
),
'title' => 'Form title',
'fields' => array(
'request' => array(
'label' => 'The request',
'tags' => 'name="request"',
'value' => qa_html($request),
'error' => qa_html('Another error'),
),
'buttons' => array(
'ok' => array(
'tags' => 'name="okthen"',
'label' => 'OK then',
'value' => '1',
),
),
),
'hidden' => array(
'hiddenfield' => '1',
'buttons' => array(
'ok' => array(
'tags' => 'name="okthen"',
'label' => 'OK then',
'value' => '1',
),
);
),
$qa_content['custom_2']='<p><br>More <i>custom html</i></p>';
'hidden' => array(
'hiddenfield' => '1',
),
);
return $qa_content;
}
$qa_content['custom_2']='<p><br>More <i>custom html</i></p>';
return $qa_content;
}
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
}
......@@ -34,16 +34,11 @@
*/
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../../');
exit;
}
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../../');
exit;
}
qa_register_plugin_module('page', 'qa-example-page.php', 'qa_example_page', 'Example Page');
qa_register_plugin_phrases('qa-example-lang-*.php', 'example_page');
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
qa_register_plugin_module('page', 'qa-example-page.php', 'qa_example_page', 'Example Page');
qa_register_plugin_phrases('qa-example-lang-*.php', 'example_page');
......@@ -20,23 +20,18 @@
More about this license: http://www.question2answer.org/license.php
*/
class qa_html_theme_layer extends qa_html_theme_base {
public function head_css()
{
qa_html_theme_base::head_css();
if (strlen(qa_opt('facebook_app_id')) && strlen(qa_opt('facebook_app_secret')))
$this->output(
'<style>',
'.fb-login-button.fb_iframe_widget.fb_hide_iframes span {display:none;}',
'</style>'
);
class qa_html_theme_layer extends qa_html_theme_base
{
public function head_css()
{
qa_html_theme_base::head_css();
if (strlen(qa_opt('facebook_app_id')) && strlen(qa_opt('facebook_app_secret'))) {
$this->output(
'<style>',
'.fb-login-button.fb_iframe_widget.fb_hide_iframes span {display:none;}',
'</style>'
);
}
}
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
}
......@@ -20,73 +20,68 @@
More about this license: http://www.question2answer.org/license.php
*/
class qa_facebook_login_page {
class qa_facebook_login_page
{
private $directory;
private $urltoroot;
private $directory;
private $urltoroot;
public function load_module($directory, $urltoroot)
{
$this->directory=$directory;
$this->urltoroot=$urltoroot;
}
public function load_module($directory, $urltoroot)
{
$this->directory=$directory;
$this->urltoroot=$urltoroot;
}
public function match_request($request)
{
return ($request=='facebook-login');
}
public function match_request($request)
{
return ($request=='facebook-login');
}
public function process_request($request)
{
if ($request=='facebook-login') {
$app_id=qa_opt('facebook_app_id');
$app_secret=qa_opt('facebook_app_secret');
$tourl=qa_get('to');
if (!strlen($tourl))
$tourl=qa_path_absolute('');
if (strlen($app_id) && strlen($app_secret)) {
require_once $this->directory.'facebook.php';
$facebook = new Facebook(array(
'appId' => $app_id,
'secret' => $app_secret,
'cookie' => true,
));
$fb_userid=$facebook->getUser();
if ($fb_userid) {
try {
$user=$facebook->api('/me?fields=email,name,verified,location,website,about,picture');
if (is_array($user))
qa_log_in_external_user('facebook', $fb_userid, array(
'email' => @$user['email'],
'handle' => @$user['name'],
'confirmed' => @$user['verified'],
'name' => @$user['name'],
'location' => @$user['location']['name'],
'website' => @$user['website'],
'about' => @$user['bio'],
'avatar' => strlen(@$user['picture']['data']['url']) ? qa_retrieve_url($user['picture']['data']['url']) : null,
));
} catch (FacebookApiException $e) {
}
} else {
qa_redirect_raw($facebook->getLoginUrl(array('redirect_uri' => $tourl)));
public function process_request($request)
{
if ($request=='facebook-login') {
$app_id=qa_opt('facebook_app_id');
$app_secret=qa_opt('facebook_app_secret');
$tourl=qa_get('to');
if (!strlen($tourl))
$tourl=qa_path_absolute('');
if (strlen($app_id) && strlen($app_secret)) {
require_once $this->directory.'facebook.php';
$facebook = new Facebook(array(
'appId' => $app_id,
'secret' => $app_secret,
'cookie' => true,
));
$fb_userid=$facebook->getUser();
if ($fb_userid) {
try {
$user=$facebook->api('/me?fields=email,name,verified,location,website,about,picture');
if (is_array($user))
qa_log_in_external_user('facebook', $fb_userid, array(
'email' => @$user['email'],
'handle' => @$user['name'],
'confirmed' => @$user['verified'],
'name' => @$user['name'],
'location' => @$user['location']['name'],
'website' => @$user['website'],
'about' => @$user['bio'],
'avatar' => strlen(@$user['picture']['data']['url']) ? qa_retrieve_url($user['picture']['data']['url']) : null,
));
} catch (FacebookApiException $e) {
}
}
qa_redirect_raw($tourl);
} else {
qa_redirect_raw($facebook->getLoginUrl(array('redirect_uri' => $tourl)));
}
}
}
qa_redirect_raw($tourl);
}
}
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
}
......@@ -20,116 +20,109 @@
More about this license: http://www.question2answer.org/license.php
*/
class qa_facebook_login {
public function match_source($source)
{
return $source=='facebook';
}
class qa_facebook_login
{
public function match_source($source)
{
return $source=='facebook';
}
public function login_html($tourl, $context)
{
$app_id=qa_opt('facebook_app_id');
public function login_html($tourl, $context)
{
$app_id=qa_opt('facebook_app_id');
if (!strlen($app_id))
return;
if (!strlen($app_id))
return;
$this->facebook_html(qa_path_absolute('facebook-login', array('to' => $tourl)), false, $context);
}
$this->facebook_html(qa_path_absolute('facebook-login', array('to' => $tourl)), false, $context);
}
public function logout_html($tourl)
{
$app_id=qa_opt('facebook_app_id');
public function logout_html($tourl)
{
$app_id=qa_opt('facebook_app_id');
if (!strlen($app_id))
return;
if (!strlen($app_id))
return;
$this->facebook_html($tourl, true, 'menu');
}
$this->facebook_html($tourl, true, 'menu');
}
public function facebook_html($tourl, $logout, $context)
{
if (($context=='login') || ($context=='register'))
$size='large';
else
$size='medium';
public function facebook_html($tourl, $logout, $context)
{
if (($context=='login') || ($context=='register'))
$size='large';
else
$size='medium';
?>
<div id="fb-root" style="display:inline;"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : <?php echo qa_js(qa_opt('facebook_app_id'), true)?>,
status : true,
cookie : true,
xfbml : true,
oauth : true
});
FB.Event.subscribe('<?php echo $logout ? 'auth.logout' : 'auth.login'?>', function(response) {
setTimeout("window.location=<?php echo qa_js($tourl)?>", 100);
});
};
(function(d){
var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
d.getElementsByTagName('head')[0].appendChild(js);
}(document));
</script>
<div class="fb-login-button" style="display:inline; vertical-align:middle;" size="<?php echo $size?>" <?php echo $logout ? 'autologoutlink="true"' : 'scope="email,user_about_me,user_location,user_website"'?>>
</div>
<div id="fb-root" style="display:inline;"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : <?php echo qa_js(qa_opt('facebook_app_id'), true)?>,
status : true,
cookie : true,
xfbml : true,
oauth : true
});
FB.Event.subscribe('<?php echo $logout ? 'auth.logout' : 'auth.login'?>', function(response) {
setTimeout("window.location=<?php echo qa_js($tourl)?>", 100);
});
};
(function(d){
var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
d.getElementsByTagName('head')[0].appendChild(js);
}(document));
</script>
<div class="fb-login-button" style="display:inline; vertical-align:middle;" size="<?php echo $size?>" <?php echo $logout ? 'autologoutlink="true"' : 'scope="email,user_about_me,user_location,user_website"'?>>
</div>
<?php
}
}
public function admin_form()
{
$saved=false;
if (qa_clicked('facebook_save_button')) {
qa_opt('facebook_app_id', qa_post_text('facebook_app_id_field'));
qa_opt('facebook_app_secret', qa_post_text('facebook_app_secret_field'));
$saved=true;
}
public function admin_form()
{
$saved=false;
$ready=strlen(qa_opt('facebook_app_id')) && strlen(qa_opt('facebook_app_secret'));
if (qa_clicked('facebook_save_button')) {
qa_opt('facebook_app_id', qa_post_text('facebook_app_id_field'));
qa_opt('facebook_app_secret', qa_post_text('facebook_app_secret_field'));
$saved=true;
}
return array(
'ok' => $saved ? 'Facebook application details saved' : null,
$ready=strlen(qa_opt('facebook_app_id')) && strlen(qa_opt('facebook_app_secret'));
'fields' => array(
array(
'label' => 'Facebook App ID:',
'value' => qa_html(qa_opt('facebook_app_id')),
'tags' => 'name="facebook_app_id_field"',
),
return array(
'ok' => $saved ? 'Facebook application details saved' : null,
array(
'label' => 'Facebook App Secret:',
'value' => qa_html(qa_opt('facebook_app_secret')),
'tags' => 'name="facebook_app_secret_field"',
'error' => $ready ? null : 'To use Facebook Login, please <a href="http://developers.facebook.com/setup/" target="_blank">set up a Facebook application</a>.',
),
'fields' => array(
array(
'label' => 'Facebook App ID:',
'value' => qa_html(qa_opt('facebook_app_id')),
'tags' => 'name="facebook_app_id_field"',
),
'buttons' => array(
array(
'label' => 'Save Changes',
'tags' => 'name="facebook_save_button"',
),
array(
'label' => 'Facebook App Secret:',
'value' => qa_html(qa_opt('facebook_app_secret')),
'tags' => 'name="facebook_app_secret_field"',
'error' => $ready ? null : 'To use Facebook Login, please <a href="http://developers.facebook.com/setup/" target="_blank">set up a Facebook application</a>.',
),
);
}
),
'buttons' => array(
array(
'label' => 'Save Changes',
'tags' => 'name="facebook_save_button"',
),
),
);
}
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
}
......@@ -35,19 +35,15 @@
*/
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../../');
exit;
}
if (!QA_FINAL_EXTERNAL_USERS) { // login modules don't work with external user integration
qa_register_plugin_module('login', 'qa-facebook-login.php', 'qa_facebook_login', 'Facebook Login');
qa_register_plugin_module('page', 'qa-facebook-login-page.php', 'qa_facebook_login_page', 'Facebook Login Page');
qa_register_plugin_layer('qa-facebook-layer.php', 'Facebook Login Layer');
}
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../../');
exit;
}
// login modules don't work with external user integration
if (!QA_FINAL_EXTERNAL_USERS) {
qa_register_plugin_module('login', 'qa-facebook-login.php', 'qa_facebook_login', 'Facebook Login');
qa_register_plugin_module('page', 'qa-facebook-login-page.php', 'qa_facebook_login_page', 'Facebook Login Page');
qa_register_plugin_layer('qa-facebook-layer.php', 'Facebook Login Layer');
}
......@@ -20,61 +20,55 @@
More about this license: http://www.question2answer.org/license.php
*/
class qa_mouseover_admin_form {
public function option_default($option)
{
if ($option === 'mouseover_content_max_len')
return 480;
}
class qa_mouseover_admin_form
{
public function option_default($option)
{
if ($option === 'mouseover_content_max_len')
return 480;
}
public function admin_form(&$qa_content)
{
$saved = qa_clicked('mouseover_save_button');
if ($saved) {
qa_opt('mouseover_content_on', (int) qa_post_text('mouseover_content_on_field'));
qa_opt('mouseover_content_max_len', (int) qa_post_text('mouseover_content_max_len_field'));
}
public function admin_form(&$qa_content)
{
$saved = qa_clicked('mouseover_save_button');
qa_set_display_rules($qa_content, array(
'mouseover_content_max_len_display' => 'mouseover_content_on_field',
));
if ($saved) {
qa_opt('mouseover_content_on', (int) qa_post_text('mouseover_content_on_field'));
qa_opt('mouseover_content_max_len', (int) qa_post_text('mouseover_content_max_len_field'));
}
return array(
'ok' => $saved ? 'Mouseover settings saved' : null,
qa_set_display_rules($qa_content, array(
'mouseover_content_max_len_display' => 'mouseover_content_on_field',
));
'fields' => array(
array(
'label' => 'Show content preview on mouseover in question lists',
'type' => 'checkbox',
'value' => qa_opt('mouseover_content_on'),
'tags' => 'name="mouseover_content_on_field" id="mouseover_content_on_field"',
),
return array(
'ok' => $saved ? 'Mouseover settings saved' : null,
array(
'id' => 'mouseover_content_max_len_display',
'label' => 'Maximum length of preview:',
'suffix' => 'characters',
'type' => 'number',
'value' => (int) qa_opt('mouseover_content_max_len'),
'tags' => 'name="mouseover_content_max_len_field"',
),
'fields' => array(
array(
'label' => 'Show content preview on mouseover in question lists',
'type' => 'checkbox',
'value' => qa_opt('mouseover_content_on'),
'tags' => 'name="mouseover_content_on_field" id="mouseover_content_on_field"',
),
'buttons' => array(
array(
'label' => 'Save Changes',
'tags' => 'name="mouseover_save_button"',
),
array(
'id' => 'mouseover_content_max_len_display',
'label' => 'Maximum length of preview:',
'suffix' => 'characters',
'type' => 'number',
'value' => (int) qa_opt('mouseover_content_max_len'),
'tags' => 'name="mouseover_content_max_len_field"',
),
);
}
),
'buttons' => array(
array(
'label' => 'Save Changes',
'tags' => 'name="mouseover_save_button"',
),
),
);
}
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
}
......@@ -20,53 +20,47 @@
More about this license: http://www.question2answer.org/license.php
*/
class qa_html_theme_layer extends qa_html_theme_base {
public function q_list($q_list)
{
if (!empty($q_list['qs']) && qa_opt('mouseover_content_on')) { // first check it is not an empty list and the feature is turned on
// Collect the question ids of all items in the question list (so we can do this in one DB query)
$postids = array();
foreach ($q_list['qs'] as $question) {
if (isset($question['raw']['postid']))
$postids[] = $question['raw']['postid'];
}
class qa_html_theme_layer extends qa_html_theme_base
{
public function q_list($q_list)
{
if (!empty($q_list['qs']) && qa_opt('mouseover_content_on')) { // first check it is not an empty list and the feature is turned on
// Collect the question ids of all items in the question list (so we can do this in one DB query)
$postids = array();
foreach ($q_list['qs'] as $question) {
if (isset($question['raw']['postid']))
$postids[] = $question['raw']['postid'];
}
if (!empty($postids)) {
if (!empty($postids)) {
// Retrieve the content for these questions from the database and put into an array fetching
// the minimal amount of characters needed to determine the string should be shortened or not
// Retrieve the content for these questions from the database and put into an array fetching
// the minimal amount of characters needed to determine the string should be shortened or not
$maxlength = qa_opt('mouseover_content_max_len');
$result = qa_db_query_sub('SELECT postid, LEFT(content, #) content, format FROM ^posts WHERE postid IN (#)', $maxlength + 1, $postids);
$postinfo = qa_db_read_all_assoc($result, 'postid');
$maxlength = qa_opt('mouseover_content_max_len');
$result = qa_db_query_sub('SELECT postid, LEFT(content, #) content, format FROM ^posts WHERE postid IN (#)', $maxlength + 1, $postids);
$postinfo = qa_db_read_all_assoc($result, 'postid');
// Get the regular expression fragment to use for blocked words and the maximum length of content to show
// Get the regular expression fragment to use for blocked words and the maximum length of content to show
$blockwordspreg = qa_get_block_words_preg();
$blockwordspreg = qa_get_block_words_preg();
// Now add the popup to the title for each question
// Now add the popup to the title for each question
foreach ($q_list['qs'] as $index => $question) {
if (isset($postinfo[$question['raw']['postid']])) {
$thispost = $postinfo[$question['raw']['postid']];
$text = qa_viewer_text($thispost['content'], $thispost['format'], array('blockwordspreg' => $blockwordspreg));
$text = qa_shorten_string_line($text, $maxlength);
$title = isset($question['title']) ? $question['title'] : '';
$q_list['qs'][$index]['title'] = sprintf('<span title="%s">%s</span>', qa_html($text), $title);
}
foreach ($q_list['qs'] as $index => $question) {
if (isset($postinfo[$question['raw']['postid']])) {
$thispost = $postinfo[$question['raw']['postid']];
$text = qa_viewer_text($thispost['content'], $thispost['format'], array('blockwordspreg' => $blockwordspreg));
$text = qa_shorten_string_line($text, $maxlength);
$title = isset($question['title']) ? $question['title'] : '';
$q_list['qs'][$index]['title'] = sprintf('<span title="%s">%s</span>', qa_html($text), $title);
}
}
}
qa_html_theme_base::q_list($q_list); // call back through to the default function
}
qa_html_theme_base::q_list($q_list); // call back through to the default function
}
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
}
......@@ -34,16 +34,11 @@
*/
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../../');
exit;
}
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../../');
exit;
}
qa_register_plugin_layer('qa-mouseover-layer.php', 'Mouseover Layer');
qa_register_plugin_module('module', 'qa-mouseover-admin-form.php', 'qa_mouseover_admin_form', 'Mouseover Layer');
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
qa_register_plugin_layer('qa-mouseover-layer.php', 'Mouseover Layer');
qa_register_plugin_module('module', 'qa-mouseover-admin-form.php', 'qa_mouseover_admin_form', 'Mouseover Layer');
......@@ -20,18 +20,12 @@
More about this license: http://www.question2answer.org/license.php
*/
class qa_html_theme_layer extends qa_html_theme_base {
public function head_links()
{
qa_html_theme_base::head_links();
$this->output('<link rel="search" type="application/opensearchdescription+xml" title="'.qa_html(qa_opt('site_title')).'" href="'.qa_path_html('opensearch.xml').'"/>');
}
class qa_html_theme_layer extends qa_html_theme_base
{
public function head_links()
{
qa_html_theme_base::head_links();
$this->output('<link rel="search" type="application/opensearchdescription+xml" title="'.qa_html(qa_opt('site_title')).'" href="'.qa_path_html('opensearch.xml').'"/>');
}
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
}
......@@ -20,38 +20,32 @@
More about this license: http://www.question2answer.org/license.php
*/
class qa_opensearch_xml {
public function match_request($request)
{
return ($request=='opensearch.xml');
}
public function process_request($request)
{
@ini_set('display_errors', 0); // we don't want to show PHP errors inside XML
class qa_opensearch_xml
{
public function match_request($request)
{
return ($request=='opensearch.xml');
}
$titlexml=qa_xml(qa_opt('site_title'));
$template=str_replace('_searchTerms_placeholder_', '{searchTerms}', qa_path_absolute('search', array('q' => '_searchTerms_placeholder_')));
public function process_request($request)
{
@ini_set('display_errors', 0); // we don't want to show PHP errors inside XML
header('Content-type: text/xml; charset=utf-8');
$titlexml=qa_xml(qa_opt('site_title'));
$template=str_replace('_searchTerms_placeholder_', '{searchTerms}', qa_path_absolute('search', array('q' => '_searchTerms_placeholder_')));
echo '<?xml version="1.0" encoding="UTF-8"?>'."\n";
echo '<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" xmlns:moz="http://www.mozilla.org/2006/browser/search/">'."\n";
header('Content-type: text/xml; charset=utf-8');
echo "\t<ShortName>".$titlexml."</ShortName>\n";
echo "\t<Description>".qa_xml(qa_lang('main/search_button')).' '.$titlexml."</Description>\n";
echo "\t".'<Url type="text/html" method="get" template="'.qa_xml($template).'"/>'."\n";
echo "\t<InputEncoding>UTF-8</InputEncoding>\n";
echo '<?xml version="1.0" encoding="UTF-8"?>'."\n";
echo '<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" xmlns:moz="http://www.mozilla.org/2006/browser/search/">'."\n";
echo '</OpenSearchDescription>'."\n";
echo "\t<ShortName>".$titlexml."</ShortName>\n";
echo "\t<Description>".qa_xml(qa_lang('main/search_button')).' '.$titlexml."</Description>\n";
echo "\t".'<Url type="text/html" method="get" template="'.qa_xml($template).'"/>'."\n";
echo "\t<InputEncoding>UTF-8</InputEncoding>\n";
return null;
}
echo '</OpenSearchDescription>'."\n";
return null;
}
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
}
......@@ -34,16 +34,11 @@
*/
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../../');
exit;
}
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../../');
exit;
}
qa_register_plugin_layer('qa-opensearch-layer.php', 'OpenSearch Layer');
qa_register_plugin_module('page', 'qa-opensearch-page.php', 'qa_opensearch_xml', 'OpenSearch XML');
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
qa_register_plugin_layer('qa-opensearch-layer.php', 'OpenSearch Layer');
qa_register_plugin_module('page', 'qa-opensearch-page.php', 'qa_opensearch_xml', 'OpenSearch XML');
......@@ -34,15 +34,10 @@
*/
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../../');
exit;
}
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../../');
exit;
}
qa_register_plugin_module('captcha', 'qa-recaptcha-captcha.php', 'qa_recaptcha_captcha', 'reCAPTCHA');
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
qa_register_plugin_module('captcha', 'qa-recaptcha-captcha.php', 'qa_recaptcha_captcha', 'reCAPTCHA');
......@@ -20,129 +20,117 @@
More about this license: http://www.question2answer.org/license.php
*/
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../');
exit;
class qa_recaptcha_captcha
{
private $directory;
public function load_module($directory, $urltoroot)
{
$this->directory=$directory;
}
class qa_recaptcha_captcha {
public function admin_form()
{
$saved=false;
private $directory;
if (qa_clicked('recaptcha_save_button')) {
qa_opt('recaptcha_public_key', qa_post_text('recaptcha_public_key_field'));
qa_opt('recaptcha_private_key', qa_post_text('recaptcha_private_key_field'));
public function load_module($directory, $urltoroot)
{
$this->directory=$directory;
$saved=true;
}
$form=array(
'ok' => $saved ? 'reCAPTCHA settings saved' : null,
public function admin_form()
{
$saved=false;
if (qa_clicked('recaptcha_save_button')) {
qa_opt('recaptcha_public_key', qa_post_text('recaptcha_public_key_field'));
qa_opt('recaptcha_private_key', qa_post_text('recaptcha_private_key_field'));
$saved=true;
}
$form=array(
'ok' => $saved ? 'reCAPTCHA settings saved' : null,
'fields' => array(
'public' => array(
'label' => 'reCAPTCHA public key:',
'value' => qa_opt('recaptcha_public_key'),
'tags' => 'name="recaptcha_public_key_field"',
),
'private' => array(
'label' => 'reCAPTCHA private key:',
'value' => qa_opt('recaptcha_private_key'),
'tags' => 'name="recaptcha_private_key_field"',
'error' => $this->recaptcha_error_html(),
),
'fields' => array(
'public' => array(
'label' => 'reCAPTCHA public key:',
'value' => qa_opt('recaptcha_public_key'),
'tags' => 'name="recaptcha_public_key_field"',
),
'buttons' => array(
array(
'label' => 'Save Changes',
'tags' => 'name="recaptcha_save_button"',
),
'private' => array(
'label' => 'reCAPTCHA private key:',
'value' => qa_opt('recaptcha_private_key'),
'tags' => 'name="recaptcha_private_key_field"',
'error' => $this->recaptcha_error_html(),
),
);
),
return $form;
}
'buttons' => array(
array(
'label' => 'Save Changes',
'tags' => 'name="recaptcha_save_button"',
),
),
);
return $form;
}
public function recaptcha_error_html()
{
if (!function_exists('fsockopen'))
return 'To use reCAPTCHA, the fsockopen() PHP function must be enabled on your server. Please check with your system administrator.';
elseif ( (!strlen(trim(qa_opt('recaptcha_public_key')))) || (!strlen(trim(qa_opt('recaptcha_private_key')))) ) {
require_once $this->directory.'recaptchalib.php';
public function recaptcha_error_html()
{
if (!function_exists('fsockopen'))
return 'To use reCAPTCHA, the fsockopen() PHP function must be enabled on your server. Please check with your system administrator.';
$url=recaptcha_get_signup_url(@$_SERVER['HTTP_HOST'], qa_opt('site_title'));
elseif ( (!strlen(trim(qa_opt('recaptcha_public_key')))) || (!strlen(trim(qa_opt('recaptcha_private_key')))) ) {
require_once $this->directory.'recaptchalib.php';
return 'To use reCAPTCHA, you must <a href="'.qa_html($url).'">sign up</a> to get these keys.';
}
$url=recaptcha_get_signup_url(@$_SERVER['HTTP_HOST'], qa_opt('site_title'));
return null;
return 'To use reCAPTCHA, you must <a href="'.qa_html($url).'">sign up</a> to get these keys.';
}
return null;
}
public function allow_captcha()
{
return function_exists('fsockopen') && strlen(trim(qa_opt('recaptcha_public_key'))) && strlen(trim(qa_opt('recaptcha_private_key')));
}
public function allow_captcha()
{
return function_exists('fsockopen') && strlen(trim(qa_opt('recaptcha_public_key'))) && strlen(trim(qa_opt('recaptcha_private_key')));
}
public function form_html(&$qa_content, $error)
{
require_once $this->directory.'recaptchalib.php';
$language=qa_opt('site_language');
if (strpos('|en|nl|fr|de|pt|ru|es|tr|', '|'.$language.'|')===false) // supported as of 3/2010
$language='en';
public function form_html(&$qa_content, $error)
{
require_once $this->directory.'recaptchalib.php';
$qa_content['script_lines'][]=array(
"var RecaptchaOptions={",
"\ttheme:'white',",
"\tlang:".qa_js($language),
"};",
);
$language=qa_opt('site_language');
if (strpos('|en|nl|fr|de|pt|ru|es|tr|', '|'.$language.'|')===false) // supported as of 3/2010
$language='en';
return recaptcha_get_html(qa_opt('recaptcha_public_key'), $error, qa_is_https_probably());
}
$qa_content['script_lines'][]=array(
"var RecaptchaOptions={",
"\ttheme:'white',",
"\tlang:".qa_js($language),
"};",
);
return recaptcha_get_html(qa_opt('recaptcha_public_key'), $error, qa_is_https_probably());
}
public function validate_post(&$error)
{
if ( (!empty($_POST['recaptcha_challenge_field'])) && (!empty($_POST['recaptcha_response_field'])) ) {
require_once $this->directory.'recaptchalib.php';
$answer=recaptcha_check_answer(
qa_opt('recaptcha_private_key'),
qa_remote_ip_address(),
$_POST['recaptcha_challenge_field'],
$_POST['recaptcha_response_field']
);
public function validate_post(&$error)
{
if ( (!empty($_POST['recaptcha_challenge_field'])) && (!empty($_POST['recaptcha_response_field'])) ) {
require_once $this->directory.'recaptchalib.php';
if ($answer->is_valid)
return true;
$answer=recaptcha_check_answer(
qa_opt('recaptcha_private_key'),
qa_remote_ip_address(),
$_POST['recaptcha_challenge_field'],
$_POST['recaptcha_response_field']
);
$error=@$answer->error;
}
if ($answer->is_valid)
return true;
return false;
$error=@$answer->error;
}
return false;
}
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
}
......@@ -34,15 +34,10 @@
*/
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../../');
exit;
}
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../../');
exit;
}
qa_register_plugin_module('widget', 'qa-tag-cloud.php', 'qa_tag_cloud', 'Tag Cloud');
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
qa_register_plugin_module('widget', 'qa-tag-cloud.php', 'qa_tag_cloud', 'Tag Cloud');
......@@ -20,131 +20,125 @@
More about this license: http://www.question2answer.org/license.php
*/
class qa_tag_cloud {
public function option_default($option)
{
if ($option === 'tag_cloud_count_tags')
return 100;
if ($option === 'tag_cloud_font_size')
return 24;
if ($option === 'tag_cloud_minimal_font_size')
return 8;
if ($option === 'tag_cloud_size_popular')
return true;
class qa_tag_cloud
{
public function option_default($option)
{
if ($option === 'tag_cloud_count_tags')
return 100;
if ($option === 'tag_cloud_font_size')
return 24;
if ($option === 'tag_cloud_minimal_font_size')
return 8;
if ($option === 'tag_cloud_size_popular')
return true;
}
public function admin_form()
{
$saved = qa_clicked('tag_cloud_save_button');
if ($saved) {
qa_opt('tag_cloud_count_tags', (int) qa_post_text('tag_cloud_count_tags_field'));
qa_opt('tag_cloud_font_size', (int) qa_post_text('tag_cloud_font_size_field'));
qa_opt('tag_cloud_minimal_font_size', (int) qa_post_text('tag_cloud_minimal_font_size_field'));
qa_opt('tag_cloud_size_popular', (int) qa_post_text('tag_cloud_size_popular_field'));
}
return array(
'ok' => $saved ? 'Tag cloud settings saved' : null,
public function admin_form()
{
$saved = qa_clicked('tag_cloud_save_button');
'fields' => array(
array(
'label' => 'Maximum tags to show:',
'type' => 'number',
'value' => (int) qa_opt('tag_cloud_count_tags'),
'suffix' => 'tags',
'tags' => 'name="tag_cloud_count_tags_field"',
),
if ($saved) {
qa_opt('tag_cloud_count_tags', (int) qa_post_text('tag_cloud_count_tags_field'));
qa_opt('tag_cloud_font_size', (int) qa_post_text('tag_cloud_font_size_field'));
qa_opt('tag_cloud_minimal_font_size', (int) qa_post_text('tag_cloud_minimal_font_size_field'));
qa_opt('tag_cloud_size_popular', (int) qa_post_text('tag_cloud_size_popular_field'));
}
array(
'label' => 'Biggest font size:',
'suffix' => 'pixels',
'type' => 'number',
'value' => (int) qa_opt('tag_cloud_font_size'),
'tags' => 'name="tag_cloud_font_size_field"',
),
return array(
'ok' => $saved ? 'Tag cloud settings saved' : null,
'fields' => array(
array(
'label' => 'Maximum tags to show:',
'type' => 'number',
'value' => (int) qa_opt('tag_cloud_count_tags'),
'suffix' => 'tags',
'tags' => 'name="tag_cloud_count_tags_field"',
),
array(
'label' => 'Biggest font size:',
'suffix' => 'pixels',
'type' => 'number',
'value' => (int) qa_opt('tag_cloud_font_size'),
'tags' => 'name="tag_cloud_font_size_field"',
),
array(
'label' => 'Smallest allowed font size:',
'suffix' => 'pixels',
'type' => 'number',
'value' => (int) qa_opt('tag_cloud_minimal_font_size'),
'tags' => 'name="tag_cloud_minimal_font_size_field"',
),
array(
'label' => 'Font size represents tag popularity',
'type' => 'checkbox',
'value' => qa_opt('tag_cloud_size_popular'),
'tags' => 'name="tag_cloud_size_popular_field"',
),
array(
'label' => 'Smallest allowed font size:',
'suffix' => 'pixels',
'type' => 'number',
'value' => (int) qa_opt('tag_cloud_minimal_font_size'),
'tags' => 'name="tag_cloud_minimal_font_size_field"',
),
'buttons' => array(
array(
'label' => 'Save Changes',
'tags' => 'name="tag_cloud_save_button"',
),
array(
'label' => 'Font size represents tag popularity',
'type' => 'checkbox',
'value' => qa_opt('tag_cloud_size_popular'),
'tags' => 'name="tag_cloud_size_popular_field"',
),
);
}
),
'buttons' => array(
array(
'label' => 'Save Changes',
'tags' => 'name="tag_cloud_save_button"',
),
),
);
}
public function allow_template($template)
{
$allowed = array(
'activity', 'qa', 'questions', 'hot', 'ask', 'categories', 'question',
'tag', 'tags', 'unanswered', 'user', 'users', 'search', 'admin', 'custom',
);
return in_array($template, $allowed);
}
public function allow_template($template)
{
$allowed = array(
'activity', 'qa', 'questions', 'hot', 'ask', 'categories', 'question',
'tag', 'tags', 'unanswered', 'user', 'users', 'search', 'admin', 'custom',
);
return in_array($template, $allowed);
}
public function allow_region($region)
{
return ($region === 'side');
}
public function allow_region($region)
{
return ($region === 'side');
}
public function output_widget($region, $place, $themeobject, $template, $request, $qa_content)
{
require_once QA_INCLUDE_DIR . 'db/selects.php';
$populartags = qa_db_single_select(qa_db_popular_tags_selectspec(0, (int) qa_opt('tag_cloud_count_tags')));
public function output_widget($region, $place, $themeobject, $template, $request, $qa_content)
{
require_once QA_INCLUDE_DIR . 'db/selects.php';
$maxcount = reset($populartags);
$populartags = qa_db_single_select(qa_db_popular_tags_selectspec(0, (int) qa_opt('tag_cloud_count_tags')));
$themeobject->output(sprintf('<h2 style="margin-top: 0; padding-top: 0;">%s</h2>', qa_lang_html('main/popular_tags')));
$maxcount = reset($populartags);
$themeobject->output('<div style="font-size: 10px;">');
$themeobject->output(sprintf('<h2 style="margin-top: 0; padding-top: 0;">%s</h2>', qa_lang_html('main/popular_tags')));
$maxsize = qa_opt('tag_cloud_font_size');
$minsize = qa_opt('tag_cloud_minimal_font_size');
$scale = qa_opt('tag_cloud_size_popular');
$blockwordspreg = qa_get_block_words_preg();
$themeobject->output('<div style="font-size: 10px;">');
foreach ($populartags as $tag => $count) {
$matches = qa_block_words_match_all($tag, $blockwordspreg);
if (empty($matches)) {
if ($scale) {
$size = number_format($maxsize * $count / $maxcount, 1);
if ($size < $minsize)
$size = $minsize;
} else
$size = $maxsize;
$maxsize = qa_opt('tag_cloud_font_size');
$minsize = qa_opt('tag_cloud_minimal_font_size');
$scale = qa_opt('tag_cloud_size_popular');
$blockwordspreg = qa_get_block_words_preg();
$themeobject->output(sprintf('<a href="%s" style="font-size: %dpx; vertical-align: baseline;">%s</a>', qa_path_html('tag/' . $tag), $size, qa_html($tag)));
}
}
foreach ($populartags as $tag => $count) {
$matches = qa_block_words_match_all($tag, $blockwordspreg);
if (empty($matches)) {
if ($scale) {
$size = number_format($maxsize * $count / $maxcount, 1);
if ($size < $minsize)
$size = $minsize;
} else
$size = $maxsize;
$themeobject->output('</div>');
$themeobject->output(sprintf('<a href="%s" style="font-size: %dpx; vertical-align: baseline;">%s</a>', qa_path_html('tag/' . $tag), $size, qa_html($tag)));
}
}
$themeobject->output('</div>');
}
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
}
......@@ -34,16 +34,11 @@
*/
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../../');
exit;
}
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../../');
exit;
}
qa_register_plugin_module('editor', 'qa-wysiwyg-editor.php', 'qa_wysiwyg_editor', 'WYSIWYG Editor');
qa_register_plugin_module('page', 'qa-wysiwyg-upload.php', 'qa_wysiwyg_upload', 'WYSIWYG Upload');
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
qa_register_plugin_module('editor', 'qa-wysiwyg-editor.php', 'qa_wysiwyg_editor', 'WYSIWYG Editor');
qa_register_plugin_module('page', 'qa-wysiwyg-upload.php', 'qa_wysiwyg_upload', 'WYSIWYG Upload');
......@@ -245,8 +245,3 @@ class qa_wysiwyg_editor
return qa_html(number_format($bytes/1048576, 1));
}
}
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
......@@ -56,8 +56,3 @@ class qa_wysiwyg_upload
return null;
}
}
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
......@@ -34,15 +34,10 @@
*/
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../../');
exit;
}
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../../');
exit;
}
qa_register_plugin_module('page', 'qa-xml-sitemap.php', 'qa_xml_sitemap', 'XML Sitemap');
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
qa_register_plugin_module('page', 'qa-xml-sitemap.php', 'qa_xml_sitemap', 'XML Sitemap');
......@@ -20,278 +20,272 @@
More about this license: http://www.question2answer.org/license.php
*/
class qa_xml_sitemap {
private $directory;
private $urltoroot;
public function load_module($directory, $urltoroot)
{
$this->directory=$directory;
$this->urltoroot=$urltoroot;
}
class qa_xml_sitemap
{
private $directory;
private $urltoroot;
public function load_module($directory, $urltoroot)
{
$this->directory=$directory;
$this->urltoroot=$urltoroot;
}
public function option_default($option)
{
switch ($option) {
case 'xml_sitemap_show_questions':
case 'xml_sitemap_show_users':
case 'xml_sitemap_show_tag_qs':
case 'xml_sitemap_show_category_qs':
case 'xml_sitemap_show_categories':
return true;
break;
}
public function option_default($option)
{
switch ($option) {
case 'xml_sitemap_show_questions':
case 'xml_sitemap_show_users':
case 'xml_sitemap_show_tag_qs':
case 'xml_sitemap_show_category_qs':
case 'xml_sitemap_show_categories':
return true;
break;
}
}
public function admin_form()
{
require_once QA_INCLUDE_DIR.'qa-util-sort.php';
$saved=false;
public function admin_form()
{
require_once QA_INCLUDE_DIR.'qa-util-sort.php';
if (qa_clicked('xml_sitemap_save_button')) {
qa_opt('xml_sitemap_show_questions', (int)qa_post_text('xml_sitemap_show_questions_field'));
$saved=false;
if (!QA_FINAL_EXTERNAL_USERS)
qa_opt('xml_sitemap_show_users', (int)qa_post_text('xml_sitemap_show_users_field'));
if (qa_clicked('xml_sitemap_save_button')) {
qa_opt('xml_sitemap_show_questions', (int)qa_post_text('xml_sitemap_show_questions_field'));
if (qa_using_tags())
qa_opt('xml_sitemap_show_tag_qs', (int)qa_post_text('xml_sitemap_show_tag_qs_field'));
if (!QA_FINAL_EXTERNAL_USERS)
qa_opt('xml_sitemap_show_users', (int)qa_post_text('xml_sitemap_show_users_field'));
if (qa_using_categories()) {
qa_opt('xml_sitemap_show_category_qs', (int)qa_post_text('xml_sitemap_show_category_qs_field'));
qa_opt('xml_sitemap_show_categories', (int)qa_post_text('xml_sitemap_show_categories_field'));
}
if (qa_using_tags())
qa_opt('xml_sitemap_show_tag_qs', (int)qa_post_text('xml_sitemap_show_tag_qs_field'));
$saved=true;
if (qa_using_categories()) {
qa_opt('xml_sitemap_show_category_qs', (int)qa_post_text('xml_sitemap_show_category_qs_field'));
qa_opt('xml_sitemap_show_categories', (int)qa_post_text('xml_sitemap_show_categories_field'));
}
$form=array(
'ok' => $saved ? 'XML sitemap settings saved' : null,
$saved=true;
}
$form=array(
'ok' => $saved ? 'XML sitemap settings saved' : null,
'fields' => array(
'questions' => array(
'label' => 'Include question pages',
'type' => 'checkbox',
'value' => (int)qa_opt('xml_sitemap_show_questions'),
'tags' => 'name="xml_sitemap_show_questions_field"',
),
'fields' => array(
'questions' => array(
'label' => 'Include question pages',
'type' => 'checkbox',
'value' => (int)qa_opt('xml_sitemap_show_questions'),
'tags' => 'name="xml_sitemap_show_questions_field"',
),
),
'buttons' => array(
array(
'label' => 'Save Changes',
'tags' => 'name="xml_sitemap_save_button"',
),
'buttons' => array(
array(
'label' => 'Save Changes',
'tags' => 'name="xml_sitemap_save_button"',
),
),
);
if (!QA_FINAL_EXTERNAL_USERS)
$form['fields']['users']=array(
'label' => 'Include user pages',
'type' => 'checkbox',
'value' => (int)qa_opt('xml_sitemap_show_users'),
'tags' => 'name="xml_sitemap_show_users_field"',
);
if (!QA_FINAL_EXTERNAL_USERS)
$form['fields']['users']=array(
'label' => 'Include user pages',
'type' => 'checkbox',
'value' => (int)qa_opt('xml_sitemap_show_users'),
'tags' => 'name="xml_sitemap_show_users_field"',
);
if (qa_using_tags())
$form['fields']['tagqs']=array(
'label' => 'Include question list for each tag',
'type' => 'checkbox',
'value' => (int)qa_opt('xml_sitemap_show_tag_qs'),
'tags' => 'name="xml_sitemap_show_tag_qs_field"',
);
if (qa_using_categories()) {
$form['fields']['categoryqs']=array(
'label' => 'Include question list for each category',
'type' => 'checkbox',
'value' => (int)qa_opt('xml_sitemap_show_category_qs'),
'tags' => 'name="xml_sitemap_show_category_qs_field"',
);
if (qa_using_tags())
$form['fields']['tagqs']=array(
'label' => 'Include question list for each tag',
'type' => 'checkbox',
'value' => (int)qa_opt('xml_sitemap_show_tag_qs'),
'tags' => 'name="xml_sitemap_show_tag_qs_field"',
);
$form['fields']['categories']=array(
'label' => 'Include category browser',
'type' => 'checkbox',
'value' => (int)qa_opt('xml_sitemap_show_categories'),
'tags' => 'name="xml_sitemap_show_categories_field"',
);
}
if (qa_using_categories()) {
$form['fields']['categoryqs']=array(
'label' => 'Include question list for each category',
'type' => 'checkbox',
'value' => (int)qa_opt('xml_sitemap_show_category_qs'),
'tags' => 'name="xml_sitemap_show_category_qs_field"',
);
return $form;
$form['fields']['categories']=array(
'label' => 'Include category browser',
'type' => 'checkbox',
'value' => (int)qa_opt('xml_sitemap_show_categories'),
'tags' => 'name="xml_sitemap_show_categories_field"',
);
}
return $form;
}
public function suggest_requests()
{
return array(
array(
'title' => 'XML Sitemap',
'request' => 'sitemap.xml',
'nav' => null, // 'M'=main, 'F'=footer, 'B'=before main, 'O'=opposite main, null=none
),
);
}
public function suggest_requests()
{
return array(
array(
'title' => 'XML Sitemap',
'request' => 'sitemap.xml',
'nav' => null, // 'M'=main, 'F'=footer, 'B'=before main, 'O'=opposite main, null=none
),
);
}
public function match_request($request)
{
return ($request=='sitemap.xml');
}
public function match_request($request)
{
return ($request=='sitemap.xml');
}
public function process_request($request)
{
@ini_set('display_errors', 0); // we don't want to show PHP errors inside XML
$siteurl=qa_opt('site_url');
public function process_request($request)
{
@ini_set('display_errors', 0); // we don't want to show PHP errors inside XML
header('Content-type: text/xml; charset=utf-8');
$siteurl=qa_opt('site_url');
echo '<?xml version="1.0" encoding="UTF-8"?>'."\n";
echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'."\n";
header('Content-type: text/xml; charset=utf-8');
echo '<?xml version="1.0" encoding="UTF-8"?>'."\n";
echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'."\n";
// Question pages
if (qa_opt('xml_sitemap_show_questions')) {
$hotstats=qa_db_read_one_assoc(qa_db_query_sub(
"SELECT MIN(hotness) AS base, MAX(hotness)-MIN(hotness) AS spread FROM ^posts WHERE type='Q'"
));
// Question pages
$nextpostid=0;
if (qa_opt('xml_sitemap_show_questions')) {
$hotstats=qa_db_read_one_assoc(qa_db_query_sub(
"SELECT MIN(hotness) AS base, MAX(hotness)-MIN(hotness) AS spread FROM ^posts WHERE type='Q'"
));
while (1) {
$questions=qa_db_read_all_assoc(qa_db_query_sub(
"SELECT postid, title, hotness FROM ^posts WHERE postid>=# AND type='Q' ORDER BY postid LIMIT 100",
$nextpostid
));
$nextpostid=0;
if (!count($questions))
break;
while (1) {
$questions=qa_db_read_all_assoc(qa_db_query_sub(
"SELECT postid, title, hotness FROM ^posts WHERE postid>=# AND type='Q' ORDER BY postid LIMIT 100",
$nextpostid
));
foreach ($questions as $question) {
$this->sitemap_output(qa_q_request($question['postid'], $question['title']),
0.1+0.9*($question['hotness']-$hotstats['base'])/(1+$hotstats['spread']));
$nextpostid=max($nextpostid, $question['postid']+1);
}
if (!count($questions))
break;
foreach ($questions as $question) {
$this->sitemap_output(qa_q_request($question['postid'], $question['title']),
0.1+0.9*($question['hotness']-$hotstats['base'])/(1+$hotstats['spread']));
$nextpostid=max($nextpostid, $question['postid']+1);
}
}
}
// User pages
// User pages
if ((!QA_FINAL_EXTERNAL_USERS) && qa_opt('xml_sitemap_show_users')) {
$nextuserid=0;
if ((!QA_FINAL_EXTERNAL_USERS) && qa_opt('xml_sitemap_show_users')) {
$nextuserid=0;
while (1) {
$users=qa_db_read_all_assoc(qa_db_query_sub(
"SELECT userid, handle FROM ^users WHERE userid>=# ORDER BY userid LIMIT 100",
$nextuserid
));
while (1) {
$users=qa_db_read_all_assoc(qa_db_query_sub(
"SELECT userid, handle FROM ^users WHERE userid>=# ORDER BY userid LIMIT 100",
$nextuserid
));
if (!count($users))
break;
if (!count($users))
break;
foreach ($users as $user) {
$this->sitemap_output('user/'.$user['handle'], 0.25);
$nextuserid=max($nextuserid, $user['userid']+1);
}
foreach ($users as $user) {
$this->sitemap_output('user/'.$user['handle'], 0.25);
$nextuserid=max($nextuserid, $user['userid']+1);
}
}
}
// Tag pages
// Tag pages
if (qa_using_tags() && qa_opt('xml_sitemap_show_tag_qs')) {
$nextwordid=0;
if (qa_using_tags() && qa_opt('xml_sitemap_show_tag_qs')) {
$nextwordid=0;
while (1) {
$tagwords=qa_db_read_all_assoc(qa_db_query_sub(
"SELECT wordid, word, tagcount FROM ^words WHERE wordid>=# AND tagcount>0 ORDER BY wordid LIMIT 100",
$nextwordid
));
while (1) {
$tagwords=qa_db_read_all_assoc(qa_db_query_sub(
"SELECT wordid, word, tagcount FROM ^words WHERE wordid>=# AND tagcount>0 ORDER BY wordid LIMIT 100",
$nextwordid
));
if (!count($tagwords))
break;
if (!count($tagwords))
break;
foreach ($tagwords as $tagword) {
$this->sitemap_output('tag/'.$tagword['word'], 0.5/(1+(1/$tagword['tagcount']))); // priority between 0.25 and 0.5 depending on tag frequency
$nextwordid=max($nextwordid, $tagword['wordid']+1);
}
foreach ($tagwords as $tagword) {
$this->sitemap_output('tag/'.$tagword['word'], 0.5/(1+(1/$tagword['tagcount']))); // priority between 0.25 and 0.5 depending on tag frequency
$nextwordid=max($nextwordid, $tagword['wordid']+1);
}
}
}
// Question list for each category
// Question list for each category
if (qa_using_categories() && qa_opt('xml_sitemap_show_category_qs')) {
$nextcategoryid=0;
if (qa_using_categories() && qa_opt('xml_sitemap_show_category_qs')) {
$nextcategoryid=0;
while (1) {
$categories=qa_db_read_all_assoc(qa_db_query_sub(
"SELECT categoryid, backpath FROM ^categories WHERE categoryid>=# AND qcount>0 ORDER BY categoryid LIMIT 2",
$nextcategoryid
));
while (1) {
$categories=qa_db_read_all_assoc(qa_db_query_sub(
"SELECT categoryid, backpath FROM ^categories WHERE categoryid>=# AND qcount>0 ORDER BY categoryid LIMIT 2",
$nextcategoryid
));
if (!count($categories))
break;
if (!count($categories))
break;
foreach ($categories as $category) {
$this->sitemap_output('questions/'.implode('/', array_reverse(explode('/', $category['backpath']))), 0.5);
$nextcategoryid=max($nextcategoryid, $category['categoryid']+1);
}
foreach ($categories as $category) {
$this->sitemap_output('questions/'.implode('/', array_reverse(explode('/', $category['backpath']))), 0.5);
$nextcategoryid=max($nextcategoryid, $category['categoryid']+1);
}
}
}
// Pages in category browser
// Pages in category browser
if (qa_using_categories() && qa_opt('xml_sitemap_show_categories')) {
$this->sitemap_output('categories', 0.5);
if (qa_using_categories() && qa_opt('xml_sitemap_show_categories')) {
$this->sitemap_output('categories', 0.5);
$nextcategoryid=0;
$nextcategoryid=0;
while (1) { // only find categories with a child
$categories=qa_db_read_all_assoc(qa_db_query_sub(
"SELECT parent.categoryid, parent.backpath FROM ^categories AS parent ".
"JOIN ^categories AS child ON child.parentid=parent.categoryid WHERE parent.categoryid>=# GROUP BY parent.categoryid LIMIT 100",
$nextcategoryid
));
while (1) { // only find categories with a child
$categories=qa_db_read_all_assoc(qa_db_query_sub(
"SELECT parent.categoryid, parent.backpath FROM ^categories AS parent ".
"JOIN ^categories AS child ON child.parentid=parent.categoryid WHERE parent.categoryid>=# GROUP BY parent.categoryid LIMIT 100",
$nextcategoryid
));
if (!count($categories))
break;
if (!count($categories))
break;
foreach ($categories as $category) {
$this->sitemap_output('categories/'.implode('/', array_reverse(explode('/', $category['backpath']))), 0.5);
$nextcategoryid=max($nextcategoryid, $category['categoryid']+1);
}
foreach ($categories as $category) {
$this->sitemap_output('categories/'.implode('/', array_reverse(explode('/', $category['backpath']))), 0.5);
$nextcategoryid=max($nextcategoryid, $category['categoryid']+1);
}
}
// Finish up...
echo "</urlset>\n";
return null;
}
private function sitemap_output($request, $priority)
{
echo "\t<url>\n".
"\t\t<loc>".qa_xml(qa_path($request, null, qa_opt('site_url')))."</loc>\n".
"\t\t<priority>".max(0, min(1.0, $priority))."</priority>\n".
"\t</url>\n";
}
// Finish up...
echo "</urlset>\n";
return null;
}
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
private function sitemap_output($request, $priority)
{
echo "\t<url>\n".
"\t\t<loc>".qa_xml(qa_path($request, null, qa_opt('site_url')))."</loc>\n".
"\t\t<priority>".max(0, min(1.0, $priority))."</priority>\n".
"\t</url>\n";
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment