-=HELLBENDER=- Posted December 22, 2010 Report Share Posted December 22, 2010 (edited) Sveiki. Cenšos izveidot adminpanelim lapu, kur varētu rediģēt citas lapas.. Apmēram šāds izskatās skripts (nav garš, tapēc rakstīšu te pat); <form action="edit.php" method="get"> Name: <input type="text" name="fname" /> <input type="submit" /> </form> <?php $fn = $_GET["fname"]; if (isset($_POST['content'])) { $content = stripslashes($_POST['content']); $fp = fopen($fn,"w") or die ("Error opening file in write mode!"); fputs($fp,$content); fclose($fp) or die ("Error closing file!"); } ?> <p> <form action="<?php echo $_SERVER["PHP_SELF"] ?>" method="post"> <textarea rows="30" cols="80" name="content"><?php readfile($fn); ?></textarea> <input type="submit" value="Edit"> </form> kad ievadu faila nosaukumu, nākamajā lapā atver veiksmīgi un parāda faila saturu, bet kad rediģēju un uzspiežu edit, izmet "Error opening file in write mode!". Mēģināju arī $_POST. Kur varētu būt vaina? :? ps. Starp citu, topic preview režīmā nestrādā HTML un PHP tagi kā vajag (neiekrāsojas). Edited December 22, 2010 by -=HELLBENDER=- Quote Link to comment Share on other sites More sharing options...
labaiss Posted December 22, 2010 Report Share Posted December 22, 2010 varbūt faila "permission"; Quote Link to comment Share on other sites More sharing options...
-=HELLBENDER=- Posted December 22, 2010 Author Report Share Posted December 22, 2010 (edited) CHMOD stāv uz 666 (all write/read) visiem web failiem. Edited December 22, 2010 by -=HELLBENDER=- Quote Link to comment Share on other sites More sharing options...
labaiss Posted December 22, 2010 Report Share Posted December 22, 2010 pamēģini - 777 varbūt nostrādā - bet varbūt es smagi kļūdos! Quote Link to comment Share on other sites More sharing options...
-=HELLBENDER=- Posted December 22, 2010 Author Report Share Posted December 22, 2010 Tas pats.. Starp citu, ja $fn = ieliek vnk faila nosaukumu, tad viss strādā.. Quote Link to comment Share on other sites More sharing options...
briedis Posted December 22, 2010 Report Share Posted December 22, 2010 Ieteiktu php.ini izslēgt magic_quotes_qpc, tad nebūs jālieto stripslashes, un īsāk ir izmantot funkcijas - file_get_contents() un file_put_contents(). Quote Link to comment Share on other sites More sharing options...
-=HELLBENDER=- Posted December 22, 2010 Author Report Share Posted December 22, 2010 (edited) Paldies, bet kļūda nemainīga.. <?php $fn = $_GET["fname"]; if (isset($_POST['content'])) { $fp = file_get_contents($fn, true) or die ("Error opening file in write mode!"); file_put_contents($fp,$content); } ?> Edited December 22, 2010 by -=HELLBENDER=- Quote Link to comment Share on other sites More sharing options...
briedis Posted December 22, 2010 Report Share Posted December 22, 2010 Gan jau ka fails neeksistē. Kam tev dota funkcija file_exists()? :) Quote Link to comment Share on other sites More sharing options...
-=HELLBENDER=- Posted December 22, 2010 Author Report Share Posted December 22, 2010 Kā tad viņš var atvērt un izdrukāt visu, kas ir tajā failā, ja tāds fails neeksistē? Quote Link to comment Share on other sites More sharing options...
briedis Posted December 22, 2010 Report Share Posted December 22, 2010 Kļūdu ziņošana ir ieslēgta? ..vai paskaties log failā, kas tad tur ir par problēmu. Quote Link to comment Share on other sites More sharing options...
-=HELLBENDER=- Posted December 22, 2010 Author Report Share Posted December 22, 2010 Tiešām, ar to file_exists izmeta.. Kā tas var būt, ka viņu sākumā nolasa, bet pēc tam vairs neatrod? "The file does not exist Error opening file in write mode!" Quote Link to comment Share on other sites More sharing options...
briedis Posted December 22, 2010 Report Share Posted December 22, 2010 varbūt aizmirsi pielikt faila paplašinājumu, vai mapi? Quote Link to comment Share on other sites More sharing options...
-=HELLBENDER=- Posted December 22, 2010 Author Report Share Posted December 22, 2010 Visi faili ir vienā un tajā pašā mapē.. Par faila paplašinājumiem ļoti šaubos, jo kā jau teicu, failu sākumā viņš atrod. Quote Link to comment Share on other sites More sharing options...
briedis Posted December 22, 2010 Report Share Posted December 22, 2010 nu bļins, atvainojos, tad salīdzini kāds tev tur ir tas kods, kas ver vaļā failu! Tak uzraksti var_dump($_GET["fname"]); un paskaties, ko tad tur satur tas mainīgais UN VAI PATIEŠĀM TĀDS FAILS EKSISTĒ! Quote Link to comment Share on other sites More sharing options...
-=HELLBENDER=- Posted December 22, 2010 Author Report Share Posted December 22, 2010 Sākumā, kad veiksmīgi nolasa faila saturu, izmet string(9) "index.php" , vēlāk, kad cenšās saglabāt, izmet NULL Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.