Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Q
question2answer
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
outils
question2answer
Commits
2be2b6bb
Commit
2be2b6bb
authored
Jul 15, 2016
by
Scott
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Coding style (misc. pages)
parent
d057c557
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
692 additions
and
744 deletions
+692
-744
categories.php
qa-include/pages/categories.php
+59
-65
favorites-list.php
qa-include/pages/favorites-list.php
+50
-55
favorites.php
qa-include/pages/favorites.php
+52
-58
feedback.php
qa-include/pages/feedback.php
+124
-128
forgot.php
qa-include/pages/forgot.php
+62
-68
ip.php
qa-include/pages/ip.php
+0
-0
message.php
qa-include/pages/message.php
+0
-0
messages.php
qa-include/pages/messages.php
+77
-77
search.php
qa-include/pages/search.php
+82
-87
tag.php
qa-include/pages/tag.php
+50
-53
tags.php
qa-include/pages/tags.php
+37
-43
unsubscribe.php
qa-include/pages/unsubscribe.php
+33
-38
updates.php
qa-include/pages/updates.php
+66
-72
No files found.
qa-include/pages/categories.php
View file @
2be2b6bb
...
...
@@ -20,99 +20,94 @@
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
;
}
if
(
!
defined
(
'QA_VERSION'
))
{
// don't allow this page to be requested directly from browser
header
(
'Location: ../'
);
exit
;
}
require_once
QA_INCLUDE_DIR
.
'db/selects.php'
;
require_once
QA_INCLUDE_DIR
.
'app/format.php'
;
require_once
QA_INCLUDE_DIR
.
'db/selects.php'
;
require_once
QA_INCLUDE_DIR
.
'app/format.php'
;
$categoryslugs
=
qa_request_parts
(
1
);
$countslugs
=
count
(
$categoryslugs
);
$categoryslugs
=
qa_request_parts
(
1
);
$countslugs
=
count
(
$categoryslugs
);
// Get information about appropriate categories and redirect to questions page if category has no sub-categories
$userid
=
qa_get_logged_in_userid
();
list
(
$categories
,
$categoryid
,
$favoritecats
)
=
qa_db_select_with_pending
(
qa_db_category_nav_selectspec
(
$categoryslugs
,
false
,
false
,
true
),
$countslugs
?
qa_db_slugs_to_category_id_selectspec
(
$categoryslugs
)
:
null
,
isset
(
$userid
)
?
qa_db_user_favorite_categories_selectspec
(
$userid
)
:
null
);
$userid
=
qa_get_logged_in_userid
();
list
(
$categories
,
$categoryid
,
$favoritecats
)
=
qa_db_select_with_pending
(
qa_db_category_nav_selectspec
(
$categoryslugs
,
false
,
false
,
true
),
$countslugs
?
qa_db_slugs_to_category_id_selectspec
(
$categoryslugs
)
:
null
,
isset
(
$userid
)
?
qa_db_user_favorite_categories_selectspec
(
$userid
)
:
null
);
if
(
$countslugs
&&
!
isset
(
$categoryid
))
return
include
QA_INCLUDE_DIR
.
'qa-page-not-found.php'
;
if
(
$countslugs
&&
!
isset
(
$categoryid
))
return
include
QA_INCLUDE_DIR
.
'qa-page-not-found.php'
;
// Function for recursive display of categories
function
qa_category_nav_to_browse
(
&
$navigation
,
$categories
,
$categoryid
,
$favoritemap
)
{
foreach
(
$navigation
as
$key
=>
$navlink
)
{
$category
=
$categories
[
$navlink
[
'categoryid'
]];
function
qa_category_nav_to_browse
(
&
$navigation
,
$categories
,
$categoryid
,
$favoritemap
)
{
foreach
(
$navigation
as
$key
=>
$navlink
)
{
$category
=
$categories
[
$navlink
[
'categoryid'
]];
if
(
!
$category
[
'childcount'
])
unset
(
$navigation
[
$key
][
'url'
]);
elseif
(
$navlink
[
'selected'
])
{
$navigation
[
$key
][
'state'
]
=
'open'
;
$navigation
[
$key
][
'url'
]
=
qa_path_html
(
'categories/'
.
qa_category_path_request
(
$categories
,
$category
[
'parentid'
]));
}
else
$navigation
[
$key
][
'state'
]
=
'closed'
;
if
(
!
$category
[
'childcount'
])
unset
(
$navigation
[
$key
][
'url'
]);
elseif
(
$navlink
[
'selected'
])
{
$navigation
[
$key
][
'state'
]
=
'open'
;
$navigation
[
$key
][
'url'
]
=
qa_path_html
(
'categories/'
.
qa_category_path_request
(
$categories
,
$category
[
'parentid'
]));
}
else
$navigation
[
$key
][
'state'
]
=
'closed'
;
if
(
@
$favoritemap
[
$navlink
[
'categoryid'
]])
$navigation
[
$key
][
'favorited'
]
=
true
;
if
(
@
$favoritemap
[
$navlink
[
'categoryid'
]])
$navigation
[
$key
][
'favorited'
]
=
true
;
$navigation
[
$key
][
'note'
]
=
''
;
$navigation
[
$key
][
'note'
]
=
''
;
$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>'
;
$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>'
;
if
(
strlen
(
$category
[
'content'
]))
$navigation
[
$key
][
'note'
]
.=
qa_html
(
' - '
.
$category
[
'content'
]);
if
(
strlen
(
$category
[
'content'
]))
$navigation
[
$key
][
'note'
]
.=
qa_html
(
' - '
.
$category
[
'content'
]);
if
(
isset
(
$navlink
[
'subnav'
]))
qa_category_nav_to_browse
(
$navigation
[
$key
][
'subnav'
],
$categories
,
$categoryid
,
$favoritemap
);
}
if
(
isset
(
$navlink
[
'subnav'
]))
qa_category_nav_to_browse
(
$navigation
[
$key
][
'subnav'
],
$categories
,
$categoryid
,
$favoritemap
);
}
}
// Prepare content for theme
$qa_content
=
qa_content_prepare
(
false
,
array_keys
(
qa_category_path
(
$categories
,
$categoryid
)));
$qa_content
=
qa_content_prepare
(
false
,
array_keys
(
qa_category_path
(
$categories
,
$categoryid
)));
$qa_content
[
'title'
]
=
qa_lang_html
(
'misc/browse_categories'
);
$qa_content
[
'title'
]
=
qa_lang_html
(
'misc/browse_categories'
);
if
(
count
(
$categories
))
{
$navigation
=
qa_category_navigation
(
$categories
,
$categoryid
,
'categories/'
,
false
);
if
(
count
(
$categories
))
{
$navigation
=
qa_category_navigation
(
$categories
,
$categoryid
,
'categories/'
,
false
);
unset
(
$navigation
[
'all'
]);
unset
(
$navigation
[
'all'
]);
$favoritemap
=
array
();
if
(
isset
(
$favoritecats
))
foreach
(
$favoritecats
as
$category
)
$favoritemap
[
$category
[
'categoryid'
]]
=
true
;
$favoritemap
=
array
();
if
(
isset
(
$favoritecats
))
foreach
(
$favoritecats
as
$category
)
$favoritemap
[
$category
[
'categoryid'
]]
=
true
;
qa_category_nav_to_browse
(
$navigation
,
$categories
,
$categoryid
,
$favoritemap
);
$qa_content
[
'nav_list'
]
=
array
(
'nav'
=>
$navigation
,
'type'
=>
'browse-cat'
,
);
}
else
{
$qa_content
[
'title'
]
=
qa_lang_html
(
'main/no_categories_found'
);
$qa_content
[
'suggest_next'
]
=
qa_html_suggest_qs_tags
(
qa_using_tags
());
}
qa_category_nav_to_browse
(
$navigation
,
$categories
,
$categoryid
,
$favoritemap
);
$qa_content
[
'nav_list'
]
=
array
(
'nav'
=>
$navigation
,
'type'
=>
'browse-cat'
,
);
return
$qa_content
;
}
else
{
$qa_content
[
'title'
]
=
qa_lang_html
(
'main/no_categories_found'
);
$qa_content
[
'suggest_next'
]
=
qa_html_suggest_qs_tags
(
qa_using_tags
());
}
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
return
$qa_content
;
qa-include/pages/favorites-list.php
View file @
2be2b6bb
...
...
@@ -20,88 +20,84 @@
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
;
}
if
(
!
defined
(
'QA_VERSION'
))
{
// don't allow this page to be requested directly from browser
header
(
'Location: ../'
);
exit
;
}
require_once
QA_INCLUDE_DIR
.
'db/selects.php'
;
require_once
QA_INCLUDE_DIR
.
'app/format.php'
;
require_once
QA_INCLUDE_DIR
.
'app/favorites.php'
;
require_once
QA_INCLUDE_DIR
.
'db/selects.php'
;
require_once
QA_INCLUDE_DIR
.
'app/format.php'
;
require_once
QA_INCLUDE_DIR
.
'app/favorites.php'
;
// Data for functions to run
$favswitch
=
array
(
'questions'
=>
array
(
'page_opt'
=>
'page_size_qs'
,
'fn_spec'
=>
'qa_db_user_favorite_qs_selectspec'
,
'fn_view'
=>
'qa_favorite_q_list_view'
,
'key'
=>
'q_list'
,
),
'users'
=>
array
(
'page_opt'
=>
'page_size_users'
,
'fn_spec'
=>
'qa_db_user_favorite_users_selectspec'
,
'fn_view'
=>
'qa_favorite_users_view'
,
'key'
=>
'ranking_users'
,
),
'tags'
=>
array
(
'page_opt'
=>
'page_size_tags'
,
'fn_spec'
=>
'qa_db_user_favorite_tags_selectspec'
,
'fn_view'
=>
'qa_favorite_tags_view'
,
'key'
=>
'ranking_tags'
,
),
);
$favswitch
=
array
(
'questions'
=>
array
(
'page_opt'
=>
'page_size_qs'
,
'fn_spec'
=>
'qa_db_user_favorite_qs_selectspec'
,
'fn_view'
=>
'qa_favorite_q_list_view'
,
'key'
=>
'q_list'
,
),
'users'
=>
array
(
'page_opt'
=>
'page_size_users'
,
'fn_spec'
=>
'qa_db_user_favorite_users_selectspec'
,
'fn_view'
=>
'qa_favorite_users_view'
,
'key'
=>
'ranking_users'
,
),
'tags'
=>
array
(
'page_opt'
=>
'page_size_tags'
,
'fn_spec'
=>
'qa_db_user_favorite_tags_selectspec'
,
'fn_view'
=>
'qa_favorite_tags_view'
,
'key'
=>
'ranking_tags'
,
),
);
// Check that we're logged in
$userid
=
qa_get_logged_in_userid
();
$userid
=
qa_get_logged_in_userid
();
if
(
!
isset
(
$userid
))
qa_redirect
(
'login'
);
if
(
!
isset
(
$userid
))
qa_redirect
(
'login'
);
// Get lists of favorites of this type
$favtype
=
qa_request_part
(
1
);
$start
=
qa_get_start
();
$favtype
=
qa_request_part
(
1
);
$start
=
qa_get_start
();
if
(
!
array_key_exists
(
$favtype
,
$favswitch
)
||
(
$favtype
===
'users'
&&
QA_FINAL_EXTERNAL_USERS
))
return
include
QA_INCLUDE_DIR
.
'qa-page-not-found.php'
;
if
(
!
array_key_exists
(
$favtype
,
$favswitch
)
||
(
$favtype
===
'users'
&&
QA_FINAL_EXTERNAL_USERS
))
return
include
QA_INCLUDE_DIR
.
'qa-page-not-found.php'
;
extract
(
$favswitch
[
$favtype
]);
// get switch variables
extract
(
$favswitch
[
$favtype
]);
// get switch variables
$pagesize
=
qa_opt
(
$page_opt
);
list
(
$totalItems
,
$items
)
=
qa_db_select_with_pending
(
qa_db_selectspec_count
(
$fn_spec
(
$userid
)),
$fn_spec
(
$userid
,
$pagesize
,
$start
)
);
$pagesize
=
qa_opt
(
$page_opt
);
list
(
$totalItems
,
$items
)
=
qa_db_select_with_pending
(
qa_db_selectspec_count
(
$fn_spec
(
$userid
)),
$fn_spec
(
$userid
,
$pagesize
,
$start
)
);
$count
=
$totalItems
[
'count'
];
$usershtml
=
qa_userids_handles_html
(
$items
);
$count
=
$totalItems
[
'count'
];
$usershtml
=
qa_userids_handles_html
(
$items
);
// Prepare and return content for theme
$qa_content
=
qa_content_prepare
(
true
);
$qa_content
=
qa_content_prepare
(
true
);
$qa_content
[
'title'
]
=
qa_lang_html
(
'misc/my_favorites_title'
);
$qa_content
[
'title'
]
=
qa_lang_html
(
'misc/my_favorites_title'
);
$qa_content
[
$key
]
=
$fn_view
(
$items
,
$usershtml
);
$qa_content
[
$key
]
=
$fn_view
(
$items
,
$usershtml
);
// Sub navigation for account pages and suggestion
$qa_content
[
'suggest_next'
]
=
qa_lang_html_sub
(
'misc/suggest_favorites_add'
,
'<span class="qa-favorite-image"> </span>'
);
$qa_content
[
'page_links'
]
=
qa_html_page_links
(
qa_request
(),
$start
,
$pagesize
,
$count
,
qa_opt
(
'pages_prev_next'
));
$qa_content
[
'suggest_next'
]
=
qa_lang_html_sub
(
'misc/suggest_favorites_add'
,
'<span class="qa-favorite-image"> </span>'
);
$qa_content
[
'navigation'
][
'sub'
]
=
qa_user_sub_navigation
(
qa_get_logged_in_handle
(),
'favorites'
,
true
);
$qa_content
[
'page_links'
]
=
qa_html_page_links
(
qa_request
(),
$start
,
$pagesize
,
$count
,
qa_opt
(
'pages_prev_next'
)
);
$qa_content
[
'navigation'
][
'sub'
]
=
qa_user_sub_navigation
(
qa_get_logged_in_handle
(),
'favorites'
,
true
);
return
$qa_content
;
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
return
$qa_content
;
qa-include/pages/favorites.php
View file @
2be2b6bb
...
...
@@ -20,105 +20,100 @@
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
;
}
if
(
!
defined
(
'QA_VERSION'
))
{
// don't allow this page to be requested directly from browser
header
(
'Location: ../'
);
exit
;
}
require_once
QA_INCLUDE_DIR
.
'db/selects.php'
;
require_once
QA_INCLUDE_DIR
.
'app/format.php'
;
require_once
QA_INCLUDE_DIR
.
'app/favorites.php'
;
require_once
QA_INCLUDE_DIR
.
'db/selects.php'
;
require_once
QA_INCLUDE_DIR
.
'app/format.php'
;
require_once
QA_INCLUDE_DIR
.
'app/favorites.php'
;
// Check that we're logged in
$userid
=
qa_get_logged_in_userid
();
$userid
=
qa_get_logged_in_userid
();
if
(
!
isset
(
$userid
))
qa_redirect
(
'login'
);
if
(
!
isset
(
$userid
))
qa_redirect
(
'login'
);
// Get lists of favorites for this user
$pagesize_qs
=
qa_opt
(
'page_size_qs'
);
$pagesize_users
=
qa_opt
(
'page_size_users'
);
$pagesize_tags
=
qa_opt
(
'page_size_tags'
);
$pagesize_qs
=
qa_opt
(
'page_size_qs'
);
$pagesize_users
=
qa_opt
(
'page_size_users'
);
$pagesize_tags
=
qa_opt
(
'page_size_tags'
);
list
(
$numQs
,
$questions
,
$numUsers
,
$users
,
$numTags
,
$tags
,
$categories
)
=
qa_db_select_with_pending
(
qa_db_selectspec_count
(
qa_db_user_favorite_qs_selectspec
(
$userid
)
),
qa_db_user_favorite_qs_selectspec
(
$userid
,
$pagesize_qs
),
list
(
$numQs
,
$questions
,
$numUsers
,
$users
,
$numTags
,
$tags
,
$categories
)
=
qa_db_select_with_pending
(
qa_db_selectspec_count
(
qa_db_user_favorite_qs_selectspec
(
$userid
)
),
qa_db_user_favorite_qs_selectspec
(
$userid
,
$pagesize_qs
),
QA_FINAL_EXTERNAL_USERS
?
null
:
qa_db_selectspec_count
(
qa_db_user_favorite_users_selectspec
(
$userid
)
),
QA_FINAL_EXTERNAL_USERS
?
null
:
qa_db_user_favorite_users_selectspec
(
$userid
,
$pagesize_users
),
QA_FINAL_EXTERNAL_USERS
?
null
:
qa_db_selectspec_count
(
qa_db_user_favorite_users_selectspec
(
$userid
)
),
QA_FINAL_EXTERNAL_USERS
?
null
:
qa_db_user_favorite_users_selectspec
(
$userid
,
$pagesize_users
),
qa_db_selectspec_count
(
qa_db_user_favorite_tags_selectspec
(
$userid
)
),
qa_db_user_favorite_tags_selectspec
(
$userid
,
$pagesize_tags
),
qa_db_selectspec_count
(
qa_db_user_favorite_tags_selectspec
(
$userid
)
),
qa_db_user_favorite_tags_selectspec
(
$userid
,
$pagesize_tags
),
qa_db_user_favorite_categories_selectspec
(
$userid
)
);
qa_db_user_favorite_categories_selectspec
(
$userid
)
);
$usershtml
=
qa_userids_handles_html
(
QA_FINAL_EXTERNAL_USERS
?
$questions
:
array_merge
(
$questions
,
$users
));
$usershtml
=
qa_userids_handles_html
(
QA_FINAL_EXTERNAL_USERS
?
$questions
:
array_merge
(
$questions
,
$users
));
// Prepare and return content for theme
$qa_content
=
qa_content_prepare
(
true
);
$qa_content
=
qa_content_prepare
(
true
);
$qa_content
[
'title'
]
=
qa_lang_html
(
'misc/my_favorites_title'
);
$qa_content
[
'title'
]
=
qa_lang_html
(
'misc/my_favorites_title'
);
// Favorite questions
$qa_content
[
'q_list'
]
=
qa_favorite_q_list_view
(
$questions
,
$usershtml
);
$qa_content
[
'q_list'
][
'title'
]
=
count
(
$questions
)
?
qa_lang_html
(
'main/nav_qs'
)
:
qa_lang_html
(
'misc/no_favorite_qs'
);
if
(
$numQs
[
'count'
]
>
count
(
$questions
))
{
$url
=
qa_path_html
(
'favorites/questions'
,
array
(
'start'
=>
$pagesize_qs
));
$qa_content
[
'q_list'
][
'footer'
]
=
'<p class="qa-link-next"><a href="'
.
$url
.
'">'
.
qa_lang_html
(
'misc/more_favorite_qs'
)
.
'</a></p>'
;
}
$qa_content
[
'q_list'
]
=
qa_favorite_q_list_view
(
$questions
,
$usershtml
);
$qa_content
[
'q_list'
][
'title'
]
=
count
(
$questions
)
?
qa_lang_html
(
'main/nav_qs'
)
:
qa_lang_html
(
'misc/no_favorite_qs'
);
if
(
$numQs
[
'count'
]
>
count
(
$questions
))
{
$url
=
qa_path_html
(
'favorites/questions'
,
array
(
'start'
=>
$pagesize_qs
));
$qa_content
[
'q_list'
][
'footer'
]
=
'<p class="qa-link-next"><a href="'
.
$url
.
'">'
.
qa_lang_html
(
'misc/more_favorite_qs'
)
.
'</a></p>'
;
}
// Favorite users
if
(
!
QA_FINAL_EXTERNAL_USERS
)
{
$qa_content
[
'ranking_users'
]
=
qa_favorite_users_view
(
$users
,
$usershtml
);
$qa_content
[
'ranking_users'
][
'title'
]
=
count
(
$users
)
?
qa_lang_html
(
'main/nav_users'
)
:
qa_lang_html
(
'misc/no_favorite_users'
);
if
(
$numUsers
[
'count'
]
>
count
(
$users
))
{
$url
=
qa_path_html
(
'favorites/users'
,
array
(
'start'
=>
$pagesize_users
));
$qa_content
[
'ranking_users'
][
'footer'
]
=
'<p class="qa-link-next"><a href="'
.
$url
.
'">'
.
qa_lang_html
(
'misc/more_favorite_users'
)
.
'</a></p>'
;
}
if
(
!
QA_FINAL_EXTERNAL_USERS
)
{
$qa_content
[
'ranking_users'
]
=
qa_favorite_users_view
(
$users
,
$usershtml
);
$qa_content
[
'ranking_users'
][
'title'
]
=
count
(
$users
)
?
qa_lang_html
(
'main/nav_users'
)
:
qa_lang_html
(
'misc/no_favorite_users'
);
if
(
$numUsers
[
'count'
]
>
count
(
$users
))
{
$url
=
qa_path_html
(
'favorites/users'
,
array
(
'start'
=>
$pagesize_users
));
$qa_content
[
'ranking_users'
][
'footer'
]
=
'<p class="qa-link-next"><a href="'
.
$url
.
'">'
.
qa_lang_html
(
'misc/more_favorite_users'
)
.
'</a></p>'
;
}
}
// Favorite tags
if
(
qa_using_tags
())
{
$qa_content
[
'ranking_tags'
]
=
qa_favorite_tags_view
(
$tags
);
$qa_content
[
'ranking_tags'
][
'title'
]
=
count
(
$tags
)
?
qa_lang_html
(
'main/nav_tags'
)
:
qa_lang_html
(
'misc/no_favorite_tags'
);
if
(
$numTags
[
'count'
]
>
count
(
$tags
))
{
$url
=
qa_path_html
(
'favorites/tags'
,
array
(
'start'
=>
$pagesize_tags
));
$qa_content
[
'ranking_tags'
][
'footer'
]
=
'<p class="qa-link-next"><a href="'
.
$url
.
'">'
.
qa_lang_html
(
'misc/more_favorite_tags'
)
.
'</a></p>'
;
}
if
(
qa_using_tags
())
{
$qa_content
[
'ranking_tags'
]
=
qa_favorite_tags_view
(
$tags
);
$qa_content
[
'ranking_tags'
][
'title'
]
=
count
(
$tags
)
?
qa_lang_html
(
'main/nav_tags'
)
:
qa_lang_html
(
'misc/no_favorite_tags'
);
if
(
$numTags
[
'count'
]
>
count
(
$tags
))
{
$url
=
qa_path_html
(
'favorites/tags'
,
array
(
'start'
=>
$pagesize_tags
));
$qa_content
[
'ranking_tags'
][
'footer'
]
=
'<p class="qa-link-next"><a href="'
.
$url
.
'">'
.
qa_lang_html
(
'misc/more_favorite_tags'
)
.
'</a></p>'
;
}
}
// Favorite categories (no pagination)
if
(
qa_using_categories
())
{
$qa_content
[
'nav_list_categories'
]
=
qa_favorite_categories_view
(
$categories
);
$qa_content
[
'nav_list_categories'
][
'title'
]
=
count
(
$categories
)
?
qa_lang_html
(
'main/nav_categories'
)
:
qa_lang_html
(
'misc/no_favorite_categories'
);
}
if
(
qa_using_categories
())
{
$qa_content
[
'nav_list_categories'
]
=
qa_favorite_categories_view
(
$categories
);
$qa_content
[
'nav_list_categories'
][
'title'
]
=
count
(
$categories
)
?
qa_lang_html
(
'main/nav_categories'
)
:
qa_lang_html
(
'misc/no_favorite_categories'
);
}
// Sub navigation for account pages and suggestion
$qa_content
[
'suggest_next'
]
=
qa_lang_html_sub
(
'misc/suggest_favorites_add'
,
'<span class="qa-favorite-image"> </span>'
);
$qa_content
[
'suggest_next'
]
=
qa_lang_html_sub
(
'misc/suggest_favorites_add'
,
'<span class="qa-favorite-image"> </span>'
);
$qa_content
[
'navigation'
][
'sub'
]
=
qa_user_sub_navigation
(
qa_get_logged_in_handle
(),
'favorites'
,
true
);
$qa_content
[
'navigation'
][
'sub'
]
=
qa_user_sub_navigation
(
qa_get_logged_in_handle
(),
'favorites'
,
true
);
return
$qa_content
;
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
return
$qa_content
;
qa-include/pages/feedback.php
View file @
2be2b6bb
...
...
@@ -20,166 +20,163 @@
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
;
}
if
(
!
defined
(
'QA_VERSION'
))
{
// don't allow this page to be requested directly from browser
header
(
'Location: ../'
);
exit
;
}
require_once
QA_INCLUDE_DIR
.
'app/captcha.php'
;
require_once
QA_INCLUDE_DIR
.
'db/selects.php'
;
require_once
QA_INCLUDE_DIR
.
'app/captcha.php'
;
require_once
QA_INCLUDE_DIR
.
'db/selects.php'
;
// Get useful information on the logged in user
$userid
=
qa_get_logged_in_userid
();
$userid
=
qa_get_logged_in_userid
();
if
(
isset
(
$userid
)
&&
!
QA_FINAL_EXTERNAL_USERS
)
list
(
$useraccount
,
$userprofile
)
=
qa_db_select_with_pending
(
qa_db_user_account_selectspec
(
$userid
,
true
),
qa_db_user_profile_selectspec
(
$userid
,
true
)
);
if
(
isset
(
$userid
)
&&
!
QA_FINAL_EXTERNAL_USERS
)
{
list
(
$useraccount
,
$userprofile
)
=
qa_db_select_with_pending
(
qa_db_user_account_selectspec
(
$userid
,
true
),
qa_db_user_profile_selectspec
(
$userid
,
true
)
);
}
$usecaptcha
=
qa_opt
(
'captcha_on_feedback'
)
&&
qa_user_use_captcha
();
$usecaptcha
=
qa_opt
(
'captcha_on_feedback'
)
&&
qa_user_use_captcha
();
// Check feedback is enabled and the person isn't blocked
if
(
!
qa_opt
(
'feedback_enabled'
))
return
include
QA_INCLUDE_DIR
.
'qa-page-not-found.php'
;
if
(
!
qa_opt
(
'feedback_enabled'
))
return
include
QA_INCLUDE_DIR
.
'qa-page-not-found.php'
;
if
(
qa_user_permit_error
())
{
$qa_content
=
qa_content_prepare
();
$qa_content
[
'error'
]
=
qa_lang_html
(
'users/no_permission'
);
return
$qa_content
;
}
if
(
qa_user_permit_error
())
{
$qa_content
=
qa_content_prepare
();
$qa_content
[
'error'
]
=
qa_lang_html
(
'users/no_permission'
);
return
$qa_content
;
}
// Send the feedback form
$feedbacksent
=
false
;
if
(
qa_clicked
(
'dofeedback'
))
{
require_once
QA_INCLUDE_DIR
.
'app/emails.php'
;
require_once
QA_INCLUDE_DIR
.
'util/string.php'
;
$inmessage
=
qa_post_text
(
'message'
);
$inname
=
qa_post_text
(
'name'
);
$inemail
=
qa_post_text
(
'email'
);
$inreferer
=
qa_post_text
(
'referer'
);
if
(
!
qa_check_form_security_code
(
'feedback'
,
qa_post_text
(
'code'
)))
$pageerror
=
qa_lang_html
(
'misc/form_security_again'
);
else
{
if
(
empty
(
$inmessage
))
$errors
[
'message'
]
=
qa_lang
(
'misc/feedback_empty'
);
if
(
$usecaptcha
)
qa_captcha_validate_post
(
$errors
);
if
(
empty
(
$errors
))
{
$subs
=
array
(
'^message'
=>
$inmessage
,
'^name'
=>
empty
(
$inname
)
?
'-'
:
$inname
,
'^email'
=>
empty
(
$inemail
)
?
'-'
:
$inemail
,
'^previous'
=>
empty
(
$inreferer
)
?
'-'
:
$inreferer
,
'^url'
=>
isset
(
$userid
)
?
qa_path_absolute
(
'user/'
.
qa_get_logged_in_handle
())
:
'-'
,
'^ip'
=>
qa_remote_ip_address
(),
'^browser'
=>
@
$_SERVER
[
'HTTP_USER_AGENT'
],
);
if
(
qa_send_email
(
array
(
'fromemail'
=>
qa_email_validate
(
@
$inemail
)
?
$inemail
:
qa_opt
(
'from_email'
),
'fromname'
=>
$inname
,
'toemail'
=>
qa_opt
(
'feedback_email'
),
'toname'
=>
qa_opt
(
'site_title'
),
'subject'
=>
qa_lang_sub
(
'emails/feedback_subject'
,
qa_opt
(
'site_title'
)),
'body'
=>
strtr
(
qa_lang
(
'emails/feedback_body'
),
$subs
),
'html'
=>
false
,
)))
$feedbacksent
=
true
;
else
$pageerror
=
qa_lang_html
(
'main/general_error'
);
qa_report_event
(
'feedback'
,
$userid
,
qa_get_logged_in_handle
(),
qa_cookie_get
(),
array
(
'email'
=>
$inemail
,
'name'
=>
$inname
,
'message'
=>
$inmessage
,
'previous'
=>
$inreferer
,
'browser'
=>
@
$_SERVER
[
'HTTP_USER_AGENT'
],
));
$feedbacksent
=
false
;
if
(
qa_clicked
(
'dofeedback'
))
{
require_once
QA_INCLUDE_DIR
.
'app/emails.php'
;
require_once
QA_INCLUDE_DIR
.
'util/string.php'
;
$inmessage
=
qa_post_text
(
'message'
);
$inname
=
qa_post_text
(
'name'
);
$inemail
=
qa_post_text
(
'email'
);
$inreferer
=
qa_post_text
(
'referer'
);
if
(
!
qa_check_form_security_code
(
'feedback'
,
qa_post_text
(
'code'
)))
$pageerror
=
qa_lang_html
(
'misc/form_security_again'
);
else
{
if
(
empty
(
$inmessage
))
$errors
[
'message'
]
=
qa_lang
(
'misc/feedback_empty'
);
if
(
$usecaptcha
)
qa_captcha_validate_post
(
$errors
);
if
(
empty
(
$errors
))
{
$subs
=
array
(
'^message'
=>
$inmessage
,
'^name'
=>
empty
(
$inname
)
?
'-'
:
$inname
,
'^email'
=>
empty
(
$inemail
)
?
'-'
:
$inemail
,
'^previous'
=>
empty
(
$inreferer
)
?
'-'
:
$inreferer
,
'^url'
=>
isset
(
$userid
)
?
qa_path_absolute
(
'user/'
.
qa_get_logged_in_handle
())
:
'-'
,
'^ip'
=>
qa_remote_ip_address
(),
'^browser'
=>
@
$_SERVER
[
'HTTP_USER_AGENT'
],
);
if
(
qa_send_email
(
array
(
'fromemail'
=>
qa_email_validate
(
@
$inemail
)
?
$inemail
:
qa_opt
(
'from_email'
),
'fromname'
=>
$inname
,
'toemail'
=>
qa_opt
(
'feedback_email'
),
'toname'
=>
qa_opt
(
'site_title'
),
'subject'
=>
qa_lang_sub
(
'emails/feedback_subject'
,
qa_opt
(
'site_title'
)),
'body'
=>
strtr
(
qa_lang
(
'emails/feedback_body'
),
$subs
),
'html'
=>
false
,
)))
{
$feedbacksent
=
true
;
}
else
{
$pageerror
=
qa_lang_html
(
'main/general_error'
);
}
qa_report_event
(
'feedback'
,
$userid
,
qa_get_logged_in_handle
(),
qa_cookie_get
(),
array
(
'email'
=>
$inemail
,
'name'
=>
$inname
,
'message'
=>
$inmessage
,
'previous'
=>
$inreferer
,
'browser'
=>
@
$_SERVER
[
'HTTP_USER_AGENT'
],
));
}
}
}
// Prepare content for theme
$qa_content
=
qa_content_prepare
();
$qa_content
[
'title'
]
=
qa_lang_html
(
'misc/feedback_title'
);
$qa_content
[
'error'
]
=@
$pageerror
;
$qa_content
[
'form'
]
=
array
(
'tags'
=>
'method="post" action="'
.
qa_self_html
()
.
'"'
,
'style'
=>
'tall'
,
'fields'
=>
array
(
'message'
=>
array
(
'type'
=>
$feedbacksent
?
'static'
:
''
,
'label'
=>
qa_lang_html_sub
(
'misc/feedback_message'
,
qa_opt
(
'site_title'
)),
'tags'
=>
'name="message" id="message"'
,
'value'
=>
qa_html
(
@
$inmessage
),
'rows'
=>
8
,
'error'
=>
qa_html
(
@
$errors
[
'message'
]),
),
'name'
=>
array
(
'type'
=>
$feedbacksent
?
'static'
:
''
,
'label'
=>
qa_lang_html
(
'misc/feedback_name'
),
'tags'
=>
'name="name"'
,
'value'
=>
qa_html
(
isset
(
$inname
)
?
$inname
:
@
$userprofile
[
'name'
]),
),
'email'
=>
array
(
'type'
=>
$feedbacksent
?
'static'
:
''
,
'label'
=>
qa_lang_html
(
'misc/feedback_email'
),
'tags'
=>
'name="email"'
,
'value'
=>
qa_html
(
isset
(
$inemail
)
?
$inemail
:
qa_get_logged_in_email
()),
'note'
=>
$feedbacksent
?
null
:
qa_opt
(
'email_privacy'
),
),
$qa_content
=
qa_content_prepare
();
$qa_content
[
'title'
]
=
qa_lang_html
(
'misc/feedback_title'
);
$qa_content
[
'error'
]
=
@
$pageerror
;
$qa_content
[
'form'
]
=
array
(
'tags'
=>
'method="post" action="'
.
qa_self_html
()
.
'"'
,
'style'
=>
'tall'
,
'fields'
=>
array
(
'message'
=>
array
(
'type'
=>
$feedbacksent
?
'static'
:
''
,
'label'
=>
qa_lang_html_sub
(
'misc/feedback_message'
,
qa_opt
(
'site_title'
)),
'tags'
=>
'name="message" id="message"'
,
'value'
=>
qa_html
(
@
$inmessage
),
'rows'
=>
8
,
'error'
=>
qa_html
(
@
$errors
[
'message'
]),
),
'buttons'
=>
array
(
'send'
=>
array
(
'label'
=>
qa_lang_html
(
'main/send_button'
),
),
'name'
=>
array
(
'type'
=>
$feedbacksent
?
'static'
:
''
,
'label'
=>
qa_lang_html
(
'misc/feedback_name'
),
'tags'
=>
'name="name"'
,
'value'
=>
qa_html
(
isset
(
$inname
)
?
$inname
:
@
$userprofile
[
'name'
]),
),
'hidden'
=>
array
(
'dofeedback'
=>
'1'
,
'code'
=>
qa_get_form_security_code
(
'feedback'
),
'referer'
=>
qa_html
(
isset
(
$inreferer
)
?
$inreferer
:
@
$_SERVER
[
'HTTP_REFERER'
]),
'email'
=>
array
(
'type'
=>
$feedbacksent
?
'static'
:
''
,
'label'
=>
qa_lang_html
(
'misc/feedback_email'
),
'tags'
=>
'name="email"'
,
'value'
=>
qa_html
(
isset
(
$inemail
)
?
$inemail
:
qa_get_logged_in_email
()),
'note'
=>
$feedbacksent
?
null
:
qa_opt
(
'email_privacy'
),
),
)
;
)
,
if
(
$usecaptcha
&&
!
$feedbacksent
)
qa_set_up_captcha_field
(
$qa_content
,
$qa_content
[
'form'
][
'fields'
],
@
$errors
);
'buttons'
=>
array
(
'send'
=>
array
(
'label'
=>
qa_lang_html
(
'main/send_button'
),
),
),
'hidden'
=>
array
(
'dofeedback'
=>
'1'
,
'code'
=>
qa_get_form_security_code
(
'feedback'
),
'referer'
=>
qa_html
(
isset
(
$inreferer
)
?
$inreferer
:
@
$_SERVER
[
'HTTP_REFERER'
]),
),
);
$qa_content
[
'focusid'
]
=
'message'
;
if
(
$usecaptcha
&&
!
$feedbacksent
)
qa_set_up_captcha_field
(
$qa_content
,
$qa_content
[
'form'
][
'fields'
],
@
$errors
);
if
(
$feedbacksent
)
{
$qa_content
[
'form'
][
'ok'
]
=
qa_lang_html
(
'misc/feedback_sent'
);
unset
(
$qa_content
[
'form'
][
'buttons'
]);
}
$qa_content
[
'focusid'
]
=
'message'
;
return
$qa_content
;
if
(
$feedbacksent
)
{
$qa_content
[
'form'
][
'ok'
]
=
qa_lang_html
(
'misc/feedback_sent'
);
unset
(
$qa_content
[
'form'
][
'buttons'
]);
}
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
return
$qa_content
;
qa-include/pages/forgot.php
View file @
2be2b6bb
...
...
@@ -20,106 +20,101 @@
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
;
}
if
(
!
defined
(
'QA_VERSION'
))
{
// don't allow this page to be requested directly from browser
header
(
'Location: ../'
);
exit
;
}
require_once
QA_INCLUDE_DIR
.
'db/users.php'
;
require_once
QA_INCLUDE_DIR
.
'app/captcha.php'
;
require_once
QA_INCLUDE_DIR
.
'db/users.php'
;
require_once
QA_INCLUDE_DIR
.
'app/captcha.php'
;
// Check we're not using single-sign on integration and that we're not logged in
if
(
QA_FINAL_EXTERNAL_USERS
)
qa_fatal_error
(
'User login is handled by external code'
);
if
(
QA_FINAL_EXTERNAL_USERS
)
qa_fatal_error
(
'User login is handled by external code'
);
if
(
qa_is_logged_in
())
qa_redirect
(
''
);
if
(
qa_is_logged_in
())
qa_redirect
(
''
);
// Start the 'I forgot my password' process, sending email if appropriate
if
(
qa_clicked
(
'doforgot'
))
{
require_once
QA_INCLUDE_DIR
.
'app/users-edit.php'
;
if
(
qa_clicked
(
'doforgot'
))
{
require_once
QA_INCLUDE_DIR
.
'app/users-edit.php'
;
$inemailhandle
=
qa_post_text
(
'emailhandle'
);
$inemailhandle
=
qa_post_text
(
'emailhandle'
);
$errors
=
array
();
$errors
=
array
();
if
(
!
qa_check_form_security_code
(
'forgot'
,
qa_post_text
(
'code'
)))
$errors
[
'page'
]
=
qa_lang_html
(
'misc/form_security_again'
);
if
(
!
qa_check_form_security_code
(
'forgot'
,
qa_post_text
(
'code'
)))
$errors
[
'page'
]
=
qa_lang_html
(
'misc/form_security_again'
);
else
{
if
(
strpos
(
$inemailhandle
,
'@'
)
===
false
)
{
// handles can't contain @ symbols
$matchusers
=
qa_db_user_find_by_handle
(
$inemailhandle
);
$passemailhandle
=
!
qa_opt
(
'allow_login_email_only'
);
else
{
if
(
strpos
(
$inemailhandle
,
'@'
)
===
false
)
{
// handles can't contain @ symbols
$matchusers
=
qa_db_user_find_by_handle
(
$inemailhandle
);
$passemailhandle
=
!
qa_opt
(
'allow_login_email_only'
);
}
else
{
$matchusers
=
qa_db_user_find_by_email
(
$inemailhandle
);
$passemailhandle
=
true
;
}
}
else
{
$matchusers
=
qa_db_user_find_by_email
(
$inemailhandle
);
$passemailhandle
=
true
;
}
if
(
count
(
$matchusers
)
!=
1
)
// if we get more than one match (should be impossible) also give an error
$errors
[
'emailhandle'
]
=
qa_lang
(
'users/user_not_found'
);
if
(
count
(
$matchusers
)
!=
1
)
// if we get more than one match (should be impossible) also give an error
$errors
[
'emailhandle'
]
=
qa_lang
(
'users/user_not_found'
);
if
(
qa_opt
(
'captcha_on_reset_password'
))
qa_captcha_validate_post
(
$errors
);
if
(
qa_opt
(
'captcha_on_reset_password'
))
qa_captcha_validate_post
(
$errors
);
if
(
empty
(
$errors
))
{
$inuserid
=
$matchusers
[
0
];
qa_start_reset_user
(
$inuserid
);
qa_redirect
(
'reset'
,
$passemailhandle
?
array
(
'e'
=>
$inemailhandle
)
:
null
);
// redirect to page where code is entered
}
if
(
empty
(
$errors
))
{
$inuserid
=
$matchusers
[
0
];
qa_start_reset_user
(
$inuserid
);
qa_redirect
(
'reset'
,
$passemailhandle
?
array
(
'e'
=>
$inemailhandle
)
:
null
);
// redirect to page where code is entered
}
}
}
else
$inemailhandle
=
qa_get
(
'e'
);
}
else
$inemailhandle
=
qa_get
(
'e'
);
// Prepare content for theme
$qa_content
=
qa_content_prepare
();
$qa_content
=
qa_content_prepare
();
$qa_content
[
'title'
]
=
qa_lang_html
(
'users/reset_title'
);
$qa_content
[
'error'
]
=
@
$errors
[
'page'
];
$qa_content
[
'title'
]
=
qa_lang_html
(
'users/reset_title'
);
$qa_content
[
'error'
]
=
@
$errors
[
'page'
];
$qa_content
[
'form'
]
=
array
(
'tags'
=>
'method="post" action="'
.
qa_self_html
()
.
'"'
,
$qa_content
[
'form'
]
=
array
(
'tags'
=>
'method="post" action="'
.
qa_self_html
()
.
'"'
,
'style'
=>
'tall'
,
'style'
=>
'tall'
,
'fields'
=>
array
(
'email_handle'
=>
array
(
'label'
=>
qa_lang_html
(
'users/email_handle_label'
),
'tags'
=>
'name="emailhandle" id="emailhandle"'
,
'value'
=>
qa_html
(
@
$inemailhandle
),
'error'
=>
qa_html
(
@
$errors
[
'emailhandle'
]),
'note'
=>
qa_lang_html
(
'users/send_reset_note'
),
),
'fields'
=>
array
(
'email_handle'
=>
array
(
'label'
=>
qa_lang_html
(
'users/email_handle_label'
),
'tags'
=>
'name="emailhandle" id="emailhandle"'
,
'value'
=>
qa_html
(
@
$inemailhandle
),
'error'
=>
qa_html
(
@
$errors
[
'emailhandle'
]),
'note'
=>
qa_lang_html
(
'users/send_reset_note'
),
),
),
'buttons'
=>
array
(
'send'
=>
array
(
'label'
=>
qa_lang_html
(
'users/send_reset_button'
),
),
'buttons'
=>
array
(
'send'
=>
array
(
'label'
=>
qa_lang_html
(
'users/send_reset_button'
),
),
),
'hidden'
=>
array
(
'doforgot'
=>
'1'
,
'code'
=>
qa_get_form_security_code
(
'forgot'
),
),
);
'hidden'
=>
array
(
'doforgot'
=>
'1'
,
'code'
=>
qa_get_form_security_code
(
'forgot'
),
),
);
if
(
qa_opt
(
'captcha_on_reset_password'
))
qa_set_up_captcha_field
(
$qa_content
,
$qa_content
[
'form'
][
'fields'
],
@
$errors
);
if
(
qa_opt
(
'captcha_on_reset_password'
))
qa_set_up_captcha_field
(
$qa_content
,
$qa_content
[
'form'
][
'fields'
],
@
$errors
);
$qa_content
[
'focusid'
]
=
'emailhandle'
;
$qa_content
[
'focusid'
]
=
'emailhandle'
;
return
$qa_content
;
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
return
$qa_content
;
qa-include/pages/ip.php
View file @
2be2b6bb
This diff is collapsed.
Click to expand it.
qa-include/pages/message.php
View file @
2be2b6bb
This diff is collapsed.
Click to expand it.
qa-include/pages/messages.php
View file @
2be2b6bb
...
...
@@ -20,106 +20,106 @@
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
;
}
if
(
!
defined
(
'QA_VERSION'
))
{
// don't allow this page to be requested directly from browser
header
(
'Location: ../'
);
exit
;
}
require_once
QA_INCLUDE_DIR
.
'db/selects.php'
;
require_once
QA_INCLUDE_DIR
.
'app/users.php'
;
require_once
QA_INCLUDE_DIR
.
'app/format.php'
;
require_once
QA_INCLUDE_DIR
.
'app/limits.php'
;
require_once
QA_INCLUDE_DIR
.
'db/selects.php'
;
require_once
QA_INCLUDE_DIR
.
'app/users.php'
;
require_once
QA_INCLUDE_DIR
.
'app/format.php'
;
require_once
QA_INCLUDE_DIR
.
'app/limits.php'
;
$loginUserId
=
qa_get_logged_in_userid
();
$loginUserHandle
=
qa_get_logged_in_handle
();
$loginUserId
=
qa_get_logged_in_userid
();
$loginUserHandle
=
qa_get_logged_in_handle
();
// Check which box we're showing (inbox/sent), we're not using Q2A's single-sign on integration and that we're logged in
$req
=
qa_request_part
(
1
);
if
(
$req
===
null
)
$showOutbox
=
false
;
elseif
(
$req
===
'sent'
)
$showOutbox
=
true
;
else
return
include
QA_INCLUDE_DIR
.
'qa-page-not-found.php'
;
$req
=
qa_request_part
(
1
);
if
(
$req
===
null
)
$showOutbox
=
false
;
elseif
(
$req
===
'sent'
)
$showOutbox
=
true
;
else
return
include
QA_INCLUDE_DIR
.
'qa-page-not-found.php'
;
if
(
QA_FINAL_EXTERNAL_USERS
)
qa_fatal_error
(
'User accounts are handled by external code'
);
if
(
QA_FINAL_EXTERNAL_USERS
)
qa_fatal_error
(
'User accounts are handled by external code'
);
if
(
!
isset
(
$loginUserId
))
{
$qa_content
=
qa_content_prepare
();
$qa_content
[
'error'
]
=
qa_insert_login_links
(
qa_lang_html
(
'misc/message_must_login'
),
qa_request
());
return
$qa_content
;
}
if
(
!
isset
(
$loginUserId
))
{
$qa_content
=
qa_content_prepare
();
$qa_content
[
'error'
]
=
qa_insert_login_links
(
qa_lang_html
(
'misc/message_must_login'
),
qa_request
());
return
$qa_content
;
}
if
(
!
qa_opt
(
'allow_private_messages'
)
||
!
qa_opt
(
'show_message_history'
))
return
include
QA_INCLUDE_DIR
.
'qa-page-not-found.php'
;
if
(
!
qa_opt
(
'allow_private_messages'
)
||
!
qa_opt
(
'show_message_history'
))
return
include
QA_INCLUDE_DIR
.
'qa-page-not-found.php'
;
// Find the messages for this user
$start
=
qa_get_start
();
$pagesize
=
qa_opt
(
'page_size_pms'
);
$start
=
qa_get_start
();
$pagesize
=
qa_opt
(
'page_size_pms'
);
// get number of messages then actual messages for this page
$func
=
$showOutbox
?
'qa_db_messages_outbox_selectspec'
:
'qa_db_messages_inbox_selectspec'
;
$pmSpecCount
=
qa_db_selectspec_count
(
$func
(
'private'
,
$loginUserId
,
true
)
);
$pmSpec
=
$func
(
'private'
,
$loginUserId
,
true
,
$start
,
$pagesize
);
// get number of messages then actual messages for this page
$func
=
$showOutbox
?
'qa_db_messages_outbox_selectspec'
:
'qa_db_messages_inbox_selectspec'
;
$pmSpecCount
=
qa_db_selectspec_count
(
$func
(
'private'
,
$loginUserId
,
true
)
);
$pmSpec
=
$func
(
'private'
,
$loginUserId
,
true
,
$start
,
$pagesize
);
list
(
$numMessages
,
$userMessages
)
=
qa_db_select_with_pending
(
$pmSpecCount
,
$pmSpec
);
$count
=
$numMessages
[
'count'
];
list
(
$numMessages
,
$userMessages
)
=
qa_db_select_with_pending
(
$pmSpecCount
,
$pmSpec
);
$count
=
$numMessages
[
'count'
];
// Prepare content for theme
$qa_content
=
qa_content_prepare
();
$qa_content
[
'title'
]
=
qa_lang_html
(
$showOutbox
?
'misc/pm_outbox_title'
:
'misc/pm_inbox_title'
);
$qa_content
[
'script_rel'
][]
=
'qa-content/qa-user.js?'
.
QA_VERSION
;
$qa_content
[
'message_list'
]
=
array
(
'tags'
=>
'id="privatemessages"'
,
'messages'
=>
array
(),
'form'
=>
array
(
'tags'
=>
'name="pmessage" method="post" action="'
.
qa_self_html
()
.
'"'
,
'style'
=>
'tall'
,
'hidden'
=>
array
(
'qa_click'
=>
''
,
// for simulating clicks in Javascript
'handle'
=>
qa_html
(
$loginUserHandle
),
'start'
=>
qa_html
(
$start
),
'code'
=>
qa_get_form_security_code
(
'pm-'
.
$loginUserHandle
),
$qa_content
=
qa_content_prepare
();
$qa_content
[
'title'
]
=
qa_lang_html
(
$showOutbox
?
'misc/pm_outbox_title'
:
'misc/pm_inbox_title'
);
$qa_content
[
'script_rel'
][]
=
'qa-content/qa-user.js?'
.
QA_VERSION
;
$qa_content
[
'message_list'
]
=
array
(
'tags'
=>
'id="privatemessages"'
,
'messages'
=>
array
(),
'form'
=>
array
(
'tags'
=>
'name="pmessage" method="post" action="'
.
qa_self_html
()
.
'"'
,
'style'
=>
'tall'
,
'hidden'
=>
array
(
'qa_click'
=>
''
,
// for simulating clicks in Javascript
'handle'
=>
qa_html
(
$loginUserHandle
),
'start'
=>
qa_html
(
$start
),
'code'
=>
qa_get_form_security_code
(
'pm-'
.
$loginUserHandle
),
),
),
);
$htmlDefaults
=
qa_message_html_defaults
();
if
(
$showOutbox
)
$htmlDefaults
[
'towhomview'
]
=
true
;
foreach
(
$userMessages
as
$message
)
{
$msgFormat
=
qa_message_html_fields
(
$message
,
$htmlDefaults
);
$replyHandle
=
$showOutbox
?
$message
[
'tohandle'
]
:
$message
[
'fromhandle'
];
$msgFormat
[
'form'
]
=
array
(
'style'
=>
'light'
,
'buttons'
=>
array
(
'reply'
=>
array
(
'tags'
=>
'onclick="window.location.href=\''
.
qa_path_html
(
'message/'
.
$replyHandle
)
.
'\';return false"'
,
'label'
=>
qa_lang_html
(
'question/reply_button'
),
),
'delete'
=>
array
(
'tags'
=>
'name="m'
.
qa_html
(
$message
[
'messageid'
])
.
'_dodelete" onclick="return qa_pm_click('
.
qa_js
(
$message
[
'messageid'
])
.
', this, '
.
qa_js
(
$showOutbox
?
'outbox'
:
'inbox'
)
.
');"'
,
'label'
=>
qa_lang_html
(
'question/delete_button'
),
'popup'
=>
qa_lang_html
(
'profile/delete_pm_popup'
),
),
),
);
$htmlDefaults
=
qa_message_html_defaults
();
if
(
$showOutbox
)
$htmlDefaults
[
'towhomview'
]
=
true
;
foreach
(
$userMessages
as
$message
)
{
$msgFormat
=
qa_message_html_fields
(
$message
,
$htmlDefaults
);
$replyHandle
=
$showOutbox
?
$message
[
'tohandle'
]
:
$message
[
'fromhandle'
];
$msgFormat
[
'form'
]
=
array
(
'style'
=>
'light'
,
'buttons'
=>
array
(
'reply'
=>
array
(
'tags'
=>
'onclick="window.location.href=\''
.
qa_path_html
(
'message/'
.
$replyHandle
)
.
'\';return false"'
,
'label'
=>
qa_lang_html
(
'question/reply_button'
),
),
'delete'
=>
array
(
'tags'
=>
'name="m'
.
qa_html
(
$message
[
'messageid'
])
.
'_dodelete" onclick="return qa_pm_click('
.
qa_js
(
$message
[
'messageid'
])
.
', this, '
.
qa_js
(
$showOutbox
?
'outbox'
:
'inbox'
)
.
');"'
,
'label'
=>
qa_lang_html
(
'question/delete_button'
),
'popup'
=>
qa_lang_html
(
'profile/delete_pm_popup'
),
),
),
);
$qa_content
[
'message_list'
][
'messages'
][]
=
$msgFormat
;
}
$qa_content
[
'message_list'
][
'messages'
][]
=
$msgFormat
;
}
$qa_content
[
'page_links'
]
=
qa_html_page_links
(
qa_request
(),
$start
,
$pagesize
,
$count
,
qa_opt
(
'pages_prev_next'
));
$qa_content
[
'page_links'
]
=
qa_html_page_links
(
qa_request
(),
$start
,
$pagesize
,
$count
,
qa_opt
(
'pages_prev_next'
));
$qa_content
[
'navigation'
][
'sub'
]
=
qa_messages_sub_navigation
(
$showOutbox
?
'outbox'
:
'inbox'
);
$qa_content
[
'navigation'
][
'sub'
]
=
qa_messages_sub_navigation
(
$showOutbox
?
'outbox'
:
'inbox'
);
return
$qa_content
;
return
$qa_content
;
qa-include/pages/search.php
View file @
2be2b6bb
...
...
@@ -20,134 +20,130 @@
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
;
}
if
(
!
defined
(
'QA_VERSION'
))
{
// don't allow this page to be requested directly from browser
header
(
'Location: ../'
);
exit
;
}
require_once
QA_INCLUDE_DIR
.
'app/format.php'
;
require_once
QA_INCLUDE_DIR
.
'app/options.php'
;
require_once
QA_INCLUDE_DIR
.
'app/search.php'
;
require_once
QA_INCLUDE_DIR
.
'app/format.php'
;
require_once
QA_INCLUDE_DIR
.
'app/options.php'
;
require_once
QA_INCLUDE_DIR
.
'app/search.php'
;
// Perform the search if appropriate
if
(
strlen
(
qa_get
(
'q'
)))
{
if
(
strlen
(
qa_get
(
'q'
)))
{
// Pull in input parameters
$inquery
=
trim
(
qa_get
(
'q'
));
$userid
=
qa_get_logged_in_userid
();
$start
=
qa_get_start
();
$inquery
=
trim
(
qa_get
(
'q'
));
$userid
=
qa_get_logged_in_userid
();
$start
=
qa_get_start
();
$display
=
qa_opt_if_loaded
(
'page_size_search'
);
$count
=
2
*
(
isset
(
$display
)
?
$display
:
QA_DB_RETRIEVE_QS_AS
)
+
1
;
// get enough results to be able to give some idea of how many pages of search results there are
$display
=
qa_opt_if_loaded
(
'page_size_search'
);
$count
=
2
*
(
isset
(
$display
)
?
$display
:
QA_DB_RETRIEVE_QS_AS
)
+
1
;
// get enough results to be able to give some idea of how many pages of search results there are
// Perform the search using appropriate module
$results
=
qa_get_search_results
(
$inquery
,
$start
,
$count
,
$userid
,
false
,
false
);
$results
=
qa_get_search_results
(
$inquery
,
$start
,
$count
,
$userid
,
false
,
false
);
// Count and truncate results
$pagesize
=
qa_opt
(
'page_size_search'
);
$gotcount
=
count
(
$results
);
$results
=
array_slice
(
$results
,
0
,
$pagesize
);
$pagesize
=
qa_opt
(
'page_size_search'
);
$gotcount
=
count
(
$results
);
$results
=
array_slice
(
$results
,
0
,
$pagesize
);
// Retrieve extra information on users
$fullquestions
=
array
();
$fullquestions
=
array
();
foreach
(
$results
as
$result
)
if
(
isset
(
$result
[
'question'
]))
$fullquestions
[]
=
$result
[
'question'
];
foreach
(
$results
as
$result
)
{
if
(
isset
(
$result
[
'question'
]))
$fullquestions
[]
=
$result
[
'question'
];
}
$usershtml
=
qa_userids_handles_html
(
$fullquestions
);
$usershtml
=
qa_userids_handles_html
(
$fullquestions
);
// Report the search event
qa_report_event
(
'search'
,
$userid
,
qa_get_logged_in_handle
(),
qa_cookie_get
(),
array
(
'query'
=>
$inquery
,
'start'
=>
$start
,
));
}
qa_report_event
(
'search'
,
$userid
,
qa_get_logged_in_handle
(),
qa_cookie_get
(),
array
(
'query'
=>
$inquery
,
'start'
=>
$start
,
));
}
// Prepare content for theme
$qa_content
=
qa_content_prepare
(
true
);
if
(
strlen
(
qa_get
(
'q'
)))
{
$qa_content
[
'search'
][
'value'
]
=
qa_html
(
$inquery
);
if
(
count
(
$results
))
$qa_content
[
'title'
]
=
qa_lang_html_sub
(
'main/results_for_x'
,
qa_html
(
$inquery
));
else
$qa_content
[
'title'
]
=
qa_lang_html_sub
(
'main/no_results_for_x'
,
qa_html
(
$inquery
));
$qa_content
[
'q_list'
][
'form'
]
=
array
(
'tags'
=>
'method="post" action="'
.
qa_self_html
()
.
'"'
,
'hidden'
=>
array
(
'code'
=>
qa_get_form_security_code
(
'vote'
),
),
);
$qa_content
[
'q_list'
][
'qs'
]
=
array
();
$qa_content
=
qa_content_prepare
(
true
);
$qdefaults
=
qa_post_html_defaults
(
'Q'
);
if
(
strlen
(
qa_get
(
'q'
)))
{
$qa_content
[
'search'
][
'value'
]
=
qa_html
(
$inquery
);
foreach
(
$results
as
$result
)
if
(
!
isset
(
$result
[
'question'
]))
{
// if we have any non-question results, display with less statistics
$qdefaults
[
'voteview'
]
=
false
;
$qdefaults
[
'answersview'
]
=
false
;
$qdefaults
[
'viewsview'
]
=
false
;
break
;
}
if
(
count
(
$results
))
$qa_content
[
'title'
]
=
qa_lang_html_sub
(
'main/results_for_x'
,
qa_html
(
$inquery
));
else
$qa_content
[
'title'
]
=
qa_lang_html_sub
(
'main/no_results_for_x'
,
qa_html
(
$inquery
));
foreach
(
$results
as
$result
)
{
if
(
isset
(
$result
[
'question'
]))
$fields
=
qa_post_html_fields
(
$result
[
'question'
],
$userid
,
qa_cookie_get
(),
$usershtml
,
null
,
qa_post_html_options
(
$result
[
'question'
],
$qdefaults
));
$qa_content
[
'q_list'
][
'form'
]
=
array
(
'tags'
=>
'method="post" action="'
.
qa_self_html
()
.
'"'
,
elseif
(
isset
(
$result
[
'url'
]))
$fields
=
array
(
'what'
=>
qa_html
(
$result
[
'url'
]),
'meta_order'
=>
qa_lang_html
(
'main/meta_order'
),
);
'hidden'
=>
array
(
'code'
=>
qa_get_form_security_code
(
'vote'
),
),
);
else
continue
;
// nothing to show here
$qa_content
[
'q_list'
][
'qs'
]
=
array
();
if
(
isset
(
$qdefaults
[
'blockwordspreg'
]))
$result
[
'title'
]
=
qa_block_words_replace
(
$result
[
'title'
],
$qdefaults
[
'blockwordspreg'
]);
$qdefaults
=
qa_post_html_defaults
(
'Q'
);
$fields
[
'title'
]
=
qa_html
(
$result
[
'title'
]);
$fields
[
'url'
]
=
qa_html
(
$result
[
'url'
]);
foreach
(
$results
as
$result
)
{
if
(
!
isset
(
$result
[
'question'
]))
{
// if we have any non-question results, display with less statistics
$qdefaults
[
'voteview'
]
=
false
;
$qdefaults
[
'answersview'
]
=
false
;
$qdefaults
[
'viewsview'
]
=
false
;
break
;
}
}
$qa_content
[
'q_list'
][
'qs'
][]
=
$fields
;
foreach
(
$results
as
$result
)
{
if
(
isset
(
$result
[
'question'
]))
{
$fields
=
qa_post_html_fields
(
$result
[
'question'
],
$userid
,
qa_cookie_get
(),
$usershtml
,
null
,
qa_post_html_options
(
$result
[
'question'
],
$qdefaults
));
}
elseif
(
isset
(
$result
[
'url'
]))
{
$fields
=
array
(
'what'
=>
qa_html
(
$result
[
'url'
]),
'meta_order'
=>
qa_lang_html
(
'main/meta_order'
),
);
}
else
{
continue
;
// nothing to show here
}
$qa_content
[
'page_links'
]
=
qa_html_page_links
(
qa_request
(),
$start
,
$pagesize
,
$start
+
$gotcount
,
qa_opt
(
'pages_prev_next'
),
array
(
'q'
=>
$inquery
),
$gotcount
>=
$count
);
if
(
isset
(
$qdefaults
[
'blockwordspreg'
]))
$result
[
'title'
]
=
qa_block_words_replace
(
$result
[
'title'
],
$qdefaults
[
'blockwordspreg'
]
);
if
(
qa_opt
(
'feed_for_search'
))
$qa_content
[
'feed'
]
=
array
(
'url'
=>
qa_path_html
(
qa_feed_request
(
'search/'
.
$inquery
)),
'label'
=>
qa_lang_html_sub
(
'main/results_for_x'
,
qa_html
(
$inquery
)),
);
$fields
[
'title'
]
=
qa_html
(
$result
[
'title'
]);
$fields
[
'url'
]
=
qa_html
(
$result
[
'url'
]);
if
(
empty
(
$qa_content
[
'page_links'
]))
$qa_content
[
'suggest_next'
]
=
qa_html_suggest_qs_tags
(
qa_using_tags
());
$qa_content
[
'q_list'
][
'qs'
][]
=
$fields
;
}
}
else
$qa_content
[
'error'
]
=
qa_lang_html
(
'main/search_explanation'
);
$qa_content
[
'page_links'
]
=
qa_html_page_links
(
qa_request
(),
$start
,
$pagesize
,
$start
+
$gotcount
,
qa_opt
(
'pages_prev_next'
),
array
(
'q'
=>
$inquery
),
$gotcount
>=
$count
);
if
(
qa_opt
(
'feed_for_search'
))
{
$qa_content
[
'feed'
]
=
array
(
'url'
=>
qa_path_html
(
qa_feed_request
(
'search/'
.
$inquery
)),
'label'
=>
qa_lang_html_sub
(
'main/results_for_x'
,
qa_html
(
$inquery
)),
);
}
if
(
empty
(
$qa_content
[
'page_links'
]))
$qa_content
[
'suggest_next'
]
=
qa_html_suggest_qs_tags
(
qa_using_tags
());
return
$qa_content
;
}
else
$qa_content
[
'error'
]
=
qa_lang_html
(
'main/search_explanation'
);
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
return
$qa_content
;
qa-include/pages/tag.php
View file @
2be2b6bb
...
...
@@ -20,79 +20,77 @@
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
;
}
if
(
!
defined
(
'QA_VERSION'
))
{
// don't allow this page to be requested directly from browser
header
(
'Location: ../'
);
exit
;
}
require_once
QA_INCLUDE_DIR
.
'db/selects.php'
;
require_once
QA_INCLUDE_DIR
.
'app/format.php'
;
require_once
QA_INCLUDE_DIR
.
'app/updates.php'
;
require_once
QA_INCLUDE_DIR
.
'db/selects.php'
;
require_once
QA_INCLUDE_DIR
.
'app/format.php'
;
require_once
QA_INCLUDE_DIR
.
'app/updates.php'
;
$tag
=
qa_request_part
(
1
);
// picked up from qa-page.php
$start
=
qa_get_start
();
$userid
=
qa_get_logged_in_userid
();
$tag
=
qa_request_part
(
1
);
// picked up from qa-page.php
$start
=
qa_get_start
();
$userid
=
qa_get_logged_in_userid
();
// Find the questions with this tag
if
(
!
strlen
(
$tag
))
qa_redirect
(
'tags'
);
if
(
!
strlen
(
$tag
))
qa_redirect
(
'tags'
);
list
(
$questions
,
$tagword
)
=
qa_db_select_with_pending
(
qa_db_tag_recent_qs_selectspec
(
$userid
,
$tag
,
$start
,
false
,
qa_opt_if_loaded
(
'page_size_tag_qs'
)),
qa_db_tag_word_selectspec
(
$tag
)
);
list
(
$questions
,
$tagword
)
=
qa_db_select_with_pending
(
qa_db_tag_recent_qs_selectspec
(
$userid
,
$tag
,
$start
,
false
,
qa_opt_if_loaded
(
'page_size_tag_qs'
)),
qa_db_tag_word_selectspec
(
$tag
)
);
$pagesize
=
qa_opt
(
'page_size_tag_qs'
);
$questions
=
array_slice
(
$questions
,
0
,
$pagesize
);
$usershtml
=
qa_userids_handles_html
(
$questions
);
$pagesize
=
qa_opt
(
'page_size_tag_qs'
);
$questions
=
array_slice
(
$questions
,
0
,
$pagesize
);
$usershtml
=
qa_userids_handles_html
(
$questions
);
// Prepare content for theme
$qa_content
=
qa_content_prepare
(
true
);
$qa_content
[
'title'
]
=
qa_lang_html_sub
(
'main/questions_tagged_x'
,
qa_html
(
$tag
));
if
(
isset
(
$userid
)
&&
isset
(
$tagword
))
{
$favoritemap
=
qa_get_favorite_non_qs_map
();
$favorite
=@
$favoritemap
[
'tag'
][
qa_strtolower
(
$tagword
[
'word'
])];
$qa_content
=
qa_content_prepare
(
true
);
$qa_content
[
'favorite'
]
=
qa_favorite_form
(
QA_ENTITY_TAG
,
$tagword
[
'wordid'
],
$favorite
,
qa_lang_sub
(
$favorite
?
'main/remove_x_favorites'
:
'main/add_tag_x_favorites'
,
$tagword
[
'word'
]));
}
$qa_content
[
'title'
]
=
qa_lang_html_sub
(
'main/questions_tagged_x'
,
qa_html
(
$tag
));
if
(
!
count
(
$questions
))
$qa_content
[
'q_list'
][
'title'
]
=
qa_lang_html
(
'main/no_questions_found'
);
if
(
isset
(
$userid
)
&&
isset
(
$tagword
))
{
$favoritemap
=
qa_get_favorite_non_qs_map
();
$favorite
=
@
$favoritemap
[
'tag'
][
qa_strtolower
(
$tagword
[
'word'
])];
$qa_content
[
'q_list'
][
'form'
]
=
array
(
'tags'
=>
'method="post" action="'
.
qa_self_html
()
.
'"'
,
$qa_content
[
'favorite'
]
=
qa_favorite_form
(
QA_ENTITY_TAG
,
$tagword
[
'wordid'
],
$favorite
,
qa_lang_sub
(
$favorite
?
'main/remove_x_favorites'
:
'main/add_tag_x_favorites'
,
$tagword
[
'word'
]));
}
'hidden'
=>
array
(
'code'
=>
qa_get_form_security_code
(
'vote'
),
),
);
if
(
!
count
(
$questions
))
$qa_content
[
'q_list'
][
'title'
]
=
qa_lang_html
(
'main/no_questions_found'
);
$qa_content
[
'q_list'
][
'qs'
]
=
array
();
foreach
(
$questions
as
$postid
=>
$question
)
$qa_content
[
'q_list'
][
'qs'
][]
=
qa_post_html_fields
(
$question
,
$userid
,
qa_cookie_get
(),
$usershtml
,
null
,
qa_post_html_options
(
$question
));
$qa_content
[
'q_list'
][
'form'
]
=
array
(
'tags'
=>
'method="post" action="'
.
qa_self_html
()
.
'"'
,
$qa_content
[
'page_links'
]
=
qa_html_page_links
(
qa_request
(),
$start
,
$pagesize
,
$tagword
[
'tagcount'
],
qa_opt
(
'pages_prev_next'
));
'hidden'
=>
array
(
'code'
=>
qa_get_form_security_code
(
'vote'
),
),
);
if
(
empty
(
$qa_content
[
'page_links'
]))
$qa_content
[
'suggest_next'
]
=
qa_html_suggest_qs_tags
(
true
);
$qa_content
[
'q_list'
][
'qs'
]
=
array
();
foreach
(
$questions
as
$postid
=>
$question
)
{
$qa_content
[
'q_list'
][
'qs'
][]
=
qa_post_html_fields
(
$question
,
$userid
,
qa_cookie_get
(),
$usershtml
,
null
,
qa_post_html_options
(
$question
));
}
if
(
qa_opt
(
'feed_for_tag_qs'
))
$qa_content
[
'feed'
]
=
array
(
'url'
=>
qa_path_html
(
qa_feed_request
(
'tag/'
.
$tag
)),
'label'
=>
qa_lang_html_sub
(
'main/questions_tagged_x'
,
qa_html
(
$tag
)),
);
$qa_content
[
'page_links'
]
=
qa_html_page_links
(
qa_request
(),
$start
,
$pagesize
,
$tagword
[
'tagcount'
],
qa_opt
(
'pages_prev_next'
));
if
(
empty
(
$qa_content
[
'page_links'
]))
$qa_content
[
'suggest_next'
]
=
qa_html_suggest_qs_tags
(
true
);
return
$qa_content
;
if
(
qa_opt
(
'feed_for_tag_qs'
))
{
$qa_content
[
'feed'
]
=
array
(
'url'
=>
qa_path_html
(
qa_feed_request
(
'tag/'
.
$tag
)),
'label'
=>
qa_lang_html_sub
(
'main/questions_tagged_x'
,
qa_html
(
$tag
)),
);
}
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
return
$qa_content
;
qa-include/pages/tags.php
View file @
2be2b6bb
...
...
@@ -20,65 +20,60 @@
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
;
}
if
(
!
defined
(
'QA_VERSION'
))
{
// don't allow this page to be requested directly from browser
header
(
'Location: ../'
);
exit
;
}
require_once
QA_INCLUDE_DIR
.
'db/selects.php'
;
require_once
QA_INCLUDE_DIR
.
'app/format.php'
;
require_once
QA_INCLUDE_DIR
.
'db/selects.php'
;
require_once
QA_INCLUDE_DIR
.
'app/format.php'
;
// Get popular tags
$start
=
qa_get_start
();
$userid
=
qa_get_logged_in_userid
();
$populartags
=
qa_db_select_with_pending
(
qa_db_popular_tags_selectspec
(
$start
,
qa_opt_if_loaded
(
'page_size_tags'
))
);
$start
=
qa_get_start
();
$userid
=
qa_get_logged_in_userid
();
$populartags
=
qa_db_select_with_pending
(
qa_db_popular_tags_selectspec
(
$start
,
qa_opt_if_loaded
(
'page_size_tags'
))
);
$tagcount
=
qa_opt
(
'cache_tagcount'
);
$pagesize
=
qa_opt
(
'page_size_tags'
);
$tagcount
=
qa_opt
(
'cache_tagcount'
);
$pagesize
=
qa_opt
(
'page_size_tags'
);
// Prepare content for theme
$qa_content
=
qa_content_prepare
();
$qa_content
[
'title'
]
=
qa_lang_html
(
'main/popular_tags'
);
$qa_content
[
'ranking'
]
=
array
(
'items'
=>
array
(),
'rows'
=>
ceil
(
$pagesize
/
qa_opt
(
'columns_tags'
)),
'type'
=>
'tags'
);
$qa_content
=
qa_content_prepare
();
if
(
count
(
$populartags
))
{
$favoritemap
=
qa_get_favorite_non_qs_map
();
$qa_content
[
'title'
]
=
qa_lang_html
(
'main/popular_tags'
);
$output
=
0
;
foreach
(
$populartags
as
$word
=>
$count
)
{
$qa_content
[
'ranking'
][
'items'
][]
=
array
(
'label'
=>
qa_tag_html
(
$word
,
false
,
@
$favoritemap
[
'tag'
][
qa_strtolower
(
$word
)]),
'count'
=>
qa_format_number
(
$count
,
0
,
true
),
);
$qa_content
[
'ranking'
]
=
array
(
'items'
=>
array
(),
'rows'
=>
ceil
(
$pagesize
/
qa_opt
(
'columns_tags'
)),
'type'
=>
'tags'
);
if
((
++
$output
)
>=
$pagesize
)
break
;
}
if
(
count
(
$populartags
))
{
$favoritemap
=
qa_get_favorite_non_qs_map
();
}
else
$qa_content
[
'title'
]
=
qa_lang_html
(
'main/no_tags_found'
);
$output
=
0
;
foreach
(
$populartags
as
$word
=>
$count
)
{
$qa_content
[
'ranking'
][
'items'
][]
=
array
(
'label'
=>
qa_tag_html
(
$word
,
false
,
@
$favoritemap
[
'tag'
][
qa_strtolower
(
$word
)]),
'count'
=>
qa_format_number
(
$count
,
0
,
true
),
);
$qa_content
[
'page_links'
]
=
qa_html_page_links
(
qa_request
(),
$start
,
$pagesize
,
$tagcount
,
qa_opt
(
'pages_prev_next'
));
if
((
++
$output
)
>=
$pagesize
)
break
;
}
if
(
empty
(
$qa_content
[
'page_links'
]))
$qa_content
[
'suggest_next'
]
=
qa_html_suggest_ask
(
);
}
else
$qa_content
[
'title'
]
=
qa_lang_html
(
'main/no_tags_found'
);
$qa_content
[
'page_links'
]
=
qa_html_page_links
(
qa_request
(),
$start
,
$pagesize
,
$tagcount
,
qa_opt
(
'pages_prev_next'
));
return
$qa_content
;
if
(
empty
(
$qa_content
[
'page_links'
]))
$qa_content
[
'suggest_next'
]
=
qa_html_suggest_ask
();
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
return
$qa_content
;
qa-include/pages/unsubscribe.php
View file @
2be2b6bb
...
...
@@ -20,62 +20,58 @@
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
;
}
if
(
!
defined
(
'QA_VERSION'
))
{
// don't allow this page to be requested directly from browser
header
(
'Location: ../'
);
exit
;
}
require_once
QA_INCLUDE_DIR
.
'db/users.php'
;
require_once
QA_INCLUDE_DIR
.
'db/users.php'
;
// Check we're not using single-sign on integration
if
(
QA_FINAL_EXTERNAL_USERS
)
qa_fatal_error
(
'User login is handled by external code'
);
if
(
QA_FINAL_EXTERNAL_USERS
)
qa_fatal_error
(
'User login is handled by external code'
);
// Check the code and unsubscribe the user if appropriate
$unsubscribed
=
false
;
$loginuserid
=
qa_get_logged_in_userid
();
$unsubscribed
=
false
;
$loginuserid
=
qa_get_logged_in_userid
();
$incode
=
trim
(
qa_get
(
'c'
));
// trim to prevent passing in blank values to match uninitiated DB rows
$inhandle
=
qa_get
(
'u'
);
$incode
=
trim
(
qa_get
(
'c'
));
// trim to prevent passing in blank values to match uninitiated DB rows
$inhandle
=
qa_get
(
'u'
);
if
(
!
empty
(
$inhandle
))
{
// match based on code and handle provided on URL
$userinfo
=
qa_db_select_with_pending
(
qa_db_user_account_selectspec
(
$inhandle
,
false
));
if
(
!
empty
(
$inhandle
))
{
// match based on code and handle provided on URL
$userinfo
=
qa_db_select_with_pending
(
qa_db_user_account_selectspec
(
$inhandle
,
false
));
if
(
strtolower
(
trim
(
@
$userinfo
[
'emailcode'
]))
==
strtolower
(
$incode
))
{
qa_db_user_set_flag
(
$userinfo
[
'userid'
],
QA_USER_FLAGS_NO_MAILINGS
,
true
);
$unsubscribed
=
true
;
}
if
(
strtolower
(
trim
(
@
$userinfo
[
'emailcode'
]))
==
strtolower
(
$incode
))
{
qa_db_user_set_flag
(
$userinfo
[
'userid'
],
QA_USER_FLAGS_NO_MAILINGS
,
true
);
$unsubscribed
=
true
;
}
}
if
(
(
!
$unsubscribed
)
&&
isset
(
$loginuserid
))
{
// as a backup, also unsubscribe logged in user
qa_db_user_set_flag
(
$loginuserid
,
QA_USER_FLAGS_NO_MAILINGS
,
true
);
$unsubscribed
=
true
;
}
if
(
(
!
$unsubscribed
)
&&
isset
(
$loginuserid
))
{
// as a backup, also unsubscribe logged in user
qa_db_user_set_flag
(
$loginuserid
,
QA_USER_FLAGS_NO_MAILINGS
,
true
);
$unsubscribed
=
true
;
}
// Prepare content for theme
$qa_content
=
qa_content_prepare
();
$qa_content
[
'title'
]
=
qa_lang_html
(
'users/unsubscribe_title'
);
$qa_content
=
qa_content_prepare
();
if
(
$unsubscribed
)
$qa_content
[
'error'
]
=
strtr
(
qa_lang_html
(
'users/unsubscribe_complete'
),
array
(
'^0'
=>
qa_html
(
qa_opt
(
'site_title'
)),
'^1'
=>
'<a href="'
.
qa_path_html
(
'account'
)
.
'">'
,
'^2'
=>
'</a>'
,
));
else
$qa_content
[
'error'
]
=
qa_insert_login_links
(
qa_lang_html
(
'users/unsubscribe_wrong_log_in'
),
'unsubscribe'
);
$qa_content
[
'title'
]
=
qa_lang_html
(
'users/unsubscribe_title'
);
if
(
$unsubscribed
)
{
$qa_content
[
'error'
]
=
strtr
(
qa_lang_html
(
'users/unsubscribe_complete'
),
array
(
'^0'
=>
qa_html
(
qa_opt
(
'site_title'
)),
'^1'
=>
'<a href="'
.
qa_path_html
(
'account'
)
.
'">'
,
'^2'
=>
'</a>'
,
));
}
else
{
$qa_content
[
'error'
]
=
qa_insert_login_links
(
qa_lang_html
(
'users/unsubscribe_wrong_log_in'
),
'unsubscribe'
);
}
return
$qa_content
;
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
return
$qa_content
;
qa-include/pages/updates.php
View file @
2be2b6bb
...
...
@@ -20,96 +20,91 @@
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
;
}
if
(
!
defined
(
'QA_VERSION'
))
{
// don't allow this page to be requested directly from browser
header
(
'Location: ../'
);
exit
;
}
require_once
QA_INCLUDE_DIR
.
'db/selects.php'
;
require_once
QA_INCLUDE_DIR
.
'app/format.php'
;
require_once
QA_INCLUDE_DIR
.
'app/q-list.php'
;
require_once
QA_INCLUDE_DIR
.
'db/selects.php'
;
require_once
QA_INCLUDE_DIR
.
'app/format.php'
;
require_once
QA_INCLUDE_DIR
.
'app/q-list.php'
;
// Check that we're logged in
$userid
=
qa_get_logged_in_userid
();
$userid
=
qa_get_logged_in_userid
();
if
(
!
isset
(
$userid
))
qa_redirect
(
'login'
);
if
(
!
isset
(
$userid
))
qa_redirect
(
'login'
);
// Find out which updates to show
$forfavorites
=
qa_get
(
'show'
)
!=
'content'
;
$forcontent
=
qa_get
(
'show'
)
!=
'favorites'
;
$forfavorites
=
qa_get
(
'show'
)
!=
'content'
;
$forcontent
=
qa_get
(
'show'
)
!=
'favorites'
;
// Get lists of recent updates for this user
$questions
=
qa_db_select_with_pending
(
qa_db_user_updates_selectspec
(
$userid
,
$forfavorites
,
$forcontent
)
);
if
(
$forfavorites
)
{
if
(
$forcontent
)
{
$sometitle
=
qa_lang_html
(
'misc/recent_updates_title'
);
$nonetitle
=
qa_lang_html
(
'misc/no_recent_updates'
);
$questions
=
qa_db_select_with_pending
(
qa_db_user_updates_selectspec
(
$userid
,
$forfavorites
,
$forcontent
)
);
}
else
{
$sometitle
=
qa_lang_html
(
'misc/recent_updates_favorites'
);
$nonetitle
=
qa_lang_html
(
'misc/no_updates_favorites
'
);
}
if
(
$forfavorites
)
{
if
(
$forcontent
)
{
$sometitle
=
qa_lang_html
(
'misc/recent_updates_title
'
);
$nonetitle
=
qa_lang_html
(
'misc/no_recent_updates'
);
}
else
{
$sometitle
=
qa_lang_html
(
'misc/recent_updates_content
'
);
$nonetitle
=
qa_lang_html
(
'misc/no_updates_content
'
);
$sometitle
=
qa_lang_html
(
'misc/recent_updates_favorites
'
);
$nonetitle
=
qa_lang_html
(
'misc/no_updates_favorites
'
);
}
}
else
{
$sometitle
=
qa_lang_html
(
'misc/recent_updates_content'
);
$nonetitle
=
qa_lang_html
(
'misc/no_updates_content'
);
}
// Prepare and return content for theme
$qa_content
=
qa_q_list_page_content
(
qa_any_sort_and_dedupe
(
$questions
),
null
,
// questions per page
0
,
// start offset
null
,
// total count (null to hide page links)
$sometitle
,
// title if some questions
$nonetitle
,
// title if no questions
null
,
// categories for navigation
null
,
// selected category id
null
,
// show question counts in category navigation
null
,
// prefix for links in category navigation
null
,
// prefix for RSS feed paths (null to hide)
$forfavorites
?
strtr
(
qa_lang_html
(
'misc/suggest_update_favorites'
),
array
(
'^1'
=>
'<a href="'
.
qa_path_html
(
'favorites'
)
.
'">'
,
'^2'
=>
'</a>'
,
))
:
null
// suggest what to do next
);
$qa_content
[
'navigation'
][
'sub'
]
=
array
(
'all'
=>
array
(
'label'
=>
qa_lang_html
(
'misc/nav_all_my_updates'
),
'url'
=>
qa_path_html
(
'updates'
),
'selected'
=>
$forfavorites
&&
$forcontent
,
),
'favorites'
=>
array
(
'label'
=>
qa_lang_html
(
'misc/nav_my_favorites'
),
'url'
=>
qa_path_html
(
'updates'
,
array
(
'show'
=>
'favorites'
)),
'selected'
=>
$forfavorites
&&
!
$forcontent
,
),
'myposts'
=>
array
(
'label'
=>
qa_lang_html
(
'misc/nav_my_content'
),
'url'
=>
qa_path_html
(
'updates'
,
array
(
'show'
=>
'content'
)),
'selected'
=>
$forcontent
&&
!
$forfavorites
,
),
);
return
$qa_content
;
// Prepare and return content for theme
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
$qa_content
=
qa_q_list_page_content
(
qa_any_sort_and_dedupe
(
$questions
),
null
,
// questions per page
0
,
// start offset
null
,
// total count (null to hide page links)
$sometitle
,
// title if some questions
$nonetitle
,
// title if no questions
null
,
// categories for navigation
null
,
// selected category id
null
,
// show question counts in category navigation
null
,
// prefix for links in category navigation
null
,
// prefix for RSS feed paths (null to hide)
$forfavorites
?
strtr
(
qa_lang_html
(
'misc/suggest_update_favorites'
),
array
(
'^1'
=>
'<a href="'
.
qa_path_html
(
'favorites'
)
.
'">'
,
'^2'
=>
'</a>'
,
))
:
null
// suggest what to do next
);
$qa_content
[
'navigation'
][
'sub'
]
=
array
(
'all'
=>
array
(
'label'
=>
qa_lang_html
(
'misc/nav_all_my_updates'
),
'url'
=>
qa_path_html
(
'updates'
),
'selected'
=>
$forfavorites
&&
$forcontent
,
),
'favorites'
=>
array
(
'label'
=>
qa_lang_html
(
'misc/nav_my_favorites'
),
'url'
=>
qa_path_html
(
'updates'
,
array
(
'show'
=>
'favorites'
)),
'selected'
=>
$forfavorites
&&
!
$forcontent
,
),
'myposts'
=>
array
(
'label'
=>
qa_lang_html
(
'misc/nav_my_content'
),
'url'
=>
qa_path_html
(
'updates'
,
array
(
'show'
=>
'content'
)),
'selected'
=>
$forcontent
&&
!
$forfavorites
,
),
);
return
$qa_content
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment