Jump to content

how to change string variable?


abeer

Recommended Posts

below is the script.i use it for to edit a single .html file. but now i want to edit multiple .html file by this script.

 

so i think i have to change dynimacaly (may be a dropdown form)  this line $url = "p".$page.".html";    and this line.

 

can any body help?

 

 

<?php   
  
function br2nl($str) {   
return preg_replace('=<br */?>=i', "", $str);   
}   
  
$action=$_POST['action'];   
$textarea=$_POST['textarea'];   
  
if($_GET['p']){   
$page=$_GET['p'];   
}   
  
// Assume your text pages are called, p1.db or p2.db, etc.   
$url = "p".$page.".html";   
if (file_exists($url)) {   
// do nothing   
} else {   
$url = "p0.html";   
}   
  
// where to go back to after the edit ...   
$return="edit.php?p=$edit";   
  
// Get page   
$data = implode("", file($url));    
  
if($action=="save"){   
$newtext=stripslashes($textarea);   
$newtext = str_replace("<?", "", $newtext);   
$newtext = str_replace("?>", "", $newtext);   
$newtext = nl2br($newtext);   
//echo "page: $url<br><br>\n";   
//echo $newtext;   
$fh = fopen($url, 'w') or die("can't open file");   
fwrite($fh, $newtext);   
fclose($fh);    
header ("location:edit.php?p=$page");   
}   
else{   
  
?>  
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
<html xmlns="http://www.w3.org/1999/xhtml">  
<head>  
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  
<title>abeer cms</title>  
<script type="text/javascript" src="jscripts/tiny_mce/tiny_mce.js"></script>  
<script type="text/javascript">  
tinyMCE.init({  
        // General options  
        mode : "textareas",  
        theme : "advanced",  
        plugins : "safari,spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,imagemanager,filemanager",  
  
        // Theme options  
        theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect",  
        theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",  
        theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",  
        theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,spellchecker,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,blockquote,pagebreak,|,insertfile,insertimage",  
        theme_advanced_toolbar_location : "top",  
        theme_advanced_toolbar_align : "left",  
        theme_advanced_statusbar_location : "bottom",  
        theme_advanced_resizing : true,  
  
        // Example content CSS (should be your site CSS)  
        content_css : "css/example.css",  
  
        // Drop lists for link/image/media/template dialogs  
        template_external_list_url : "js/template_list.js",  
        external_link_list_url : "js/link_list.js",  
        external_image_list_url : "js/image_list.js",  
        media_external_list_url : "js/media_list.js",  
  
        // Replace values for the template plugin  
        template_replace_values : {  
                username : "Some User",  
                staffid : "991234"  
        }  
});  
</script>  
<style>   
body,html{   
margin:0px auto;   
width:700px;   
text-align:center;   
}   
#content{   
margin:0px auto;   
width:700px;   
}   
#middle h1 {   
    color: transparent;   
    font-family:georgia;   
    font-size:12pt;   
    margin:0;   
    color: #dF9100;   
    padding:10px 0px 15px 0px;   
    text-align:left;   
}   
</style>   
</head>  
  
<body>  
<div id='content'>   
<?  
  
$ta=br2nl($data);   
  
echo"   
<a href='$return'><-- Return to Page</a><br /><br />   
Make Changes and click \"Save Changes\" at the very bottom ...<br />   
<form action='edit.php' method='post'>   
<input type='hidden' name='action' value='save'>   
<input type='hidden' name='p' value='$page'>   
<input type='hidden' name='n' value='$n'>   
<textarea name='textarea' rows='25' cols='80'>$ta</textarea>   
<br />   
<input type='submit' name='submit' value='Save Changes'>   
</form>   
  
<div id='middle' style='width:680px; text-align:left; padding-left:20px; border:1px solid #ccc;'>   
</div>   
</div>   
</body>   
</html>   
";   
}   
  
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.