Jump to content

bambinou1980

Members
  • Posts

    130
  • Joined

  • Last visited

Everything posted by bambinou1980

  1. Hello, I would like to understand a little bit more about CHMOD777 please as I looked online and some say it is fine while other are against having a folder with 777. Here is my problem. I have an sms printer which requires access to a folder on my website in order to download all the orders in txt format. All my orders are currently being appended to multiple .txt files in that specific folder which is in the public_html location, so if someone finds the folder he will be able to see all the orders in those .txt files. My question is: If my folder is CHMOD 777 could someone change the text content of my .txt file via the web, if yes how? I need to understand how this can happen in order to stop it, could you please tell me a little more about it and how can people hurt websites which have CHMOD777 on certain folders? Thank you,
  2. Hello, I have a question on the SELECT statements when you have 4 tables interconnected in this way: order <----where the data is the most important --id --grand_total --cust_name --cust_surname --cust_address order_items <--table --id --order_id --items_id --name --quantity --unit_price --total items <--table --id --name --price --description items_toppings<--table --id --order_id --order_items_id --items_id --topping_name --topping_price As you can see there are 4 tables which are related to each others. The most important table is the "order", the others should be pulled only if there is data linked. I would like to know how could I query the order table while pulling the order_items, items and items_toppings at the same time, would this works please? $sql = "SELECT o.id, o.grand_total, o.cust_name, o.cust_surname, o.cust_address, o_i.name, o_i.quantity, o_i.unit_price, o_i.total, i.name, i.price, i.description, i_t.topping_name, i_t,topping_price FROM order AS o LEFT JOIN order_items as o_i items as i items_toppings as i_t ON o.id = o_i.order_id o_i.items_id = i.id ORDER BY o.id DESC $limit"; Thank you for your help! Ben
  3. Hello, I have this code here: <div class="col-md-4 col-xs-12 col-sm-12 orderTypes"> <h3 ng-click="goToBusinessIndex();deliveryCondition=1" style="font-weight: 500;font-size: 2.8em" class="searchbychar"> <a href=""><div class="interested-in-font">TAKE-AWAY</div></a> <input type="radio" name="my-checkbox" checked> <!--<i ng-if="deliveryCondition==1" class="fa fa-check"></i>--> </h3> </div> And would like to trigger the same action using the radio button instead but it fails I tried this: <div class="col-md-4 col-xs-12 col-sm-12 orderTypes"> <h3 style="font-weight: 500;font-size: 2.8em" class="searchbychar"> <a href=""><div class="interested-in-font">TAKE-AWAY</div></a> <input ng-click="goToBusinessIndex();deliveryCondition=1" type="radio" name="my-checkbox" checked> <!--<i ng-if="deliveryCondition==1" class="fa fa-check"></i>--> </h3> </div> And that(ng-change) <div class="col-md-4 col-xs-12 col-sm-12 orderTypes"> <h3 style="font-weight: 500;font-size: 2.8em" class="searchbychar"> <a href=""><div class="interested-in-font">TAKE-AWAY</div></a> <input ng-change="goToBusinessIndex();deliveryCondition=1" type="radio" name="my-checkbox" checked> <!--<i ng-if="deliveryCondition==1" class="fa fa-check"></i>--> </h3> </div> Any why please? Thank you, Ben
  4. Hello, I am having a problem, I need 3 buttons like the 3 you see at the bottom left of this page: http://www.bootstrap-switch.org/examples.html My problem, is that I cannot work out how to only switch one button at the time: <input type="checkbox" name="my-checkbox" class="bootstrap-switch bootstrap-switch-wrapper bootstrap-switch-animate bootstrap-switch-on"> <input type="checkbox" name="my-checkbox" class="bootstrap-switch bootstrap-switch-wrapper bootstrap-switch-animate bootstrap-switch-on"> <input type="checkbox" name="my-checkbox" class="bootstrap-switch bootstrap-switch-wrapper bootstrap-switch-animate bootstrap-switch-off"> I tried this but it does not stop work: <script> $("[name='my-checkbox']").bootstrapSwitch(); $('input[name="my-checkbox"]').bootstrapSwitch('state', true, true); $('.bootstrap-switch-animate').on('switch-change', function () { $("[name='my-checkbox']").bootstrapSwitch('toggleState'); }); //or $('.bootstrap-switch-animate').on('switch-change', function () { $("[name='my-checkbox']").bootstrapSwitch('setState', false);; }); // or $('.bootstrap-switch-animate').on('switch-change', function () { $("[name='my-checkbox']").bootstrapSwitch('setState', false);; }); </script> What I am trying to achieve is to only have 1 buttons on while the other 2 turn off. Thank you, Ben
  5. Actually you are right, I just had to empty my cache for it to work. thank you. One quick question please, if the , FILE_APPEND function right because it is not creating any files on the server.
  6. Yes thanks I tried that already but it did not work.
  7. Hi, I am adding the whole code, I have not yet added any validations...but I cannot get anything passed in the var_dump, I must have a tiny error somewhere but cannot work it out.. At the moment I am just trying to get a print test of the printer, this is why I added some values manually to some of the variables. <?phpif(isset($_POST['submit'])){ $product1 = $_POST['product1']; //$product2 = $_POST['product2']; //$product3 = $_POST['product3']; //$product4 = $_POST['product4']; $quantity1 = $_POST['quantity1']; // $quantity2 = $_POST['quantity2']; // $quantity3 = $_POST['quantity3']; // $quantity4 = $_POST['quantity4']; $price1 = $_POST['price1']; //$price2 = $_POST['price2']; //$price3 = $_POST['price3']; // $price4 = $_POST['price4']; /*# Delivery;13:30;18-08-15;* //Date of the order 121345* //Order number 2;Chicken Tikka Massala;13.90;* //Food item 5.00* //Delivery Fees 18.90* //Total Price Freddy Crugger;Street 154 beach house palier, town1;555444;Hi, Could you please call me when you are near the phone box after frankie's club; //Customer Address 7;Cash on Delivery; //Type of delivery & Payment type # */ $item1 = $quantity1 . ";" . $product1 . ";" . $price1 . ";";//$item2 = $quantity2 . ";" . $product2 . ";" . $price2 . ";";//$item3 = $quantity3 . ";" . $product3 . ";" . $price3 . ";";//$item4 = $quantity4 . ";" . $product4 . ";" . $price4 . ";"; $start_of_order = "#";$type_of_order = "Delivery";$time = "13:30;";$date = "18-08-15;";$order_number = "121345*";$total_price = "18.90*";$delivery_fees = "5.00*";$Customer_surname = "Freddy;";$Customer_name = "Crugger;";$customer_address = "Street 154 beach house palier, town1;";$customer_phone = "88585898;";$comments = "Hi, Could you please call me when you are near the phone box after frankie's club;";$type_of_delivery = "7"; //Order not Paid. Use 6 for Paid$payment_type = "Cash on Delivery";$end_of_order = "#"; file_put_contents("order_test.txt", $start_of_order .$type_of_order .$time .$date .$order_number .$item1 .$total_price .$delivery_fees .$Customer_surname .$Customer_name .$customer_address .$customer_phone .$comments .$type_of_delivery .$payment_type .$end_of_order . "", FILE_APPEND); var_dump($_POST);} ?><!DOCTYPE HTML><html><head><meta http-equiv="content-type" content="text/html" /><meta name="author" content="lolkittens" /><!-- Latest compiled and minified CSS --><link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" /> <!-- Optional theme --><link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css" /> <!-- Latest compiled and minified JavaScript --><script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script><title>Test Form</title></head> <body><br /><br /><br /><br /><div class="row"><div class="col-md-2"></div> <div class="col-md-8"><form action="test.php" method="post" enctype="text/plain"> <div class="input-group"> <span class="input-group-addon" id="basic-addon1">Product 1</span> <input type="text" class="form-control" value="Tal Fenek Pizza" name="product1"/> <span class="input-group-addon" id="basic-addon1">Quantity 1</span> <input type="text" class="form-control" value="2" name="quantity1"/> <span class="input-group-addon" id="basic-addon1">Price 1</span> <input type="text" class="form-control" value="25.60" name="price1" /></div> <br /> <div class="input-group"> <span class="input-group-addon" id="basic-addon1">Product 2</span> <input type="text" class="form-control" value="Cappriciosa Pizza" name="product2"/> <span class="input-group-addon" id="basic-addon1">Quantity 2</span> <input type="text" class="form-control" value="3" name="quantity2"/> <span class="input-group-addon" id="basic-addon1">Price 2</span> <input type="text" class="form-control" value="35.60" name="price2" /></div> <br /><div class="input-group"> <span class="input-group-addon" id="basic-addon1">Product 3</span> <input type="text" class="form-control" value="Quatro Formaggi Pizza" name="product3"/> <span class="input-group-addon" id="basic-addon1">Quantity 3</span> <input type="text" class="form-control" value="5" name="quantity3"/> <span class="input-group-addon" id="basic-addon1">Price 3</span> <input type="text" class="form-control" value="45.60" name="price3" /></div> <br /> <div class="input-group"> <span class="input-group-addon" id="basic-addon1">Product 4</span> <input type="text" class="form-control" value="Chicken Tikka Massala" name="product4"/> <span class="input-group-addon" id="basic-addon1">Quantity 4</span> <input type="text" class="form-control" value="6" name="quantity4"/> <span class="input-group-addon" id="basic-addon1">Price 4</span> <input type="text" class="form-control" value="65.60" name="price4" /></div><br /><input type="submit" class="btn btn-primary btn-block" /> </form></div><div class="col-md-2"></div></div> </body></html>
  8. Hello, I am having a little problem and do not know where to start. I have a printer that requires the following type of data to be written to a txt file: # Delivery;13:30;18-08-15;* //Date of the order 121345* //Order number 2;Chicken Tikka Massala;13.90;* //Food item 5.00* //Delivery Fees 18.90* //Total Price Freddy Crugger;Street 154 beach house palier, town1;555444;Hi, Could you please call me when you are near the phone box after frankie's club;*//Customer Address 7;Cash on Delivery; //Type of delivery & Payment type # As you can see, each variable is delimited by an asterix *. The whole order is delimited by # The ; means that this fits on one line. Now here is my problem. Let's say I have this: $date_of_the_order $order_number $food_item $delivery_fees $total_price $customer_address $type-of-delivery $payment_type I have already the form, the form data from my $_POST is going into those variables, how can I add my variables in a way that it always creates the output in my txt file as: # Delivery;13:30;18-08-15;* //Date of the order 121345* //Order number 2;Chicken Tikka Massala;13.90;* //Food item 5.00* //Delivery Fees 18.90* //Total Price Freddy Crugger;Street 154 beach house palier, town1;555444;Hi, Could you please call me when you are near the phone box after frankie's club;*//Customer Address 7;Cash on Delivery; //Type of delivery & Payment type # Could you please give me a quick example? I looked for this: <?php $content = "foo"; file_put_contents("text_file.txt", $ip, FILE_APPEND); ?> Would the above function works, if yes, how to add multiple variables to it? Thank you so much! Ben
  9. Thank you so much for your fast reply. What about the cronjob path, sometime I see people adding -q or -php front of the path, what does this changes please, any idea? Thank you, Ben
  10. Hello, I would like to setup a cron job in my cpanel. This cron job is situated in: public_html/protected/commands/cron.php I do not want people to call this url from the web as it could hit the server ressources if started too often. Is there a way to set this cronjob in a way that it is only executable from the server itself and not from the web. Please tell me if I am wrong but what I did is set up the command as: /usr/bin/php -q /home/account_name/public_html/protected/commands/cron.php And set the cronjob.php file to 644. Is this right? Thank you. Ben
  11. Hello, I have started learning PHP and mysql only a little while ago, where I do find it difficult is when I develop locally mysql and wish to move my moficiations each time remotely. I tried mysql wrkbench but keep having errors on upload...tried everything but can't get the migrations to work when there are foregin keys . Do you know a free(or cheap) tool which could help me by comparing the local and remote mysql and create all the migration code for me so I can advance faster with less manual migrations errors. Thank you, Ben
  12. Hello, I have found this fantastic code here: http://www.funphp.com/?p=33#comment-62497 But I am wondering if all the functions are still working fine with the latest php version. Also I have 2 questions about this script: 1)I am not understanding the "$response='NEW:1", where does the "NEW:1" comes from, I have never seen that before. 2)If I wanted to change the function: $output = ereg_replace("[ \t\n\r]","",$input)."\0"; to preg_replace Would this works? $output = preg_replace("[ \t\n\r]","",$input)."\0"; Thank you Ben /*********function to check new order******************/ function get_new_order() { $con=mysql_connect(HOST, USERNAME, PASSWORD); mysql_select_db(DATABASE, $con); $sql="select OrderId from customer_order where order_Status='0' "; //0 for new order $query=mysql_query($sql,$con); if(mysql_num_rows( $query)&gt;0) { return true; } else return false; } /*************************************/ /********Socket Server*********************/ set_time_limit (0); // Set the ip and port we will listen on $address = '127.0.0.1'; $port = 6789; // Create a TCP Stream socket $sock = socket_create(AF_INET, SOCK_STREAM, 0); // 0 for SQL_TCP // Bind the socket to an address/port socket_bind($sock, 0, $port) or die('Could not bind to address'); //0 for localhost // Start listening for connections socket_listen($sock); //loop and listen while (true) { /* Accept incoming requests and handle them as child processes */ $client = socket_accept($sock); // Read the input from the client – 1024000 bytes $input = socket_read($client, 1024000); // Strip all white spaces from input $output = ereg_replace("[ \t\n\r]","",$input)."\0"; $message=explode('=',$output); if(count($message)==2) { if(get_new_order()) $response='NEW:1'; else $response='NEW:0'; } else $response='NEW:0'; // Display output back to client socket_write($client, $response); socket_close($client); } // Close the master sockets socket_close($sock);
  13. Interesting post but I still do not understand why would a hacker cross site script a graph data, what would be the point if the data is useless to use on another website?
  14. Thank you, yes you are right and I forgot about it.... I had to come back to google charts as I could not parse the output with the other libraries...I did not know it was so complicated to get those charts working properly..
  15. Hello, I currently have this code: <?php $query = "SELECT SUM(cust_order_total) AS label, due_date AS y FROM orders WHERE YEAR(due_date) = YEAR(CURDATE()) AND MONTH(due_date) = MONTH(CURDATE()) GROUP BY due_date ORDER BY label"; $rows = []; $result = mysqli_query($connection,$query); $rows = mysqli_fetch_all($result, MYSQLI_ASSOC); ?> The output in json format is: [{"label":"95.00","y":"2015-09-01"},{"label":"112.50","y":"2015-09-10"},{"label":"150.00","y":"2015-09-23"}] I am trying to get this data into a line chart from the Google chart API but I just cannot get it to work. There is an example in jsfiddle here: [https://jsfiddle.net/api/post/library/pure/][1] Here is what I tried(Which gives me a blank graph): <script type="text/javascript"> google.load('visualization', '1', {packages: ['corechart', 'line']}); google.setOnLoadCallback(drawBasic); function drawBasic() { var data = new google.visualization.DataTable(); data.addColumn('number', 'Sales'); data.addColumn('date', 'Time'); data.addRows(<?php echo json_encode($rows); ?>); var options = { hAxis: { title: 'Time' }, vAxis: { title: 'Popularity' } }; var chart = new google.visualization.LineChart(document.getElementById('chart_div')); chart.draw(data, options); } </script> <div id="chart_div"></div> I believe the problem comes from the way my json_encode formats the output, but how to change this to get it to work with the Google Chart API please? Thank you,
  16. Someone just gave me a beautiful solution in another forum: RewriteEngine On RewriteCond %{HTTPS} offRewriteCond %{THE_REQUEST} !/printing [NC]RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] RewriteCond %{HTTPS} onRewriteCond %{THE_REQUEST} /printing [NC]RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] By using this fantastic piece of code I can go on my website and have https all over but not in the folder /printing, just tired it and it works very well. Now it might sounds crazy to you but I have a good reason for this. I have multiple printers which are using 2g communications to communicate with my php order page and php callback page. The problem with those printers is that they do not work over https(got the message from the manufacturer today s I just could not get them to grab the files in https) and they have told me to force this specific url to http. Now security wise, there are no problem at all because this folder will not be accessible to users and will only be used for printer communications, no login there. Hope you understand now why I needed this so much.
  17. Hello, Could anyone tell me how I can force https on my whole website but not on a single folder or url. At the moment I have this code: RewriteEngine On RewriteCond %{HTTP_HOST} ^thatmysite\.com [NC] RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://thatmysite.com/$1 [R,L] But if I add this second code in the root htaccess to remove https from the /thatsite.com/printing folder, I get a redirect loop because I am forcing on the code http to https and not https to http... RewriteCond %{HTTP:X-Forwarded-SSL} !on RewriteCond %{REQUEST_URI} ^\/(printing) RewriteRule (.*) https://%{HTTP_HOST}/$1 [L,R=301] RewriteCond %{HTTP:X-Forwarded-SSL} =on RewriteCond %{REQUEST_URI} !^\/(printing) RewriteRule (.*) http://%{HTTP_HOST}/$1 [L,R=301] Do you know a way around this please? I have been looking all over the internet and cannot find a single good answer. Thank you, Ben
  18. Got it, thanks Barand. By the way I found another nice graph library that is quite pretty too: http://canvasjs.com/
  19. I got it now.....thank you. I understood the mysql code differently. I thought the WHERE YEAR(due_date) = YEAR(CURDATE()) AND MONTH(due_date) = MONTH(CURDATE()) Meant "where Year is the current year and month the current month With the above code I thought I could have seen all the results for this current year (2015) month by month with all the sales SUM() if all the days together for each month. But now with your last comment I have just understood that this code was used to output any results day by day of the current month and the current year. If this is the case, I find the mysql code very confusing to read for the dates. So the YEAR() and MONTH() functions in mysql always output the "current" Year and Month? What about outputting the current months with time span of a full current year?
  20. Thank you Barand, I was expecting your code to work but I am getting a blank array showing just " [] " : <?php $query = "SELECT SUM(cust_order_total) AS label, due_date AS y FROM orders WHERE YEAR(due_date) = YEAR(CURDATE()) AND MONTH(due_date) = MONTH(CURDATE()) GROUP BY due_date ORDER BY label"; $rows = []; $result = mysqli_query($connection,$query); $rows = mysqli_fetch_all($result, MYSQLI_ASSOC); echo json_encode($rows); ?>
  21. Hi Barand, Thank you for the reply. What I am trying to understand is the logic behind creating an array with aliases and without. I have created 2 queries below, the firslt one(with the aliases) does not work(no ouput) while the other works, could you please tell me why as I am really confused on this. <?php $query = "SELECT SUM(cust_order_total) AS daily_gross_sales, due_date AS day FROM orders WHERE YEAR(due_date) = YEAR(CURDATE()) AND MONTH(due_date) = MONTH(CURDATE()) GROUP BY due_date ORDER BY day"; $types = array(); $result = mysqli_query($connection,$query); while(($row = mysqli_fetch_assoc($result))) { $types[] = array('x' => $row['day'], 'y' => $row['daily_gross_sales']); } echo json_encode($types); ?> <?php $query = "SELECT * FROM orders GROUP BY due_date ORDER BY due_date"; $types = array(); $result = mysqli_query($connection,$query); while(($row = mysqli_fetch_assoc($result))) { $types[] = array('x' => $row['due_date'], 'y' => $row['cust_name']); } echo json_encode($types); ?> Thank you,
×
×
  • 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.