add Thomas's Diaspora repair script as include/fixd.php - altered so it can be re-run if necessary with a count of remaining hublocs to be fixed. Some sites are down so it probably can't ever get to zero. The check for a null join is quite an expensive query. It could block your DB for a couple minutes while it runs.
Also some preliminary work on a means to take the channel module out of list/forum mode if a specific mid is requested.
This commit is contained in:
		
							
								
								
									
										33
									
								
								include/fixd.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								include/fixd.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,33 @@ | ||||
| <?php | ||||
|  | ||||
| 	require_once('include/cli_startup.php'); | ||||
|  | ||||
| 	cli_startup(); | ||||
|  | ||||
| 	$rand = db_getfunc('RAND'); | ||||
| 	$r = q("select xchan_addr, hubloc_url from xchan left join hubloc on hubloc_hash = xchan_hash where xchan_network like '%%diaspora%%' order by $rand"); | ||||
|  | ||||
| 	if(! $r) | ||||
| 		killme(); | ||||
|  | ||||
| 	require_once('include/network.php'); | ||||
| 	$total = 0; | ||||
| 	foreach ($r as $rr) { | ||||
| 		if($rr['hubloc_url']) { | ||||
| 			continue; | ||||
| 		} | ||||
| 		$total ++; | ||||
| 	} | ||||
|  | ||||
| 	print $total . "\n"; | ||||
|  | ||||
| 	foreach ($r as $rr) { | ||||
| 		if($rr['hubloc_url']) { | ||||
| 			continue; | ||||
| 		} | ||||
|  | ||||
| 		$webbie = $rr['xchan_addr']; | ||||
| 		print $webbie . ' '; | ||||
|  | ||||
| 		discover_by_webbie($webbie); | ||||
| 	} | ||||
| @@ -1094,23 +1094,25 @@ function discover_by_webbie($webbie) { | ||||
| 			); | ||||
| 			if(! $r) { | ||||
|  | ||||
| 			$r = q("insert into xchan ( xchan_hash, xchan_guid, xchan_pubkey, xchan_addr, xchan_url, xchan_name, xchan_network, xchan_instance_url, xchan_name_date ) values ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s') ", | ||||
| 				dbesc($addr), | ||||
| 				dbesc($guid), | ||||
| 				dbesc($pubkey), | ||||
| 				dbesc($addr), | ||||
| 				dbesc($profile), | ||||
| 				dbesc($vcard['fn']), | ||||
| 				dbesc($network), | ||||
| 				dbesc(z_root()), | ||||
| 				dbescdate(datetime_convert()) | ||||
| 			); | ||||
| 				$r = q("insert into xchan ( xchan_hash, xchan_guid, xchan_pubkey, xchan_addr, xchan_url, xchan_name, xchan_network, xchan_instance_url, xchan_name_date ) values ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s') ", | ||||
| 					dbesc($addr), | ||||
| 					dbesc($guid), | ||||
| 					dbesc($pubkey), | ||||
| 					dbesc($addr), | ||||
| 					dbesc($profile), | ||||
| 					dbesc($vcard['fn']), | ||||
| 					dbesc($network), | ||||
| 					dbesc(z_root()), | ||||
| 					dbescdate(datetime_convert()) | ||||
| 				); | ||||
| 			} | ||||
|  | ||||
| 			$r = q("select * from hubloc where hubloc_hash = '%s' limit 1", | ||||
| 				dbesc($webbie) | ||||
| 			); | ||||
|  | ||||
| 			if(! $r) { | ||||
|  | ||||
| 				$r = q("insert into hubloc ( hubloc_guid, hubloc_hash, hubloc_addr, hubloc_network, hubloc_url, hubloc_host, hubloc_callback, hubloc_updated, hubloc_flags ) values ('%s','%s','%s','%s','%s','%s','%s','%s', %d)", | ||||
| 					dbesc($guid), | ||||
| 					dbesc($addr), | ||||
|   | ||||
| @@ -47,7 +47,7 @@ function channel_content(&$a, $update = 0, $load = false) { | ||||
|  | ||||
| 	$category = $datequery = $datequery2 = ''; | ||||
|  | ||||
| 	$mid = $_GET['mid']; | ||||
| 	$mid = ((x($_REQUEST,'mid')) ? $_REQUEST['mid'] : ''); | ||||
|  | ||||
| 	$datequery = ((x($_GET,'dend') && is_a_date_arg($_GET['dend'])) ? notags($_GET['dend']) : ''); | ||||
| 	$datequery2 = ((x($_GET,'dbegin') && is_a_date_arg($_GET['dbegin'])) ? notags($_GET['dbegin']) : ''); | ||||
| @@ -138,7 +138,7 @@ function channel_content(&$a, $update = 0, $load = false) { | ||||
|  | ||||
| 	$sql_extra = item_permissions_sql($a->profile['profile_uid'],$remote_contact,$groups); | ||||
|  | ||||
| 	if(get_pconfig($a->profile['profile_uid'],'system','channel_list_mode')) | ||||
| 	if(get_pconfig($a->profile['profile_uid'],'system','channel_list_mode') && (! $mid)) | ||||
| 		$page_mode = 'list'; | ||||
| 	else | ||||
| 		$page_mode = 'client'; | ||||
| @@ -147,7 +147,7 @@ function channel_content(&$a, $update = 0, $load = false) { | ||||
| 	if(($update) && (! $load)) { | ||||
| 		if ($mid) { | ||||
| 			$r = q("SELECT parent AS item_id from item where mid = '%s' and uid = %d AND item_restrict = 0 | ||||
| 				AND (item_flags &  %d)>0 AND (item_flags & %d)>0 $sql_extra limit 1", | ||||
| 				AND (item_flags &  %d) > 0 AND (item_flags & %d) > 0 $sql_extra limit 1", | ||||
| 				dbesc($mid), | ||||
| 				intval($a->profile['profile_uid']), | ||||
| 				intval(ITEM_WALL), | ||||
| @@ -157,7 +157,7 @@ function channel_content(&$a, $update = 0, $load = false) { | ||||
| 			$r = q("SELECT distinct parent AS `item_id`, created from item | ||||
| 				left join abook on item.author_xchan = abook.abook_xchan | ||||
| 				WHERE uid = %d AND item_restrict = 0 | ||||
| 				AND (item_flags &  %d)>0 AND ( item_flags & %d )>0 | ||||
| 				AND (item_flags &  %d) > 0 AND ( item_flags & %d ) > 0 | ||||
| 				AND ((abook.abook_flags & %d) = 0 or abook.abook_flags is null) | ||||
| 				$sql_extra | ||||
| 				ORDER BY created DESC", | ||||
| @@ -171,7 +171,6 @@ function channel_content(&$a, $update = 0, $load = false) { | ||||
| 	} | ||||
| 	else { | ||||
|  | ||||
|  | ||||
| 		if(x($category)) { | ||||
| 		        $sql_extra .= protect_sprintf(term_query('item', $category, TERM_CATEGORY)); | ||||
| 		} | ||||
|   | ||||
| @@ -1 +1 @@ | ||||
| 2014-12-15.890 | ||||
| 2014-12-16.891 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user