Changeset 690

Show
Ignore:
Timestamp:
11/05/06 04:51:30 (2 years ago)
Author:
sven
Message:

more icon cacheability - all icon urls now /_icon/(user|file)/ID, to remove unused username variable and question marks

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • devel/_files/download.php

    r662 r690  
    1919        // ... and the owner of the file in the URL line hasn't been spoofed ... 
    2020        $files_name = optional_param('files_name'); 
    21         if (user_info_username('ident', $files_name) == $file->owner 
    22             || user_info_username('ident', $files_name) == $file->files_owner) { 
     21        $userid = user_info_username('ident', $files_name); 
     22        if ($userid == $file->owner || $userid == $file->files_owner) { 
    2323             
    2424            // ... and the current user is allowed to access it ... 
    25              
    26             if (run("users:access_level_check",$file->access) == true || $file->owner == $_SESSION['userid']) { 
    27                  
    28                 // ... and the file exists on disk ... 
     25            if ($file->access == 'PUBLIC' || $file->owner == $_SESSION['userid'] || run("users:access_level_check",$file->access) == true) { 
    2926                 
    3027                // Then output some appropriate headers and send the file data! 
    31                 require_once($CFG->dirroot . 'lib/filelib.php'); 
    32                 $mimetype = mimeinfo('type',$file->location); 
    33                  
    3428                if ($file->access == 'PUBLIC') { 
    3529                    header("Pragma: public"); 
     
    4034                    header("Cache-Control: private"); 
    4135                } 
     36                 
     37                require_once($CFG->dirroot . 'lib/filelib.php'); 
     38                $mimetype = mimeinfo('type',$file->location); 
    4239                 
    4340                if ($mimetype == "application/octet-stream") { 
  • devel/_files/icon.php

    r678 r690  
    1616    // ... and the file exists ... 
    1717    if ($file = get_record('files','ident',$id)) { 
    18         if (run("users:access_level_check",$file->access) == true) { 
     18        if ($file->access == 'PUBLIC' || run("users:access_level_check",$file->access) == true) { 
    1919             
    2020            require_once($CFG->dirroot . 'lib/filelib.php'); 
    2121            require_once($CFG->dirroot . 'lib/iconslib.php'); 
    2222             
     23            // images most likely don't want compressing, and this will kill the Vary header 
     24            @apache_setenv('no-gzip', '1'); 
     25             
     26            if ($file->access == 'PUBLIC') { 
     27                header("Pragma: public"); 
     28                header("Cache-Control: public"); 
     29            } else { 
     30                // "Cache-Control: private" to allow a user's browser to cache the file, but not a shared proxy 
     31                // Also to override PHP's default "DON'T EVER CACHE THIS EVER" header 
     32                header("Cache-Control: private"); 
     33            } 
     34             
    2335            $mimetype = mimeinfo('type',$file->originalname); 
    24             if ($mimetype == "image/jpeg" || $mimetype == "image/png") { 
     36            if ($mimetype == "image/jpeg" || $mimetype == "image/png" || $mimetype == "image/gif") { 
    2537                // file is an image 
    26                  
    27                 // images most likely don't want compressing, and this will kill the Vary header 
    28                 @apache_setenv('no-gzip', '1'); 
    29                  
    30                 if ($file->access == 'PUBLIC') { 
    31                     header("Pragma: public"); 
    32                     header("Cache-Control: public"); 
    33                 } else { 
    34                     // "Cache-Control: private" to allow a user's browser to cache the file, but not a shared proxy 
    35                     // Also to override PHP's default "DON'T EVER CACHE THIS EVER" header 
    36                     header("Cache-Control: private"); 
    37                 } 
    3838                 
    3939                $phpthumbconfig['w'] = 90; 
  • devel/_icons/icon.php

    r662 r690  
    22 
    33// User icon serving script. 
    4 // Usage: http://URL/{username}/icons/{icon_id} 
     4// Usage: http://URL/_icon/user/{icon_id} 
    55 
    66// Run includes 
    77define("context","icons"); 
    88require_once(dirname(dirname(__FILE__))."/includes.php"); 
    9 $textlib = textlib_get_instance(); 
    109 
    1110// If an ID number for the file has been specified ... 
     
    2423} 
    2524if (!$default) { 
    26     $upload_folder = $textlib->substr($user->username,0,1); 
     25    $upload_folder = substr($user->username,0,1); 
    2726    $filepath = $CFG->dataroot . "icons/" . $upload_folder . "/" . $user->username . "/".$file->filename;  
    2827    if (!file_exists($filepath)) { 
     
    7271    // 100 pixels requested, redirect to attributeless icon url for cacheability fun 
    7372    header($_SERVER['SERVER_PROTOCOL'] . " 301 Moved Permanently"); 
    74     header("Location: " . $CFG->wwwroot . $user->username . '/icons/' . $id); 
     73    header("Location: " . $CFG->wwwroot . '_icon/user/' . $id); 
    7574    die(); 
    7675} 
  • devel/htaccess-dist

    r675 r690  
    8181RewriteRule ^([A-Za-z0-9]+)\/files\/rss\/(.+)\/?$ _files/rss2.php?files_name=$1&tag=$2 
    8282 
    83 RewriteRule ^([A-Za-z0-9]+)\/icons\/([-0-9]+)\/?$ _icons/icon.php?id=$2 
    84 RewriteRule ^([A-Za-z0-9]+)\/icons\/([-0-9]+)\/([A-Za-z])\/([0-9]+)\/?$ _icons/icon.php?id=$2&constraint1=$3&size1=$4 
    85 RewriteRule ^([A-Za-z0-9]+)\/icons\/([-0-9]+)\/([A-Za-z])\/([0-9]+)\/([A-Za-z])\/([0-9]+)\/?$ _icons/icon.php?id=$2&constraint1=$3&size1=$4&constraint2=$5&size2=$6 
     83RewriteRule ^_icon\/user/([-0-9]+)\/?$ _icons/icon.php?id=$1 
     84RewriteRule ^_icon\/user/([-0-9]+)\/([A-Za-z])\/([0-9]+)\/?$ _icons/icon.php?id=$1&constraint1=$2&size1=$3 
     85RewriteRule ^_icon\/user/([-0-9]+)\/([A-Za-z])\/([0-9]+)\/([A-Za-z])\/([0-9]+)\/?$ _icons/icon.php?id=$1&constraint1=$2&size1=$3&constraint2=$4&size2=$5 
     86RewriteRule ^_icon\/file/([-0-9]+)\/?$ _files/icon.php?id=$1 
    8687 
    8788# Some blogging clients probe Wordpress or MoveableType endpoints, 
  • devel/lib/filelib.php

    r674 r690  
    509509        if ($tstamp < $timenow) { 
    510510            header("Last-Modified: " . $lm); 
    511         } 
    512          
    513         if ($tstamp < ($timenow - 3600)) { 
    514             header('Expires: ' . gmdate("D, d M Y H:i:s", ($timenow+3600)) . " GMT"); 
     511            if ($tstamp < ($timenow - 3600)) { 
     512                header('Expires: ' . gmdate("D, d M Y H:i:s", ($timenow+3600)) . " GMT"); 
     513            } 
    515514        } 
    516515         
     
    532531         
    533532        if ($mimetype) { 
    534             header("Content-type: $mimetype"); 
     533            header("Content-Type: $mimetype"); 
    535534        } 
    536535        readfile($filepath); 
     536    } else { 
     537        header("{$_SERVER['SERVER_PROTOCOL']} 404 Not Found"); 
    537538    } 
    538539    exit; 
  • devel/lib/templates.php

    r665 r690  
    12741274                      <td align="center"> 
    12751275                         <div class="image_holder"> 
    1276                          <a href="{$CFG->wwwroot}{$user->username}/"><img src="{$CFG->wwwroot}{$user->username}/icons/{$user->iconid}/w/80/h/80" border="0" /></a> 
     1276                         <a href="{$CFG->wwwroot}{$user->username}/"><img src="{$CFG->wwwroot}_icon/user/{$user->iconid}/w/80/h/80" border="0" /></a> 
    12771277                         </div> 
    12781278                        <div class="userdetails"> 
  • devel/mod/browser/index.php

    r666 r690  
    177177                $description = get_record_sql("SELECT ".$CFG->prefix."profile_data.value FROM ".$CFG->prefix."profile_data WHERE owner = {$result->ident} AND name = 'minibio'"); 
    178178                 
    179                 $icon = "{$CFG->wwwroot}{$result->username}/icons/{$result->icon}/h/67/"; 
     179                $icon = "{$CFG->wwwroot}_icon/user/{$result->icon}/h/67/"; 
    180180                 
    181181                $description = @stripslashes($description->value); 
  • devel/profile/profile.class.php

    r659 r690  
    305305                        <p> 
    306306                        <a href="{$CFG->wwwroot}{$friends_username}/"> 
    307                         <img src="{$CFG->wwwroot}{$friends_username}/icons/{$info->icon}/w/{$width}" alt="{$friends_name}" border="0" /></a><br /> 
     307                        <img src="{$CFG->wwwroot}_icon/user/{$info->icon}/w/{$width}" alt="{$friends_name}" border="0" /></a><br /> 
    308308                        <span class="userdetails"> 
    309309                        {$friends_name} 
     
    377377                                          WHERE '.$searchline)) { 
    378378                foreach($result as $key => $info) { 
    379                     $icon = url . $info->username . '/icons/'.$post->icon; 
     379                    $icon = url . '_icon/user/'.$post->icon; 
    380380                    $sub_result .= "\t\t\t<item>\n"; 
    381381                    $sub_result .= "\t\t\t\t<name><![CDATA[" . htmlspecialchars(stripslashes($info->name), ENT_COMPAT, 'utf-8') . "]]></name>\n"; 
     
    808808     
    809809        // If this is someone else's portfolio, display the user's icon 
    810         $run_result = "<div class=\"box_user\">"
     810        $run_result = '<div class="box_user">'
    811811         
    812812        $info = get_record('users','ident',$page_owner); 
     
    818818        } 
    819819         
    820         $icon = "<img alt=\"\" src=\"".url.$info->username.'icons/'.$info->icon.'/w/67" />'; 
     820        $icon = '<img alt="" src="' . url . '_icon/user/' . $info->icon . '/w/67" />'; 
    821821        $name = stripslashes($info->name); 
    822822        $url = url . $info->username . "/"; 
  • devel/units/admin/admin_users_add.php

    r659 r690  
    66             
    77            global $admin_users_add; 
    8             if (!isset($admin_users_add)) { 
    9                 $admin_users_add = array("", "", "", "", "", "", "", "", "", "", "", ""); 
    10             } else { 
    11                 for ($i = 0; $i < 12; $i++) { 
    12                     if (!isset($admin_users_add[$i])) { 
    13                         $admin_users_add[$i] = ""; 
    14                     } 
     8            for ($i = 0; $i < 12; $i++) { 
     9                if (!isset($admin_users_add[$i])) { 
     10                    //$admin_users_add[$i] = ""; 
     11                    $admin_users_add[$i]->username = ""; 
     12                    $admin_users_add[$i]->name = ""; 
     13                    $admin_users_add[$i]->email = ""; 
    1514                } 
    1615            } 
  • devel/units/communities/communities_edit.php

    r659 r690  
    3232                    <p> 
    3333                    <a href="{$CFG->wwwroot}{$info->username}/"> 
    34                     <img src="{$CFG->wwwroot}{$info->username}/icons/{$info->icon}/w/{$w}" alt="{$friends_name}" border="0" /></a><br /> 
     34                    <img src="{$CFG->wwwroot}_icon/user/{$info->icon}/w/{$w}" alt="{$friends_name}" border="0" /></a><br /> 
    3535                    <span class="userdetails"> 
    3636                        <a href="{$CFG->wwwroot}{$info->username}/">{$friends_name}</a> 
  • devel/units/communities/communities_members.php

    r659 r690  
    3232                    <p> 
    3333                    <a href="{$CFG->wwwroot}{$info->username}/"> 
    34                     <img src="{$CFG->wwwroot}{$info->username}/icons/{$info->icon}/w/{$w}" alt="{$friends_name}" border="0" /></a><br /> 
     34                    <img src="{$CFG->wwwroot}_icon/user/{$info->icon}/w/{$w}" alt="{$friends_name}" border="0" /></a><br /> 
    3535                    <span class="userdetails"> 
    3636                        {$friends_name} 
  • devel/units/communities/communities_membership_requests.php

    r659 r690  
    3737                    $body .= templates_draw(array( 
    3838                                                        'context' => 'adminTable', 
    39                                                         'name' => "<img src=\"" . url . "{$pending_user->username}/icons/{$pending_user->icon}/" . $icon . "\" />", 
     39                                                        'name' => "<img src=\"" . url . "_icon/user/{$pending_user->icon}/" . $icon . "\" />", 
    4040                                                        'column1' => $col1, 
    4141                                                        'column2' => $col2 
  • devel/units/communities/communities_moderator_of.php

    r659 r690  
    3131            <p> 
    3232            <a href="{$CFG->wwwroot}{$info->username}/"> 
    33             <img src="{$CFG->wwwroot}{$info->username}/icons/{$info->icon}/w/{$w}" alt="{$friends_name}" border="0" /></a><br /> 
     33            <img src="{$CFG->wwwroot}_icon/user/{$info->icon}/w/{$w}" alt="{$friends_name}" border="0" /></a><br /> 
    3434            <span class="userdetails"> 
    3535                <a href="{$CFG->wwwroot}{$info->username}/">{$friends_name}</a> 
  • devel/units/files/files_links_make.php

    r676 r690  
    3939                    $run_result .= $CFG->wwwroot . user_info('username', $file->owner) . "/files/" . $file->folder . "/" . $file->ident . "/" . $file->originalname; 
    4040                    $run_result .= "\" >"; 
    41                     $run_result .= '<img src="' . $CFG->wwwroot . '_files/icon.php?id=' . $file->ident . '" alt="' . htmlspecialchars(stripslashes($file->title), ENT_COMPAT, 'utf-8') . '" />'; 
     41                    $run_result .= '<img src="' . $CFG->wwwroot . '_icon/file/' . $file->ident . '" alt="' . htmlspecialchars(stripslashes($file->title), ENT_COMPAT, 'utf-8') . '" />'; 
    4242                    $run_result .= "</a>"; 
    4343                } else { 
  • devel/units/files/folder_view.php

    r679 r690  
    118118            $originalname = stripslashes($file->originalname); 
    119119            $filemenu = round(($file->size / 1000000),4) . "Mb "; 
    120             $icon = $CFG->wwwroot . "_files/icon.php?id=" . $file->ident; 
     120            $icon = $CFG->wwwroot . "_icon/file/" . $file->ident; 
    121121            $filepath = $CFG->wwwroot . "$username/files/$folder/$ident/" . urlencode($originalname); 
    122122            require_once($CFG->dirroot.'lib/filelib.php'); 
  • devel/units/files/function_search.php

    r659 r690  
    133133            <p> 
    134134            <a href="{$CFG->wwwroot}search/index.php?file={$link_keyword}&amp;owner={$friends_userid}"> 
    135             <img src="{$CFG->wwwroot}{$info->username}/icons/{$info->icon}/w/{$w}" alt="{$friends_name}" border="0" /></a><br /> 
     135            <img src="{$CFG->wwwroot}_icon/user/{$info->icon}/w/{$w}" alt="{$friends_name}" border="0" /></a><br /> 
    136136            <span class="userdetails"> 
    137137                {$friends_name} 
  • devel/units/friends/friends_edit.php

    r659 r690  
    3131            <p> 
    3232            <a href="{$CFG->wwwroot}{$info->username}/"> 
    33             <img src="{$CFG->wwwroot}{$info->username}/icons/{$info->icon}/w/{$w}" alt="{$friends_name}" border="0" /></a><br /> 
     33            <img src="{$CFG->wwwroot}_icon/user/{$info->icon}/w/{$w}" alt="{$friends_name}" border="0" /></a><br /> 
    3434            <span class="userdetails"> 
    3535                <a href="{$CFG->wwwroot}{$info->username}/">{$friends_name}</a> 
  • devel/units/friends/friends_of_edit.php

    r659 r690  
    3232            <p> 
    3333            <a href="{$CFG->wwwroot}{$info->username}/"> 
    34             <img src="{$CFG->wwwroot}{$info->username}/icons/{$info->icon}/w/{$w}" alt="{$friends_name}" border="0" /></a><br /> 
     34            <img src="{$CFG->wwwroot}_icon/user/{$info->icon}/w/{$w}" alt="{$friends_name}" border="0" /></a><br /> 
    3535            <span class="userdetails"> 
    3636                <a href="{$CFG->wwwroot}{$info->username}/">{$friends_name}</a> 
  • devel/units/friends/generate_foaf.php

    r454 r690  
    1212     
    1313    if ($user->icon != -1) { 
    14         $iconstring = "<foaf:depiction rdf:resource=\"". $CFG->wwwroot . $user->username."/icons/".$user->icon."\" />"; 
     14        $iconstring = "<foaf:depiction rdf:resource=\"". $CFG->wwwroot . "_icon/user/".$user->icon."\" />"; 
    1515    } else { 
    1616        $iconstring = ""; 
     
    5757        $foafurl = $personalurl . "foaf/"; 
    5858        if ($friend->icon != -1) { 
    59             $iconstring = "<foaf:depiction rdf:resource=\"". url . $friend->username."/icons/".$friend->icon."\" />"; 
     59            $iconstring = "<foaf:depiction rdf:resource=\"". url . "_icon/user/".$friend->icon."\" />"; 
    6060        } else { 
    6161            $iconstring = ""; 
  • devel/units/friends/user_friendship_requests.php

    r659 r690  
    4040                    $body .= templates_draw(array( 
    4141                                                        'context' => 'adminTable', 
    42                                                         'name' => "<img src=\"" . url . "{$pending_user->username}/icons/{$pending_user->icon}\" />", 
     42                                                        'name' => "<img src=\"" . url . "_icon/user/{$pending_user->icon}\" />", 
    4343                                                        'column1' => $col1, 
    4444                                                        'column2' => $col2 
  • devel/units/icons/function_edit_icons.php

    r659 r690  
    4646        $defaulticon = htmlspecialchars(stripslashes($icon->description), ENT_COMPAT, 'utf-8'); 
    4747        $column1 = <<< END 
    48                         <img alt="{$defaulticon}" src="{$CFG->wwwroot}{$page_username}/icons/{$icon->ident}" /> 
     48                        <img alt="{$defaulticon}" src="{$CFG->wwwroot}_icon/user/{$icon->ident}" /> 
    4949END; 
    5050        if ($icon->filename == $currenticon) { 
  • devel/units/profile/function_search.php

    r659 r690  
    6161            <p> 
    6262            <a href="{$CFG->wwwroot}{$friends_username}/"> 
    63             <img src="{$CFG->wwwroot}{$friends_username}/icons/{$info->icon}/w/{$w}" alt="{$friends_name}" border="0" /></a><br /> 
     63            <img src="{$CFG->wwwroot}_icon/user/{$info->icon}/w/{$w}" alt="{$friends_name}" border="0" /></a><br /> 
    6464            <span class="userdetails"> 
    6565                <a href="{$CFG->wwwroot}{$friends_username}/">{$friends_name}</a> 
  • devel/units/profile/function_search_ecl.php

    r454 r690  
    2424                foreach($result as $key => $info) { 
    2525                     
    26                     $icon = url . $info->username . "/icons/".$info->icon; 
     26                    $icon = url . "_icon/user/".$info->icon; 
    2727                     
    2828                    $sub_result .= "\t\t\t<item>\n"; 
  • devel/units/profile/profile_user_info.php

    r659 r690  
    1919$info->icon = run("icons:get", $page_owner); 
    2020 
    21 $icon = '<img alt="" src="'.url. $ul_username.'/icons/'.$info->icon.'/h/67/w/67" border="0" />'; // height is the important one here. 
     21$icon = '<img alt="" src="'.url. '_icon/user/'.$info->icon.'/h/67/w/67" border="0" />'; // height is the important one here. 
    2222$name = stripslashes($info->name);  
    2323//$name = run("profile:display:name"); 
  • devel/units/rpc/lib/class_user.php

    r471 r690  
    8484                } 
    8585 
    86                 $this->icon = url.$this->username.'/icons/'.$info->icon; 
     86                $this->icon = url . '_icon/user/' . $info->icon; 
    8787            } 
    8888        } 
  • devel/units/weblogs/default_template.php

    r659 r690  
    2828    <div class="entry"><!-- Open class entry --> 
    2929        <div class="user"><!-- Open class user --> 
    30             <a href="{{url}}{{username}}/weblog/"><img alt="" src="{{url}}{{username}}/icons/{{usericon}}"/></a><br /><a href="{{url}}{{username}}/weblog/">{{fullname}}</a> 
     30            <a href="{{url}}{{username}}/weblog/"><img alt="" src="{{url}}_icon/user/{{usericon}}"/></a><br /><a href="{{url}}{{username}}/weblog/">{{fullname}}</a> 
    3131        </div><!-- Close class user --> 
    3232        <div class="weblog_title"><h3>{{title}}</h3></div> 
     
    8585<li> 
    8686    {{body}} 
    87        <div class="comment_owner"> 
     87    <div class="comment_owner"> 
    8888    <p> 
    8989        {{usericon}}{{postedname}} on {{posted}} <a href="{{permalink}}">#</a> 
    9090    </p> 
    91        </div> 
     91    </div> 
    9292</li> 
    9393 
  • devel/units/weblogs/function_search.php

    r659 r690  
    102102            <p> 
    103103            <a href="{$CFG->wwwroot}search/index.php?weblog={$link_keyword}&amp;owner={$friends_userid}"> 
    104             <img src="{$CFG->wwwroot}{$info->username}/icons/{$info->icon}/w/{$w}" alt="{$friends_name}" border="0" /></a><br /> 
     104            <img src="{$CFG->wwwroot}_icon/user/{$info->icon}/w/{$w}" alt="{$friends_name}" border="0" /></a><br /> 
    105105            <span class="userdetails"> 
    106106                {$friends_name} 
  • devel/units/weblogs/weblogs_posts_view.php

    r673 r690  
    162162                        $commentownerusername = user_info('username', $comment->owner); 
    163163                        $comment->postedname = '<a href="' . url . $commentownerusername . '/">' . $comment->postedname . '</a>'; 
    164                         $comment->icon = '<a href="' . url . $commentownerusername . '/">' . "<img src=\"" . $CFG->wwwroot . $commentownerusername . "/icons/" . run("icons:get",$comment->owner) . "/w/50/h/50/\" border=\"0\" align=\"left\" alt=\"\" /></a>"; 
     164                        $comment->icon = '<a href="' . url . $commentownerusername . '/">' . "<img src=\"" . $CFG->wwwroot . "_icon/user/" . run("icons:get",$comment->owner) . "/w/50/h/50/\" border=\"0\" align=\"left\" alt=\"\" /></a>"; 
    165165                        $comment->body = run("weblogs:text:process", array($comment->body, false)); 
    166166                    } else {