Commit 2a744533 by Gideon Greenspan

1.5.1

parent b12de3f3
1.5.1
\ No newline at end of file
...@@ -180,6 +180,9 @@ ...@@ -180,6 +180,9 @@
QA_USER_LEVEL_BASIC, QA_USER_LEVEL_EDITOR, QA_USER_LEVEL_ADMIN, QA_USER_LEVEL_SUPER QA_USER_LEVEL_BASIC, QA_USER_LEVEL_EDITOR, QA_USER_LEVEL_ADMIN, QA_USER_LEVEL_SUPER
To indicate that the user is blocked you can also add an element 'blocked' with the value true.
Blocked users are not allowed to perform any write actions such as voting or posting.
The result of this function will be passed to your other function qa_get_logged_in_user_html() The result of this function will be passed to your other function qa_get_logged_in_user_html()
so you may add any other elements to the returned array if they will be useful to you. so you may add any other elements to the returned array if they will be useful to you.
......
...@@ -35,14 +35,32 @@ ...@@ -35,14 +35,32 @@
$metadata=qa_admin_addon_metadata(qa_retrieve_url($uri), array( $metadata=qa_admin_addon_metadata(qa_retrieve_url($uri), array(
'version' => $versionkey, 'version' => $versionkey,
'uri' => $urikey, 'uri' => $urikey,
// these two elements are only present for plugins, not themes, so we can hard code them here
'min_q2a' => 'Plugin Minimum Question2Answer Version',
'min_php' => 'Plugin Minimum PHP Version',
)); ));
if (strlen(@$metadata['version'])) { if (strlen(@$metadata['version'])) {
if (strcmp($metadata['version'], $version)) { if (strcmp($metadata['version'], $version)) {
$response=qa_lang_html_sub('admin/version_get_x', qa_html('v'.$metadata['version'])); if (qa_qa_version_below(@$metadata['min_q2a']))
$response=strtr(qa_lang_html('admin/version_requires_q2a'), array(
if (strlen(@$metadata['uri'])) '^1' => qa_html('v'.$metadata['version']),
$response='<A HREF="'.qa_html($metadata['uri']).'" STYLE="color:#d00;">'.$response.'</A>'; '^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 } else
$response=qa_lang_html('admin/version_latest'); $response=qa_lang_html('admin/version_latest');
......
...@@ -434,7 +434,7 @@ ...@@ -434,7 +434,7 @@
$fields['what']=qa_lang_html($isquestion ? 'main/asked' : ($isanswer ? 'main/answered' : 'main/commented')); $fields['what']=qa_lang_html($isquestion ? 'main/asked' : ($isanswer ? 'main/answered' : 'main/commented'));
if (@$options['whatlink'] && !$isquestion) if (@$options['whatlink'] && !$isquestion)
$fields['what_url']='?show='.qa_html($postid).'#'.qa_html($anchor); $fields['what_url']=qa_path_html(qa_request(), array('show' => $postid), null, null, qa_anchor($post['basetype'], $postid));
} }
if (isset($post['created']) && @$options['whenview']) { if (isset($post['created']) && @$options['whenview']) {
...@@ -1091,13 +1091,17 @@ ...@@ -1091,13 +1091,17 @@
{ {
if ( if (
(!qa_permit_value_error($page['permit'], qa_get_logged_in_userid(), qa_get_logged_in_level(), qa_get_logged_in_flags())) || !isset($page['permit']) (!qa_permit_value_error($page['permit'], qa_get_logged_in_userid(), qa_get_logged_in_level(), qa_get_logged_in_flags())) || !isset($page['permit'])
) ) {
$url=qa_custom_page_url($page);
$navigation[($page['flags'] & QA_PAGE_FLAGS_EXTERNAL) ? ('custom-'.$page['pageid']) : $page['tags']]=array( $navigation[($page['flags'] & QA_PAGE_FLAGS_EXTERNAL) ? ('custom-'.$page['pageid']) : $page['tags']]=array(
'url' => qa_html(qa_custom_page_url($page)), 'url' => qa_html($url),
'label' => qa_html($page['title']), 'label' => qa_html($page['title']),
'opposite' => ($page['nav']=='O'), 'opposite' => ($page['nav']=='O'),
'target' => ($page['flags'] & QA_PAGE_FLAGS_NEW_WINDOW) ? '_blank' : null, 'target' => ($page['flags'] & QA_PAGE_FLAGS_NEW_WINDOW) ? '_blank' : null,
'selected' => ($page['flags'] & QA_PAGE_FLAGS_EXTERNAL) && ( ($url==qa_path(qa_request())) || ($url==qa_self_html()) ),
); );
}
} }
...@@ -1635,7 +1639,8 @@ ...@@ -1635,7 +1639,8 @@
if (qa_to_override(__FUNCTION__)) { $args=func_get_args(); return qa_call_override(__FUNCTION__, $args); } if (qa_to_override(__FUNCTION__)) { $args=func_get_args(); return qa_call_override(__FUNCTION__, $args); }
if ($size>0) if ($size>0)
return '<IMG SRC="http://www.gravatar.com/avatar/'.md5(strtolower(trim($email))).'?s='.(int)$size. return '<IMG SRC="'.(qa_is_https_probably() ? 'https' : 'http').
'://www.gravatar.com/avatar/'.md5(strtolower(trim($email))).'?s='.(int)$size.
'" WIDTH="'.(int)$size.'" HEIGHT="'.(int)$size.'" CLASS="qa-avatar-image"/>'; '" WIDTH="'.(int)$size.'" HEIGHT="'.(int)$size.'" CLASS="qa-avatar-image"/>';
else else
return null; return null;
......
...@@ -234,6 +234,27 @@ ...@@ -234,6 +234,27 @@
} }
function qa_post_set_created($postid, $created)
/*
Set the created date of $postid to $created, which is a unix timestamp.
*/
{
$oldpost=qa_post_get_full($postid);
qa_db_post_set_created($postid, $created);
switch ($oldpost['basetype']) {
case 'Q':
qa_db_hotness_update($postid);
break;
case 'A':
qa_db_hotness_update($oldpost['parentid']);
break;
}
}
function qa_post_delete($postid) function qa_post_delete($postid)
/* /*
Delete $postid from the database, hiding it first if appropriate. Delete $postid from the database, hiding it first if appropriate.
......
...@@ -87,6 +87,7 @@ ...@@ -87,6 +87,7 @@
{ {
require_once QA_INCLUDE_DIR.'qa-util-string.php'; require_once QA_INCLUDE_DIR.'qa-util-string.php';
require_once QA_INCLUDE_DIR.'qa-db-maxima.php'; require_once QA_INCLUDE_DIR.'qa-db-maxima.php';
require_once QA_INCLUDE_DIR.'qa-db-users.php';
if (!strlen($handle)) if (!strlen($handle))
$handle=qa_lang('users/registered_user'); $handle=qa_lang('users/registered_user');
...@@ -99,12 +100,12 @@ ...@@ -99,12 +100,12 @@
$filtermodules=qa_load_modules_with('filter', 'filter_handle'); $filtermodules=qa_load_modules_with('filter', 'filter_handle');
foreach ($filtermodules as $filtermodule) foreach ($filtermodules as $filtermodule)
$filtermodule->filter_handle($handle, null); // filter first without worrying about errors, since our goal is to get a valid one $filtermodule->filter_handle($tryhandle, null); // filter first without worrying about errors, since our goal is to get a valid one
$haderror=false; $haderror=false;
foreach ($filtermodules as $filtermodule) { foreach ($filtermodules as $filtermodule) {
$error=$filtermodule->filter_handle($handle, null); // now check for errors after we've filtered $error=$filtermodule->filter_handle($tryhandle, null); // now check for errors after we've filtered
if (isset($error)) if (isset($error))
$haderror=true; $haderror=true;
} }
......
...@@ -563,7 +563,10 @@ ...@@ -563,7 +563,10 @@
Return flags (see QA_USER_FLAGS_*) of currently logged in user, or null if none Return flags (see QA_USER_FLAGS_*) of currently logged in user, or null if none
*/ */
{ {
return QA_FINAL_EXTERNAL_USERS ? 0 : qa_get_logged_in_user_field('flags'); if (QA_FINAL_EXTERNAL_USERS)
return qa_get_logged_in_user_field('blocked') ? QA_USER_FLAGS_USER_BLOCKED : 0;
else
return qa_get_logged_in_user_field('flags');
} }
......
...@@ -25,8 +25,8 @@ ...@@ -25,8 +25,8 @@
*/ */
define('QA_VERSION', '1.5'); // also used as suffix for .js and .css requests define('QA_VERSION', '1.5.1'); // also used as suffix for .js and .css requests
define('QA_BUILD_DATE', '2012-01-18'); define('QA_BUILD_DATE', '2012-03-18');
// Execution section of this file - remainder contains function definitions // Execution section of this file - remainder contains function definitions
...@@ -47,6 +47,54 @@ ...@@ -47,6 +47,54 @@
qa_db_allow_connect(); qa_db_allow_connect();
// Version comparison functions
function qa_version_to_float($version)
/*
Converts the $version string (e.g. 1.6.2.2) to a floating point that can be used for greater/lesser comparisons
(PHP's version_compare() function is not quite suitable for our needs)
*/
{
$value=0.0;
if (preg_match('/[0-9\.]+/', $version, $matches)) {
$parts=explode('.', $matches[0]);
$units=1.0;
foreach ($parts as $part) {
$value+=min($part, 999)*$units;
$units/=1000;
}
}
return $value;
}
function qa_qa_version_below($version)
/*
Returns true if the current Q2A version is lower than $version, if both are valid version strings for qa_version_to_float()
*/
{
$minqa=qa_version_to_float($version);
$thisqa=qa_version_to_float(QA_VERSION);
return $minqa && $thisqa && ($thisqa<$minqa);
}
function qa_php_version_below($version)
/*
Returns true if the current PHP version is lower than $version, if both are valid version strings for qa_version_to_float()
*/
{
$minphp=qa_version_to_float($version);
$thisphp=qa_version_to_float(phpversion());
return $minphp && $thisphp && ($thisphp<$minphp);
}
// Initialization functions called above // Initialization functions called above
function qa_initialize_php() function qa_initialize_php()
...@@ -54,7 +102,7 @@ ...@@ -54,7 +102,7 @@
Set up and verify the PHP environment for Q2A, including unregistering globals if necessary Set up and verify the PHP environment for Q2A, including unregistering globals if necessary
*/ */
{ {
if ( ((float)phpversion()) < 4.3 ) if (qa_php_version_below('4.3'))
qa_fatal_error('This requires PHP 4.3 or later'); qa_fatal_error('This requires PHP 4.3 or later');
error_reporting(E_ALL); // be ultra-strict about error checking error_reporting(E_ALL); // be ultra-strict about error checking
...@@ -151,12 +199,24 @@ ...@@ -151,12 +199,24 @@
define('QA_FINAL_EXTERNAL_USERS', true); define('QA_FINAL_EXTERNAL_USERS', true);
// Undo WordPress's addition of magic quotes to various things (leave $_COOKIE as is since WP code might need that) // Undo WordPress's addition of magic quotes to various things (leave $_COOKIE as is since WP code might need that)
foreach ($_GET as $key => $value)
$_GET[$key]=strtr(stripslashes($value), array('\\\'' => '\'', '\"' => '"')); // also compensate for WordPress's .htaccess file function qa_undo_wordpress_quoting($param, $isget)
{
foreach ($_POST as $key => $value) if (is_array($param)) { //
$_POST[$key]=stripslashes($value); foreach ($param as $key => $value)
$param[$key]=qa_undo_wordpress_quoting($value, $isget);
} else {
$param=stripslashes($param);
if ($isget)
$param=strtr($param, array('\\\'' => '\'', '\"' => '"')); // also compensate for WordPress's .htaccess file
}
return $param;
}
$_GET=qa_undo_wordpress_quoting($_GET, true);
$_POST=qa_undo_wordpress_quoting($_POST, false);
$_SERVER['PHP_SELF']=stripslashes($_SERVER['PHP_SELF']); $_SERVER['PHP_SELF']=stripslashes($_SERVER['PHP_SELF']);
} else { } else {
...@@ -226,11 +286,11 @@ ...@@ -226,11 +286,11 @@
$contents=file_get_contents($pluginfile); $contents=file_get_contents($pluginfile);
if (preg_match('/Plugin[ \t]*Minimum[ \t]*Question2Answer[ \t]*Version\:[ \t]*([0-9\.]+)\s/i', $contents, $matches)) if (preg_match('/Plugin[ \t]*Minimum[ \t]*Question2Answer[ \t]*Version\:[ \t]*([0-9\.]+)\s/i', $contents, $matches))
if ( ((float)QA_VERSION>0) && ($matches[1]>(float)QA_VERSION) ) if (qa_qa_version_below($matches[1]))
continue; // skip plugin which requires a later version of Q2A 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 (preg_match('/Plugin[ \t]*Minimum[ \t]*PHP[ \t]*Version\:[ \t]*([0-9\.]+)\s/i', $contents, $matches))
if ( ((float)phpversion()>0) && ($matches[1]>(float)phpversion()) ) if (qa_php_version_below($matches[1]))
continue; // skip plugin which requires a later version of PHP continue; // skip plugin which requires a later version of PHP
$qa_plugin_directory=dirname($pluginfile).'/'; $qa_plugin_directory=dirname($pluginfile).'/';
......
...@@ -175,6 +175,18 @@ ...@@ -175,6 +175,18 @@
} }
function qa_db_post_set_created($postid, $created)
/*
Set the created date of $postid to $created, which is a unix timestamp
*/
{
qa_db_query_sub(
'UPDATE ^posts SET created=FROM_UNIXTIME(#) WHERE postid=#',
$created, $postid
);
}
function qa_db_post_delete($postid) function qa_db_post_delete($postid)
/* /*
Deletes post $postid from the database (will also delete any votes on the post due to foreign key cascading) Deletes post $postid from the database (will also delete any votes on the post due to foreign key cascading)
......
...@@ -247,6 +247,8 @@ ...@@ -247,6 +247,8 @@
'users_title' => 'Users', 'users_title' => 'Users',
'users_voted' => 'Users who voted:', 'users_voted' => 'Users who voted:',
'version_get_x' => 'get ^', 'version_get_x' => 'get ^',
'version_requires_php' => '^1 requires PHP ^2',
'version_requires_q2a' => '^1 requires Q2A ^2',
'version_latest_unknown' => 'latest unknown', 'version_latest_unknown' => 'latest unknown',
'version_latest' => 'latest', 'version_latest' => 'latest',
'viewing_title' => 'Viewing', 'viewing_title' => 'Viewing',
......
...@@ -347,7 +347,7 @@ ...@@ -347,7 +347,7 @@
array_push($showoptions, 'show_user_points', '', 'sort_answers_by', 'show_selected_first', 'page_size_q_as', 'show_a_form_immediate'); array_push($showoptions, 'show_user_points', '', 'sort_answers_by', 'show_selected_first', 'page_size_q_as', 'show_a_form_immediate');
if (qa_opt('comment_on_qs') || qa_opt('command_on_as')) if (qa_opt('comment_on_qs') || qa_opt('comment_on_as'))
array_push($showoptions, 'show_fewer_cs_from', 'show_fewer_cs_count', 'show_c_reply_buttons'); array_push($showoptions, 'show_fewer_cs_from', 'show_fewer_cs_count', 'show_c_reply_buttons');
$showoptins[]=''; $showoptins[]='';
...@@ -544,7 +544,7 @@ ...@@ -544,7 +544,7 @@
array_push($showoptions, 'max_rate_ip_qs', 'max_rate_user_qs', 'max_rate_ip_as', 'max_rate_user_as'); array_push($showoptions, 'max_rate_ip_qs', 'max_rate_user_qs', 'max_rate_ip_as', 'max_rate_user_as');
if (qa_opt('comment_on_qs') || qa_opt('command_on_as')) if (qa_opt('comment_on_qs') || qa_opt('comment_on_as'))
array_push($showoptions, 'max_rate_ip_cs', 'max_rate_user_cs'); array_push($showoptions, 'max_rate_ip_cs', 'max_rate_user_cs');
$showoptions[]=''; $showoptions[]='';
...@@ -970,7 +970,7 @@ ...@@ -970,7 +970,7 @@
$updatehtml='(<SPAN ID="'.$elementid.'">...</SPAN>)'; $updatehtml='(<SPAN ID="'.$elementid.'">...</SPAN>)';
$qa_content['script_onloads'][]=array( $qa_content['script_onloads'][]=array(
"qa_version_check(".qa_js($metadata['update']).", 'Theme Version', ".qa_js($metadata['version']).", 'Theme URI', ".qa_js($elementid).");" "qa_version_check(".qa_js($metadata['update']).", 'Theme Version', ".qa_js($metadata['version'], true).", 'Theme URI', ".qa_js($elementid).");"
); );
} else } else
......
...@@ -133,7 +133,7 @@ ...@@ -133,7 +133,7 @@
$updatehtml='(<SPAN ID="'.$elementid.'">...</SPAN>)'; $updatehtml='(<SPAN ID="'.$elementid.'">...</SPAN>)';
$qa_content['script_onloads'][]=array( $qa_content['script_onloads'][]=array(
"qa_version_check(".qa_js($metadata['update']).", 'Plugin Version', ".qa_js($metadata['version']).", 'Plugin URI', ".qa_js($elementid).");" "qa_version_check(".qa_js($metadata['update']).", 'Plugin Version', ".qa_js($metadata['version'], true).", 'Plugin URI', ".qa_js($elementid).");"
); );
} else } else
...@@ -151,11 +151,11 @@ ...@@ -151,11 +151,11 @@
$pluginhtml=$namehtml.' '.$authorhtml.' '.$updatehtml.'<BR>'.$deschtml.(strlen($deschtml) ? '<BR>' : ''). $pluginhtml=$namehtml.' '.$authorhtml.' '.$updatehtml.'<BR>'.$deschtml.(strlen($deschtml) ? '<BR>' : '').
'<SMALL STYLE="color:#666">'.qa_html($plugindirectory).'</SMALL>'; '<SMALL STYLE="color:#666">'.qa_html($plugindirectory).'</SMALL>';
if (is_numeric(@$metadata['min_q2a']) && ((float)QA_VERSION>0) && $metadata['min_q2a']>(float)QA_VERSION) if (qa_qa_version_below(@$metadata['min_q2a']))
$pluginhtml='<STRIKE STYLE="color:#999">'.$pluginhtml.'</STRIKE><BR><SPAN STYLE="color:#f00">'. $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>'; qa_lang_html_sub('admin/requires_q2a_version', qa_html($metadata['min_q2a'])).'</SPAN>';
elseif (is_numeric(@$metadata['min_php']) && ((float)phpversion()>0) && $metadata['min_php']>(float)phpversion()) elseif (qa_php_version_below(@$metadata['min_php']))
$pluginhtml='<STRIKE STYLE="color:#999">'.$pluginhtml.'</STRIKE><BR><SPAN STYLE="color:#f00">'. $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_lang_html_sub('admin/requires_php_version', qa_html($metadata['min_php'])).'</SPAN>';
......
...@@ -144,7 +144,8 @@ ...@@ -144,7 +144,8 @@
$qa_content['suggest_next']=qa_lang_html_sub('misc/suggest_favorites_add', '<SPAN CLASS="qa-favorite-image">&nbsp;</SPAN>'); $qa_content['suggest_next']=qa_lang_html_sub('misc/suggest_favorites_add', '<SPAN CLASS="qa-favorite-image">&nbsp;</SPAN>');
$qa_content['navigation']['sub']=qa_account_sub_navigation(); if (!QA_FINAL_EXTERNAL_USERS)
$qa_content['navigation']['sub']=qa_account_sub_navigation();
return $qa_content; return $qa_content;
......
...@@ -449,7 +449,7 @@ ...@@ -449,7 +449,7 @@
if (!isset($in['tags'])) if (!isset($in['tags']))
$in['tags']=qa_tagstring_to_tags($question['tags']); $in['tags']=qa_tagstring_to_tags($question['tags']);
if (!isset($in['categoryid'])) if (!array_key_exists('categoryid', $in))
$in['categoryid']=$question['categoryid']; $in['categoryid']=$question['categoryid'];
$setnotify=$question['isbyuser'] ? qa_combine_notify_email($question['userid'], $in['notify'], $in['email']) : $question['notify']; $setnotify=$question['isbyuser'] ? qa_combine_notify_email($question['userid'], $in['notify'], $in['email']) : $question['notify'];
......
...@@ -67,7 +67,7 @@ ...@@ -67,7 +67,7 @@
$qa_content['ranking']=array( $qa_content['ranking']=array(
'items' => array(), 'items' => array(),
'rows' => ceil(qa_opt('page_size_users')/qa_opt('columns_users')), 'rows' => ceil(count($users)/qa_opt('columns_users')),
'type' => 'users' 'type' => 'users'
); );
......
...@@ -95,7 +95,7 @@ ...@@ -95,7 +95,7 @@
If no user is logged in, call through to the login modules to see if they want to log someone in If no user is logged in, call through to the login modules to see if they want to log someone in
*/ */
{ {
if (!qa_is_logged_in()) { if ((!QA_FINAL_EXTERNAL_USERS) && !qa_is_logged_in()) {
$loginmodules=qa_load_modules_with('login', 'check_login'); $loginmodules=qa_load_modules_with('login', 'check_login');
foreach ($loginmodules as $loginmodule) { foreach ($loginmodules as $loginmodule) {
...@@ -222,15 +222,10 @@ ...@@ -222,15 +222,10 @@
// Set appropriate selected flags for navigation (not done in qa_content_prepare() since it also applies to sub-navigation) // Set appropriate selected flags for navigation (not done in qa_content_prepare() since it also applies to sub-navigation)
$selfpathhtml=qa_path_html($requestlower);
foreach ($qa_content['navigation'] as $navtype => $navigation) foreach ($qa_content['navigation'] as $navtype => $navigation)
if (is_array($navigation) && ($navtype!='cat')) if (is_array($navigation) && ($navtype!='cat'))
foreach ($navigation as $navprefix => $navlink) foreach ($navigation as $navprefix => $navlink)
if ( if (substr($requestlower.'$', 0, strlen($navprefix)) == $navprefix)
(substr($requestlower.'$', 0, strlen($navprefix)) == $navprefix) ||
(strtolower(@$navlink['url'])==$selfpathhtml) // this check is needed for custom links that go to Q2A pages
)
$qa_content['navigation'][$navtype][$navprefix]['selected']=true; $qa_content['navigation'][$navtype][$navprefix]['selected']=true;
// Slide down notifications // Slide down notifications
...@@ -671,15 +666,17 @@ ...@@ -671,15 +666,17 @@
} else { } else {
require_once QA_INCLUDE_DIR.'qa-util-string.php'; require_once QA_INCLUDE_DIR.'qa-util-string.php';
$loginmodules=qa_load_modules_with('login', 'login_html'); if (!QA_FINAL_EXTERNAL_USERS) {
$loginmodules=qa_load_modules_with('login', 'login_html');
foreach ($loginmodules as $tryname => $module) {
ob_start(); foreach ($loginmodules as $tryname => $module) {
$module->login_html(isset($topath) ? (qa_opt('site_url').$topath) : qa_path($request, $_GET, qa_opt('site_url')), 'menu'); ob_start();
$label=ob_get_clean(); $module->login_html(isset($topath) ? (qa_opt('site_url').$topath) : qa_path($request, $_GET, qa_opt('site_url')), 'menu');
$label=ob_get_clean();
if (strlen($label))
$qa_content['navigation']['user'][implode('-', qa_string_to_words($tryname))]=array('label' => $label); if (strlen($label))
$qa_content['navigation']['user'][implode('-', qa_string_to_words($tryname))]=array('label' => $label);
}
} }
if (!empty($userlinks['login'])) if (!empty($userlinks['login']))
......
...@@ -867,11 +867,16 @@ ...@@ -867,11 +867,16 @@
$this->output('<TD CLASS="qa-form-'.$style.'-label"'.$extratags.'>'); $this->output('<TD CLASS="qa-form-'.$style.'-label"'.$extratags.'>');
if ($prefixed) if ($prefixed) {
$this->output('<LABEL>');
$this->form_field($field, $style); $this->form_field($field, $style);
}
$this->output(@$field['label']); $this->output(@$field['label']);
if ($prefixed)
$this->output('</LABEL>');
if ($suffixed) { if ($suffixed) {
$this->output('&nbsp;'); $this->output('&nbsp;');
$this->form_field($field, $style); $this->form_field($field, $style);
......
...@@ -68,8 +68,10 @@ ...@@ -68,8 +68,10 @@
if (is_array($imagesize)) { // if image can't be parsed, don't worry about anything else if (is_array($imagesize)) { // if image can't be parsed, don't worry about anything else
$width=$imagesize[0]; $width=$imagesize[0];
$height=$imagesize[1]; $height=$imagesize[1];
$bits=isset($imagesize['bits']) ? $imagesize['bits'] : 8; // these elements can be missing (PHP bug) so assume this as default
$channels=isset($imagesize['channels']) ? $imagesize['channels'] : 3; // for more info: http://gynvael.coldwind.pl/?id=223
$needbytes+=$width*$height*$imagesize['bits']*$imagesize['channels']/8*2; // memory to load original image $needbytes+=$width*$height*$bits*$channels/8*2; // memory to load original image
if (isset($size) && qa_image_constrain($width, $height, $size)) // memory for constrained image if (isset($size) && qa_image_constrain($width, $height, $size)) // memory for constrained image
$needbytes+=$width*$height*3*2; // *2 here and above based on empirical tests $needbytes+=$width*$height*3*2; // *2 here and above based on empirical tests
...@@ -93,11 +95,15 @@ ...@@ -93,11 +95,15 @@
$inimage=@imagecreatefromstring($imagedata); $inimage=@imagecreatefromstring($imagedata);
if (is_resource($inimage)) { if (is_resource($inimage)) {
$width=imagesx($inimage); $inwidth=imagesx($inimage);
$height=imagesy($inimage); $inheight=imagesy($inimage);
if (qa_image_constrain($width, $height, $size)) $outwidth=$inwidth;
qa_gd_image_resize($inimage, $width, $height); $outheight=$inheight;
// always call qa_gd_image_resize(), even if the size is the same, to take care of possible PNG transparency
qa_image_constrain($outwidth, $outheight, $size);
qa_gd_image_resize($inimage, $outwidth, $outheight);
} }
if (is_resource($inimage)) { if (is_resource($inimage)) {
...@@ -137,7 +143,9 @@ ...@@ -137,7 +143,9 @@
$image=null; $image=null;
$newimage=imagecreatetruecolor($width, $height); $newimage=imagecreatetruecolor($width, $height);
$white=imagecolorallocate($newimage, 255, 255, 255); // fill with white first in case we have a transparent PNG
imagefill($newimage, 0, 0, $white);
if (is_resource($newimage)) { if (is_resource($newimage)) {
if (imagecopyresampled($newimage, $oldimage, 0, 0, 0, 0, $width, $height, imagesx($oldimage), imagesy($oldimage))) if (imagecopyresampled($newimage, $oldimage, 0, 0, 0, 0, $width, $height, imagesx($oldimage), imagesy($oldimage)))
$image=$newimage; $image=$newimage;
......
...@@ -640,7 +640,7 @@ ...@@ -640,7 +640,7 @@
return preg_match("/^[\-\!\#\$\%\&\'\*\+\/\=\?\_\`\{\|\}\~a-zA-Z0-9\.\^]+\@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\.\-]+$/", $email) ? true : false; return preg_match("/^[\-\!\#\$\%\&\'\*\+\/\=\?\_\`\{\|\}\~a-zA-Z0-9\.\^]+\@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\.\-]+$/", $email) ? true : false;
} }
function qa_strlen($string) function qa_strlen($string)
/* /*
Return the number of characters in $string, preferably using PHP's multibyte string functions Return the number of characters in $string, preferably using PHP's multibyte string functions
......
...@@ -28,14 +28,14 @@ ...@@ -28,14 +28,14 @@
Plugin Name: Facebook Login Plugin Name: Facebook Login
Plugin URI: Plugin URI:
Plugin Description: Allows users to log in via Facebook Plugin Description: Allows users to log in via Facebook
Plugin Version: 1.1 Plugin Version: 1.1.1
Plugin Date: 2011-12-14 Plugin Date: 2012-03-13
Plugin Author: Question2Answer Plugin Author: Question2Answer
Plugin Author URI: http://www.question2answer.org/ Plugin Author URI: http://www.question2answer.org/
Plugin License: GPLv2 Plugin License: GPLv2
Plugin Minimum Question2Answer Version: 1.3 Plugin Minimum Question2Answer Version: 1.3
Plugin Minimum PHP Version: 5 Plugin Minimum PHP Version: 5
Plugin Update Check URI: Plugin Update Check URI:
*/ */
...@@ -45,7 +45,8 @@ ...@@ -45,7 +45,8 @@
} }
qa_register_plugin_module('login', 'qa-facebook-login.php', 'qa_facebook_login', 'Facebook Login'); 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');
/* /*
......
...@@ -179,7 +179,7 @@ ...@@ -179,7 +179,7 @@
foreach ($questions as $question) { foreach ($questions as $question) {
$this->sitemap_output(qa_q_request($question['postid'], $question['title']), $this->sitemap_output(qa_q_request($question['postid'], $question['title']),
0.1+0.9*($question['hotness']-$hotstats['base'])/$hotstats['spread']); 0.1+0.9*($question['hotness']-$hotstats['base'])/(1+$hotstats['spread']));
$nextpostid=max($nextpostid, $question['postid']+1); $nextpostid=max($nextpostid, $question['postid']+1);
} }
} }
......
...@@ -421,7 +421,7 @@ h2 {font-size:22px; color:#c659ab; padding-top:12px; clear:both;} ...@@ -421,7 +421,7 @@ h2 {font-size:22px; color:#c659ab; padding-top:12px; clear:both;}
.qa-related-qs {font-size:14px;} .qa-related-qs {font-size:14px;}
.qa-related-qs h2 {font-size:18px;} .qa-related-qs h2 {font-size:18px;}
.qa-related-q-list {list-style-type:none; padding:0;} .qa-related-q-list {list-style-type:none; padding:0;}
.qa-related-q-item {margin:0.5em 0;} .qa-related-q-item {margin:0.5em 0; word-wrap: break-word;}
.qa-activity-count {font-size:14px;} .qa-activity-count {font-size:14px;}
.qa-activity-count-item {margin:0.5em 0;} .qa-activity-count-item {margin:0.5em 0;}
.qa-activity-count-data {font-size:24px; font-weight:bold;} .qa-activity-count-data {font-size:24px; font-weight:bold;}
......
...@@ -390,7 +390,7 @@ h2 {font-size:16px; padding-top:12px; clear:both;} ...@@ -390,7 +390,7 @@ h2 {font-size:16px; padding-top:12px; clear:both;}
/* Related questions and activity count widgets */ /* Related questions and activity count widgets */
.qa-related-q-list {list-style-type:none; padding:0;} .qa-related-q-list {list-style-type:none; padding:0;}
.qa-related-q-item {margin:0.5em 0;} .qa-related-q-item {margin:0.5em 0; word-wrap: break-word;}
.qa-activity-count {font-size:150%;} .qa-activity-count {font-size:150%;}
.qa-activity-count-item {margin:0.25em 0;} .qa-activity-count-item {margin:0.25em 0;}
.qa-activity-count-data {font-weight:bold;} .qa-activity-count-data {font-weight:bold;}
......
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