PHP - How To Run A Line Of Code After 10 Minutes Of Running Another Line Of Code In Php
I want my application will send a email after 10 minutes of sending another email. In my application A user completes registration with payment Application sends the user a payment confirmation emailNow I want to send another email 10 minutes After payment confirmation email with welcome tipsBelow is the function where for user setup .
public function finishUserSetup($Sub){ if($Sub == 0){ $subscription = SubscriptionPlans::where('identifier', '=', "Monthly")->first(); $expiry = date('Y-m-d', strtotime('+' . $subscription->months . ' months')); $sub_period = "monthly"; } else{ $subscription = SubscriptionPlans::where('identifier', '=', "Annually")->first(); $expiry = date('Y-m-d', strtotime('+' . $subscription->months . ' months')); $sub_period = "annually"; } $this->expiry_date = $expiry; $this->user_type = "SUB"; $this->subscription_period = $sub_period; $this->update(); $replaceArray = array( 'fullname' => $this->forename . " " . $this->surname, 'subscriptionName' => $subscription->name, ); EmailTemplate::findAndSendTemplate("paymentconfirm", $this->email, $this->forename . " " . $this->surname, $replaceArray); } In the above function the last line of code is the one which sends a payment confirmation email to the user which is EmailTemplate::findAndSendTemplate("paymentconfirm", $this->email, $this->forename . " " . $this->surname, $replaceArray); I want to execute the following line of code 10 minutes after the above one
EmailTemplate::findAndSendTemplate("WelcomeTips", $this->email, $this->forename . " " . $this->surname, $replaceArray);
How to do that. that is running the last line of code 10 minutes after Similar TutorialsCan you suggest a better way to write this code (I didn't create it):
<body onload="getParameterByName('url')"> <a href="" id="urllink" >Click Here</a> </body>so, I don't have to change the <body> tag? How do I remove the captcha check on this line and keep it valid? if ($author && $message && ($capatcha == 6 || controlPosts::isAdmin())) I tried if ($author && $message && (controlPosts::isAdmin())) but the script wont post like this? for timthumb in my wordpress i use this code to function first_image() { global $post, $posts; $first_img = ''; ob_start(); ob_end_clean(); $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches); $first_img = $matches [1] [0]; if(empty($first_img)){ //Defines a default image $first_img = "images/default.gif"; } return $first_img; } it works really well, then i thought why not to make it show random images if timthumb dont find any image? so the 1st googling i did came up with this function: <?php function getRandomFromArray($ar) { mt_srand( (double)microtime() * 1000000 ); $num = array_rand($ar); return $ar[$num]; } function getImagesFromDir($path) { $images = array(); if ( $img_dir = @opendir($path) ) { while ( false !== ($img_file = readdir($img_dir)) ) { // checks for gif, jpg, png if ( preg_match("/(\.gif|\.jpg|\.png)$/", $img_file) ) { $images[] = $img_file; } } closedir($img_dir); } return $images; } $root = ''; // If images not in sub directory of current directory specify root //$root = $_SERVER['DOCUMENT_ROOT']; $path = 'images/'; // Obtain list of images from directory $imgList = getImagesFromDir($root . $path); $img = getRandomFromArray($imgList); ?> and to show random image i Place the following where i wish the random image to appear: Code: [Select] <img src="<?php echo $path . $img ?>" alt="" /> my question is how to place this code in my function first_image?? i need to do something like this, but it doesnt make any sense: if(empty($first_img)){ //Defines a default image $first_img = " <img src="<?php echo $path . $img ?>" alt="" /> this was my thought, if i can mix those 2 normally it should work, right? or maybe there is another way to show random image in the Code: [Select] [i] if(empty($first_img)){ //Defines a default image[/i] [b] $first_img = ? ok, this is a much shorter version, but i have: Code: [Select] $val = "1"; then i have a function Code: [Select] function include_function_name{ echo' <ul><li> <a href="index.php?pageID="{$val}"">page name</a> <li/><ul/>'; } i have tried all sorts of variations but i can get it to make pageID=1 plaease help thanks ricky I looked up 'how to get all POST variables' and I ended up putting this bit of code together. Im not experienced at all with OOP programming, but I think that when '=>' is used its to do with OOP? Anyway. I dont get this code. I understand Foreach $_POST, as $someVar, (BTW im looking for checkboxes from a form), However, If I leave out the '=> $val' I simply get a lot of 'on' values, indicating the checkboxes I checked. However, WITH the '=> $val' I end up with the checkbox name. Now i've changed the name of '$val' so i know its not a keyword. But i dont get it. Is there a way to access the value of the checkbox? Can someone explain to me whats going on here? I know that I can get the value of the checkbox by $_POST['$checkRows'] But, I have a feeling It can be done in the foreach line. foreach($_POST as $checkRows => $hip) { echo "POSTED: $checkRows<br>\n"; } Please help! Hi, can any see is the are mistakes in this for me. Thanks echo'<img src="skinFiles/'.$skin['thumb_name'].'"class="skinImage" onclick="changeSkin(\'skinFiles/'.$skin["css_name"].'\')" />'; I'm using a templated PHP script and have successfully added a link (to an image) I've made up some new code but I have an issue with trying to figure out why it won't work. Do you see any issues with it? $rss = fetch_feed('<?php echo get_post_meta($post->ID, "linktosource", true);?>'); Thanks in advance can anyone help me with an overwhelming problem ? I want to use this command in the php curl code. curl -v --data "WSCommunityStringRW?2=1200ve50set&Submit=Submit" http://10.2.3.111/Forms/SnmpCommunityString -u "admin:a1s2d3" --anyauth $tab is a variable for my table's name <?php while($row=mysqli_fetch_assoc($result)){ ?> <?php echo $row['{$tab}_name']?> Hello -- I'm trying to work through a very simple CMS that I found on the web (just for learning purposes). I need some help understanding this line: <table> <form method="POST" action="account.php?mode=save<?=( isset($_REQUEST['id']) ? "&id={$_REQUEST['id']}" : null )?> <? I understand the Method = "POST", but not the "action = " line. Thanks for any help. I want to offer my site visitors the opportunity to use some of my content on their sites. For example, a Quote of the Day or This Date in History snippet that they can place on their site. I want to host and manage the content on my site and allow the visitors to syndicate it on their sites easily. The key word here is "easily". I don't want to do this through RSS, which can be tricky for entry-level webmasters and bloggers. I want to be able to offer a line of code, say in Javascript, that the visitor can copy and paste into their site (Wordpress widget etc.) and have my content appear there. Does anyone have any starting points for how to do this? I have several years of experience with PHPP, MySQL, CSS, HTML, etc., but I don't want to re-invent the wheel. I've done something similar in JSP, but not using PHP. I hav a php page which takes data from the db.But the problem i am facing is for a particular fild in database ,i have long data,which i need to b displayed in a wordwrap way eg my data is " Description need a site for school gave order on 12-10-2010 work started on 12-10-2010 " this shuld be displayed as "Description need a site for school gave order on 12-10-2010 work started on 12-10-2010" Description is the field in the database and rest of them are the datas in it Is it possible to find out what line of code a PHP script was processing immediately before it is interrupted upon receiving a POSIX signal? A bit of background - I've got a PHP script which runs (from the command line) hundreds of thousands of times a day and usually it's just fine. Every so often (less than once a week) it gets into a muddle and freezes until I kill it. I've written a signal handler (using the posix_signal() function) into the script which catches SIGABRT signals. When it gets one, it dumps $GLOBALS to a file, cleanly releases the data its working on then exits. That gives me a nice 'get out of jail free' card, but I'd really like to identify where (and then why) it's freezing. I could insert loads of debugging code which sets some variable with what stage it's up to, but it's a fairly complicated script and I'd rather not. There's got to be a better way! __LINE__ and __FUNCTION__ unfortunately just point to my signal handler function. So, is there anyway that the function which is invoked by the SIGABRT signal can report what line of code the script was on at the time the SIGABRT was received? Or alternatively, is there a way to figure out what a running PHP script is doing if you know its PID? Maybe there's something in /proc/<PID> which might help me... Here's what I'm trying to do, and I am having trouble getting started with this. It's a very simple process, but I didn't want to spend the next 6 hours in frustration, so some help getting started would be great. Here's the purpose of the script: 1. Allow user to add a text file to a form. 2. Take the text file, add HTML code to the beginning and end of each paragraph (a single line of text, usually paragraphs would be separated by a line return) 3. Send the user an email with the HTML file attached and thank them or whatever. 4. Allow the system to throttle itself (one-at-a-time) so that many people using the site won't bog it down. These files will probably be anywhere from 100 KB to 1,000 KB in size, usually hitting in the 300-500KB range. Here's what I can do very easily: 1. Allow user to add a text file - very simple and straightforward. 2. Take the text file, add HTML... - this is what I need a little help figuring out. Each paragraph needs to have <p> at the beginning and </p> at the end, and the script will also search for keywords on certain lines (section headers) and add a <align="center"> tag to that, and so forth. I can handle the formatting rules, but making sure the loop runs correctly could be a problem. 3. Send the user an email... - very easy, I can do that myself. 4. Allow the system to throttle itself... - this could be tricky. I was thinking a database with a TINYINT field, 0 for not processed yet, 1 for processing, 2 for processed. Cron job checks the next one on the list to see if it needs to send it to the processor, if the file is already being processed, or can be sent to a different database (completed entries) and removed from the current queue. The cron job would also be responsible for triggering the "Your file is converted!" email and the attachment. Any/all help would be greatly appreciated on this. I am going to work on the parts that I can do myself, and I'll be checking back for the discussion - in between Mountain Dew runs. This topic has been moved to Editor Help (Dreamweaver, Zend, etc). http://www.phpfreaks.com/forums/index.php?topic=355418.0 I would like to update the DB when a service ends and thought about doing so in the destructor, but I did not make much progress. Then tried using pcntl_signal(), but also didn't get far. Is doing so possible? Thanks /usr/lib/systemd/system/test123.service [Unit] Description=bla After=syslog.target [Service] ExecStart=/usr/bin/php /var/www/testing/__destruct.php [Install] WantedBy=multi-user.target
/var/www/testing/__destruct.php <?php ini_set('display_errors', 1); pcntl_signal(SIGTERM, function() { syslog(LOG_INFO, 'Caught SIGTERM'); die; }); pcntl_signal(SIGHUP, function() { syslog(LOG_INFO, 'Caught SIGHUP'); die; }); pcntl_signal(SIGUSR1, function() { syslog(LOG_INFO, 'Caught SIGUSR1'); die; }); pcntl_signal(SIGINT, function() { syslog(LOG_INFO, 'Caught SIGINT'); die; }); pcntl_signal(SIGABRT , function() { syslog(LOG_INFO, 'Caught SIGABRT '); die; }); /* pcntl_signal(SIGSTOP , function() { syslog(LOG_INFO, 'Caught SIGSTOP '); die; }); */ /* pcntl_signal(SIGKILL , function() { syslog(LOG_INFO, 'Caught SIGKILL '); die; }); */ class Bla { private $bla; public function __construct($bla) { syslog(LOG_INFO, '__construct'); $this->bla = $bla; } public function __destruct() { syslog(LOG_INFO, '__destruct'); } public function start() { $counter=0; $counter2=0; while(true) { $counter++; if($counter>10000000) { $counter2++; $counter=0; syslog(LOG_INFO, '.'); } if($counter2>5) { die('all done!'); } } } } $bla = new Bla('hello'); $bla->start();
Looking to set current page to more than one option... Something that sets $currentPage to contact.php or thankyou.php... how can I modify this statement below? <li><a href="contact.php" <?php if ($currentPage == 'contact.php') {echo 'id="here"';} ?>>Contact</a></li> Thanks for your time! what im trying to do is take a youtube embed code find the URL code for that video and remove all other parts of the code keeping only the URL of the video after i get the URL by it self then replace the http://www.youtube.com/ part of the URL with http://i2.ytimg.com/vi/ to do this i know that i need something like this to get the URL of the video http://www.youtube.com/((?:v|cp)/[A-Za-z0-9\-_=]+) but how to only return just the URL is something idk how to do then use str_replace http://www.youtube.com/(?:v|cp)/" with http://i2.ytimg.com/vi/ so in the end im asking if anyone know how to remove all other codes i dont want and only keep the URL this may have to be done using "regex" im not sure as i dont know to much about regex and what it can do but does sound like it would help lol i have to read a single line from a csv, its a really big file and i only need one column.
i need the response to be a string ,i made a search and found the following code but i dont have any idea how to get a single line from a single string per run .
<?php $row = 1; //open the file if (($handle = fopen("file.csv", "r")) !== FALSE) { while (($data = fgetcsv($handle, 0, ",")) !== FALSE) { $num = count($data); echo "<p> $num fields in line $row: <br /></p>\n"; $row++; for ($c=0; $c < $num; $c++) { echo $data[$c] . "<br />\n"; } } fclose($handle); } ?> Edited by bores_escalovsk, 16 May 2014 - 06:38 PM. |