Jump to content

Covert perl log count code to php


sonny

Recommended Posts

I am converting perl scripts over to php

does anyone know how to convert this code below

over to php code?

 

{
my $n = 0; 
open (FH, "<", 'count.txt') or die "$!"; 
$n = <FH>; 
close FH; 
if ($n < 10) { 
   open (FH, ">", 'count.txt') or die "$!"; 
   print FH ++$n; 
   close FH;  
} 
else { 
print "Limit reached\n"; 
   exit(0); 
} 
@mail('$to, $subject, $message, headers');

 

Thanks

Sonny

Link to comment
Share on other sites

Does anyone know how I can delete my account on here?

if there is no way, please can a admin remove me,

 

I do not need wise a@# remarks like that, what would have been the

big deal anyway. Ive seen people on here ask for 100 times

more help on writing code then this.

Link to comment
Share on other sites

Does anyone know how I can delete my account on here?

if there is no way, please can a admin remove me,

 

I do not need wise a@# remarks like that, what would have been the

big deal anyway. Ive seen people on here ask for 100 times

more help on writing code then this.

 

No one will delete your account, it is wasteful. If you do not wish to recieve help from others, and have others write the code for you, look into the freelancing forum or else-sites. No one said you have to stay.

 

If you want a wise ass remark, That code takes seconds to convert into PHP, why should you if you cannot act properly towards helpful advice?

Link to comment
Share on other sites

What? no one will delete my account, I never read anything about signing up, was a lifetime thing?

you make it sound like that was a privilege or something, there should be a delete button in profile

its a commonsense and fair thing to have.

 

You and that other guy are punk wise guys, this forum is useless because of people like you!

go write yourself some code on politeness when you get some time, and share that with your

bro above.

Link to comment
Share on other sites

sorry to say 'sonny' we can't all just hold you by the hand and do all the work for you, i was rather busy with work at the time, and with your comments i scrapped what i put together for you...

 

You didn't put nothing together for me, stop it,

your just trying to get the last word in, and look

good,  you two guys where just trying to to make

a fool out of me.

 

People like you are ruining this forum.

Link to comment
Share on other sites

Sonny, give your best effort in changing the code before asking for help

 

Ok,

 

$n = 0;
$fh = @fopen('count.txt', 'r+') or die('Error in opening file for read & write');
$n = fread($fh);
if ($n < 3)
{
    ftruncate($fh, 0);
    @fwrite($fh, ++$n) or die ('Unable to write to file!');
}
else
{
    print "Limit Reached\n";
}
fclose($fh); 

 

This is giving me Warning: Wrong parameter count for fread() error

 

Link to comment
Share on other sites

try this:

<?php 
$n = 0;
$fh = @fopen('count.txt', 'r+') or die('Error in opening file for read & write');
$n = fread($fh,filesize('count.txt'));
if ($n < 3)
{
    ftruncate($fh, 0);
    @fwrite($fh, ++$n) or die ('Unable to write to file!');
}
else
{
    print "Limit Reached\n";
}
fclose($fh);
?> 

Glad to see you work your way through it!

Oh, and you need to give the size of the file for it to open (length).

Link to comment
Share on other sites

The code above is still not working right

 

This is the reason I was asking for help

my way, I need to have a 0 in the file to start

 

Plus every time the number is updated it pushws it to the right

with a space in front, something is not right with this code.

 

I figured someone might have a fresh way to do this

 

the whole basics behind this is so that I can have a setting for

limiting emails, I am not a pro not even close, just trying

 

but I cannot stand  someone trying to make a fool out of me

thats why I lost it, I don't think anyone on here would want that.

 

 

Link to comment
Share on other sites

but I cannot stand  someone trying to make a fool out of me

thats why I lost it, I don't think anyone on here would want that.

 

Guess again.  We don't care if you "lose it".  We're volunteers here. We don't get paid a cent for helping.  If you get an attitude, there are hundreds of other people who need our help, and will show a grain of respect. Have a nice day.

Link to comment
Share on other sites

but I cannot stand  someone trying to make a fool out of me

thats why I lost it, I don't think anyone on here would want that.

 

Guess again.  We don't care if you "lose it".  We're volunteers here. We don't get paid a cent for helping.  If you get an attitude, there are hundreds of other people who need our help, and will show a grain of respect. Have a nice day.

 

Just think about this for a moment, why even add your 2 cents then?

other then to be a wise guy, I never asked you or anone in purticular for

anything, I simply posted a tread for some minor help thats all,  Guess what, I guessed

wrong I guess, I'll speak in your native tongue maybe it will sink in deeper.

 

what a smart ... you are man

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.