<?php
-define( 'UPDATE_VERSION' , 1184 );
+define('UPDATE_VERSION' , 1209);
/**
*
// create 's' keys for everybody that does not have one
$r = q("SELECT * FROM `user` WHERE `spubkey` = '' ");
- if(count($r)) {
+ if (dbm::is_result($r)) {
foreach($r as $rr) {
$sres=openssl_pkey_new(array('encrypt_key' => false ));
$sprvkey = '';
function update_1011() {
q("ALTER TABLE `contact` ADD `nick` CHAR( 255 ) NOT NULL AFTER `name` ");
$r = q("SELECT * FROM `contact` WHERE 1");
- if(count($r)) {
+ if (dbm::is_result($r)) {
foreach($r as $rr) {
q("UPDATE `contact` SET `nick` = '%s' WHERE `id` = %d",
dbesc(basename($rr['url'])),
require_once('include/Photo.php');
q("ALTER TABLE `contact` ADD `micro` TEXT NOT NULL AFTER `thumb` ");
$r = q("SELECT * FROM `photo` WHERE `scale` = 4");
- if(count($r)) {
+ if (dbm::is_result($r)) {
foreach($r as $rr) {
$ph = new Photo($rr['data']);
if($ph->is_valid()) {
}
}
$r = q("SELECT * FROM `contact` WHERE 1");
- if(count($r)) {
+ if (dbm::is_result($r)) {
foreach($r as $rr) {
if(stristr($rr['thumb'],'avatar'))
q("UPDATE `contact` SET `micro` = '%s' WHERE `id` = %d",
function update_1031() {
// Repair any bad links that slipped into the item table
$r = q("SELECT `id`, `object` FROM `item` WHERE `object` != '' ");
- if($r && count($r)) {
+ if($r && dbm::is_result($r)) {
foreach($r as $rr) {
if(strstr($rr['object'],'type="http')) {
q("UPDATE `item` SET `object` = '%s' WHERE `id` = %d",
function update_1036() {
$r = dbq("SELECT * FROM `contact` WHERE `network` = 'dfrn' && `photo` LIKE '%include/photo%' ");
- if(count($r)) {
+ if (dbm::is_result($r)) {
foreach($r as $rr) {
q("UPDATE `contact` SET `photo` = '%s', `thumb` = '%s', `micro` = '%s' WHERE `id` = %d",
dbesc(str_replace('include/photo','photo',$rr['photo'])),
function update_1074() {
q("ALTER TABLE `user` ADD `hidewall` TINYINT( 1) NOT NULL DEFAULT '0' AFTER `blockwall` ");
$r = q("SELECT `uid` FROM `profile` WHERE `is-default` = 1 AND `hidewall` = 1");
- if(count($r)) {
+ if (dbm::is_result($r)) {
foreach($r as $rr)
q("UPDATE `user` SET `hidewall` = 1 WHERE `uid` = %d",
intval($rr['uid'])
function update_1075() {
q("ALTER TABLE `user` ADD `guid` CHAR( 16 ) NOT NULL AFTER `uid` ");
$r = q("SELECT `uid` FROM `user` WHERE 1");
- if(count($r)) {
+ if (dbm::is_result($r)) {
foreach($r as $rr) {
$found = true;
do {
ADD INDEX ( `guid` ) ");
// make certain the following code is only executed once
$r = q("select `id` from `photo` where `guid` != '' limit 1");
- if($r && count($r))
+ if (dbm::is_result($r))
return;
$r = q("SELECT distinct(`resource-id`) FROM `photo` WHERE 1 group by `id`");
- if(count($r)) {
+ if (dbm::is_result($r)) {
foreach($r as $rr) {
$guid = get_guid();
q("update `photo` set `guid` = '%s' where `resource-id` = '%s'",
q("ALTER TABLE `item` ADD `commented` datetime NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `edited` ");
$r = q("SELECT `id` FROM `item` WHERE `parent` = `id` ");
- if(count($r)) {
+ if (dbm::is_result($r)) {
foreach($r as $rr) {
$x = q("SELECT max(`created`) AS `cdate` FROM `item` WHERE `parent` = %d LIMIT 1",
intval($rr['id'])
require_once('include/text.php');
$r = q("select id, url from contact where url != '' and nurl = '' ");
- if(count($r)) {
+ if (dbm::is_result($r)) {
foreach($r as $rr) {
q("update contact set nurl = '%s' where id = %d",
dbesc(normalise_link($rr['url'])),
// might be missing on new installs. We'll check.
$r = q("describe item");
- if($r && count($r)) {
+ if (dbm::is_result($r)) {
foreach($r as $rr)
if($rr['Field'] == 'spam')
return;
// order in reverse so that we save the newest entry
$r = q("select * from config where 1 order by id desc");
- if(count($r)) {
+ if (dbm::is_result($r)) {
foreach($r as $rr) {
$found = false;
foreach($arr as $x) {
$arr = array();
$r = q("select * from pconfig where 1 order by id desc");
- if(count($r)) {
+ if (dbm::is_result($r)) {
foreach($r as $rr) {
$found = false;
foreach($arr as $x) {
if (!$r)
return UPDATE_FAILED;
- proc_run('php',"include/threadupdate.php");
+ proc_run(PRIORITY_LOW, "include/threadupdate.php");
return UPDATE_SUCCESS;
}
set_config('system','community_page_style', CP_NO_COMMUNITY_PAGE);
// Update the central item storage with uid=0
- proc_run('php',"include/threadupdate.php");
+ proc_run(PRIORITY_LOW, "include/threadupdate.php");
return UPDATE_SUCCESS;
}
function update_1180() {
// Fill the new fields in the term table.
- proc_run('php',"include/tagupdate.php");
+ proc_run(PRIORITY_LOW, "include/tagupdate.php");
return UPDATE_SUCCESS;
}
+
+function update_1188() {
+
+ if (strlen(get_config('system','directory_submit_url')) AND
+ !strlen(get_config('system','directory'))) {
+ set_config('system','directory', dirname(get_config('system','directory_submit_url')));
+ del_config('system','directory_submit_url');
+ }
+
+ return UPDATE_SUCCESS;
+}
+
+function update_1190() {
+
+ require_once('include/plugin.php');
+
+ set_config('system', 'maintenance', 1);
+
+ if (plugin_enabled('forumlist')) {
+ $plugin = 'forumlist';
+ $plugins = get_config('system','addon');
+ $plugins_arr = array();
+
+ if($plugins) {
+ $plugins_arr = explode(",",str_replace(" ", "",$plugins));
+
+ $idx = array_search($plugin, $plugins_arr);
+ if ($idx !== false){
+ unset($plugins_arr[$idx]);
+ //delete forumlist manually from addon and hook table
+ // since uninstall_plugin() don't work here
+ q("DELETE FROM `addon` WHERE `name` = 'forumlist' ");
+ q("DELETE FROM `hook` WHERE `file` = 'addon/forumlist/forumlist.php' ");
+ set_config('system','addon', implode(", ",$plugins_arr));
+ }
+ }
+ }
+
+ // select old formlist addon entries
+ $r = q("SELECT `uid`, `cat`, `k`, `v` FROM `pconfig` WHERE `cat` = '%s' ",
+ dbesc('forumlist')
+ );
+
+ // convert old forumlist addon entries in new config entries
+ if (dbm::is_result($r)) {
+ foreach ($r as $rr) {
+ $uid = $rr['uid'];
+ $family = $rr['cat'];
+ $key = $rr['k'];
+ $value = $rr['v'];
+
+ if ($key === 'randomise')
+ del_pconfig($uid,$family,$key);
+
+ if ($key === 'show_on_profile') {
+ if ($value)
+ set_pconfig($uid,feature,forumlist_profile,$value);
+
+ del_pconfig($uid,$family,$key);
+ }
+
+ if ($key === 'show_on_network') {
+ if ($value)
+ set_pconfig($uid,feature,forumlist_widget,$value);
+
+ del_pconfig($uid,$family,$key);
+ }
+ }
+ }
+
+ set_config('system', 'maintenance', 0);
+
+ return UPDATE_SUCCESS;
+
+}
+
+function update_1202() {
+ $r = q("UPDATE `user` SET `account-type` = %d WHERE `page-flags` IN (%d, %d)",
+ dbesc(ACCOUNT_TYPE_COMMUNITY), dbesc(PAGE_COMMUNITY), dbesc(PAGE_PRVGROUP));
+}