Skip to content

Commit

Permalink
mistpark 2.0 infrasturcture lands
Browse files Browse the repository at this point in the history
  • Loading branch information
macgirvin committed Sep 9, 2010
1 parent b49858b commit ffb1997
Show file tree
Hide file tree
Showing 360 changed files with 25,001 additions and 457 deletions.
80 changes: 76 additions & 4 deletions boot.php
Expand Up @@ -21,8 +21,25 @@
define ( 'NOTIFY_COMMENT', 0x0008 );
define ( 'NOTIFY_MAIL', 0x0010 );

define ( 'NAMESPACE_DFRN' , 'http://purl.org/macgirvin/dfrn/1.0' );
define ( 'NAMESPACE_ACTIVITY', 'http://activitystrea.ms/schema/1.0/' );
define ( 'NAMESPACE_DFRN' , 'http://purl.org/macgirvin/dfrn/1.0' );
define ( 'NAMESPACE_ACTIVITY', 'http://activitystrea.ms/spec/1.0/' );
define ( 'NAMESPACE_ACTIVITY_SCHEMA', 'http://activitystrea.ms/schema/1.0/');
define ( 'ACTIVITY_LIKE', NAMESPACE_ACTIVITY_SCHEMA . 'like' );
define ( 'ACTIVITY_FRIEND', NAMESPACE_ACTIVITY_SCHEMA . 'make-friend' );
define ( 'ACTIVITY_POST', NAMESPACE_ACTIVITY_SCHEMA . 'post' );
define ( 'ACTIVITY_UPDATE', NAMESPACE_ACTIVITY_SCHEMA . 'update' );

define ( 'ACTIVITY_OBJ_COMMENT', NAMESPACE_ACTIVITY_SCHEMA . 'comment' );
define ( 'ACTIVITY_OBJ_NOTE', NAMESPACE_ACTIVITY_SCHEMA . 'note' );
define ( 'ACTIVITY_OBJ_PERSON', NAMESPACE_ACTIVITY_SCHEMA . 'person' );
define ( 'ACTIVITY_OBJ_PHOTO', NAMESPACE_ACTIVITY_SCHEMA . 'photo' );
define ( 'ACTIVITY_OBJ_P_PHOTO', NAMESPACE_ACTIVITY_SCHEMA . 'profile-photo' );
define ( 'ACTIVITY_OBJ_ALBUM', NAMESPACE_ACTIVITY_SCHEMA . 'photo-album' );


define ( 'ACTIVITY_OBJ_HEART', NAMESPACE_DFRN . '/heart' );



if(! class_exists('App')) {
class App {
Expand Down Expand Up @@ -582,8 +599,11 @@ function get_config($family, $key, $instore = false) {

global $a;
if(! $instore) {
if(isset($a->config[$family][$key]))
if(isset($a->config[$family][$key])) {
if($a->config[$family][$key] == '!<unset>!')
return false;
return $a->config[$family][$key];
}
}
$ret = q("SELECT `v` FROM `config` WHERE `cat` = '%s' AND `k` = '%s' LIMIT 1",
dbesc($family),
Expand All @@ -593,6 +613,9 @@ function get_config($family, $key, $instore = false) {
$a->config[$family][$key] = $ret[0]['v'];
return $ret[0]['v'];
}
else {
$a->config[$family][$key] = '!<unset>!';
}
return false;
}}

Expand Down Expand Up @@ -667,8 +690,9 @@ function convert_xml_element_to_array($xml_element, &$recursion_depth=0) {

if(! function_exists('webfinger')) {
function webfinger($s) {
if(! strstr($s,'@'))
if(! strstr($s,'@')) {
return $s;
}
$host = substr($s,strpos($s,'@') + 1);
$url = 'http://' . $host . '/.well-known/host-meta' ;
$xml = fetch_url($url);
Expand Down Expand Up @@ -714,3 +738,51 @@ function webfinger($s) {
return $link['@attributes']['href'];
return '';
}}

if(! function_exists('perms2str')) {
function perms2str($p) {
$ret = '';
$tmp = $p;
if(is_array($tmp)) {
array_walk($tmp,'sanitise_acl');
$ret = implode('',$tmp);
}
return $ret;
}}

if(! function_exists('item_new_uri')) {
function item_new_uri($hostname,$uid) {

do {
$dups = false;
$hash = random_string();

$uri = "urn:X-dfrn:" . $hostname . ':' . $uid . ':' . $hash;

$r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' LIMIT 1",
dbesc($uri));
if(count($r))
$dups = true;
} while($dups == true);
return $uri;
}}

if(! function_exists('get_uid')) {
function get_uid() {
return ((x($_SESSION,'uid')) ? intval($_SESSION['uid']) : 0) ;
}}

if(! function_exists('validate_url')) {
function validate_url($url) {
if(substr($url,0,4) != 'http')
$url = 'http://' . $url;
$h = parse_url($url);

if(! $h)
return false;
if(! checkdnsrr($h['host'], 'ANY'))
return false;
return true;
}}


54 changes: 54 additions & 0 deletions include/Contact.php
@@ -0,0 +1,54 @@
<?php




function contact_remove($id) {
q("DELETE FROM `contact` WHERE `id` = %d LIMIT 1",
intval($id)
);
q("DELETE FROM `item` WHERE `contact-id` = %d ",
intval($id)
);
q("DELETE FROM `photo` WHERE `contact-id` = %d ",
intval($id)
);
}


// Contact has refused to recognise us as a friend. We will start a countdown.
// If they still don't recognise us in 32 days, the relationship is over,
// and we won't waste any more time trying to communicate with them.
// This provides for the possibility that their database is temporarily messed
// up or some other transient event and that there's a possibility we could recover from it.

if(! function_exists('mark_for_death')) {
function mark_for_death($contact) {
if($contact['term-date'] == '0000-00-00 00:00:00') {
q("UPDATE `contact` SET `term-date` = '%s' WHERE `id` = %d LIMIT 1",
dbesc(datetime_convert()),
intval($contact['id'])
);
}
else {
$expiry = $contact['term-date'] . ' + 32 days ';
if(datetime_convert() > datetime_convert('UTC','UTC',$expiry)) {

// relationship is really truly dead.

contact_remove($contact['id']);

}
}

}}

if(! function_exists('unmark_for_death')) {
function unmark_for_death($contact) {
// It's a miracle. Our dead contact has inexplicably come back to life.
q("UPDATE `contact` SET `term-date = '%s' WHERE `id` = %d LIMIT 1",
dbesc('0000-00-00 00:00:00'),
intval($contact['id'])
);
}}

2 changes: 0 additions & 2 deletions include/auth.php
Expand Up @@ -7,7 +7,6 @@
unset($_SESSION['authenticated']);
unset($_SESSION['uid']);
unset($_SESSION['visitor_id']);
unset($_SESSION['is_visitor']);
unset($_SESSION['administrator']);
unset($_SESSION['cid']);
unset($_SESSION['theme']);
Expand Down Expand Up @@ -41,7 +40,6 @@
unset($_SESSION['authenticated']);
unset($_SESSION['uid']);
unset($_SESSION['visitor_id']);
unset($_SESSION['is_visitor']);
unset($_SESSION['administrator']);
unset($_SESSION['cid']);
$encrypted = hash('whirlpool',trim($_POST['password']));
Expand Down
2 changes: 1 addition & 1 deletion include/bbcode.php
Expand Up @@ -76,7 +76,7 @@ function bbcode($Text) {

// Youtube extensions
$Text = preg_replace("/\[youtube\]http:\/\/www.youtube.com\/watch\?v\=(.+?)\[\/youtube\]/",'[youtube]$1[/youtube]',$Text);
$Text = preg_replace("/\[youtube\](.+?)\[\/youtube\]/", '<object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/$1"></param><embed src="http://www.youtube.com/v/$1" type="application/x-shockwave-flash" width="425" height="350"></embed></object>', $Text);
$Text = preg_replace("/\[youtube\](.+?)\[\/youtube\]/", '<object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/$1"></param><!--[if IE]><embed src="http://www.youtube.com/v/$1" type="application/x-shockwave-flash" width="425" height="350" /><![endif]--></object>', $Text);

return $Text;
}
17 changes: 14 additions & 3 deletions include/datetime.php
Expand Up @@ -55,9 +55,20 @@ function select_timezone($current = 'America/Los_Angeles') {

if(! function_exists('datetime_convert')) {
function datetime_convert($from = 'UTC', $to = 'UTC', $s = 'now', $fmt = "Y-m-d H:i:s") {
$d = new DateTime($s, new DateTimeZone($from));
$d->setTimeZone(new DateTimeZone($to));
return($d->format($fmt));

// Slight hackish adjustment so that 'zero' datetime actually returns what is intended
// otherwise we end up with -0001-11-30 ...
// add 32 days so that we at least get year 00, and then hack around the fact that
// months and days always start with 1.

if(substr($s,0,10) == '0000-00-00') {
$d = new DateTime($s . ' + 32 days', new DateTimeZone('UTC'));
return str_replace('1','0',$d->format($fmt));
}

$d = new DateTime($s, new DateTimeZone($from));
$d->setTimeZone(new DateTimeZone($to));
return($d->format($fmt));
}}

function dob($dob) {
Expand Down
50 changes: 50 additions & 0 deletions include/html2bbcode.php
@@ -0,0 +1,50 @@
<?php


function html2bbcode($s) {


// Tags to Find
$htmltags = array(
'/\<b\>(.*?)\<\/b\>/is',
'/\<i\>(.*?)\<\/i\>/is',
'/\<u\>(.*?)\<\/u\>/is',
'/\<ul\>(.*?)\<\/ul\>/is',
'/\<li\>(.*?)\<\/li\>/is',
'/\<img(.*?) src=\"(.*?)\" (.*?)\>/is',
'/\<div(.*?)\>(.*?)\<\/div\>/is',
'/\<br(.*?)\>/is',
'/\<strong\>(.*?)\<\/strong\>/is',
'/\<a href=\"(.*?)\"(.*?)\>(.*?)\<\/a\>/is',
'/\<code\>(.*?)\<\/code\>/is',
'/\<font color=(.*?)\>(.*?)\<\/font\>',
'/\<font color=\"(.*?)\"\>(.*?)\<\/font\>',
'/\<blockquote\>(.*?)\<\/blockquote\>/is',

);

// Replace with
$bbtags = array(
'[b]$1[/b]',
'[i]$1[/i]',
'[u]$1[/u]',
'[list]$1[/list]',
'[*]$1',
'[img]$2[/img]',
'$2',
'\n',
'[b]$1[/b]',
'[url=$1]$3[/url]',
'[code]$1[/code],
'[color="$1"]$2[/color]',
'[color="$1"]$2[/color]',
'[quote]$1[/quote]',
);

// Replace $htmltags in $text with $bbtags
$text = preg_replace ($htmltags, $bbtags, $s);

// Strip all other HTML tags
$text = strip_tags($text);
return $text;
}

0 comments on commit ffb1997

Please sign in to comment.