00001 <?php
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00020 function siteURL($removepagename = false) {
00021         $s = empty($_SERVER["HTTPS"]) ? ''
00022                 : ($_SERVER["HTTPS"] == "on") ? "s"
00023                 : "";
00024         $protocol = strleft(strtolower($_SERVER["SERVER_PROTOCOL"]), "/").$s;
00025         $port = ($_SERVER["SERVER_PORT"] == "80") ? "" : (":".$_SERVER["SERVER_PORT"]);
00026         
00027         if ($removepagename) {
00028                 $pagename = $protocol . "://" . $_SERVER['SERVER_NAME'] . $port . substr($_SERVER['SCRIPT_NAME'], 0, strlen($_SERVER['SCRIPT_NAME']) - 9);
00029         } else {
00030                 $pagename = $protocol . "://" . $_SERVER['SERVER_NAME'] . $port . $_SERVER['SCRIPT_NAME'];
00031         }
00032         return $pagename;
00033 }
00034 
00044 function thisPageURL($header = false, $absoluteURL = true, $extraReqVars = "") {
00045         global $page_id, $language, $viewUser, $globalID, $systemOptions;
00046         
00047         $reqVars = array();
00048                 
00049         global $systemOptions;
00050         if( $systemOptions["rewrite"] == 1 )
00051                 $temp_absoluteurl = siteURL( true );
00052         else
00053                 $temp_absoluteurl = siteURL() . "?globalID=";
00054         
00055 
00056 
00057 
00058         
00059         if( $header )
00060                 $separator = "&";
00061         else
00062                 $separator = "&";
00063 
00064         if( $globalID != "" )
00065                 $thispageurl = $temp_absoluteurl . $globalID;
00066         else
00067         {
00068                 if( $_REQUEST["userlist_page"] != "" )
00069                         $reqVars["userlist_page"] = $_REQUEST["userlist_page"];
00070                 if( $_REQUEST["user_id"] != "" )
00071                         $reqVars["user_id"] = $_REQUEST["user_id"];
00072                 if( $viewUser != "" )
00073                         $reqVars["user_id"] = $viewUser;
00074                 if( $_REQUEST["module"] != "" )
00075                         $reqVars["module"] = $_REQUEST["module"];
00076                 if( $_REQUEST["action"] != "" )
00077                         $reqVars["action"] = $_REQUEST["action"];
00078                 if( $_REQUEST["profile_mode"] != "" )
00079                         $reqVars["profile_mode"] = $_REQUEST['profile_mode'];
00080                 if( $_REQUEST["language"] != "" )
00081                         $reqVars["language"] = $language;
00082                 
00083                 $thispageurl = $temp_absoluteurl . "index.php?page_id=$page_id";
00084         }
00085         
00086         if( is_array( $extraReqVars ) )
00087         {
00088                 foreach( $extraReqVars as $name => $value )
00089                         $reqVars[$name] = $value;
00090         }
00091 
00092         foreach( $reqVars as $name => $value )
00093                 $extraparams .= $separator . $name . "=" . $value;
00094         
00095         return $thispageurl . $extraparams;
00096 }
00097 
00105 function globalID_user( $splitID )
00106 {
00107         global $viewUser;
00108         $pageID = null;
00109         
00110         if( $splitID[0] == "user" )
00111         {
00112                 $pageID = $_REQUEST["page_id"] = "13";
00113                 $viewUser = $splitID[1];
00114                 switch( $splitID[2] )
00115                 {
00116                 case null:
00117                 case "view":
00118                         break; 
00119                 case "new":
00120                         $_REQUEST["profile_mode"] = "new";
00121                         break;
00122                 case "mypage":
00123                         $_REQUEST["profile_mode"] = "mypage";
00124                         break;
00125                 case "edit":
00126                         $_REQUEST["profile_mode"] = "edit";
00127                         
00128                         if( $splitID[3] != null )
00129                                 $_REQUEST["edit_section"] = $splitID[3];
00130                         else
00131                                 $_REQUEST["edit_section"] = "general_information";
00132                         break;
00133                 case "contact":
00134                         $_REQUEST["profile_mode"] = "contact";
00135                         break;
00136                 default:
00137                         
00138                         return null;
00139                 }
00140         }
00141         
00142         return $pageID;
00143 }
00144 
00145 $modules_globalID[] = "globalID_user";
00146 
00179 function handleGlobalID()
00180 {
00181         global $modules_globalID, $page_id, $globalID;
00182         
00183         
00184         while( substr( $globalID, -1 ) == "/" )
00185                 $globalID = substr( $globalID, 0, -1 );
00186         
00187         $splitID = split( "/", $globalID );
00188         
00189         foreach( $modules_globalID as $key => $function )
00190         {
00191                 $tmpVal = $function( $splitID );
00192                 if( $tmpVal != null )
00193                         $pageID = $tmpVal;
00194         }
00195         
00196         
00197         if( $pageID == null )
00198                 $pageID = $page_id;
00199         
00200         return $pageID;
00201 }
00202 
00210 function getGlobalIDThumbnail( $globalID )
00211 {
00212         global $setup_folder;
00213         
00214         if( $globalID == "" )
00215                 $splitID = array();
00216         else
00217                 $splitID = split( "/", $globalID );
00218         
00219         if( $splitID[0] == "content" || count( $splitID ) == 0 )
00220         {
00221                 
00222                 $data = array( "uri" => siteURL(true) . $setup_folder . "/images/thumb-content.png", "width" => 64, "height" => 64 );
00223         }
00224         else if( $splitID[0] == "user" )
00225         {
00226                 $modulefunction = "globalIDThumbnail_" . $splitID[2];
00227                 
00228                 
00229                 if( array_key_exists( 2, $splitID ) && function_exists($modulefunction))
00230                 {
00231                         
00232                         $data = $modulefunction($splitID);
00233                 }
00234                 else
00235                 {
00236                         
00237                         $imageFile = getAvatarThumbnail( $splitID[1] );
00238                         list($width, $height) = getimagesize($imageFile);
00239                         $uri = siteURL(true) . $imageFile;
00240                         $data = array( "uri" => $uri, "width" => $width, "height" => $height );
00241                 }
00242         }
00243         else
00244         {
00245                 
00246                 
00247                 $modulefunction = "globalIDThumbnail_" . $splitID[0];
00248                 
00249                 if( function_exists($modulefunction) )
00250                 {
00251                         
00252                         $data = $modulefunction($splitID);
00253                 }
00254                 else
00255                 {
00256                         
00257                 $data = array( "uri" => siteURL(true) . $setup_folder . "/images/thumb-generic.png", "width" => 64, "height" => 64 );
00258                 }
00259         }
00260         
00261         return $data;
00262 }
00263 
00272 function globalIDtoURL( $globalID, $extraReqVars = null )
00273 {
00274         global $systemOptions;
00275         if( $systemOptions["rewrite"] == 1 )
00276                 $toplevel = siteURL( true );
00277         else
00278                 $toplevel = siteURL() . "?globalID=";
00279         
00280         if( $extraReqVars != null )
00281                 foreach( $extraReqVars as $name => $value )
00282                         $extraparams .= "&" . $name . "=" . $value;
00283         
00284         return $toplevel . $globalID . $extraparams;
00285 }
00286 ?>