@@ -28,13 +28,13 @@ |
||
| 28 | 28 | echo "---------------\n"; |
| 29 | 29 | $boincToken = BoincToken::lookup_valid_token(0, $token, 'T'); |
| 30 | 30 | if ( $boincToken != null ) { |
| 31 | - echo "Found valid token\n"; |
|
| 31 | + echo "Found valid token\n"; |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | echo "---------------\n"; |
| 35 | 35 | $boincToken = BoincToken::lookup_valid_token(0, 'notrealtoken', 'T'); |
| 36 | 36 | if ( $boincToken == null ) { |
| 37 | - echo "Successfully didn't find invalid token\n"; |
|
| 37 | + echo "Successfully didn't find invalid token\n"; |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | echo "---------------\n"; |
@@ -37,7 +37,7 @@ |
||
| 37 | 37 | ."</ul><br/>"; |
| 38 | 38 | |
| 39 | 39 | form_start(secure_url_base()."delete_account_request.php", "post"); |
| 40 | - form_input_text(tra("Password"), "passwd", "", "password",'id="passwd"',passwd_visible_checkbox("passwd")); |
|
| 40 | + form_input_text(tra("Password"), "passwd", "", "password", 'id="passwd"', passwd_visible_checkbox("passwd")); |
|
| 41 | 41 | form_submit(tra("Send Confirmation Email")); |
| 42 | 42 | form_end(); |
| 43 | 43 | |
@@ -25,6 +25,10 @@ discard block |
||
| 25 | 25 | // Constants for token durations |
| 26 | 26 | define("TOKEN_DURATION_ONE_DAY", 86400); |
| 27 | 27 | |
| 28 | +/** |
|
| 29 | + * @param string $type |
|
| 30 | + * @param integer $duration |
|
| 31 | + */ |
|
| 28 | 32 | function create_token($userid, $type, $duration) { |
| 29 | 33 | $token = random_string(); |
| 30 | 34 | $now = time(); |
@@ -37,6 +41,9 @@ discard block |
||
| 37 | 41 | return $token; |
| 38 | 42 | } |
| 39 | 43 | |
| 44 | +/** |
|
| 45 | + * @param string $type |
|
| 46 | + */ |
|
| 40 | 47 | function is_valid_token($userid, $token, $type) { |
| 41 | 48 | $boincToken = BoincToken::lookup_valid_token($userid, $token, $type); |
| 42 | 49 | if ( $boincToken == null ) { |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | |
| 26 | 26 | // send an email, using PHPMailer or not. |
| 27 | 27 | // |
| 28 | -function send_email($user, $subject, $body, $body_html=null) { |
|
| 28 | +function send_email($user, $subject, $body, $body_html = null) { |
|
| 29 | 29 | if (function_exists("make_php_mailer")) { |
| 30 | 30 | require_once("../inc/phpmailer/class.phpmailer.php"); |
| 31 | 31 | $mail = make_php_mailer(); |
@@ -44,11 +44,11 @@ discard block |
||
| 44 | 44 | return true; |
| 45 | 45 | } |
| 46 | 46 | } else { |
| 47 | - $headers =""; |
|
| 47 | + $headers = ""; |
|
| 48 | 48 | if (defined('EMAIL_FROM') && defined('EMAIL_FROM_NAME')) { |
| 49 | 49 | $headers = "From: ".EMAIL_FROM_NAME." <".EMAIL_FROM.">"; |
| 50 | 50 | } else if (defined('EMAIL_FROM')) { |
| 51 | - $headers = "From: ". EMAIL_FROM; |
|
| 51 | + $headers = "From: ".EMAIL_FROM; |
|
| 52 | 52 | } |
| 53 | 53 | return mail($user->email_addr, $subject, $body, $headers); |
| 54 | 54 | } |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | if (defined("USE_STOPFORUMSPAM") && USE_STOPFORUMSPAM && array_key_exists('REMOTE_ADDR', $_SERVER)) { |
| 97 | 97 | $ip = $_SERVER['REMOTE_ADDR']; |
| 98 | 98 | // For obviously private IPs check just the email against SFS, otherwise check both IP and email |
| 99 | - if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE)) { |
|
| 99 | + if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE|FILTER_FLAG_NO_RES_RANGE)) { |
|
| 100 | 100 | $x = @file_get_contents("https://www.stopforumspam.com/api?ip=".$ip."&email=".$addr); |
| 101 | 101 | } else { |
| 102 | 102 | $x = @file_get_contents("https://www.stopforumspam.com/api?email=".$addr); |
@@ -107,12 +107,12 @@ discard block |
||
| 107 | 107 | } |
| 108 | 108 | $pattern = '/^([^@]+)@([^@\.]+)\.([^@]{2,})$/'; |
| 109 | 109 | $match = preg_match($pattern, $addr); |
| 110 | - return (bool) $match; |
|
| 110 | + return (bool)$match; |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | function send_confirm_delete_email($user) { |
| 114 | 114 | $token = create_token($user->id, TOKEN_TYPE_DELETE_ACCOUNT, TOKEN_DURATION_ONE_DAY); |
| 115 | - if ( $token == null ) { |
|
| 115 | + if ($token == null) { |
|
| 116 | 116 | error_page("Error creating token. Please try again later."); |
| 117 | 117 | } |
| 118 | 118 | |
@@ -32,9 +32,9 @@ |
||
| 32 | 32 | page_head(tra("Delete Account")); |
| 33 | 33 | |
| 34 | 34 | echo "<p>".tra("Thank you for verifying ownership of your account.")."</p>" |
| 35 | - ."<p>".tra("You can now delete your account by entering in your password below and clicking the \"Delete Account\" button.")."</p>" |
|
| 36 | - ."<p>".tra("As a reminder, your account <b>cannot be recovered</b> once you delete it.")."</p>" |
|
| 37 | - ."<br/>"; |
|
| 35 | + ."<p>".tra("You can now delete your account by entering in your password below and clicking the \"Delete Account\" button.")."</p>" |
|
| 36 | + ."<p>".tra("As a reminder, your account <b>cannot be recovered</b> once you delete it.")."</p>" |
|
| 37 | + ."<br/>"; |
|
| 38 | 38 | |
| 39 | 39 | form_start(secure_url_base()."delete_account_confirm.php", "post"); |
| 40 | 40 | form_input_hidden("token",$token); |
@@ -37,9 +37,9 @@ discard block |
||
| 37 | 37 | ."<br/>"; |
| 38 | 38 | |
| 39 | 39 | form_start(secure_url_base()."delete_account_confirm.php", "post"); |
| 40 | - form_input_hidden("token",$token); |
|
| 41 | - form_input_hidden("id",$userid); |
|
| 42 | - form_input_text(tra("Password"), "passwd", "", "password",'id="passwd"',passwd_visible_checkbox("passwd")); |
|
| 40 | + form_input_hidden("token", $token); |
|
| 41 | + form_input_hidden("id", $userid); |
|
| 42 | + form_input_text(tra("Password"), "passwd", "", "password", 'id="passwd"', passwd_visible_checkbox("passwd")); |
|
| 43 | 43 | form_submit(tra("Delete Account")); |
| 44 | 44 | form_end(); |
| 45 | 45 | |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | $passwd = post_str("passwd"); |
| 58 | 58 | check_passwd_ui($user, $passwd); |
| 59 | 59 | |
| 60 | - if ( !delete_account($user) ) { |
|
| 60 | + if (!delete_account($user)) { |
|
| 61 | 61 | error_page( |
| 62 | 62 | tra("Failed to delete your account. Please contact the project administrator.") |
| 63 | 63 | ); |
@@ -33,13 +33,13 @@ discard block |
||
| 33 | 33 | // they've participated in |
| 34 | 34 | // |
| 35 | 35 | function get_other_projects($user) { |
| 36 | - $cpid = md5($user->cross_project_id . $user->email_addr); |
|
| 36 | + $cpid = md5($user->cross_project_id.$user->email_addr); |
|
| 37 | 37 | $url = "http://boinc.netsoft-online.com/get_user.php?cpid=".$cpid; |
| 38 | 38 | |
| 39 | 39 | // Check the cache for that URL |
| 40 | 40 | // |
| 41 | 41 | $cacheddata = get_cached_data(REMOTE_PROJECTS_TTL, $url); |
| 42 | - if ($cacheddata){ |
|
| 42 | + if ($cacheddata) { |
|
| 43 | 43 | $remote = unserialize($cacheddata); |
| 44 | 44 | } else { |
| 45 | 45 | // Fetch the XML, use curl if fopen() is disallowed |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | |
| 111 | 111 | function cmp($a, $b) { |
| 112 | 112 | if ($a->expavg_credit == $b->expavg_credit) return 0; |
| 113 | - return ($a->expavg_credit < $b->expavg_credit)? 1 : -1; |
|
| 113 | + return ($a->expavg_credit < $b->expavg_credit) ? 1 : -1; |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | function show_other_projects($user, $personal) { |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | ), |
| 134 | 134 | array("", ALIGN_RIGHT, ALIGN_RIGHT, ALIGN_RIGHT) |
| 135 | 135 | ); |
| 136 | - foreach($user->projects as $project) { |
|
| 136 | + foreach ($user->projects as $project) { |
|
| 137 | 137 | show_project($project); |
| 138 | 138 | } |
| 139 | 139 | end_table(); |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | if (!NO_STATS) { |
| 177 | - $cpid = md5($user->cross_project_id . $user->email_addr); |
|
| 177 | + $cpid = md5($user->cross_project_id.$user->email_addr); |
|
| 178 | 178 | $x = ""; |
| 179 | 179 | shuffle($cpid_stats_sites); |
| 180 | 180 | foreach ($cpid_stats_sites as $site) { |
@@ -262,7 +262,7 @@ discard block |
||
| 262 | 262 | } else { |
| 263 | 263 | $delete_account_str = ""; |
| 264 | 264 | $config = get_config(); |
| 265 | - if ( parse_bool($config, "enable_delete_account") ) { |
|
| 265 | + if (parse_bool($config, "enable_delete_account")) { |
|
| 266 | 266 | $delete_account_str = " · <a href=\"delete_account_request.php\">".tra("delete account")."</a>"; |
| 267 | 267 | } |
| 268 | 268 | |
@@ -327,7 +327,7 @@ discard block |
||
| 327 | 327 | // show user name, with links to profile if present. |
| 328 | 328 | // if $badge_height is > 0, show badges |
| 329 | 329 | // |
| 330 | -function user_links($user, $badge_height=0) { |
|
| 330 | +function user_links($user, $badge_height = 0) { |
|
| 331 | 331 | BoincForumPrefs::lookup($user); |
| 332 | 332 | if (is_banished($user)) { |
| 333 | 333 | return "(banished: ID $user->id)"; |
@@ -338,7 +338,7 @@ discard block |
||
| 338 | 338 | $x .= ' <a href="'.url_base().'view_profile.php?userid='.$user->id.'"><img title="View the profile of '.$user->name.'" src="'.$img_url.'" alt="Profile"></a>'; |
| 339 | 339 | } |
| 340 | 340 | $x .= " <a href=\"".url_base()."show_user.php?userid=".$user->id."\">".$user->name."</a>"; |
| 341 | - if (function_exists("project_user_links")){ |
|
| 341 | + if (function_exists("project_user_links")) { |
|
| 342 | 342 | $x .= project_user_links($user); |
| 343 | 343 | } |
| 344 | 344 | if ($badge_height) { |
@@ -391,7 +391,7 @@ discard block |
||
| 391 | 391 | |
| 392 | 392 | // if there's a foundership request, notify the founder |
| 393 | 393 | // |
| 394 | - if ($user->id==$team->userid && $team->ping_user >0) { |
|
| 394 | + if ($user->id == $team->userid && $team->ping_user > 0) { |
|
| 395 | 395 | $x .= "<p class=\"text-danger\">".tra("(foundership change request pending)")."</p>"; |
| 396 | 396 | } |
| 397 | 397 | row2(tra("Member of team"), $x); |
@@ -416,7 +416,7 @@ discard block |
||
| 416 | 416 | $x = "<a href=\"user_search.php\">".tra("Find friends")."</a><br/>\n"; |
| 417 | 417 | $n = count($friends); |
| 418 | 418 | if ($n) { |
| 419 | - foreach($friends as $friend) { |
|
| 419 | + foreach ($friends as $friend) { |
|
| 420 | 420 | $fuser = BoincUser::lookup_id($friend->user_dest); |
| 421 | 421 | if (!$fuser) continue; |
| 422 | 422 | $x .= friend_links($fuser); |
@@ -459,7 +459,7 @@ discard block |
||
| 459 | 459 | // Returns a cacheable community links data object |
| 460 | 460 | // @param user The user to produce a community links object for |
| 461 | 461 | |
| 462 | -function get_community_links_object($user){ |
|
| 462 | +function get_community_links_object($user) { |
|
| 463 | 463 | $cache_object = new StdClass; |
| 464 | 464 | $cache_object->post_count = total_posts($user); |
| 465 | 465 | $cache_object->user = $user; |
@@ -467,7 +467,7 @@ discard block |
||
| 467 | 467 | $cache_object->friends = array(); |
| 468 | 468 | |
| 469 | 469 | $friends = BoincFriend::enum("user_src=$user->id and reciprocated=1"); |
| 470 | - foreach($friends as $friend) { |
|
| 470 | + foreach ($friends as $friend) { |
|
| 471 | 471 | $fuser = BoincUser::lookup_id($friend->user_dest); |
| 472 | 472 | if (!$fuser) continue; |
| 473 | 473 | $cache_object->friends[] = $fuser; |
@@ -475,7 +475,7 @@ discard block |
||
| 475 | 475 | return $cache_object; |
| 476 | 476 | } |
| 477 | 477 | |
| 478 | -function community_links($clo, $logged_in_user){ |
|
| 478 | +function community_links($clo, $logged_in_user) { |
|
| 479 | 479 | $user = $clo->user; |
| 480 | 480 | $team = $clo->team; |
| 481 | 481 | $friends = $clo->friends; |
@@ -501,15 +501,15 @@ discard block |
||
| 501 | 501 | "<a href=\"friend.php?action=cancel_confirm&userid=$user->id\">".tra("Cancel friendship")."</a>" |
| 502 | 502 | ); |
| 503 | 503 | } else if ($friend) { |
| 504 | - row2(tra("Friends"), "<a href=\"friend.php?action=add&userid=$user->id\">".tra("Request pending")."</a>"); |
|
| 504 | + row2(tra("Friends"), "<a href=\"friend.php?action=add&userid=$user->id\">".tra("Request pending")."</a>"); |
|
| 505 | 505 | } else { |
| 506 | - row2(tra("Friends"), "<a href=\"friend.php?action=add&userid=$user->id\">".tra("Add as friend")."</a>"); |
|
| 506 | + row2(tra("Friends"), "<a href=\"friend.php?action=add&userid=$user->id\">".tra("Add as friend")."</a>"); |
|
| 507 | 507 | } |
| 508 | 508 | } |
| 509 | 509 | |
| 510 | 510 | if ($friends) { |
| 511 | 511 | $x = ""; |
| 512 | - foreach($friends as $friend) { |
|
| 512 | + foreach ($friends as $friend) { |
|
| 513 | 513 | $x .= friend_links($friend); |
| 514 | 514 | } |
| 515 | 515 | row2(tra("Friends")." (".sizeof($friends).")", $x); |
@@ -554,6 +554,6 @@ discard block |
||
| 554 | 554 | } |
| 555 | 555 | |
| 556 | 556 | |
| 557 | -$cvs_version_tracker[]="\$Id$"; //Generated automatically - do not edit |
|
| 557 | +$cvs_version_tracker[] = "\$Id$"; //Generated automatically - do not edit |
|
| 558 | 558 | |
| 559 | 559 | ?> |
@@ -40,6 +40,10 @@ discard block |
||
| 40 | 40 | // 2: only use replica_db_user, only try replica_db_host |
| 41 | 41 | // can be set projectwide using <replica_fallback_mode> |
| 42 | 42 | // |
| 43 | + |
|
| 44 | + /** |
|
| 45 | + * @param boolean $readonly |
|
| 46 | + */ |
|
| 43 | 47 | static function get_aux($readonly, $fallback_mode = 0) { |
| 44 | 48 | $config = get_config(); |
| 45 | 49 | $user = parse_config($config, '<db_user>'); |
@@ -196,6 +200,10 @@ discard block |
||
| 196 | 200 | $db = BoincDb::get(); |
| 197 | 201 | return $db->count('user', $clause); |
| 198 | 202 | } |
| 203 | + |
|
| 204 | + /** |
|
| 205 | + * @param string $field |
|
| 206 | + */ |
|
| 199 | 207 | static function max($field) { |
| 200 | 208 | $db = BoincDb::get(); |
| 201 | 209 | return $db->max('user', $field); |
@@ -208,6 +216,10 @@ discard block |
||
| 208 | 216 | $db = BoincDb::get(); |
| 209 | 217 | return $db->enum('user', 'BoincUser', $where_clause, $order_clause); |
| 210 | 218 | } |
| 219 | + |
|
| 220 | + /** |
|
| 221 | + * @param string $fields |
|
| 222 | + */ |
|
| 211 | 223 | static function enum_fields($fields, $where_clause, $order_clause=null) { |
| 212 | 224 | $db = BoincDb::get(); |
| 213 | 225 | return $db->enum_fields( |
@@ -225,10 +237,19 @@ discard block |
||
| 225 | 237 | $db->delete_aux('profile', "userid=$this->id"); |
| 226 | 238 | return $db->delete($this, 'user'); |
| 227 | 239 | } |
| 240 | + |
|
| 241 | + /** |
|
| 242 | + * @param string $field |
|
| 243 | + */ |
|
| 228 | 244 | static function sum($field) { |
| 229 | 245 | $db = BoincDb::get(); |
| 230 | 246 | return $db->sum('user', $field); |
| 231 | 247 | } |
| 248 | + |
|
| 249 | + /** |
|
| 250 | + * @param string $field |
|
| 251 | + * @param string $clause |
|
| 252 | + */ |
|
| 232 | 253 | static function percentile($field, $clause, $pct) { |
| 233 | 254 | $db = BoincDb::get(); |
| 234 | 255 | return $db->percentile('user', $field, $clause, $pct); |
@@ -237,6 +258,10 @@ discard block |
||
| 237 | 258 | |
| 238 | 259 | class BoincTeam { |
| 239 | 260 | static $cache; |
| 261 | + |
|
| 262 | + /** |
|
| 263 | + * @param string $clause |
|
| 264 | + */ |
|
| 240 | 265 | static function insert($clause) { |
| 241 | 266 | $db = BoincDb::get(); |
| 242 | 267 | $ret = $db->insert('team', $clause); |
@@ -274,14 +299,27 @@ discard block |
||
| 274 | 299 | $db = BoincDb::get(); |
| 275 | 300 | return $db->delete($this, 'team'); |
| 276 | 301 | } |
| 302 | + |
|
| 303 | + /** |
|
| 304 | + * @param string $field |
|
| 305 | + * @param string $clause |
|
| 306 | + */ |
|
| 277 | 307 | static function percentile($field, $clause, $pct) { |
| 278 | 308 | $db = BoincDb::get(); |
| 279 | 309 | return $db->percentile('team', $field, $clause, $pct); |
| 280 | 310 | } |
| 311 | + |
|
| 312 | + /** |
|
| 313 | + * @param string $field |
|
| 314 | + */ |
|
| 281 | 315 | static function max($field) { |
| 282 | 316 | $db = BoincDb::get(); |
| 283 | 317 | return $db->max('team', $field); |
| 284 | 318 | } |
| 319 | + |
|
| 320 | + /** |
|
| 321 | + * @param string $fields |
|
| 322 | + */ |
|
| 285 | 323 | static function enum_fields($fields, $where_clause, $order_clause=null) { |
| 286 | 324 | $db = BoincDb::get(); |
| 287 | 325 | return $db->enum_fields( |
@@ -322,6 +360,12 @@ discard block |
||
| 322 | 360 | $db = BoincDb::get(); |
| 323 | 361 | return $db->enum('host', 'BoincHost', $where_clause, $order_clause); |
| 324 | 362 | } |
| 363 | + |
|
| 364 | + /** |
|
| 365 | + * @param string $fields |
|
| 366 | + * @param string $where_clause |
|
| 367 | + * @param string $order_clause |
|
| 368 | + */ |
|
| 325 | 369 | static function enum_fields($fields, $where_clause, $order_clause=null) { |
| 326 | 370 | $db = BoincDb::get(); |
| 327 | 371 | return $db->enum_fields( |
@@ -358,6 +402,11 @@ discard block |
||
| 358 | 402 | $db = BoincDb::get(); |
| 359 | 403 | return $db->enum('result', 'BoincResult', $where_clause); |
| 360 | 404 | } |
| 405 | + |
|
| 406 | + /** |
|
| 407 | + * @param string $fields |
|
| 408 | + * @param string $where_clause |
|
| 409 | + */ |
|
| 361 | 410 | static function enum_fields($fields, $where_clause, $order_clause) { |
| 362 | 411 | $db = BoincDb::get(); |
| 363 | 412 | return $db->enum_fields('result', 'BoincResult', $fields, $where_clause, $order_clause); |
@@ -412,6 +461,10 @@ discard block |
||
| 412 | 461 | $db = BoincDb::get(); |
| 413 | 462 | return $db->update_aux('workunit', $clause); |
| 414 | 463 | } |
| 464 | + |
|
| 465 | + /** |
|
| 466 | + * @param string $clause |
|
| 467 | + */ |
|
| 415 | 468 | static function count($clause) { |
| 416 | 469 | $db = BoincDb::get(); |
| 417 | 470 | return $db->count('workunit', $clause); |
@@ -427,6 +480,10 @@ discard block |
||
| 427 | 480 | $db = BoincDb::get(); |
| 428 | 481 | return $db->lookup('app', 'BoincApp', $clause); |
| 429 | 482 | } |
| 483 | + |
|
| 484 | + /** |
|
| 485 | + * @param string $where_clause |
|
| 486 | + */ |
|
| 430 | 487 | static function enum($where_clause) { |
| 431 | 488 | $db = BoincDb::get(); |
| 432 | 489 | return $db->enum('app', 'BoincApp', $where_clause); |
@@ -441,6 +498,11 @@ discard block |
||
| 441 | 498 | $db = BoincDb::get(); |
| 442 | 499 | return $db->update($this, 'app', $clause); |
| 443 | 500 | } |
| 501 | + |
|
| 502 | + /** |
|
| 503 | + * @param string $field |
|
| 504 | + * @param string $clause |
|
| 505 | + */ |
|
| 444 | 506 | static function sum($field, $clause=null) { |
| 445 | 507 | $db = BoincDb::get(); |
| 446 | 508 | return $db->sum('app', $field, $clause); |
@@ -473,6 +535,10 @@ discard block |
||
| 473 | 535 | } |
| 474 | 536 | |
| 475 | 537 | class BoincProfile { |
| 538 | + |
|
| 539 | + /** |
|
| 540 | + * @param string $fields |
|
| 541 | + */ |
|
| 476 | 542 | static function lookup_fields($fields, $clause) { |
| 477 | 543 | $db = BoincDb::get(); |
| 478 | 544 | return $db->lookup_fields('profile', 'BoincProfile', $fields, $clause); |
@@ -489,18 +555,37 @@ discard block |
||
| 489 | 555 | $db = BoincDb::get(); |
| 490 | 556 | return $db->update_aux('profile', $clause.' where userid='.$this->userid); |
| 491 | 557 | } |
| 558 | + |
|
| 559 | + /** |
|
| 560 | + * @param string $clause |
|
| 561 | + */ |
|
| 492 | 562 | static function update_aux($clause) { |
| 493 | 563 | $db = BoincDb::get(); |
| 494 | 564 | return $db->update_aux('profile', $clause); |
| 495 | 565 | } |
| 566 | + |
|
| 567 | + /** |
|
| 568 | + * @param string $clause |
|
| 569 | + */ |
|
| 496 | 570 | static function insert($clause) { |
| 497 | 571 | $db = BoincDb::get(); |
| 498 | 572 | return $db->insert('profile', $clause); |
| 499 | 573 | } |
| 574 | + |
|
| 575 | + /** |
|
| 576 | + * @param string $where_clause |
|
| 577 | + * @param string $order_clause |
|
| 578 | + */ |
|
| 500 | 579 | static function enum($where_clause=null, $order_clause=null) { |
| 501 | 580 | $db = BoincDb::get(); |
| 502 | 581 | return $db->enum('profile', 'BoincProfile', $where_clause, $order_clause); |
| 503 | 582 | } |
| 583 | + |
|
| 584 | + /** |
|
| 585 | + * @param string $fields |
|
| 586 | + * @param string $where_clause |
|
| 587 | + * @param string $order_clause |
|
| 588 | + */ |
|
| 504 | 589 | static function enum_fields($fields, $where_clause=null, $order_clause=null) { |
| 505 | 590 | $db = BoincDb::get(); |
| 506 | 591 | return $db->enum_fields('profile', 'BoincProfile', $fields, $where_clause, $order_clause); |
@@ -561,6 +646,10 @@ discard block |
||
| 561 | 646 | $db = BoincDb::get(); |
| 562 | 647 | return $db->delete($this, 'private_messages'); |
| 563 | 648 | } |
| 649 | + |
|
| 650 | + /** |
|
| 651 | + * @param string $clause |
|
| 652 | + */ |
|
| 564 | 653 | static function delete_aux($clause) { |
| 565 | 654 | $db = BoincDb::get(); |
| 566 | 655 | return $db->delete_aux('private_messages', $clause); |
@@ -568,6 +657,10 @@ discard block |
||
| 568 | 657 | } |
| 569 | 658 | |
| 570 | 659 | class BoincPlatform { |
| 660 | + |
|
| 661 | + /** |
|
| 662 | + * @param string $where_clause |
|
| 663 | + */ |
|
| 571 | 664 | static function enum($where_clause) { |
| 572 | 665 | $db = BoincDb::get(); |
| 573 | 666 | return $db->enum('platform', 'BoincPlatform', $where_clause); |
@@ -652,6 +745,10 @@ discard block |
||
| 652 | 745 | } |
| 653 | 746 | |
| 654 | 747 | class BoincBadge { |
| 748 | + |
|
| 749 | + /** |
|
| 750 | + * @param string $where_clause |
|
| 751 | + */ |
|
| 655 | 752 | static function enum($where_clause) { |
| 656 | 753 | $db = BoincDb::get(); |
| 657 | 754 | return $db->enum('badge', 'BoincBadge', $where_clause); |
@@ -747,6 +844,11 @@ discard block |
||
| 747 | 844 | $db = BoincDb::get(); |
| 748 | 845 | return $db->enum('credit_user', 'BoincCreditUser', $where_clause); |
| 749 | 846 | } |
| 847 | + |
|
| 848 | + /** |
|
| 849 | + * @param string $field |
|
| 850 | + * @param string $clause |
|
| 851 | + */ |
|
| 750 | 852 | static function sum($field, $clause) { |
| 751 | 853 | $db = BoincDb::get(); |
| 752 | 854 | return $db->sum('credit_user', $field, $clause); |
@@ -759,6 +861,11 @@ discard block |
||
| 759 | 861 | $db = BoincDb::get(); |
| 760 | 862 | $db->delete_aux('credit_user', "userid=$user->id"); |
| 761 | 863 | } |
| 864 | + |
|
| 865 | + /** |
|
| 866 | + * @param string $order_clause |
|
| 867 | + * @param string $limit |
|
| 868 | + */ |
|
| 762 | 869 | static function get_list($where_clause, $order_clause, $limit) { |
| 763 | 870 | $db = BoincDB::get(); |
| 764 | 871 | return $db->get_list('user', 'credit_user', 'id', 'userid', 'BoincCreditUser', '*', $where_clause, $order_clause, $limit); |
@@ -774,6 +881,11 @@ discard block |
||
| 774 | 881 | $db = BoincDb::get(); |
| 775 | 882 | return $db->enum('credit_team', 'BoincCreditTeam', $where_clause); |
| 776 | 883 | } |
| 884 | + |
|
| 885 | + /** |
|
| 886 | + * @param string $field |
|
| 887 | + * @param string $clause |
|
| 888 | + */ |
|
| 777 | 889 | static function sum($field, $clause) { |
| 778 | 890 | $db = BoincDb::get(); |
| 779 | 891 | return $db->sum('credit_team', $field, $clause); |
@@ -782,6 +894,11 @@ discard block |
||
| 782 | 894 | $db = BoincDb::get(); |
| 783 | 895 | return $db->update_aux('credit_team', $clause); |
| 784 | 896 | } |
| 897 | + |
|
| 898 | + /** |
|
| 899 | + * @param string $order_clause |
|
| 900 | + * @param string $limit |
|
| 901 | + */ |
|
| 785 | 902 | static function get_list($where_clause, $order_clause, $limit) { |
| 786 | 903 | $db = BoincDB::get(); |
| 787 | 904 | return $db->get_list('team', 'credit_team', 'id', 'teamid', 'BoincCreditTeam', '*', $where_clause, $order_clause, $limit); |
@@ -876,6 +993,11 @@ discard block |
||
| 876 | 993 | // |
| 877 | 994 | // apply this to any user-supplied strings used in queries |
| 878 | 995 | // |
| 996 | +/** |
|
| 997 | + * @param string $x |
|
| 998 | + * |
|
| 999 | + * @return string |
|
| 1000 | + */ |
|
| 879 | 1001 | function boinc_real_escape_string($x) { |
| 880 | 1002 | if (version_compare(phpversion(),"4.3.0")>=0) { |
| 881 | 1003 | return BoincDb::escape_string($x); |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | function check_passwd_ui($user, $passwd) { |
| 58 | - if( !check_passwd($user, $passwd) ) { |
|
| 58 | + if (!check_passwd($user, $passwd)) { |
|
| 59 | 59 | sleep(LOGIN_FAIL_SLEEP_SEC); |
| 60 | 60 | page_head("Password incorrect"); |
| 61 | 61 | echo "The password you entered is incorrect. Please go back and try again.\n"; |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | function is_banned_email_addr($email_addr) { |
| 67 | 67 | global $banned_email_domains; |
| 68 | 68 | if (isset($banned_email_domains)) { |
| 69 | - foreach($banned_email_domains as $d) { |
|
| 69 | + foreach ($banned_email_domains as $d) { |
|
| 70 | 70 | $x = strstr($email_addr, $d); |
| 71 | 71 | if ($x == $d) return true; |
| 72 | 72 | } |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | // |
| 95 | 95 | function make_user( |
| 96 | 96 | $email_addr, $name, $passwd_hash, |
| 97 | - $country=null, $postal_code=null, $project_prefs=null, $teamid=0 |
|
| 97 | + $country = null, $postal_code = null, $project_prefs = null, $teamid = 0 |
|
| 98 | 98 | ) { |
| 99 | 99 | if (!is_valid_email_addr($email_addr)) return null; |
| 100 | 100 | if (is_banned_email_addr($email_addr)) return null; |
@@ -222,7 +222,7 @@ discard block |
||
| 222 | 222 | show_error(tra("Passwords may only include ASCII characters.")); |
| 223 | 223 | } |
| 224 | 224 | |
| 225 | - if (strlen($passwd)<$min_passwd_length) { |
|
| 225 | + if (strlen($passwd) < $min_passwd_length) { |
|
| 226 | 226 | show_error( |
| 227 | 227 | tra("New password is too short: minimum password length is %1 characters.", $min_passwd_length) |
| 228 | 228 | ); |
@@ -32,14 +32,14 @@ discard block |
||
| 32 | 32 | define("DELETE_ACCOUNT_METHOD_PROJECT_DEFINED", 3); |
| 33 | 33 | |
| 34 | 34 | $config = get_config(); |
| 35 | -if ( !parse_bool($config, "enable_delete_account") ) { |
|
| 35 | +if (!parse_bool($config, "enable_delete_account")) { |
|
| 36 | 36 | error_page( |
| 37 | 37 | tra("This feature is disabled. Please contact the project administrator.") |
| 38 | 38 | ); |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | function check_delete_account_token($userid, $token) { |
| 42 | - if( !is_valid_token($userid, $token, TOKEN_TYPE_DELETE_ACCOUNT) ) { |
|
| 42 | + if (!is_valid_token($userid, $token, TOKEN_TYPE_DELETE_ACCOUNT)) { |
|
| 43 | 43 | sleep(LOGIN_FAIL_SLEEP_SEC); |
| 44 | 44 | error_page( |
| 45 | 45 | tra("The token you used has expired or is otherwise not valid. Please request a new one <a href=\"delete_account_request.php\">here</a>") |
@@ -65,11 +65,11 @@ discard block |
||
| 65 | 65 | function delete_account($user) { |
| 66 | 66 | $config = get_config(); |
| 67 | 67 | $enable_delete_account = parse_config($config, "<enable_delete_account>"); |
| 68 | - if ( $enable_delete_account == DELETE_ACCOUNT_METHOD_OBFUSCATE ) { |
|
| 68 | + if ($enable_delete_account == DELETE_ACCOUNT_METHOD_OBFUSCATE) { |
|
| 69 | 69 | return obfuscate_account($user); |
| 70 | - } else if ( $enable_delete_account == DELETE_ACCOUNT_METHOD_WIPE ) { |
|
| 70 | + } else if ($enable_delete_account == DELETE_ACCOUNT_METHOD_WIPE) { |
|
| 71 | 71 | return wipe_account($user); |
| 72 | - } else if ( $enable_delete_account == DELETE_ACCOUNT_METHOD_PROJECT_DEFINED ) { |
|
| 72 | + } else if ($enable_delete_account == DELETE_ACCOUNT_METHOD_PROJECT_DEFINED) { |
|
| 73 | 73 | return project_delete_account($user); |
| 74 | 74 | } else { |
| 75 | 75 | error_page( |
@@ -109,11 +109,11 @@ discard block |
||
| 109 | 109 | insert_deleted_records($user); |
| 110 | 110 | |
| 111 | 111 | // delete remote submit user |
| 112 | - delete_remote_submit_user($user); // from submit_util.inc |
|
| 112 | + delete_remote_submit_user($user); // from submit_util.inc |
|
| 113 | 113 | |
| 114 | 114 | // remove user's team records |
| 115 | - user_erase_team_owner($user); // from team.inc |
|
| 116 | - user_quit_team($user); // from team.inc |
|
| 115 | + user_erase_team_owner($user); // from team.inc |
|
| 116 | + user_quit_team($user); // from team.inc |
|
| 117 | 117 | user_erase_team_delta($user); // from team.inc |
| 118 | 118 | |
| 119 | 119 | // Items that do not have logic elsewhere |
@@ -136,6 +136,6 @@ discard block |
||
| 136 | 136 | BoincHost::delete_for_user($user->id); |
| 137 | 137 | |
| 138 | 138 | // final action |
| 139 | - delete_user($user); //from user_util.inc |
|
| 139 | + delete_user($user); //from user_util.inc |
|
| 140 | 140 | return true; |
| 141 | 141 | } |
| 142 | 142 | \ No newline at end of file |