Location: PHPKode > projects > Basic Announce > Basic Announce Version 4.0/system/dynamic_pages_editor.php
<?php
################################################################################
##              -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =-                 #
## --------------------------------------------------------------------------- #
##  ApPHP AdminPanel Pro                                                       #
##  Developed by:  ApPHP <hide@address.com>                                      #
##  License:       GNU LGPL v.3                                                #
##  Site:          http://www.apphp.com/php-adminpanel/                        #
##  Copyright:     ApPHP AdminPanel (c) 2006-2011. All rights reserved.        #
##                                                                             #
################################################################################

    header("content-type: text/html; charset=utf-8");

    // Initialize the session.
    session_start();
    
    require_once("../inc/classes/session.class.php");	
    require_once("../inc/checkAdminPagePermissions.php");

    require_once("../inc/config.inc.php");
    require_once("../inc/settings.inc.php");
	require_once("../inc/functions.inc.php");
	require_once("../inc/languages/".$SETTINGS['site_language'].".php");

    if(!page_access_allowed($_SERVER['SCRIPT_NAME'])) redirect_to("access_denied.php");

    $dpid           = isset($_REQUEST['dpid']) ? (int)$_REQUEST['dpid'] : "0";
    $act            = isset($_POST['act']) ? $_POST['act'] : "";
    $txaPageContent = isset($_POST['txaPageContent']) ? $_POST['txaPageContent'] : "";
    $file_name      = isset($_POST['file_name']) ? $_POST['file_name'] : "";
    $page_content   = "";
    $page_name      = "";
    $msg            = "";
	$is_file_exists = true;

    if($act == "submit"){
		if(strtolower(_SITE_MODE) == "demo"){
			$msg = draw_message("error", "This operation is blocked in demo version.", false, "780px", "../");					
		}else{			
			if($txaPageContent == ""){
				$msg = draw_message("error", "Page can not be empty! Please re-enter.", false, "780px", "../");
			}else{            
				// write data to the file 
				@chmod("../pages/".$file_name, 0755);
				$fh = fopen("../pages/".$file_name, 'w');
				if(!$fh){
					$msg = draw_message("error", "Can not open file: ".$file_name, false, "780px", "../");
				}else{
					$txaPageContent = str_replace("\\", "", $txaPageContent);
					fwrite($fh, $txaPageContent);
					fclose($fh);

					$sql = "UPDATE ".TABLE_DYNAMIC_PAGES." SET updated_at = '".date("Y-m-d H:i:s")."' WHERE id = ".(int)$dpid;
					$db->Exec($sql);
					
					$msg = draw_message("success", "The page was susseccfully updated!", false, "780px", "../");                
				}
				@chmod("../pages/".$file_name, 0644);
			}			
		}		
    }
	
	$sql = "SELECT
			".TABLE_MENU.".name,
			".TABLE_MENU.".page_name
		FROM ".TABLE_DYNAMIC_PAGES."
			INNER JOIN ".TABLE_MENU." ON ".TABLE_DYNAMIC_PAGES.".menu_id = ".TABLE_MENU.".id
		WHERE ".TABLE_DYNAMIC_PAGES.".id = ".(int)$dpid;
	$db->Query($sql);
	if($row = $db->FetchArray()){
		$file_name = $row['page_name'];
		if(!file_exists("../pages/".$file_name)){
			$msg = draw_message("error", "File ".$file_name." doesn't exist!", false, "780px", "../");					
			$is_file_exists = false;
		}else{
			$page_content = file_get_contents("../pages/".$row['page_name']);
			$is_file_exists = true;			
		}
		//$page_content = str_replace("\\'", "'", $page_content);
		//$page_content = str_replace('\\"', '"', $page_content);
		$page_name = $row['name'];
	}		


?>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
	<title><?php echo $SETTINGS['site_name']; ?> :: <?php echo lang('admin_panel'); ?></title>
    <meta http-equiv=Content-Type content="text/html; charset=utf-8">
    <link href="../styles/<?php echo $SETTINGS['css_style'];?>/style.css" type=text/css rel=stylesheet>
    <script>
        function btnCancel_OnClick(){
            document.location.href = "dynamic_pages_manager.php";
        }
        
        function btnSubmit_OnClick(){
            var frm = document.getElementById("frmEditPage");
            frm.submit();
        }
    </script>
</head>

<body dir="<?php echo $SETTINGS['language_dir'];?>">
<?php echo page_breadcrumbs("dynamic_pages_manager.php"); ?>
<br />  
<h3>Edit <?php echo $page_name." (".$file_name.")"; ?></h3>
<?php
if($is_file_exists){
?>
    <form name="frmEditPage" id="frmEditPage" action="dynamic_pages_editor.php?dpid=<?php echo $dpid;?>" method="post">
        <input type="hidden" name="act" value="submit" />
        <input type="hidden" name="file_name" value="<?php echo $file_name;?>" />
        
        <table cellpadding="2" cellspacing="2">
        <tr valign="top">
            <td></td>
            <td></td>
            <td><?php echo $msg;?></td>
        </tr>
        <tr valign="top">
            <td><b>Code: <font color="#b60000">*</a></b></td>
            <td>&nbsp;</td>
            <td>
                <textarea name="txaPageContent" wrap="off" style="overflow-x:auto; width:760px; height: 380px;"><?php echo $page_content; ?></textarea>
            </td>
        </tr>
        <tr valign="top">
            <td></td>
            <td>&nbsp;</td>
            <td>
                <input type="button" name="btnCancel" value="Cancel" onclick="btnCancel_OnClick()" />
                <input type="button" name="btnSubmit" value="Save" onclick="btnSubmit_OnClick()" />
            </td>
        </tr>    
        </table>
    </form>

<?php
}else{ 
	echo "<br />".$msg;
	echo "<br /><br /><table width='780px' align='center'><tr><td><a href='javascript:history.back(1);'>Back</a></td></tr></table>";
}
?>
<br />
</body>
</html>
Return current item: Basic Announce