]> git.mxchange.org Git - friendica.git/commitdiff
Merge branch 'master', remote-tracking branch 'remotes/upstream/master'
authorSimon L'nu <simon.lnu@gmail.com>
Thu, 15 Mar 2012 05:02:44 +0000 (01:02 -0400)
committerSimon L'nu <simon.lnu@gmail.com>
Thu, 15 Mar 2012 05:02:44 +0000 (01:02 -0400)
* remotes/upstream/master:
  don't allow multiple friends with http/https same person, don't show mail2 coming soon unless person is allowed to have email contacts
  roll protocol version due to ssl_policy settings
  force login to ssl on SSL_POLICY_SELFSIGN
  basic ssl_policy for important modules
  ssl_policy stuff
  revup
  splitted tests into several files
  removed done TODO
  get_tags tests corrected. They test for the right things now.
  addon settings form error
  more work on filer, comment level and file tag removal
  added slack-NS, non-scrolly, slackr-based theme.
  get tags test improved
  splitted test cases.
  changed a test string
  added some tests
  added library and include to .htaccess
  excludes reports from git
  better tests
  added test blueprints, fixed? encoding issues

* master:

37 files changed:
.gitignore
.htaccess
boot.php
build.xml
include/conversation.php
include/items.php
include/nav.php
include/oembed.php
include/text.php
mod/admin.php
mod/contacts.php
mod/dfrn_notify.php
mod/dfrn_request.php
mod/filerm.php [new file with mode: 0644]
mod/item.php
mod/manage.php
mod/message.php
mod/network.php
mod/notifications.php
mod/notify.php
mod/profiles.php
mod/settings.php
tests/autoname_test.php [new file with mode: 0755]
tests/contains_attribute_test.php [new file with mode: 0755]
tests/expand_acl_test.php [new file with mode: 0755]
tests/get_tags_test.php [new file with mode: 0644]
tests/xss_filter_test.php [new file with mode: 0644]
util/db_update.php
view/admin_site.tpl
view/de/strings.php
view/login.tpl
view/logout.tpl
view/theme/duepuntozero/style.css
view/theme/duepuntozero/wall_item.tpl
view/theme/duepuntozero/wallwall_item.tpl
view/theme/slack-NS/style.css [new file with mode: 0755]
view/theme/slack-NS/theme.php [new file with mode: 0755]

index 6302bc1c8bcdd16345778ff3186ca5fec060b4a6..2531fe4cdd2e34cad6c7b7a0541e283817f19ff2 100755 (executable)
@@ -13,6 +13,9 @@ addon
 #ignore documentation, it should be newly built 
 doc/api
 
+#ignore reports, should be generted with every build
+report/
+
 #ignore config files from eclipse, we don't want IDE files in our repository
 .project
 .buildpath
index 1df5096702eb6c5d051e0cf0d88ee356a84ca6a9..5f9531a7ebf83d3462d8b03b7732cc858f40c1ef 100755 (executable)
--- a/.htaccess
+++ b/.htaccess
@@ -5,6 +5,9 @@ AddType audio/ogg .oga
 <FilesMatch "\.(out|log)$">
 Deny from all
 </FilesMatch>
+<Files "(include|library)">
+Deny from all
+</Files>
 
 <IfModule mod_rewrite.c>
   RewriteEngine on
index 749ef6e3f3ae30ee5dc7d3f7497cd9cfaf44f12e..04f36093bfffb38359a9a780999aef30e24c1eba 100755 (executable)
--- a/boot.php
+++ b/boot.php
@@ -9,8 +9,8 @@ require_once('include/nav.php');
 require_once('include/cache.php');
 
 define ( 'FRIENDICA_PLATFORM',     'Friendica');
-define ( 'FRIENDICA_VERSION',      '2.3.1280' );
-define ( 'DFRN_PROTOCOL_VERSION',  '2.22'    );
+define ( 'FRIENDICA_VERSION',      '2.3.1281' );
+define ( 'DFRN_PROTOCOL_VERSION',  '2.23'    );
 define ( 'DB_UPDATE_VERSION',      1131      );
 
 define ( 'EOL',                    "<br />\r\n"     );
@@ -379,11 +379,22 @@ class App {
 
                $scheme = $this->scheme;
 
-               if(x($this->config,'ssl_policy')) {
-                       if(($ssl) || ($this->config['ssl_policy'] == SSL_POLICY_FULL)) 
-                               $scheme = 'https';
-                       if(($this->config['ssl_policy'] == SSL_POLICY_SELFSIGN) && (local_user() || x($_POST,'auth-params')))
+               if((x($this->config,'system')) && (x($this->config['system'],'ssl_policy'))) {
+                       if($this->config['system']['ssl_policy'] == SSL_POLICY_FULL) 
                                $scheme = 'https';
+
+//                     We need to populate the $ssl flag across the entire program before turning this on.
+//                     Basically, we'll have $ssl = true on any links which can only be seen by a logged in user
+//                     (and also the login link). Anything seen by an outsider will have it turned off.
+//                     At present, setting SSL_POLICY_SELFSIGN will only force remote contacts to update their 
+//                     contact links to this site with "http:" if they are currently using "https:"
+
+//                     if($this->config['system']['ssl_policy'] == SSL_POLICY_SELFSIGN) {
+//                             if($ssl)
+//                                     $scheme = 'https';
+//                             else
+//                                     $scheme = 'http';
+//                     }
                }
 
                $this->baseurl = $scheme . "://" . $this->hostname . ((isset($this->path) && strlen($this->path)) ? '/' . $this->path : '' );
@@ -685,6 +696,7 @@ function get_guid($size=16) {
 
 if(! function_exists('login')) {
 function login($register = false, $hiddens=false) {
+       $a = get_app();
        $o = "";
        $reg = false;
        if ($register) {
@@ -704,23 +716,26 @@ function login($register = false, $hiddens=false) {
 
        }
 
+       $dest_url = $a->get_baseurl(true) . '/' . $a->query_string;
 
        $o .= replace_macros($tpl,array(
-               '$logout'        => t('Logout'),
-               '$login'                 => t('Login'),
+
+               '$dest_url'     => $dest_url,
+               '$logout'       => t('Logout'),
+               '$login'        => t('Login'),
                
                '$lname'                => array('username', t('Nickname or Email address: ') , '', ''),
                '$lpassword'    => array('password', t('Password: '), '', ''),
                
                '$openid'               => !$noid,
-               '$lopenid'      => array('openid_url', t('Or login using OpenID: '),'',''),
+               '$lopenid'      => array('openid_url', t('Or login using OpenID: '),'',''),
                
-               '$hiddens'      => $hiddens,
+               '$hiddens'      => $hiddens,
                
-               '$register'             => $reg,
+               '$register'     => $reg,
                
-               '$lostpass'      => t('Forgot your password?'),
-               '$lostlink'      => t('Password Reset'),
+               '$lostpass'     => t('Forgot your password?'),
+               '$lostlink'     => t('Password Reset'),
        ));
 
        call_hooks('login_hook',$o);
index 83c53002643eb5f668d7cfdd6e11076a25b3f17d..a61a5123d7cef5d13bd060cefd4e3300f03add48 100644 (file)
--- a/build.xml
+++ b/build.xml
@@ -1,14 +1,49 @@
 <?xml version="1.0" encoding="UTF-8"?>
 
 <project name="friendica" default="test">
-
+       <!-- ====================================================== -->
+       <!-- Target: clean-test -->
+       <!-- deletes directories with old test reports -->
+       <!-- ====================================================== -->
+       <target name="clean-test">
+               <delete dir="report" />
+       </target>
+       
+       <!-- ====================================================== -->
+       <!-- Target: prepare-test -->
+       <!-- creates directories for test reports -->
+       <!-- ====================================================== -->
+       <target name="prepare-test" depends="clean-test">
+               <mkdir dir="report" />
+       </target>
+       
        <!-- =================================== -->
        <!-- Target: test -->
        <!-- this target runs all test files -->
        <!-- =================================== -->
-
-       <target name="test">
-               <!-- there are no tests by now, so, nothing to do -->
+       <target name="test" depends="prepare-test">
+               <!-- coverage-setup database="./report/coverage-database">
+                       <fileset dir=".">
+                               <include name="**/*.php" />
+                               <exclude name="*test.php"/>
+                               <exclude name="index.php"/>
+                               <exclude name="library/**"/>
+                               <exclude name="doc/**"/>
+                               <exclude name=".."/>
+                       </fileset>
+               </coverage-setup -->
+               <phpunit printsummary="true">
+                       <batchtest>
+                               <fileset dir="tests">
+                                       <include name="*test.php" />
+                               </fileset>
+                       </batchtest>
+                       <formatter type="xml" todir="report" outfile="testlog.xml" />
+               </phpunit>
+               <phpunitreport infile="report/testlog.xml" todir="report" />
+               <!-- coverage-report outfile="report/coverage-database">
+                     <report todir="report" styledir="/home/phing/etc" />
+                   </coverage-report -->
        </target>
 
        <!-- ===================================================== -->
@@ -31,6 +66,9 @@
                <docblox title="Friendica API" destdir="./doc/api">
                        <fileset dir=".">
                                <include name="**/*.php" />
+                               <include name="README"/>
+                               <include name="INSTALL.txt"/>
+                               <include name="LICENSE"/>
                        </fileset>
                </docblox>
        </target>
index a420e9923abc52555b9305c2942326f5dd5c9764..88ecf502b222e4b66867f0115cc82e8410b6f8e3 100755 (executable)
@@ -186,6 +186,8 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
 
        require_once('bbcode.php');
 
+       $ssl_state = ((local_user()) ? true : false);
+
        $profile_owner = 0;
        $page_writeable      = false;
 
@@ -345,7 +347,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
                                        'like' => '',
                                        'dislike' => '',
                                        'comment' => '',
-                                       'conv' => (($preview) ? '' : array('href'=> $a->get_baseurl() . '/display/' . $nickname . '/' . $item['id'], 'title'=> t('View in context'))),
+                                       'conv' => (($preview) ? '' : array('href'=> $a->get_baseurl($ssl_state) . '/display/' . $nickname . '/' . $item['id'], 'title'=> t('View in context'))),
                                        'previewing' => $previewing,
                                        'wait' => t('Please wait'),
                                );
@@ -461,7 +463,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
                                        $comment_lastcollapsed = true;
                                }
 
-                               $redirect_url = $a->get_baseurl() . '/redir/' . $item['cid'] ;
+                               $redirect_url = $a->get_baseurl($ssl_state) . '/redir/' . $item['cid'] ;
 
                                $lock = ((($item['private']) || (($item['uid'] == local_user()) && (strlen($item['allow_cid']) || strlen($item['allow_gid']) 
                                        || strlen($item['deny_cid']) || strlen($item['deny_gid']))))
@@ -543,7 +545,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
                                }
 
                                $edpost = (((($profile_owner == local_user()) && ($toplevelpost) && (intval($item['wall']) == 1)) || ($mode === 'notes'))
-                                               ? array($a->get_baseurl()."/editpost/".$item['id'], t("Edit"))
+                                               ? array($a->get_baseurl($ssl_state)."/editpost/".$item['id'], t("Edit"))
                                                : False);
 
 
@@ -560,25 +562,28 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
                                );
 
                                $star = false;
+                               $filer = false;
+
                                $isstarred = "unstarred";
-                               if ($profile_owner == local_user() && $toplevelpost) {
-                                       $isstarred = (($item['starred']) ? "starred" : "unstarred");
-
-                                       $star = array(
-                                               'do' => t("add star"),
-                                               'undo' => t("remove star"),
-                                               'toggle' => t("toggle star status"),
-                                               'classdo' => (($item['starred']) ? "hidden" : ""),
-                                               'classundo' => (($item['starred']) ? "" : "hidden"),
-                                               'starred' =>  t('starred'),
-                                               'tagger' => t("add tag"),
-                                               'filer' => t("file as"),
-                                               'classtagger' => "",
-                                       );
+                               if ($profile_owner == local_user()) {
+                                       if($toplevelpost) {
+                                               $isstarred = (($item['starred']) ? "starred" : "unstarred");
+
+                                               $star = array(
+                                                       'do' => t("add star"),
+                                                       'undo' => t("remove star"),
+                                                       'toggle' => t("toggle star status"),
+                                                       'classdo' => (($item['starred']) ? "hidden" : ""),
+                                                       'classundo' => (($item['starred']) ? "" : "hidden"),
+                                                       'starred' =>  t('starred'),
+                                                       'tagger' => t("add tag"),
+                                                       'classtagger' => "",
+                                               );
+                                       }
+                                       $filer = t("file as");
                                }
 
 
-
                                $photo = $item['photo'];
                                $thumb = $item['thumb'];
 
@@ -672,6 +677,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
                                        'edpost' => $edpost,
                                        'isstarred' => $isstarred,
                                        'star' => $star,
+                                       'filer' => $filer,
                                        'drop' => $drop,
                                        'vote' => $likebuttons,
                                        'like' => $like,
@@ -693,7 +699,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
 
        $page_template = get_markup_template("conversation.tpl");
        $o .= replace_macros($page_template, array(
-               '$baseurl' => $a->get_baseurl(),
+               '$baseurl' => $a->get_baseurl($ssl_state),
                '$mode' => $mode,
                '$user' => $a->user,
                '$threads' => $threads,
@@ -703,7 +709,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
        return $o;
 }}
 
-function best_link_url($item,&$sparkle) {
+function best_link_url($item,&$sparkle,$ssl_state = false) {
 
        $a = get_app();
 
@@ -715,7 +721,7 @@ function best_link_url($item,&$sparkle) {
        if((local_user()) && (local_user() == $item['uid'])) {
                if(isset($a->contacts) && x($a->contacts,$clean_url)) {
                        if($a->contacts[$clean_url]['network'] === NETWORK_DFRN) {
-                               $best_url = $a->get_baseurl() . '/redir/' . $a->contacts[$clean_url]['id'];
+                               $best_url = $a->get_baseurl($ssl_state) . '/redir/' . $a->contacts[$clean_url]['id'];
                                $sparkle = true;
                        }
                        else
@@ -736,10 +742,14 @@ function best_link_url($item,&$sparkle) {
 if(! function_exists('item_photo_menu')){
 function item_photo_menu($item){
        $a = get_app();
-       
-       if (local_user() && (! count($a->contacts)))
-               load_contact_links(local_user());
 
+       $ssl_state = false;
+
+       if(local_user()) {
+               $ssl_state = true;
+                if(! count($a->contacts))
+                       load_contact_links(local_user());
+       }
        $contact_url="";
        $pm_url="";
        $status_link="";
@@ -747,7 +757,7 @@ function item_photo_menu($item){
        $posts_link="";
 
        $sparkle = false;
-    $profile_link = best_link_url($item,$sparkle);
+    $profile_link = best_link_url($item,$sparkle,$ssl_state);
        if($profile_link === 'mailbox')
                $profile_link = '';
 
@@ -756,7 +766,7 @@ function item_photo_menu($item){
                $status_link = $profile_link . "?url=status";
                $photos_link = $profile_link . "?url=photos";
                $profile_link = $profile_link . "?url=profile";
-               $pm_url = $a->get_baseurl() . '/message/new/' . $cid;
+               $pm_url = $a->get_baseurl($ssl_state) . '/message/new/' . $cid;
        }
        else {
                if(local_user() && local_user() == $item['uid'] && link_compare($item['url'],$item['author-link'])) {
@@ -767,8 +777,8 @@ function item_photo_menu($item){
                }
        }
        if(($cid) && (! $item['self'])) {
-               $contact_url = $a->get_baseurl() . '/contacts/' . $cid;
-               $posts_link = $a->get_baseurl() . '/network/?cid=' . $cid;
+               $contact_url = $a->get_baseurl($ssl_state) . '/contacts/' . $cid;
+               $posts_link = $a->get_baseurl($ssl_state) . '/network/?cid=' . $cid;
        }
 
        $menu = Array(
@@ -804,7 +814,7 @@ function like_puller($a,$item,&$arr,$mode) {
        if((activity_match($item['verb'],$verb)) && ($item['id'] != $item['parent'])) {
                $url = $item['author-link'];
                if((local_user()) && (local_user() == $item['uid']) && ($item['network'] === 'dfrn') && (! $item['self']) && (link_compare($item['author-link'],$item['url']))) {
-                       $url = $a->get_baseurl() . '/redir/' . $item['contact-id'];
+                       $url = $a->get_baseurl(true) . '/redir/' . $item['contact-id'];
                        $sparkle = ' class="sparkle" ';
                }
                if(! ((isset($arr[$item['parent'] . '-l'])) && (is_array($arr[$item['parent'] . '-l']))))
@@ -866,7 +876,7 @@ function status_editor($a,$x, $notes_cid = 0, $popup=false) {
        
        $a->page['htmlhead'] .= replace_macros($tpl, array(
                '$newpost' => 'true',
-               '$baseurl' => $a->get_baseurl(),
+               '$baseurl' => $a->get_baseurl(true),
                '$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'),
                '$geotag' => $geotag,
                '$nickname' => $x['nickname'],
@@ -917,7 +927,7 @@ function status_editor($a,$x, $notes_cid = 0, $popup=false) {
 
        $o .= replace_macros($tpl,array(
                '$return_path' => $a->cmd,
-               '$action' =>  $a->get_baseurl().'/item',
+               '$action' =>  $a->get_baseurl(true) . '/item',
                '$share' => (x($x,'button') ? $x['button'] : t('Share')),
                '$upload' => t('Upload photo'),
                '$shortupload' => t('upload photo'),
@@ -941,7 +951,7 @@ function status_editor($a,$x, $notes_cid = 0, $popup=false) {
                '$ptyp' => (($notes_cid) ? 'note' : 'wall'),
                '$content' => '',
                '$post_id' => '',
-               '$baseurl' => $a->get_baseurl(),
+               '$baseurl' => $a->get_baseurl(true),
                '$defloc' => $x['default_location'],
                '$visitor' => $x['visitor'],
                '$pvisit' => (($notes_cid) ? 'none' : $x['visitor']),
index 70c72ae165315f7975df384bf8805b308600d224..4b1523ff65397c4ac84330002708ea10484716b9 100755 (executable)
@@ -1046,6 +1046,21 @@ function dfrn_deliver($owner,$contact,$atom, $dissolve = false) {
        if(! $rino_enable)
                $rino = 0;
 
+       $ssl_val = intval(get_config('system','ssl_policy'));
+       $ssl_policy = '';
+       switch($ssl_val){
+               case SSL_POLICY_FULL:
+                       $ssl_policy = 'full';
+                       break;
+               case SSL_POLICY_SELFSIGN:
+                       $ssl_policy = 'self';
+                       break;                  
+               case SSL_POLICY_NONE:
+               default:
+                       $ssl_policy = 'none';
+                       break;
+       }
+
        $url = $contact['notify'] . '&dfrn_id=' . $idtosend . '&dfrn_version=' . DFRN_PROTOCOL_VERSION . (($rino) ? '&rino=1' : '');
 
        logger('dfrn_deliver: ' . $url);
@@ -1118,6 +1133,8 @@ function dfrn_deliver($owner,$contact,$atom, $dissolve = false) {
                $postvars['perm'] = 'r';
        }
 
+       $postvars['ssl_policy'] = $ssl_policy;
+
        if($rino && $rino_allowed && (! $dissolve)) {
                $key = substr(random_string(),0,16);
                $data = bin2hex(aes_encrypt($postvars['data'],$key));
index aadfa82fd852c8a20f02a8e4b90c3649f46d0254..e28081839965731b7aa2135e71fb8c3f805c9e27 100755 (executable)
@@ -8,6 +8,8 @@ function nav(&$a) {
         *
         */
 
+       $ssl_state = ((local_user()) ? true : false);
+
        if(!(x($a->page,'nav')))
                $a->page['nav'] = '';
 
@@ -27,7 +29,7 @@ function nav(&$a) {
 
        $myident = ((is_array($a->user) && isset($a->user['nickname'])) ? $a->user['nickname'] . '@' : '');
                
-       $sitelocation = $myident . substr($a->get_baseurl(),strpos($a->get_baseurl(),'//') + 2 );
+       $sitelocation = $myident . substr($a->get_baseurl($ssl_state),strpos($a->get_baseurl($ssl_state),'//') + 2 );
 
 
        // nav links: array of array('href', 'text', 'extra css classes', 'title')
@@ -53,7 +55,7 @@ function nav(&$a) {
                // user info
                $r = q("SELECT micro FROM contact WHERE uid=%d AND self=1", intval($a->user['uid']));
                $userinfo = array(
-                       'icon' => (count($r) ? $r[0]['micro']: $a->get_baseurl()."/images/default-profile-mm.jpg"),
+                       'icon' => (count($r) ? $r[0]['micro']: $a->get_baseurl($ssl_state)."/images/default-profile-mm.jpg"),
                        'name' => $a->user['username'],
                );
                
@@ -76,7 +78,7 @@ function nav(&$a) {
        if(($a->config['register_policy'] == REGISTER_OPEN) && (! local_user()) && (! remote_user()))
                $nav['register'] = array('register',t('Register'), "", t('Create an account'));
 
-       $help_url = $a->get_baseurl() . '/help';
+       $help_url = $a->get_baseurl($ssl_state) . '/help';
 
        if(! get_config('system','hide_help'))
                $nav['help'] = array($help_url, t('Help'), "", t('Help and documentation'));
index 52068efc763fab6599e4d98b2168452c4815f9c6..cc71f9757c9208ffcdcd31ac5d8c4de38a53b24b 100755 (executable)
@@ -1,6 +1,6 @@
 <?php
 function oembed_replacecb($matches){
-       logger('oembedcb');
+//     logger('oembedcb');
        $embedurl=$matches[1];
        $j = oembed_fetch_url($embedurl);
        $s =  oembed_format_object($j);
@@ -14,6 +14,9 @@ function oembed_fetch_url($embedurl){
 
        $txt = Cache::get($embedurl);
 
+       // These media files should now be caught in bbcode.php
+       // left here as a fallback in case this is called from another source
+
        $noexts = array("mp3","mp4","ogg","ogv","oga","ogm","webm");
        $ext = pathinfo(strtolower($embedurl),PATHINFO_EXTENSION);
        
index c44b4d1789bef1fb05697ad66f5c649d88ef9e52..199460d2cf12104841d27085a3d8db9a14c34559 100644 (file)
@@ -874,6 +874,7 @@ function link_compare($a,$b) {
 if(! function_exists('prepare_body')) {
 function prepare_body($item,$attach = false) {
 
+       $a = get_app();
        call_hooks('prepare_body_init', $item); 
 
        $s = prepare_text($item['body']);
@@ -916,7 +917,7 @@ function prepare_body($item,$attach = false) {
        $matches = false;
        $cnt = preg_match_all('/<(.*?)>/',$item['file'],$matches,PREG_SET_ORDER);
        if($cnt) {
-               logger('prepare_text: categories: ' . print_r($matches,true), LOGGER_DEBUG);
+//             logger('prepare_text: categories: ' . print_r($matches,true), LOGGER_DEBUG);
                foreach($matches as $mtch) {
                        if(strlen($x))
                                $x .= ',';
@@ -931,11 +932,11 @@ function prepare_body($item,$attach = false) {
        $x = '';
        $cnt = preg_match_all('/\[(.*?)\]/',$item['file'],$matches,PREG_SET_ORDER);
        if($cnt) {
-               logger('prepare_text: filed_under: ' . print_r($matches,true), LOGGER_DEBUG);
+//             logger('prepare_text: filed_under: ' . print_r($matches,true), LOGGER_DEBUG);
                foreach($matches as $mtch) {
                        if(strlen($x))
-                               $x .= ',';
-                       $x .= file_tag_decode($mtch[1]);
+                               $x .= '&nbsp;&nbsp;&nbsp;';
+                       $x .= file_tag_decode($mtch[1]). ' <a href="' . $a->get_baseurl() . '/filerm/' . $item['id'] . '?f=&term=' . file_tag_decode($mtch[1]) . '" title="' . t('remove') . '" >' . t('[remove]') . '</a>';
                }
                if(strlen($x) && (local_user() == $item['uid']))
                        $s .= '<div class="filesavetags"><span>' . t('Filed under:') . ' </span>' . $x . '</div>'; 
index 93714bb5f9079c695da18bdb63333df38a84ea0a..88ccad6d3e42f9c7f970eba972f04417f132d3bd 100755 (executable)
@@ -37,7 +37,7 @@ function admin_post(&$a){
                                                        $func($a);
                                                }
                                }
-                               goaway($a->get_baseurl() . '/admin/plugins/' . $a->argv[2] );
+                               goaway($a->get_baseurl(true) . '/admin/plugins/' . $a->argv[2] );
                                return; // NOTREACHED
                                break;
                        case 'logs':
@@ -49,7 +49,7 @@ function admin_post(&$a){
                }
        }
 
-       goaway($a->get_baseurl() . '/admin' );
+       goaway($a->get_baseurl(true) . '/admin' );
        return; // NOTREACHED   
 }
 
@@ -68,11 +68,11 @@ function admin_content(&$a) {
 
        // array( url, name, extra css classes )
        $aside = Array(
-               'site'   =>     Array($a->get_baseurl()."/admin/site/", t("Site") , "site"),
-               'users'  =>     Array($a->get_baseurl()."/admin/users/", t("Users") , "users"),
-               'plugins'=>     Array($a->get_baseurl()."/admin/plugins/", t("Plugins") , "plugins"),
-               'themes' =>     Array($a->get_baseurl()."/admin/themes/", t("Themes") , "themes"),
-               'update' =>     Array($a->get_baseurl()."/admin/update/", t("Update") , "update")
+               'site'   =>     Array($a->get_baseurl(true)."/admin/site/", t("Site") , "site"),
+               'users'  =>     Array($a->get_baseurl(true)."/admin/users/", t("Users") , "users"),
+               'plugins'=>     Array($a->get_baseurl(true)."/admin/plugins/", t("Plugins") , "plugins"),
+               'themes' =>     Array($a->get_baseurl(true)."/admin/themes/", t("Themes") , "themes"),
+               'update' =>     Array($a->get_baseurl(true)."/admin/update/", t("Update") , "update")
        );
        
        /* get plugins admin page */
@@ -81,18 +81,18 @@ function admin_content(&$a) {
        $aside['plugins_admin']=Array();
        foreach ($r as $h){
                $plugin =$h['name'];
-               $aside['plugins_admin'][] = Array($a->get_baseurl()."/admin/plugins/".$plugin, $plugin, "plugin");
+               $aside['plugins_admin'][] = Array($a->get_baseurl(true)."/admin/plugins/".$plugin, $plugin, "plugin");
                // temp plugins with admin
                $a->plugins_admin[] = $plugin;
        }
                
-       $aside['logs'] = Array($a->get_baseurl()."/admin/logs/", t("Logs"), "logs");
+       $aside['logs'] = Array($a->get_baseurl(true)."/admin/logs/", t("Logs"), "logs");
 
        $t = get_markup_template("admin_aside.tpl");
        $a->page['aside'] = replace_macros( $t, array(
                        '$admin' => $aside, 
                        '$h_pending' => t('User registrations waiting for confirmation'),
-                       '$admurl'=> $a->get_baseurl()."/admin/"
+                       '$admurl'=> $a->get_baseurl(true)."/admin/"
        ));
 
 
@@ -151,11 +151,7 @@ function admin_page_summary(&$a) {
 
        $r = q("SELECT COUNT(id) as `count` FROM `register`");
        $pending = $r[0]['count'];
-       
-       
-       
-       
-       
+               
        $t = get_markup_template("admin_summary.tpl");
        return replace_macros($t, array(
                '$title' => t('Administration'),
@@ -210,7 +206,7 @@ function admin_page_site_post(&$a){
        $dfrn_only          =   ((x($_POST,'dfrn_only'))            ? True      :       False);
     $ostatus_disabled   =   !((x($_POST,'ostatus_disabled')) ? True  :   False);
        $diaspora_enabled   =   ((x($_POST,'diaspora_enabled')) ? True   :  False);
-
+       $ssl_policy         =   ((x($_POST,'ssl_policy')) ? intval($_POST['ssl_policy']) : 0);
 
        set_config('config','sitename',$sitename);
        if ($banner==""){
@@ -222,6 +218,7 @@ function admin_page_site_post(&$a){
        } else {
                set_config('system','banner', $banner);
        }
+       set_config('system','ssl_policy',$ssl_policy);
        set_config('system','language', $language);
        set_config('system','theme', $theme);
        set_config('system','maximagesize', $maximagesize);
@@ -258,7 +255,7 @@ function admin_page_site_post(&$a){
        set_config('system','diaspora_enabled', $diaspora_enabled);
 
        info( t('Site settings updated.') . EOL);
-       goaway($a->get_baseurl() . '/admin/site' );
+       goaway($a->get_baseurl(true) . '/admin/site' );
        return; // NOTREACHED   
        
 }
@@ -305,6 +302,12 @@ function admin_page_site(&$a) {
                REGISTER_APPROVE => t("Requires approval"),
                REGISTER_OPEN => t("Open")
        ); 
+
+       $ssl_choices = array(
+               SSL_POLICY_NONE => t("No SSL policy, links will track page SSL state"),
+               SSL_POLICY_FULL => t("Force all links to use SSL"),
+               SSL_POLICY_SELFSIGN => t("Self-signed certificate, use SSL for local links only (discouraged)")
+       );
        
        $t = get_markup_template("admin_site.tpl");
        return replace_macros($t, array(
@@ -316,13 +319,13 @@ function admin_page_site(&$a) {
                '$corporate' => t('Policies'),
                '$advanced' => t('Advanced'),
                
-               '$baseurl' => $a->get_baseurl(),
+               '$baseurl' => $a->get_baseurl(true),
                                                                        // name, label, value, help string, extra data...
                '$sitename'             => array('sitename', t("Site name"), htmlentities($a->config['sitename'], ENT_QUOTES), ""),
                '$banner'                       => array('banner', t("Banner/Logo"), $banner, ""),
                '$language'             => array('language', t("System language"), get_config('system','language'), "", $lang_choices),
                '$theme'                        => array('theme', t("System theme"), get_config('system','theme'), t("Default system theme - may be over-ridden by user profiles"), $theme_choices),
-
+               '$ssl_policy'       => array('ssl_policy', t("SSL link policy"), get_config('system','ssl_policy'), t("Determines whether generated links should be forced to use SSL"), $ssl_choices),
                '$maximagesize'         => array('maximagesize', t("Maximum image size"), get_config('system','maximagesize'), t("Maximum size in bytes of uploaded images. Default is 0, which means no limits.")),
 
                '$register_policy'      => array('register_policy', t("Register policy"), $a->config['register_policy'], "", $register_choices),
@@ -389,7 +392,7 @@ function admin_page_users_post(&$a){
                        user_deny($hash);
                }
        }
-       goaway($a->get_baseurl() . '/admin/users' );
+       goaway($a->get_baseurl(true) . '/admin/users' );
        return; // NOTREACHED   
 }
  
@@ -399,7 +402,7 @@ function admin_page_users(&$a){
                $user = q("SELECT * FROM `user` WHERE `uid`=%d", intval($uid));
                if (count($user)==0){
                        notice( 'User not found' . EOL);
-                       goaway($a->get_baseurl() . '/admin/users' );
+                       goaway($a->get_baseurl(true) . '/admin/users' );
                        return; // NOTREACHED                                           
                }               
                switch($a->argv[2]){
@@ -418,7 +421,7 @@ function admin_page_users(&$a){
                                notice( sprintf( ($user[0]['blocked']?t("User '%s' unblocked"):t("User '%s' blocked")) , $user[0]['username']) . EOL);
                        }; break;
                }
-               goaway($a->get_baseurl() . '/admin/users' );
+               goaway($a->get_baseurl(true) . '/admin/users' );
                return; // NOTREACHED   
                
        }
@@ -497,7 +500,7 @@ function admin_page_users(&$a){
 
 
                // values //
-               '$baseurl' => $a->get_baseurl(),
+               '$baseurl' => $a->get_baseurl(true),
 
                '$pending' => $pending,
                '$users' => $users,
@@ -536,7 +539,7 @@ function admin_page_plugins(&$a){
                                info( sprintf( t("Plugin %s enabled."), $plugin ) );
                        }
                        set_config("system","addon", implode(", ",$a->plugins));
-                       goaway($a->get_baseurl() . '/admin/plugins' );
+                       goaway($a->get_baseurl(true) . '/admin/plugins' );
                        return; // NOTREACHED   
                }
                // display plugin details
@@ -569,7 +572,7 @@ function admin_page_plugins(&$a){
                        '$page' => t('Plugins'),
                        '$toggle' => t('Toggle'),
                        '$settings' => t('Settings'),
-                       '$baseurl' => $a->get_baseurl(),
+                       '$baseurl' => $a->get_baseurl(true),
                
                        '$plugin' => $plugin,
                        '$status' => $status,
@@ -607,7 +610,7 @@ function admin_page_plugins(&$a){
                '$title' => t('Administration'),
                '$page' => t('Plugins'),
                '$submit' => t('Submit'),
-               '$baseurl' => $a->get_baseurl(),
+               '$baseurl' => $a->get_baseurl(true),
                '$function' => 'plugins',       
                '$plugins' => $plugins
        ));
@@ -713,7 +716,7 @@ function admin_page_themes(&$a){
                                info( sprintf('Theme %s disabled.',$theme));
 
                        set_config('system','allowed_themes',$s);
-                       goaway($a->get_baseurl() . '/admin/themes' );
+                       goaway($a->get_baseurl(true) . '/admin/themes' );
                        return; // NOTREACHED   
                }
 
@@ -742,7 +745,7 @@ function admin_page_themes(&$a){
                        '$page' => t('Themes'),
                        '$toggle' => t('Toggle'),
                        '$settings' => t('Settings'),
-                       '$baseurl' => $a->get_baseurl(),
+                       '$baseurl' => $a->get_baseurl(true),
                
                        '$plugin' => $theme,
                        '$status' => $status,
@@ -774,7 +777,7 @@ function admin_page_themes(&$a){
                '$title' => t('Administration'),
                '$page' => t('Themes'),
                '$submit' => t('Submit'),
-               '$baseurl' => $a->get_baseurl(),
+               '$baseurl' => $a->get_baseurl(true),
                '$function' => 'themes',
                '$plugins' => $xthemes,
                '$experimental' => t('[Experimental]'),
@@ -802,7 +805,7 @@ function admin_page_logs_post(&$a) {
        }
 
        info( t("Log settings updated.") );
-       goaway($a->get_baseurl() . '/admin/logs' );
+       goaway($a->get_baseurl(true) . '/admin/logs' );
        return; // NOTREACHED   
 }
  
@@ -856,7 +859,7 @@ readable.");
                '$submit' => t('Submit'),
                '$clear' => t('Clear'),
                '$data' => $data,
-               '$baseurl' => $a->get_baseurl(),
+               '$baseurl' => $a->get_baseurl(true),
                '$logname' =>  get_config('system','logfile'),
                
                                                                        // name, label, value, help string, extra data...
@@ -901,7 +904,7 @@ function admin_page_remoteupdate(&$a) {
        
        $tpl = get_markup_template("admin_remoteupdate.tpl");
        return replace_macros($tpl, array(
-               '$baseurl' => $a->get_baseurl(),
+               '$baseurl' => $a->get_baseurl(true),
                '$submit' => t("Update now"),
                '$close' => t("Close"),
                '$localversion' => FRIENDICA_VERSION,
index 38ca570ddfd1bf5df6902a9f53b38deb2fa18034..78c8d40928c2b6461d2faa35539356a9d1128ee2 100755 (executable)
@@ -61,7 +61,7 @@ function contacts_post(&$a) {
 
        if(! count($orig_record)) {
                notice( t('Could not access contact record.') . EOL);
-               goaway($a->get_baseurl() . '/contacts');
+               goaway($a->get_baseurl(true) . '/contacts');
                return; // NOTREACHED
        }
 
@@ -141,7 +141,7 @@ function contacts_content(&$a) {
 
                if(! count($orig_record)) {
                        notice( t('Could not access contact record.') . EOL);
-                       goaway($a->get_baseurl() . '/contacts');
+                       goaway($a->get_baseurl(true) . '/contacts');
                        return; // NOTREACHED
                }
 
@@ -149,7 +149,7 @@ function contacts_content(&$a) {
 
                        // pull feed and consume it, which should subscribe to the hub.
                        proc_run('php',"include/poller.php","$contact_id");
-                       goaway($a->get_baseurl() . '/contacts/' . $contact_id);
+                       goaway($a->get_baseurl(true) . '/contacts/' . $contact_id);
                        // NOTREACHED
                }
 
@@ -164,7 +164,7 @@ function contacts_content(&$a) {
                                //notice( t('Contact has been ') . (($blocked) ? t('blocked') : t('unblocked')) . EOL );
                                info( (($blocked) ? t('Contact has been blocked') : t('Contact has been unblocked')) . EOL );
                        }
-                       goaway($a->get_baseurl() . '/contacts/' . $contact_id);
+                       goaway($a->get_baseurl(true) . '/contacts/' . $contact_id);
                        return; // NOTREACHED
                }
 
@@ -178,7 +178,7 @@ function contacts_content(&$a) {
                        if($r) {
                                info( (($readonly) ? t('Contact has been ignored') : t('Contact has been unignored')) . EOL );
                        }
-                       goaway($a->get_baseurl() . '/contacts/' . $contact_id);
+                       goaway($a->get_baseurl(true) . '/contacts/' . $contact_id);
                        return; // NOTREACHED
                }
 
@@ -220,9 +220,9 @@ function contacts_content(&$a) {
                        contact_remove($orig_record[0]['id']);
                        info( t('Contact has been removed.') . EOL );
                        if(x($_SESSION,'return_url'))
-                               goaway($a->get_baseurl() . '/' . $_SESSION['return_url']);
+                               goaway($a->get_baseurl(true) . '/' . $_SESSION['return_url']);
                        else
-                               goaway($a->get_baseurl() . '/contacts');
+                               goaway($a->get_baseurl(true) . '/contacts');
                        return; // NOTREACHED
                }
        }
@@ -233,7 +233,7 @@ function contacts_content(&$a) {
                $contact = $a->data['contact'];
 
                $tpl = get_markup_template('contact_head.tpl');
-               $a->page['htmlhead'] .= replace_macros($tpl, array('$baseurl' => $a->get_baseurl()));
+               $a->page['htmlhead'] .= replace_macros($tpl, array('$baseurl' => $a->get_baseurl(true)));
 
                require_once('include/contact_selectors.php');
 
@@ -295,17 +295,17 @@ function contacts_content(&$a) {
                $tabs = array(
                        array(
                                'label' => (($contact['blocked']) ? t('Unblock') : t('Block') ),
-                               'url'   => $a->get_baseurl() . '/contacts/' . $contact_id . '/block',
+                               'url'   => $a->get_baseurl(true) . '/contacts/' . $contact_id . '/block',
                                'sel'   => '',
                        ),
                        array(
                                'label' => (($contact['readonly']) ? t('Unignore') : t('Ignore') ),
-                               'url'   => $a->get_baseurl() . '/contacts/' . $contact_id . '/ignore',
+                               'url'   => $a->get_baseurl(true) . '/contacts/' . $contact_id . '/ignore',
                                'sel'   => '',
                        ),
                        array(
                                'label' => t('Repair'),
-                               'url'   => $a->get_baseurl() . '/crepair/' . $contact_id,
+                               'url'   => $a->get_baseurl(true) . '/crepair/' . $contact_id,
                                'sel'   => '',
                        )
                );
@@ -322,7 +322,7 @@ function contacts_content(&$a) {
                        '$lbl_info1' => t('Contact Information / Notes'),
                        '$infedit' => t('Edit contact notes'),
                        '$common_text' => $common_text,
-                       '$common_link' => $a->get_baseurl() . '/common/' . $contact['id'],
+                       '$common_link' => $a->get_baseurl(true) . '/common/' . $contact['id'],
                        '$all_friends' => $all_friends,
                        '$relation_text' => $relation_text,
                        '$visit' => sprintf( t('Visit %s\'s profile [%s]'),$contact['name'],$contact['url']),
@@ -397,30 +397,30 @@ function contacts_content(&$a) {
        $tabs = array(
                array(
                        'label' => t('All Contacts'),
-                       'url'   => $a->get_baseurl() . '/contacts/all', 
+                       'url'   => $a->get_baseurl(true) . '/contacts/all', 
                        'sel'   => ($all) ? 'active' : '',
                ),
                array(
                        'label' => t('Unblocked Contacts'),
-                       'url'   => $a->get_baseurl() . '/contacts',
+                       'url'   => $a->get_baseurl(true) . '/contacts',
                        'sel'   => ((! $all) && (! $blocked) && (! $hidden) && (! $search) && (! $nets) && (! $ignored)) ? 'active' : '',
                ),
 
                array(
                        'label' => t('Blocked Contacts'),
-                       'url'   => $a->get_baseurl() . '/contacts/blocked',
+                       'url'   => $a->get_baseurl(true) . '/contacts/blocked',
                        'sel'   => ($blocked) ? 'active' : '',
                ),
 
                array(
                        'label' => t('Ignored Contacts'),
-                       'url'   => $a->get_baseurl() . '/contacts/ignored',
+                       'url'   => $a->get_baseurl(true) . '/contacts/ignored',
                        'sel'   => ($ignored) ? 'active' : '',
                ),
 
                array(
                        'label' => t('Hidden Contacts'),
-                       'url'   => $a->get_baseurl() . '/contacts/hidden',
+                       'url'   => $a->get_baseurl(true) . '/contacts/hidden',
                        'sel'   => ($hidden) ? 'active' : '',
                ),
 
index 0c0c27e3d67a465c2118bf2db20ead142d511488..3dbdc5b328953a55c142340bd00956c96c44b669 100755 (executable)
@@ -14,6 +14,7 @@ function dfrn_notify_post(&$a) {
        $key          = ((x($_POST,'key'))          ? $_POST['key']                     : '');
        $dissolve     = ((x($_POST,'dissolve'))     ? intval($_POST['dissolve'])        :  0);
        $perm         = ((x($_POST,'perm'))         ? notags(trim($_POST['perm']))      : 'r');
+       $ssl_policy   = ((x($_POST,'ssl_policy'))   ? notags(trim($_POST['ssl_policy'])): 'none');
 
        $writable = (-1);
        if($dfrn_version >= 2.21) {
@@ -94,6 +95,65 @@ function dfrn_notify_post(&$a) {
                $importer['writable'] = $writable;
        }
 
+       // if contact's ssl policy changed, update our links
+
+       $ssl_changed = false;
+
+       if($ssl_policy == 'self' && strstr($importer['url'],'https:')) {
+               $ssl_changed = true;
+               $importer['url']     =  str_replace('https:','http:',$importer['url']);
+               $importer['nurl']    = normalise_link($importer['url']);
+               $importer['photo']   =  str_replace('https:','http:',$importer['photo']);
+               $importer['thumb']   =  str_replace('https:','http:',$importer['thumb']);
+               $importer['micro']   =  str_replace('https:','http:',$importer['micro']);
+               $importer['request'] =  str_replace('https:','http:',$importer['request']);
+               $importer['notify']  =  str_replace('https:','http:',$importer['notify']);
+               $importer['poll']    =  str_replace('https:','http:',$importer['poll']);
+               $importer['confirm'] =  str_replace('https:','http:',$importer['confirm']);
+               $importer['poco']    =  str_replace('https:','http:',$importer['poco']);
+       }
+
+       if($ssl_policy == 'full' && strstr($importer['url'],'http:')) {
+               $ssl_changed = true;
+               $importer['url']     =  str_replace('http:','https:',$importer['url']);
+               $importer['nurl']    = normalise_link($importer['url']);
+               $importer['photo']   =  str_replace('http:','https:',$importer['photo']);
+               $importer['thumb']   =  str_replace('http:','https:',$importer['thumb']);
+               $importer['micro']   =  str_replace('http:','https:',$importer['micro']);
+               $importer['request'] =  str_replace('http:','https:',$importer['request']);
+               $importer['notify']  =  str_replace('http:','https:',$importer['notify']);
+               $importer['poll']    =  str_replace('http:','https:',$importer['poll']);
+               $importer['confirm'] =  str_replace('http:','https:',$importer['confirm']);
+               $importer['poco']    =  str_replace('http:','https:',$importer['poco']);
+       }
+
+       if($ssl_changed) {
+               q("update contact set 
+                       url = '%s', 
+                       nurl = '%s',
+                       photo = '%s',
+                       thumb = '%s',
+                       micro = '%s',
+                       request = '%s',
+                       notify = '%s',
+                       poll = '%s',
+                       confirm = '%s',
+                       poco = '%s'
+                       where id = %d limit 1",
+                       dbesc($importer['url']),
+                       dbesc($importer['nurl']),
+                       dbesc($importer['photo']),
+                       dbesc($importer['thumb']),
+                       dbesc($importer['micro']),
+                       dbesc($importer['request']),
+                       dbesc($importer['notify']),
+                       dbesc($importer['poll']),
+                       dbesc($importer['confirm']),
+                       dbesc($importer['poco']),
+                       intval($importer['id'])
+               );
+       }
+                       
        logger('dfrn_notify: received notify from ' . $importer['name'] . ' for ' . $importer['username']);
        logger('dfrn_notify: data: ' . $data, LOGGER_DATA);
 
index 4acb5c9bb51905d01f8d970cded159551c0f1c12..c2d37dac7e094d625a085d7571d80bac58b89387 100755 (executable)
@@ -77,9 +77,10 @@ function dfrn_request_post(&$a) {
                                 * Lookup the contact based on their URL (which is the only unique thing we have at the moment)
                                 */
        
-                               $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `url` = '%s' AND `self` = 0 LIMIT 1",
+                               $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND (`url` = '%s' OR `nurl` = '%s') AND `self` = 0 LIMIT 1",
                                        intval(local_user()),
-                                       dbesc($dfrn_url)
+                                       dbesc($dfrn_url),
+                                       dbesc(normalise_link($dfrn_url))
                                );
        
                                if(count($r)) {
@@ -668,7 +669,21 @@ function dfrn_request_content(&$a) {
 
                $page_desc .= t("Please enter your 'Identity Address' from one of the following supported communications networks:");
 
-               $emailnet = t("<strike>Connect as an email follower</strike> \x28Coming soon\x29");
+               // see if we are allowed to have NETWORK_MAIL2 contacts
+
+               $mail_disabled = ((function_exists('imap_open') && (! get_config('system','imap_disabled'))) ? 0 : 1);
+               if(get_config('system','dfrn_only'))
+                       $mail_disabled = 1;
+
+               if(! $mail_disabled) {
+                       $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1",
+                               intval($a->profile['uid'])
+                       );
+                       if(! count($r))
+                               $mail_disabled = 1;
+               }
+
+               $emailnet = (($mail_disabled) ? '' : t("<strike>Connect as an email follower</strike> \x28Coming soon\x29"));
 
                $invite_desc = t('If you are not yet a member of the free social web, <a href="http://dir.friendica.com/siteinfo">follow this link to find a public Friendica site and join us today</a>.');
 
diff --git a/mod/filerm.php b/mod/filerm.php
new file mode 100644 (file)
index 0000000..66b684d
--- /dev/null
@@ -0,0 +1,21 @@
+<?php
+
+function filerm_content(&$a) {
+
+       if(! local_user()) {
+               killme();
+       }
+
+       $term = notags(trim($_GET['term']));
+       $item_id = (($a->argc > 1) ? notags(trim($a->argv[1])) : 0);
+
+       logger('filerm: tag ' . $term . ' item ' . $item_id);
+
+       if($item_id && strlen($term))
+               file_tag_unsave_file(local_user(),$item_id,$term);
+
+       if(x($_SESSION,'return_url'))
+               goaway($a->get_baseurl() . '/' . $_SESSION['return_url']);
+       
+       killme();
+}
index 6f31f917f2b246461c115e8cfcbe73cc71babac5..98cfb4338512bc57d7de2fb6ea5d44658975363d 100755 (executable)
@@ -425,110 +425,7 @@ function item_post(&$a) {
 
        if(count($tags)) {
                foreach($tags as $tag) {
-                       
-                       if(isset($profile))
-                               unset($profile);
-                       if(strpos($tag,'#') === 0) {
-                               if(strpos($tag,'[url='))
-                                       continue;
-                               $basetag = str_replace('_',' ',substr($tag,1));
-                               $body = str_replace($tag,'#[url=' . $a->get_baseurl() . '/search?search=' . rawurlencode($basetag) . ']' . $basetag . '[/url]',$body);
-
-                               $newtag = '#[url=' . $a->get_baseurl() . '/search?search=' . rawurlencode($basetag) . ']' . $basetag . '[/url]';
-                               if(! stristr($str_tags,$newtag)) {
-                                       if(strlen($str_tags))
-                                               $str_tags .= ',';
-                                       $str_tags .= $newtag;
-                               } 
-                               continue;
-                       }
-                       if(strpos($tag,'@') === 0) {
-                               if(strpos($tag,'[url='))
-                                       continue;
-                               $stat = false;
-                               $name = substr($tag,1);
-                               if((strpos($name,'@')) || (strpos($name,'http://'))) {
-                                       $newname = $name;
-                                       $links = @lrdd($name);
-                                       if(count($links)) {
-                                               foreach($links as $link) {
-                                                       if($link['@attributes']['rel'] === 'http://webfinger.net/rel/profile-page')
-                                       $profile = $link['@attributes']['href'];
-                                                       if($link['@attributes']['rel'] === 'salmon') {
-                                                               if(strlen($inform))
-                                                                       $inform .= ',';
-                                       $inform .= 'url:' . str_replace(',','%2c',$link['@attributes']['href']);
-                                                       }
-                                               }
-                                       }
-                               }
-                               else {
-                                       $newname = $name;
-                                       $alias = '';
-                                       $tagcid = 0;
-                                       if(strrpos($newname,'+')) {
-                                               $tagcid = intval(substr($newname,strrpos($newname,'+') + 1));
-                                               if(strpos($name,' '))
-                                                       $name = substr($name,0,strpos($name,' '));
-                                       }       
-                                       if($tagcid) {
-                                               $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
-                                                       intval($tagcid),
-                                                       intval($profile_uid)
-                                               );
-                                       }
-                                       elseif(strstr($name,'_') || strstr($name,' ')) {
-                                               $newname = str_replace('_',' ',$name);
-                                               $r = q("SELECT * FROM `contact` WHERE `name` = '%s' AND `uid` = %d LIMIT 1",
-                                                       dbesc($newname),
-                                                       intval($profile_uid)
-                                               );
-                                       }
-                                       else {
-                                               $r = q("SELECT * FROM `contact` WHERE `attag` = '%s' OR `nick` = '%s' AND `uid` = %d ORDER BY `attag` DESC LIMIT 1",
-                                                       dbesc($name),
-                                                       dbesc($name),
-                                                       intval($profile_uid)
-                                               );
-                                       }
-                                       if(count($r)) {
-                                               $profile = $r[0]['url'];
-                                               if($r[0]['network'] === 'stat') {
-                                                       $newname = $r[0]['nick'];
-                                                       $stat = true;
-                                                       if($r[0]['alias'])
-                                                               $alias = $r[0]['alias'];
-                                               }
-                                               else
-                                                       $newname = $r[0]['name'];
-                                               if(strlen($inform))
-                                                       $inform .= ',';
-                                               $inform .= 'cid:' . $r[0]['id'];
-                                       }
-                               }
-                               if($profile) {
-                                       $body = str_replace('@' . $name, '@' . '[url=' . $profile . ']' . $newname      . '[/url]', $body);
-                                       $profile = str_replace(',','%2c',$profile);
-                                       $newtag = '@[url=' . $profile . ']' . $newname  . '[/url]';
-                                       if(! stristr($str_tags,$newtag)) {
-                                               if(strlen($str_tags))
-                                                       $str_tags .= ',';
-                                               $str_tags .= $newtag;
-                                       }
-
-                                       // Status.Net seems to require the numeric ID URL in a mention if the person isn't 
-                                       // subscribed to you. But the nickname URL is OK if they are. Grrr. We'll tag both. 
-
-                                       if(strlen($alias)) {
-                                               $newtag = '@[url=' . $alias . ']' . $newname    . '[/url]';
-                                               if(! stristr($str_tags,$newtag)) {
-                                                       if(strlen($str_tags))
-                                                               $str_tags .= ',';
-                                                       $str_tags .= $newtag;
-                                               }
-                                       }
-                               }
-                       }
+                       handle_tag($a, $body, $inform, $str_tags, $profile_uid, $tag); 
                }
        }
 
@@ -922,3 +819,142 @@ function item_content(&$a) {
                drop_item($a->argv[2]);
        }
 }
+
+/**
+ * This function removes the tag $tag from the text $body and replaces it with 
+ * the appropiate link. 
+ * 
+ * @param unknown_type $body the text to replace the tag in
+ * @param unknown_type $inform a comma-seperated string containing everybody to inform
+ * @param unknown_type $str_tags string to add the tag to
+ * @param unknown_type $profile_uid
+ * @param unknown_type $tag the tag to replace
+ */
+function handle_tag($a, &$body, &$inform, &$str_tags, $profile_uid, $tag) {
+       //is it a hash tag? 
+       if(strpos($tag,'#') === 0) {\r
+               //if the tag is replaced...
+               if(strpos($tag,'[url='))
+                       //...do nothing\r
+                       continue;
+               //base tag has the tags name only\r
+               $basetag = str_replace('_',' ',substr($tag,1));\r
+               //create text for link
+               $newtag = '#[url=' . $a->get_baseurl() . '/search?search=' . rawurlencode($basetag) . ']' . $basetag . '[/url]';
+               //replace tag by the link\r
+               $body = str_replace($tag, $newtag, $body);\r
+       
+               //is the link already in str_tags?\r
+               if(! stristr($str_tags,$newtag)) {\r
+                       //append or set str_tags
+                       if(strlen($str_tags))\r
+                               $str_tags .= ',';\r
+                       $str_tags .= $newtag;\r
+               }\r
+               return;\r
+       }
+       //is it a person tag? \r
+       if(strpos($tag,'@') === 0) {\r
+               //is it already replaced? 
+               if(strpos($tag,'[url='))\r
+                       continue;\r
+               $stat = false;\r
+               //get the person's name
+               $name = substr($tag,1);
+               //is it a link or a full dfrn address? \r
+               if((strpos($name,'@')) || (strpos($name,'http://'))) {\r
+                       $newname = $name;\r
+                       //get the profile links
+                       $links = @lrdd($name);\r
+                       if(count($links)) {\r
+                               //for all links, collect how is to inform and how's profile is to link
+                               foreach($links as $link) {\r
+                                       if($link['@attributes']['rel'] === 'http://webfinger.net/rel/profile-page')\r
+                                               $profile = $link['@attributes']['href'];\r
+                                       if($link['@attributes']['rel'] === 'salmon') {\r
+                                               if(strlen($inform))\r
+                                                       $inform .= ',';\r
+                                               $inform .= 'url:' . str_replace(',','%2c',$link['@attributes']['href']);\r
+                                       }\r
+                               }\r
+                       }\r
+               } else { //if it is a name rather than an address\r
+                       $newname = $name;\r
+                       $alias = '';\r
+                       $tagcid = 0;
+                       //is it some generated name?\r
+                       if(strrpos($newname,'+')) {\r
+                               //get the id
+                               $tagcid = intval(substr($newname,strrpos($newname,'+') + 1));\r
+                               //remove the next word from tag's name
+                               if(strpos($name,' ')) {\r
+                                       $name = substr($name,0,strpos($name,' '));
+                               }\r
+                       }
+                       if($tagcid) { //if there was an id
+                               //select contact with that id from the logged in user's contact list\r
+                               $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",\r
+                                               intval($tagcid),\r
+                                               intval($profile_uid)
+                               );\r
+                       } elseif(strstr($name,'_') || strstr($name,' ')) { //no id
+                               //get the real name\r
+                               $newname = str_replace('_',' ',$name);\r
+                               //select someone from this user's contacts by name
+                               $r = q("SELECT * FROM `contact` WHERE `name` = '%s' AND `uid` = %d LIMIT 1",\r
+                                               dbesc($newname),\r
+                                               intval($profile_uid)\r
+                               );\r
+                       } else {
+                               //select someone by attag or nick and the name passed in\r
+                               $r = q("SELECT * FROM `contact` WHERE `attag` = '%s' OR `nick` = '%s' AND `uid` = %d ORDER BY `attag` DESC LIMIT 1",\r
+                                               dbesc($name),\r
+                                               dbesc($name),\r
+                                               intval($profile_uid)\r
+                               );\r
+                       }
+                       //$r is set, if someone could be selected\r
+                       if(count($r)) {\r
+                               $profile = $r[0]['url'];
+                               //set newname to nick, find alias\r
+                               if($r[0]['network'] === 'stat') {\r
+                                       $newname = $r[0]['nick'];\r
+                                       $stat = true;\r
+                                       if($r[0]['alias'])\r
+                                               $alias = $r[0]['alias'];\r
+                               }\r
+                               else\r
+                                       $newname = $r[0]['name'];\r
+                               //add person's id to $inform
+                               if(strlen($inform))\r
+                                       $inform .= ',';\r
+                               $inform .= 'cid:' . $r[0]['id'];\r
+                       }\r
+               }
+               //if there is an url for this persons profile\r
+               if(isset($profile)) {\r
+                       //create profile link
+                       $profile = str_replace(',','%2c',$profile);\r
+                       $newtag = '@[url=' . $profile . ']' . $newname  . '[/url]';\r
+                       $body = str_replace('@' . $name, $newtag, $body);\r
+                       //append tag to str_tags
+                       if(! stristr($str_tags,$newtag)) {\r
+                               if(strlen($str_tags))\r
+                                       $str_tags .= ',';\r
+                               $str_tags .= $newtag;\r
+                       }\r
+       \r
+                       // Status.Net seems to require the numeric ID URL in a mention if the person isn't\r
+                       // subscribed to you. But the nickname URL is OK if they are. Grrr. We'll tag both.\r
+       \r
+                       if(strlen($alias)) {\r
+                               $newtag = '@[url=' . $alias . ']' . $newname    . '[/url]';\r
+                               if(! stristr($str_tags,$newtag)) {\r
+                                       if(strlen($str_tags))\r
+                                               $str_tags .= ',';\r
+                                       $str_tags .= $newtag;\r
+                               }\r
+                       }\r
+               }\r
+       }
+}
index ec4dcd8a00922e0125aca2ae3a690df2a4a6153e..84dfa6917c3529c05293fcf39d83c06d692b1dfb 100755 (executable)
@@ -74,7 +74,7 @@ function manage_post(&$a) {
        if($limited_id)
                $_SESSION['submanage'] = $original_id;
 
-       goaway($a->get_baseurl() . '/profile/' . $a->user['nickname']);
+       goaway($a->get_baseurl(true) . '/profile/' . $a->user['nickname']);
        // NOTREACHED
 }
 
index 65f692f3d52767adab1837cc4dc6bdef1f39958e..55e313776d6c0897f0cf2f426377c19891c1c048 100755 (executable)
@@ -56,23 +56,23 @@ function message_content(&$a) {
                return;
        }
 
-       $myprofile = $a->get_baseurl() . '/profile/' . $a->user['nickname'];
+       $myprofile = $a->get_baseurl(true) . '/profile/' . $a->user['nickname'];
 
 
        $tabs = array(
                array(
                        'label' => t('Inbox'),
-                       'url'=> $a->get_baseurl() . '/message',
+                       'url'=> $a->get_baseurl(true) . '/message',
                        'sel'=> (($a->argc == 1) ? 'active' : ''),
                ),
                array(
                        'label' => t('Outbox'),
-                       'url' => $a->get_baseurl() . '/message/sent',
+                       'url' => $a->get_baseurl(true) . '/message/sent',
                        'sel'=> (($a->argv[1] == 'sent') ? 'active' : ''),
                ),
                array(
                        'label' => t('New Message'),
-                       'url' => $a->get_baseurl() . '/message/new',
+                       'url' => $a->get_baseurl(true) . '/message/new',
                        'sel'=> (($a->argv[1] == 'new') ? 'active' : ''),
                ),
        );
@@ -99,7 +99,7 @@ function message_content(&$a) {
                        if($r) {
                                info( t('Message deleted.') . EOL );
                        }
-                       goaway($a->get_baseurl() . '/message' );
+                       goaway($a->get_baseurl(true) . '/message' );
                }
                else {
                        $r = q("SELECT `parent-uri`,`convid` FROM `mail` WHERE `id` = %d AND `uid` = %d LIMIT 1",
@@ -129,7 +129,7 @@ function message_content(&$a) {
                                if($r)
                                        info( t('Conversation removed.') . EOL );
                        } 
-                       goaway($a->get_baseurl() . '/message' );
+                       goaway($a->get_baseurl(true) . '/message' );
                }       
        
        }
@@ -146,7 +146,7 @@ function message_content(&$a) {
                $tpl = get_markup_template('msg-header.tpl');
 
                $a->page['htmlhead'] .= replace_macros($tpl, array(
-                       '$baseurl' => $a->get_baseurl(),
+                       '$baseurl' => $a->get_baseurl(true),
                        '$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'),
                        '$nickname' => $a->user['nickname'],
                        '$linkurl' => t('Please enter a link URL:')
@@ -210,7 +210,7 @@ function message_content(&$a) {
                        $o .= replace_macros($tpl, array(
                                '$id' => $rr['id'],
                                '$from_name' =>$rr['from-name'],
-                               '$from_url' => (($rr['network'] === NETWORK_DFRN) ? $a->get_baseurl() . '/redir/' . $rr['contact-id'] : $rr['url']),
+                               '$from_url' => (($rr['network'] === NETWORK_DFRN) ? $a->get_baseurl(true) . '/redir/' . $rr['contact-id'] : $rr['url']),
                                '$sparkle' => ' sparkle',
                                '$from_photo' => $rr['thumb'],
                                '$subject' => template_escape((($rr['mailseen']) ? $rr['title'] : '<strong>' . $rr['title'] . '</strong>')),
@@ -267,7 +267,7 @@ function message_content(&$a) {
        
                $a->page['htmlhead'] .= replace_macros($tpl, array(
                        '$nickname' => $a->user['nickname'],
-                       '$baseurl' => $a->get_baseurl()
+                       '$baseurl' => $a->get_baseurl(true)
                ));
 
 
@@ -278,7 +278,7 @@ function message_content(&$a) {
                                $sparkle = '';
                        }
                        else {
-                               $from_url = $a->get_baseurl() . '/redir/' . $message['contact-id'];
+                               $from_url = $a->get_baseurl(true) . '/redir/' . $message['contact-id'];
                                $sparkle = ' sparkle';
                        }
                        $o .= replace_macros($tpl, array(
index 4f58fc4fbc8fb487f3d652e3d1c381e229cb741c..d0f1733f46120e5c6cec659491ddda9cc17b8398 100755 (executable)
@@ -44,14 +44,16 @@ function network_init(&$a) {
        }
        
        $a->page['aside'] .= group_side('network','network',true,$group_id);
-       $a->page['aside'] .= networks_widget($a->get_baseurl() . '/network',(x($_GET, 'nets') ? $_GET['nets'] : ''));
+       $a->page['aside'] .= networks_widget($a->get_baseurl(true) . '/network',(x($_GET, 'nets') ? $_GET['nets'] : ''));
        $a->page['aside'] .= saved_searches($search);
-       $a->page['aside'] .= fileas_widget($a->get_baseurl() . '/network',(x($_GET, 'file') ? $_GET['file'] : ''));
+       $a->page['aside'] .= fileas_widget($a->get_baseurl(true) . '/network',(x($_GET, 'file') ? $_GET['file'] : ''));
 
 }
 
 function saved_searches($search) {
 
+       $a = get_app();
+
        $srchurl = '/network?f=' 
                . ((x($_GET,'cid'))   ? '&cid='   . $_GET['cid']   : '') 
                . ((x($_GET,'star'))  ? '&star='  . $_GET['star']  : '')
@@ -88,7 +90,7 @@ function saved_searches($search) {
        $o = replace_macros($tpl, array(
                '$title'         => t('Saved Searches'),
                '$add'           => t('add'),
-               '$searchbox' => search($search,'netsearch-box',$srchurl,true),
+               '$searchbox' => search($search,'netsearch-box',$a->get_baseurl(true) . $srchurl,true),
                '$saved'         => $saved,
        ));
        
@@ -167,38 +169,38 @@ function network_content(&$a, $update = 0) {
        $tabs = array(
                array(
                        'label' => t('Commented Order'),
-                       'url'=>$a->get_baseurl() . '/' . str_replace('/new', '', $a->cmd) . ((x($_GET,'cid')) ? '?f=&cid=' . $_GET['cid'] : ''), 
+                       'url'=>$a->get_baseurl(true) . '/' . str_replace('/new', '', $a->cmd) . ((x($_GET,'cid')) ? '?f=&cid=' . $_GET['cid'] : ''), 
                        'sel'=>$all_active,
                ),
                array(
                        'label' => t('Posted Order'),
-                       'url'=>$a->get_baseurl() . '/' . str_replace('/new', '', $a->cmd) . '?f=&order=post' . ((x($_GET,'cid')) ? '&cid=' . $_GET['cid'] : ''), 
+                       'url'=>$a->get_baseurl(true) . '/' . str_replace('/new', '', $a->cmd) . '?f=&order=post' . ((x($_GET,'cid')) ? '&cid=' . $_GET['cid'] : ''), 
                        'sel'=>$postord_active,
                ),
 
                array(
                        'label' => t('Personal'),
-                       'url' => $a->get_baseurl() . '/' . str_replace('/new', '', $a->cmd) . ((x($_GET,'cid')) ? '/?f=&cid=' . $_GET['cid'] : '') . '&conv=1',
+                       'url' => $a->get_baseurl(true) . '/' . str_replace('/new', '', $a->cmd) . ((x($_GET,'cid')) ? '/?f=&cid=' . $_GET['cid'] : '') . '&conv=1',
                        'sel' => $conv_active,
                ),
                array(
                        'label' => t('New'),
-                       'url' => $a->get_baseurl() . '/' . str_replace('/new', '', $a->cmd) . '/new' . ((x($_GET,'cid')) ? '/?f=&cid=' . $_GET['cid'] : ''),
+                       'url' => $a->get_baseurl(true) . '/' . str_replace('/new', '', $a->cmd) . '/new' . ((x($_GET,'cid')) ? '/?f=&cid=' . $_GET['cid'] : ''),
                        'sel' => $new_active,
                ),
                array(
                        'label' => t('Starred'),
-                       'url'=>$a->get_baseurl() . '/' . str_replace('/new', '', $a->cmd) . ((x($_GET,'cid')) ? '/?f=&cid=' . $_GET['cid'] : '') . '&star=1',
+                       'url'=>$a->get_baseurl(true) . '/' . str_replace('/new', '', $a->cmd) . ((x($_GET,'cid')) ? '/?f=&cid=' . $_GET['cid'] : '') . '&star=1',
                        'sel'=>$starred_active,
                ),
                array(
-                       'label' => t('Bookmarks'),
-                       'url'=>$a->get_baseurl() . '/' . str_replace('/new', '', $a->cmd) . ((x($_GET,'cid')) ? '/?f=&cid=' . $_GET['cid'] : '') . '&bmark=1',
+                       'label' => t('Shared Links'),
+                       'url'=>$a->get_baseurl(true) . '/' . str_replace('/new', '', $a->cmd) . ((x($_GET,'cid')) ? '/?f=&cid=' . $_GET['cid'] : '') . '&bmark=1',
                        'sel'=>$bookmarked_active,
                ),      
 //             array(
 //                     'label' => t('Spam'),
-//                     'url'=>$a->get_baseurl() . '/network?f=&spam=1'
+//                     'url'=>$a->get_baseurl(true) . '/network?f=&spam=1'
 //                     'sel'=> $spam_active,
 //             ),      
 
@@ -300,7 +302,7 @@ function network_content(&$a, $update = 0) {
                        if($update)
                                killme();
                        notice( t('No such group') . EOL );
-                       goaway($a->get_baseurl() . '/network');
+                       goaway($a->get_baseurl(true) . '/network');
                        // NOTREACHED
                }
 
@@ -332,7 +334,7 @@ function network_content(&$a, $update = 0) {
                }
                else {
                        notice( t('Invalid contact.') . EOL);
-                       goaway($a->get_baseurl() . '/network');
+                       goaway($a->get_baseurl(true) . '/network');
                        // NOTREACHED
                }
        }
index 99031a1d59f0dee8a2050e08def1082dc0f1cf98..d478b51634a3f3bb1349d2e1709f398ad7497b8a 100755 (executable)
@@ -42,12 +42,12 @@ function notifications_post(&$a) {
                                        intval(local_user())
                                );
                        }
-                       goaway($a->get_baseurl() . '/notifications/intros');
+                       goaway($a->get_baseurl(true) . '/notifications/intros');
                }
                if($_POST['submit'] == t('Ignore')) {
                        $r = q("UPDATE `intro` SET `ignore` = 1 WHERE `id` = %d LIMIT 1",
                                intval($intro_id));
-                       goaway($a->get_baseurl() . '/notifications/intros');
+                       goaway($a->get_baseurl(true) . '/notifications/intros');
                }
        }
 }
@@ -69,32 +69,32 @@ function notifications_content(&$a) {
        $tabs = array(
                array(
                        'label' => t('System'),
-                       'url'=>$a->get_baseurl() . '/notifications/system',
+                       'url'=>$a->get_baseurl(true) . '/notifications/system',
                        'sel'=> (($a->argv[1] == 'system') ? 'active' : ''),
                ),
                array(
                        'label' => t('Network'),
-                       'url'=>$a->get_baseurl() . '/notifications/network',
+                       'url'=>$a->get_baseurl(true) . '/notifications/network',
                        'sel'=> (($a->argv[1] == 'network') ? 'active' : ''),
                ),
                array(
                        'label' => t('Personal'),
-                       'url'=>$a->get_baseurl() . '/notifications/personal',
+                       'url'=>$a->get_baseurl(true) . '/notifications/personal',
                        'sel'=> (($a->argv[1] == 'personal') ? 'active' : ''),
                ),
                array(
                        'label' => t('Home'),
-                       'url' => $a->get_baseurl() . '/notifications/home',
+                       'url' => $a->get_baseurl(true) . '/notifications/home',
                        'sel'=> (($a->argv[1] == 'home') ? 'active' : ''),
                ),
                array(
                        'label' => t('Introductions'),
-                       'url' => $a->get_baseurl() . '/notifications/intros',
+                       'url' => $a->get_baseurl(true) . '/notifications/intros',
                        'sel'=> (($a->argv[1] == 'intros') ? 'active' : ''),
                ),
                array(
                        'label' => t('Messages'),
-                       'url' => $a->get_baseurl() . '/message',
+                       'url' => $a->get_baseurl(true) . '/message',
                        'sel'=> '',
                ),
        );
@@ -244,7 +244,7 @@ function notifications_content(&$a) {
                                switch($it['verb']){
                                        case ACTIVITY_LIKE:
                                                $notif_content .= replace_macros($tpl_item_likes,array(
-                                                       '$item_link' => $a->get_baseurl().'/display/'.$a->user['nickname']."/".$it['parent'],
+                                                       '$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
                                                        '$item_image' => $it['author-avatar'],
                                                        '$item_text' => sprintf( t("%s liked %s's post"), $it['author-name'], $it['pname']),
                                                        '$item_when' => relative_date($it['created'])
@@ -253,7 +253,7 @@ function notifications_content(&$a) {
                                                
                                        case ACTIVITY_DISLIKE:
                                                $notif_content .= replace_macros($tpl_item_dislikes,array(
-                                                       '$item_link' => $a->get_baseurl().'/display/'.$a->user['nickname']."/".$it['parent'],
+                                                       '$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
                                                        '$item_image' => $it['author-avatar'],
                                                        '$item_text' => sprintf( t("%s disliked %s's post"), $it['author-name'], $it['pname']),
                                                        '$item_when' => relative_date($it['created'])
@@ -267,7 +267,7 @@ function notifications_content(&$a) {
                                                $it['fname'] = $obj->title;
                                                
                                                $notif_content .= replace_macros($tpl_item_friends,array(
-                                                       '$item_link' => $a->get_baseurl().'/display/'.$a->user['nickname']."/".$it['parent'],
+                                                       '$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
                                                        '$item_image' => $it['author-avatar'],
                                                        '$item_text' => sprintf( t("%s is now friends with %s"), $it['author-name'], $it['fname']),
                                                        '$item_when' => relative_date($it['created'])
@@ -281,7 +281,7 @@ function notifications_content(&$a) {
                                                $tpl = (($it['id'] == $it['parent']) ? $tpl_item_posts : $tpl_item_comments);
 
                                                $notif_content .= replace_macros($tpl,array(
-                                                       '$item_link' => $a->get_baseurl().'/display/'.$a->user['nickname']."/".$it['parent'],
+                                                       '$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
                                                        '$item_image' => $it['author-avatar'],
                                                        '$item_text' => $item_text,
                                                        '$item_when' => relative_date($it['created'])
@@ -314,7 +314,7 @@ function notifications_content(&$a) {
                if (count($r) > 0) {
                        foreach ($r as $it) {
                                $notif_content .= replace_macros($not_tpl,array(
-                                       '$item_link' => $a->get_baseurl().'/notify/view/'. $it['id'],
+                                       '$item_link' => $a->get_baseurl(true).'/notify/view/'. $it['id'],
                                        '$item_image' => $it['photo'],
                                        '$item_text' => strip_tags(bbcode($it['msg'])),
                                        '$item_when' => relative_date($it['date'])
@@ -334,7 +334,7 @@ function notifications_content(&$a) {
                
                $notif_tpl = get_markup_template('notifications.tpl');
                
-               $myurl = $a->get_baseurl() . '/profile/'. $a->user['nickname'];
+               $myurl = $a->get_baseurl(true) . '/profile/'. $a->user['nickname'];
                $myurl = substr($myurl,strpos($myurl,'://')+3);
                $myurl = str_replace(array('www.','.'),array('','\\.'),$myurl);
                $diasp_url = str_replace('/profile/','/u/',$myurl);
@@ -369,7 +369,7 @@ function notifications_content(&$a) {
                                switch($it['verb']){
                                        case ACTIVITY_LIKE:
                                                $notif_content .= replace_macros($tpl_item_likes,array(
-                                                       '$item_link' => $a->get_baseurl().'/display/'.$a->user['nickname']."/".$it['parent'],
+                                                       '$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
                                                        '$item_image' => $it['author-avatar'],
                                                        '$item_text' => sprintf( t("%s liked %s's post"), $it['author-name'], $it['pname']),
                                                        '$item_when' => relative_date($it['created'])
@@ -378,7 +378,7 @@ function notifications_content(&$a) {
                                                
                                        case ACTIVITY_DISLIKE:
                                                $notif_content .= replace_macros($tpl_item_dislikes,array(
-                                                       '$item_link' => $a->get_baseurl().'/display/'.$a->user['nickname']."/".$it['parent'],
+                                                       '$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
                                                        '$item_image' => $it['author-avatar'],
                                                        '$item_text' => sprintf( t("%s disliked %s's post"), $it['author-name'], $it['pname']),
                                                        '$item_when' => relative_date($it['created'])
@@ -392,7 +392,7 @@ function notifications_content(&$a) {
                                                $it['fname'] = $obj->title;
                                                
                                                $notif_content .= replace_macros($tpl_item_friends,array(
-                                                       '$item_link' => $a->get_baseurl().'/display/'.$a->user['nickname']."/".$it['parent'],
+                                                       '$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
                                                        '$item_image' => $it['author-avatar'],
                                                        '$item_text' => sprintf( t("%s is now friends with %s"), $it['author-name'], $it['fname']),
                                                        '$item_when' => relative_date($it['created'])
@@ -406,7 +406,7 @@ function notifications_content(&$a) {
                                                $tpl = (($it['id'] == $it['parent']) ? $tpl_item_posts : $tpl_item_comments);
 
                                                $notif_content .= replace_macros($tpl,array(
-                                                       '$item_link' => $a->get_baseurl().'/display/'.$a->user['nickname']."/".$it['parent'],
+                                                       '$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
                                                        '$item_image' => $it['author-avatar'],
                                                        '$item_text' => $item_text,
                                                        '$item_when' => relative_date($it['created'])
@@ -456,7 +456,7 @@ function notifications_content(&$a) {
                                switch($it['verb']){
                                        case ACTIVITY_LIKE:
                                                $notif_content .= replace_macros($tpl_item_likes,array(
-                                                       '$item_link' => $a->get_baseurl().'/display/'.$a->user['nickname']."/".$it['parent'],
+                                                       '$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
                                                        '$item_image' => $it['author-avatar'],
                                                        '$item_text' => sprintf( t("%s liked %s's post"), $it['author-name'], $it['pname']),
                                                        '$item_when' => relative_date($it['created'])
@@ -465,7 +465,7 @@ function notifications_content(&$a) {
                                                break;
                                        case ACTIVITY_DISLIKE:
                                                $notif_content .= replace_macros($tpl_item_dislikes,array(
-                                                       '$item_link' => $a->get_baseurl().'/display/'.$a->user['nickname']."/".$it['parent'],
+                                                       '$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
                                                        '$item_image' => $it['author-avatar'],
                                                        '$item_text' => sprintf( t("%s disliked %s's post"), $it['author-name'], $it['pname']),
                                                        '$item_when' => relative_date($it['created'])
@@ -479,7 +479,7 @@ function notifications_content(&$a) {
                                                $it['fname'] = $obj->title;
                                                
                                                $notif_content .= replace_macros($tpl_item_friends,array(
-                                                       '$item_link' => $a->get_baseurl().'/display/'.$a->user['nickname']."/".$it['parent'],
+                                                       '$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
                                                        '$item_image' => $it['author-avatar'],
                                                        '$item_text' => sprintf( t("%s is now friends with %s"), $it['author-name'], $it['fname']),
                                                        '$item_when' => relative_date($it['created'])
@@ -488,7 +488,7 @@ function notifications_content(&$a) {
                                                break;
                                        default:
                                                $notif_content .= replace_macros($tpl_item_comments,array(
-                                                       '$item_link' => $a->get_baseurl().'/display/'.$a->user['nickname']."/".$it['parent'],
+                                                       '$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
                                                        '$item_image' => $it['author-avatar'],
                                                        '$item_text' => sprintf( t("%s commented on %s's post"), $it['author-name'], $it['pname']),
                                                        '$item_when' => relative_date($it['created'])
index a572b15344269f8c4d0bcd9776c6c1cd8b696195..ae8273a1d3eda064c7a7b2f5697162e3955f018c 100644 (file)
@@ -20,7 +20,7 @@ function notify_init(&$a) {
                        goaway($r[0]['link']);
                }
 
-               goaway($a->get_baseurl());
+               goaway($a->get_baseurl(true));
        }
 
        if($a->argc > 2 && $a->argv[1] === 'mark' && $a->argv[2] === 'all' ) {
@@ -51,7 +51,7 @@ function notify_content(&$a) {
                if (count($r) > 0) {
                        foreach ($r as $it) {
                                $notif_content .= replace_macros($not_tpl,array(
-                                       '$item_link' => $a->get_baseurl().'/notify/view/'. $it['id'],
+                                       '$item_link' => $a->get_baseurl(true).'/notify/view/'. $it['id'],
                                        '$item_image' => $it['photo'],
                                        '$item_text' => strip_tags(bbcode($it['msg'])),
                                        '$item_when' => relative_date($it['date'])
index b307a2d43bfe3af50b8c81f1b885e56ea93e62df..7b3b6ccc1eb5ea1451bcf361768c53f73f117379 100755 (executable)
@@ -240,7 +240,7 @@ function profiles_content(&$a) {
                );
                if(! count($r)) {
                        notice( t('Profile not found.') . EOL);
-                       goaway($a->get_baseurl() . '/profiles');
+                       goaway($a->get_baseurl(true) . '/profiles');
                        return; // NOTREACHED
                }
                
@@ -260,7 +260,7 @@ function profiles_content(&$a) {
                if($r)
                        info( t('Profile deleted.') . EOL);
 
-               goaway($a->get_baseurl() . '/profiles');
+               goaway($a->get_baseurl(true) . '/profiles');
                return; // NOTREACHED
        }
 
@@ -297,9 +297,9 @@ function profiles_content(&$a) {
 
                info( t('New profile created.') . EOL);
                if(count($r3) == 1)
-                       goaway($a->get_baseurl() . '/profiles/' . $r3[0]['id']);
+                       goaway($a->get_baseurl(true) . '/profiles/' . $r3[0]['id']);
                
-               goaway($a->get_baseurl() . '/profiles');
+               goaway($a->get_baseurl(true) . '/profiles');
        } 
 
        if(($a->argc > 2) && ($a->argv[1] === 'clone')) {
@@ -339,9 +339,9 @@ function profiles_content(&$a) {
                );
                info( t('New profile created.') . EOL);
                if(count($r3) == 1)
-                       goaway($a->get_baseurl() . '/profiles/' . $r3[0]['id']);
+                       goaway($a->get_baseurl(true) . '/profiles/' . $r3[0]['id']);
                
-               goaway($a->get_baseurl() . '/profiles');
+               goaway($a->get_baseurl(true) . '/profiles');
                
                return; // NOTREACHED
        }
@@ -373,7 +373,7 @@ function profiles_content(&$a) {
                ));
 
 
-               $a->page['htmlhead'] .= replace_macros($tpl, array('$baseurl' => $a->get_baseurl()));
+               $a->page['htmlhead'] .= replace_macros($tpl, array('$baseurl' => $a->get_baseurl(true)));
                $a->page['htmlhead'] .= "<script type=\"text/javascript\" src=\"js/country.js\" ></script>";
 
                $f = get_config('system','birthday_input_format');
@@ -425,7 +425,7 @@ function profiles_content(&$a) {
                        '$lbl_work' => t('Work/employment'),
                        '$lbl_school' => t('School/education'),
                        '$disabled' => (($is_default) ? 'onclick="return false;" style="color: #BBBBFF;"' : ''),
-                       '$baseurl' => $a->get_baseurl(),
+                       '$baseurl' => $a->get_baseurl(true),
                        '$profile_id' => $r[0]['id'],
                        '$profile_name' => $r[0]['profile-name'],
                        '$default' => (($is_default) ? '<p id="profile-edit-default-desc">' . t('This is your <strong>public</strong> profile.<br />It <strong>may</strong> be visible to anybody using the internet.') . '</p>' : ""),
@@ -489,7 +489,7 @@ function profiles_content(&$a) {
                                        '$alt' => t('Profile Image'),
                                        '$profile_name' => $rr['profile-name'],
                                        '$visible' => (($rr['is-default']) ? '<strong>' . t('visible to everybody') . '</strong>' 
-                                               : '<a href="' . $a->get_baseurl() . '/profperm/' . $rr['id'] . '" />' . t('Edit visibility') . '</a>')
+                                               : '<a href="' . $a->get_baseurl(true) . '/profperm/' . $rr['id'] . '" />' . t('Edit visibility') . '</a>')
                                ));
                        }
                }
index f42fdb3973178d30a1f5740b546bff79cadc1647..f694b5840f088887819e37911b69b88828786094 100755 (executable)
@@ -59,7 +59,7 @@ function settings_post(&$a) {
                q("DELETE FROM tokens WHERE id='%s' AND uid=%d",
                        dbesc($key),
                        local_user());
-               goaway($a->get_baseurl()."/settings/oauth/");
+               goaway($a->get_baseurl(true)."/settings/oauth/");
                return;                 
        }
 
@@ -104,7 +104,7 @@ function settings_post(&$a) {
                                                local_user());
                        }
                }
-               goaway($a->get_baseurl()."/settings/oauth/");
+               goaway($a->get_baseurl(true)."/settings/oauth/");
                return;
        }
 
@@ -411,7 +411,7 @@ function settings_post(&$a) {
 
        }
 
-       goaway($a->get_baseurl() . '/settings' );
+       goaway($a->get_baseurl(true) . '/settings' );
        return; // NOTREACHED
 }
                
@@ -435,27 +435,27 @@ function settings_content(&$a) {
        $tabs = array(
                array(
                        'label' => t('Account settings'),
-                       'url'   => $a->get_baseurl().'/settings',
+                       'url'   => $a->get_baseurl(true).'/settings',
                        'sel'   => (($a->argc == 1)?'active':''),
                ),      
                array(
                        'label' => t('Connector settings'),
-                       'url'   => $a->get_baseurl().'/settings/connectors',
+                       'url'   => $a->get_baseurl(true).'/settings/connectors',
                        'sel'   => (($a->argc > 1) && ($a->argv[1] === 'connectors')?'active':''),
                ),
                array(
                        'label' => t('Plugin settings'),
-                       'url'   => $a->get_baseurl().'/settings/addon',
+                       'url'   => $a->get_baseurl(true).'/settings/addon',
                        'sel'   => (($a->argc > 1) && ($a->argv[1] === 'addon')?'active':''),
                ),
                array(
                        'label' => t('Connections'),
-                       'url' => $a->get_baseurl() . '/settings/oauth',
+                       'url' => $a->get_baseurl(true) . '/settings/oauth',
                        'sel' => (($a->argc > 1) && ($a->argv[1] === 'oauth')?'active':''),
                ),
                array(
                        'label' => t('Export personal data'),
-                       'url' => $a->get_baseurl() . '/uexport',
+                       'url' => $a->get_baseurl(true) . '/uexport',
                        'sel' => ''
                )
        );
@@ -517,7 +517,7 @@ function settings_content(&$a) {
                        $r = q("DELETE FROM clients WHERE client_id='%s' AND uid=%d",
                                        dbesc($a->argv[3]),
                                        local_user());
-                       goaway($a->get_baseurl()."/settings/oauth/");
+                       goaway($a->get_baseurl(true)."/settings/oauth/");
                        return;                 
                }
                
@@ -533,7 +533,7 @@ function settings_content(&$a) {
                $tpl = get_markup_template("settings_oauth.tpl");
                $o .= replace_macros($tpl, array(
                        '$form_security_token' => get_form_security_token("settings_oauth"),
-                       '$baseurl'      => $a->get_baseurl(),
+                       '$baseurl'      => $a->get_baseurl(true),
                        '$title'        => t('Connected Apps'),
                        '$add'          => t('Add application'),
                        '$edit'         => t('Edit'),
@@ -559,7 +559,7 @@ function settings_content(&$a) {
                
                $tpl = get_markup_template("settings_addons.tpl");
                $o .= replace_macros($tpl, array(
-                       '$form_security_token' => get_form_security_token("settings_addons"),
+                       '$form_security_token' => get_form_security_token("settings_addon"),
                        '$title'        => t('Plugin Settings'),
                        '$tabs'         => $tabs,
                        '$settings_addons' => $settings_addons
@@ -789,7 +789,7 @@ function settings_content(&$a) {
        $theme_selected = (!x($_SESSION,'theme')? $default_theme : $_SESSION['theme']);
 
 
-       $subdir = ((strlen($a->get_path())) ? '<br />' . t('or') . ' ' . $a->get_baseurl() . '/profile/' . $nickname : '');
+       $subdir = ((strlen($a->get_path())) ? '<br />' . t('or') . ' ' . $a->get_baseurl(true) . '/profile/' . $nickname : '');
 
        $tpl_addr = get_markup_template("settings_nick_set.tpl");
 
@@ -819,7 +819,7 @@ function settings_content(&$a) {
                '$ptitle'       => t('Account Settings'),
 
                '$submit'       => t('Submit'),
-               '$baseurl' => $a->get_baseurl(),
+               '$baseurl' => $a->get_baseurl(true),
                '$uid' => local_user(),
                '$form_security_token' => get_form_security_token("settings"),
                
diff --git a/tests/autoname_test.php b/tests/autoname_test.php
new file mode 100755 (executable)
index 0000000..9dae920
--- /dev/null
@@ -0,0 +1,73 @@
+<?php
+/**
+ * this file contains tests for the autoname function
+ * 
+ * @package test.util
+ */
+
+/** required, it is the file under test */
+require_once('include/text.php');
+
+/**
+ * TestCase for the autoname function
+ * 
+ * @author Alexander Kampmann
+ * @package test.util
+ */
+class AutonameTest extends PHPUnit_Framework_TestCase {
+       /**\r
+        *autonames should be random, even length\r
+        */\r
+       public function testAutonameEven() {\r
+               $autoname1=autoname(10);\r
+               $autoname2=autoname(10);\r
+       \r
+               $this->assertNotEquals($autoname1, $autoname2);\r
+       }\r
+       \r
+       /**\r
+        *autonames should be random, odd length\r
+        */\r
+       public function testAutonameOdd() {\r
+               $autoname1=autoname(9);\r
+               $autoname2=autoname(9);\r
+       \r
+               $this->assertNotEquals($autoname1, $autoname2);\r
+       }\r
+       \r
+       /**\r
+        * try to fail autonames\r
+        */\r
+       public function testAutonameNoLength() {\r
+               $autoname1=autoname(0);\r
+               $this->assertEquals(0, count($autoname1));\r
+       }\r
+       
+       /**
+        * try to fail it with invalid input
+        * 
+        * TODO: What's corect behaviour here? An exception?
+        */\r
+       public function testAutonameNegativeLength() {\r
+               $autoname1=autoname(-23);\r
+               $this->assertEquals(0, count($autoname1));\r
+       }\r
+       \r
+       //      public function testAutonameMaxLength() {\r
+       //              $autoname2=autoname(PHP_INT_MAX);\r
+       //              $this->assertEquals(PHP_INT_MAX, count($autoname2));\r
+       //      }\r
+       
+       /**
+        * test with a length, that may be too short
+        */\r
+       public function testAutonameLength1() {\r
+               $autoname1=autoname(1);\r
+               $this->assertEquals(1, count($autoname1));
+               
+               $autoname2=autoname(1);\r
+               $this->assertEquals(1, count($autoname2));
+               
+               $this->assertFalse($autoname1==$autoname2); \r
+       }
+}
\ No newline at end of file
diff --git a/tests/contains_attribute_test.php b/tests/contains_attribute_test.php
new file mode 100755 (executable)
index 0000000..b0bb06a
--- /dev/null
@@ -0,0 +1,51 @@
+<?php
+/**\r
+ * this test tests the contains_attribute function\r
+ *\r
+ * @package test.util\r
+ */\r
+\r
+/** required, it is the file under test */\r
+require_once('include/text.php');\r
+\r
+/**\r
+ * TestCase for the contains_attribute function\r
+ *\r
+ * @author Alexander Kampmann\r
+ * @package test.util\r
+ */\r
+class ContainsAttributeTest extends PHPUnit_Framework_TestCase {
+       /**\r
+        * test attribute contains\r
+        */\r
+       public function testAttributeContains1() {\r
+               $testAttr="class1 notclass2 class3";\r
+               $this->assertTrue(attribute_contains($testAttr, "class3"));\r
+               $this->assertFalse(attribute_contains($testAttr, "class2"));\r
+       }\r
+       \r
+       /**\r
+        * test attribute contains\r
+        */\r
+       public function testAttributeContains2() {\r
+               $testAttr="class1 not-class2 class3";\r
+               $this->assertTrue(attribute_contains($testAttr, "class3"));\r
+               $this->assertFalse(attribute_contains($testAttr, "class2"));\r
+       }\r
+       
+       /**
+        * test with empty input
+        */\r
+       public function testAttributeContainsEmpty() {\r
+               $testAttr="";\r
+               $this->assertFalse(attribute_contains($testAttr, "class2"));\r
+       }\r
+       
+       /**
+        * test input with special chars
+        */\r
+       public function testAttributeContainsSpecialChars() {\r
+               $testAttr="--... %\$ä() /(=?}";\r
+               $this->assertFalse(attribute_contains($testAttr, "class2"));\r
+       }
+}
\ No newline at end of file
diff --git a/tests/expand_acl_test.php b/tests/expand_acl_test.php
new file mode 100755 (executable)
index 0000000..b516a3f
--- /dev/null
@@ -0,0 +1,142 @@
+<?php
+/**
+ * this test tests the expand_acl function
+ *
+ * @package test.util
+ */
+
+/** required, it is the file under test */
+require_once('include/text.php');
+
+/**\r
+ * TestCase for the expand_acl function\r
+ *\r
+ * @author Alexander Kampmann\r
+ * @package test.util\r
+ */\r
+class ExpandAclTest extends PHPUnit_Framework_TestCase {
+       
+       /**\r
+        * test expand_acl, perfect input\r
+        */\r
+       public function testExpandAclNormal() {\r
+               $text='<1><2><3>';\r
+               $this->assertEquals(array(1, 2, 3), expand_acl($text));\r
+       }\r
+       
+       /**
+        * test with a big number
+        */\r
+       public function testExpandAclBigNumber() {\r
+               $text='<1><'.PHP_INT_MAX.'><15>';\r
+               $this->assertEquals(array(1, PHP_INT_MAX, 15), expand_acl($text));\r
+       }\r
+       
+       /**
+        * test with a string in it. 
+        * 
+        * TODO: is this valid input? Otherwise: should there be an exception?
+        */\r
+       public function testExpandAclString() {\r
+               $text="<1><279012><tt>"; \r
+               $this->assertEquals(array(1, 279012, 'tt'), expand_acl($text));\r
+       }\r
+       
+       /**
+        * test with a ' ' in it. 
+        * 
+        * TODO: is this valid input? Otherwise: should there be an exception?
+        */\r
+       public function testExpandAclSpace() {\r
+               $text="<1><279 012><32>"; \r
+               $this->assertEquals(array(1, "279 012", "32"), expand_acl($text));\r
+       }\r
+       
+       /**
+        * test empty input
+        */\r
+       public function testExpandAclEmpty() {\r
+               $text=""; \r
+               $this->assertEquals(array(), expand_acl($text));\r
+       }\r
+       
+       /**
+        * test invalid input, no < at all
+        * 
+        * TODO: should there be an exception?
+        */\r
+       public function testExpandAclNoBrackets() {\r
+               $text="According to documentation, that's invalid. "; //should be invalid\r
+               $this->assertEquals(array(), expand_acl($text));\r
+       }\r
+       
+       /**\r
+        * test invalid input, just open <\r
+        *\r
+        * TODO: should there be an exception?\r
+        */\r
+       public function testExpandAclJustOneBracket1() {\r
+               $text="<Another invalid string"; //should be invalid\r
+               $this->assertEquals(array(), expand_acl($text));\r
+       }\r
+       
+       /**\r
+        * test invalid input, just close >\r
+        *\r
+        * TODO: should there be an exception?\r
+        */\r
+       public function testExpandAclJustOneBracket2() {\r
+               $text="Another invalid> string"; //should be invalid\r
+               $this->assertEquals(array(), expand_acl($text));\r
+       }\r
+       
+       /**\r
+        * test invalid input, just close >\r
+        *\r
+        * TODO: should there be an exception?\r
+        */\r
+       public function testExpandAclCloseOnly() {\r
+               $text="Another> invalid> string>"; //should be invalid\r
+               $this->assertEquals(array(), expand_acl($text));\r
+       }\r
+       
+       /**\r
+        * test invalid input, just open <\r
+        *\r
+        * TODO: should there be an exception?\r
+        */\r
+       public function testExpandAclOpenOnly() {\r
+               $text="<Another< invalid string<"; //should be invalid\r
+               $this->assertEquals(array(), expand_acl($text));\r
+       }\r
+       
+       /**\r
+        * test invalid input, open and close do not match\r
+        *\r
+        * TODO: should there be an exception?\r
+        */\r
+       public function testExpandAclNoMatching1() {\r
+               $text="<Another<> invalid <string>"; //should be invalid\r
+               $this->assertEquals(array(), expand_acl($text));\r
+       }\r
+       
+       /**\r
+        * test invalid input, open and close do not match\r
+        *\r
+        * TODO: should there be an exception?\r
+        */\r
+       public function testExpandAclNoMatching2() {\r
+               $text="<1>2><3>";\r
+               $this->assertEquals(array(), expand_acl($text));\r
+       }
+       
+       /**\r
+        * test invalid input, empty <>\r
+        *\r
+        * TODO: should there be an exception? Or array(1, 3)\r
+        */\r
+       public function testExpandAclEmptyMatch() {\r
+               $text="<1><><3>";\r
+               $this->assertEquals(array(), expand_acl($text));\r
+       }
+}
\ No newline at end of file
diff --git a/tests/get_tags_test.php b/tests/get_tags_test.php
new file mode 100644 (file)
index 0000000..9051923
--- /dev/null
@@ -0,0 +1,313 @@
+<?php
+/**
+ * This file contains the tests for get_tags and the tag handling in item.php
+ * 
+ * @package test.util
+ */
+
+/**
+ * required, because it contains the get_tags() function
+ */
+require_once 'include/text.php';
+/**
+ * required, because it contains the tag handling
+ */
+require_once 'mod/item.php';
+
+/**
+ * A class which can be used as replacement for an app if
+ * only get_baseurl is used. 
+ * 
+ * @author Alexander Kampmann
+ * @package test.util
+ */
+class MockApp {
+       function get_baseurl() {
+               return "baseurl"; 
+       }
+}; 
+
+/**
+ * the test should not rely on a database, 
+ * so this is a replacement for the database access method q. 
+ * 
+ * It simulates the user with uid 11 has one contact, named Mike Lastname. 
+ * 
+ * @param string $sql
+ */
+function q($sql) {
+       $result=array(array('id'=>15, 
+                       'attag'=>'', 'network'=>'dfrn', 
+                       'name'=>'Mike Lastname', 'alias'=>'Mike', 
+                       'nick'=>'Mike', 'url'=>"http://justatest.de")); 
+       
+       $args=func_get_args(); 
+
+       //last parameter is always (in this test) uid, so, it should be 11
+       if($args[count($args)-1]!=11) {
+               return; 
+       }
+       
+       
+       if(3==count($args)) {
+               //first call in handle_body, id only
+               if($result[0]['id']==$args[1]) {
+                       return $result; 
+               }
+               //second call in handle_body, name
+               if($result[0]['name']===$args[1]) {\r
+                       return $result;\r
+               }
+       }
+       //third call in handle_body, nick or attag
+       if($result[0]['nick']===$args[2] || $result[0]['attag']===$args[1]) {\r
+               return $result;\r
+       }
+}
+
+/**
+ * replacement for dbesc. 
+ * I don't want to test dbesc here, so
+ * I just return the input. It won't be a problem, because 
+ * the test does not use a real database. 
+ * 
+ * DON'T USE HAT FUNCTION OUTSIDE A TEST!
+ * 
+ * @param string $str
+ * @return input
+ */
+function dbesc($str) {
+       return $str; 
+}
+
+/**
+ * TestCase for tag handling. 
+ * 
+ * @author alexander
+ * @package test.util
+ */
+class GetTagsTest extends PHPUnit_Framework_TestCase {
+       /** the mock to use as app */
+       private $a; \r
+
+       /**
+        * initialize the test. That's a phpUnit function, 
+        * don't change its name.
+        */\r
+       public function setUp() {\r
+               $this->a=new MockApp(); 
+       }
+
+       /**\r
+        * test with one Person tag\r
+        */\r
+       public function testGetTagsShortPerson() {\r
+               $text="hi @Mike";\r
+\r
+               $tags=get_tags($text);\r
+
+               $inform=''; 
+               $str_tags='';
+               foreach($tags as $tag) {
+                       handle_tag($this->a, $text, $inform, $str_tags, 11, $tag);
+               }
+
+               //correct tags found?
+               $this->assertEquals(1, count($tags)); \r
+               $this->assertTrue(in_array("@Mike", $tags));
+               
+               //correct output from handle_tag?
+               $this->assertEquals("cid:15", $inform); 
+               $this->assertEquals("@[url=http://justatest.de]Mike Lastname[/url]", $str_tags);
+               $this->assertEquals("hi @[url=http://justatest.de]Mike Lastname[/url]", $text);\r
+       }
+       
+       /**\r
+        * test with one Person tag. 
+        * There's a minor spelling mistake...\r
+        */\r
+       public function testGetTagsShortPersonSpelling() {\r
+               $text="hi @Mike.because";\r
+       \r
+               $tags=get_tags($text);\r
+       
+               //correct tags found?\r
+               $this->assertEquals(1, count($tags));\r
+               $this->assertTrue(in_array("@Mike.because", $tags));
+               \r
+               $inform='';\r
+               $str_tags='';\r
+               handle_tag($this->a, $text, $inform, $str_tags, 11, $tags[0]);\r
+       \r
+               $this->assertEquals("cid:15", $inform); 
+               $this->assertEquals("@[url=http://justatest.de]Mike Lastname[/url]", $str_tags);
+               $this->assertEquals("hi @[url=http://justatest.de]Mike Lastname[/url].because", $text);\r
+       }
+       
+       /**\r
+        * test with two Person tags. 
+        * There's a minor spelling mistake...\r
+        */\r
+       public function testGetTagsPerson2Spelling() {\r
+               $text="hi @Mike@campino@friendica.eu";\r
+       \r
+               $tags=get_tags($text);\r
+       
+               $this->assertEquals(2, count($tags)); \r
+               $this->assertTrue(in_array("@Mike", $tags));
+               $this->assertTrue(in_array("@campino@friendica.eu", $tags));\r
+       }\r
+
+       /**
+        * Test with one hash tag.
+        */\r
+       public function testGetTagsShortTag() {\r
+               $text="This is a #test_case";\r
+\r
+               $tags=get_tags($text);\r
+
+               $this->assertEquals(1, count($tags));\r
+               $this->assertTrue(in_array("#test_case", $tags));\r
+       }\r
+
+       /**
+        * test with a person and a hash tag
+        */\r
+       public function testGetTagsShortTagAndPerson() {\r
+               $text="hi @Mike This is a #test_case";\r
+\r
+               $tags=get_tags($text);\r
+
+               $this->assertEquals(3, count($tags));
+               $this->assertTrue(in_array("@Mike", $tags));
+               $this->assertTrue(in_array("@Mike This", $tags));\r
+               $this->assertTrue(in_array("#test_case", $tags));\r
+
+               $inform='';
+               $str_tags='';
+               foreach($tags as $tag) {
+                       handle_tag($this->a, $text, $inform, $str_tags, 11, $tag);
+               }
+               \r
+               $this->assertEquals("cid:15", $inform); 
+               $this->assertEquals("@[url=http://justatest.de]Mike Lastname[/url],#[url=baseurl/search?search=test%20case]test case[/url]", $str_tags);
+               $this->assertEquals("hi @[url=http://justatest.de]Mike Lastname[/url] This is a #[url=baseurl/search?search=test%20case]test case[/url]", $text); 
+               \r
+       }\r
+
+       /**
+        * test with a person, a hash tag and some special chars.
+        */\r
+       public function testGetTagsShortTagAndPersonSpecialChars() {\r
+               $text="hi @Mike, This is a #test_case.";\r
+\r
+               $tags=get_tags($text);\r
+\r
+               $this->assertEquals(2, count($tags));
+               $this->assertTrue(in_array("@Mike", $tags));
+               $this->assertTrue(in_array("#test_case", $tags));\r
+       }\r
+
+       /**
+        * Test with a person tag and text behind it.
+        */\r
+       public function testGetTagsPersonOnly() {\r
+               $text="@Test I saw the Theme Dev group was created.";\r
+\r
+               $tags=get_tags($text);\r
+
+               $this->assertEquals(2, count($tags));\r
+               $this->assertTrue(in_array("@Test I", $tags));
+               $this->assertTrue(in_array("@Test", $tags));\r
+       }\r
+
+       /**
+        * this test demonstrates strange behaviour by intval. 
+        * It makes the next test fail. 
+        */
+       public function testIntval() {
+               $this->assertEquals(15, intval("15 it")); 
+       }
+       
+       /**
+        * test a tag with an id in it
+        */
+       public function testIdTag() {
+               $text="Test with @mike+15 id tag"; 
+               
+               $tags=get_tags($text); 
+               
+               $this->assertEquals(2, count($tags)); 
+               $this->assertTrue(in_array("@mike+15", $tags));
+               
+               //happens right now, but it shouldn't be necessary
+               $this->assertTrue(in_array("@mike+15 id", $tags));
+               
+               $inform='';\r
+               $str_tags='';
+               foreach($tags as $tag) {
+                       handle_tag($this->a, $text, $inform, $str_tags, 11, $tag);
+               }
+               
+               $this->assertEquals("Test with @[url=http://justatest.de]Mike Lastname[/url] id tag", $text);\r
+               $this->assertEquals("@[url=http://justatest.de]Mike Lastname[/url]", $str_tags);\r
+               $this->assertEquals("cid:15", $inform);
+       }
+       
+       /**
+        * test with two persons and one special tag.
+        */\r
+       public function testGetTags2Persons1TagSpecialChars() {\r
+               $text="hi @Mike, I'm just writing #test_cases, so"\r
+               ." so @somebody@friendica.com may change #things.";\r
+\r
+               $tags=get_tags($text);\r
+
+               $this->assertEquals(5, count($tags));\r
+               $this->assertTrue(in_array("@Mike", $tags));\r
+               $this->assertTrue(in_array("#test_cases", $tags));
+               $this->assertTrue(in_array("@somebody@friendica.com", $tags));\r
+               $this->assertTrue(in_array("@somebody@friendica.com may", $tags));\r
+               $this->assertTrue(in_array("#things", $tags));\r
+       }\r
+
+       /**
+        * test with a long text.
+        */\r
+       public function testGetTags() {\r
+               $text="hi @Mike, I'm just writing #test_cases, "\r
+               ." so @somebody@friendica.com may change #things. Of course I "\r
+               ."look for a lot of #pitfalls, like #tags at the end of a sentence "\r
+               ."@comment. I hope noone forgets about @fullstops.because that might"\r
+               ." break #things. @Mike@campino@friendica.eu is also #nice, isn't it? "\r
+               ."Now, add a @first_last tag. ";\r
+               \r
+               $tags=get_tags($text);\r
+\r
+               $this->assertTrue(in_array("@Mike", $tags));\r
+               $this->assertTrue(in_array("#test_cases", $tags));\r
+               $this->assertTrue(in_array("@somebody@friendica.com", $tags));\r
+               $this->assertTrue(in_array("#things", $tags));\r
+               $this->assertTrue(in_array("#pitfalls", $tags));\r
+               $this->assertTrue(in_array("#tags", $tags));\r
+               $this->assertTrue(in_array("@comment", $tags));\r
+               $this->assertTrue(in_array("@fullstops.because", $tags));\r
+               $this->assertTrue(in_array("#things", $tags));\r
+               $this->assertTrue(in_array("@Mike", $tags));\r
+               $this->assertTrue(in_array("#nice", $tags));\r
+               $this->assertTrue(in_array("@first_last", $tags));
+               
+               //right now, none of the is matched
+               $this->assertFalse(in_array("@Mike@campino@friendica.eu", $tags));\r
+               $this->assertTrue(in_array("@campino@friendica.eu", $tags));
+               $this->assertTrue(in_array("@campino@friendica.eu is", $tags));\r
+       }\r
+
+       /**
+        * test with an empty string
+        */\r
+       public function testGetTagsEmpty() {\r
+               $tags=get_tags("");\r
+               $this->assertEquals(0, count($tags));\r
+       }
+}
\ No newline at end of file
diff --git a/tests/xss_filter_test.php b/tests/xss_filter_test.php
new file mode 100644 (file)
index 0000000..d7dcf04
--- /dev/null
@@ -0,0 +1,50 @@
+<?php
+/**
+ * tests several functions which are used to prevent xss attacks
+ * 
+ * @package test.util
+ */
+
+require_once('include/text.php');
+
+class AntiXSSTest extends PHPUnit_Framework_TestCase {
+
+       /**
+        * test, that tags are escaped
+        */
+       public function testEscapeTags() {
+               $invalidstring='<submit type="button" onclick="alert(\'failed!\');" />';
+
+               $validstring=notags($invalidstring);
+               $escapedString=escape_tags($invalidstring);
+
+               $this->assertEquals('[submit type="button" onclick="alert(\'failed!\');" /]', $validstring);
+               $this->assertEquals("&lt;submit type=&quot;button&quot; onclick=&quot;alert('failed!');&quot; /&gt;", $escapedString);
+       }
+
+       /**
+        *xmlify and unxmlify
+        */
+       public function testXmlify() {
+               $text="<tag>I want to break\n this!11!<?hard?></tag>";
+               $xml=xmlify($text); //test whether it actually may be part of a xml document
+               $retext=unxmlify($text);
+
+               $this->assertEquals($text, $retext);
+       }
+
+       /**
+        * test hex2bin and reverse
+        */
+       public function testHex2Bin() {
+               $this->assertEquals(-3, hex2bin(bin2hex(-3)));
+               $this->assertEquals(0, hex2bin(bin2hex(0)));
+               $this->assertEquals(12, hex2bin(bin2hex(12)));
+               $this->assertEquals(PHP_INT_MAX, hex2bin(bin2hex(PHP_INT_MAX)));
+       }
+
+       //function qp, quick and dirty??
+       //get_mentions
+       //get_contact_block, bis Zeile 538
+}
+?>
index a6177324aced4fc9cd19a3f2237d6b23f18c4d14..35620e80b756dda2e84594a9304a540896a9f9a6 100755 (executable)
@@ -26,7 +26,7 @@ echo "New DB VERSION: " . DB_UPDATE_VERSION . "\n";
 
 if($build != DB_UPDATE_VERSION) {
        echo "Updating database...";
-       check_config();
+       check_config($a);
        echo "Done\n";
 }
 
index 9a122984546080450117655176e396a4623db839..01fe893c6551b8966294391da86340b4757bc1f9 100755 (executable)
@@ -7,6 +7,7 @@
        {{ inc field_textarea.tpl with $field=$banner }}{{ endinc }}
        {{ inc field_select.tpl with $field=$language }}{{ endinc }}
        {{ inc field_select.tpl with $field=$theme }}{{ endinc }}
+       {{ inc field_select.tpl with $field=$ssl_policy }}{{ endinc }}
        
        <div class="submit"><input type="submit" name="page_site" value="$submit" /></div>
        
index 3f9176cd7be9821ee6781d3287dba1bd74202c46..5438a1c9fc2719f0fbd5499517b198709419d990 100755 (executable)
@@ -4,23 +4,23 @@ function string_plural_select_de($n){
        return ($n != 1);
 }
 ;
-$a->strings["Post successful."] = "Beitrag erfolgreich veröffentlicht.";
+$a->strings["Post successful."] = "Beitrag erfolgreich verffentlicht.";
 $a->strings["[Embedded content - reload page to view]"] = "[Eingebetteter Inhalt - Seite neu laden zum Betrachten]";
 $a->strings["Contact settings applied."] = "Einstellungen zum Kontakt angewandt.";
 $a->strings["Contact update failed."] = "Konnte den Kontakt nicht aktualisieren.";
 $a->strings["Permission denied."] = "Zugriff verweigert.";
 $a->strings["Contact not found."] = "Kontakt nicht gefunden.";
 $a->strings["Repair Contact Settings"] = "Kontakt-Einstellungen reparieren";
-$a->strings["<strong>WARNING: This is highly advanced</strong> and if you enter incorrect information your communications with this contact may stop working."] = "<strong>ACHTUNG: Das sind Experten-Einstellungen!</strong> Wenn Du etwas Falsches eingibst, funktioniert die Kommunikation mit diesem Kontakt evtl. nicht mehr.";
-$a->strings["Please use your browser 'Back' button <strong>now</strong> if you are uncertain what to do on this page."] = "Bitte nutze den Zurück-Button deines Browsers <strong>jetzt</strong>, wenn du dir unsicher bist, was du tun willst.";
-$a->strings["Return to contact editor"] = "Zurück zum Kontakteditor";
+$a->strings["<strong>WARNING: This is highly advanced</strong> and if you enter incorrect information your communications with this contact may stop working."] = "<strong>ACHTUNG: Das sind Experten-Einstellungen!</strong> Wenn Du etwas falsches eingibst, funktioniert die Kommunikation mit diesem Kontakt evtl. nicht mehr.";
+$a->strings["Please use your browser 'Back' button <strong>now</strong> if you are uncertain what to do on this page."] = "Bitte nutze den Zur�ck-Button deines Browsers <strong>jetzt</strong>, wenn du dir unsicher bist, was auf dieser Seite gemacht wird.";
+$a->strings["Return to contact editor"] = "Zurck zum Kontakteditor";
 $a->strings["Name"] = "Name";
 $a->strings["Account Nickname"] = "Account-Spitzname";
-$a->strings["@Tagname - overrides Name/Nickname"] = "@Tagname - überschreibt Name/Spitzname";
+$a->strings["@Tagname - overrides Name/Nickname"] = "@Tagname - berschreibt Name/Spitzname";
 $a->strings["Account URL"] = "Account-URL";
-$a->strings["Friend Request URL"] = "URL für Freundschaftsanfragen";
-$a->strings["Friend Confirm URL"] = "URL für Bestätigungen von Freundschaftsanfragen";
-$a->strings["Notification Endpoint URL"] = "URL-Endpunkt für Benachrichtigungen";
+$a->strings["Friend Request URL"] = "URL fr Freundschaftsanfragen";
+$a->strings["Friend Confirm URL"] = "URL f�r Best�tigungen von Freundschaftsanfragen";
+$a->strings["Notification Endpoint URL"] = "URL-Endpunkt fr Benachrichtigungen";
 $a->strings["Poll/Feed URL"] = "Pull/Feed-URL";
 $a->strings["New photo from this URL"] = "Neues Foto von dieser URL";
 $a->strings["Submit"] = "Senden";
@@ -28,7 +28,7 @@ $a->strings["Help:"] = "Hilfe:";
 $a->strings["Help"] = "Hilfe";
 $a->strings["Not Found"] = "Nicht gefunden";
 $a->strings["Page not found."] = "Seite nicht gefunden.";
-$a->strings["File exceeds size limit of %d"] = "Die Datei ist größer als das erlaubte Limit von %d";
+$a->strings["File exceeds size limit of %d"] = "Die Datei ist gr��er als das erlaubte Limit von %d";
 $a->strings["File upload failed."] = "Hochladen der Datei fehlgeschlagen.";
 $a->strings["Friend suggestion sent."] = "Kontaktvorschlag gesendet.";
 $a->strings["Suggest Friends"] = "Kontakte vorschlagen";
@@ -40,7 +40,7 @@ $a->strings["link to source"] = "Link zum Originalbeitrag";
 $a->strings["Events"] = "Veranstaltungen";
 $a->strings["Create New Event"] = "Neue Veranstaltung erstellen";
 $a->strings["Previous"] = "Vorherige";
-$a->strings["Next"] = "Nächste";
+$a->strings["Next"] = "Nchste";
 $a->strings["hour:minute"] = "Stunde:Minute";
 $a->strings["Event details"] = "Veranstaltungsdetails";
 $a->strings["Format is %s %s. Starting date and Description are required."] = "Format ist %s %s. Anfangsdatum und Beschreibung sind notwendig.";
index 5349fa3d836876f186e1f1398723e178c735a399..4cbbb162400a76789950a012982153e2f2277ebd 100755 (executable)
@@ -1,5 +1,5 @@
 
-<form action="" method="post" >
+<form action="$dest_url" method="post" >
        <input type="hidden" name="auth-params" value="login" />
 
        <div id="login_standard">
index 6a84a5bbcf58ae49f676c1c9f0de5c97cebf66c8..efc971df8491a2c59d4e01c5add95f2e6c90c549 100755 (executable)
@@ -1,4 +1,4 @@
-<form action="" method="post" >
+<form action="$dest_url" method="post" >
 <div class="logout-wrapper">
 <input type="hidden" name="auth-params" value="logout" />
 <input type="submit" name="submit" id="logout-button" value="$logout" />
index 10ddb00909df6c754bfd9d9cda46475a47c21b1b..b79b00ef418f6ad62702a5da2538fe55892a1b6b 100755 (executable)
@@ -2615,12 +2615,12 @@ aside input[type='text'] {
        margin-top: 10px;
 }
 
-.body-tag {
+.body-tag, .filesavetags {
        opacity: 0.5;
        filter:alpha(opacity=50);
 }
 
-.body-tag:hover {
+.body-tag:hover, .filesavetags:hover {
        opacity: 1.0 !important;
        filter:alpha(opacity=100) !important;
 }
index 2c88fc598ef914d6c64fed26b81eee8f834b09db..6cb018b7bc37932398fd472d3c2e5d49d156aa45 100755 (executable)
                        {{ if $item.star }}
                        <a href="#" id="starred-$item.id" onclick="dostar($item.id); return false;" class="star-item icon $item.isstarred" title="$item.star.toggle"></a>
                        <a href="#" id="tagger-$item.id" onclick="itemTag($item.id); return false;" class="tag-item icon tagged" title="$item.star.tagger"></a>
-                       <a href="#" id="filer-$item.id" onclick="itemFiler($item.id); return false;" class="filer-item filer-icon" title="$item.star.filer"></a>
                        {{ endif }}
-                       
+                       {{ if $item.filer }}
+                       <a href="#" id="filer-$item.id" onclick="itemFiler($item.id); return false;" class="filer-item filer-icon" title="$item.filer"></a>
+                       {{ endif }}
+
                        <div class="wall-item-delete-wrapper" id="wall-item-delete-wrapper-$item.id" >
                                {{ if $item.drop.dropping }}<a href="item/drop/$item.id" onclick="return confirmDelete();" class="icon drophide" title="$item.drop.delete" onmouseover="imgbright(this);" onmouseout="imgdull(this);" ></a>{{ endif }}
                        </div>
index 211906c9343c995f5e0b8b7bd7ec3470e89f04a6..c37bcb4a28bb81f4e96b5b449fe25274ce05418d 100755 (executable)
@@ -61,6 +61,9 @@
                        <a href="#" id="starred-$item.id" onclick="dostar($item.id); return false;" class="star-item icon $item.isstarred" title="$item.star.toggle"></a>
                        <a href="#" id="tagger-$item.id" onclick="itemTag($item.id); return false;" class="tag-item icon tagged" title="$item.star.tagger"></a>
                        {{ endif }}
+                       {{ if $item.filer }}
+                       <a href="#" id="filer-$item.id" onclick="itemFiler($item.id); return false;" class="filer-item filer-icon" title="$item.filer"></a>
+                       {{ endif }}
                        
                        <div class="wall-item-delete-wrapper" id="wall-item-delete-wrapper-$item.id" >
                                {{ if $item.drop.dropping }}<a href="item/drop/$item.id" onclick="return confirmDelete();" class="icon drophide" title="$item.drop.delete" onmouseover="imgbright(this);" onmouseout="imgdull(this);" ></a>{{ endif }}
diff --git a/view/theme/slack-NS/style.css b/view/theme/slack-NS/style.css
new file mode 100755 (executable)
index 0000000..82bceea
--- /dev/null
@@ -0,0 +1,51 @@
+@import url('../duepuntozero/style.css');
+
+.wall-item-content-wrapper {
+       border: none;
+}
+
+.wall-item-content-wrapper.comment {
+       background: #ffffff !important;
+       border-left: 1px solid #EEE;
+}
+
+.wall-item-tools {
+       background: none;
+}
+
+.wall-item-content { 
+       max-height: 20000px; 
+       overflow: none; 
+}
+
+.comment-edit-text-empty, .comment-edit-text-full {
+       border: none;
+       border-left: 1px solid #EEE;
+       background: #EEEEEE;
+}
+
+.comment-edit-wrapper, .comment-wwedit-wrapper {
+       background: #ffffff !important;
+}
+
+section {
+       margin: 0px 32px;
+}
+
+aside {
+       margin-left: 32px;
+}
+nav {
+       margin-left: 32px;
+       margin-right: 32px;
+}
+
+nav #site-location {
+       top: 80px;
+       right: 36px;
+}
+
+.wall-item-photo, .photo, .contact-block-img, .my-comment-photo {
+       border-radius: 3px;
+       -moz-border-radius: 3px;
+}
diff --git a/view/theme/slack-NS/theme.php b/view/theme/slack-NS/theme.php
new file mode 100755 (executable)
index 0000000..ceec4dd
--- /dev/null
@@ -0,0 +1,51 @@
+<?php
+$a->theme_info = array(
+  'extends' => 'duepuntozero',
+);
+
+$a->page['htmlhead'] .= <<< EOT
+<script>
+$(document).ready(function() {
+
+$('html').click(function() { $("#nav-notifications-menu" ).hide(); });
+
+$('.group-edit-icon').hover(
+       function() {
+               $(this).addClass('icon'); $(this).removeClass('iconspacer');},
+       function() {
+               $(this).removeClass('icon'); $(this).addClass('iconspacer');}
+       );
+
+$('.sidebar-group-element').hover(
+       function() {
+               id = $(this).attr('id');
+               $('#edit-' + id).addClass('icon'); $('#edit-' + id).removeClass('iconspacer');},
+
+       function() {
+               id = $(this).attr('id');
+               $('#edit-' + id).removeClass('icon');$('#edit-' + id).addClass('iconspacer');}
+       );
+
+
+$('.savedsearchdrop').hover(
+       function() {
+               $(this).addClass('drop'); $(this).addClass('icon'); $(this).removeClass('iconspacer');},
+       function() {
+               $(this).removeClass('drop'); $(this).removeClass('icon'); $(this).addClass('iconspacer');}
+       );
+
+$('.savedsearchterm').hover(
+       function() {
+               id = $(this).attr('id');
+               $('#drop-' + id).addClass('icon');      $('#drop-' + id).addClass('drophide'); $('#drop-' + id).removeClass('iconspacer');},
+
+       function() {
+               id = $(this).attr('id');
+               $('#drop-' + id).removeClass('icon');$('#drop-' + id).removeClass('drophide'); $('#drop-' + id).addClass('iconspacer');}
+       );
+
+});
+
+
+</script>
+EOT;