Jump to content

PHP exit


GuestofHonor

Recommended Posts

Hello guyz,

 

i need a help to stop a script from running after posting a message.

 

Original code

<?php
 if ($talk == true) {
  $check = Check_Link($chat, $user_file, $date);
  if ($check == true);
  else {
   if (strpos($chat, 'Stupid Bot') != 0 || strpos($chat, 'stupid bot') != 0) {
 //Save file + time
 $log = fopen($user_file,"a",1);
 $today = getdate();
 $data = $date.'-'.$chat.'|';
 fwrite($log, $data); 
 fclose($log);
 $mess = "[color=blue][b]".$name."[/color] haha go [/b] :sleep";
 post_cbox($mess);
   }
   elseif (strpos($chat, 'alt="thanks"/>') != 0 && strpos($chat, 'Gasolina') != 0 || strpos($chat, 'alt="thanks"/>') != 0 && strpos($chat, 'gasolina') != 0) {
 //Save file + time
 $log = fopen($user_file,"a",1);
 $today = getdate();
 $data = $date.'-'.$chat.'|';
 fwrite($log, $data); 
 fclose($log);
 $mess = "@ [color=blue][b]".$name."[/b][/color] You Are Most welcome ";
 post_cbox($mess);
   }

 

what i want to do is to stop script from writing user folder but still stop after posting the $mess, i tried exit and goto but it keep posting the message infinitly when i do.

 

thanks in advance

Link to comment
https://forums.phpfreaks.com/topic/274726-php-exit/
Share on other sites

Use stripos which is the case-insensitive version of strpos(), will save you some writing.

Also, in the elseif block conditional statement, place parens around each && condition for correct order of operations:

(this && that) || (this && that)

 

I don't quite understand you logic, I believe you want the post_cbox() function to execute but do not want any data to be written to a file?

Link to comment
https://forums.phpfreaks.com/topic/274726-php-exit/#findComment-1413625
Share on other sites

Use stripos which is the case-insensitive version of strpos(), will save you some writing.

Also, in the elseif block conditional statement, place parens around each && condition for correct order of operations:

(this && that) || (this && that)

 

I don't quite understand you logic, I believe you want the post_cbox() function to execute but do not want any data to be written to a file?

 

Thanks for the reply

this script was not written by me, but whoever wrote it made every thing write to log, now when it writes to log it will force users who the script reply to to wait 5 minutes before doing any more actions, i dont want them to wait for chat or for other things, thats why i asked if there's a way for the script to post the message without storing the name in the log.

so i just want it to send message and stop without writing any file.

 

Regards

Link to comment
https://forums.phpfreaks.com/topic/274726-php-exit/#findComment-1413629
Share on other sites

Comment out the lines that are relevant to sending data to the log?

I don't recommend removing them altogether as you may need them in the future, there is a reason the logic was implemented the way it was.

 

can i explain the main concept of the whole script ?

 

it is a bot that login to cbox chat box to give links to users, each user is allowed to get one link from the bot each 5 minutes or whatever i set time, but i dont want users to wait if they just chat with bot or bot chat with users.

 

Thanks in advance

Link to comment
https://forums.phpfreaks.com/topic/274726-php-exit/#findComment-1413638
Share on other sites

can i explain the main concept of the whole script ?

 

it is a bot that login to cbox chat box to give links to users, each user is allowed to get one link from the bot each 5 minutes or whatever i set time, but i dont want users to wait if they just chat with bot or bot chat with users.

 

Thanks in advance

 

this sounds a little different then the issue in the OP. If you do not want the script to write data to a log then remove the code that does so.

Link to comment
https://forums.phpfreaks.com/topic/274726-php-exit/#findComment-1414079
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.