Show
Ignore:
Timestamp:
11/12/05 12:17:45 (3 years ago)
Author:
mbonetti
Message:

Fixed indentation here and there

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/rss/admin/index.php

    r1005 r1011  
    7070 
    7171if (defined('ADMIN_USERNAME') && defined ('ADMIN_PASSWORD')) { 
    72     if (!array_key_exists('PHP_AUTH_USER',$_SERVER) || 
    73         $_SERVER['PHP_AUTH_USER'] != ADMIN_USERNAME || 
    74         !array_key_exists('PHP_AUTH_PW',$_SERVER) || 
    75         $_SERVER['PHP_AUTH_PW'] != ADMIN_PASSWORD ) { 
    76             header('WWW-Authenticate: Basic realm="Gregarius Admin Authentication"'); 
    77             header('HTTP/1.0 401 Unauthorized'); 
    78             $auth = false; 
    79     } 
     72    if (!array_key_exists('PHP_AUTH_USER',$_SERVER) || 
     73            $_SERVER['PHP_AUTH_USER'] != ADMIN_USERNAME || 
     74            !array_key_exists('PHP_AUTH_PW',$_SERVER) || 
     75            $_SERVER['PHP_AUTH_PW'] != ADMIN_PASSWORD ) { 
     76        header('WWW-Authenticate: Basic realm="Gregarius Admin Authentication"'); 
     77        header('HTTP/1.0 401 Unauthorized'); 
     78        $auth = false; 
     79    } 
    8080} 
    8181 
    8282if ($auth) { 
    83     setAdminCookie(); 
    84      
    85     if (array_key_exists('login',$_GET)) { 
     83    setAdminCookie(); 
     84 
     85    if (array_key_exists('login',$_GET)) { 
    8686        rss_redirect(); 
    87     } 
     87    } 
    8888} 
    8989admin_header(); 
     
    100100function admin_main($authorised) { 
    101101 
    102     echo "\n<div id=\"channel_admin\" class=\"frame\">"; 
     102    echo "\n<div id=\"channel_admin\" class=\"frame\">"; 
    103103 
    104104    if ($authorised) { 
    105       admin_menu(); 
    106       if (array_key_exists(CST_ADMIN_DOMAIN,$_REQUEST)) { 
    107          switch($_REQUEST[CST_ADMIN_DOMAIN]) { 
    108           case CST_ADMIN_DOMAIN_FOLDER: 
    109          $show = folder_admin(); 
    110          break; 
    111           case CST_ADMIN_DOMAIN_CHANNEL: 
    112          $show = channel_admin(); 
    113          break; 
    114           case CST_ADMIN_DOMAIN_CONFIG: 
    115          $show = config_admin(); 
    116          break; 
    117           case CST_ADMIN_DOMAIN_ITEM: 
    118          $show = item_admin(); 
    119          break; 
    120           default: 
    121          break; 
    122          } 
    123       } 
    124     
    125       if (array_key_exists(CST_ADMIN_VIEW,$_REQUEST) || isset($show)) { 
    126          if (!isset($show)) { 
    127          $show = $_REQUEST[CST_ADMIN_VIEW]; 
    128          } 
    129          switch ($show) { 
    130           case CST_ADMIN_DOMAIN_CONFIG: 
    131          config(); 
    132          break; 
    133           case CST_ADMIN_DOMAIN_CHANNEL: 
    134          channels(); 
    135          break; 
    136           case CST_ADMIN_DOMAIN_FOLDER: 
    137          folders(); 
    138          break; 
    139           case CST_ADMIN_DOMAIN_OPML: 
    140          opml(); 
    141          break; 
    142           case CST_ADMIN_DOMAIN_NONE: 
    143          break; 
    144           case CST_ADMIN_DOMAIN_ITEM: 
    145          items();            
    146          break; 
    147             case CST_ADMIN_DOMAIN_SYSINFO: 
    148             sysinfo(); 
    149             break; 
    150             case CST_ADMIN_DOMAIN_DASHBOARD: 
    151             dashboard(); 
    152  
    153             break; 
    154           default: 
    155          } 
    156       } else { 
    157          dashboard(); 
    158       } 
    159     
    160       echo "\n<div class=\"clearer\"></div>\n"; 
    161     
    162    } else { 
    163         rss_error(sprintf(LBL_ADMIN_ERROR_NOT_AUTHORIZED,getPath()), RSS_ERROR_ERROR,true); 
    164     } 
    165     echo "</div>\n"; 
     105        admin_menu(); 
     106        if (array_key_exists(CST_ADMIN_DOMAIN,$_REQUEST)) { 
     107            switch($_REQUEST[CST_ADMIN_DOMAIN]) { 
     108            case CST_ADMIN_DOMAIN_FOLDER: 
     109                    $show = folder_admin(); 
     110                break; 
     111            case CST_ADMIN_DOMAIN_CHANNEL: 
     112                $show = channel_admin(); 
     113                break; 
     114            case CST_ADMIN_DOMAIN_CONFIG: 
     115                $show = config_admin(); 
     116                break; 
     117            case CST_ADMIN_DOMAIN_ITEM: 
     118                $show = item_admin(); 
     119                break; 
     120            default: 
     121                break; 
     122            } 
     123        } 
     124 
     125        if (array_key_exists(CST_ADMIN_VIEW,$_REQUEST) || isset($show)) { 
     126            if (!isset($show)) { 
     127                $show = $_REQUEST[CST_ADMIN_VIEW]; 
     128            } 
     129            switch ($show) { 
     130            case CST_ADMIN_DOMAIN_CONFIG: 
     131                config(); 
     132                break; 
     133            case CST_ADMIN_DOMAIN_CHANNEL: 
     134                channels(); 
     135                break; 
     136            case CST_ADMIN_DOMAIN_FOLDER: 
     137                folders(); 
     138                break; 
     139            case CST_ADMIN_DOMAIN_OPML: 
     140                opml(); 
     141                break; 
     142            case CST_ADMIN_DOMAIN_NONE: 
     143                break; 
     144            case CST_ADMIN_DOMAIN_ITEM: 
     145                items(); 
     146                break; 
     147            case CST_ADMIN_DOMAIN_SYSINFO: 
     148                sysinfo(); 
     149                break; 
     150            case CST_ADMIN_DOMAIN_DASHBOARD: 
     151                dashboard(); 
     152 
     153                break; 
     154            default: 
     155            } 
     156        } else { 
     157            dashboard(); 
     158        } 
     159 
     160        echo "\n<div class=\"clearer\"></div>\n"; 
     161 
     162    } else { 
     163        rss_error(sprintf(LBL_ADMIN_ERROR_NOT_AUTHORIZED,getPath()), RSS_ERROR_ERROR,true); 
     164    } 
     165    echo "</div>\n"; 
    166166} 
    167167 
     
    172172 */ 
    173173function admin_menu() { 
    174     $active = array_key_exists(CST_ADMIN_VIEW, $_REQUEST) ? $_REQUEST[CST_ADMIN_VIEW] : null; 
    175  
    176     /* 
    177     $use_mod_rewrite = getConfig('rss.output.usemodrewrite'); 
    178  
    179     if (function_exists("apache_get_modules")) { 
    180         $use_mod_rewrite = $use_mod_rewrite && in_array('mod_rewrite', apache_get_modules()); 
    181     } 
    182     */ 
    183     $use_mod_rewrite = false; 
    184      
    185     echo "\n<ul class=\"navlist\">\n"; 
    186     foreach (array ( 
    187     /* url/id -- internationalized label, defined in intl/* */ 
    188     array (CST_ADMIN_DOMAIN_DASHBOARD, LBL_ADMIN_DASHBOARD), 
    189     array (CST_ADMIN_DOMAIN_CHANNEL, LBL_ADMIN_DOMAIN_CHANNEL_LBL),  
    190     array (CST_ADMIN_DOMAIN_ITEM, LBL_ADMIN_DOMAIN_ITEM_LBL),  
    191     array (CST_ADMIN_DOMAIN_CONFIG, LBL_ADMIN_DOMAIN_CONFIG_LBL),  
    192     array (CST_ADMIN_DOMAIN_FOLDER, LBL_ADMIN_DOMAIN_FOLDER_LBL),  
    193     array (CST_ADMIN_DOMAIN_OPML, LBL_ADMIN_DOMAIN_LBL_OPML_LBL)) as $item) { 
    194  
    195         if ($use_mod_rewrite) { 
    196             $link = $item[0]; 
    197         } else { 
    198             $link = "index.php?view=".$item[0]; 
    199         } 
    200         $lbl = $item[1]; 
    201         $cls = ($item[0] == $active ? " class=\"active\"" : ""); 
    202         echo "\t<li$cls><a href=\"".getPath()."admin/$link\">".ucfirst($lbl)."</a></li>\n"; 
    203     } 
    204     echo "\t<li><a href=\"".getPath()."?logout\">".LBL_ADMIN_LOGOUT."</a></li>\n"; 
    205     echo "</ul>\n"; 
     174    $active = array_key_exists(CST_ADMIN_VIEW, $_REQUEST) ? $_REQUEST[CST_ADMIN_VIEW] : null; 
     175 
     176    /* 
     177    $use_mod_rewrite = getConfig('rss.output.usemodrewrite'); 
     178 
     179    if (function_exists("apache_get_modules")) { 
     180        $use_mod_rewrite = $use_mod_rewrite && in_array('mod_rewrite', apache_get_modules()); 
     181    } 
     182    */ 
     183    $use_mod_rewrite = false; 
     184 
     185    echo "\n<ul class=\"navlist\">\n"; 
     186    foreach (array ( 
     187                 /* url/id -- internationalized label, defined in intl/* */ 
     188                 array (CST_ADMIN_DOMAIN_DASHBOARD, LBL_ADMIN_DASHBOARD), 
     189                 array (CST_ADMIN_DOMAIN_CHANNEL, LBL_ADMIN_DOMAIN_CHANNEL_LBL), 
     190                 array (CST_ADMIN_DOMAIN_ITEM, LBL_ADMIN_DOMAIN_ITEM_LBL), 
     191                 array (CST_ADMIN_DOMAIN_CONFIG, LBL_ADMIN_DOMAIN_CONFIG_LBL), 
     192                 array (CST_ADMIN_DOMAIN_FOLDER, LBL_ADMIN_DOMAIN_FOLDER_LBL), 
     193                 array (CST_ADMIN_DOMAIN_OPML, LBL_ADMIN_DOMAIN_LBL_OPML_LBL)) as $item) { 
     194 
     195        if ($use_mod_rewrite) { 
     196            $link = $item[0]; 
     197        } else { 
     198            $link = "index.php?view=".$item[0]; 
     199        } 
     200        $lbl = $item[1]; 
     201        $cls = ($item[0] == $active ? " class=\"active\"" : ""); 
     202        echo "\t<li$cls><a href=\"".getPath()."admin/$link\">".ucfirst($lbl)."</a></li>\n"; 
     203    } 
     204    echo "\t<li><a href=\"".getPath()."?logout\">".LBL_ADMIN_LOGOUT."</a></li>\n"; 
     205    echo "</ul>\n"; 
    206206} 
    207207 
    208208function admin_kses_to_html($arr) { 
    209     $ret = ""; 
    210     foreach ($arr as $tag => $attr) { 
    211     $ret .= "&lt;$tag"; 
    212     foreach ($attr as $nm => $val) { 
    213         $ret .= "&nbsp;$nm=\"...\"&nbsp;"; 
    214     } 
    215     $ret .= "&gt;\n"; 
    216     } 
    217     return $ret; 
     209    $ret = ""; 
     210    foreach ($arr as $tag => $attr) { 
     211        $ret .= "&lt;$tag"; 
     212        foreach ($attr as $nm => $val) { 
     213            $ret .= "&nbsp;$nm=\"...\"&nbsp;"; 
     214        } 
     215        $ret .= "&gt;\n"; 
     216    } 
     217    return $ret; 
    218218} 
    219219 
    220220function admin_plugins_mgmnt($arr) { 
    221     $ret = "<ul>\n"; 
    222     foreach($arr as $plugin) { 
    223         $info = getPluginInfo($plugin); 
    224         if (count($info)) { 
    225             $ret .= "\t<li>"; 
    226             if (array_key_exists('name',$info)) { 
    227                 $ret .= $info['name']; 
    228             } 
    229             if (array_key_exists('version',$info)) { 
    230                 $ret .= " v".$info['version']; 
    231             } 
    232             $ret .="</li>\n"; 
    233         } 
    234     } 
    235     $ret .= "</ul>\n"; 
    236     return $ret; 
     221    $ret = "<ul>\n"; 
     222    foreach($arr as $plugin) { 
     223        $info = getPluginInfo($plugin); 
     224        if (count($info)) { 
     225            $ret .= "\t<li>"; 
     226            if (array_key_exists('name',$info)) { 
     227                $ret .= $info['name']; 
     228            } 
     229            if (array_key_exists('version',$info)) { 
     230                $ret .= " v".$info['version']; 
     231            } 
     232            $ret .="</li>\n"; 
     233        } 
     234    } 
     235    $ret .= "</ul>\n"; 
     236    return $ret; 
    237237} 
    238238 
     
    249249 */ 
    250250function getPluginInfo($file) { 
    251     $info = array(); 
    252     $path = "../".RSS_PLUGINS_DIR."/$file"; 
    253     if (file_exists($path)) { 
    254         $f = @fopen($path,'r'); 
    255         $contents = ""; 
    256         if ($f) { 
    257             $contents .= fread($f, filesize($path)); 
    258             @fclose($f); 
    259         } else { 
    260             $contents = ""; 
    261         } 
    262  
    263         if ($contents && preg_match_all("/\/\/\/\s?([^:]+):(.*)/",$contents,$matches,PREG_SET_ORDER)) { 
    264             foreach($matches as $match) { 
    265                 $key = trim(strtolower($match[1])); 
    266                 $val = trim($match[2]); 
    267                 if ($key == 'version') { 
    268                     $val=preg_replace('/[^0-9\.]+/','',$val); 
    269                 } 
    270                  
    271                 $info[$key] = $val; 
    272             } 
    273         } 
    274     }  
    275      
    276     return $info; 
     251    $info = array(); 
     252    $path = "../".RSS_PLUGINS_DIR."/$file"; 
     253    if (file_exists($path)) { 
     254        $f = @fopen($path,'r'); 
     255        $contents = ""; 
     256        if ($f) { 
     257            $contents .= fread($f, filesize($path)); 
     258            @fclose($f); 
     259        } else { 
     260            $contents = ""; 
     261        } 
     262 
     263        if ($contents && preg_match_all("/\/\/\/\s?([^:]+):(.*)/",$contents,$matches,PREG_SET_ORDER)) { 
     264            foreach($matches as $match) { 
     265                $key = trim(strtolower($match[1])); 
     266                $val = trim($match[2]); 
     267                if ($key == 'version') { 
     268                    $val=preg_replace('/[^0-9\.]+/','',$val); 
     269                } 
     270 
     271                $info[$key] = $val; 
     272            } 
     273        } 
     274    } 
     275 
     276    return $info; 
    277277} 
    278278 
     
    285285    $activeIdx = "0"; 
    286286    while (false !== ($entry = $d->read())) { 
    287        if ( 
    288         $entry != "CVS" && 
    289         substr($entry,0,1) != "." 
    290        ) { 
    291             $info = getLanguageInfo($entry); 
    292              if (count($info) && array_key_exists('language',$info)) { 
     287        if ( 
     288            $entry != "CVS" && 
     289            substr($entry,0,1) != "." 
     290        ) { 
     291            $info = getLanguageInfo($entry); 
     292            if (count($info) && array_key_exists('language',$info)) { 
    293293                $shortL=  preg_replace('|\.php.*$|','',$entry); 
    294294                $ret[$shortL] = $info['language']; 
    295              } 
    296        } 
     295            } 
     296        } 
    297297    } 
    298298    $d->close(); 
     
    308308    $activeIdx = "0"; 
    309309    while (false !== ($theme = $d->read())) { 
    310        if ($theme != "CVS" && !is_file("../".RSS_THEME_DIR."/$theme") && substr($theme,0,1) != ".") { 
    311             $ret[$theme]=getThemeInfo($theme); 
    312        } 
     310        if ($theme != "CVS" && !is_file("../".RSS_THEME_DIR."/$theme") && substr($theme,0,1) != ".") { 
     311            $ret[$theme]=getThemeInfo($theme); 
     312        } 
    313313    } 
    314314    $d->close(); 
     
    318318function getThemeInfo($theme) { 
    319319 
    320     $path = "../".RSS_THEME_DIR."/$theme/.themeinfo"; 
    321     $ret = array( 
    322         'name' => '', 
    323         'url' => '', 
    324         'official' => false, 
    325         'fsname' => $theme, 
    326         'description' => '', 
    327         'htmltheme' => true, 
    328         'version' => "1.0", 
    329         'author' => '' 
    330         ); 
    331     if (file_exists($path)) { 
    332       $f = @fopen($path,'r'); 
    333       $contents = ""; 
    334       if ($f) { 
    335         $contents .= fread($f, filesize($path)); 
    336         @fclose($f); 
    337       } else { 
    338         $contents = ""; 
    339       } 
    340  
    341       if ($contents && preg_match_all("/^\s?([^:]+):(.*)$/m",$contents,$matches,PREG_SET_ORDER)) { 
    342         foreach($matches as $match) { 
    343             $key = trim(strtolower($match[1])); 
    344             $val = trim($match[2]); 
    345             if (array_key_exists($key,$ret)) { 
    346                 if ($val == 'true') { 
    347                     $ret[$key] = true; 
    348                 } elseif ($val == 'false') { 
    349                     $ret[$key] = false; 
    350                 } else { 
    351                     $ret[$key] = $val; 
    352                 } 
    353             } 
    354         } 
    355       } 
    356     } 
    357     return $ret; 
     320    $path = "../".RSS_THEME_DIR."/$theme/.themeinfo"; 
     321    $ret = array( 
     322               'name' => '', 
     323               'url' => '', 
     324               'official' => false, 
     325               'fsname' => $theme, 
     326               'description' => '', 
     327               'htmltheme' => true, 
     328               'version' => "1.0", 
     329               'author' => '' 
     330           ); 
     331    if (file_exists($path)) { 
     332        $f = @fopen($path,'r'); 
     333        $contents = ""; 
     334        if ($f) { 
     335            $contents .= fread($f, filesize($path)); 
     336            @fclose($f); 
     337        } else { 
     338            $contents = ""; 
     339        } 
     340 
     341        if ($contents && preg_match_all("/^\s?([^:]+):(.*)$/m",$contents,$matches,PREG_SET_ORDER)) { 
     342            foreach($matches as $match) { 
     343                $key = trim(strtolower($match[1])); 
     344                $val = trim($match[2]); 
     345                if (array_key_exists($key,$ret)) { 
     346                    if ($val == 'true') { 
     347                        $ret[$key] = true; 
     348                    } 
     349                    elseif ($val == 'false') { 
     350                        $ret[$key] = false; 
     351                    } 
     352                    else { 
     353                        $ret[$key] = $val; 
     354                    } 
     355                } 
     356            } 
     357        } 
     358    } 
     359    return $ret; 
    358360} 
    359361 
    360362 
    361363function getLanguageInfo($file) { 
    362     $info = array(); 
    363     $path = "../intl/$file"; 
    364     if (file_exists($path)) { 
    365         $f = @fopen($path,'r'); 
    366         $contents = ""; 
    367         if ($f) { 
    368             $contents .= fread($f, filesize($path)); 
    369             @fclose($f); 
    370         } else { 
    371             $contents = ""; 
    372         } 
    373  
    374         if ($contents && preg_match_all("/\/\/\/\s?([^:]+):(.*)/",$contents,$matches,PREG_SET_ORDER)) { 
    375             foreach($matches as $match) { 
    376                 $key = trim(strtolower($match[1])); 
    377                 $val = trim($match[2]); 
    378                 if ($key == 'version') { 
    379                     $val=preg_replace('/[^0-9\.]+/','',$val); 
    380                 } 
    381  
    382                 $info[$key] = $val; 
    383             } 
    384         } 
    385     } 
    386  
    387     return $info; 
     364    $info = array(); 
     365    $path = "../intl/$file"; 
     366    if (file_exists($path)) { 
     367        $f = @fopen($path,'r'); 
     368        $contents = ""; 
     369        if ($f) { 
     370            $contents .= fread($f, filesize($path)); 
     371            @fclose($f); 
     372        } else { 
     373            $contents = ""; 
     374        } 
     375 
     376        if ($contents && preg_match_all("/\/\/\/\s?([^:]+):(.*)/",$contents,$matches,PREG_SET_ORDER)) { 
     377            foreach($matches as $match) { 
     378                $key = trim(strtolower($match[1])); 
     379                $val = trim($match[2]); 
     380                if ($key == 'version') { 
     381                    $val=preg_replace('/[^0-9\.]+/','',$val); 
     382                } 
     383 
     384                $info[$key] = $val; 
     385            } 
     386        } 
     387    } 
     388 
     389    return $info; 
    388390} 
    389391 
    390392function admin_enum_to_html($arr) { 
    391     $idx = array_pop($arr); 
    392     $ret = ""; 
    393     foreach ($arr as $i => $val) { 
    394         if ($i == $idx)  
    395             $ret .= "$val"; 
    396     } 
    397     return $ret; 
     393    $idx = array_pop($arr); 
     394    $ret = ""; 
     395    foreach ($arr as $i => $val) { 
     396        if ($i == $idx) 
     397            $ret .= "$val"; 
     398    } 
     399    return $ret; 
    398400} 
    399401 
     
    414416function admin_header() { 
    415417 
    416     echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n"; 
    417     echo "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\">\n"; 
    418     echo "<head>"; 
    419      
    420     $header = new Header(LBL_TITLE_ADMIN, LOCATION_ADMIN, null, '', (HDR_NONE | HDR_NO_CACHECONTROL | HDR_NO_OUPUTBUFFERING)); 
    421     $header -> render(); 
    422  
    423     echo "</head>"; 
    424     echo "<body>\n"; 
    425      
    426     echo "" 
     418    echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n"; 
     419    echo "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\">\n"; 
     420    echo "<head>"; 
     421 
     422    $header = new Header(LBL_TITLE_ADMIN, LOCATION_ADMIN, null, '', (HDR_NONE | HDR_NO_CACHECONTROL | HDR_NO_OUPUTBUFFERING)); 
     423    $header -> render(); 
     424 
     425    echo "</head>"; 
     426    echo "<body>\n"; 
     427 
     428    echo "" 
    427429    ."<div id=\"nav\" class=\"frame\">" 
    428     ."<h1 id=\"top\">" .rss_main_title() ."</h1>";     
    429     $nav = new Navigation(); 
    430     $nav->render(); 
    431     echo "</div>"; 
     430    ."<h1 id=\"top\">" .rss_main_title() ."</h1>"; 
     431    $nav = new Navigation(); 
     432    $nav->render(); 
     433    echo "</div>"; 
    432434} 
    433435 
    434436function admin_footer() { 
    435     echo "<div id=\"footer\" class=\"frame\">\n"; 
    436     rss_main_footer(); 
    437     echo "</div>\n\n</body>\n</html>\n"; 
     437    echo "<div id=\"footer\" class=\"frame\">\n"; 
     438    rss_main_footer(); 
     439    echo "</div>\n\n</body>\n</html>\n"; 
    438440} 
    439441?>