}
}
- if(class_exists('mysqli')) {
+ if (class_exists('mysqli')) {
$this->db = @new mysqli($server,$user,$pass,$db);
- if(! mysqli_connect_errno()) {
+ if (! mysqli_connect_errno()) {
$this->connected = true;
+ //mysqli_set_charset($this->db, 'utf8');
}
- }
- else {
+ if (isset($a->config["system"]["db_charset"])) {
+ $this->db->set_charset($a->config["system"]["db_charset"]);
+ }
+ } else {
$this->mysqli = false;
$this->db = mysql_connect($server,$user,$pass);
- if($this->db && mysql_select_db($db,$this->db)) {
+ if ($this->db && mysql_select_db($db,$this->db)) {
$this->connected = true;
+ //mysql_set_charset('utf8', $this->db);
}
+ if (isset($a->config["system"]["db_charset"]))
+ mysql_set_charset($a->config["system"]["db_charset"], $this->db);
}
- if(! $this->connected) {
+ if (!$this->connected) {
$this->db = null;
- if(! $install)
+ if (!$install) {
system_unavailable();
+ }
}
$a->save_timestamp($stamp1, "network");
// only setup pagination on initial page view
$pager_sql = '';
- }
- else {
+ } else {
if(get_config('system', 'old_pager')) {
- $r = q("SELECT COUNT(*) AS `total`
+ $r = qu("SELECT COUNT(*) AS `total`
FROM $sql_table $sql_post_table INNER JOIN `contact` ON `contact`.`id` = $sql_table.`contact-id`
AND NOT `contact`.`blocked` AND NOT `contact`.`pending`
WHERE $sql_table.`uid` = %d AND $sql_table.`visible` AND NOT $sql_table.`deleted`
$simple_update = (($update) ? " AND `item`.`unseen` " : '');
if ($sql_order == "")
- $sql_order = "`item`.`received`";
+ $sql_order = "`item`.`id`";
// "New Item View" - show all items unthreaded in reverse created date order
- $items = q("SELECT %s FROM $sql_table $sql_post_table %s
+ $items = qu("SELECT %s FROM $sql_table $sql_post_table %s
WHERE %s AND `item`.`uid` = %d
$simple_update
$sql_extra $sql_nets
return;
}
}
- logger("cron_start");
+*/ logger("cron_start");
- $users = q("SELECT profile.*, `user`.`login_date`, `lastitem`.`lastitem_date`
- FROM (SELECT MAX(`item`.`changed`) as `lastitem_date`, `item`.`uid`
- FROM `item`
- WHERE `item`.`type` = 'wall'
- GROUP BY `item`.`uid`) AS `lastitem`
- RIGHT OUTER JOIN `user` ON `user`.`uid` = `lastitem`.`uid`, `contact`, `profile`
- WHERE
- `user`.`uid` = `contact`.`uid` AND `profile`.`uid` = `user`.`uid`
- AND `profile`.`is-default` AND (`profile`.`publish` OR `profile`.`net-publish`)
- AND `user`.`verified` AND `contact`.`self`
- AND NOT `user`.`blocked`
- AND NOT `user`.`account_removed`
- AND NOT `user`.`account_expired`");
-
+ $users = qu("SELECT `user`.`uid`, `user`.`login_date`, `contact`.`last-item`
+ FROM `user`
+ INNER JOIN `profile` ON `profile`.`uid` = `user`.`uid` AND `profile`.`is-default`
+ INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`
+ WHERE (`profile`.`publish` OR `profile`.`net-publish`) AND `user`.`verified`
+ AND NOT `user`.`blocked` AND NOT `user`.`account_removed`
+ AND NOT `user`.`account_expired`");
if (is_array($users)) {
$total_users = count($users);
$active_users_halfyear = 0;
set_config('nodeinfo','active_users_monthly', $active_users_monthly);
}
- // $posts = q("SELECT COUNT(*) AS `local_posts` FROM `thread`
- // INNER JOIN `contact` ON `contact`.`id` = `thread`.`contact-id` AND `contact`.`uid` = `thread`.`uid`
- // WHERE `contact`.`self`");
- $posts = q("SELECT COUNT(*) AS local_posts FROM `thread` WHERE `thread`.`wall`");
- /*
- $posts = q("SELECT COUNT(*) AS local_posts FROM `thread`
- INNER JOIN `item` ON `item`.`id` = `thread`.`iid`
- WHERE `thread`.`wall` AND NOT `thread`.`private` AND
- `thread`.`uid` != 0 AND LEFT(`item`.`body`, 6) != '[share' AND
- `thread`.`network` IN ('%s', '%s', '%s')",
- dbesc(NETWORK_OSTATUS), dbesc(NETWORK_DIASPORA), dbesc(NETWORK_DFRN));
- */
++ $posts = qu("SELECT COUNT(*) AS local_posts FROM `thread` WHERE `thread`.`wall`");
+/*
- $posts = q("SELECT COUNT(*) AS `local_posts` FROM `item`
+ $posts = qu("SELECT COUNT(*) AS `local_posts` FROM `item`
INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
WHERE `contact`.`self` and `item`.`id` = `item`.`parent` AND left(body, 6) != '[share' AND `item`.`network` IN ('%s', '%s', '%s')",
dbesc(NETWORK_OSTATUS), dbesc(NETWORK_DIASPORA), dbesc(NETWORK_DFRN));