Commit cdee121e by Scott

Merge branch 'dev' into 1.8

parents f22e8abb 2fcf4966
......@@ -367,7 +367,7 @@
else
switch ($name) {
case 'site_url':
$value='http://'.@$_SERVER['HTTP_HOST'].strtr(dirname($_SERVER['SCRIPT_NAME']), '\\', '/').'/';
$value='http://'.@$_SERVER['HTTP_HOST'].strtr(rtrim(dirname($_SERVER['SCRIPT_NAME']), '/'), '\\', '/').'/';
break;
case 'site_title':
......
......@@ -137,7 +137,7 @@
'userlevels' => array(
'userid' => $useridcoltype.' NOT NULL', // the user who has this level
'entitytype' => "CHAR(1) CHARACTER SET ascii NOT NULL", // see qa-app-updates.php
'entitytype' => 'CHAR(1) CHARACTER SET ascii NOT NULL', // see qa-app-updates.php
'entityid' => 'INT UNSIGNED NOT NULL', // relevant postid / userid / tag wordid / categoryid
'level' => 'TINYINT UNSIGNED', // if not NULL, special permission level for that user and that entity
'UNIQUE userid (userid, entitytype, entityid)',
......@@ -180,7 +180,7 @@
'userfavorites' => array(
'userid' => $useridcoltype.' NOT NULL', // the user who favorited the entity
'entitytype' => "CHAR(1) CHARACTER SET ascii NOT NULL", // see qa-app-updates.php
'entitytype' => 'CHAR(1) CHARACTER SET ascii NOT NULL', // see qa-app-updates.php
'entityid' => 'INT UNSIGNED NOT NULL', // favorited postid / userid / tag wordid / categoryid
'nouserevents' => 'TINYINT UNSIGNED NOT NULL', // do we skip writing events to the user stream?
'PRIMARY KEY (userid, entitytype, entityid)',
......@@ -201,7 +201,7 @@
'userevents' => array(
'userid' => $useridcoltype.' NOT NULL', // the user to be informed about this event in their updates
'entitytype' => "CHAR(1) CHARACTER SET ascii NOT NULL", // see qa-app-updates.php
'entitytype' => 'CHAR(1) CHARACTER SET ascii NOT NULL', // see qa-app-updates.php
'entityid' => 'INT UNSIGNED NOT NULL', // favorited source of event - see userfavorites table - 0 means not from a favorite
'questionid' => 'INT UNSIGNED NOT NULL', // the affected question
'lastpostid' => 'INT UNSIGNED NOT NULL', // what part of question was affected
......@@ -213,7 +213,7 @@
),
'sharedevents' => array(
'entitytype' => "CHAR(1) CHARACTER SET ascii NOT NULL", // see qa-app-updates.php
'entitytype' => 'CHAR(1) CHARACTER SET ascii NOT NULL', // see qa-app-updates.php
'entityid' => 'INT UNSIGNED NOT NULL', // see userfavorites table
'questionid' => 'INT UNSIGNED NOT NULL', // see userevents table
'lastpostid' => 'INT UNSIGNED NOT NULL', // see userevents table
......
......@@ -93,7 +93,8 @@
function qa_db_post_set_parent($postid, $parentid, $lastuserid=null, $lastip=null)
/*
Set the parent in the database of $postid to $parentid, and optionally record that $lastuserid did it from $lastip (if at least one is specified)
Set the parent in the database of $postid to $parentid, and optionally record that $lastuserid did it from $lastip
(if at least one is specified)
*/
{
if (isset($lastuserid) || isset($lastip))
......@@ -143,7 +144,8 @@
function qa_db_post_set_category($postid, $categoryid, $lastuserid=null, $lastip=null)
/*
Set the (exact) category in the database of $postid to $categoryid, and optionally record that $lastuserid did it from $lastip (if at least one is specified)
Set the (exact) category in the database of $postid to $categoryid, and optionally record that $lastuserid did it from
$lastip (if at least one is specified)
*/
{
if (isset($lastuserid) || isset($lastip))
......@@ -192,7 +194,7 @@
function qa_db_post_set_updated($postid, $updated)
/*
Set the last updated date of $postid to $updated, which is a unix timestamp. If updated is nul, set to now.
Set the last updated date of $postid to $updated, which is a unix timestamp. If updated is null, set to now.
*/
{
if (isset($updated))
......@@ -318,7 +320,7 @@
function qa_db_posts_filter_q_postids($postids)
/*
Return the array $postids containing only those elements which are the postid of a qustion in the database
Return the array $postids containing only those elements which are the postid of a question in the database
*/
{
if (count($postids))
......
......@@ -116,7 +116,7 @@
function qa_db_user_get_userid_handles($userids)
/*
Return an array mapping mapping each userid in $userids that can be found to that user's handle
Return an array mapping each userid in $userids that can be found to that user's handle
*/
{
if (count($userids))
......
......@@ -86,10 +86,10 @@
'no_blocked_users' => 'No blocked users found',
'no_permission' => 'You do not have permission to perform this operation',
'old_password' => 'Old password:',
'only_shown_admins' => '(only shown to admins)',
'only_shown_editors' => '(only shown to editors and above)',
'only_shown_experts' => '(only shown to experts and above)',
'only_shown_moderators' => '(only shown to moderators and admins)',
'only_shown_admins' => '(only shown to you and admins)',
'only_shown_editors' => '(only shown to you, editors and above)',
'only_shown_experts' => '(only shown to you, experts and above)',
'only_shown_moderators' => '(only shown to you, moderators and admins)',
'password_changed' => 'Password changed',
'password_label' => 'Password:',
'password_min' => 'Password must be at least ^ characters',
......
......@@ -914,7 +914,7 @@ if ($recalchotness) {
);
} else { // rudimentary non-Javascript version of mass mailing loop
echo '<tt>';
echo '<code>';
while (true) {
qa_mailing_perform_step();
......@@ -930,7 +930,7 @@ if ($recalchotness) {
sleep(1);
}
echo qa_lang_html('admin/mailing_complete') . '</tt><p><a href="' . qa_path_html('admin/mailing') . '">' . qa_lang_html('admin/admin_title') . ' - ' . qa_lang_html('admin/mailing_title') . '</a>';
echo qa_lang_html('admin/mailing_complete').'</code><p><a href="'.qa_path_html('admin/mailing').'">'.qa_lang_html('admin/admin_title').' - '.qa_lang_html('admin/mailing_title').'</a>';
qa_exit();
}
......
......@@ -155,8 +155,8 @@ if (!empty($pluginfiles)) {
$qa_content['script_onloads'][] = array(
"qa_version_check(" . qa_js($metadata['update_uri']) . ", " . qa_js($metadata['version'], true) . ", " . qa_js($elementid) . ");"
);
} else
}
else
$updatehtml = '';
if (isset($metadata['description']))
......@@ -164,25 +164,23 @@ if (!empty($pluginfiles)) {
else
$deschtml = '';
if (isset($pluginoptionmodules[$plugindirectory]) && !$showthisform) {
$deschtml .= (strlen($deschtml) ? ' - ' : '') . '<a href="' .
qa_admin_plugin_options_path($plugindirectory) . '">' . qa_lang_html('admin/options') . '</a>';
}
if (isset($pluginoptionmodules[$plugindirectory]) && !$showthisform)
$deschtml .= (strlen($deschtml) ? ' - ' : '').'<a href="'.
qa_admin_plugin_options_path($plugindirectory).'">'.qa_lang_html('admin/options').'</a>';
$pluginhtml = $namehtml . ' ' . $authorhtml . ' ' . $updatehtml . '<br>' . $deschtml . (strlen($deschtml) ? '<br>' : '') .
'<small style="color:#666">' . qa_html($plugindirectory) . '/</small>';
$pluginhtml = $namehtml.' '.$authorhtml.' '.$updatehtml.'<br>'.$deschtml.(strlen($deschtml) ? '<br>' : '').
'<small style="color:#666">'.qa_html($plugindirectory).'/</small>';
if (qa_qa_version_below(@$metadata['min_q2a'])) {
$pluginhtml = '<strike style="color:#999">' . $pluginhtml . '</strike><br><span style="color:#f00">' .
qa_lang_html_sub('admin/requires_q2a_version', qa_html($metadata['min_q2a'])) . '</span>';
if (qa_qa_version_below(@$metadata['min_q2a']))
$pluginhtml = '<s style="color:#999">'.$pluginhtml.'</s><br><span style="color:#f00">'.
qa_lang_html_sub('admin/requires_q2a_version', qa_html($metadata['min_q2a'])).'</span>';
} elseif (qa_php_version_below(@$metadata['min_php'])) {
$pluginhtml = '<strike style="color:#999">' . $pluginhtml . '</strike><br><span style="color:#f00">' .
qa_lang_html_sub('admin/requires_php_version', qa_html($metadata['min_php'])) . '</span>';
}
elseif (qa_php_version_below(@$metadata['min_php']))
$pluginhtml = '<s style="color:#999">'.$pluginhtml.'</s><br><span style="color:#f00">'.
qa_lang_html_sub('admin/requires_php_version', qa_html($metadata['min_php'])).'</span>';
$qa_content['form_plugin_' . $pluginIndex] = array(
'tags' => 'id="' . qa_html($hash) . '"',
$qa_content['form_plugin_'.$pluginIndex] = array(
'tags' => 'id="'.qa_html($hash).'"',
'style' => 'tall',
'fields' => array(
array(
......
......@@ -68,7 +68,7 @@ if ($recalcnow) {
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body>
<tt>
<code>
<?php
......@@ -87,7 +87,7 @@ if ($recalcnow) {
}
?>
</tt>
</code>
<a href="<?php echo qa_path_html('admin/stats')?>"><?php echo qa_lang_html('admin/admin_title').' - '.qa_lang_html('admin/stats_title')?></a>
</body>
......
......@@ -64,13 +64,11 @@ function qa_category_nav_to_browse(&$navigation, $categories, $categoryid, $favo
if (@$favoritemap[$navlink['categoryid']])
$navigation[$key]['favorited'] = true;
$navigation[$key]['note'] = '';
$navigation[$key]['note'] .=
' - <a href="' . qa_path_html('questions/' . implode('/', array_reverse(explode('/', $category['backpath'])))) . '">' . (($category['qcount'] == 1)
$navigation[$key]['note'] =
' - <a href="'.qa_path_html('questions/'.implode('/', array_reverse(explode('/', $category['backpath'])))).'">'.( ($category['qcount']==1)
? qa_lang_html_sub('main/1_question', '1', '1')
: qa_lang_html_sub('main/x_questions', qa_format_number($category['qcount'], 0, true))
) . '</a>';
: qa_lang_html_sub('main/x_questions', number_format($category['qcount']))
).'</a>';
if (strlen($category['content']))
$navigation[$key]['note'] .= qa_html(' - ' . $category['content']);
......
......@@ -91,7 +91,7 @@ $qa_content['form'] = array(
'fields' => array(
'email_handle' => array(
'label' => qa_lang_html('users/email_handle_label'),
'label' => qa_opt('allow_login_email_only') ? qa_lang_html('users/email_label') : qa_lang_html('users/email_handle_label'),
'tags' => 'name="emailhandle" id="emailhandle"',
'value' => qa_html(@$inemailhandle),
'error' => qa_html(@$errors['emailhandle']),
......
......@@ -42,21 +42,23 @@ if (qa_clicked('doaccount'))
// Find the user profile and questions and answers for this handle
$loginuserid = qa_get_logged_in_userid();
$identifier = QA_FINAL_EXTERNAL_USERS ? $userid : $handle;
list($useraccount, $userprofile, $userfields, $usermessages, $userpoints, $userlevels, $navcategories, $userrank) = qa_db_select_with_pending(
QA_FINAL_EXTERNAL_USERS ? null : qa_db_user_account_selectspec($handle, false),
QA_FINAL_EXTERNAL_USERS ? null : qa_db_user_profile_selectspec($handle, false),
QA_FINAL_EXTERNAL_USERS ? null : qa_db_userfields_selectspec(),
QA_FINAL_EXTERNAL_USERS ? null : qa_db_recent_messages_selectspec(null, null, $handle, false, qa_opt_if_loaded('page_size_wall')),
qa_db_user_points_selectspec($identifier),
qa_db_user_levels_selectspec($identifier, QA_FINAL_EXTERNAL_USERS, true),
qa_db_category_nav_selectspec(null, true),
qa_db_user_rank_selectspec($identifier)
);
list($useraccount, $userprofile, $userfields, $usermessages, $userpoints, $userlevels, $navcategories, $userrank) =
qa_db_select_with_pending(
QA_FINAL_EXTERNAL_USERS ? null : qa_db_user_account_selectspec($handle, false),
QA_FINAL_EXTERNAL_USERS ? null : qa_db_user_profile_selectspec($handle, false),
QA_FINAL_EXTERNAL_USERS ? null : qa_db_userfields_selectspec(),
QA_FINAL_EXTERNAL_USERS ? null : qa_db_recent_messages_selectspec(null, null, $handle, false, qa_opt_if_loaded('page_size_wall')),
qa_db_user_points_selectspec($identifier),
qa_db_user_levels_selectspec($identifier, QA_FINAL_EXTERNAL_USERS, true),
qa_db_category_nav_selectspec(null, true),
qa_db_user_rank_selectspec($identifier)
);
if (!QA_FINAL_EXTERNAL_USERS) {
if (!QA_FINAL_EXTERNAL_USERS && $handle !== qa_get_logged_in_handle()) {
foreach ($userfields as $index => $userfield) {
if (isset($userfield['permit']) && qa_permit_value_error($userfield['permit'], $loginuserid, qa_get_logged_in_level(), qa_get_logged_in_flags()))
unset($userfields[$index]); // don't pay attention to user fields we're not allowed to view
......
......@@ -89,7 +89,7 @@ class qa_filter_basic
else {
$tagstring = qa_tags_to_tagstring($question['tags']);
if (qa_strlen($tagstring) > QA_DB_MAX_TAGS_LENGTH) { // for storage
$errors['tags'] = qa_lang_sub('main/max_length_x', $maxlength);
$errors['tags'] = qa_lang_sub('main/max_length_x', QA_DB_MAX_TAGS_LENGTH);
}
}
}
......@@ -107,7 +107,7 @@ class qa_filter_basic
public function filter_comment(&$comment, &$errors, $question, $parent, $oldcomment)
{
$this->validate_field_length($errors, $comment, 'content', 0, QA_DB_MAX_CONTENT_LENGTH); // for storage
$this->validate_field_length($errors, $comment, 'text', qa_opt('min_len_a_content'), null, 'content'); // for display
$this->validate_field_length($errors, $comment, 'text', qa_opt('min_len_c_content'), null, 'content'); // for display
$this->validate_post_email($errors, $comment);
}
......
......@@ -738,14 +738,18 @@
{
if (qa_to_override(__FUNCTION__)) { $args=func_get_args(); return qa_call_override(__FUNCTION__, $args); }
echo 'Question2Answer fatal error:<p><font color="red">'.qa_html($message, true).'</font></p>';
@error_log('PHP Question2Answer fatal error: '.$message);
echo 'Question2Answer fatal error:<p style="color: red">' . qa_html($message, true) . '</p>';
@error_log('PHP Question2Answer fatal error: ' . $message);
echo '<p>Stack trace:<p>';
$backtrace=array_reverse(array_slice(debug_backtrace(), 1));
foreach ($backtrace as $trace)
echo '<font color="#'.((strpos(@$trace['file'], '/qa-plugin/')!==false) ? 'f00' : '999').'">'.
qa_html(@$trace['function'].'() in '.basename(@$trace['file']).':'.@$trace['line']).'</font><br>';
$backtrace = array_reverse(array_slice(debug_backtrace(), 1));
foreach ($backtrace as $trace) {
$color = strpos(@$trace['file'], '/qa-plugin/') !== false ? 'red' : '#999';
echo sprintf(
'<code style="color: %s">%s() in %s:%s</code><br>',
$color, qa_html(@$trace['function']), basename(@$trace['file']), @$trace['line']
);
}
qa_exit('error');
}
......
......@@ -35,10 +35,17 @@
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>Question2Answer Language Check</title>
<style>
code {font-size:125%;}
body {
font-family: arial;
font-size: 12px;
}
code {font-size: 125%;}
.severe {color: #b83939;}
.warning {color: #d2930d;}
.includes {color: #999;}
</style>
</head>
<body style="font-family:arial; font-size:12px;">
<body>
<?php
function get_phrase_substitutions($phrase)
......@@ -52,8 +59,8 @@
return $substitutions;
}
echo '<font color="#cc0000"><code>Dark red = important to review.</code></font><br>';
echo '<font color="#cc9999"><code>Light red = probably safe to ignore.</code></font>';
echo '<code class="severe">Red = important to review.</code><br>';
echo '<code class="warning">Orange = probably safe to ignore.</code>';
echo '<h1>Checking US English files in <code>qa-include</code>...</h1>';
......@@ -207,14 +214,14 @@
function output_lang_issue($prefix, $key, $issue, $error=true)
{
echo '<font color="'.($error ? '#cc0000' : '#cc9999').'"><code>';
echo 'qa-lang-<b>'.qa_html($prefix).'</b>.php:';
$colorClass = $error ? 'severe' : 'warning';
if (strlen($key))
echo "'<b>".qa_html($key)."</b>'";
$htmlKey = strlen($key) > 0 ? "'<strong>" . qa_html($key) . "</strong>'" : '';
echo '</code></font> &nbsp; '.qa_html($issue).'<br>';
echo sprintf(
'<code class="%s">qa-lang-<strong>%s</strong>.php:%s</code> &nbsp; %s<br>',
$colorClass, qa_html($prefix), $htmlKey, qa_html($issue)
);
}
......@@ -224,7 +231,7 @@
$oneread=false;
echo '<p style="font-size:80%; color:#999;">Reading: ';
echo '<p class="includes">Reading: ';
}
......
......@@ -108,13 +108,15 @@
global $qa_db_fail_handler;
@error_log('PHP Question2Answer MySQL '.$type.' error '.$errno.': '.$error.(isset($query) ? (' - Query: '.$query) : ''));
@error_log('PHP Question2Answer MySQL ' . $type . ' error ' . $errno . ': ' . $error . (isset($query) ? (' - Query: ' . $query) : ''));
if (function_exists($qa_db_fail_handler))
$qa_db_fail_handler($type, $errno, $error, $query);
else {
echo '<hr><font color="red">Database '.htmlspecialchars($type.' error '.$errno).'<p>'.nl2br(htmlspecialchars($error."\n\n".$query));
echo sprintf(
'<hr><div style="color: red">Database %s<p>%s</p><code>%s</code></div>',
htmlspecialchars($type . ' error ' . $errno), nl2br(htmlspecialchars($error)), nl2br(htmlspecialchars($query))
);
qa_exit('error');
}
}
......
......@@ -1116,6 +1116,10 @@ class qa_html_theme_base
$this->form_number($field, $style);
break;
case 'file':
$this->form_file($field, $style);
break;
case 'select':
$this->form_select($field, $style);
break;
......@@ -1270,6 +1274,11 @@ class qa_html_theme_base
$this->output('<input '.@$field['tags'].' type="text" value="'.@$field['value'].'" class="qa-form-'.$style.'-number"/>');
}
public function form_file($field, $style)
{
$this->output('<input '.@$field['tags'].' type="file" class="qa-form-'.$style.'-file"/>');
}
/**
* Output a <select> element. The $field array may contain the following keys:
* options: (required) a key-value array containing all the options in the select.
......
......@@ -54,6 +54,8 @@ class qa_event_logger
}
}
}
return array();
}
......
......@@ -233,6 +233,9 @@ class qa_wysiwyg_editor
);
}
else {
// convert to text
qa_load_module('viewer', '');
return array(
'format' => '',
'content' => $this->html_to_text($html),
......
......@@ -31,7 +31,6 @@ class qa_xml_sitemap
case 'xml_sitemap_show_category_qs':
case 'xml_sitemap_show_categories':
return true;
break;
}
}
......
......@@ -913,7 +913,7 @@ blockquote p {
.qa-q-view-content,
.qa-a-item-content,
.qa-c-item-content {
word-break: break-word;
word-wrap: break-word;
}
.qa-q-view-content table, .qa-a-item-content table, .qa-c-item-content table {
......@@ -2473,7 +2473,7 @@ input[type="submit"], button {
background: #fff;
margin-bottom: 5px;
}
.qa-part-a-form:empty
.qa-part-a-form:empty,
.qa-part-a-form h2 {
margin-top: 0;
}
......
......@@ -303,7 +303,7 @@ class qa_html_theme extends qa_html_theme_base
$this->output_raw($this->content['sidepanel']);
$this->feed();
$this->widgets('side', 'bottom');
$this->output('</div>', '');
$this->output('</div> <!-- qa-sidepanel -->', '');
}
/**
......@@ -318,7 +318,7 @@ class qa_html_theme extends qa_html_theme_base
if (!empty($sidebar)) {
$this->output('<div class="qa-sidebar ' . $this->welcome_widget_class . '">');
$this->output_raw($sidebar);
$this->output('</div>', '');
$this->output('</div> <!-- qa-sidebar -->', '');
}
}
}
......
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