@@ -45,7 +45,7 @@ function check_cookie()
4545 $ select_check_cookie = array ('u.* ' , 'g.* ' , 'o.logged ' , 'o.idle ' );
4646 $ where_check_cookie = array ('u.id ' => intval ($ cookie ['user_id ' ]));
4747
48- $ result = ORM ::for_table ('users ' )
48+ $ result = \ DB ::for_table ('users ' )
4949 ->table_alias ('u ' )
5050 ->select_many ($ select_check_cookie )
5151 ->inner_join ('groups ' , array ('u.group_id ' , '= ' , 'g.g_id ' ), 'g ' )
@@ -114,11 +114,11 @@ function set_preferences()
114114 case 'mysqli_innodb ' :
115115 case 'sqlite ' :
116116 case 'sqlite3 ' :
117- \ORM ::for_table ('online ' )->raw_execute ('REPLACE INTO ' .$ feather ->prefix .'online (user_id, ident, logged) VALUES(:user_id, :ident, :logged) ' , array (':user_id ' => $ feather ->user ->id , ':ident ' => $ feather ->user ->username , ':logged ' => $ feather ->user ->logged ));
117+ \DB ::for_table ('online ' )->raw_execute ('REPLACE INTO ' .$ feather ->prefix .'online (user_id, ident, logged) VALUES(:user_id, :ident, :logged) ' , array (':user_id ' => $ feather ->user ->id , ':ident ' => $ feather ->user ->username , ':logged ' => $ feather ->user ->logged ));
118118 break ;
119119
120120 default :
121- \ORM ::for_table ('online ' )->raw_execute ('INSERT INTO ' .$ feather ->prefix .'online (user_id, ident, logged) SELECT :user_id, :ident, :logged WHERE NOT EXISTS (SELECT 1 FROM ' .$ feather ->prefix .'online WHERE user_id=:user_id) ' , array (':user_id ' => $ feather ->user ->id , ':ident ' => $ feather ->user ->username , ':logged ' => $ feather ->user ->logged ));
121+ \DB ::for_table ('online ' )->raw_execute ('INSERT INTO ' .$ feather ->prefix .'online (user_id, ident, logged) SELECT :user_id, :ident, :logged WHERE NOT EXISTS (SELECT 1 FROM ' .$ feather ->prefix .'online WHERE user_id=:user_id) ' , array (':user_id ' => $ feather ->user ->id , ':ident ' => $ feather ->user ->username , ':logged ' => $ feather ->user ->logged ));
122122 break ;
123123 }
124124
@@ -128,7 +128,7 @@ function set_preferences()
128128 } else {
129129 // Special case: We've timed out, but no other user has browsed the forums since we timed out
130130 if ($ feather ->user ->logged < ($ now -$ feather ->config ['o_timeout_visit ' ])) {
131- \ORM ::for_table ('users ' )->where ('id ' , $ feather ->user ->id )
131+ \DB ::for_table ('users ' )->where ('id ' , $ feather ->user ->id )
132132 ->find_one ()
133133 ->set ('last_visit ' , $ feather ->user ->logged )
134134 ->save ();
@@ -137,7 +137,7 @@ function set_preferences()
137137
138138 $ idle_sql = ($ feather ->user ->idle == '1 ' ) ? ', idle=0 ' : '' ;
139139
140- \ORM ::for_table ('online ' )->raw_execute ('UPDATE ' .$ feather ->prefix .'online SET logged= ' .$ now .$ idle_sql .' WHERE user_id=:user_id ' , array (':user_id ' => $ feather ->user ->id ));
140+ \DB ::for_table ('online ' )->raw_execute ('UPDATE ' .$ feather ->prefix .'online SET logged= ' .$ now .$ idle_sql .' WHERE user_id=:user_id ' , array (':user_id ' => $ feather ->user ->id ));
141141
142142 // Update tracked topics with the current expire time
143143 $ cookie_tracked_topics = $ feather ->getCookie ($ cookie_name .'_track ' );
@@ -286,15 +286,15 @@ function set_default_user()
286286 case 'mysqli_innodb ' :
287287 case 'sqlite ' :
288288 case 'sqlite3 ' :
289- \ORM ::for_table ('online ' )->raw_execute ('REPLACE INTO ' .$ feather ->prefix .'online (user_id, ident, logged) VALUES(1, :ident, :logged) ' , array (':ident ' => $ remote_addr , ':logged ' => $ feather ->user ->logged ));
289+ \DB ::for_table ('online ' )->raw_execute ('REPLACE INTO ' .$ feather ->prefix .'online (user_id, ident, logged) VALUES(1, :ident, :logged) ' , array (':ident ' => $ remote_addr , ':logged ' => $ feather ->user ->logged ));
290290 break ;
291291
292292 default :
293- \ORM ::for_table ('online ' )->raw_execute ('INSERT INTO ' .$ feather ->prefix .'online (user_id, ident, logged) SELECT 1, :ident, :logged WHERE NOT EXISTS (SELECT 1 FROM ' .$ feather ->prefix .'online WHERE ident=:ident) ' , array (':ident ' => $ remote_addr , ':logged ' => $ feather ->user ->logged ));
293+ \DB ::for_table ('online ' )->raw_execute ('INSERT INTO ' .$ feather ->prefix .'online (user_id, ident, logged) SELECT 1, :ident, :logged WHERE NOT EXISTS (SELECT 1 FROM ' .$ feather ->prefix .'online WHERE ident=:ident) ' , array (':ident ' => $ remote_addr , ':logged ' => $ feather ->user ->logged ));
294294 break ;
295295 }
296296 } else {
297- \ORM ::for_table ('online ' )->where ('ident ' , $ remote_addr )
297+ \DB ::for_table ('online ' )->where ('ident ' , $ remote_addr )
298298 ->update_many ('logged ' , time ());
299299 }
300300
@@ -352,7 +352,7 @@ function check_bans()
352352 foreach ($ feather_bans as $ cur_ban ) {
353353 // Has this ban expired?
354354 if ($ cur_ban ['expire ' ] != '' && $ cur_ban ['expire ' ] <= time ()) {
355- \ORM ::for_table ('bans ' )->where ('id ' , $ cur_ban ['id ' ])
355+ \DB ::for_table ('bans ' )->where ('id ' , $ cur_ban ['id ' ])
356356 ->delete_many ();
357357 $ bans_altered = true ;
358358 continue ;
@@ -382,7 +382,7 @@ function check_bans()
382382 }
383383
384384 if ($ is_banned ) {
385- \ORM ::for_table ('online ' )->where ('ident ' , $ feather ->user ->username )
385+ \DB ::for_table ('online ' )->where ('ident ' , $ feather ->user ->username )
386386 ->delete_many ();
387387 message ($ lang_common ['Ban message ' ].' ' .(($ cur_ban ['expire ' ] != '' ) ? $ lang_common ['Ban message 2 ' ].' ' .strtolower (format_time ($ cur_ban ['expire ' ], true )).'. ' : '' ).(($ cur_ban ['message ' ] != '' ) ? $ lang_common ['Ban message 3 ' ].'<br /><br /><strong> ' .feather_escape ($ cur_ban ['message ' ]).'</strong><br /><br /> ' : '<br /><br /> ' ).$ lang_common ['Ban message 4 ' ].' <a href="mailto: ' .feather_escape ($ feather_config ['o_admin_email ' ]).'"> ' .feather_escape ($ feather_config ['o_admin_email ' ]).'</a>. ' , true , true , true );
388388 }
@@ -435,7 +435,7 @@ function check_username($username, $errors, $exclude_id = null)
435435 // Check that the username (or a too similar username) is not already registered
436436 $ query = (!is_null ($ exclude_id )) ? ' AND id!= ' .$ exclude_id : '' ;
437437
438- $ result = \ORM ::for_table ('online ' )->raw_query ('SELECT username FROM ' .$ feather ->prefix .'users WHERE (UPPER(username)=UPPER(:username1) OR UPPER(username)=UPPER(:username2)) AND id>1 ' .$ query , array (':username1 ' => $ username , ':username2 ' => ucp_preg_replace ('%[^\p{L}\p{N}]%u ' , '' , $ username )))->find_one ();
438+ $ result = \DB ::for_table ('online ' )->raw_query ('SELECT username FROM ' .$ feather ->prefix .'users WHERE (UPPER(username)=UPPER(:username1) OR UPPER(username)=UPPER(:username2)) AND id>1 ' .$ query , array (':username1 ' => $ username , ':username2 ' => ucp_preg_replace ('%[^\p{L}\p{N}]%u ' , '' , $ username )))->find_one ();
439439
440440 if ($ result ) {
441441 $ busy = $ result ['username ' ];
@@ -466,26 +466,26 @@ function update_users_online()
466466 // Fetch all online list entries that are older than "o_timeout_online"
467467 $ select_update_users_online = array ('user_id ' , 'ident ' , 'logged ' , 'idle ' );
468468
469- $ result = \ORM ::for_table ('online ' )->select_many ($ select_update_users_online )
469+ $ result = \DB ::for_table ('online ' )->select_many ($ select_update_users_online )
470470 ->where_lt ('logged ' , $ now -$ feather_config ['o_timeout_online ' ])
471471 ->find_many ();
472472
473473 foreach ($ result as $ cur_user ) {
474474 // If the entry is a guest, delete it
475475 if ($ cur_user ['user_id ' ] == '1 ' ) {
476- \ORM ::for_table ('online ' )->where ('ident ' , $ cur_user ['ident ' ])
476+ \DB ::for_table ('online ' )->where ('ident ' , $ cur_user ['ident ' ])
477477 ->delete_many ();
478478 } else {
479479 // If the entry is older than "o_timeout_visit", update last_visit for the user in question, then delete him/her from the online list
480480 if ($ cur_user ['logged ' ] < ($ now -$ feather_config ['o_timeout_visit ' ])) {
481- \ORM ::for_table ('users ' )->where ('id ' , $ cur_user ['user_id ' ])
481+ \DB ::for_table ('users ' )->where ('id ' , $ cur_user ['user_id ' ])
482482 ->find_one ()
483483 ->set ('last_visit ' , $ cur_user ['logged ' ])
484484 ->save ();
485- \ORM ::for_table ('online ' )->where ('user_id ' , $ cur_user ['user_id ' ])
485+ \DB ::for_table ('online ' )->where ('user_id ' , $ cur_user ['user_id ' ])
486486 ->delete_many ();
487487 } elseif ($ cur_user ['idle ' ] == '0 ' ) {
488- \ORM ::for_table ('online ' )->where ('user_id ' , $ cur_user ['user_id ' ])
488+ \DB ::for_table ('online ' )->where ('user_id ' , $ cur_user ['user_id ' ])
489489 ->update_many ('idle ' , 1 );
490490 }
491491 }
@@ -589,7 +589,7 @@ function update_forum($forum_id)
589589 // Get Slim current session
590590 $ feather = \Slim \Slim::getInstance ();
591591
592- $ stats_query = \ORM ::for_table ('topics ' )
592+ $ stats_query = \DB ::for_table ('topics ' )
593593 ->where ('forum_id ' , $ forum_id )
594594 ->select_expr ('COUNT(id) ' , 'total_topics ' )
595595 ->select_expr ('SUM(num_replies) ' , 'total_replies ' )
@@ -602,7 +602,7 @@ function update_forum($forum_id)
602602
603603 $ select_update_forum = array ('last_post ' , 'last_post_id ' , 'last_poster ' );
604604
605- $ result = \ORM ::for_table ('topics ' )->select_many ($ select_update_forum )
605+ $ result = \DB ::for_table ('topics ' )->select_many ($ select_update_forum )
606606 ->where ('forum_id ' , $ forum_id )
607607 ->where_null ('moved_to ' )
608608 ->order_by_desc ('last_post ' )
@@ -627,7 +627,7 @@ function update_forum($forum_id)
627627 'last_poster ' => 'NULL ' ,
628628 );
629629 }
630- \ORM ::for_table ('forums ' )
630+ \DB ::for_table ('forums ' )
631631 ->where ('id ' , $ forum_id )
632632 ->find_one ()
633633 ->set ($ insert_update_forum )
@@ -667,17 +667,17 @@ function delete_topic($topic_id)
667667 array ('moved_to ' => $ topic_id )
668668 );
669669
670- \ORM ::for_table ('topics ' )
670+ \DB ::for_table ('topics ' )
671671 ->where_any_is ($ where_delete_topic )
672672 ->delete_many ();
673673
674674 // Delete posts in topic
675- \ORM ::for_table ('posts ' )
675+ \DB ::for_table ('posts ' )
676676 ->where ('topic_id ' , $ topic_id )
677677 ->delete_many ();
678678
679679 // Delete any subscriptions for this topic
680- \ORM ::for_table ('topic_subscriptions ' )
680+ \DB ::for_table ('topic_subscriptions ' )
681681 ->where ('topic_id ' , $ topic_id )
682682 ->delete_many ();
683683}
@@ -691,7 +691,7 @@ function delete_post($post_id, $topic_id)
691691 // Get Slim current session
692692 $ feather = \Slim \Slim::getInstance ();
693693
694- $ result = \ORM ::for_table ('posts ' )
694+ $ result = \DB ::for_table ('posts ' )
695695 ->select_many ('id ' , 'poster ' , 'posted ' )
696696 ->where ('topic_id ' , $ topic_id )
697697 ->order_by_desc ('id ' )
@@ -712,15 +712,15 @@ function delete_post($post_id, $topic_id)
712712 }
713713
714714 // Delete the post
715- \ORM ::for_table ('posts ' )
715+ \DB ::for_table ('posts ' )
716716 ->where ('id ' , $ post_id )
717717 ->find_one ()
718718 ->delete ();
719719
720720 strip_search_index ($ post_id );
721721
722722 // Count number of replies in the topic
723- $ num_replies = \ORM ::for_table ('posts ' )->where ('topic_id ' , $ topic_id )->count () - 1 ;
723+ $ num_replies = \DB ::for_table ('posts ' )->where ('topic_id ' , $ topic_id )->count () - 1 ;
724724
725725 // If the message we deleted is the most recent in the topic (at the end of the topic)
726726 if ($ last_id == $ post_id ) {
@@ -732,14 +732,14 @@ function delete_post($post_id, $topic_id)
732732 'last_poster ' => $ second_poster ,
733733 'num_replies ' => $ num_replies ,
734734 );
735- \ORM ::for_table ('topics ' )
735+ \DB ::for_table ('topics ' )
736736 ->where ('id ' , $ topic_id )
737737 ->find_one ()
738738 ->set ($ update_topic )
739739 ->save ();
740740 } else {
741741 // We deleted the only reply, so now last_post/last_post_id/last_poster is posted/id/poster from the topic itself
742- \ORM ::for_table ('topics ' )
742+ \DB ::for_table ('topics ' )
743743 ->where ('id ' , $ topic_id )
744744 ->find_one ()
745745 ->set_expr ('last_post ' , 'posted ' )
@@ -750,7 +750,7 @@ function delete_post($post_id, $topic_id)
750750 }
751751 } else {
752752 // Otherwise we just decrement the reply counter
753- \ORM ::for_table ('topics ' )
753+ \DB ::for_table ('topics ' )
754754 ->where ('id ' , $ topic_id )
755755 ->find_one ()
756756 ->set ('num_replies ' , $ num_replies )
@@ -1727,10 +1727,10 @@ function display_saved_queries()
17271727
17281728 $ query_time_total = 0.0 ;
17291729 $ i = 0 ;
1730- foreach (\ORM ::get_query_log ()[1 ] as $ query ) {
1730+ foreach (\DB ::get_query_log ()[1 ] as $ query ) {
17311731 ?>
17321732 <tr>
1733- <td class="tcl"><?php echo feather_escape (round (\ORM ::get_query_log ()[0 ][$ i ], 6 )) ?> </td>
1733+ <td class="tcl"><?php echo feather_escape (round (\DB ::get_query_log ()[0 ][$ i ], 6 )) ?> </td>
17341734 <td class="tcr"><?php echo feather_escape ($ query ) ?> </td>
17351735 </tr>
17361736 <?php
0 commit comments