הוסטס - פורום אחסון האתרים הגדול בישראל

הוסטס - פורום אחסון האתרים הגדול בישראל (https://hosts.co.il/forums/index.php)
-   פורום תיכנות (https://hosts.co.il/forums/forumdisplay.php?f=14)
-   -   [מחפש] פונקציה ליצירת קבצים. (https://hosts.co.il/forums/showthread.php?t=51540)

Startzero.net 07-08-07 13:47

[מחפש] פונקציה ליצירת קבצים.
 
אני רוצה ליצור דף בשם "index.html" ובתוכו לשים תוכן.

יש כזאת פונקציה שעושה את זה?
תודה לעוזרים.

Meir 07-08-07 13:48

http://il2.php.net/manual/en/function.fopen.php

Startzero.net 07-08-07 14:06

מקווה שיעבוד.. תודה.

Startzero.net 07-08-07 14:45

PHP קוד:

fopen("/$rand/index.txt""MA KOrE?"); 

זה עושה לי ככה:
ציטוט:

Warning: fopen() [function.fopen]: open_basedir restriction in effect. File(/19480/index.txt) is not within the allowed path(s): (/home/startzero/:/tmp:/usr/local/lib/php/) in /home/startzero/domains/startzero.net/public_html/u/url.php on line 12

Warning: fopen(/19480/index.txt) [function.fopen]: failed to open stream: Operation not permitted in /home/startzero/domains/startzero.net/public_html/u/url.php on line 12

Meir 07-08-07 14:53

אתה לא עובד נכון עם הפונקציה הפרמטר השני צריך להיות המצב שבו אתה פותח את הקובץ, אל תשכח גם לתת הרשאת כתיבה לתיקייה.

Startzero.net 08-08-07 16:02

קוד:

<form method="POST">
<input type="hidden" name="post" value="1">
<input name="url" size="26"> <input type="submit" value="Shortcut >>">
</form>

<?php

if($_POST['post'] == "1") {

$rand = rand(1111, 9999);
mkdir("$rand", 0777);
fopen("$rand/index.txt", "MA KOrE?");

}

?>

עשיתי ככה,
זה יוצר תיקיה.. אבל לא את הקובץ.

ציטוט:

Warning: fopen() [function.fopen]: SAFE MODE Restriction in effect. The script whose uid is 749 is not allowed to access /home/startzero/domains/startzero.net/public_html/u/3685 owned by uid 100 in /home/startzero/domains/startzero.net/public_html/u/url.php on line 12

Warning: fopen(3685/index.txt) [function.fopen]: failed to open stream: No such file or directory in /home/startzero/domains/startzero.net/public_html/u/url.php on line 12

Tomer 08-08-07 16:17

תקרא לגבי הפרמטרים של fopen ב php.net - הוא לא מקבל את התוכן של הקובץ, אלא פרמטר שקובע איך לעבוד עם הקובץ. fwrite רושם לקובץ.

Startzero.net 08-08-07 16:22

הנה תומר, עכשיו עשיתי את הקוד הבא:

PHP קוד:

$url $_POST['url'];

$myFile "index.html";
$fh fopen($myFile'w') or die("can't open file");
$stringData "

<html> <script>location.href='$url'</script> </html> 

"
;
fwrite($fh$stringData);
fclose($fh); 

עכשיו זה יוצר תקובץ, ועושה מה שאני רוצה.
אבל.. אני רוצה שזה יכניס תקובץ לתוך תיקיה אחרי שכבר יצרתי אותה.
כשאני עושה את זה יש בעיות.

חיים 08-08-07 16:33

איזה בעיות זה עושה :S

Startzero.net 08-08-07 16:47

PHP קוד:

<form method="POST">
<input type="hidden" name="post" value="1">
<input name="url" size="26"> <input type="submit" value="Shortcut >>">
</form>

<?php

if($_POST['post'] == "1") {

$rand rand(11119999);
mkdir("$rand"0777);

$url $_POST['url'];
$myFile "/$rand/index.html";
$fh fopen($myFile'w') or die("can't open file");
$stringData "

<html> <script>location.href='$url'</script> </html> 

"
;
fwrite($fh$stringData);
fclose($fh);

}

?>

זה נותן שגיאה כזאת:
ציטוט:

Warning: fopen() [function.fopen]: open_basedir restriction in effect. File(/8947/index.html) is not within the allowed path(s): (/home/startzero/:/tmp:/usr/local/lib/php/) in /home/startzero/domains/startzero.net/public_html/u/url.php on line 15

Warning: fopen(/8947/index.html) [function.fopen]: failed to open stream: Operation not permitted in /home/startzero/domains/startzero.net/public_html/u/url.php on line 15
can't open file


כל הזמנים הם GMT +2. הזמן כעת הוא 19:01.

מופעל באמצעות VBulletin גרסה 3.8.6
כל הזכויות שמורות ©
כל הזכויות שמורות לסולל יבוא ורשתות (1997) בע"מ