storyboo Posted July 31, 2008 Share Posted July 31, 2008 What I did was I made a new page in my store admin area and gave it a link under navigation. Then I made sure to included the general files like header.inc.php etc. I am trying to open the index.tpl to a form in the new admin page and then read it...and make changes and upon saving the changes..have the php script I wrote overwrite the contents of the index.tpl with my changes and then save those changes for next time I edit it. I have copied the code from the select skin under general settings to put on the new page, so that I can first choose a skin..then it loads in the text area below and then I can edit. The way this cart work is when you get to the skin directory...there are three skins beneath it named killer, classic, and legend..and it each of those folders is the same heirachy of folders and files. So the paths will always be the same to get to my index.tpl EXCEPT the skin name directory. The PROBLEM: I think I am not getting the path to the file correct. Or I may be missing something in my code. I FINALLY got the tpl to read to the text area...so now I can see my tpl file in the text area now and I can make changes. However, I had to delete all the other skins except the killer that I use and that way I was able to use the form to find file=" http://www.mystore.com/skins/Killer/styleT...lobal/index.tpl. Bu tI dont want to use this FN in the form area....but if I dont use the absolute path..it get an error that it cant find the file..no such file. Also, I made sure to chmodd the files to writable readable. The file is displayed in my little text area BUT when I hit save to save changes, I get this error: Warning: fopen(skins//styleTemplates/content/index.tpl) [function.fopen]: failed to open stream: No such file or directory in /home/marketmo/public_html/admin/settings/getfile.php on line 4 Error opening file in write mode! ----------------------------------------------------------------------------------- The code for the form or extra adminpage I made: ---------------------------------------------------------------------------------- <?php include("../../includes/ini.inc.php"); include("../../includes/global.inc.php"); require_once("../../classes/db.inc.php"); $db = new db(); include_once("../../includes/functions.inc.php"); $config = fetchDbConfig("config"); include_once("../../language/".$config['defaultLang']."/lang.inc.php"); $enableSSl = 1; include_once("../../includes/sslSwitch.inc.php"); include("../includes/auth.inc.php"); include("../includes/functions.inc.php"); if(permission("settings","read")==FALSE){ header("Location: ".$GLOBALS['rootRel']."admin/401.php"); exit; } include("../includes/header.inc.php"); ?> <p class="pageTitle"><?php echo $lang['admin']['settings']['store_settings']; ?></p> <?php if(isset($msg)){ echo stripslashes($msg); } else { ?> <p class="copyText"><?php echo $lang['admin']['settings']['edit_below']; ?></p> <?php } ?> <table> <tr> <td width="30%" class="tdText"><strong><?php echo $lang['admin']['settings']['store_skin'];?></strong></td> <td align="left"> <?php $path = $GLOBALS['rootDir']."/skins"; if ($dir = opendir($path)) { ?> <select class="textbox" name="config[skinDir]"> <?php while (false !== ($file = readdir($dir))) { if(!eregi($file,array(".",".."))){ ?> <option value="<?php echo $file; ?>" <?php if($file==$config['skinDir']) { echo "selected='selected'"; } ?>><?php echo $file; ?></option> <?php } } ?> </select> <?php } ?> </td> </tr><tr><td> <form action="getfile.php" method="POST"> <table border="0" cellpadding="7" cellspacing="0" align="center" class="generaltable"> <tr> <td align="center" class="fieldname" colspan="2">Custom Template</td> </tr> <tr> <td align="center" colspan="2"> Paste your custom template's HTML code below, including all HTML tags<br> and any <a href="includes/sitecodes.htm" target="_blank" onClick="PopUp=window.open('includes/sitecodes.htm', 'NewWin', 'resizable=yes,scrollbars=yes,width=400,height=400,left=0,top=0,screenX=0,scr eenY=0'); PopUp.focus(); return false;">site include codes</a> as needed. Use absolute references for all of your<br> images and links, instead of relative ones. (ie. <a href="page.php">Page</a><br> would be written as <a href="http://www.yoursite.com/page.php">Page</a>)</td> </tr> <td> <tr> <td align="center" colspan="2"> <textarea rows="20" name="store_template" cols="55"> <?php $fn = "http://www.mysite.com/skins/Killer/styleTemplates/global/index.tpl"; print htmlspecialchars(implode("",file($fn))); ?> </textarea></td> </tr> <tr> <tr> <td width="30%" class="tdText"> </td> <td align="left"> <input name="submit" type="submit" class="submit" id="submit" value="Update Settings" /></td> </tr> </tr> </table> </form> </td></tr></table> <?php include("../includes/footer.inc.php"); ?> ---------------------------------------------------------------------------- And here is the file for the file that the form calls to perform functions ---------------------------------------------------------------------------------- <?php $fn =($glob['rootDir']."skins/".$config['skinDir']."/styleTemplates/global/index.tpl"); $store_template = stripslashes($_POST['content']); $fp = fopen($fn,"r+") or die ("Error opening file in write mode!"); fputs($fp,$store_template); fclose($fp) or die ("Error closing file!"); echo "<meta http-equiv=\"refresh\" content=\"0; url=stm.php\" />\n"; ?> ---------------------------------------------------------------------------------- NOTE: I also tried making the snippet above look like this as an alternative: ------------------------------------------------------------------------------------ <?php $fn =("http://www.mysite.com/skins/Killer/styleTemplates/content/index.tpl"); $store_template = stripslashes($_POST['content']); $fp = fopen($fn,"r+") or die ("Error opening file in write mode!"); fputs($fp,$store_template); fclose($fp) or die ("Error closing file!"); echo "<meta http-equiv=\"refresh\" content=\"0; url=stm.php\" />\n"; ?> ----------------------------------------------------------------------------- HOWEVER THIS MADE A WARNING THAT THE HTTP wrapper does not support writeable connections in blahblahblah------------- I REALLY want to be able to take the store admin select skin feature and then be able to add the functionality of editing the chosen skin file's TPL from admin. Have it open, read it, allow me to change it and save it. Then to be able to do it again anytime. What am I doing wrong? Link to comment https://forums.phpfreaks.com/topic/117630-webbased-html-form-php-help/ Share on other sites More sharing options...
waynew Posted July 31, 2008 Share Posted July 31, 2008 Put your code inside code tags plzktnx Link to comment https://forums.phpfreaks.com/topic/117630-webbased-html-form-php-help/#findComment-605015 Share on other sites More sharing options...
storyboo Posted July 31, 2008 Author Share Posted July 31, 2008 Sorry In the stm.php file I replaced the php for the textfile to this...different from above: <?php $fn =$glob['rootDir']."skins/".$config['skinDir']."/styleTemplates/global/index.tpl"; print htmlspecialchars(implode("",file($fn))); ?> Now i get this error: <br /> <b>Warning</b>: file(/home/marketmo/public_htmlskins/Killer/styleTemplates/global/index.tpl) [<a href='function.file'>function.file</a>]: failed to open stream: No such file or directory in <b>/home/marketmo/public_html/admin/settings/stm.php</b> on line <b>51</b><br /> <br /> <b>Warning</b>: implode() [<a href='function.implode'>function.implode</a>]: Invalid arguments passed in <b>/home/marketmo/public_html/admin/settings/stm.php</b> on line <b>51</b><br /> Link to comment https://forums.phpfreaks.com/topic/117630-webbased-html-form-php-help/#findComment-605043 Share on other sites More sharing options...
waynew Posted July 31, 2008 Share Posted July 31, 2008 Double check your filenames and directories and make sure that they're a match. Link to comment https://forums.phpfreaks.com/topic/117630-webbased-html-form-php-help/#findComment-605048 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.