]> git.mxchange.org Git - friendica.git/blobdiff - include/event.php
Add check_blocklist to z_fetch_url and post_url
[friendica.git] / include / event.php
index 82d5a1ec58b6fdf0d640920005144dee8e306331..64b1ebddc3c4a4008ce11e2f4c82c5050063622a 100644 (file)
@@ -10,7 +10,7 @@ require_once 'include/datetime.php';
 
 function format_event_html($ev, $simple = false) {
 
-       if(! ((is_array($ev)) && count($ev))) {
+       if (! ((is_array($ev)) && count($ev))) {
                return '';
        }
 
@@ -82,6 +82,7 @@ function format_event_html($ev, $simple = false) {
 }
 
 /*
+@TODO old-lost code found?
 function parse_event($h) {
 
        require_once('include/Scrape.php');
@@ -98,26 +99,26 @@ function parse_event($h) {
                logger('parse_event: parse error: ' . $e);
        }
 
-       if(! $dom)
+       if (! $dom)
                return $ret;
 
        $items = $dom->getElementsByTagName('*');
 
-       foreach($items as $item) {
-               if(attribute_contains($item->getAttribute('class'), 'vevent')) {
+       foreach ($items as $item) {
+               if (attribute_contains($item->getAttribute('class'), 'vevent')) {
                        $level2 = $item->getElementsByTagName('*');
-                       foreach($level2 as $x) {
-                               if(attribute_contains($x->getAttribute('class'),'dtstart') && $x->getAttribute('title')) {
+                       foreach ($level2 as $x) {
+                               if (attribute_contains($x->getAttribute('class'),'dtstart') && $x->getAttribute('title')) {
                                        $ret['start'] = $x->getAttribute('title');
-                                       if(! strpos($ret['start'],'Z'))
+                                       if (! strpos($ret['start'],'Z'))
                                                $ret['adjust'] = true;
                                }
-                               if(attribute_contains($x->getAttribute('class'),'dtend') && $x->getAttribute('title'))
+                               if (attribute_contains($x->getAttribute('class'),'dtend') && $x->getAttribute('title'))
                                        $ret['finish'] = $x->getAttribute('title');
 
-                               if(attribute_contains($x->getAttribute('class'),'description'))
+                               if (attribute_contains($x->getAttribute('class'),'description'))
                                        $ret['desc'] = $x->textContent;
-                               if(attribute_contains($x->getAttribute('class'),'location'))
+                               if (attribute_contains($x->getAttribute('class'),'location'))
                                        $ret['location'] = $x->textContent;
                        }
                }
@@ -125,23 +126,23 @@ function parse_event($h) {
 
        // sanitise
 
-       if((x($ret,'desc')) && ((strpos($ret['desc'],'<') !== false) || (strpos($ret['desc'],'>') !== false))) {
+       if ((x($ret,'desc')) && ((strpos($ret['desc'],'<') !== false) || (strpos($ret['desc'],'>') !== false))) {
                $config = HTMLPurifier_Config::createDefault();
                $config->set('Cache.DefinitionImpl', null);
                $purifier = new HTMLPurifier($config);
                $ret['desc'] = html2bbcode($purifier->purify($ret['desc']));
        }
 
-       if((x($ret,'location')) && ((strpos($ret['location'],'<') !== false) || (strpos($ret['location'],'>') !== false))) {
+       if ((x($ret,'location')) && ((strpos($ret['location'],'<') !== false) || (strpos($ret['location'],'>') !== false))) {
                $config = HTMLPurifier_Config::createDefault();
                $config->set('Cache.DefinitionImpl', null);
                $purifier = new HTMLPurifier($config);
                $ret['location'] = html2bbcode($purifier->purify($ret['location']));
        }
 
-       if(x($ret,'start'))
+       if (x($ret,'start'))
                $ret['start'] = datetime_convert('UTC','UTC',$ret['start']);
-       if(x($ret,'finish'))
+       if (x($ret,'finish'))
                $ret['finish'] = datetime_convert('UTC','UTC',$ret['finish']);
 
        return $ret;
@@ -195,32 +196,32 @@ function bbtoevent($s) {
        $ev = array();
 
        $match = '';
-       if (preg_match("/\[event\-summary\](.*?)\[\/event\-summary\]/is",$s,$match)) {
+       if (preg_match("/\[event\-summary\](.*?)\[\/event\-summary\]/is", $s, $match)) {
                $ev['summary'] = $match[1];
        }
 
        $match = '';
-       if (preg_match("/\[event\-description\](.*?)\[\/event\-description\]/is",$s,$match)) {
+       if (preg_match("/\[event\-description\](.*?)\[\/event\-description\]/is", $s, $match)) {
                $ev['desc'] = $match[1];
        }
 
        $match = '';
-       if (preg_match("/\[event\-start\](.*?)\[\/event\-start\]/is",$s,$match)) {
+       if (preg_match("/\[event\-start\](.*?)\[\/event\-start\]/is", $s, $match)) {
                $ev['start'] = $match[1];
        }
 
        $match = '';
-       if (preg_match("/\[event\-finish\](.*?)\[\/event\-finish\]/is",$s,$match)) {
+       if (preg_match("/\[event\-finish\](.*?)\[\/event\-finish\]/is", $s, $match)) {
                $ev['finish'] = $match[1];
        }
 
        $match = '';
-       if (preg_match("/\[event\-location\](.*?)\[\/event\-location\]/is",$s,$match)) {
+       if (preg_match("/\[event\-location\](.*?)\[\/event\-location\]/is", $s, $match)) {
                $ev['location'] = $match[1];
        }
 
        $match = '';
-       if (preg_match("/\[event\-adjust\](.*?)\[\/event\-adjust\]/is",$s,$match)) {
+       if (preg_match("/\[event\-adjust\](.*?)\[\/event\-adjust\]/is", $s, $match)) {
                $ev['adjust'] = $match[1];
        }
 
@@ -269,11 +270,11 @@ function event_store($arr) {
        $arr['edited']  = (($arr['edited'])      ? $arr['edited']          : datetime_convert());
        $arr['type']    = (($arr['type'])        ? $arr['type']            : 'event' );
        $arr['cid']     = ((intval($arr['cid'])) ? intval($arr['cid'])     : 0);
-       $arr['uri']     = (x($arr,'uri')         ? $arr['uri']             : item_new_uri($a->get_hostname(), $arr['uid']));
-       $arr['private'] = ((x($arr,'private'))   ? intval($arr['private']) : 0);
+       $arr['uri']     = (x($arr, 'uri')        ? $arr['uri']             : item_new_uri($a->get_hostname(), $arr['uid']));
+       $arr['private'] = ((x($arr, 'private'))  ? intval($arr['private']) : 0);
        $arr['guid']    = get_guid(32);
 
-       if($arr['cid']) {
+       if ($arr['cid']) {
                $c = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
                        intval($arr['cid']),
                        intval($arr['uid'])
@@ -463,7 +464,7 @@ function event_store($arr) {
 function get_event_strings() {
 
        // First day of the week (0 = Sunday)
-       $firstDay = get_pconfig(local_user(),'system', 'first_day_of_week');
+       $firstDay = get_pconfig(local_user(), 'system', 'first_day_of_week');
        if ($firstDay === false) {
                $firstDay = 0;
        }
@@ -595,7 +596,7 @@ function event_by_id($owner_uid = 0, $event_params, $sql_extra = '') {
  */
 function events_by_date($owner_uid = 0, $event_params, $sql_extra = '') {
        // Only allow events if there is a valid owner_id
-       if($owner_uid == 0) {
+       if ($owner_uid == 0) {
                return;
        }
 
@@ -699,7 +700,7 @@ function process_events($arr) {
  * @return string Content according to selected export format
  */
 function event_format_export ($events, $format = 'ical', $timezone) {
-       if(! ((is_array($events)) && count($events))) {
+       if (! ((is_array($events)) && count($events))) {
                return;
        }
 
@@ -812,7 +813,7 @@ function events_by_uid($uid = 0, $sql_extra = '') {
        }
 
        // The permission condition if no condition was transmitted
-       if($sql_extra == '') {
+       if ($sql_extra == '') {
                $sql_extra = " AND `allow_cid` = '' AND `allow_gid` = '' ";
        }
 
@@ -940,5 +941,4 @@ function widget_events() {
                '$export_csv' => t("Export calendar as csv"),
                '$user' => $user
        ));
-
 }