PHP - Capture Abandoned Carts For Guests And Unconfirmed Users Pro-grammatically?
In PrestaShop Is there a way to capture abandoned carts for guests and unconfirmed users programmatically?
Also is there a way to email alert to the customers and admin on each abandonedment. On a blog I found that with SQL this can be done. But don’t know the exact or simple way, Anybody can help.
Similar TutorialsI've seen countless forum software/cms which have such feature, I understand how they count the total users online (as theirs a row which says if a user is online or not (boolean), and then its all counted using mysql_num_rows() to get the total) However I don't get how they'd display the number of Guests? (as I don't think they'd log them woul'dnt that be messy/tedious?) I am trying to display current online registered users and online guests. A user is defined as online by the online column in the database. if set to 1 they are online, if set to 0 they are offline. so when a user logs in i set this column to 1 to show they are online. but when a user is inactive i set it to 0. i do this using: Code: [Select] if($user->last_active_time < time()-1800) { $link->query("UPDATE ".TBL_PREFIX."users SET u_online = 0 WHERE u_username = '".$user->user_name."'") or die(print_link_error()); } else { $link->query("UPDATE ".TBL_PREFIX."users SET u_online = 1 WHERE u_username = '".$user->user_name."'") or die(print_link_error()); } $user->last_active_time is set on every page load to the current time stamp(UNIX) however they are sometimes displayed as online or offline when they arent. Also for displaying guests i use: Code: [Select] $session_time = time()-300; $query = $link->query("SELECT g_ip FROM ".TBL_PREFIX."guests WHERE g_ip = '".$_SERVER['REMOTE_ADDR']."'") or die(print_link_error()); $num_rows = $query->rowCount(); if($num_rows == 0) { if(!$user->user_name) { $link->query("INSERT INTO ".TBL_PREFIX."guests (g_ip, g_time) VALUES ('".$_SERVER['REMOTE_ADDR']."', '".$config['time_now']."')") or die(print_link_error()); } } if the IP address of the current visitor is not in the database and they are not logged in then it adds their ip to the database. but sometimes more guests are displayed then there actually are(tested this on local server so i know how many are online). Are there any better ways i could be doing this? Hi there, i am working on a mobile site can u pls help me with a script which shows guests online on my site with their country flag next to its phone model Hello
I am trying to work out how many regular users I have to my site and how long those users tend to be users..
So, I have a table that logs every time a user visits my site and logs in, it stores the date / time as a unix timestamp and it logs their user id.
I started by getting the id's of any user who logs in more than 5 times in a specified period, but now I want to extend that...
SELECT userID as user, count(userID) as logins FROM login_history where timestamp > UNIX_TIMESTAMP('2014-06-01 00:00:00') and timestamp < UNIX_TIMESTAMP('2014-07-01 00:00:00') group by user having logins > 5; I just discovered that I have a major security flaw with my website. Anyone who logs in to the website can easily access other users information as well as delete and edit other users information just by changing the ID variable in the address bar. I have user ID Session started on these pages but still people can do anything they like with other users information just by editing the address bar. For example if your logged in in the address bar of www.mywebsite.com/delete_mystuff.php?id=5 and change the "5" say to a "9" then you will have access to user#9 information. Every important page that I have has this code: Code: [Select] session_start(); if (!isset($_SESSION['user_id'])) { // Start defining the URL. $url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']); // Check for a trailing slash. if ((substr($url, -1) == '/') OR (substr($url, -1) == '\\') ) { $url = substr ($url, 0, -1); // Chop off the slash. } // Add the page. $url .= '/index.php'; ob_end_clean(); // Delete the buffer. header("Location: $url"); exit(); // Quit the script. } else { //Else If Logged In Run The Script if((isset($_GET['id'])) && (is_numeric($_GET['id']))) { $id = (int) $_GET['id']; } elseif ((isset($_POST['id'])) && (is_numeric($_POST['id']))) { $id = (int) $_POST['id']; } else { echo ' No valid ID found, passed in url or form element'; exit(); } What am I doing wrong? Please help if you know how to correct this. Many thanks in advance. Hi everyone, thanks for reading. I have live HTTP headers installed on Firefox, hopefully some of you will be familiar with this addon. I would like to make a php script that is able to do what live http headers does, that is, I'd like to be able to give the script a URL and it will return all the headers. I know how to use CURLOPT_HEADER and CURLOPT_RETURNTRANSFER but this doesn't quite do what I'm looking for. For example if I go to : https://adwords.google.com/o/Targeting/Explorer?__c=1000000000&__u=1000000000&ideaRequestType=KEYWORD_STATS#search.none with Live HTTP Headers switched on I get the following data under the 'generators' tab GET /o/Targeting/Explorer?__c=1000000000&__u=1000000000&ideaRequestType=KEYWORD_STATS GET /cues/cues.js GET /ga.js GET /cues/cb?__u=1000000000&__c=1000000000&l=en_US&v=5E5BE5A3D9AD806BA7FF2C9FE2E15DF9&a=1000000000 GET /cues/metrics/?requestType=external&startTime=1287073462287&browserStartTime=1287073471028&browserEndTime=1287073472156 GET /cues/metrics/?requestType=notabs&startTime=1287073462287&browserStartTime=1287073471028&browserEndTime=1287073472162 GET /o/Targeting/clear.cache.gif GET /__utm.gif?utmwv=4.8.6&utmn=606563096&utmhn=adwords.google.com&utmcs=UTF-8&utmsr=1280x1024&utmsc=24-bit&utmul=en-gb&utmje=1&utmfl=10.1%20r85&utmdt=Google%20AdWords%3A%20Traffic%20Estimator&utmhid=1700273830&utmr=-&utmp=%2FAnonymous%2FTargetingExplorer%2FKeywordStats%3Fcontext%3DHistoryChange%26__c%3D1000000000%26__u%3D1000000000%26ideaRequestType%3DKEYWORD_STATS&utmac=UA-3418223-1&utmcc=__utma%3D229779660.119716289.1279381615.1286975241.1287071773.41%3B%2B__utmz%3D229779660.1279381615.1.1.utmcsr%3D(direct)%7Cutmccn%3D(direct)%7Cutmcmd%3D(none)%3B&utmu=q GET /o/Targeting/F098CA184E661C697D29595B67C57BAA.cache.png GET /favicon.ico POST /o/Targeting/captcha?__u=1000000000&__c=1000000000&challengedService=/o/Targeting/g 6|1|4|https://adwords.google.com/o/Targeting/|02990CDDCF521142AE1B373ED2008D94|_|getToken|1|2|3|4|0| GET /o/Targeting/captchaData?token=AJtyWwbzrehZWrT8puwruvcvjxCHnRJWKqWvpWfw54W2AjmF2cAlFpYLcL13KE0hi7retjZclcFHqnd8yMC0vDfP4tRNXISZ1QfbdLBK_WVW1wqlzqrR2ouSBgclxUiU0RiHUXHWy1VrIlo5oq3xNeemD-dZHQr0ed1s6p-dBF9mvyvkct1BifkXPAD___W32qxemYPbi6qvgpec3-rgsesGVUoYPglxzg&type=IMAGE GET /favicon.ico However my current CURL script only returns the following HTTP/1.1 200 OK Cache-Control: no-cache, no-store, max-age=0, must-revalidate Pragma: no-cache Expires: Fri, 01 Jan 1990 00:00:00 GMT Date: Thu, 14 Oct 2010 17:05:12 GMT Content-Type: text/html; charset=UTF-8 X-Invoke-Duration: 8 X-Content-Type-Options: nosniff X-Frame-Options: SAMEORIGIN X-XSS-Protection: 1; mode=block Server: GSE Transfer-Encoding: chunked This is my script so far <?php $url="https://adwords.google.com/o/Targeting/Explorer?__c=1000000000&__u=1000000000&ideaRequestType=KEYWORD_STATS#search.none"; $useragent="Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1"; //next open a new CURL session $ch = curl_init(); curl_setopt ($ch, CURLOPT_URL,$url); curl_setopt($ch, CURLOPT_USERAGENT, $useragent); curl_setopt ($ch, CURLOPT_HEADER, 1); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt ($ch, CURLOPT_FRESH_CONNECT, 0); curl_setopt ($ch, CURLOPT_CAINFO, dirname(__FILE__)."/cacert.pem"); $source=curl_exec($ch); //the source code is now stored in $source, lets close the curl session curl_close($ch); echo $source; ?> Greetings experts, Please forgive me for this cheap question. I have got a calendar of events and displays events for 7 departments. For each department, we would like the calendar to display events specific to that department. The way I am thinking about doing this is to grab the department from the url and compare it with the department on the db for which events is inserted into the db with. If there is a match, then display the events for that department. Something like: $tquery = "select * from ".$EVENTS_TB." where ".$EVENTS_TB.".month='".$smmonth."' and ".$EVENTS_TB.".year='".$smyear."' and ".$EVENTS_TB.".deptid='deptFromQueryString' " ; The problem that I have is that I don't in php, how to capture the querystring from url. For instance, assume this is the url: http://www.domain.com/departName. DeparmentName represents the department value. How do I capture the query above? Thanks so much. hi i am working on a php form where i need to get user signature and store in a db or as file, here is a link to an applet with perl but i am not sure about it. i need something like this http://www.lawrencegoetz.com/programs/signature/ Please can anyone tell if there is something related for php. thanks for any suggestion. I'm wondering how I can use the following code to capture the current url...... Code: [Select] <?php function curPageURL() { $pageURL = 'http'; if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";} $pageURL .= "://"; if ($_SERVER["SERVER_PORT"] != "80") { $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]; } else { $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; } return $pageURL; } ?> <?php echo curPageURL(); ?> and then have the output modified to change the domain name and create a link. Example: before - http://website1.com/page after - http://website2.com/page I think this would be done using function modify_url, but I'm not sure how to do it, any help would be greatly appreciated. Thanks I need assistance with a few things with my coding. 1. where I grab the filename content...$filename = file_get_contents($_FILES['uploadedfile']['name']); will that work since I already moved the file to the /temp/files/? if not how would i say look in that folder? 2. two upload happen with my script one is for the .csv file and the other are the docx files. what I need help with is to capture the filenames from the flash part so i can upload them to /temp/files 3. as you can see i'm trying to use this as a php_self so how would i go about removing the upload.php in the upload_url for the flash? do I just put the name of the page or php_self code? Code: [Select] <?php if(isset($_POST['submit'])) { // check .csv file has been uploaded... and on the server proceed if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], '../temp/files/')) { $filename = file_get_contents($_FILES['uploadedfile']['name']); //*** process flash upload save files to /temp/files/ should go here $handle = fopen("$filename", "r"); while (($data = fgetcsv($handle, 100000, ",")) !== FALSE) { if(file_exists('/temp/files/'. $data[0] .'.docx')) { $import="INSERT into kmmb_member1(docx_id,no_ahli,no_pin,nama,no_ic_baru,no_ic_lama) values('$data[0]','$data[1]','$data[2]','$data[3]','$data[4]')"; mysql_query($import) or die(mysql_error()); //*** after insert move file rename('/temp/files/'. $data[0] .'.docx', '/docx_files/'. $data[0] .'.docx'); } } fclose($handle); print "Import done"; } else { echo "There was an error uploading the *.csv file, please try again!"; } } else { ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title></title> <link href="swf_up/css/default.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="swf_up/swfupload/swfupload.js"></script> <script type="text/javascript" src="swf_up/swfupload/swfupload.queue.js"></script> <script type="text/javascript" src="swf_up/js/fileprogress.js"></script> <script type="text/javascript" src="swf_up/js/handlers.js"></script> <script type="text/javascript"> var swfu; SWFUpload.onload = function () { var settings = { flash_url : "swf_up/swfupload/swfupload.swf", flash9_url : "swf_up/swfupload/swfupload_fp9.swf", upload_url: "swf_up/upload.php", post_params: { "PHPSESSID" : "NONE", "HELLO-WORLD" : "Here I Am", ".what" : "OKAY" }, file_size_limit : "100 MB", file_types : "*.*", file_types_description : "All Files", file_upload_limit : 100, file_queue_limit : 0, custom_settings : { progressTarget : "fsUploadProgress", cancelButtonId : "btnCancel" }, debug: false, // Button Settings button_image_url : "swf_up/XPButtonUploadText_61x22.png", button_placeholder_id : "spanButtonPlaceholder", button_width: 61, button_height: 22, // The event handler functions are defined in handlers.js swfupload_preload_handler : swfUploadPreLoad, swfupload_load_failed_handler : swfUploadLoadFailed, swfupload_loaded_handler : swfUploadLoaded, file_queued_handler : fileQueued, file_queue_error_handler : fileQueueError, file_dialog_complete_handler : fileDialogComplete, upload_start_handler : uploadStart, upload_progress_handler : uploadProgress, upload_error_handler : uploadError, upload_success_handler : uploadSuccess, upload_complete_handler : uploadComplete, queue_complete_handler : queueComplete // Queue plugin event }; swfu = new SWFUpload(settings); } </script> </head> <body> <div id="content"> <h2>Upload</h2> <form id="form1" action="index.php" method="post" enctype="multipart/form-data"> <div id="divSWFUploadUI" style="margin-top: 20px;"> <span>Select .csv file: <input name='uploadedfile' type='file' /><br /> </span> <div class="fieldset flash" id="fsUploadProgress"> <span class="legend">Upload Queue</span> </div> <p id="divStatus">0 Files Uploaded</p> <p> <span id="spanButtonPlaceholder"></span> <input id="btnCancel" type="button" value="Cancel All Uploads" disabled="disabled" style="margin-left: 2px; height: 22px; font-size: 8pt;" /> <br /> </p> </div> <!-- --> </form> </div> </body> </html> <?php } ?> Ok, I'm trying to play with custom error handeling, and not getting anywhere. I have some code I made up just to mess about and get a feel for this, but no matter what I try I get nothing thrown out and no error caught. I did have it all in the one class, but got strongly advised that was a bad bad bad thing to do, so in an effort to keep the focus on the actual problem I've moved it off into it's own class. Here's the code, it's self contained (as I said its only a play around) but I would really appreciate it if someone could explain why the errors arn't being caught: <?php //------------------------------------------------ class dbc { public $server; public $host; public $db; public $user; public $pass; public function set($var, $val=0){ try{ if(is_array($var)){ foreach ($var as $k => $v) { if(!$this->$k = $v){ throw new Exception('Error Setting Database Information :'); } } } else{ if(!$this->$var = $val){ throw new Exception('Error Setting Database Information :'); } } } catch(Exception $e){ $setError = array('1', 'set', $e->getMessage()); $error->ErrorHandle($setError); } } } //------------------------------------------------ class errorCatch{ public $severity; public $methodCall; public $message; public function ErrorHandle($error){ $this->severity = $error['0']; $this->methodCalled = $error['1']; $this->message = $error['2']; if ($this->severity == 1){ die ("Critical error in call to dbo->$methodCall: $message"); } die("Warning Call to $methodCall resulted in a non fatal error: $message"); } } //------------------------------------------------ $error = new errorCatch; $con = new dbc; $set = array('hst'=>'localhost', 'svr'=>'mysql'); $con -> set($set); var_dump($error); ?> How do i capture and get the xml data send by other page to my php page? Let say my page is mypage.php. I send some parameters to otherpage.php. otherpage.php send xml data (eg. delivery status) to mypage.php. On the browser itself i still on mypage.php. otherpage.php does not send data in parameter value.. that where i feel lost. Please help.. Greetings, Hi, I am making login page with database and php. I need to be able when the person clicks theogin button to take photo of the person and add it to that same database based on the info entered.
I am doing this to know if that person that logged in is the person in reality.
Is it possible I have a page (input.php) that will allow a user to upload a CSV file. This file has 5 columns (SKU, Product, Quantity, Retail Price, and Total Retail Price). The CSV upload will only have the SKU number and Quantity filled in. When the user hit upload the (import.php) page is suppose to go to the site and pull the product up by searching the SKU number and pulling the price and product (brand and title). I paid a freelancer to create this code. I watched it work on his machine. I cant seem to get it to work on mine (wont pull price or product) and he is non-responsive now. Any help would be greatly appreciated!! I added some note in the code as I was troubleshooting.
<?php ini_set('max_execution_time', 0); error_reporting(0); move_uploaded_file($_FILES["file"]["tmp_name"], "upload/". $_FILES["file"]["name"]); $handle = fopen("upload/". $_FILES["file"]["name"], "r"); $file = ''; $line .= "SKU,Product,Quantity,Retail Price,Total Retail Price"; $file .= $line . PHP_EOL; for ($i = 0; $row = fgetcsv($handle ); ++$i) { // Do something will $row array if($row[0]!="" AND $i>0) { $line=""; #echo "<pre>"; #print_r($row); $SKU=$row[0]; $quantity=$row[2]; $loop=1; do{ $url = "https://www.homedepot.com/s/".$SKU; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HEADER, 1); $response = curl_exec($ch); $header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE); $headers = substr($response, 0, $header_size); $body = substr($response, $header_size); curl_close($ch); header("Content-Type:text/plain; charset=UTF-8"); $headers_arr = explode("\r\n", $headers); $str=$headers_arr[5]; $arr=explode(":",$str); $check=trim($arr[0]); #echo $check; ### remove troubleshooting if($check=="location") # made lowercase so it would get inside the If statement { #echo "Dustin"; ## remove troubleshooting $productPageLink=$headers_arr[5]; $productPageLink=str_replace("Location:","",$productPageLink); #echo $productPageLink; ## troubleshooting -- seems to be getting the links $productPageLink=trim($productPageLink); $productPageLink=str_replace("http:","https:",$productPageLink); #echo $productPageLink; ## troubleshooting -- still seems to have links $ch = curl_init(); #echo $ch; ##troubleshooting -- prints out "resouce id" curl_setopt($ch, CURLOPT_URL, $productPageLink); #echo $ch; ##troubleshooting -- prints out "resouce id" curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET'); curl_setopt($ch, CURLOPT_ENCODING, 'gzip, deflate'); $headers = array(); $headers[] = 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:70.0) Gecko/20100101 Firefox/70.0'; $headers[] = 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'; $headers[] = 'Accept-Language: en-US,en;q=0.5'; $headers[] = 'Upgrade-Insecure-Requests: 1'; $headers[] = 'Connection: keep-alive'; $headers[] = 'Te: Trailers'; #echo $headers; ##troubleshooting -- ## Troubleshooting -- prints out "Array" curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); $result = curl_exec($ch); #echo $result; ### troubleshooting - doesnt have any data if (curl_errno($ch)) { echo 'Error:' . curl_error($ch); # it end inside this if statement, however no error is printed } curl_close($ch); preg_match_all('/<h2 class="product-title__brand" itemprop="brand" data-component="clickable brand link">(.*?)<\/h2>/s', $result, $output_array_brand); #echo "<pre>"; ### #print_r($output_array_brand);#### $brand=trim(strip_tags($output_array_brand[1][0])); preg_match_all('/<h1 class="product-title__title">(.*)<\/h1>/', $result, $output_array); $productTitle=$output_array[1][0]; $productTitle=$brand." ".$productTitle; preg_match_all('/<span class="price__dollars">(.*?)<\/span>/s', $result, $output_array_price); preg_match_all('/<span class="price__cents">(.*)<\/span>/', $result, $output_array_cent); #echo "<pre>"; #print_r($output_array_price); $price=trim(strip_tags($output_array_price[1][0])); $cent=trim(strip_tags($output_array_cent[1][0])); if($cent!="" OR $cent!=0) { $price=$price.".".$cent; } $line.=$row[0].","; $line.='"'.$productTitle.'",'; $line.=$row[2].","; $line.=$price.","; $totalPrice=$row[2]*$price; $line.=$totalPrice; $file .= $line . PHP_EOL; } # echo "<br>"; $loop=$loop+1; #echo "<br>"; if($loop>4) { if($check!="Location") { $line.=$row[0].","; $line.=','; $line.=$row[2].","; $line.=","; $line.=""; $file .= $line . PHP_EOL; break; } } } while($check!="Location"); } } fclose($handle); header('Content-Type: application/csv'); $output=$_REQUEST['output']; header('Content-disposition: attachment; filename='.$output.'.csv'); echo $file; #header('Content-disposition: attachment; filename='.$output.'1.csv'); #echo $file1; exit; ?>
1- Write a PHP program that goes through all integers between 1 and 100 (excluding 1 and 0) and displays each even number on a separate line. 2- Re-write the program in question 1 but this time use a function to go through the numbers and display them. I have the following. How can I do the other one? <?php for ($i = 2; $i <= 100; $i++) { if ($i % 2 == 0){ print $i . " <Br> "; } } ?> I wrote a VB6 app that uses a web browser control to create an inbuilt instance of IE. I then used that to navigate to a LOC web page, do a search and collect MARC tag data. I was wondering how you could do this in PHP.? I put up some attachments that show this working in VB6. The searchable web page that returns results is here http://www.loc.gov/cgi-bin/zgate?ACTION=INIT&FORM_HOST_PORT=/prod/www/data/z3950/locils2.html,z3950.loc.gov,7090 So you do a search for something. LOC gives you a list. You click on an item in the list where it says 'more on this record' then you click 'tagged display' And that is the data you want to have collected into your variable. I created a Download Icon on the web browser control that turns green when the data is displayed. Do you somehow create your own web browser instance? or? I am new to PHP and have figured out a few things. I created this here in PHP http://www.sdowney717.byethost16.com/mysearch2first.php Hi there, I am trying to edit my shopping cart page so that i can use a different shipping rate for each country that i ship to. At the minute this is the code i use: */ if(isset($_GET['eushipping'])||(isset($_POST['rec_country'])&&$_POST['rec_country']!='uk')){ $shipping = ceil($total/30.00)*20.00; } I though it if i just changed the value 'eushipping' to the country option value it would work but it doesn't. Can anyone point me in the write direction of what i need to change? Many thanks. Hash Hi All
I am hoping someone can help.
I am trying to create a session based on when the users first enters the page. This will capture the timestamp and retain that as the starting point for the countdown so even if the user goes away from the page and comes back, the timestamp does not reinstantiate itself.
Can anyone give me some guidance please?
I'd like to capture the text of a PHP warning. This is an internal process, no one will ever visit these php pages, so I want to send myself an email if the process fails. Right now, as part of debugging this, I am forcing failures and echoing the content of my email to the page. The first test is to use the wrong password. The following message is put on the page (broken into 3 sections for discussion purposes). A) Warning: mysql_connect() [function.mysql-connect]: B) Access denied for user 'xxx'@'localhost' (using password: YES) C) in E:\php\www\folder\DatabaseConnectionInfo.php on line 8 mysql_error() gives me part B. Access denied for user 'xxx'@'localhost' (using password: YES) How can I get parts A and C ? |