Jump to content

eddcaton

Members
  • Posts

    30
  • Joined

  • Last visited

Everything posted by eddcaton

  1. Sorry to be so vague in my previous message. So I spoke with one user today who is using Chrome (which I use) and they said the cannot login. Just nothing happens when the form is submitted. I personally think its people that are struggling this 'new technology'. I have added an auto login after the user has registered, to ensure that they are getting into the 'login area'. Which then will update the 'last_logged_in' field in MYSL. When looking at MYSL it does not show that the 'last_logged_in' has been updated. So it tends to suggest that the users are having some issue somewhere, but I am unsure where! Hope that makes sense.
  2. Hey All, I am after some advice on a recent project I am working on. I have a User system that uses Session for logging in. I have it working fine and tested it on IE, Edge, Chrome & Safari. However I have some users (like 10%) that are having issues logging into the system. With the others having no issues at all. Is there anything i should take a look at? Edd
  3. global $wpdb; //// Look at custom current plugin to change below//////// global $wp_query; if (isset($wp_query->query_vars['page_no'])) { print $wp_query->query_vars['page_no']; } ///////////////////////////////////////////////////////// ///////////////////// DO API REQUEST ///////////////////// $per_page = 10; $page = $wp_query->query_vars['page_no']; $url = 'https://api.com/api/v1/products?page='.$page.'&per_page='.$per_page.'q[allowed_stock_type_eq]=1'; $ch = curl_init($url); $customHeaders = array( 'X-SUBDOMAIN:domain', 'X-AUTH-TOKEN:Token' ); curl_setopt($ch, CURLOPT_HTTPHEADER, $customHeaders); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); $result = curl_exec($ch); curl_close($ch); $phpObj = json_decode($result, true); if (!empty($phpObj)) { foreach($phpObj as $x=>$x_value) { foreach ($x_value as $y=> $y_value) { if ($y_value['allowed_stock_type']=='1') { $product_search_id = $y_value['id']; $product_name = $y_value['name']; $product_description = $y_value['description']; $product_image = $y_value['icon']['url']; $product_group = $y_value['product_group']['name']; $product_type = $y_value['allowed_stock_type_name']; $product_weight = $y_value['weight']; $product_price = $y_value['rental_rate']['price']; ///////////////////// SEE IF PRODUCT ID IS IN THE POST META TABLE ///////////////////// $post_exists = $wpdb->get_var("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = 'product_id' AND meta_value = '".$product_search_id."'"); if ($post_exists) { $queried_post = get_post($post_exists); $db_product_name = $queried_post->post_title; $db_product_description = $queried_post->post_content; if(!$y_value['active']) { wp_delete_post( $post_exists); echo("Removing Post"); echo($product_name); } else { $post_meta = get_post_meta( $post_exists ); // array of all meta fields if($product_name != $db_product_name) /// Name { $my_post = array( 'ID' => $post_exists, 'post_title' => $product_name); wp_update_post( $my_post ); } if($product_description != $db_product_description) /// Description { $my_post = array( 'ID' => $post_exists, 'post_content' => $product_description); wp_update_post( $my_post ); } if($product_image != $post_meta['_imageUrl'][0]) /// Image { update_post_meta($post_exists,'_imageUrl',$product_image); } if($product_weight != $post_meta['product_weight'][0]) /// Weight { update_post_meta($post_exists,'product_weight',$product_weight); } if($product_price != $post_meta['product_price'][0]) /// Price { update_post_meta($post_exists,'product_price',$product_price); } $terms = get_the_terms($post_exists,'item_category'); // See if product category matches foreach ( $terms as $term ) { if ($product_group != html_entity_decode($term->name)) { wp_set_object_terms($post_exists, $product_group, 'item_category'); } } if($product_image != $post_meta['_imageUrl'][0]) { update_post_meta($post_exists,'_imageUrl', $product_image); Generate_Featured_Image($product_image, $post_exists); //update_post_meta(get_the_ID(),'product_img_upload','yes'); } echo ("<br />"); echo "Tile : ".$db_product_name.""; echo ("<br />"); echo "Product ID : ".$post_meta['product_id'][0].""; echo ("<br />"); echo "Weight : ".$post_meta['product_weight'][0].""; echo ("<br />"); echo "Price : ".$post_meta['product_price'][0].""; echo ("<br />"); echo "Image URL : ".$post_meta['_imageUrl'][0].""; echo ("<br />"); echo "Description : ".$db_product_description.""; echo ("<br />"); echo "Total Data : ".$post_meta['product_total_data'][0].""; echo ("<br />"); } } else { if(!$y_value['active']) { //Add new post $my_post = array( 'post_title' => wp_strip_all_tags($product_name), 'post_content' => '', 'post_status' => 'publish', 'post_author' => 1, 'post_type' => 'item', ); $post_id=wp_insert_post( $my_post ); if($post_id) { update_post_meta($post_id, 'product_id', $product_search_id); update_post_meta($post_id, 'product_weight', $product_weight); update_post_meta($post_id, 'product_price', $product_price); update_post_meta($post_id, 'product_total_data', ''); update_post_meta( $post_id, '_imageUrl',$product_img); } update_option('current_exists_value', get_option( 'current_exists_value' ).','.$product_search_id); } } } } } $next_page = ++$page; echo "<meta http-equiv='refresh' content='10;url=?page_no=".$next_page."'>"; /////////////////////////////////////////////////////////////////////////////////// }
  4. Yes, i have the code working, but am unsure as to how i loop through the API request pages?
  5. Brilliant, Thanks for the advice. But how do i go about turning my script that works with meta refresh, to one that will work with cronjobs?
  6. I would think that we can have automated updates weekly. Then if i do any large changes i can run the code manually.
  7. To be honest it could loop through every week or so. Basically i use a web based rental system to keep track of hires and inventory which i am using to update a wordpress website with the hire products details so that customers can see it from the website. The hire products can have their details updated every few weeks, by multiple users who inherently don't tell me if they update things, hence an automatic update. I have the update process working through a wordpress template which i am just manually accessing at the moment.
  8. Hey All, I am using a Curl script to call item details from an API and then updating mysql with the results. But the API is limited to 100 requests per 60 seconds. So I am currently just using: $page = $_GET["page"]; $next_page = ++$page; echo "<meta http-equiv='refresh' content='60;url=?page=".$next_page."'>"; This runs until the results from the API runs out, then resets the page number to 1 and loops through again. My question is, will this would the same with a CRON job?
  9. Thanks for the reply, do you know if i can send this custom data with the PayPal SDK?
  10. Hey All, I have setup a Paypal API to handle the recurring payments on my website, once the payment is completed I get a token id and ba_token id return. I am storing this in a database, but wondered how people link this with a user table? I could use a cookie to store the user's id before payment and then get it once the payment is complete, but this would not work with the subsequent recurring payments. How do you go about sending the user id when a recurring payment happens? Any advise would be appreciated. Edd
  11. I have managed to get a little further with this. Could anyone advise how to get the filenames back to my form.php file: This is my upload.php file that my form.php sends the drop zone upload request. <?php /** * Dropzone PHP file upload/delete */ // Check if the request is for deleting or uploading $delete_file = 0; if(isset($_POST['delete_file'])){ $delete_file = $_POST['delete_file']; } $targetPath = dirname( __FILE__ ) . '/user_uploads/item/'; // Check if it's an upload or delete and if there is a file in the form if ( !empty($_FILES) && $delete_file == 0 ) { // Check if the upload folder is exists if ( file_exists($targetPath) && is_dir($targetPath) ) { // Check if we can write in the target directory if ( is_writable($targetPath) ) { /* create new name file */ $source = $_FILES["file"]["tmp_name"]; $destination = "../img/imageDirectory/{$basename}"; /** * Start dancing */ $filename = uniqid() . "-" . time(); // 5dab1961e93a7-1571494241 $extension = pathinfo( $_FILES["file"]["name"], PATHINFO_EXTENSION ); // jpg $basename = $filename . "." . $extension; // 5dab1961e93a7_1571494241.jpg $tempFile = $_FILES['file']['tmp_name']; $targetFile = $targetPath . $basename; // Check if there is any file with the same name if ( !file_exists($targetFile) ) { move_uploaded_file($tempFile, $targetFile); // Be sure that the file has been uploaded if ( file_exists($targetFile) ) { $response = array ( 'status' => 'success', 'file_link' => $targetFile ); } else { $response = array ( 'status' => 'error', 'info' => 'Couldn\'t upload the requested file :(, a mysterious error happend.' ); } } else { // A file with the same name is already here $response = array ( 'status' => 'error', 'info' => 'A file with the same name is exists.', 'file_link' => $targetFile ); } } else { $response = array ( 'status' => 'error', 'info' => 'The specified folder for upload isn\'t writeable.' ); } } else { $response = array ( 'status' => 'error', 'info' => 'No folder to upload to :(, Please create one.' ); } // Return the response echo json_encode($response); exit; } // Remove file if( $delete_file == 1 ){ $file_path = $_POST['target_file']; // Check if file is exists if ( file_exists($file_path) ) { // Delete the file unlink($file_path); // Be sure we deleted the file if ( !file_exists($file_path) ) { $response = array ( 'status' => 'success', 'info' => 'Successfully Deleted.' ); } else { // Check the directory's permissions $response = array ( 'status' => 'error', 'info' => 'We screwed up, the file can\'t be deleted.' ); } } else { // Something weird happend and we lost the file $response = array ( 'status' => 'error', 'info' => 'Couldn\'t find the requested file :(' ); } // Return the response echo json_encode($response); exit; } ?> I have seen that some people user something like this on the form.php file: onyxDropzone.on("success", function(file, response) { let parsedResponse = JSON.parse(response); file.upload_ticket = parsedResponse.file_link; But unfortunetly my understanding on JAVA is very limited. Basically I want to get all the filenames of the files that have been updated in the drop zone and then save them as a php variable which then i can insert into MYSQL when the form is submitted.
  12. I am after some guideance / best practices for dropzone.js inside a text form. I have a form that is used to create listings on a website and it has text fields and a dropzone.js file uploader in it. But on submit of the completed form, i would like it to upload the files and submit the text fields to mysql. The upload files part is working and also the mysql part working but I cannot work out how to make the relationship between the listing and the images that are attributed to the listing, which are stored in different tables. At the point of submission the user is not logged in, so i cannot use that to assist with telling mysql where the image is attributed to.. I have looked into submitting the text form first then redirecting to the upload section but it really isn't what I want for the form. It would be nice that the user can submit all the information for that listing in one form. Now i am sure that there is a really simple way to achieve this but i am running round and round in circles on this one.
  13. Thanks for all the help and assistance on this really annoying issue. I have now found the error in the code. When coding in Sublime everything looks fine and no issues. When i took a look at the file directly from Cpanel there was a single . before <?php which threw the whole lot off. I have removed the dot from the cpanel view and it works perfectly now.
  14. Thanks for the info. 1. Shows up an error on the working and not working file Warning: Cannot modify header information - headers already sent by (output started at /homepages/41/d553935649/htdocs/edd/login.php:1) in /homepages/41/d553935649/htdocs/edd/login.php on line 47 Warning: Cannot modify header information - headers already sent by (output started at /homepages/41/d553935649/htdocs/edd/login.php:1) in /homepages/41/d553935649/htdocs/edd/login.php on line 48 line 1: <?php line 47: setcookie("login_id", $randomNumber, time()+86400); line 48: header("location:index.php"); 2. Amended 3. Yes the db_const.php is in the same directory as the login.php file 4. The form is in the same file as the php action with a if(isset($_POST["login"])) before the posting and setting of the cookie 5. Shows the email and login that was input into the login form and the errors mentions in #1
  15. Thanks. I will take a look at changing the PHP settings. Do you think this might influence the cookie setting?
  16. Hey, error_reporting is set to 22517 and display_errors is set to on
  17. if(password_verify($_POST["user_password"], $row["user_password"])) //// Check PHP HASH ///////////// { $randomNumber = rand(); $user_id = "$row[user_id]"; setcookie("login_id", $randomNumber, time()+86400); $sql2 = "UPDATE user_details SET login_id=$randomNumber WHERE user_id='$user_id'"; if ($mysqli->query($sql2) === TRUE) { } header("location:index.php"); exit(); MYSQL submits fine and the table is updated fine when the login form is completed. What i cant understand is that i have it working 100% in a un stylised php file. As soon as i copy to a stylised design it doesn't work...
  18. Once a submission is made from the un stylised login from it displays: Array { [login_id] => 1681386050 } The cookie is populated with a random number that is sent to the DB when the user submits the login form. Then later on in other pages I check the cookie against the DB to then get the users info. I added the random number in after @mac_gyver mentioned about the security issue of setting the cookie with the users actual id.
  19. I will take a look at the PHP info and see what i have listed. I just cant help thinking there is something throwing the cookie off from being set properly
  20. Thanks for the info. I have done some more searching of google and found how to see cookies that are set from a website in google chrome. When I submit the login form from the troublesome page. I checked the cookies and it has set a cookie with the description of "Database Storage" and the flie is 2,315 B in size. It looks like somewhere along the line i am submitting something other than the login_id that i am trying to set. Here is the part of the code that handles my cookie setting etc. <?php //login.php include 'db_const.php'; //if(isset($_COOKIE["login_id"])) //{ // header("location:index.php"); // exit(); //} $message = ''; if(isset($_POST["login"])) { if(empty($_POST["user_email"]) || empty($_POST["user_password"])) { $message = "<div class='alert alert-danger'>Both Fields are required</div>"; } else { $query = " SELECT * FROM user_details WHERE user_email = :user_email"; $statement = $connect->prepare($query); $statement->execute( array( 'user_email' => $_POST["user_email"] ) ); $count = $statement->rowCount(); if($count > 0) { $result = $statement->fetchAll(); foreach($result as $row) { if(password_verify($_POST["user_password"], $row["user_password"])) //// Check PHP HASH ///////////// { $randomNumber = rand(); $user_id = "$row[user_id]"; setcookie("login_id", $randomNumber, time()+86400); $sql2 = "UPDATE user_details SET login_id=$randomNumber WHERE user_id='$user_id'"; if ($mysqli->query($sql2) === TRUE) { } header("location:index.php"); exit(); } else { $message = '<div class="alert alert-danger">Wrong Password</div>'; } } } else { $message = "<div class='alert alert-danger'>Wrong Email Address</div>"; } } } ?> <html> <head>
  21. Hey, This is what i get when i submit the login form: Array ( ) When i say "blank" file. I mean a file with just the code in for the form. Nothing fancy and no real CSS styling.
  22. Any further ideas why the cookies are being set in a "blank" file and not in a stylised file?
  23. Thanks for the info. 1. So if i generated a random code submitted to MYSQL every time the login form is submitted, then save that to the cookie. When i am then trying to get the users info then i check MYSQL for the random code that matches the cookie info? 2. Sorry for my lack of knowledge on this. I am unsure where the exits need to be placed 3. I should change the fetch argument to: $random_id = $_COOKIE["random_id"]; /// not the user_id but a random code generate on login. $sql = "SELECT * FROM user_deatils WHERE random_id LIKE ".$random_id.""; $result = $mysqli->query($sql); if ($result->num_rows > 0) { while($row = $result->fetch_assoc()) { 4. I thought the code needed to be before any HTML to set the cookie.
  24. Hey, I started this using sessions and had the same outcome with the session not being saved/created upon login submit. I checked the PHP info for the web server and all the session details seemed to be correct and active, but still couldn't get it to work. I only swapped to Cookies as i seemed to have more success this them.
  25. I see.. This is the top of the Code i am using: <?php include 'db_const.php'; if(isset($_COOKIE["id"])) { header("location:index.php"); } $message = ''; if(isset($_POST["login"])) { if(empty($_POST["user_email"]) || empty($_POST["user_password"])) { $message = "<div class='alert alert-danger'>Both Fields are required</div>"; } else { $query = " SELECT * FROM user_details WHERE user_email = :user_email"; $statement = $connect->prepare($query); $statement->execute( array( 'user_email' => $_POST["user_email"] ) ); $count = $statement->rowCount(); if($count > 0) { $result = $statement->fetchAll(); foreach($result as $row) { if(password_verify($_POST["user_password"], $row["user_password"])) //// Check PHP HASH ///////////// { setcookie("user_id", $row["user_id"], time()+86400); header("location:index.php"); } else { $message = '<div class="alert alert-danger">Wrong Password</div>'; } } } else { $message = "<div class='alert alert-danger'>Wrong Email Address</div>"; } } } ?> <!DOCTYPE html> <html lang="en"> <head>
×
×
  • 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.