Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Not a member yet? Click here to register.
Forgot Password?

small logfile

Asked Modified Viewed 1,730 times
C
Catzenjaeger
C
  • Senior Member, joined since
  • Contributed 408 posts on the community forums.
  • Started 137 threads in the forums
  • Started this discussions
asked
Senior Member

hello

i have written a small log.php but it makes some errors and i dont find why


<?php

///////////////////////////////////////////////////////////////////
//LOG wird im Ordner log im Root abgelegt - Textbasiert/////////////
///////////////////////////////////////////////////////////////////
$monate = array(1=>"Januar", 2=>"Februar", 3=>"Maerz", 4=>"April", 5=>"Mai", 6=>"Juni", 7=>"Juli", 8=>"August", 9=>"September", 10=>"Oktober", 11=>"November", 12=>"Dezember");
$monat = date("n");
$jahr = date("y");
$dateiname="log/log_$monate[$monat]_$jahr.txt";

$logdatei=fopen($dateiname,"a");

fputs($logdatei,
    date("d.m.Y, H:i:s",time()) .
    ", " . $_SERVER['REMOTE_ADDR'] .
    ", " . $_SERVER['REQUEST_METHOD'] .
    ", " . $_SERVER['PHP_SELF'] .
    ", " . $_SERVER['HTTP_USER_AGENT'] .
    ", " . $_SERVER['HTTP_REFERER'] ."\n"
    );
fclose($dateiname);
/////////////////////////////////////////////////////////////////////
//LOG ENDE/////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////

?>


i get:

log/log.php
fclose() expects parameter 1 to be resource, boolean given Zeile: 21    05. März 2014 um 11:12:51    
log/log.php
fputs() expects parameter 1 to be resource, boolean given Zeile: 20    05. März 2014 um 11:12:51    
log/log.php
fopen(log/log_Maerz_14.txt): failed to open stream: No such file or directory Zeile: 11
0 replies

1 post

C
Craig
C
Craig 14
  • Fusioneer, joined since
  • Contributed 4,462 posts on the community forums.
  • Started 212 threads in the forums
answered
Fusioneer

WOWSERS Mate Steady there. You wrote that or pulled it from somewhere?

Please study PHP Security. I will not point out exactly what I can do with that but please consider some security checks including using isset, isnum(?), and stripinput and elses. You will learn soon enough. Keep up the enthusiasm, and good luck!!
0 replies

Labels

None yet

Statistics

  • Views 0 views
  • Posts 1 post
  • Votes 0 votes
  • Topic users 2 members

2 participants

C
C
  • Senior Member, joined since
  • Contributed 408 posts on the community forums.
  • Started 137 threads in the forums
  • Started this discussions
C
C
Craig 14
  • Fusioneer, joined since
  • Contributed 4,462 posts on the community forums.
  • Started 212 threads in the forums

Notifications

Track thread

You are not receiving notifications from this thread.

Related Questions

Not yet