View Single Post
ישן 29-01-06, 20:40   # 1
miniature
חבר וותיק
 
מיני פרופיל
תאריך הצטרפות: Oct 2005
הודעות: 1,754

miniature לא מחובר  

אה כנראה שהייתי צריך להביא את הקוד המלא מלכתחילה, מצטער.
הנה כל הקוד (ללא השינוי שאמרת לי לעשות):
PHP קוד:
<?php
if($action == "edit" && isset($HTTP_POST_VARS['password'])) {
    
//obviously you should change this password on the next line
    
if($HTTP_POST_VARS['password'] == "123456") {
        
//First let's recompile that line with the pipe symbols so we can reinsert it
        
$line $HTTP_POST_VARS['date'] . "|" $HTTP_POST_VARS['name'];
        
$line .= "|" $HTTP_POST_VARS['articles'];
        
$line str_replace("\r\n","<BR>",$line);
        
$line .= "\r\n";
        
$data file('articles.txt');
        
$data[$id] = $line;
        
//the next line makes sure the $data array starts at the beginning
        
reset($data);
        
//now we open the file with mode 'w' which truncates the file
        
$fp fopen('articles.txt','w');
        foreach(
$data as $element) {
            
fwrite($fp$element);
        }
        
fclose($fp);
        echo 
"<div class=\"content\"><b>הכתבה נערכה</b>\n";
        echo 
"&nbsp;|&nbsp;<a href=\"$PHP_SELF\">חזור לעמוד הראשי</a></div><BR><BR>\n";
        exit;
    } else {
$data file('articles.txt');
//next line removed to make everything else easier in the admin script
//$data = array_reverse($data);
foreach($data as $key=>$element) {
    
$element trim($element);
    
$pieces explode("|"$element);
        echo 
"<div class=\"content\"><b>סיסמה שגויה</b>\n";
        echo 
"&nbsp;|&nbsp;<a href=\"$PHP_SELF?action=edit&id=$key\">חזור</a></div><BR><BR>\n";
        exit;
    }
    }
}
if(
$action == "edit") {
    
$data file('articles.txt');
    
$element trim($data[$id]);
    
$pieces explode("|"$element);
    
//the next line is to reverse the process of turning the end of lines into breaking returns
    
$articles str_replace("<BR>","\r\n",$pieces[2]);
    echo 
"<div id=\"content\"><h2><u>ערוך כתבה</u></h2></div><BR>\n";
    echo 
"<div class=\"content\"><FORM ACTION=\"$PHP_SELF?action=edit\" METHOD=\"POST\" NAME=\"editform\">\n";
    echo 
"שם:<BR>\n";
    echo 
"<INPUT TYPE=\"text\" SIZE=\"30\" NAME=\"name\" value=\"".$pieces[1]."\"><BR>\n";
    echo 
"תוכן הכתבה:<BR>\n";
    echo 
"<TEXTAREA NAME=\"articles\" COLS=\"40\" ROWS=\"5\">".$articles."</TEXTAREA><BR><BR>\n";
    echo 
"סיסמה:<BR>\n";
    echo 
"<INPUT TYPE=\"password\" SIZE=\"30\" NAME=\"password\"><BR>\n";
    echo 
"<INPUT TYPE=\"hidden\" NAME=\"date\" VALUE=\"".$pieces[0]."\">\n";
    echo 
"<INPUT TYPE=\"hidden\" NAME=\"id\" VALUE=\"$id\">\n";
    echo 
"<INPUT TYPE=\"submit\" NAME=\"submit\" VALUE=\" שמור \"><BR>\n";
    echo 
"</FORM></div>\n";
    exit;
}
if(
$action == "delete" && isset($HTTP_POST_VARS['password'])) {
    
//obviously you should change this password on the next line
    
if($HTTP_POST_VARS['password'] == "123456") {
        
$data file('articles.txt');
        
//this next line will remove the single articles item from the array
        
array_splice($data,$id,1);
        
//now we open the file with mode 'w' which truncates the file
        
$fp fopen('articles.txt','w');
        foreach(
$data as $element) {
            
fwrite($fp$element);
        }
        
fclose($fp);    
        echo 
"<div class=\"content\"><b>הכתבה נמחקה</b>\n";    
        echo 
"&nbsp;|&nbsp;<a href=\"$PHP_SELF\">חזור לעמוד הראשי</a></div><BR><BR>\n";
        exit;
    } else {
$data file('articles.txt');
//next line removed to make everything else easier in the admin script
//$data = array_reverse($data);
foreach($data as $key=>$element) {
    
$element trim($element);
    
$pieces explode("|"$element);
        echo 
"<div class=\"content\"><b>סיסמה שגויה</b>\n";
        echo 
"&nbsp;|&nbsp;<a href=\"$PHP_SELF?action=edit&id=$key\">חזור</a></div><BR><BR>\n";
        exit;
    }
    }
}
if(
$action == "delete") {
    echo 
"<div id=\"content\"><h2><u>מחיקת כתבה</u></h2></div>\n";
    
$data file('articles.txt');
    
$element trim($data[$id]);
    
$pieces explode("|"$element);
    echo 
"<div class=\"content\">" $pieces[2] . "<BR>" "<b>נשלח על ידי " $pieces[1] . " ב " $pieces[0] . "</b>\n";
    echo 
"<BR><BR>\n";
    echo 
"אם אתה בטוח שברצונך למחוק את הכתבה, הקלד את הסיסמה ומחק:<BR><BR>\n";
    echo 
"<FORM ACTION=\"$PHP_SELF?action=delete\" METHOD=\"POST\" NAME=\"deleteform\">\n";
    echo 
"סיסמה:<BR>\n";
    echo 
"<INPUT TYPE=\"password\" SIZE=\"30\" NAME=\"password\"><BR>\n";
    echo 
"<INPUT TYPE=\"hidden\" NAME=\"id\" VALUE=\"$id\">\n";
    echo 
"<INPUT TYPE=\"submit\" NAME=\"submit\" VALUE=\" מחק \"><BR>\n";
    echo 
"</FORM></div>\n";
    exit;
}

echo 
"<div id=\"content\"><h2><u>כתבות נוכחיות</u></h2></div>\n";
$data file('articles.txt');
$data array_reverse($data);
foreach(
$data as $key=>$element) {
    
$element trim($element);
    
$pieces explode("|"$element);

    echo 
"<BR><div class=\"content\">" $pieces[2] . "<BR>" "<b>נשלח על ידי " $pieces[1] . " ב " $pieces[0] . "</b>\n";
    echo 
"&nbsp;(<a href=\"$PHP_SELF?action=delete&id=$key\">מחק</a>\n";
    echo 
"&nbsp;|&nbsp;<a href=\"$PHP_SELF?action=edit&id=$key\">ערוך</a>)\n";
    echo 
"<BR><HR><BR><BR></div>\n";
}
?>
אם תדע איך לעשות את אותו הדבר רק שתהיה אפשרות של עריכה ומחיקה אז תודה רבה
__________________
יואב.

דרכים ליצירת קשר:

אימייל: thebigfire@walla.co.il
הודעה פרטית