Changeset 1484

Show
Ignore:
Timestamp:
06/05/06 17:36:00 (2 years ago)
Author:
spetersen
Message:

Update PostgreSQL branch to 1477.

Location:
branches/postgresql
Files:
42 modified
22 copied

Legend:

Unmodified
Added
Removed
  • branches/postgresql/INSTALL

    r1393 r1484  
    4141         
    4242        2.  Edit the dbinit.php file to match your database configuration.  
    43             Make sure that the database user you define owns privileges to  
    44             create tables. 
     43            Make sure that the database exists and has the right permissions 
     44            and the database user you define owns privileges to create/modify 
     45            tables. 
    4546    
    4647   6.   Point your browser to the root directory of your installation. 
  • branches/postgresql/admin/index.php

    r1432 r1484  
    8181        $admin_uname = null; 
    8282        $admin_pass = null; 
    83         if (isset($_POST['admin_uname']) && isset($_POST['admin_pass'])) { 
    84             $admin_uname = $_POST['admin_uname']; 
    85             $admin_pass = $_POST['admin_pass']; 
     83        if (isset($_POST['username']) && isset($_POST['password'])) { 
     84            $admin_uname = $_POST['username']; 
     85            $admin_pass = $_POST['password']; 
    8686        } 
    8787        set_admin_pass($admin_uname,$admin_pass); 
  • branches/postgresql/admin/plugins.php

    r1284 r1484  
    132132                ."</td>\n"; 
    133133                echo "<td><label 
    134                 for=\"_gregarius_plugin_$entry\">".(array_key_exists('name',$info)?$info['name']:"&nbsp"). 
     134                for=\"_gregarius_plugin_$entry\">".(array_key_exists('name',$info)?$info['name']:"&nbsp;"). 
    135135                "</label></td>\n"; 
    136136                echo "<td class=\"cntr\">" 
    137                 .(array_key_exists('version',$info)?$info['version']:"&nbsp"). "</td>\n"; 
    138                 echo "<td>" .(array_key_exists('author',$info)?$info['author']:"&nbsp"). "</td>\n"; 
    139                 echo "<td>" .(array_key_exists('description',$info)?$info['description']:"&nbsp"). "</td>\n"; 
     137                .(array_key_exists('version',$info)?$info['version']:"&nbsp;"). "</td>\n"; 
     138                echo "<td>" .(array_key_exists('author',$info)?$info['author']:"&nbsp;"). "</td>\n"; 
     139                echo "<td>" .(array_key_exists('description',$info)?$info['description']:"&nbsp;"). "</td>\n"; 
    140140 
    141141                // output the column to call a plugin's config page. 
     
    150150                    ."</a>"; 
    151151                } else { 
    152                     echo "&nbsp"; 
     152                    echo "&nbsp;"; 
    153153                } 
    154154                echo "</td>\n"; 
  • branches/postgresql/admin/users.php

    r1432 r1484  
    4949    <!-- 
    5050        function on_submit_password_match() { 
    51             pass=document.getElementById('admin_pass').value; 
    52             pass2=document.getElementById('admin_pass2').value; 
     51            pass=document.getElementById('password').value; 
     52            pass2=document.getElementById('password2').value; 
    5353            if(pass !== pass2){ 
    5454                msg = '<?php echo LBL_ADMIN_PASS_NO_MATCH ?>'; 
    5555                document.getElementById('admin_match_result').innerHTML = msg; 
    56                 document.getElementById('admin_pass').value = ''; 
    57                 document.getElementById('admin_pass2').value = ''; 
     56                document.getElementById('password').value = ''; 
     57                document.getElementById('password2').value = ''; 
    5858                return false; 
    5959            }else{ 
    60                 return true; 
     60                document.getElementById('password2').value = ''; 
     61                return loginHandler(); 
    6162            } 
    6263        }    
     
    7172    echo "<form action=\"".$_SERVER['PHP_SELF'] . "\" onsubmit=\"return on_submit_password_match();\" method=\"post\">\n" 
    7273    ."<fieldset style=\"width:400px;\">" 
    73     ."<p><label style=\"display:block\" for=\"admin_uname\">".LBL_USERNAME.":</label>\n" 
    74     ."<input type=\"text\" id=\"admin_uname\" name=\"admin_uname\" /></p>\n" 
    75     ."<p><label style=\"display:block\" for=\"admin_pass\">".LBL_PASSWORD.":</label>\n" 
    76     ."<input type=\"password\" id=\"admin_pass\" name=\"admin_pass\" /></p>\n" 
    77     ."<p><label style=\"display:block\" for=\"admin_pass2\">".LBL_PASSWORD2.":</label>\n" 
    78     ."<input type=\"password\" id=\"admin_pass2\" name=\"admin_pass2\" /></p>\n" 
     74    ."<p><label style=\"display:block\" for=\"username\">".LBL_USERNAME.":</label>\n" 
     75    ."<input type=\"text\" id=\"username\" name=\"username\" /></p>\n" 
     76    ."<p><label style=\"display:block\" for=\"password\">".LBL_PASSWORD.":</label>\n" 
     77    ."<input type=\"password\" id=\"password\" name=\"password\" /></p>\n" 
     78    ."<p><label style=\"display:block\" for=\"password2\">".LBL_PASSWORD2.":</label>\n" 
     79    ."<input type=\"password\" id=\"password2\" name=\"password2\" /></p>\n" 
    7980    ."<p><input type=\"submit\" value=\"".LBL_ADMIN_OK."\" /></p>\n" 
    8081    ."<div style=\"display:inline;\" id=\"admin_match_result\"></div>\n" 
     
    9293  echo "\n<div id=\"channel_admin\" class=\"frame\">"; 
    9394         
    94     echo "<form id=\"admin_login\" style=\"text-align:center\" action=\"".$_SERVER['PHP_SELF'] ."\" method=\"post\">\n" 
     95    echo "<form id=\"admin_login\" onsubmit=\"return loginHandler();\"  
     96        style=\"text-align:center\" action=\"".$_SERVER['PHP_SELF'] ."\" method=\"post\">\n" 
    9597    ."<fieldset>" 
    9698    ."<legend>" . LBL_ADMIN_LOGIN . "</legend>\n" 
  • branches/postgresql/ajax.php

    r1432 r1484  
    169169} 
    170170 
     171function loginHandler() { 
     172    pw = document.getElementById('password'); 
     173    username = document.getElementById('username'); 
     174    var re = /[0-9a-f]{32}/ ; 
     175    if (! re.test(pw.value)) { 
     176        pw.value = hex_md5(pw.value + username.value); 
     177    }  
     178    return true; 
     179} 
    171180 
    172181function setTags(id,tagss) { 
  • branches/postgresql/author.php

    r1190 r1484  
    2828require_once ('init.php'); 
    2929 
    30 $a =  preg_replace("/[^A-Za-z0-9\.]/","%",rss_real_escape_string($_REQUEST['author'])); 
    31  
     30$a =trim(sanitize($_REQUEST['author'], RSS_SANITIZER_WORDS)); 
    3231list ($ra) = rss_fetch_row(rss_query( 
    3332    "select distinct(author) from " .getTable('item')  
    34     ." where author like '%$a%'" 
     33    ." where author like '$a'" 
    3534)); 
    3635 
    3736if (!$ra) { 
    38     rss_redirect(); 
     37    rss_404(); 
     38    exit; 
    3939} 
    4040 
     
    4343$GLOBALS['rss']->feedList = new FeedList(false); 
    4444$authorItems = new ItemList(); 
    45 $sqlWhere = " i.author like '%$a%' "; 
    46 $authorItems->populate($sqlWhere); 
     45$sqlWhere = " i.author like '$a' "; 
     46$numItems = getConfig('rss.output.frontpage.numitems'); 
     47$authorItems->populate($sqlWhere, "",  0, $numItems); 
    4748$authorItems->setTitle($t); 
    4849$authorItems->setRenderOptions(IL_NO_COLLAPSE|IL_TITLE_NO_ESCAPE); 
  • branches/postgresql/cls/items.php

    r1255 r1484  
    244244    var $unreadIids = array(); 
    245245    var $rss; 
    246      
    247  
     246    var $_template; 
     247     
     248    var $_sqlActualWhat = ""; 
     249    var $_sqlActualFrom = ""; 
     250    var $_sqlActualWhere= ""; 
     251    var $_sqlActualOrder= ""; 
     252    var $_sqlActualLimit= ""; 
    248253     
    249254    function ItemList() { 
    250      
     255        $this -> _template = 'itemlist.php'; 
    251256        $this -> rss = &$GLOBALS['rss']; 
    252257         
     
    273278     * @param sqlOrder (optional) specifies a different item ordering 
    274279     * @param sqlLimit (optional) specifies how many items should be fetched 
    275   * @param includeDeprecated (optional) specifies if deprecated feeds should be fetched 
     280    * @param includeDeprecated (optional) specifies if deprecated feeds should be fetched 
    276281     */ 
    277282    function populate($sqlWhere, $sqlOrder="", $startItem = 0, $itemCount = -1, $hint = ITEM_SORT_HINT_MIXED, $includeDeprecated = false) { 
    278283 
    279         _pf('ItemList::populate()'); 
    280         $sql = "select i.title,  c.title, c.id, i.unread, " 
     284      _pf('ItemList::populate()'); 
     285        $this -> _sqlActualWhat = " i.title,  c.title, c.id, i.unread, " 
    281286            ."i.url, i.enclosure, i.author, i.description, c.icon, " 
    282             ." case when i.pubdate is null then unix_timestamp(i.added) else unix_timestamp(i.pubdate) end as ts, " 
    283             ." case when i.pubdate is not null then true else false end as ispubdate, i.id, r.rating  " 
    284             ." from ".getTable("item") ." i " 
     287            ." unix_timestamp(coalesce(i.pubdate,i.added)) as ts, " 
     288            ." i.pubdate is not null as ispubdate, i.id, r.rating  "; 
     289        $this -> _sqlActualFrom =   getTable("item") ." i " 
    285290            ." left join " 
    286291            . getTable("rating") ." r on (i.id = r.iid), " 
    287292            .getTable("channels")." c, " 
    288             .getTable("folders") ." f " 
    289  
    290             ." where " 
    291             ." i.cid = c.id and " 
     293            .getTable("folders") ." f "; 
     294 
     295        $this -> _sqlActualWhere = " i.cid = c.id and " 
    292296            ." f.id=c.parent and ". (false == $includeDeprecated ? " (c.mode & ".RSS_MODE_DELETED_STATE.")=0 and " : "") 
    293297            ." (i.unread & ".RSS_MODE_DELETED_STATE.")=0 and "; 
     
    296300 
    297301        if (hidePrivate()) { 
    298             $sql .= " (i.unread & ".RSS_MODE_PRIVATE_STATE.")=0 and "; 
    299         } 
    300  
    301         if ($sqlWhere) { 
    302             $sql .= $sqlWhere ." and "; 
    303         } 
    304         $sql .= " 1=1 "; 
     302            $this -> _sqlActualWhere .= " (i.unread & ".RSS_MODE_PRIVATE_STATE.")=0 and "; 
     303        } 
     304 
     305        if ($this -> _sqlActualWhere) { 
     306            $this -> _sqlActualWhere .= $sqlWhere ." and "; 
     307        } 
     308        $this -> _sqlActualWhere .= " 1=1 "; 
    305309         
    306310        /// Order by 
     
    318322                    break; 
    319323            } 
    320             $sql .= " order by  "; 
     324 
    321325            if (!getConfig('rss.config.feedgrouping')) { 
    322326                if(getConfig("rss.config.datedesc.$skey")){ 
    323                     $sql .= " ts desc, f.position asc, c.position asc "; 
     327                    $this -> _sqlActualOrder = " ts desc, f.position asc, c.position asc "; 
    324328                }else{ 
    325                     $sql .= " ts asc, f.position asc, c.position asc "; 
     329                    $this -> _sqlActualOrder = " ts asc, f.position asc, c.position asc "; 
    326330                } 
    327331            } elseif (getConfig('rss.config.absoluteordering')) { 
    328                 $sql .= " f.position asc, c.position asc"; 
     332                $this -> _sqlActualOrder = " f.position asc, c.position asc"; 
    329333            } else { 
    330                 $sql .= " f.name asc, c.title asc"; 
     334                $this -> _sqlActualOrder = " f.name asc, c.title asc"; 
    331335            } 
    332336            if(getConfig("rss.config.datedesc.$skey")){ 
    333                 $sql .= ", ts desc, i.id asc"; 
     337                $this -> _sqlActualOrder .= ", ts desc, i.id asc"; 
    334338            }else{ 
    335                 $sql .= ", ts asc, i.id asc"; 
     339                $this -> _sqlActualOrder .= ", ts asc, i.id asc"; 
    336340            } 
    337341        } else { 
    338             $sql .= " $sqlOrder ";   
     342            $this -> _sqlActualOrder = " $sqlOrder ";    
    339343        } 
    340344        if (($itemCount < 0) || ($itemCount > RSS_DB_MAX_QUERY_RESULTS)) { 
    341345            $itemCount = RSS_DB_MAX_QUERY_RESULTS; 
    342346        } 
    343         $sql .= " limit $itemCount OFFSET $startItem"; 
    344  
     347        $this -> _sqlActualLimit = " $itemCount OFFSET $startItem"; 
     348 
     349        $sql = "select " 
     350            .$this -> _sqlActualWhat 
     351            . " from " 
     352            .$this -> _sqlActualFrom 
     353            . " where " 
     354            . $this -> _sqlActualWhere 
     355            . " order by " 
     356            . $this -> _sqlActualOrder 
     357            . " limit " 
     358            . $this -> _sqlActualLimit; 
     359             
    345360        //echo $sql;         
    346361        $this -> iids = array(); 
     
    461476        rss_plugin_hook('rss.plugins.items.beforeitems', null); 
    462477 
    463         eval($this-> rss ->getCachedTemplateFile("itemlist.php")); 
     478        eval($this-> rss ->getCachedTemplateFile($this -> _template)); 
    464479         
    465480        _pf("done: ItemList -> render()"); 
     
    470485} 
    471486 
    472  
     487class ItemListNavigation { 
     488    var $_parent; 
     489    var $pages; 
     490    function ItemListNavigation($il) { 
     491        $this -> _parent = $il; 
     492        $this -> pages = array(); 
     493        $base = $_SERVER["REQUEST_URI"]; 
     494        if (!preg_match('#page=[0-9]+$#',$base)) { 
     495            $base .= "?page=0"; 
     496        } 
     497        $last = ceil( $this -> _parent -> numItems / $this -> _parent -> itemsPerPage); 
     498        $lastin = 0; 
     499        for ($i = 0; $i < $last; $i++) { 
     500            if ($i == 0 || $i == $last-1 || abs($i - $this -> _parent -> page) < 3) { 
     501                $url = preg_replace('#^(.+)page=[0-9]+$#','${1}page='.$i, $base); 
     502                $this -> pages[$i] = array($url, $i == $this -> _parent -> page, false); 
     503                $lastin = $i; 
     504            } elseif ($i - 1 == $lastin) { 
     505                $this -> pages[$i] = array(null,false,true); 
     506            } 
     507        } 
     508    } 
     509    function render() { 
     510        eval($this-> _parent -> rss ->getCachedTemplateFile('pagination.php')); 
     511    } 
     512} 
     513 
     514class PaginatedItemList extends ItemList { 
     515    var $page; 
     516    var $navigation; 
     517    var $itemsPerPage = 0; 
     518    var $numItems = 0; 
     519    function PaginatedItemList() {  
     520        parent::ItemList();  
     521        if (isset($_REQUEST['page'])) { 
     522            $this -> page = sanitize($_REQUEST['page'], RSS_SANITIZER_NUMERIC); 
     523        } else { 
     524            $this -> page = 0; 
     525        } 
     526         
     527        $this ->  itemsPerPage = getConfig('rss.output.frontpage.numitems'); 
     528    } 
     529    function populate($sqlWhere, $sqlOrder="", $startItem = 0, $itemCount = -1, $hint = ITEM_SORT_HINT_MIXED, $includeDeprecated = false) { 
     530 
     531        $si = $this -> page * $this ->  itemsPerPage; 
     532        parent::populate($sqlWhere, $sqlOrder, $si, $this ->  itemsPerPage, $hint, $includeDeprecated); 
     533         
     534        $sql = "select count(*) as cnt " 
     535            . " from " 
     536            . $this -> _sqlActualFrom 
     537            . " where " 
     538            . $this -> _sqlActualWhere; 
     539        list($this -> numItems) = rss_fetch_row(rss_query($sql)); 
     540        $this -> navigation = new ItemListNavigation(& $this); 
     541    } 
     542} 
    473543?> 
  • branches/postgresql/cls/search.php

    r1393 r1484  
    186186 
    187187        if ($this->orderBy == QUERY_ORDER_BY_DATE) { 
    188             $qOrder = " order by ts desc"; 
     188            $qOrder = " ts desc"; 
    189189        } else { 
    190190            if (getConfig('rss.config.absoluteordering')) { 
    191                 $qOrder = " order by f.position asc, c.position asc"; 
     191                $qOrder = " f.position asc, c.position asc"; 
    192192            } else { 
    193                 $qOrder = " order by f.name asc, c.title asc"; 
     193                $qOrder = " f.name asc, c.title asc"; 
    194194            } 
    195195        } 
  • branches/postgresql/cls/update.php

    r1432 r1484  
    293293 
    294294        } 
    295  
    296295        parent::cleanUp($newIds, $ignorePrivate = true); 
    297  
    298     } 
    299  
    300 } 
    301  
     296    } 
     297} 
     298 
     299class MobileUpdate extends Update { 
     300    function MobileUpdate() { 
     301        parent::Update($doPopulate = true); 
     302    } 
     303    function render() { 
     304        $newIds = array(); 
     305    foreach ($this->chans as $chan) { 
     306            list ($cid, $url, $title) = $chan; 
     307            echo "$title ...\t"; 
     308            flush(); 
     309            $ret = update($cid); 
     310 
     311            if (is_array($ret)) { 
     312                    list ($error, $unreadIds) = $ret; 
     313                    $newIds = array_merge($newIds, $unreadIds); 
     314            } else { 
     315                    $error = 0; 
     316                    $unreadIds = array (); 
     317            } 
     318            $unread = count($unreadIds); 
     319            list($label,$cls) = parent::magpieError($error); 
     320            echo "\n$label, $unread " . LBL_UPDATE_UNREAD . "<br />"; 
     321            flush(); 
     322    } 
     323    } 
     324} 
     325 
     326     
    302327/** 
    303328 * CommandLineUpdateNews updates the feeds and displays only feeds with 
  • branches/postgresql/cls/user.php

    r1432 r1484  
    2828rss_require('cls/wrappers/user.php'); 
    2929 
    30 /**  
     30define ('RSS_USER_ACTION_LOGIN',0x01); 
     31define ('RSS_USER_ACTION_COOKIE',0x02); 
     32define ('RSS_USER_ACTION_SESSION',0x04); 
     33define ('RSS_USER_ACTION_LOGOUT',0x08); 
     34 
     35/** 
    3136 * The RSSUser class holds all the business logic to handle Gregarius users  
    3237 */ 
    3338class RSSUser { 
    34     /** Userid */ 
    35     var $_uid; 
    36     /** Userlevel */ 
    37     var $_level; 
    38     /** Username */ 
    39     var $_uname; 
    40     /** md5 hash of the user password */ 
    41     var $_hash; 
    42     /** List of valid IP subnets this user is allowed to log in via a cookie */ 
    43     var $_validIPs; 
    44      
    45     /**  
    46      * RSSUser constructor: 
    47      * Handles:  
    48      * -logout 
    49      * -cookie login (with validation) 
    50      * -login 
    51      */ 
    52     function RSSUser() { 
    53         $this -> _uid = 0; 
    54         $this -> _validIPs = array(); 
    55         $this -> _level = RSS_USER_LEVEL_NOLEVEL; 
    56         $this -> _uname = ''; 
    57         $this -> _realName = '';         
    58         $this -> _hash = null; 
     39    /** Userid */ 
     40    var $_uid; 
     41    /** Userlevel */ 
     42    var $_level; 
     43    /** Username */ 
     44    var $_uname; 
     45    /** md5 hash of the user password */ 
     46    var $_hash; 
     47    /** List of valid IP subnets this user is allowed to log in via a cookie */ 
     48    var $_validIPs; 
     49    /** Mobile session */ 
     50    var $_mobileSession; 
     51    /** Action */ 
     52    var $_action; 
     53 
     54    /** 
     55     * RSSUser constructor: 
     56     * Handles:  
     57     * -logout 
     58     * -cookie login (with validation) 
     59     * -login 
     60     */ 
     61    function RSSUser() { 
     62     
     63        $this -> _uid = 0; 
     64        $this -> _validIPs = array(); 
     65        $this -> _level = RSS_USER_LEVEL_NOLEVEL; 
     66        $this -> _uname = ''; 
     67        $this -> _realName = ''; 
     68        $this -> _hash = null; 
     69         
     70         
     71        $this -> _mobileSession =  
     72            isset($_POST['media']) && 'mobile' == $_POST['media']; 
     73         
     74        if ('mobile' ==  getThemeMedia()) { 
     75            ini_set('session.use_trans_sid',true); 
     76            session_start(); 
     77        } 
    5978                 
    60         if (array_key_exists('logout',$_GET)) { 
    61             $this -> logout(); 
    62             rss_redirect(''); 
     79        if (array_key_exists('logout',$_GET)) { 
     80            $this -> logout(); 
     81            rss_redirect(''); 
     82        } 
     83                 
     84        $cuname = $chash = null; 
     85