]> git.mxchange.org Git - friendica.git/commitdiff
Merge branch 'fabrixxm-master'
authorFriendika <info@friendika.com>
Sat, 29 Jan 2011 02:50:20 +0000 (18:50 -0800)
committerFriendika <info@friendika.com>
Sat, 29 Jan 2011 02:50:20 +0000 (18:50 -0800)
Conflicts:
boot.php

1  2 
boot.php
mod/dfrn_notify.php
mod/follow.php
mod/photos.php
mod/settings.php

diff --combined boot.php
index 3cc98cc9b6febe84034872b87d26d5da8d20c68a,d3187648c7859d25e478fc1d94562fc2c421b0b8..223c9416d1c62d4e07dd78ee8d245efbd08d2dc7
+++ b/boot.php
@@@ -3,7 -3,7 +3,7 @@@
  set_time_limit(0);
  
  define ( 'BUILD_ID',               1033   );
 -define ( 'FRIENDIKA_VERSION',      '2.01.1006' );
 +define ( 'FRIENDIKA_VERSION',      '2.10.0902' );
  define ( 'DFRN_PROTOCOL_VERSION',  '2.0'  );
  
  define ( 'EOL',                    "<br />\r\n"     );
@@@ -1655,7 -1655,6 +1655,6 @@@ function attribute_contains($attr,$s) 
  
  if(! function_exists('logger')) {
  function logger($msg,$level = 0) {
        $debugging = get_config('system','debugging');
        $loglevel  = intval(get_config('system','loglevel'));
        $logfile   = get_config('system','logfile');
@@@ -1692,7 -1691,7 +1691,7 @@@ function get_tags($s) 
  
        $s = preg_replace('/\[code\](.*?)\[\/code\]/sm','',$s);
  
 -      if(preg_match_all('/([@#][^ \x0D\x0A,:?]*)([ \x0D\x0A,:?]|$)/',$s,$match)) {
 +      if(preg_match_all('/([@#][^ \x0D\x0A,:?]+)([ \x0D\x0A,:?]|$)/',$s,$match)) {
                foreach($match[1] as $match) {
                        if(strstr($match,"]")) {
                                // we might be inside a bbcode color tag - leave it alone
@@@ -1878,7 -1877,7 +1877,7 @@@ function aes_encrypt($val,$ky
  
  if(! function_exists('linkify')) {
  function linkify($s) {
 -      $s = preg_replace("/(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\.\=\_\~\#\'\%]*)/", ' <a href="$1" >$1</a>', $s);
 +      $s = preg_replace("/(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\.\=\_\~\#\'\%]*)/", ' <a href="$1" target="external-link">$1</a>', $s);
        return($s);
  }}
  
@@@ -2217,15 -2216,29 +2216,39 @@@ function link_compare($a,$b) 
  }}
  
  
 +if(! function_exists('prepare_body')) {
 +function prepare_body($item) {
 +
 +      require_once('include/bbcode.php');
 +
 +      $s = smilies(bbcode($item['body']));
 +
 +      return $s;
++}}
 +
+ /**
+  * 
+  * Wrap calls to proc_close(proc_open()) and call hook
+  * so plugins can take part in process :)
+  * 
+  * args:
+  * $cmd program to run
+  *  next args are passed as $cmd command line
+  * 
+  * e.g.: proc_run("ls","-la","/tmp");
+  * 
+  * $cmd and string args are surrounded with ""
+  */
 +
+ if(! function_exists('run_proc')) {
+ function proc_run($cmd){
+       $args = func_get_args();
+       call_hooks("proc_run", $args);
+       
+       foreach ($args as &$arg){
+               if(is_string($arg)) $arg='"'.$arg.'"';
+       }
+       $cmdline = implode($args," ");
+       proc_close(proc_open($cmdline." &",array(),$foo));
+ }}
  
- }}
 -?>
diff --combined mod/dfrn_notify.php
index f581702d8e23bcce60c3abd5ac327964a7a0c4c2,39d882411076c703661ab1e56a9de5913ac0ede6..f904b06bc5e742740fa2df84782ca520e141c22e
@@@ -11,7 -11,6 +11,7 @@@ function dfrn_notify_post(&$a) 
        $challenge    = ((x($_POST,'challenge'))    ? notags(trim($_POST['challenge'])) : '');
        $data         = ((x($_POST,'data'))         ? $_POST['data']                    : '');
        $key          = ((x($_POST,'key'))          ? $_POST['key']                     : '');
 +      $dissolve     = ((x($_POST,'dissolve'))     ? intval($_POST['dissolve'])        :  0);
  
        $direction = (-1);
        if(strpos($dfrn_id,':') == 1) {
@@@ -52,8 -51,6 +52,8 @@@
        }
                 
  
 +
 +
        $r = q("SELECT `contact`.*, `contact`.`uid` AS `importer_uid`, 
                `contact`.`pubkey` AS `cpubkey`, `contact`.`prvkey` AS `cprvkey`, `user`.* FROM `contact` 
                LEFT JOIN `user` ON `contact`.`uid` = `user`.`uid` 
                //NOTREACHED
        }
  
 +      // $importer in this case contains the contact record for the remote contact joined with the user record of our user. 
 +
        $importer = $r[0];
  
        logger('dfrn_notify: received notify from ' . $importer['name'] . ' for ' . $importer['username']);
        logger('dfrn_notify: data: ' . $data, LOGGER_DATA);
  
 -      if($importer['readonly']) {
 -              // We aren't receiving stuff from this person. But we will quietly ignore them
 -              // rather than a blatant "go away" message.
 -              logger('dfrn_notify: ignoring');
 +      if($dissolve == 1) {
 +
 +              /**
 +               * Relationship is dissolved permanently
 +               */
 +
 +              require_once('include/Contact.php'); 
 +              contact_remove($importer['id']);
 +              logger('relationship dissolved : ' . $importer['name'] . ' dissolved ' . $importer['username']);
                xml_status(0);
 -              //NOTREACHED
 +
        }
  
        if(strlen($key)) {
                logger('rino: decrypted data: ' . $data, LOGGER_DATA);
        }
  
 +
 +
 +
 +      if($importer['readonly']) {
 +              // We aren't receiving stuff from this person. But we will quietly ignore them
 +              // rather than a blatant "go away" message.
 +              logger('dfrn_notify: ignoring');
 +              xml_status(0);
 +              //NOTREACHED
 +      }
 +
        // Consume notification feed. This may differ from consuming a public feed in several ways
        // - might contain email
        // - might contain remote followup to our message
  
                                        $php_path = ((strlen($a->config['php_path'])) ? $a->config['php_path'] : 'php');
  
-                                       proc_close(proc_open("\"$php_path\" \"include/notifier.php\" \"comment-import\" \"$posted_id\" &", 
-                                               array(),$foo));
+                                       //proc_close(proc_open("\"$php_path\" \"include/notifier.php\" \"comment-import\" \"$posted_id\" &", array(),$foo));
+                                       proc_run($php_path,"include/notifier.php","comment-import","$posted_id");
+                                       
                                        if((! $is_like) && ($importer['notify-flags'] & NOTIFY_COMMENT) && (! $importer['self'])) {
                                                require_once('bbcode.php');
                                                $from = stripslashes($datarray['author-name']);
diff --combined mod/follow.php
index b4e50fa451c9f9df4e2785ef9a525e0d23ccf20d,102f46aec6427bee6c02b23127d2257f7912303e..a90ae3f5127b7239994520655ed22d647b3b614f
@@@ -48,8 -48,7 +48,8 @@@ function follow_post(&$a) 
                }
        }
  
 -      $network = 'stat';
 +      $network  = 'stat';
 +      $priority = 0;
  
        if($hcard) {
                $vcard = scrape_vcard($hcard);
@@@ -75,8 -74,8 +75,8 @@@
  
                $ret = scrape_feed($url);
  
 -              if(count($ret) && $ret['feed_atom']) {
 -                      $poll = $ret['feed_atom'];
 +              if(count($ret) && ($ret['feed_atom'] || $ret['feed_rss'])) {
 +                      $poll = ((x($ret,'feed_atom')) ? $ret['feed_atom'] : $ret['feed_rss']);
                        $vcard = array();
                        require_once('simplepie/simplepie.inc');
                    $feed = new SimplePie();
                        if((! $vcard['photo']) && strlen($email))
                                $vcard['photo'] = gravatar_img($email);
                        $network = 'feed';
 -        }
 +                      $priority = 2;
 +              }
        }
  
        logger('follow: poll=' . $poll . ' notify=' . $notify . ' profile=' . $profile . ' vcard=' . print_r($vcard,true));
  
 -
        // do we have enough information?
        
        if(! ((x($vcard['fn'])) && ($poll) && ($profile))) {
        }
        else {
                // create contact record 
 -              $r = q("INSERT INTO `contact` ( `uid`, `created`, `url`, `notify`, `poll`, `name`, `nick`, `photo`, `network`, `rel`, 
 +              $r = q("INSERT INTO `contact` ( `uid`, `created`, `url`, `notify`, `poll`, `name`, `nick`, `photo`, `network`, `rel`, `priority`,
                        `blocked`, `readonly`, `pending` )
                        VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, 0, 0, 0 ) ",
                        intval(local_user()),
                        dbesc($vcard['nick']),
                        dbesc($vcard['photo']),
                        dbesc($network),
 -                      intval(REL_FAN)
 +                      intval(REL_FAN),
 +                      intval($priority)
                );
        }
  
        // pull feed and consume it, which should subscribe to the hub.
  
        $php_path = ((x($a->config,'php_path') && strlen($a->config['php_path'])) ? $a->config['php_path'] : 'php');
-       proc_close(proc_open("\"$php_path\" \"include/poller.php\" \"$contact_id\" &", array(), $foo));
+       //proc_close(proc_open("\"$php_path\" \"include/poller.php\" \"$contact_id\" &", array(), $foo));
+       proc_run($php_path,"include/poller.php","$contact_id");
  
        // create a follow slap
  
diff --combined mod/photos.php
index 2a55fa5e9a81f7b03ceadf7c521f4b44be814abf,11d234bf73bf1a3b44f9cd5a2dcab80d09fc44b6..82060378e666d7fa7a54325ab2076a990a7f11e9
@@@ -1,4 -1,5 +1,4 @@@
  <?php
 -
  require_once('include/Photo.php');
  require_once('include/items.php');
  require_once('include/acl_selectors.php');
@@@ -48,18 -49,9 +48,18 @@@ function photos_init(&$a) 
  
  
  
 -
  function photos_post(&$a) {
  
 +logger('mod/photos.php: photos_post(): begin' , 'LOGGER_DEBUG');
 +
 +foreach($_REQUEST AS $key => $val) {
 +      logger('mod/photos.php: photos_post(): $_REQUEST key: ' . $key . ' val: ' . $val , 'LOGGER_DEBUG');
 +}
 +
 +foreach($_FILES AS $key => $val) {
 +      logger('mod/photos.php: photos_post(): $_FILES key: ' . $key . ' val: ' . $val , 'LOGGER_DEBUG');
 +}
 +
        $can_post  = false;
        $visitor   = 0;
  
                                        // send the notification upstream/downstream as the case may be
  
                                        if($rr['visible'])
-                                               proc_close(proc_open("\"$php_path\" \"include/notifier.php\" \"drop\" \"$drop_id\" & ",
-                                                       array(),$foo));
+                                               //proc_close(proc_open("\"$php_path\" \"include/notifier.php\" \"drop\" \"$drop_id\" & ",array(),$foo));
+                                               proc_run($php_path,"include/notifier.php","drop","$drop_id");
                                }
                        }
                }
                                $php_path = ((strlen($a->config['php_path'])) ? $a->config['php_path'] : 'php');
  
                                if($i[0]['visible'])
-                                       proc_close(proc_open("\"$php_path\" \"include/notifier.php\" \"drop\" \"$drop_id\" & ",
-                                               array(),$foo));
+                                       //proc_close(proc_open("\"$php_path\" \"include/notifier.php\" \"drop\" \"$drop_id\" & ",       array(),$foo));
+                                       proc_run($php_path,"include/notifier.php","drop","$drop_id");
                        }
                }
  
  
                                        $item_id = item_store($arr);
                                        $php_path = ((strlen($a->config['php_path'])) ? $a->config['php_path'] : 'php');
-                                       proc_close(proc_open("\"$php_path\" \"include/notifier.php\" \"tag\" \"$item_id\" & ",
-                                               array(),$foo));
+                                       //proc_close(proc_open("\"$php_path\" \"include/notifier.php\" \"tag\" \"$item_id\" & ",array(),$foo));
+                                       proc_run($php_path,"include/notifier.php","tag","$item_id");
                                }
  
                        }
        }
  
  
 -      // default post action - upload a photo
 +      /**
 +       * default post action - upload a photo
 +       */
  
 -      if(! x($_FILES,'userfile'))
 -              killme();
 +      call_hooks('photo_post_init', $_POST);
  
 -      if($_POST['partitionCount'])
 -              $java_upload = true;
 -      else
 -              $java_upload = false;
 +      /**
 +       * Determine the album to use
 +       */
 +
 +      $album    = notags(trim($_REQUEST['album']));
 +      $newalbum = notags(trim($_REQUEST['newalbum']));
  
 -      $album =  notags(trim($_POST['album']));
 -      $newalbum = notags(trim($_POST['newalbum']));
 +      logger('mod/photos.php: photos_post(): album= ' . $album . ' newalbum= ' . $newalbum , 'LOGGER_DEBUG');
  
        if(! strlen($album)) {
                if(strlen($newalbum))
                        $album = datetime_convert('UTC',date_default_timezone_get(),'now', 'Y');
        }
  
 +      /**
 +       *
 +       * We create a wall item for every photo, but we don't want to
 +       * overwhelm the data stream with a hundred newly uploaded photos.
 +       * So we will make one photo (the first one uploaded to this album)
 +       * visible by default, the rest will become visible over time when and if
 +       * they acquire comments, likes, dislikes, and/or tags 
 +       *
 +       */
 +
        $r = q("SELECT * FROM `photo` WHERE `album` = '%s' AND `uid` = %d",
                dbesc($album),
                intval($page_owner_uid)
        else
                $visible = 0;
  
 +      $str_group_allow   = perms2str(((is_array($_REQUEST['group_allow']))   ? $_REQUEST['group_allow']   : explode(',',$_REQUEST['group_allow'])));
 +      $str_contact_allow = perms2str(((is_array($_REQUEST['contact_allow'])) ? $_REQUEST['contact_allow'] : explode(',',$_REQUEST['contact_allow'])));
 +      $str_group_deny    = perms2str(((is_array($_REQUEST['group_deny']))    ? $_REQUEST['group_deny']    : explode(',',$_REQUEST['group_deny'])));
 +      $str_contact_deny  = perms2str(((is_array($_REQUEST['contact_deny']))  ? $_REQUEST['contact_deny']  : explode(',',$_REQUEST['contact_deny'])));
 +
 +      $ret = array('src' => '', 'filename' => '', 'filesize' => 0);
  
 -      $str_group_allow   = perms2str($_POST['group_allow']);
 -      $str_contact_allow = perms2str($_POST['contact_allow']);
 -      $str_group_deny    = perms2str($_POST['group_deny']);
 -      $str_contact_deny  = perms2str($_POST['contact_deny']);
 +      call_hooks('photo_post_file',$ret);
  
 -      $src               = $_FILES['userfile']['tmp_name'];
 -      $filename          = basename($_FILES['userfile']['name']);
 -      $filesize          = intval($_FILES['userfile']['size']);
 +      if(x($ret,'src') && x($ret,'filesize')) {
 +              $src      = $ret['src'];
 +              $filename = $ret['filename'];
 +              $filesize = $ret['filesize'];
 +      }
 +      else {
 +              $src        = $_FILES['userfile']['tmp_name'];
 +              $filename   = basename($_FILES['userfile']['name']);
 +              $filesize   = intval($_FILES['userfile']['size']);
 +      }
  
        $maximagesize = get_config('system','maximagesize');
  
                return;
        }
  
 +      logger('mod/photos.php: photos_post(): loading the contents of ' . $src , 'LOGGER_DEBUG');
 +
        $imagedata = @file_get_contents($src);
        $ph = new Photo($imagedata);
  
        if(! $ph->is_valid()) {
 +              logger('mod/photos.php: photos_post(): unable to process image' , 'LOGGER_DEBUG');
                notice( t('Unable to process image.') . EOL );
                @unlink($src);
                killme();
  
        @unlink($src);
  
 -      $width = $ph->getWidth();
 +      $width  = $ph->getWidth();
        $height = $ph->getHeight();
  
        $smallest = 0;
        $r = $ph->store($page_owner_uid, $visitor, $photo_hash, $filename, $album, 0 , 0, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny);
  
        if(! $r) {
 +              logger('mod/photos.php: photos_post(): image store failed' , 'LOGGER_DEBUG');
                notice( t('Image upload failed.') . EOL );
                killme();
        }
  
        // Create item container
  
 -
        $arr = array();
  
        $arr['uid']           = $page_owner_uid;
  
        $item_id = item_store($arr);
  
 -      if(! $java_upload) {
 -              goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
 -              return; // NOTREACHED
 -      }
 +      call_hooks('photo_post_end',intval($item_id));
  
 -      killme();
 -      return; // NOTREACHED
 +      // addon uploaders should call "killme()" [e.g. exit] within the photo_post_end hook
 +      // if they do not wish to be redirected
  
 +      goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
 +      // NOTREACHED
  }
  
  
@@@ -769,22 -736,6 +768,22 @@@ function photos_content(&$a) 
                $celeb = ((($a->user['page-flags'] == PAGE_SOAPBOX) || ($a->user['page-flags'] == PAGE_COMMUNITY)) ? true : false);
  
                $albumselect .= '</select>';
 +
 +              $uploader = '';
 +
 +              $ret = array('post_url' => $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'],
 +                              'addon_text' => $uploader,
 +                              'default_upload' => true);
 +
 +
 +              call_hooks('photo_upload_form',$ret);
 +
 +              $default_upload = '<input type="file" name="userfile" />        <div class="photos-upload-submit-wrapper" >
 +              <input type="submit" name="submit" value="' . t('Submit') . '" id="photos-upload-submit" /> </div>';
 +
 +
 + 
 +
                $tpl = load_view_file('view/photos_upload.tpl');
                $o .= replace_macros($tpl,array(
                        '$pagename' => t('Upload Photos'),
                        '$nickname' => $a->data['user']['nickname'],
                        '$newalbum' => t('New album name: '),
                        '$existalbumtext' => t('or existing album name: '),
 -                      '$filestext' => t('Select files to upload: '),
                        '$albumselect' => $albumselect,
                        '$permissions' => t('Permissions'),
                        '$aclselect' => (($visitor) ? '' : populate_acl($a->user, $celeb)),
 -                      '$archive' => $a->get_baseurl() . '/jumploader_z.jar',
 -                      '$nojava' => t('Use the following controls only if the Java uploader [above] fails to launch.'),
 -                      '$uploadurl' => $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'],
 -                      '$submit' => t('Submit')
 +                      '$uploader' => $ret['addon_text'],
 +                      '$default' => (($ret['default_upload']) ? $default_upload : ''),
 +                      '$uploadurl' => $ret['post_url']
 +
                ));
  
                return $o; 
        $o .= paginate($a);
        return $o;
  }
 +
diff --combined mod/settings.php
index 32906d86e7c9017e9b31d91a081da06a94740f37,fd75657c7166fd7eb26f4efd56187fa36425ccf2..dbbac8bdeb3c9b14f2eededb6a74242c64889d29
@@@ -87,14 -87,11 +87,14 @@@ function settings_post(&$a) 
  
        $err = '';
  
 +      $name_change = false;
 +
        if($username != $a->user['username']) {
 -              if(strlen($username) > 40)
 -                      $err .= t(' Please use a shorter name.');
 -              if(strlen($username) < 3)
 -                      $err .= t(' Name too short.');
 +              $name_change = true;
 +              if(strlen($username) > 40)
 +                      $err .= t(' Please use a shorter name.');
 +              if(strlen($username) < 3)
 +                      $err .= t(' Name too short.');
        }
  
        if($email != $a->user['email']) {
                intval(local_user())
        );
  
 +
 +      if($name_change) {
 +              q("UPDATE `contact` SET `name` = '%s', `name-date` = '%s' WHERE `uid` = %d AND `self` = 1 LIMIT 1",
 +                      dbesc($username),
 +                      dbesc(datetime_convert()),
 +                      intval(local_user())
 +              );
 +      }               
 +
        if($old_visibility != $net_publish) {
                // Update global directory in background
                $php_path = ((strlen($a->config['php_path'])) ? $a->config['php_path'] : 'php');
                $url = $_SESSION['my_url'];
                if($url && strlen(get_config('system','directory_submit_url')))
-                       proc_close(proc_open("\"$php_path\" \"include/directory.php\" \"$url\" &",
-                               array(),$foo));
+                       //proc_close(proc_open("\"$php_path\" \"include/directory.php\" \"$url\" &",array(),$foo));
+                       proc_run($php_path,"include/directory.php","$url");
        }
  
        $_SESSION['theme'] = $theme;