Показать сообщение отдельно
Старый 09.01.2010, 00:05   #20
Участник
 
Аватар для lytgeygen
 
Регистрация: 09.02.2009
Сообщений: 74

Репутация: 40
По умолчанию

как легче оптимизировать этот код и сделать его более понятным ?

PHP код:
function archive_list($tpl$p) {
    include 
'././ldata/config.php';
    
    
$lines file('././ldata/archive.dat');
    
$content '';
    
$mpost count($lines);
    
$mpost_ count($lines)-1;
    
$mp ceil($mpost $config['n_post-site']);
    if (!isset(
$p) or $p 1)
    {
        
$p 1;
    } 
    elseif (
$p $mp
    {
        
$p $mp;
    }
    
    if (
$config['data'] == 0)
    {
        
$post_start $config['n_post-site'] * ($p 1);
        if (
$post_start $mpost_)
        {
            
$post_start $mpost_ $config['n_post-site'];
        }
        
$post_end $post_start $config['n_post-site'];
    }
    elseif (
$config['data'] == 1)
    {
        
$post_start $mpost_ $config['n_post-site'] * ($p 1);
        if (
$post_start 0)
        {
            
$post_start $config['n_post-site'];
        }
        
$post_end $post_start $config['n_post-site'];
        if (
$post_end 0)
        {
            
$post_end '-1';
        }
    }
    
    do 
    {
        
$post_data explode("|"$lines[$post_start]);
        
$post_data[1] = html_entity_decode($post_data[1]);
        
$post_tpl $tpl;
        if (
$config['data'] == 0
        { 
            
$post_start++;
        } 
        elseif (
$config['data'] == 1
        {
             
$post_start--;
        }

        
$aid $mpost $post_start;
        if (
$post_data[3] == 0
        {
            
$post_status '<b>(</b><font color="#B30900"><i>[LANG-9]</i></font><b>)</b>';
        }
        elseif (
$post_data[3] == 1)
        {
            
$post_status '<b>(</b><font color="#407504"><i>[LANG-10]</i></font><b>)</b>';
        }
        
        
$post_tpl str_replace("[ANAME]",$post_data[0],$post_tpl);
        
$post_tpl str_replace("[ATEXT]",$post_data[1],$post_tpl);
        
$post_tpl str_replace("[ADATE]",$post_data[2],$post_tpl);
        
$post_tpl str_replace("[ASTATUS]",$post_status,$post_tpl);
        
$post_tpl str_replace("[AID]",$aid,$post_tpl);
        
        
$content.= $post_tpl;
        if (
$config['data'] == 0
        {          
            
$u1=$post_start
            
$u2=$post_end;
        } 
        elseif (
$config['data'] == 1)
        {
            
$u1=$post_end
            
$u2=$post_start;
        }
    } 
    while(
$u1 $u2);    
    
    
    return 
$content;

lytgeygen вне форума