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
daeb8c4a
Commit
daeb8c4a
authored
Jan 12, 2017
by
Scott
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Coding style (feed)
parent
ac597698
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
300 additions
and
309 deletions
+300
-309
qa-feed.php
qa-include/qa-feed.php
+300
-309
No files found.
qa-include/qa-feed.php
View file @
daeb8c4a
...
...
@@ -20,409 +20,401 @@
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
;
}
@
ini_set
(
'display_errors'
,
0
);
// we don't want to show PHP errors to RSS readers
qa_report_process_stage
(
'init_feed'
);
require_once
QA_INCLUDE_DIR
.
'app/options.php'
;
// Functions used within this file
/**
* Database failure handler function for RSS feeds - outputs HTTP and text errors
*/
function
qa_feed_db_fail_handler
(
$type
,
$errno
=
null
,
$error
=
null
,
$query
=
null
)
{
header
(
'HTTP/1.1 500 Internal Server Error'
);
echo
qa_lang_html
(
'main/general_error'
);
qa_exit
(
'error'
);
}
/**
* Common function called when a non-existent feed is requested - outputs HTTP and text errors
*/
function
qa_feed_not_found
()
{
header
(
'HTTP/1.0 404 Not Found'
);
echo
qa_lang_html
(
'misc/feed_not_found'
);
qa_exit
();
}
/**
* Common function to load appropriate set of questions for requested feed, check category exists, and set up page title
*/
function
qa_feed_load_ifcategory
(
$categoryslugs
,
$allkey
,
$catkey
,
&
$title
,
$questionselectspec1
=
null
,
$questionselectspec2
=
null
,
$questionselectspec3
=
null
,
$questionselectspec4
=
null
)
{
$countslugs
=
@
count
(
$categoryslugs
);
list
(
$questions1
,
$questions2
,
$questions3
,
$questions4
,
$categories
,
$categoryid
)
=
qa_db_select_with_pending
(
$questionselectspec1
,
$questionselectspec2
,
$questionselectspec3
,
$questionselectspec4
,
$countslugs
?
qa_db_category_nav_selectspec
(
$categoryslugs
,
false
)
:
null
,
$countslugs
?
qa_db_slugs_to_category_id_selectspec
(
$categoryslugs
)
:
null
);
if
(
$countslugs
&&
!
isset
(
$categoryid
))
qa_feed_not_found
();
@
ini_set
(
'display_errors'
,
0
);
// we don't want to show PHP errors to RSS readers
if
(
isset
(
$allkey
))
$title
=
(
isset
(
$categoryid
)
&&
isset
(
$catkey
))
?
qa_lang_sub
(
$catkey
,
$categories
[
$categoryid
][
'title'
])
:
qa_lang
(
$allkey
);
qa_report_process_stage
(
'init_feed'
);
return
array_merge
(
is_array
(
$questions1
)
?
$questions1
:
array
(),
is_array
(
$questions2
)
?
$questions2
:
array
(),
is_array
(
$questions3
)
?
$questions3
:
array
(),
is_array
(
$questions4
)
?
$questions4
:
array
()
);
}
require_once
QA_INCLUDE_DIR
.
'app/options.php'
;
// Connect to database and get the type of feed and category requested (in some cases these are overridden later)
// Functions used within this file
qa_db_connect
(
'qa_feed_db_fail_handler'
);
qa_preload_options
();
function
qa_feed_db_fail_handler
(
$type
,
$errno
=
null
,
$error
=
null
,
$query
=
null
)
/*
Database failure handler function for RSS feeds - outputs HTTP and text errors
*/
{
header
(
'HTTP/1.1 500 Internal Server Error'
);
echo
qa_lang_html
(
'main/general_error'
);
qa_exit
(
'error'
);
}
$requestlower
=
strtolower
(
qa_request
());
$foursuffix
=
substr
(
$requestlower
,
-
4
);
if
(
$foursuffix
==
'.rss'
||
$foursuffix
==
'.xml'
)
{
$requestlower
=
substr
(
$requestlower
,
0
,
-
4
);
}
function
qa_feed_not_found
()
/*
Common function called when a non-existent feed is requested - outputs HTTP and text errors
*/
{
header
(
'HTTP/1.0 404 Not Found'
);
echo
qa_lang_html
(
'misc/feed_not_found'
);
qa_exit
();
}
$requestlowerparts
=
explode
(
'/'
,
$requestlower
);
$feedtype
=
@
$requestlowerparts
[
1
];
$feedparams
=
array_slice
(
$requestlowerparts
,
2
);
function
qa_feed_load_ifcategory
(
$categoryslugs
,
$allkey
,
$catkey
,
&
$title
,
$questionselectspec1
=
null
,
$questionselectspec2
=
null
,
$questionselectspec3
=
null
,
$questionselectspec4
=
null
)
/*
Common function to load appropriate set of questions for requested feed, check category exists, and set up page title
*/
{
$countslugs
=@
count
(
$categoryslugs
);
list
(
$questions1
,
$questions2
,
$questions3
,
$questions4
,
$categories
,
$categoryid
)
=
qa_db_select_with_pending
(
$questionselectspec1
,
$questionselectspec2
,
$questionselectspec3
,
$questionselectspec4
,
$countslugs
?
qa_db_category_nav_selectspec
(
$categoryslugs
,
false
)
:
null
,
$countslugs
?
qa_db_slugs_to_category_id_selectspec
(
$categoryslugs
)
:
null
);
if
(
$countslugs
&&
!
isset
(
$categoryid
))
qa_feed_not_found
();
// Choose which option needs to be checked to determine if this feed can be requested, and stop if no matches
if
(
isset
(
$allkey
))
$title
=
(
isset
(
$categoryid
)
&&
isset
(
$catkey
))
?
qa_lang_sub
(
$catkey
,
$categories
[
$categoryid
][
'title'
])
:
qa_lang
(
$allkey
)
;
$feedoption
=
null
;
$categoryslugs
=
$feedparams
;
return
array_merge
(
is_array
(
$questions1
)
?
$questions1
:
array
(),
is_array
(
$questions2
)
?
$questions2
:
array
(),
is_array
(
$questions3
)
?
$questions3
:
array
(),
is_array
(
$questions4
)
?
$questions4
:
array
()
);
}
switch
(
$feedtype
)
{
case
'questions'
:
$feedoption
=
'feed_for_questions'
;
break
;
case
'hot'
:
$feedoption
=
'feed_for_hot'
;
if
(
!
QA_ALLOW_UNINDEXED_QUERIES
)
$categoryslugs
=
null
;
break
;
// Connect to database and get the type of feed and category requested (in some cases these are overridden later)
case
'unanswered'
:
$feedoption
=
'feed_for_unanswered'
;
if
(
!
QA_ALLOW_UNINDEXED_QUERIES
)
$categoryslugs
=
null
;
break
;
qa_db_connect
(
'qa_feed_db_fail_handler'
);
qa_preload_options
();
case
'answers'
:
case
'comments'
:
case
'activity'
:
$feedoption
=
'feed_for_activity'
;
break
;
$requestlower
=
strtolower
(
qa_request
());
$foursuffix
=
substr
(
$requestlower
,
-
4
);
if
(
(
$foursuffix
==
'.rss'
)
||
(
$foursuffix
==
'.xml'
)
)
$requestlower
=
substr
(
$requestlower
,
0
,
-
4
);
$requestlowerparts
=
explode
(
'/'
,
$requestlower
);
$feedtype
=@
$requestlowerparts
[
1
];
$feedparams
=
array_slice
(
$requestlowerparts
,
2
);
case
'qa'
:
$feedoption
=
'feed_for_qa'
;
break
;
case
'tag'
:
if
(
strlen
(
@
$feedparams
[
0
]))
{
$feedoption
=
'feed_for_tag_qs'
;
$categoryslugs
=
null
;
}
break
;
// Choose which option needs to be checked to determine if this feed can be requested, and stop if no matches
case
'search'
:
if
(
strlen
(
@
$feedparams
[
0
]))
{
$feedoption
=
'feed_for_search'
;
$categoryslugs
=
null
;
}
break
;
}
$feedoption
=
null
;
$categoryslugs
=
$feedparams
;
$countslugs
=
@
count
(
$categoryslugs
);
switch
(
$feedtype
)
{
case
'questions'
:
$feedoption
=
'feed_for_questions'
;
break
;
if
(
!
isset
(
$feedoption
))
qa_feed_not_found
();
case
'hot'
:
$feedoption
=
'feed_for_hot'
;
if
(
!
QA_ALLOW_UNINDEXED_QUERIES
)
$categoryslugs
=
null
;
break
;
case
'unanswered'
:
$feedoption
=
'feed_for_unanswered'
;
if
(
!
QA_ALLOW_UNINDEXED_QUERIES
)
$categoryslugs
=
null
;
break
;
// Check that all the appropriate options are in place to allow this feed to be retrieved
case
'answers'
:
case
'comments'
:
case
'activity'
:
$feedoption
=
'feed_for_activity'
;
break
;
if
(
!
(
qa_opt
(
$feedoption
)
&&
(
$countslugs
?
(
qa_using_categories
()
&&
qa_opt
(
'feed_per_category'
))
:
true
)))
qa_feed_not_found
();
case
'qa'
:
$feedoption
=
'feed_for_qa'
;
break
;
case
'tag'
:
if
(
strlen
(
@
$feedparams
[
0
]))
{
$feedoption
=
'feed_for_tag_qs'
;
$categoryslugs
=
null
;
}
break
;
// Retrieve the appropriate questions and other information for this feed
case
'search'
:
if
(
strlen
(
@
$feedparams
[
0
]))
{
$feedoption
=
'feed_for_search'
;
$categoryslugs
=
null
;
}
break
;
}
require_once
QA_INCLUDE_DIR
.
'db/selects.php'
;
$countslugs
=@
count
(
$categoryslugs
);
$sitetitle
=
qa_opt
(
'site_title'
);
$siteurl
=
qa_opt
(
'site_url'
);
$full
=
qa_opt
(
'feed_full_text'
);
$count
=
qa_opt
(
'feed_number_items'
);
$showurllinks
=
qa_opt
(
'show_url_links'
);
if
(
!
isset
(
$feedoption
))
qa_feed_not_found
()
;
$linkrequest
=
$feedtype
.
(
$countslugs
?
(
'/'
.
implode
(
'/'
,
$categoryslugs
))
:
''
);
$linkparams
=
null
;
switch
(
$feedtype
)
{
case
'questions'
:
$questions
=
qa_feed_load_ifcategory
(
$categoryslugs
,
'main/recent_qs_title'
,
'main/recent_qs_in_x'
,
$title
,
qa_db_qs_selectspec
(
null
,
'created'
,
0
,
$categoryslugs
,
null
,
false
,
$full
,
$count
)
);
break
;
// Check that all the appropriate options are in place to allow this feed to be retrieved
if
(
!
(
(
qa_opt
(
$feedoption
))
&&
(
$countslugs
?
(
qa_using_categories
()
&&
qa_opt
(
'feed_per_category'
))
:
true
)
))
qa_feed_not_found
();
case
'hot'
:
$questions
=
qa_feed_load_ifcategory
(
$categoryslugs
,
'main/hot_qs_title'
,
'main/hot_qs_in_x'
,
$title
,
qa_db_qs_selectspec
(
null
,
'hotness'
,
0
,
$categoryslugs
,
null
,
false
,
$full
,
$count
)
);
break
;
case
'unanswered'
:
$questions
=
qa_feed_load_ifcategory
(
$categoryslugs
,
'main/unanswered_qs_title'
,
'main/unanswered_qs_in_x'
,
$title
,
qa_db_unanswered_qs_selectspec
(
null
,
null
,
0
,
$categoryslugs
,
false
,
$full
,
$count
)
);
break
;
// Retrieve the appropriate questions and other information for this feed
case
'answers'
:
$questions
=
qa_feed_load_ifcategory
(
$categoryslugs
,
'main/recent_as_title'
,
'main/recent_as_in_x'
,
$title
,
qa_db_recent_a_qs_selectspec
(
null
,
0
,
$categoryslugs
,
null
,
false
,
$full
,
$count
)
);
break
;
require_once
QA_INCLUDE_DIR
.
'db/selects.php'
;
case
'comments'
:
$questions
=
qa_feed_load_ifcategory
(
$categoryslugs
,
'main/recent_cs_title'
,
'main/recent_cs_in_x'
,
$title
,
qa_db_recent_c_qs_selectspec
(
null
,
0
,
$categoryslugs
,
null
,
false
,
$full
,
$count
)
);
break
;
$sitetitle
=
qa_opt
(
'site_title'
);
$siteurl
=
qa_opt
(
'site_url'
);
$full
=
qa_opt
(
'feed_full_text'
);
$count
=
qa_opt
(
'feed_number_items'
);
$showurllinks
=
qa_opt
(
'show_url_links'
);
case
'qa'
:
$questions
=
qa_feed_load_ifcategory
(
$categoryslugs
,
'main/recent_qs_as_title'
,
'main/recent_qs_as_in_x'
,
$title
,
qa_db_qs_selectspec
(
null
,
'created'
,
0
,
$categoryslugs
,
null
,
false
,
$full
,
$count
),
qa_db_recent_a_qs_selectspec
(
null
,
0
,
$categoryslugs
,
null
,
false
,
$full
,
$count
)
);
break
;
case
'activity'
:
$questions
=
qa_feed_load_ifcategory
(
$categoryslugs
,
'main/recent_activity_title'
,
'main/recent_activity_in_x'
,
$title
,
qa_db_qs_selectspec
(
null
,
'created'
,
0
,
$categoryslugs
,
null
,
false
,
$full
,
$count
),
qa_db_recent_a_qs_selectspec
(
null
,
0
,
$categoryslugs
,
null
,
false
,
$full
,
$count
),
qa_db_recent_c_qs_selectspec
(
null
,
0
,
$categoryslugs
,
null
,
false
,
$full
,
$count
),
qa_db_recent_edit_qs_selectspec
(
null
,
0
,
$categoryslugs
,
null
,
true
,
$full
,
$count
)
);
break
;
$linkrequest
=
$feedtype
.
(
$countslugs
?
(
'/'
.
implode
(
'/'
,
$categoryslugs
))
:
''
);
$linkparams
=
null
;
case
'tag'
:
$tag
=
$feedparams
[
0
]
;
switch
(
$feedtype
)
{
case
'questions'
:
$questions
=
qa_feed_load_ifcategory
(
$categoryslugs
,
'main/recent_qs_title'
,
'main/recent_qs_in_x'
,
$title
,
qa_db_qs_selectspec
(
null
,
'created'
,
0
,
$categoryslugs
,
null
,
false
,
$full
,
$count
)
);
break
;
$questions
=
qa_feed_load_ifcategory
(
null
,
null
,
null
,
$title
,
qa_db_tag_recent_qs_selectspec
(
null
,
$tag
,
0
,
$full
,
$count
)
);
case
'hot'
:
$questions
=
qa_feed_load_ifcategory
(
$categoryslugs
,
'main/hot_qs_title'
,
'main/hot_qs_in_x'
,
$title
,
qa_db_qs_selectspec
(
null
,
'hotness'
,
0
,
$categoryslugs
,
null
,
false
,
$full
,
$count
)
);
break
;
$title
=
qa_lang_sub
(
'main/questions_tagged_x'
,
$tag
);
$linkrequest
=
'tag/'
.
$tag
;
break
;
case
'unanswered'
:
$questions
=
qa_feed_load_ifcategory
(
$categoryslugs
,
'main/unanswered_qs_title'
,
'main/unanswered_qs_in_x'
,
$title
,
qa_db_unanswered_qs_selectspec
(
null
,
null
,
0
,
$categoryslugs
,
false
,
$full
,
$count
)
);
break
;
case
'search'
:
require_once
QA_INCLUDE_DIR
.
'app/search.php'
;
case
'answers'
:
$questions
=
qa_feed_load_ifcategory
(
$categoryslugs
,
'main/recent_as_title'
,
'main/recent_as_in_x'
,
$title
,
qa_db_recent_a_qs_selectspec
(
null
,
0
,
$categoryslugs
,
null
,
false
,
$full
,
$count
)
);
break
;
$query
=
$feedparams
[
0
];
case
'comments'
:
$questions
=
qa_feed_load_ifcategory
(
$categoryslugs
,
'main/recent_cs_title'
,
'main/recent_cs_in_x'
,
$title
,
qa_db_recent_c_qs_selectspec
(
null
,
0
,
$categoryslugs
,
null
,
false
,
$full
,
$count
)
);
break
;
$results
=
qa_get_search_results
(
$query
,
0
,
$count
,
null
,
true
,
$full
);
case
'qa'
:
$questions
=
qa_feed_load_ifcategory
(
$categoryslugs
,
'main/recent_qs_as_title'
,
'main/recent_qs_as_in_x'
,
$title
,
qa_db_qs_selectspec
(
null
,
'created'
,
0
,
$categoryslugs
,
null
,
false
,
$full
,
$count
),
qa_db_recent_a_qs_selectspec
(
null
,
0
,
$categoryslugs
,
null
,
false
,
$full
,
$count
)
);
break
;
case
'activity'
:
$questions
=
qa_feed_load_ifcategory
(
$categoryslugs
,
'main/recent_activity_title'
,
'main/recent_activity_in_x'
,
$title
,
qa_db_qs_selectspec
(
null
,
'created'
,
0
,
$categoryslugs
,
null
,
false
,
$full
,
$count
),
qa_db_recent_a_qs_selectspec
(
null
,
0
,
$categoryslugs
,
null
,
false
,
$full
,
$count
),
qa_db_recent_c_qs_selectspec
(
null
,
0
,
$categoryslugs
,
null
,
false
,
$full
,
$count
),
qa_db_recent_edit_qs_selectspec
(
null
,
0
,
$categoryslugs
,
null
,
true
,
$full
,
$count
)
);
break
;
$title
=
qa_lang_sub
(
'main/results_for_x'
,
$query
);
$linkrequest
=
'search'
;
$linkparams
=
array
(
'q'
=>
$query
);
case
'tag'
:
$tag
=
$feedparams
[
0
];
$questions
=
array
();
$questions
=
qa_feed_load_ifcategory
(
null
,
null
,
null
,
$title
,
qa_db_tag_recent_qs_selectspec
(
null
,
$tag
,
0
,
$full
,
$count
)
foreach
(
$results
as
$result
)
{
$setarray
=
array
(
'title'
=>
$result
[
'title'
],
'url'
=>
$result
[
'url'
],
);
$title
=
qa_lang_sub
(
'main/questions_tagged_x'
,
$tag
);
$linkrequest
=
'tag/'
.
$tag
;
break
;
case
'search'
:
require_once
QA_INCLUDE_DIR
.
'app/search.php'
;
$query
=
$feedparams
[
0
];
$results
=
qa_get_search_results
(
$query
,
0
,
$count
,
null
,
true
,
$full
);
$title
=
qa_lang_sub
(
'main/results_for_x'
,
$query
);
$linkrequest
=
'search'
;
$linkparams
=
array
(
'q'
=>
$query
);
$questions
=
array
();
foreach
(
$results
as
$result
)
{
$setarray
=
array
(
'title'
=>
$result
[
'title'
],
'url'
=>
$result
[
'url'
],
);
if
(
isset
(
$result
[
'question'
]))
$questions
[]
=
array_merge
(
$result
[
'question'
],
$setarray
);
elseif
(
isset
(
$result
[
'url'
]))
$questions
[]
=
$setarray
;
}
break
;
}
// Remove duplicate questions (perhaps referenced in an answer and a comment) and cut down to size
if
(
isset
(
$result
[
'question'
]))
$questions
[]
=
array_merge
(
$result
[
'question'
],
$setarray
);
elseif
(
isset
(
$result
[
'url'
]))
$questions
[]
=
$setarray
;
}
break
;
}
require_once
QA_INCLUDE_DIR
.
'app/format.php'
;
require_once
QA_INCLUDE_DIR
.
'app/updates.php'
;
require_once
QA_INCLUDE_DIR
.
'util/string.php'
;
if
(
(
$feedtype
!=
'search'
)
&&
(
$feedtype
!=
'hot'
)
)
// leave search results and hot questions sorted by relevance
$questions
=
qa_any_sort_and_dedupe
(
$questions
);
// Remove duplicate questions (perhaps referenced in an answer and a comment) and cut down to size
$questions
=
array_slice
(
$questions
,
0
,
$count
);
$blockwordspreg
=
qa_get_block_words_preg
();
require_once
QA_INCLUDE_DIR
.
'app/format.php'
;
require_once
QA_INCLUDE_DIR
.
'app/updates.php'
;
require_once
QA_INCLUDE_DIR
.
'util/string.php'
;
if
(
$feedtype
!=
'search'
&&
$feedtype
!=
'hot'
)
// leave search results and hot questions sorted by relevance
$questions
=
qa_any_sort_and_dedupe
(
$questions
);
// Prepare the XML output
$questions
=
array_slice
(
$questions
,
0
,
$count
);
$blockwordspreg
=
qa_get_block_words_preg
();
$lines
=
array
();
$lines
[]
=
'<?xml version="1.0" encoding="utf-8"?>'
;
$lines
[]
=
'<rss version="2.0">'
;
$lines
[]
=
'<channel>'
;
// Prepare the XML output
$lines
[]
=
'<title>'
.
qa_xml
(
$sitetitle
.
' - '
.
$title
)
.
'</title>'
;
$lines
[]
=
'<link>'
.
qa_xml
(
qa_path
(
$linkrequest
,
$linkparams
,
$siteurl
))
.
'</link>'
;
$lines
[]
=
'<description>Powered by Question2Answer</description>'
;
$lines
=
array
();
foreach
(
$questions
as
$question
)
{
$lines
[]
=
'<?xml version="1.0" encoding="utf-8"?>'
;
$lines
[]
=
'<rss version="2.0">'
;
$lines
[]
=
'<channel>'
;
// Determine whether this is a question, answer or comment, and act accordingly
$lines
[]
=
'<title>'
.
qa_xml
(
$sitetitle
.
' - '
.
$title
)
.
'</title>'
;
$lines
[]
=
'<link>'
.
qa_xml
(
qa_path
(
$linkrequest
,
$linkparams
,
$siteurl
))
.
'</link>'
;
$lines
[]
=
'<description>Powered by Question2Answer</description>'
;
$options
=
array
(
'blockwordspreg'
=>
@
$blockwordspreg
,
'showurllinks'
=>
$showurllinks
);
foreach
(
$questions
as
$question
)
{
$time
=
null
;
$htmlcontent
=
null
;
// Determine whether this is a question, answer or comment, and act accordingly
if
(
isset
(
$question
[
'opostid'
]))
{
$time
=
$question
[
'otime'
];
$options
=
array
(
'blockwordspreg'
=>
@
$blockwordspreg
,
'showurllinks'
=>
$showurllinks
);
if
(
$full
)
$htmlcontent
=
qa_viewer_html
(
$question
[
'ocontent'
],
$question
[
'oformat'
],
$options
)
;
$time
=
null
;
$htmlcontent
=
null
;
}
elseif
(
isset
(
$question
[
'
postid'
]))
{
$time
=
$question
[
'created
'
];
if
(
isset
(
$question
[
'o
postid'
]))
{
$time
=
$question
[
'otime
'
];
if
(
$full
)
$htmlcontent
=
qa_viewer_html
(
$question
[
'content'
],
$question
[
'format'
],
$options
);
}
if
(
$full
)
$htmlcontent
=
qa_viewer_html
(
$question
[
'ocontent'
],
$question
[
'oformat'
],
$options
);
if
(
$feedtype
==
'search'
)
{
$titleprefix
=
''
;
$urlxml
=
qa_xml
(
$question
[
'url'
]);
}
elseif
(
isset
(
$question
[
'postid'
]))
{
$time
=
$question
[
'created'
];
}
else
{
switch
(
@
$question
[
'obasetype'
]
.
'-'
.@
$question
[
'oupdatetype'
])
{
case
'Q-'
:
case
'-'
:
$langstring
=
null
;
break
;
if
(
$full
)
$htmlcontent
=
qa_viewer_html
(
$question
[
'content'
],
$question
[
'format'
],
$options
);
}
case
'Q-'
.
QA_UPDATE_VISIBLE
:
$langstring
=
$question
[
'hidden'
]
?
'misc/feed_hidden_prefix'
:
'misc/feed_reshown_prefix
'
;
break
;
if
(
$feedtype
==
'search'
)
{
$titleprefix
=
'
'
;
$urlxml
=
qa_xml
(
$question
[
'url'
])
;
case
'Q-'
.
QA_UPDATE_CLOSED
:
$langstring
=
isset
(
$question
[
'closedbyid'
])
?
'misc/feed_closed_prefix'
:
'misc/feed_reopened_prefix'
;
break
;
}
else
{
switch
(
@
$question
[
'obasetype'
]
.
'-'
.
@
$question
[
'oupdatetype'
])
{
case
'Q-'
:
case
'-'
:
$langstring
=
null
;
break
;
case
'Q-'
.
QA_UPDATE_TAGS
:
$langstring
=
'misc/feed_retagged
_prefix'
;
break
;
case
'Q-'
.
QA_UPDATE_VISIBLE
:
$langstring
=
$question
[
'hidden'
]
?
'misc/feed_hidden_prefix'
:
'misc/feed_reshown
_prefix'
;
break
;
case
'Q-'
.
QA_UPDATE_CATEGORY
:
$langstring
=
'misc/feed_recategoriz
ed_prefix'
;
break
;
case
'Q-'
.
QA_UPDATE_CLOSED
:
$langstring
=
isset
(
$question
[
'closedbyid'
])
?
'misc/feed_closed_prefix'
:
'misc/feed_reopen
ed_prefix'
;
break
;
case
'A-'
:
$langstring
=
'misc/feed_a
_prefix'
;
break
;
case
'Q-'
.
QA_UPDATE_TAGS
:
$langstring
=
'misc/feed_retagged
_prefix'
;
break
;
case
'A-'
.
QA_UPDATE_SELECTED
:
$langstring
=
'misc/feed_a_select
ed_prefix'
;
break
;
case
'Q-'
.
QA_UPDATE_CATEGORY
:
$langstring
=
'misc/feed_recategoriz
ed_prefix'
;
break
;
case
'A-'
.
QA_UPDATE_VISIBLE
:
$langstring
=
$question
[
'ohidden'
]
?
'misc/feed_hidden_prefix'
:
'misc/feed_a_reshown
_prefix'
;
break
;
case
'A-'
:
$langstring
=
'misc/feed_a
_prefix'
;
break
;
case
'A-'
.
QA_UPDATE_CONTENT
:
$langstring
=
'misc/feed_a_edi
ted_prefix'
;
break
;
case
'A-'
.
QA_UPDATE_SELECTED
:
$langstring
=
'misc/feed_a_selec
ted_prefix'
;
break
;
case
'C-'
:
$langstring
=
'misc/feed_c
_prefix'
;
break
;
case
'A-'
.
QA_UPDATE_VISIBLE
:
$langstring
=
$question
[
'ohidden'
]
?
'misc/feed_hidden_prefix'
:
'misc/feed_a_reshown
_prefix'
;
break
;
case
'C-'
.
QA_UPDATE_TYPE
:
$langstring
=
'misc/feed_c_mov
ed_prefix'
;
break
;
case
'A-'
.
QA_UPDATE_CONTENT
:
$langstring
=
'misc/feed_a_edit
ed_prefix'
;
break
;
case
'C-'
.
QA_UPDATE_VISIBLE
:
$langstring
=
$question
[
'ohidden'
]
?
'misc/feed_hidden_prefix'
:
'misc/feed_c_reshown
_prefix'
;
break
;
case
'C-'
:
$langstring
=
'misc/feed_c
_prefix'
;
break
;
case
'C-'
.
QA_UPDATE_CONTENT
:
$langstring
=
'misc/feed_c_edit
ed_prefix'
;
break
;
case
'C-'
.
QA_UPDATE_TYPE
:
$langstring
=
'misc/feed_c_mov
ed_prefix'
;
break
;
case
'Q-'
.
QA_UPDATE_CONTENT
:
default
:
$langstring
=
'misc/feed_edited_prefix'
;
break
;
case
'C-'
.
QA_UPDATE_VISIBLE
:
$langstring
=
$question
[
'ohidden'
]
?
'misc/feed_hidden_prefix'
:
'misc/feed_c_reshown_prefix'
;
break
;
}
case
'C-'
.
QA_UPDATE_CONTENT
:
$langstring
=
'misc/feed_c_edited_prefix'
;
break
;
$titleprefix
=
isset
(
$langstring
)
?
qa_lang
(
$langstring
)
:
''
;
case
'Q-'
.
QA_UPDATE_CONTENT
:
default
:
$langstring
=
'misc/feed_edited_prefix'
;
break
;
$urlxml
=
qa_xml
(
qa_q_path
(
$question
[
'postid'
],
$question
[
'title'
],
true
,
@
$question
[
'obasetype'
],
@
$question
[
'opostid'
]));
}
if
(
isset
(
$blockwordspreg
))
$question
[
'title'
]
=
qa_block_words_replace
(
$question
[
'title'
],
$blockwordspreg
);
$titleprefix
=
isset
(
$langstring
)
?
qa_lang
(
$langstring
)
:
''
;
// Build the inner XML structure for each item
$urlxml
=
qa_xml
(
qa_q_path
(
$question
[
'postid'
],
$question
[
'title'
],
true
,
@
$question
[
'obasetype'
],
@
$question
[
'opostid'
]));
}
$lines
[]
=
'<item>'
;
$lines
[]
=
'<title>'
.
qa_xml
(
$titleprefix
.
$question
[
'title'
])
.
'</title>'
;
$lines
[]
=
'<link>'
.
$urlxml
.
'</link>'
;
if
(
isset
(
$blockwordspreg
))
$question
[
'title'
]
=
qa_block_words_replace
(
$question
[
'title'
],
$blockwordspreg
);
if
(
isset
(
$htmlcontent
))
$lines
[]
=
'<description>'
.
qa_xml
(
$htmlcontent
)
.
'</description>'
;
// Build the inner XML structure for each item
if
(
isset
(
$question
[
'categoryname'
]))
$lines
[]
=
'<category>'
.
qa_xml
(
$question
[
'categoryname'
])
.
'</category>'
;
$lines
[]
=
'<item>'
;
$lines
[]
=
'<title>'
.
qa_xml
(
$titleprefix
.
$question
[
'title'
])
.
'</title>'
;
$lines
[]
=
'<link>'
.
$urlxml
.
'</link>'
;
$lines
[]
=
'<guid isPermaLink="true">'
.
$urlxml
.
'</guid>'
;
if
(
isset
(
$htmlcontent
))
$lines
[]
=
'<description>'
.
qa_xml
(
$htmlcontent
)
.
'</description>'
;
if
(
isset
(
$time
))
$lines
[]
=
'<pubDate>'
.
qa_xml
(
gmdate
(
'r'
,
$time
))
.
'</pubDate
>'
;
if
(
isset
(
$question
[
'categoryname'
]
))
$lines
[]
=
'<category>'
.
qa_xml
(
$question
[
'categoryname'
])
.
'</category
>'
;
$lines
[]
=
'</item>'
;
}
$lines
[]
=
'<guid isPermaLink="true">'
.
$urlxml
.
'</guid>'
;
$lines
[]
=
'</channel>'
;
$lines
[]
=
'</rss
>'
;
if
(
isset
(
$time
))
$lines
[]
=
'<pubDate>'
.
qa_xml
(
gmdate
(
'r'
,
$time
))
.
'</pubDate
>'
;
$lines
[]
=
'</item>'
;
}
// Disconnect here, once all output is ready to go
$lines
[]
=
'</channel>'
;
$lines
[]
=
'</rss>'
;
qa_db_disconnect
();
// Disconnect here, once all output is ready to go
// Output the XML - and we're done!
qa_db_disconnect
();
header
(
'Content-type: text/xml; charset=utf-8'
);
echo
implode
(
"
\n
"
,
$lines
);
// Output the XML - and we're done!
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
header
(
'Content-type: text/xml; charset=utf-8'
);
echo
implode
(
"
\n
"
,
$lines
);
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