Changeset 110

Show
Ignore:
Timestamp:
01/14/06 08:12:05 (3 years ago)
Author:
sven
Message:

more sql and getimagesize() optimisation

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • devel/profile/rss2.php

    r92 r110  
    4747                                } else { 
    4848                                        $tag = trim($_REQUEST['tag']); 
    49                                         $entries = db_query("select weblog_posts.* from tags left join weblog_posts on weblog_posts.ident = tags.ref where weblog_posts.weblog = $page_owner and weblog_posts.access = 'PUBLIC' and tags.tag = '$tag' and tags.tagtype = 'weblog' order by weblog_posts.posted desc limit 10"); 
     49                                        $entries = db_query("select weblog_posts.* from tags join weblog_posts on weblog_posts.ident = tags.ref where weblog_posts.weblog = $page_owner and weblog_posts.access = 'PUBLIC' and tags.tag = '$tag' and tags.tagtype = 'weblog' order by weblog_posts.posted desc limit 10"); 
    5050                                } 
    5151                                if (sizeof($entries) > 0) { 
     
    8080                                } else { 
    8181                                        $tag = trim($_REQUEST['tag']); 
    82                                         $files = db_query("select files.* from tags left join files on files.ident = tags.ref where files.files_owner = $page_owner and files.access = 'PUBLIC' and tags.tagtype = 'file' and tags.tag = '$tag' order by files.time_uploaded desc limit 10"); 
     82                                        $files = db_query("select files.* from tags join files on files.ident = tags.ref where files.files_owner = $page_owner and files.access = 'PUBLIC' and tags.tagtype = 'file' and tags.tag = '$tag' order by files.time_uploaded desc limit 10"); 
    8383                                } 
    8484                                if (sizeof($files) > 0) { 
  • devel/units/communities/communities_access_levels.php

    r45 r110  
    1414                 
    1515                $communities = db_query("select users.* from friends  
    16                                                                                 left join users on users.ident = friends.friend  
     16                                                                                join users on users.ident = friends.friend  
    1717                                                                                where users.user_type = 'community'  
    1818                                                                                and users.owner <> " . $_SESSION['userid'] . " 
  • devel/units/communities/communities_edit.php

    r106 r110  
    2020                $i = 1; 
    2121                if (sizeof ($result) > 0) { 
     22                         
     23                        $icon = "default.png"; 
     24                        $defaulticonparams = @getimagesize(path . "_icons/data/default.png"); 
     25                         
    2226                        foreach($result as $key => $info) { 
     27                                list($width, $height, $type, $attr) = $defaulticonparams; 
    2328                                // $info = $info[0]; 
    2429                                if ($info->icon != -1) { 
     
    2631                                        if (sizeof($icon) == 1) { 
    2732                                                $icon = $icon[0]->filename; 
    28                                         } else { 
    29                                                 $icon = "default.png"; 
     33                                                if (!(list($width, $height, $type, $attr) = @getimagesize(path . "_icons/data/" . $icon))) { 
     34                                                        $icon = "default.png"; 
     35                                                        list($width, $height, $type, $attr) = $defaulticonparams; 
     36                                                } 
    3037                                        } 
    31                                 } else { 
    32                                         $icon = "default.png"; 
    3338                                } 
    34                                 list($width, $height, $type, $attr) = getimagesize(path . "_icons/data/" . $icon); 
     39                                 
    3540                                if (sizeof($parameter[1]) > 4) { 
    3641                                        $width = round($width / 2); 
  • devel/units/communities/communities_members.php

    r84 r110  
    1010                 
    1111                $result = db_query("select users.*, friends.ident as friendident from friends 
    12                                                                         left join users on users.ident = friends.owner 
     12                                                                        join users on users.ident = friends.owner 
    1313                                                                        where friends.friend = $user_id and users.user_type = 'person'"); 
    1414                                                                         
     
    2020                $i = 1; 
    2121                if (sizeof ($result) > 0) { 
     22                         
     23                        $icon = "default.png"; 
     24                        $defaulticonparams = @getimagesize(path . "_icons/data/default.png"); 
     25                         
    2226                        foreach($result as $key => $info) { 
     27                                list($width, $height, $type, $attr) = $defaulticonparams; 
    2328                                // $info = $info[0]; 
    2429                                if ($info->icon != -1) { 
     
    2631                                        if (sizeof($icon) == 1) { 
    2732                                                $icon = $icon[0]->filename; 
    28                                         } else { 
    29                                                 $icon = "default.png"; 
     33                                                if (!(list($width, $height, $type, $attr) = @getimagesize(path . "_icons/data/" . $icon))) { 
     34                                                        $icon = "default.png"; 
     35                                                        list($width, $height, $type, $attr) = $defaulticonparams; 
     36                                                } 
    3037                                        } 
    31                                 } else { 
    32                                         $icon = "default.png"; 
    3338                                } 
    34                                 list($width, $height, $type, $attr) = getimagesize(path . "_icons/data/" . $icon); 
     39                                 
    3540                                if (sizeof($parameter[1]) > 4) { 
    3641                                        $width = round($width / 2); 
  • devel/units/communities/communities_moderator_of.php

    r84 r110  
    1919                $i = 1; 
    2020                if (sizeof ($result) > 0) { 
     21                         
     22                        $icon = "default.png"; 
     23                        $defaulticonparams = @getimagesize(path . "_icons/data/default.png"); 
     24                         
    2125                        foreach($result as $key => $info) { 
    22                                         // $info = $info[0]; 
    23                                         if ($info->icon != -1) { 
    24                                                 $icon = db_query("select filename from icons where ident = " . $info->icon . " and owner = " . $info->ident); 
    25                                                 if (sizeof($icon) == 1) { 
    26                                                         $icon = $icon[0]->filename; 
    27                                                 } else { 
     26                                list($width, $height, $type, $attr) = $defaulticonparams; 
     27                                // $info = $info[0]; 
     28                                if ($info->icon != -1) { 
     29                                        $icon = db_query("select filename from icons where ident = " . $info->icon . " and owner = " . $info->ident); 
     30                                        if (sizeof($icon) == 1) { 
     31                                                $icon = $icon[0]->filename; 
     32                                                if (!(list($width, $height, $type, $attr) = @getimagesize(path . "_icons/data/" . $icon))) { 
    2833                                                        $icon = "default.png"; 
     34                                                        list($width, $height, $type, $attr) = $defaulticonparams; 
    2935                                                } 
    30                                         } else { 
    31                                                 $icon = "default.png"; 
    3236                                        } 
    33                                         list($width, $height, $type, $attr) = getimagesize(path . "_icons/data/" . $icon); 
    34                                         if (sizeof($parameter[1]) > 4) { 
    35                                                 $width = round($width / 2); 
    36                                                 $height = round($height / 2); 
    37                                         } 
    38                 $friends_username = stripslashes($info->username); 
    39                 $friends_name = htmlentities(stripslashes($info->name)); 
    40                 // $friends_menu = run("users:infobox:menu",array($info->ident)); 
    41                 $body .= <<< END 
     37                                } 
     38                                 
     39                                if (sizeof($parameter[1]) > 4) { 
     40                                        $width = round($width / 2); 
     41                                        $height = round($height / 2); 
     42                                } 
     43                                $friends_username = stripslashes($info->username); 
     44                                $friends_name = htmlentities(stripslashes($info->name)); 
     45                                // $friends_menu = run("users:infobox:menu",array($info->ident)); 
     46                                $body .= <<< END 
    4247                <td> 
    4348                        <p> 
     
    5055                </td> 
    5156END; 
    52                                        if ($i % 5 == 0) { 
    53                                                $body .= "</tr><tr>"; 
    54                                        
    55                                        $i++; 
     57                                if ($i % 5 == 0) { 
     58                                        $body .= "</tr><tr>"; 
     59                               
     60                                $i++; 
    5661                        } 
    5762                } else { 
  • devel/units/communities/community_memberships.php

    r85 r110  
    66                if (run("users:type:get", $page_owner) == "person") { 
    77                        $result = db_query("select users.ident, users.username, users.name from friends 
    8                                                                                 left join users on users.ident = friends.friend 
     8                                                                                join users on users.ident = friends.friend 
    99                                                                                where friends.owner = $page_owner 
    1010                                                                                and users.user_type = 'community' 
    11                                                                                 and users.owner != $page_owner 
    12                                                                                 group by friends.friend"); 
     11                                                                                and users.owner != " . $page_owner); 
    1312                                 
    1413                        if (sizeof($result) > 0) { 
     
    3130                } else if (run("users:type:get", $page_owner) == "community") { 
    3231                        $result = db_query("select users.ident from friends 
    33                                                                                 left join users on users.ident = friends.owner 
     32                                                                                join users on users.ident = friends.owner 
    3433                                                                                where friends.friend = $page_owner 
    3534                                                                                group by friends.owner 
  • devel/units/files/edit_file.php

    r85 r110  
    99                $file_id = (int) $_REQUEST['edit_file_id']; 
    1010         
    11                 $file_details = db_query("select files.*, users.username from files left join users on users.ident = files.owner where files.ident = $file_id"); 
     11                $file_details = db_query("select files.*, users.username from files join users on users.ident = files.owner where files.ident = $file_id"); 
    1212                if (sizeof($file_details) > 0 && (run("permissions:check", array("files:edit",$file_details[0]->owner)) || run("permissions:check", array("files:edit",$file_details[0]->files_owner)))) { 
    1313                        $file = $file_details[0]; 
  • devel/units/files/files_links_make.php

    r45 r110  
    3434                                                } 
    3535                                        } else { 
    36                                                 list($width, $height, $type, $attr) = getimagesize($file[0]->location); 
     36                                                list($width, $height, $type, $attr) = @getimagesize($file[0]->location); 
    3737                                                if ($width > 400 || $height > 400) { 
    3838                                                        $run_result .= "<a href=\""; 
  • devel/units/files/function_search.php

    r106 r110  
    8282                        $body = "<table><tr>"; 
    8383                        $i = 1; 
     84                        $icon = "default.png"; 
     85                        $defaulticonparams = @getimagesize(path . "_icons/data/default.png"); 
     86                         
    8487                        foreach($users as $key => $info) { 
    85          
    86                                         // $info = $info[0]; 
    87                                         if ($info->icon != -1) { 
    88                                                 $icon = db_query("select filename from icons where ident = " . $info->icon . " and owner = " . $info->ident); 
    89                                                 if (sizeof($icon) == 1) { 
    90                                                         $icon = $icon[0]->filename; 
    91                                                 } else { 
     88                                 
     89                                list($width, $height, $type, $attr) = $defaulticonparams; 
     90                                // $info = $info[0]; 
     91                                if ($info->icon != -1) { 
     92                                        $icon = db_query("select filename from icons where ident = " . $info->icon . " and owner = " . $info->ident); 
     93                                        if (sizeof($icon) == 1) { 
     94                                                $icon = $icon[0]->filename; 
     95                                                if (!(list($width, $height, $type, $attr) = @getimagesize(path . "_icons/data/" . $icon))) { 
    9296                                                        $icon = "default.png"; 
     97                                                        list($width, $height, $type, $attr) = $defaulticonparams; 
    9398                                                } 
    94                                         } else { 
    95                                                 $icon = "default.png"; 
    9699                                        } 
    97                                          
    98                                         if (!(list($width, $height, $type, $attr) = @getimagesize(path . "_icons/data/" . $icon))) { 
    99                                                 $icon = "default.png"; 
    100                                                 list($width, $height, $type, $attr) = getimagesize(path . "_icons/data/" . $icon); 
    101                                         } 
    102                                          
    103                                         if (sizeof($users) > 4) { 
    104                                                 $width = round($width / 2); 
    105                                                 $height = round($height / 2); 
    106                                         } 
    107                 $friends_userid = $info->ident; 
    108                 $friends_name = htmlentities(stripslashes($info->name)); 
    109                 $friends_menu = run("users:infobox:menu",array($info->ident)); 
    110                 $link_keyword = urlencode($parameter[1]); 
    111                 $width = round($width / 2); 
    112                 $height = round($height / 2); 
    113                 $body .= <<< END 
     100                                } 
     101                                 
     102                                if (sizeof($users) > 4) { 
     103                                        $width = round($width / 2); 
     104                                        $height = round($height / 2); 
     105                                } 
     106                                $friends_userid = $info->ident; 
     107                                $friends_name = htmlentities(stripslashes($info->name)); 
     108                                $friends_menu = run("users:infobox:menu",array($info->ident)); 
     109                                $link_keyword = urlencode($parameter[1]); 
     110                                $width = round($width / 2); 
     111                                $height = round($height / 2); 
     112                                $body .= <<< END 
    114113                <td align="center"> 
    115114                        <p> 
     
    123122                </td> 
    124123END; 
    125                                        if ($i % 5 == 0) { 
    126                                                $body .= "\n</tr><tr>\n"; 
    127                                        
    128                                        $i++; 
     124                                if ($i % 5 == 0) { 
     125                                        $body .= "\n</tr><tr>\n"; 
     126                               
     127                                $i++; 
    129128                        } 
    130129                        $body .= "</tr></table>"; 
  • devel/units/files/function_search_rss.php

    r45 r110  
    1616                $searchline_folders = str_replace("access", "file_folders.access", $searchline_folders); 
    1717                $searchline_folders = str_replace("owner", "file_folders.owner", $searchline_folders); 
    18                 $file_refs = db_query("select files.*, users.username, users.name as fullname, ref from tags left join files on files.ident = tags.ref left join users on users.ident = tags.owner where $searchline_files limit 50"); 
    19                 $folder_refs = db_query("select file_folders.*, users.username, users.name as fullname, ref from tags left join file_folders on file_folders.ident = tags.ref left join users on users.ident = tags.owner where $searchline_folders limit 50"); 
     18                $file_refs = db_query("select files.*, users.username, users.name as fullname, ref from tags join files on files.ident = tags.ref join users on users.ident = tags.owner where $searchline_files limit 50"); 
     19                $folder_refs = db_query("select file_folders.*, users.username, users.name as fullname, ref from tags join file_folders on file_folders.ident = tags.ref join users on users.ident = tags.owner where $searchline_folders limit 50"); 
    2020                $searchline = ""; 
    2121                if (sizeof($folder_refs) > 0) { 
  • devel/units/friends/friends_edit.php

    r106 r110  
    2020                $i = 1; 
    2121                if (sizeof ($result) > 0) { 
     22                         
     23                        $icon = "default.png"; 
     24                        $defaulticonparams = @getimagesize(path . "_icons/data/default.png"); 
     25                         
    2226                        foreach($result as $key => $info) { 
    23                                         // $info = $info[0]; 
    24                                         if ($info->icon != -1) { 
    25                                                 $icon = db_query("select filename from icons where ident = " . $info->icon . " and owner = " . $info->ident); 
    26                                                 if (sizeof($icon) == 1) { 
    27                                                         $icon = $icon[0]->filename; 
    28                                                 } else { 
     27                                list($width, $height, $type, $attr) = $defaulticonparams; 
     28                                // $info = $info[0]; 
     29                                if ($info->icon != -1) { 
     30                                        $icon = db_query("select filename from icons where ident = " . $info->icon . " and owner = " . $info->ident); 
     31                                        if (sizeof($icon) == 1) { 
     32                                                $icon = $icon[0]->filename; 
     33                                                if (!(list($width, $height, $type, $attr) = @getimagesize(path . "_icons/data/" . $icon))) { 
    2934                                                        $icon = "default.png"; 
     35                                                        list($width, $height, $type, $attr) = $defaulticonparams; 
    3036                                                } 
    31                                         } else { 
    32                                                 $icon = "default.png"; 
    3337                                        } 
    34                                          
    35                                         if (!(list($width, $height, $type, $attr) = @getimagesize(path . "_icons/data/" . $icon))) { 
    36                                                 $icon = "default.png"; 
    37                                                 list($width, $height, $type, $attr) = getimagesize(path . "_icons/data/" . $icon); 
    38                                         } 
    39                                          
    40                                         if (sizeof($parameter[1]) > 4) { 
    41                                                 $width = round($width / 2); 
    42                                                 $height = round($height / 2); 
    43                                         } 
    44                 $friends_username = stripslashes($info->username); 
    45                 $friends_name = htmlentities(stripslashes($info->name)); 
    46                 $friends_menu = run("users:infobox:menu",array($info->ident)); 
    47                 $body .= <<< END 
     38                                } 
     39                                 
     40                                if (sizeof($parameter[1]) > 4) { 
     41                                        $width = round($width / 2); 
     42                                        $height = round($height / 2); 
     43                                } 
     44                                $friends_username = stripslashes($info->username); 
     45                                $friends_name = htmlentities(stripslashes($info->name)); 
     46                                $friends_menu = run("users:infobox:menu",array($info->ident)); 
     47                                $body .= <<< END 
    4848                <td> 
    4949                        <p> 
     
    5757                </td> 
    5858END; 
    59                                        if ($i % 5 == 0) { 
    60                                                $body .= "</tr><tr>"; 
    61                                        
    62                                        $i++; 
     59                                if ($i % 5 == 0) { 
     60                                        $body .= "</tr><tr>"; 
     61                               
     62                                $i++; 
    6363                        } 
    6464                } else { 
  • devel/units/friends/friends_of_edit.php

    r106 r110  
    1414 
    1515                $body = <<< END 
    16  
    1716        <div class="networktable"> 
    1817        <table> 
    1918                <tr> 
    20  
    2119END; 
    2220                $i = 1; 
    2321                if (sizeof ($result) > 0) { 
     22                         
     23                        $icon = "default.png"; 
     24                        $defaulticonparams = @getimagesize(path . "_icons/data/default.png"); 
     25                         
    2426                        foreach($result as $key => $info) { 
    25                                         // $info = $info[0]; 
    26                                         if ($info->icon != -1) { 
    27                                                 $icon = db_query("select filename from icons where ident = " . $info->icon . " and owner = " . $info->ident); 
    28                                                 if (sizeof($icon) == 1) { 
    29                                                         $icon = $icon[0]->filename; 
    30                                                 } else { 
     27                                list($width, $height, $type, $attr) = $defaulticonparams; 
     28                                // $info = $info[0]; 
     29                                if ($info->icon != -1) { 
     30                                        $icon = db_query("select filename from icons where ident = " . $info->icon . " and owner = " . $info->ident); 
     31                                        if (sizeof($icon) == 1) { 
     32                                                $icon = $icon[0]->filename; 
     33                                                if (!(list($width, $height, $type, $attr) = @getimagesize(path . "_icons/data/" . $icon))) { 
    3134                                                        $icon = "default.png"; 
    32                                                 } 
    33                                         } else { 
    34                                                 $icon = "default.png"; 
    35                                         } 
    36                                         $result = @getimagesize(path . "_icons/data/" . $icon); 
    37                                         if ($result != false) { 
    38                                                 list($width, $height, $type, $attr) = $result; 
    39                                                 if (sizeof($parameter[1]) > 4) { 
    40                                                         $width = round($width / 2); 
    41                                                         $height = round($height / 2); 
     35                                                        list($width, $height, $type, $attr) = $defaulticonparams; 
    4236                                                } 
    4337                                        } 
    44                 $friends_username = stripslashes($info->username); 
    45                 $friends_name = htmlentities(stripslashes($info->name)); 
    46                 $friends_menu = run("users:infobox:menu",array($info->ident)); 
    47                 $body .= <<< END 
     38                                } 
     39                                 
     40                                if (sizeof($parameter[1]) > 4) { 
     41                                        $width = round($width / 2); 
     42                                        $height = round($height / 2); 
     43                                } 
     44                                $friends_username = stripslashes($info->username); 
     45                                $friends_name = htmlentities(stripslashes($info->name)); 
     46                                $friends_menu = run("users:infobox:menu",array($info->ident)); 
     47                                $body .= <<< END 
    4848                <td> 
    4949                        <p> 
     
    5757                </td> 
    5858END; 
    59                                        if ($i % 5 == 0) { 
    60                                                $body .= "</tr><tr>"; 
    61                                        
    62                                        $i++; 
     59                                if ($i % 5 == 0) { 
     60                                        $body .= "</tr><tr>"; 
     61                               
     62                                $i++; 
    6363                        } 
    6464                } else { 
    6565                        if ($user_id == $_SESSION['userid']) { 
    66                                 $body .= "<td><p>" . gettext("Nobody's listed you as a friend! Maybe you need to start chatting to some other users?") . "</p></td>"; 
     66                                $body .= "<td><p>" . gettext("Nobody's listed you as a friend! Maybe you need to start chatting to some other users?") . "</p></td>"; 
    6767                        } else { 
    6868                                $body .= "<td><p>" . gettext("This user isn't currently listed as anyone's friend. Maybe you could be the first?") . "</p></td>"; 
     
    7474        </div> 
    7575END; 
    76                
     76       
    7777 
    7878        $run_result .= $body; 
  • devel/units/friends/generate_foaf.php

    r64 r110  
    5353                $run_result .= "\t\t</vCard:ADR>\n"; 
    5454                 
    55                 $friends = db_query("select users.* from friends left join users on users.ident = friends.friend where friends.owner = " . $user->ident); 
     55                $friends = db_query("select users.* from friends join users on users.ident = friends.friend where friends.owner = " . $user->ident); 
    5656                if (sizeof($friends) > 0) { 
    5757                        foreach($friends as $friend) { 
  • devel/units/friends/get_friends.php

    r45 r110  
    1717                $run_result = db_query("select friends.friend as user_id, 
    1818                                                                                users.name from friends 
    19                                                                                 left join users on users.ident = friends.friend 
     19                                                                                join users on users.ident = friends.friend 
    2020                                                                                where friends.owner = $ident"); 
    2121                                 
  • devel/units/friends/profile_friends.php

    r84 r110  
    55        if ($page_owner != -1 && run("users:type:get", $page_owner) == "person") { 
    66                $result = db_query("select users.ident from friends 
    7                                                                         left join users on users.ident = friends.friend 
     7                                                                        join users on users.ident = friends.friend 
    88                                                                        where friends.owner = $page_owner 
    99                                                                        and users.user_type = 'person' 
  • devel/units/groups/get_groups.php

    r45 r110  
    2323                                        $members = db_query("select group_membership.user_id, 
    2424                                                                                                users.name from group_membership  
    25                                                                                                 left join users on users.ident = group_membership.user_id 
     25                                                                                                join users on users.ident = group_membership.user_id 
    2626                                                                                                where group_membership.group_id = " . $tempdata->ident); 
    2727                                        $tempdata->members = $members; 
  • devel/units/icons/function_edit_icons.php

    r96 r110  
    1010                $icons = db_query("select * from icons where owner = $page_owner"); 
    1111                if ($page_owner != $_SESSION['userid']) { 
    12                         $currenticon = db_query("select icons.filename, users.icon from users left join icons on icons.ident = users.icon where users.ident = $page_owner"); 
     12                        $currenticon = db_query("select icons.filename, users.icon from users join icons on icons.ident = users.icon where users.ident = $page_owner"); 
    1313                        $currenticon = $currenticon[0]->filename; 
    1414                } else { 
     
    2828                        $desc = gettext("Site pictures are small pictures that act as a representative icon throughout the system."); // gettext variable 
    2929                        $body .= <<< END 
    30                 <form action="" method="post" />                
     30                <form action="" method="post" /> 
    3131                        <p> 
    3232                                $desc 
     
    3434END; 
    3535                        foreach($icons as $icon) { 
    36                                 list($width, $height, $type, $attr) = getimagesize(path . "_icons/data/" . $icon->filename); 
     36                                list($width, $height, $type, $attr) = @getimagesize(path . "_icons/data/" . $icon->filename); 
    3737 
    3838                                $delete = gettext("Delete"); 
     
    9090                                <p align="center"> 
    9191                                        <input type="hidden" name="action" value="icons:edit" /> 
    92                                         <input type="submit" value=$save />             
     92                                        <input type="submit" value=$save /> 
    9393                                </p> 
    9494                        </form> 
  • devel/units/invite/new_password.php