Changeset 453

Show
Ignore:
Timestamp:
07/15/06 05:53:51 (2 years ago)
Author:
sven
Message:

fix a load of php notices and a couple of trivial bugs
files: add displaying of access perms like on blog posts

Files:

Legend:

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

    r438 r453  
    2828                // ... and the file exists on disk ... 
    2929                 
    30                 // Send 304s where possible, rather than spitting out the file each time 
    31                 $if_modified_since = preg_replace('/;.*$/', '', $_SERVER['HTTP_IF_MODIFIED_SINCE']); 
    32                  
    33                 $tstamp = filemtime($CFG->dataroot . $file->location); 
    34                 $lm = gmdate("D, d M Y H:i:s", $tstamp) . " GMT"; 
    35                  
    36                 if ($if_modified_since == $lm) { 
    37                     header("{$_SERVER['SERVER_PROTOCOL']} 304 Not Modified"); 
    38                     exit; 
    39                 } 
    40                  
    41                 // Send last-modified header to enable if-modified-since requests 
    42                 if ($tstamp < time()) { 
    43                     header("Last-Modified: " . $lm); 
    44                 } 
    45                  
    4630                // Then output some appropriate headers and send the file data! 
    4731                require_once($CFG->dirroot . 'lib/filelib.php'); 
     
    5236                header("Cache-Control: private"); 
    5337                 
    54                 header("Content-type: $mimetype"); 
    5538                if ($mimetype == "application/octet-stream") { 
    5639                    header('Content-Disposition: attachment'); 
     
    6346                    @apache_setenv('no-gzip', '1'); 
    6447                } 
    65                 readfile($CFG->dataroot . $file->location); 
     48                spitfile_with_mtime_check($CFG->dataroot . $file->location, $mimetype); 
    6649            } 
    6750        } 
  • devel/_files/rss2.php

    r447 r453  
    5151        header('Expires: ' . gmdate("D, d M Y H:i:s", (time()+3600)) . " GMT"); 
    5252         
    53         $if_none_match = preg_replace('/[^0-9a-f]/', '', $_SERVER['HTTP_IF_NONE_MATCH'])
     53        $if_none_match = (isset($_SERVER['HTTP_IF_NONE_MATCH'])) ? preg_replace('/[^0-9a-f]/', '', $_SERVER['HTTP_IF_NONE_MATCH']) : false
    5454         
    5555        $etag = md5($output); 
    5656                header('ETag: "' . $etag . '"'); 
    5757         
    58         if ($if_none_match == $etag) { 
     58        if ($if_none_match && $if_none_match == $etag) { 
    5959            header("{$_SERVER['SERVER_PROTOCOL']} 304 Not Modified"); 
    6060            exit; 
  • devel/_invite/forgotten_password.php

    r339 r453  
    1313        $title = gettext("Generate a New Password"); 
    1414         
    15         $body .= run("invite:password:request"); 
     15        $body = run("invite:password:request"); 
    1616         
    1717        $body = templates_draw(array( 
  • devel/_rss/blog.php

    r430 r453  
    1515    $title = run("profile:display:name") ." :: " . gettext("Publish feeds to blog"); 
    1616     
    17     $body = run("rss:subscriptions:publish:blog",$feed); 
     17    $body = run("rss:subscriptions:publish:blog"); 
    1818     
    1919    $body = templates_draw(array( 
  • devel/_rss/popular.php

    r386 r453  
    1212    $title = gettext("Popular feeds"); 
    1313     
    14     $body = run("rss:subscriptions:popular",$feed); 
     14    $body = run("rss:subscriptions:popular"); 
    1515     
    1616    $body = templates_draw( array( 
  • devel/_rss/static.php

    r269 r453  
    1515header("Pragma: public"); 
    1616header("Cache-Control: public");  
    17 header('Expires: ' . gmdate("D, d M Y H:i:s", (time()+3600)) . " GMT"); 
    1817 
    19  
    20 $if_modified_since = preg_replace('/;.*$/', '', $_SERVER['HTTP_IF_MODIFIED_SINCE']); 
    21                      
    22 $tstamp = filemtime($file); 
    23 $lm = gmdate("D, d M Y H:i:s", $tstamp) . " GMT"; 
    24                      
    25 if ($if_modified_since == $lm) { 
    26     header("{$_SERVER['SERVER_PROTOCOL']} 304 Not Modified"); 
    27     exit; 
    28 
    29                  
    30 // Send last-modified header to enable if-modified-since requests 
    31 if ($tstamp < time()) { 
    32     header("Last-Modified: " . $lm); 
    33 
    34  
    35 header("Content-type: text/xml; charset=utf-8"); 
    36 readfile($file); 
     18require_once($CFG->dirroot . 'lib/filelib.php'); 
     19spitfile_with_mtime_check($file, "text/xml; charset=utf-8"); 
    3720 
    3821?> 
  • devel/_rss/subscriptions.php

    r296 r453  
    1515    $title = run("profile:display:name") ." :: " . gettext("Feeds"); 
    1616     
    17     $body = run("rss:subscriptions",$feed); 
     17    $body = run("rss:subscriptions"); 
    1818     
    1919    $body = templates_draw(array( 
  • devel/_weblog/archive_month.php

    r296 r453  
    1515        $title = run("profile:display:name") . " :: " . gettext("Blog Archives"); 
    1616         
    17         $body .= run("weblogs:archives:month:view"); 
     17        $body = run("weblogs:archives:month:view"); 
    1818         
    1919        $body = templates_draw(array( 
  • devel/_weblog/rss2.php

    r429 r453  
    109109                header('Expires: ' . gmdate("D, d M Y H:i:s", (time()+3600)) . " GMT"); 
    110110                 
    111                 $if_none_match = preg_replace('/[^0-9a-f]/', '', $_SERVER['HTTP_IF_NONE_MATCH'])
     111                $if_none_match = (isset($_SERVER['HTTP_IF_NONE_MATCH'])) ? preg_replace('/[^0-9a-f]/', '', $_SERVER['HTTP_IF_NONE_MATCH']) : false
    112112                 
    113113                $etag = md5($output); 
    114                     header('ETag: "' . $etag . '"'); 
     114                header('ETag: "' . $etag . '"'); 
    115115                 
    116                 if ($if_none_match == $etag) { 
     116                if ($if_none_match && $if_none_match == $etag) { 
    117117                    header("{$_SERVER['SERVER_PROTOCOL']} 304 Not Modified"); 
    118118                    exit; 
  • devel/lib/datalib.php

    r446 r453  
    12681268 
    12691269    $data = (array)$dataobject; 
     1270    $ddd = array(); 
    12701271 
    12711272  // Pull out data matching these fields 
     
    14001401 
    14011402    $data = (array)$dataobject; 
     1403    $ddd = array(); 
    14021404 
    14031405    if (defined('ELGG_PERFDB')) { global $PERF ; $PERF->dbqueries++; }; 
  • devel/lib/elgglib.php

    r451 r453  
    34063406function cookied_login() { 
    34073407    global $USER; 
    3408     if($ticket = md5($_COOKIE[AUTH_COOKIE])) { 
     3408    if((!empty($_COOKIE[AUTH_COOKIE])) && $ticket = md5($_COOKIE[AUTH_COOKIE])) { 
    34093409        if ($user = get_record('users','code',$ticket)) { 
    34103410            $USER = $user; 
     
    41634163 
    41644164 
     4165// return the "this is restricted" text for a given access value 
     4166// functionised to reduce code duplication 
     4167function get_access_description ($accessvalue) { 
     4168     
     4169    if ($accessvalue != "PUBLIC") { 
     4170        if ($accessvalue == "LOGGED_IN") { 
     4171            $title = "[" . gettext("Logged in users") . "] "; 
     4172        } else if (substr_count($accessvalue, "user") > 0) { 
     4173            $title = "[" . gettext("Private") . "] "; 
     4174        } else { 
     4175            $title = "[" . gettext("Restricted") . "] "; 
     4176        } 
     4177    } else { 
     4178        $title = ""; 
     4179    } 
     4180     
     4181    return $title; 
     4182} 
     4183 
     4184 
    41654185?> 
  • devel/profile/index.php

    r420 r453  
    2525         
    2626$title = $profile->display_name(); 
    27 $body .= $profile->view(); 
     27$body  = $profile->view(); 
     28 
    2829$body  = templates_draw( array( 
    2930                               'context' => 'contentholder', 
  • devel/units/communities/communities_actions.php

    r433 r453  
    2424                $username = strtolower(trim($comm_username)); 
    2525                if (record_exists('users','username',$username)) { 
    26                     $messages[] = sprintf(gettext("The username $s is already taken by another user. You will need to pick a different one."), stripslashes($username)); 
     26                    $messages[] = sprintf(gettext("The username %s is already taken by another user. You will need to pick a different one."), stripslashes($username)); 
    2727                } else { 
    2828                    $name = trim($comm_name); 
  • devel/units/communities/communities_create.php

    r269 r453  
    11<?php 
    22 
     3    $comm_name = ''; 
    34    if (isset($_SESSION['comm_name'])) { 
    45        $comm_name = $_SESSION['comm_name']; 
    56    } 
     7    $comm_username = ''; 
    68    if (isset($_SESSION['comm_username'])) { 
    7         $comm_name = $_SESSION['comm_username']; 
     9        $comm_username = $_SESSION['comm_username']; 
    810    } 
    911 
  • devel/units/communities/communities_moderator_of.php

    r447 r453  
    2020        foreach($result as $key => $info) { 
    2121            $w = 100; 
    22             if (sizeof($parameter[1]) > 4) { 
    23                 $w = 100; 
    24            
     22            //if (count($result) > 4) { 
     23            //    $w = 100; 
     24            //
    2525            $friends_username = stripslashes($info->username); 
    2626            // $friends_name = htmlspecialchars(stripslashes($info->name), ENT_COMPAT, 'utf-8'); 
  • devel/units/files/folder_view.php

    r447 r453  
    6969            $username = $owner_username; 
    7070            $ident = (int) $folder_details->ident; 
    71             $name = stripslashes($folder_details->name); 
     71            $name = get_access_description($folder_details->access); 
     72            $name .= stripslashes($folder_details->name); 
    7273            if (run("permissions:check", array("files:edit", $folder_details->owner))  || run("permissions:check", array("files:edit", $folder_details->files_owner))) { 
    7374                $areyouSure = gettext("Are you sure you want to permanently delete this folder?"); // gettext variable 
     
    108109            $ident = (int) $file->ident; 
    109110            $folder = $file->folder; 
    110             $title = stripslashes($file->title); 
     111            $title = get_access_description($file->access); 
     112            $title .= stripslashes($file->title); 
    111113            $description = nl2br(stripslashes($file->description)); 
    112114            $filetitle = urlencode($title); 
  • devel/units/files/function_rss_getitems.php

    r420 r453  
    4141                require_once($CFG->dirroot . 'lib/filelib.php'); 
    4242                foreach($files as $file) { 
    43                     $title = (stripslashes($file->title)); 
     43                    $title = stripslashes($file->title); 
    4444                    $link = url . $username . "/files/" . $file->folder . "/" . $file->ident . "/" . (urlencode(stripslashes($file->originalname))); 
    45                     $description = (stripslashes($file->description)); 
     45                    $description = stripslashes($file->description); 
    4646                    $pubdate = gmdate("D, d M Y H:i:s T", $file->time_uploaded); 
    47                     $trackmaxtime = max($trackmaxtime, $file->time_uploaded); 
     47                    // $trackmaxtime = max($trackmaxtime, $file->time_uploaded); 
    4848                    $length = (int) $file->size; 
    4949                    $mimetype = mimeinfo('type',$file->location); 
  • devel/units/files/function_rss_publish.php

    r447 r453  
    4141            $rssurl = $mainurl . "rss/"; 
    4242            $rssdescription = sprintf(gettext("Files for %s, hosted on %s."),$name,$sitename); 
    43             $output .= <<< END 
     43            $output = <<< END 
    4444<?xml-stylesheet type="text/xsl" href="{$rssurl}rssstyles.xsl"?> 
    4545<rss version='2.0'   xmlns:dc='http://purl.org/dc/elements/1.1/'> 
  • devel/units/files/weblogs_posts_add_fields.php

    r434 r453  
    2525    if ($files = get_records_select('files',"owner = ? AND folder = ?",array($userid,$folderid))) { 
    2626        foreach($files as $file) { 
    27             $name = stripslashes($file->name); 
    2827            $filetitle = stripslashes($file->title); 
    2928            $body .= <<< END 
  • devel/units/friends/friends_edit.php

    r447 r453  
    2020        foreach($result as $key => $info) { 
    2121            $w = 100; 
    22             if (sizeof($parameter[1]) > 4) { 
     22            if (count($result) > 4) { 
    2323                $w = 50; 
    2424            } 
  • devel/units/magpie/function_subscriptions.php

    r442 r453  
    11<?php 
    22global $USER,$CFG,$page_owner; 
     3$body = ''; 
    34 
    45if (logged_on) { 
  • devel/units/magpie/function_subscriptions_popular.php

    r442 r453  
    11<?php 
    22global $CFG; 
     3$body = ''; 
    34    if (logged_on) { 
    45         
  • devel/units/magpie/function_subscriptions_publish_to_blog.php

    r442 r453  
    22 
    33    global $USER,$CFG,$page_owner; 
     4    $body = ''; 
    45     
    56    if (logged_on) { 
  • devel/units/magpie/function_update.php

    r402 r453  
    8484                    $url = substr($url, 0, 255); // trim urls down to the max length in the db, just in case. CURSE YOU, GUARDIAN BLOGGERS! 
    8585                     
    86                     if ($item['date_timestamp']) { 
     86                    if (!empty($item['date_timestamp'])) { 
    8787                        $added = (int) $item['date_timestamp']; 
    8888                    } 
     
    9999                        if (in_array($url,$feeditems)) { 
    100100                            // update_record is not going to work here, we don't have a primary key that I can see (Penny) 
    101                             $f = new StdClass; 
    102                             $f->ident = array_search($url,$feeditems); 
    103                             $f->title = $title; 
    104                             $f->body =  $description; 
    105                             $f->posted = $posted; 
    106                             $f->url = $url; 
    107                             $f->feed = $parameter; 
     101                            $fp = new StdClass; 
     102                            $fp->ident = array_search($url,$feeditems); 
     103                            $fp->title = $title; 
     104                            $fp->body =  $description; 
     105                            $fp->posted = $posted; 
     106                            $fp->url = $url; 
     107                            $fp->feed = $parameter; 
    108108                            update_record('feed_posts',$fp); 
    109109                        } else { 
  • devel/units/magpie/function_view_individual.php

    r447 r453  
    99$feed_offset = optional_param('feed_offset',0,PARAM_INT); 
    1010 
    11 $numposts = count_records_sql('SELECT COUNT (fp.ident) FROM '.$CFG->prefix.'feed_posts fp 
     11$numposts = count_records_sql('SELECT COUNT(fp.ident) FROM '.$CFG->prefix.'feed_posts fp 
    1212                               JOIN '.$CFG->prefix.'feeds f ON f.ident = fp.feed 
    1313                               WHERE f.ident = ?',array($parameter)); 
  • devel/units/magpie/function_view_post.php

    r442 r453  
    1313        $author = ""; 
    1414        $usericon = "default.png"; 
    15         $post_authors[$post->owner] = $author; 
     15        //if (!empty($post->owner)) { 
     16        //    $post_authors[$post->owner] = $author; 
     17        //} 
    1618         
    1719        // $date = stripslashes($post->posted); 
  • devel/units/profile/function_init.php

    r287 r453  
    2323        $page_owner = $profile_id; 
    2424         
    25         define('profileinit',true); 
     25        if (!defined('profileinit')) { 
     26            define('profileinit', true); 
     27        } 
    2628 
    2729?> 
  • devel/units/search/search_suggest_tags.php

    r269 r453  
    1818    } 
    1919     
    20     if ($results = get_records_sql($searchline) && count($results) > 1) { 
     20    if (($results = get_records_sql($searchline)) && count($results) > 1) { 
    2121        $run_result .= "<h2>" . gettext("Automatic tag suggestion:") . "</h2><p>"; 
    2222        foreach($results as $returned_tag) { 
  • devel/units/tinymce/tinymce_js.php

    r355 r453  
    77    if (run('userdetails:editor', $page_owner) == "yes") { 
    88 
    9         if (!$CFG->userlocale) { 
     9        if (empty($CFG->userlocale)) { 
    1010            $lang = substr($CFG->defaultlocale, 0, 2); 
    1111        } else { 
  • devel/units/tinymce/tinymce_userdetails_edit.php

    r269 r453  
    44    $visualEditorRules = gettext("Set this to 'yes' if you would like to use a visual (WYSIWYG) text editor for your posts and comments."); 
    55 
    6     $body .= <<< END 
     6    $body = <<< END 
    77 
    88    <h2>$visualEditor</h2> 
  • devel/units/weblogs/archives_view.php

    r269 r453  
    1818// If there are any archives ... 
    1919$archive = gettext("Weblog Archive"); // gettext variable 
    20  $run_result .= "<h1 class=\"weblogdateheader\">$archive</h1>"; 
     20$run_result .= "<h1 class=\"weblogdateheader\">$archive</h1>"; 
    2121     
    22  // Get the name of the weblog user 
    23   
    24  $weblog_name = htmlspecialchars(stripslashes(optional_param('weblog_name')), ENT_COMPAT, 'utf-8'); 
    25   
    26  // Run through them 
    27   
    28  $lastyear = 0; 
    29   
    30  foreach($archives as $archive) { 
    31       
    32      // Extract the year and the month 
    33       
    34      $year = substr($archive->archivestamp, 0, 4); 
    35      $month = substr($archive->archivestamp, 4, 2); 
    36       
    37      if ($year != $lastyear) { 
    38          if ($lastyear .= 0) { 
    39              $run_result .= "</ul>"; 
    40          
    41          $lastyear = $year; 
    42          $run_result .= "<h2 class=\"weblogdateheader\">$year</h2>"; 
    43          $run_result .= "<ul>"; 
    44      
    45       
    46      // Print a link 
    47       
    48      $run_result .= "<li>"; 
    49      $run_result .= "<a href=\"" . url . $weblog_name . "/weblog/archive/$year/$month/\">"; 
    50      $run_result .= strftime("%B %Y", gmmktime(0,0,0,$month,1,$year)); 
    51      $run_result .= "</a>"; 
    52      $run_result .= "</li>"; 
    53       
    54  
    55   
    56  $run_result .= "</ul>"; 
    57   
    58  // If there are no posts to archive, say so! 
     22    // Get the name of the weblog user 
     23     
     24    $weblog_name = htmlspecialchars(stripslashes(optional_param('weblog_name')), ENT_COMPAT, 'utf-8'); 
     25     
     26    // Run through them 
     27     
     28    $lastyear = 0; 
     29     
     30    foreach($archives as $archive) { 
     31         
     32        // Extract the year and the month 
     33         
     34        $year = substr($archive->archivestamp, 0, 4); 
     35        $month = substr($archive->archivestamp, 4, 2); 
     36         
     37        if ($year != $lastyear) { 
     38            if ($lastyear .= 0) { 
     39                $run_result .= "</ul>"; 
     40            
     41            $lastyear = $year; 
     42            $run_result .= "<h2 class=\"weblogdateheader\">$year</h2>"; 
     43            $run_result .= "<ul>"; 
     44        
     45         
     46        // Print a link 
     47         
     48        $run_result .= "<li>"; 
     49        $run_result .= "<a href=\"" . url . $weblog_name . "/weblog/archive/$year/$month/\">"; 
     50        $run_result .= strftime("%B %Y", gmmktime(0,0,0,$month,1,$year)); 
     51        $run_result .= "</a>"; 
     52        $run_result .= "</li>"; 
     53         
     54    
     55     
     56    $run_result .= "</ul>"; 
     57     
     58    // If there are no posts to archive, say so! 
    5959  
    6060} else { 
    61     $noBlogs = gettext("There are no weblog posts to archive as yet."); // gettext variable - NOT SURE ABOUT THIS POSITION 
    62     $run_result .= "<p>There are no weblog posts to archive as yet.</p>"; 
     61     
     62    $run_result .= "<p>" . gettext("There are no weblog posts to archive as yet.") . "</p>"; 
    6363     
    6464} 
  • devel/units/weblogs/archives_view_month.php

    r269 r453  
    1414    // Get the name of the weblog user 
    1515     
    16     $weblog_name = htmlspecialchars(stripslashes(optional_param('weblog_name')), ENT_COMPAT, 'utf-8'); 
     16    $weblog_name = optional_param('weblog_name', '', PARAM_ALPHANUM); 
    1717     
    1818    // Run through them 
  • devel/units/weblogs/function_rss_getitems.php

    r405 r453  
    5757                    if ($keywords = get_records_select('tags','tagtype = ? AND ref = ?',array('weblog',$entry->ident))) { 
    5858                        foreach($keywords as $keyword) { 
    59                             $keywordtags .= "\n\t\t<dc:subject><![CDATA[".(stripslashes($keyword->tag)) . "]]></dc:subject>"; 
     59                            $keywordtags .= "\n\t\t<dc:subject><![CDATA[" . (stripslashes($keyword->tag)) . "]]></dc:subject>"; 
    6060                        } 
    6161                    } 
  • devel/units/weblogs/function_search.php

    r447 r453  
    2626            } 
    2727            $searchline = " wp.ident in (" . $searchline . ")"; 
    28             if (!$posts = get_records_sql('SELECT wp.ident,u.name,u.username,u.ident as uesrid,wp.title,wp.ident,wp.weblog,wp.owner,wp.posted 
     28            if (!$posts = get_records_sql('SELECT wp.ident,u.name,u.username,u.ident as userid, wp.title, wp.ident, wp.weblog, wp.owner, wp.posted 
    2929                                     FROM '.$CFG->prefix.'weblog_posts wp JOIN '.$CFG->prefix.'users u ON u.ident = wp.owner 
    3030                                     WHERE ('.$searchline.') ORDER BY posted DESC')) { 
     
    8585            $friends_menu = run("users:infobox:menu",array($info->ident)); 
    8686            $link_keyword = urlencode($parameter[1]); 
    87             $width = round($width / 2); 
    88             $height = round($height / 2); 
    8987            $body .= <<< END 
    9088        <td align="center"> 
  • devel/units/weblogs/function_search_rss.php

    r269 r453  
    2323            $weblogusername = run("users:id_to_name",$post->weblog); 
    2424            $run_result .= "]]></title>\n"; 
    25             $run_result .= "\t\t<link>" . url . (stripslashes($weblogusername)) . "/weblog/" . $post->ident . ".html</link>\n"; 
     25            $run_result .= "\t\t<link>" . url . $weblogusername . "/weblog/" . $post->ident . ".html</link>\n"; 
    2626            $run_result .= "\t</item>\n"; 
    2727        } 
  • devel/units/weblogs/weblogs_posts_view.php

    r447 r453  
    6969        $fullname = $specialname; 
    7070    } 
    71         if ($post->access != "PUBLIC") { 
    72             if ($post->access == "LOGGED_IN") { 
    73                 $title = "[" . gettext("Logged in users") . "]"; 
    74             } else if (substr_count($post->access, "user") > 0) { 
    75                 $title = "[" . gettext("Private") . "]"; 
    76             } else { 
    77                 $title = "[" . gettext("Restricted") . "]"; 
    78             } 
    79         } else { 
    80             $title = ""; 
    81         } 
    82          
    83         $title .= " " . stripslashes($post->title); 
     71     
     72    $title = get_access_description($post->access); 
     73    $title .= stripslashes($post->title); 
    8474     
    8575    if ($post->owner != $post->weblog) {