@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | // You should have received a copy of the GNU Lesser General Public License |
17 | 17 | // along with BOINC. If not, see <http://www.gnu.org/licenses/>. |
18 | 18 | |
19 | -NOT FINISHED. DON'T USE |
|
19 | +NOT FINISHED.DON'T USE |
|
20 | 20 | |
21 | 21 | require 'openid.php'; |
22 | 22 | include_once("../inc/boinc_db.inc"); |
@@ -26,14 +26,14 @@ discard block |
||
26 | 26 | |
27 | 27 | function show_error($str) { |
28 | 28 | page_head("Can't create account"); |
29 | - echo "$str<br>\n"; |
|
29 | + echo "$str < br > \n"; |
|
30 | 30 | page_tail(); |
31 | 31 | exit(); |
32 | 32 | } |
33 | 33 | |
34 | 34 | try { |
35 | 35 | $openid = new LightOpenID; |
36 | - echo "<pre>"; |
|
36 | + echo " < pre > "; |
|
37 | 37 | if(!$openid->mode) { |
38 | 38 | if(isset($_POST['openid_identifier'])) { |
39 | 39 | $openid->identity = $_POST['openid_identifier']; |
@@ -27,7 +27,7 @@ |
||
27 | 27 | $subset = sanitize_tags(get_str("subset")); |
28 | 28 | $venue = sanitize_tags(get_str("venue", true)); |
29 | 29 | $columns = get_int("cols", true); |
30 | -$c = $columns?"&cols=$columns":""; |
|
30 | +$c = $columns ? "&cols=$columns" : ""; |
|
31 | 31 | check_subset($subset); |
32 | 32 | if ($action) { |
33 | 33 | check_tokens($user->authenticator); |
@@ -56,10 +56,10 @@ discard block |
||
56 | 56 | return file_exists("$d/stop_sched"); |
57 | 57 | } |
58 | 58 | |
59 | -function xml_error($num=-1, $msg=null, $file=null, $line=null) { |
|
59 | +function xml_error($num = -1, $msg = null, $file = null, $line = null) { |
|
60 | 60 | global $xml_outer_tag; |
61 | 61 | if (!$msg) { |
62 | - switch($num) { |
|
62 | + switch ($num) { |
|
63 | 63 | case -112: $msg = "Invalid XML"; break; |
64 | 64 | case -136: $msg = "Not found"; break; |
65 | 65 | case -137: $msg = "Name or email address is not unique"; break; |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | // If it's a single-tag element, and it's present, just return the tag |
106 | 106 | // |
107 | 107 | function parse_element($xml, $tag) { |
108 | - $closetag = "</" . substr($tag,1); |
|
108 | + $closetag = "</".substr($tag, 1); |
|
109 | 109 | $x = strstr($xml, $tag); |
110 | 110 | if ($x) { |
111 | 111 | if (strstr($tag, "/>")) return $tag; |
@@ -121,8 +121,8 @@ discard block |
||
121 | 121 | |
122 | 122 | function parse_next_element($xml, $tag, &$cursor) { |
123 | 123 | $element = null; |
124 | - $closetag = "</" . substr($tag,1); |
|
125 | - $pos = substr($xml,$cursor); |
|
124 | + $closetag = "</".substr($tag, 1); |
|
125 | + $pos = substr($xml, $cursor); |
|
126 | 126 | $x = strstr($pos, $tag); |
127 | 127 | if ($x) { |
128 | 128 | if (strstr($tag, "/>")) return $tag; |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | // whose OSs may have such restrictions. |
223 | 223 | // |
224 | 224 | function is_valid_filename($x) { |
225 | - if (strlen($x)>255) return false; |
|
225 | + if (strlen($x) > 255) return false; |
|
226 | 226 | // \w means A-Za-z0-9_ |
227 | 227 | return preg_match('/^[\w\-.]+$/', $x); |
228 | 228 | } |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | error_page("Forums are disabled"); |
44 | 44 | } |
45 | 45 | |
46 | -if (user_can_create_thread($logged_in_user, $forum)=='no') { |
|
46 | +if (user_can_create_thread($logged_in_user, $forum) == 'no') { |
|
47 | 47 | error_page(tra("Only project admins may create a thread here. However, you may reply to existing threads.")); |
48 | 48 | } |
49 | 49 | check_post_access($logged_in_user, $forum); |
@@ -56,10 +56,10 @@ discard block |
||
56 | 56 | $preview = post_str("preview", true); |
57 | 57 | $warning = null; |
58 | 58 | |
59 | -if ($content && $title && (!$preview)){ |
|
59 | +if ($content && $title && (!$preview)) { |
|
60 | 60 | if (post_str('add_signature', true)) { |
61 | - $add_signature = true; // set a flag and concatenate later |
|
62 | - } else { |
|
61 | + $add_signature = true; // set a flag and concatenate later |
|
62 | + } else { |
|
63 | 63 | $add_signature = false; |
64 | 64 | } |
65 | 65 | check_tokens($logged_in_user->authenticator); |
@@ -74,14 +74,14 @@ discard block |
||
74 | 74 | if (post_str('subscribe', true)) { |
75 | 75 | BoincSubscription::replace($logged_in_user->id, $thread->id); |
76 | 76 | } |
77 | - header('Location: forum_thread.php?id=' . $thread->id); |
|
77 | + header('Location: forum_thread.php?id='.$thread->id); |
|
78 | 78 | } else { |
79 | 79 | error_page("Can't create thread. $forum_error"); |
80 | 80 | } |
81 | 81 | } |
82 | 82 | } |
83 | 83 | |
84 | -page_head(tra("Create new thread"),'','','', $bbcode_js); |
|
84 | +page_head(tra("Create new thread"), '', '', '', $bbcode_js); |
|
85 | 85 | show_forum_header($logged_in_user); |
86 | 86 | |
87 | 87 | if ($warning) { |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | $submit_help = "<br /><font color=\"red\">".tra("Remember to add a title")."</font>"; |
123 | 123 | } |
124 | 124 | |
125 | -if ($force_title && $title){ |
|
125 | +if ($force_title && $title) { |
|
126 | 126 | row2( |
127 | 127 | tra("Title"), |
128 | 128 | sprintf( |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | row2( |
137 | 137 | tra("Title").$submit_help, |
138 | 138 | sprintf('<input type="text" class="form-control" name="title" value="%s">', |
139 | - $title?htmlspecialchars($title):'' |
|
139 | + $title ?htmlspecialchars($title) : '' |
|
140 | 140 | ), |
141 | 141 | null, FORUM_LH_PCT |
142 | 142 | ); |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | sprintf( |
148 | 148 | '%s <textarea class="form-control" name="content" rows="12" cols="80">%s</textarea>', |
149 | 149 | $bbcode_html, |
150 | - $content?htmlspecialchars($content):'' |
|
150 | + $content ?htmlspecialchars($content) : '' |
|
151 | 151 | ), |
152 | 152 | null, FORUM_LH_PCT |
153 | 153 | ); |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | if (!$logged_in_user->prefs->no_signature_by_default) { |
156 | 156 | $enable_signature = 'checked="true"'; |
157 | 157 | } else { |
158 | - $enable_signature=''; |
|
158 | + $enable_signature = ''; |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | if (is_news_forum($forum)) { |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | $user = BoincUser::lookup_id($userid); |
30 | 30 | if (!$user) error_page('no such user'); |
31 | 31 | $offset = get_int("offset", true); |
32 | -if (!$offset) $offset=0; |
|
32 | +if (!$offset) $offset = 0; |
|
33 | 33 | $items_per_page = 20; |
34 | 34 | |
35 | 35 | $logged_in_user = get_logged_in_user(false); |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | break; |
115 | 115 | } |
116 | 116 | if ($n >= $offset) { |
117 | - show_post_and_context($post, $thread, $forum, $options, $n+1); |
|
117 | + show_post_and_context($post, $thread, $forum, $options, $n + 1); |
|
118 | 118 | } |
119 | 119 | $n++; |
120 | 120 | } |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | |
38 | 38 | // See if "action" is provided - either through post or get |
39 | 39 | if (!post_str('action', true)) { |
40 | - if (!get_str('action', true)){ |
|
40 | + if (!get_str('action', true)) { |
|
41 | 41 | error_page(tra("You must specify an action...")); |
42 | 42 | } else { |
43 | 43 | $action = get_str('action'); |
@@ -47,10 +47,10 @@ discard block |
||
47 | 47 | } |
48 | 48 | |
49 | 49 | $userid = post_int('userid'); |
50 | -$user=BoincUser::lookup_id($userid); |
|
50 | +$user = BoincUser::lookup_id($userid); |
|
51 | 51 | if (!$user) error_page('No such user'); |
52 | 52 | |
53 | -if ($action!="start"){ |
|
53 | +if ($action != "start") { |
|
54 | 54 | error_page("Unknown action"); |
55 | 55 | } |
56 | 56 | |
@@ -66,10 +66,10 @@ discard block |
||
66 | 66 | $mod_category = tra("Other"); |
67 | 67 | } |
68 | 68 | |
69 | -if (post_str('reason', true)){ |
|
70 | - start_vote($config,$logged_in_user,$user, $mod_category,post_str("reason")); |
|
69 | +if (post_str('reason', true)) { |
|
70 | + start_vote($config, $logged_in_user, $user, $mod_category, post_str("reason")); |
|
71 | 71 | } else { |
72 | - start_vote($config,$logged_in_user,$user, $mod_category,"None given"); |
|
72 | + start_vote($config, $logged_in_user, $user, $mod_category, "None given"); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | ?> |
@@ -30,6 +30,6 @@ |
||
30 | 30 | if (!$thread) error_page('No such thread'); |
31 | 31 | $logged_in_user = get_logged_in_user(); |
32 | 32 | |
33 | -$posts = get_thread_posts($threadid, 0,true); |
|
33 | +$posts = get_thread_posts($threadid, 0, true); |
|
34 | 34 | header("Location: forum_rate.php?choice=p&post=".$posts[0]->id); |
35 | 35 | ?> |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | start_table(); |
51 | 51 | |
52 | 52 | $get_reason = true; |
53 | -if (get_str('action')=="hide") { |
|
53 | +if (get_str('action') == "hide") { |
|
54 | 54 | //display input that selects reason |
55 | 55 | echo "<input type=hidden name=action value=hide>"; |
56 | 56 | row1(tra("Hide post")); |
@@ -67,12 +67,12 @@ discard block |
||
67 | 67 | ) |
68 | 68 | ) |
69 | 69 | ); |
70 | -} elseif (get_str('action')=="move") { |
|
70 | +} elseif (get_str('action') == "move") { |
|
71 | 71 | row1(tra("Move post")); |
72 | 72 | echo "<input type=hidden name=action value=move>"; |
73 | 73 | row2(tra("Destination thread ID:"), "<input name=\"threadid\">"); |
74 | 74 | // TODO: display where to move the post as a dropdown instead of having to get ID |
75 | -} elseif (get_str('action')=="banish_user") { |
|
75 | +} elseif (get_str('action') == "banish_user") { |
|
76 | 76 | $userid = get_int('userid'); |
77 | 77 | $user = BoincUser::lookup_id($userid); |
78 | 78 | if (!$user) { |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | } |
81 | 81 | BoincForumPrefs::lookup($user); |
82 | 82 | $x = $user->prefs->banished_until; |
83 | - if ($x>time()) { |
|
83 | + if ($x > time()) { |
|
84 | 84 | error_page(tra("User is already banished")); |
85 | 85 | } |
86 | 86 | row1(tra("Banish user")); |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | echo "<input type=\"hidden\" name=\"id\" value=\"".$postid."\">\n"; |
99 | 99 | echo "<input type=\"hidden\" name=\"userid\" value=\"".$userid."\">\n"; |
100 | 100 | echo "<input type=\"hidden\" name=\"confirmed\" value=\"yes\">\n"; |
101 | -} elseif (get_str('action')=="delete") { |
|
101 | +} elseif (get_str('action') == "delete") { |
|
102 | 102 | echo "<input type=hidden name=action value=delete>"; |
103 | 103 | row2( |
104 | 104 | "Are you sure want to delete this post? This cannot be undone.", |
@@ -31,10 +31,10 @@ discard block |
||
31 | 31 | // Optionally filters by forum, user, time, or hidden if specified. |
32 | 32 | // |
33 | 33 | function search_thread_titles( |
34 | - $keyword_list, $forum="", $user="", $time="", $limit=200, |
|
35 | - $sort_style=CREATE_TIME_NEW, $show_hidden = false |
|
36 | -){ |
|
37 | - $search_string="%"; |
|
34 | + $keyword_list, $forum = "", $user = "", $time = "", $limit = 200, |
|
35 | + $sort_style = CREATE_TIME_NEW, $show_hidden = false |
|
36 | +) { |
|
37 | + $search_string = "%"; |
|
38 | 38 | foreach ($keyword_list as $key => $word) { |
39 | 39 | $search_string .= BoincDb::escape_string($word)."%"; |
40 | 40 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | if (!$show_hidden) { |
52 | 52 | $query .= " and thread.hidden = 0"; |
53 | 53 | } |
54 | - switch($sort_style) { |
|
54 | + switch ($sort_style) { |
|
55 | 55 | case MODIFIED_NEW: |
56 | 56 | $query .= ' ORDER BY timestamp DESC'; |
57 | 57 | break; |
@@ -84,11 +84,11 @@ discard block |
||
84 | 84 | // |
85 | 85 | function search_post_content( |
86 | 86 | $keyword_list, $forum, $user, $time, $limit, $sort_style, $show_hidden |
87 | -){ |
|
87 | +) { |
|
88 | 88 | $db = BoincDb::get(); |
89 | 89 | |
90 | - $search_string="%"; |
|
91 | - foreach ($keyword_list as $key => $word){ |
|
90 | + $search_string = "%"; |
|
91 | + foreach ($keyword_list as $key => $word) { |
|
92 | 92 | $search_string .= BoincDb::escape_string($word)."%"; |
93 | 93 | } |
94 | 94 | $optional_join = ""; |
@@ -100,20 +100,20 @@ discard block |
||
100 | 100 | } |
101 | 101 | $query = "select post.* from ".$db->db_name.".post".$optional_join." where content like '".$search_string."'"; |
102 | 102 | if ($forum) { |
103 | - $query.=" and forum = $forum->id"; |
|
103 | + $query .= " and forum = $forum->id"; |
|
104 | 104 | } |
105 | 105 | if ($user) { |
106 | - $query.=" and post.user = $user->id "; |
|
106 | + $query .= " and post.user = $user->id "; |
|
107 | 107 | } |
108 | 108 | if ($time) { |
109 | - $query.=" and post.timestamp > $time"; |
|
109 | + $query .= " and post.timestamp > $time"; |
|
110 | 110 | } |
111 | 111 | if (!$show_hidden) { |
112 | 112 | $query .= " AND post.hidden = 0"; |
113 | 113 | } |
114 | - switch($sort_style) { |
|
114 | + switch ($sort_style) { |
|
115 | 115 | case VIEWS_MOST: |
116 | - $query.= ' ORDER BY views DESC'; |
|
116 | + $query .= ' ORDER BY views DESC'; |
|
117 | 117 | break; |
118 | 118 | case CREATE_TIME_NEW: |
119 | 119 | $query .= ' ORDER by post.timestamp desc'; |
@@ -128,13 +128,13 @@ discard block |
||
128 | 128 | $query .= ' ORDER BY post.timestamp DESC'; |
129 | 129 | break; |
130 | 130 | } |
131 | - $query.= " limit $limit"; |
|
131 | + $query .= " limit $limit"; |
|
132 | 132 | return BoincPost::enum_general($query); |
133 | 133 | } |
134 | 134 | |
135 | 135 | $logged_in_user = get_logged_in_user(false); |
136 | 136 | BoincForumPrefs::lookup($logged_in_user); |
137 | -if ($logged_in_user && $logged_in_user->prefs->privilege(S_MODERATOR)){ |
|
137 | +if ($logged_in_user && $logged_in_user->prefs->privilege(S_MODERATOR)) { |
|
138 | 138 | $show_hidden_posts = true; |
139 | 139 | } else { |
140 | 140 | $show_hidden_posts = false; |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | $search_max_time = post_int("search_max_time"); |
148 | 148 | $search_forum = post_int("search_forum"); |
149 | 149 | $search_sort = post_int("search_sort"); |
150 | -$search_list = explode(" ",$search_keywords); |
|
150 | +$search_list = explode(" ", $search_keywords); |
|
151 | 151 | if ($search_max_time) { |
152 | 152 | $min_timestamp = time() - ($search_max_time*3600*24); |
153 | 153 | } else { |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | |
157 | 157 | $limit = 100; |
158 | 158 | |
159 | -if ($search_forum==-1){ |
|
159 | +if ($search_forum == -1) { |
|
160 | 160 | $forum = null; |
161 | 161 | } else if ($search_forum) { |
162 | 162 | $forum = BoincForum::lookup_id($search_forum); |
@@ -176,11 +176,11 @@ discard block |
||
176 | 176 | |
177 | 177 | // Display the threads |
178 | 178 | // |
179 | -if (count($threads)){ |
|
180 | - echo "<h3>" . tra("Thread titles matching your query:") . "</h3>"; |
|
179 | +if (count($threads)) { |
|
180 | + echo "<h3>".tra("Thread titles matching your query:")."</h3>"; |
|
181 | 181 | start_table('table-striped'); |
182 | 182 | thread_list_header(); |
183 | - foreach ($threads as $thread){ |
|
183 | + foreach ($threads as $thread) { |
|
184 | 184 | if (!$show_hidden_posts) { |
185 | 185 | $u = BoincUser::lookup_id($thread->owner); |
186 | 186 | if ($u && is_banished($u)) continue; |
@@ -200,8 +200,8 @@ discard block |
||
200 | 200 | $show_hidden_posts |
201 | 201 | ); |
202 | 202 | |
203 | -if (count($posts)){ |
|
204 | - echo "<h3>" . tra("Messages matching your query:") . "</h3>"; |
|
203 | +if (count($posts)) { |
|
204 | + echo "<h3>".tra("Messages matching your query:")."</h3>"; |
|
205 | 205 | start_table('table-striped'); |
206 | 206 | row_heading_array(['Info', 'Post'], ['', 'width=70%']); |
207 | 207 | $n = 1; |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | end_table(); |
229 | 229 | } |
230 | 230 | |
231 | -if (!count($threads) && !count($posts)){ |
|
231 | +if (!count($threads) && !count($posts)) { |
|
232 | 232 | echo "<p>".tra("Sorry, couldn't find anything matching your search query. You can try to broaden your search by using less words (or less specific words).")."</p> |
233 | 233 | <p>" |
234 | 234 | .tra("You can also %1 try the same search on Google. %2", |