Skip to content

Commit

Permalink
1.5.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Gideon Greenspan committed Nov 29, 2012
1 parent c41db55 commit 2c67b77
Show file tree
Hide file tree
Showing 127 changed files with 2,720 additions and 475 deletions.
2 changes: 1 addition & 1 deletion VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.5.3
1.5.4
17 changes: 14 additions & 3 deletions qa-include/qa-app-post-update.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,11 +220,16 @@ function qa_question_set_hidden($oldquestion, $hidden, $userid, $handle, $cookie
if (@$closepost['parentid']==$oldquestion['postid'])
qa_post_unindex($closepost['postid']);

$setupdated=$hidden || !$wasqueued; // don't record approval of a post as an update action
$setupdated=$hidden || !$wasqueued; // don't record approval of a post as an update action...

qa_db_post_set_type($oldquestion['postid'], $hidden ? 'Q_HIDDEN' : 'Q',
$setupdated ? $userid : null, $setupdated ? qa_remote_ip_address() : null, QA_UPDATE_VISIBLE);

if (!$setupdated) { // ... for approval of a post, set created time to now instead
qa_db_post_set_created($oldquestion['postid'], null);
qa_db_hotness_update($oldquestion['postid']);
}

qa_db_category_path_qcount_update(qa_db_post_get_category_path($oldquestion['postid']));
qa_db_points_update_ifuser($oldquestion['userid'], array('qposts', 'aselects'));
qa_db_qcount_update();
Expand Down Expand Up @@ -462,11 +467,14 @@ function qa_answer_set_hidden($oldanswer, $hidden, $userid, $handle, $cookieid,
if ( ($comment['basetype']=='C') && ($comment['parentid']==$oldanswer['postid']) )
qa_post_unindex($comment['postid']);

$setupdated=$hidden || !$wasqueued; // don't record approval of a post as an update action
$setupdated=$hidden || !$wasqueued; // don't record approval of a post as an update action...

qa_db_post_set_type($oldanswer['postid'], $hidden ? 'A_HIDDEN' : 'A',
$setupdated ? $userid : null, $setupdated ? qa_remote_ip_address() : null, QA_UPDATE_VISIBLE);

if (!$setupdated) // ... for approval of a post, set created time to now instead
qa_db_post_set_created($oldanswer['postid'], null);

qa_db_points_update_ifuser($oldanswer['userid'], array('aposts', 'aselecteds'));
qa_db_post_acount_update($question['postid']);
qa_db_hotness_update($question['postid']);
Expand Down Expand Up @@ -680,11 +688,14 @@ function qa_comment_set_hidden($oldcomment, $hidden, $userid, $handle, $cookieid

qa_post_unindex($oldcomment['postid']);

$setupdated=$hidden || !$wasqueued; // don't record approval of a post as an update action
$setupdated=$hidden || !$wasqueued; // don't record approval of a post as an update action...

qa_db_post_set_type($oldcomment['postid'], $hidden ? 'C_HIDDEN' : 'C',
$setupdated ? $userid : null, $setupdated ? qa_remote_ip_address() : null, QA_UPDATE_VISIBLE);

if (!$setupdated) // ... for approval of a post, set created time to now instead
qa_db_post_set_created($oldcomment['postid'], null);

qa_db_points_update_ifuser($oldcomment['userid'], array('cposts'));
qa_db_ccount_update();

Expand Down
14 changes: 12 additions & 2 deletions qa-include/qa-app-users.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,10 @@ function qa_session_var_suffix()
*/
{
if (qa_to_override(__FUNCTION__)) { $args=func_get_args(); return qa_call_override(__FUNCTION__, $args); }

return md5(QA_FINAL_MYSQL_HOSTNAME.'/'.QA_FINAL_MYSQL_USERNAME.'/'.QA_FINAL_MYSQL_PASSWORD.'/'.QA_FINAL_MYSQL_DATABASE.'/'.QA_MYSQL_TABLE_PREFIX);

$prefix=defined('QA_MYSQL_USERS_PREFIX') ? QA_MYSQL_USERS_PREFIX : QA_MYSQL_TABLE_PREFIX;

return md5(QA_FINAL_MYSQL_HOSTNAME.'/'.QA_FINAL_MYSQL_USERNAME.'/'.QA_FINAL_MYSQL_PASSWORD.'/'.QA_FINAL_MYSQL_DATABASE.'/'.$prefix);
}


Expand Down Expand Up @@ -303,6 +305,14 @@ function qa_log_in_external_user($source, $identifier, $fields)

} else {
$handle=qa_handle_make_valid(@$fields['handle']);

if (strlen(@$fields['email'])) { // remove email address if it will cause a duplicate
$emailusers=qa_db_user_find_by_email($fields['email']);
if (count($emailusers)) {
unset($fields['email']);
unset($fields['confirmed']);
}
}

$userid=qa_create_new_user((string)@$fields['email'], null /* no password */, $handle,
isset($fields['level']) ? $fields['level'] : QA_USER_LEVEL_BASIC, @$fields['confirmed']);
Expand Down
9 changes: 6 additions & 3 deletions qa-include/qa-base.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
*/


define('QA_VERSION', '1.5.3'); // also used as suffix for .js and .css requests
define('QA_BUILD_DATE', '2012-09-26');
define('QA_VERSION', '1.5.4'); // also used as suffix for .js and .css requests
define('QA_BUILD_DATE', '2012-11-29');

// Execution section of this file - remainder contains function definitions

Expand Down Expand Up @@ -715,13 +715,16 @@ function qa_sanitize_html($html, $linksnewwindow=false, $storage=false)
}


function qa_sanitize_html_hook_tag($element, $attributes)
function qa_sanitize_html_hook_tag($element, $attributes=null)
/*
htmLawed hook function used to process tags in qa_sanitize_html(...)
*/
{
global $qa_sanitize_html_newwindow;

if (!isset($attributes)) // it's a closing tag
return '</'.$element.'>';

if ( ($element=='param') && (trim(strtolower(@$attributes['name']))=='allowscriptaccess') )
$attributes['name']='allowscriptaccess_denied';

Expand Down
16 changes: 11 additions & 5 deletions qa-include/qa-db-post-update.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,19 @@ function qa_db_posts_set_category_path($postids, $path)

function qa_db_post_set_created($postid, $created)
/*
Set the created date of $postid to $created, which is a unix timestamp
Set the created date of $postid to $created, which is a unix timestamp. If created is NULL, set to now.
*/
{
qa_db_query_sub(
'UPDATE ^posts SET created=FROM_UNIXTIME(#) WHERE postid=#',
$created, $postid
);
if (isset($created))
qa_db_query_sub(
'UPDATE ^posts SET created=FROM_UNIXTIME(#) WHERE postid=#',
$created, $postid
);
else
qa_db_query_sub(
'UPDATE ^posts SET created=NOW() WHERE postid=#',
$postid
);
}


Expand Down
4 changes: 3 additions & 1 deletion qa-include/qa-db-selects.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,10 @@ function qa_db_add_selectspec_opost(&$selectspec, $poststable, $fromupdated=fals
if ($full) {
$selectspec['columns']['ocontent']=$poststable.'.content';
$selectspec['columns']['oformat']=$poststable.'.format';
$selectspec['columns']['oupdated']='UNIX_TIMESTAMP('.$poststable.'.updated)';
}

if ($fromupdated || $full)
$selectspec['columns']['oupdated']='UNIX_TIMESTAMP('.$poststable.'.updated)';
}


Expand Down
78 changes: 45 additions & 33 deletions qa-include/qa-htmLawed.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

/*
htmLawed 1.1.10, 22 October 2011
htmLawed 1.1.14, 8 August 2012
Copyright Santosh Patnaik
LGPL v3 license
Dual licensed with LGPL 3 and GPL 2+
A PHP Labware internal utility; www.bioinformatics.org/phplabware/internal_utilities/htmLawed
See htmLawed_README.txt/htm
Expand Down Expand Up @@ -194,15 +194,18 @@ function hl_bal($t, $do=1, $in='div'){
echo '&lt;', $s, $e, $a, '&gt;';
}
if(isset($x[0])){
if($do < 3 or isset($ok['#pcdata'])){echo $x;}
if(strlen(trim($x)) && (($ql && isset($cB[$p])) or (isset($cB[$in]) && !$ql))){
echo '<div>', $x, '</div>';
}
elseif($do < 3 or isset($ok['#pcdata'])){echo $x;}
elseif(strpos($x, "\x02\x04")){
foreach(preg_split('`(\x01\x02[^\x01\x02]+\x02\x01)`', $x, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY) as $v){
echo (substr($v, 0, 2) == "\x01\x02" ? $v : ($do > 4 ? preg_replace('`\S`', '', $v) : ''));
}
}elseif($do > 4){echo preg_replace('`\S`', '', $x);}
}
// get markup
if(!preg_match('`^(/?)([a-zA-Z1-6]+)([^>]*)>(.*)`sm', $t[$i], $r)){$x = $t[$i]; continue;}
if(!preg_match('`^(/?)([a-z1-6]+)([^>]*)>(.*)`sm', $t[$i], $r)){$x = $t[$i]; continue;}
$s = null; $e = null; $a = null; $x = null; list($all, $s, $e, $a, $x) = $r;
// close tag
if($s){
Expand Down Expand Up @@ -427,7 +430,7 @@ function hl_tag($t){
// close tag
static $eE = array('area'=>1, 'br'=>1, 'col'=>1, 'embed'=>1, 'hr'=>1, 'img'=>1, 'input'=>1, 'isindex'=>1, 'param'=>1); // Empty ele
if(!empty($m[1])){
return (!isset($eE[$e]) ? "</$e>" : (($C['keep_bad'])%2 ? str_replace(array('<', '>'), array('&lt;', '&gt;'), $t) : ''));
return (!isset($eE[$e]) ? (empty($C['hook_tag']) ? "</$e>" : $C['hook_tag']($e)) : (($C['keep_bad'])%2 ? str_replace(array('<', '>'), array('&lt;', '&gt;'), $t) : ''));
}

// open tag & attr
Expand Down Expand Up @@ -470,8 +473,8 @@ function hl_tag($t){
$aA[$nm] = '';
}
break; case 2: // Val
if(preg_match('`^"[^"]*"`', $a, $m) or preg_match("`^'[^']*'`", $a, $m) or preg_match("`^\s*[^\s\"']+`", $a, $m)){
$m = $m[0]; $w = 1; $mode = 0; $a = ltrim(substr_replace($a, '', 0, strlen($m)));
if(preg_match('`^((?:"[^"]*")|(?:\'[^\']*\')|(?:\s*[^\s"\']+))(.*)`', $a, $m)){
$a = ltrim($m[2]); $m = $m[1]; $w = 1; $mode = 0;
$aA[$nm] = trim(($m[0] == '"' or $m[0] == '\'') ? substr($m, 1, -1) : $m);
}
break;
Expand All @@ -488,7 +491,7 @@ function hl_tag($t){
$rl = isset($S[$e]) ? $S[$e] : array();
$a = array(); $nfr = 0;
foreach($aA as $k=>$v){
if(((isset($C['deny_attribute']['*']) ? isset($C['deny_attribute'][$k]) : !isset($C['deny_attribute'][$k])) or isset($rl[$k])) && ((!isset($rl['n'][$k]) && !isset($rl['n']['*'])) or isset($rl[$k])) && (isset($aN[$k][$e]) or (isset($aNU[$k]) && !isset($aNU[$k][$e])))){
if(((isset($C['deny_attribute']['*']) ? isset($C['deny_attribute'][$k]) : !isset($C['deny_attribute'][$k])) && (isset($aN[$k][$e]) or (isset($aNU[$k]) && !isset($aNU[$k][$e]))) && !isset($rl['n'][$k]) && !isset($rl['n']['*'])) or isset($rl[$k])){
if(isset($aNE[$k])){$v = $k;}
elseif(!empty($lcase) && (($e != 'button' or $e != 'input') or $k == 'type')){ // Rather loose but ?not cause issues
$v = (isset($aNL[($v2 = strtolower($v))])) ? $v2 : $v;
Expand Down Expand Up @@ -622,7 +625,7 @@ function hl_tag2(&$e, &$a, $t=1){
static $fs = array('0'=>'xx-small', '1'=>'xx-small', '2'=>'small', '3'=>'medium', '4'=>'large', '5'=>'x-large', '6'=>'xx-large', '7'=>'300%', '-1'=>'smaller', '-2'=>'60%', '+1'=>'larger', '+2'=>'150%', '+3'=>'200%', '+4'=>'300%');
if($e == 'font'){
$a2 = '';
if(preg_match('`face\s*=\s*(\'|")([^=]+?)\\1`i', $a, $m) or preg_match('`face\s*=\s*([^"])(\S+)`i', $a, $m)){
if(preg_match('`face\s*=\s*(\'|")([^=]+?)\\1`i', $a, $m) or preg_match('`face\s*=(\s*)(\S+)`i', $a, $m)){
$a2 .= ' font-family: '. str_replace('"', '\'', trim($m[2])). ';';
}
if(preg_match('`color\s*=\s*(\'|")?(.+?)(\\1|\s|$)`i', $a, $m)){
Expand All @@ -647,33 +650,42 @@ function hl_tidy($t, $w, $p){
}
$s = strpos(" $w", 't') ? "\t" : ' ';
$s = preg_match('`\d`', $w, $m) ? str_repeat($s, $m[0]) : str_repeat($s, ($s == "\t" ? 1 : 2));
$n = preg_match('`[ts]([1-9])`', $w, $m) ? $m[1] : 0;
$N = preg_match('`[ts]([1-9])`', $w, $m) ? $m[1] : 0;
$a = array('br'=>1);
$b = array('button'=>1, 'input'=>1, 'option'=>1);
$c = array('caption'=>1, 'dd'=>1, 'dt'=>1, 'h1'=>1, 'h2'=>1, 'h3'=>1, 'h4'=>1, 'h5'=>1, 'h6'=>1, 'isindex'=>1, 'label'=>1, 'legend'=>1, 'li'=>1, 'object'=>1, 'p'=>1, 'pre'=>1, 'td'=>1, 'textarea'=>1, 'th'=>1);
$d = array('address'=>1, 'blockquote'=>1, 'center'=>1, 'colgroup'=>1, 'dir'=>1, 'div'=>1, 'dl'=>1, 'fieldset'=>1, 'form'=>1, 'hr'=>1, 'iframe'=>1, 'map'=>1, 'menu'=>1, 'noscript'=>1, 'ol'=>1, 'optgroup'=>1, 'rbc'=>1, 'rtc'=>1, 'ruby'=>1, 'script'=>1, 'select'=>1, 'table'=>1, 'tfoot'=>1, 'thead'=>1, 'tr'=>1, 'ul'=>1);
ob_start();
if(isset($d[$p])){echo str_repeat($s, ++$n);}
$t = explode('<', $t);
echo ltrim(array_shift($t));
for($i=-1, $j=count($t); ++$i<$j;){
$r = ''; list($e, $r) = explode('>', $t[$i]);
$x = $e[0] == '/' ? 0 : (substr($e, -1) == '/' ? 1 : ($e[0] != '!' ? 2 : -1));
$y = !$x ? ltrim($e, '/') : ($x > 0 ? substr($e, 0, strcspn($e, ' ')) : 0);
$e = "<$e>";
if(isset($d[$y])){
if(!$x){echo "\n", str_repeat($s, --$n), "$e\n", str_repeat($s, $n);}
else{echo "\n", str_repeat($s, $n), "$e\n", str_repeat($s, ($x != 1 ? ++$n : $n));}
echo ltrim($r); continue;
$d = array('address'=>1, 'blockquote'=>1, 'center'=>1, 'colgroup'=>1, 'dir'=>1, 'div'=>1, 'dl'=>1, 'fieldset'=>1, 'form'=>1, 'hr'=>1, 'iframe'=>1, 'map'=>1, 'menu'=>1, 'noscript'=>1, 'ol'=>1, 'optgroup'=>1, 'rbc'=>1, 'rtc'=>1, 'ruby'=>1, 'script'=>1, 'select'=>1, 'table'=>1, 'tbody'=>1, 'tfoot'=>1, 'thead'=>1, 'tr'=>1, 'ul'=>1);
$T = explode('<', $t);
$X = 1;
while($X){
$n = $N;
$t = $T;
ob_start();
if(isset($d[$p])){echo str_repeat($s, ++$n);}
echo ltrim(array_shift($t));
for($i=-1, $j=count($t); ++$i<$j;){
$r = ''; list($e, $r) = explode('>', $t[$i]);
$x = $e[0] == '/' ? 0 : (substr($e, -1) == '/' ? 1 : ($e[0] != '!' ? 2 : -1));
$y = !$x ? ltrim($e, '/') : ($x > 0 ? substr($e, 0, strcspn($e, ' ')) : 0);
$e = "<$e>";
if(isset($d[$y])){
if(!$x){
if($n){echo "\n", str_repeat($s, --$n), "$e\n", str_repeat($s, $n);}
else{++$N; ob_end_clean(); continue 2;}
}
else{echo "\n", str_repeat($s, $n), "$e\n", str_repeat($s, ($x != 1 ? ++$n : $n));}
echo ltrim($r); continue;
}
$f = "\n". str_repeat($s, $n);
if(isset($c[$y])){
if(!$x){echo $e, $f, ltrim($r);}
else{echo $f, $e, $r;}
}elseif(isset($b[$y])){echo $f, $e, $r;
}elseif(isset($a[$y])){echo $e, $f, ltrim($r);
}elseif(!$y){echo $f, $e, $f, ltrim($r);
}else{echo $e, $r;}
}
$f = "\n". str_repeat($s, $n);
if(isset($c[$y])){
if(!$x){echo $e, $f, ltrim($r);}
else{echo $f, $e, $r;}
}elseif(isset($b[$y])){echo $f, $e, $r;
}elseif(isset($a[$y])){echo $e, $f, ltrim($r);
}elseif(!$y){echo $f, $e, $f, ltrim($r);
}else{echo $e, $r;}
$X = 0;
}
$t = preg_replace('`[\n]\s*?[\n]+`', "\n", ob_get_contents());
ob_end_clean();
Expand All @@ -686,7 +698,7 @@ function hl_tidy($t, $w, $p){

function hl_version(){
// rel
return '1.1.10';
return '1.1.14';
// eof
}

Expand Down
2 changes: 1 addition & 1 deletion qa-include/qa-install.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ function qa_install_db_fail_handler($type, $errno=null, $error=null, $query=null
break;

case 'non-users-missing':
$errorhtml='This Question2Answer site is sharing its users with another Q2A site, but it needs some additional database tables for its own content. Click below to create them.';
$errorhtml='This Question2Answer site is sharing its users with another Q2A site, but it needs some additional database tables for its own content. Please click below to create them.';
$buttons=array('nonuser' => 'Create Tables');
break;

Expand Down
1 change: 1 addition & 0 deletions qa-include/qa-lang-main.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
'me' => 'me',
'meta_order' => '^what^when^where^who', // you can reorder but DO NOT translate! e.g. <answered> <15 hours ago> <in Problems> <by me (500 points)>
'min_length_x' => 'Please provide more information - at least ^ characters',
'max_upload_size_x' => 'Maximum upload size is ^',
'moved' => 'moved',
'nav_account' => 'My Account',
'nav_activity' => 'All Activity',
Expand Down
1 change: 1 addition & 0 deletions qa-include/qa-page-account.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@

'buttons' => array(
'save' => array(
'tags' => 'onClick="qa_show_waiting_after(this, false);"',
'label' => qa_lang_html('users/save_profile'),
),
),
Expand Down
3 changes: 2 additions & 1 deletion qa-include/qa-page-ask.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,8 @@

'buttons' => array(
'ask' => array(
'tags' => method_exists($editor, 'update_script') ? ('onClick="'.$editor->update_script('content').'"') : '',
'tags' => 'onClick="qa_show_waiting_after(this, false); '.
(method_exists($editor, 'update_script') ? $editor->update_script('content') : '').'"',
'label' => qa_lang_html('question/ask_button'),
),
),
Expand Down
2 changes: 1 addition & 1 deletion qa-include/qa-page-ip.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@

if (count($questions) && !qa_user_permit_error('permit_hide_show'))
$qa_content['form']['buttons']['hideall']=array(
'tags' => 'NAME="dohideall"',
'tags' => 'NAME="dohideall" onClick="qa_show_waiting_after(this, false);"',
'label' => qa_lang_html('misc/hide_all_ip_button'),
);

Expand Down
1 change: 1 addition & 0 deletions qa-include/qa-page-message.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@

'buttons' => array(
'send' => array(
'tags' => 'onClick="qa_show_waiting_after(this, false);"',
'label' => qa_lang_html('main/send_button'),
),
),
Expand Down
13 changes: 9 additions & 4 deletions qa-include/qa-page-question-post.php
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ function qa_page_q_edit_q_form(&$qa_content, $question, $in, $errors, $completet

'buttons' => array(
'save' => array(
'tags' => 'onClick="qa_show_waiting_after(this, false);"',
'label' => qa_lang_html('main/save_button'),
),

Expand All @@ -359,7 +360,8 @@ function qa_page_q_edit_q_form(&$qa_content, $question, $in, $errors, $completet
$form['fields']['content']=array_merge($form['fields']['content'],
qa_editor_load_field($editor, $qa_content, $content, $format, 'q_content', 12, true));

$form['buttons']['save']['tags']=method_exists($editor, 'update_script') ? ('onClick="'.$editor->update_script('q_content').'"') : '';
if (method_exists($editor, 'update_script'))
$form['buttons']['save']['tags']='onClick="qa_show_waiting_after(this, false); '.$editor->update_script('q_content').'"';

$form['hidden']['q_editor']=qa_html($editorname);

Expand Down Expand Up @@ -502,6 +504,7 @@ function qa_page_q_close_q_form(&$qa_content, $question, $id, $in, $errors)

'buttons' => array(
'close' => array(
'tags' => 'onClick="qa_show_waiting_after(this, false);"',
'label' => qa_lang_html('question/close_form_button'),
),

Expand Down Expand Up @@ -615,10 +618,11 @@ function qa_page_q_edit_a_form(&$qa_content, $id, $answer, $question, $answers,
)
),
),

'buttons' => array(
'save' => array(
'tags' => method_exists($editor, 'update_script') ? ('onClick="'.$editor->update_script($prefix.'content').'"') : '',
'tags' => 'onClick="qa_show_waiting_after(this, false); '.
(method_exists($editor, 'update_script') ? $editor->update_script($prefix.'content') : '').'"',
'label' => qa_lang_html('main/save_button'),
),

Expand Down Expand Up @@ -833,7 +837,8 @@ function qa_page_q_edit_c_form(&$qa_content, $id, $comment, $in, $errors)

'buttons' => array(
'save' => array(
'tags' => method_exists($editor, 'update_script') ? ('onClick="'.$editor->update_script($prefix.'content').'"') : '',
'tags' => 'onClick="qa_show_waiting_after(this, false); '.
(method_exists($editor, 'update_script') ? $editor->update_script($prefix.'content') : '').'"',
'label' => qa_lang_html('main/save_button'),
),

Expand Down
Loading

0 comments on commit 2c67b77

Please sign in to comment.