Jump to content

qwertyjjj

Members
  • Posts

    7
  • Joined

  • Last visited

Everything posted by qwertyjjj

  1. I need to transfer some files from one server to a folder on a nother server but I do not have access to sftp and this needs to be done programatically and securely. What would be the best way to do it? Using a web service in the target server or using curl to transfer the file via SSL?
  2. I have data as below. I can't do this check in the SQL because my server is still on v 4 so I have to do it in PHP code. If there is a blank line linked to an order ID but that orderID also has a PayPal entry then it's ok, I want to delete it from the array. However, if it hast an OrderID and everything is blank, then I want to echo it. In the example below: 9500 is incorrect 9503 only has 1 row but is ok the rest may have 2 or more rows but as long as 1 row has PayPal in it, then it is ok. How can I loop through an array but then delete everything from the array with that ID, and then carry on looping through the array again? 9511 3 PayPal IPN Verified [Completed (Verified; £24.99)] 9511 3 9508 3 PayPal IPN Verified [Completed (Unverified; £3.99)] 9508 3 9507 3 PayPal IPN Verified [Completed (Unverified; £1.99)] 9507 3 9506 3 PayPal IPN Verified [Completed (Verified; £9.49)] 9505 3 PayPal IPN Verified [Completed (Verified; £9.49)] 9505 3 9504 3 PayPal IPN Verified [Completed (Verified; £7.99)] 9504 3 9503 3 PayPal IPN Verified [Completed (Unverified; £7.99)] 9502 3 PayPal IPN Verified [Completed (Verified; £1.99)] 9502 3 9501 3 PayPal IPN Verified [Completed (Unverified; £7.99)] 9500 3 PayPal IPN Verified [Completed (Verified; £9.49)] 9500 3
  3. I would like to start learning codeigniter and also an IDE like Ntebeans. I have an OSCommerce site that I need to work on. Is there a way to install CI and also edit all the code on the site using Netbeans without messing up the existing PHP code?
  4. How big the PHP script file is does not really make much of any difference on execution time. Obviously if it is generating a lot of output though, the end user has to download all that which depending on connection speed can take a while. One way to help speed that up is to compress the output before sending it to the client. Most browsers these days support gzip compression. The data is sent from the server in a compressed format using the gzip algorithm and then the browser will automatically decompress it on it's end before displaying it to the user. Compression works well on text, especially text that is repetitive so applying to HTML, JS, or CSS can reduce the amount of data being transferred significantly. As for how to do this there are a few different ways. Apache has an extension called mod_gzip which will automatically compress files if the browser requests it. I've never used it so I'm not sure if it will handle output from PHP scripts as well or only static files. Someone else or some google research could probably answer that for you. PHP itself, if compile with gzip support, will allow you to compress it's output using a combiniation of output buffering (ob_start) and the handler function ob_gzhandler. If you handle it through PHP though you need to take care that the client actually supports gzip otherwise they will get useless output. Browsers that support it will indicate so via an additional header, Accept-Encoding I believe is the name. There exists some applications which will cache your PHP scripts (or arbitrary data your scripts may use often) in order to increase execution and access times. For example memcached or APC. Googling the terms php opcode cache could get you started on finding out more details Are there tools that can be used to monitor the performance of PHP scripts and or load times of the HTML?
  5. I think it was more to do with reducing the size of PHP scripts, eg one question was if I had a PHP script poduce a page of 1.5Mb, how could I make it smaller. I answered something about preloading images and buffering output. However, looking online, I saw some stuff about compressing the actual PHP script on the server side? Also, how can you cashe these scripts so they run quicker?
  6. So, I had a technical interview for a job recently that was way over my head with what I have been used to doing procedural and basic OOP in PHP. Some questions I got asked were on: Caching Compression IDE for PHP - Eclipse? Netbeans? Mootools Codeigniter and Zend Cross browser testing Load balancing within PHP - is this SQL load balancing? I presumed any load balancing would be done by hardware or Linux. Any ideas on some of these topics particularly compression? Also, I don;t really use an IDE, I use something called Bluefish and Kompozer. I realise I have a lot of looking up to do as my PHP is ibviously way behind what the professional developers use.
  7. I download a file via curl every 10mins as the site needs authentication and doesn't have RSS for updates. If the file is different (HTML code) then I want to email it to myself to have a look. I tried this but it doesn't seem to compare the files - it seems even though the file is the same, curl adds or takes off a few bytes here and there for the filesize. Can I somehow compare the HTML string without spaces? Any ideas? Full code: #! /usr/bin/php <?php $fh = fopen("/usr/local/sbin/myscripts/ITMS_PTWL.html", 'w') or die("can't open file fh"); //INIT CURL $ch = curl_init(); // SET URL FOR THE POST FORM LOGIN curl_setopt($ch, CURLOPT_URL, 'https://www.inthemoneystocks.com/login.php'); // ENABLE HTTP POST curl_setopt ($ch, CURLOPT_POST, 1); // SET POST PARAMETERS : FORM VALUES FOR EACH FIELD curl_setopt ($ch, CURLOPT_POSTFIELDS, '_username=MYUSERN&password=MYPASSWORD'); // IMITATE CLASSIC BROWSER'S BEHAVIOUR : HANDLE COOKIES curl_setopt ($ch, CURLOPT_COOKIEJAR, 'cookie.txt'); # Setting CURLOPT_RETURNTRANSFER variable to 1 will force cURL # not to print out the results of its query. # Instead, it will return the results as a string return value # from curl_exec() instead of the usual true/false. curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); // EXECUTE 1st REQUEST (FORM LOGIN) $store = curl_exec ($ch); // SET FILE TO DOWNLOAD curl_setopt($ch, CURLOPT_URL, 'https://www.inthemoneystocks.com/pro_trader_watch_list_prem.php'); // EXECUTE 2nd REQUEST (FILE DOWNLOAD) $content = curl_exec ($ch); fwrite($fh, $content); fclose($fh); // CLOSE CURL curl_close ($ch); $to = 'webster_jack@hotmail.com'; $subject = 'Pro Trader Watchlist'; $random_hash = md5(date('r', time())); $headers = "From: webmaster@proxyplayer.co.uk\r\nReply-To: webmaster@proxyplayer.co.uk"; $headers .= "\r\nContent-Type: multipart/alternative; boundary=\"PHP-alt-".$random_hash."\""; ob_start(); //Turn on output buffering ?> --PHP-alt-<?php echo $random_hash; ?> Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: 7bit <? $page = file_get_contents('/usr/local/sbin/myscripts/ITMS_PTWL.html'); echo $page; ?> --PHP-alt-<?php echo $random_hash; ?>-- <? $message = ob_get_clean(); $mail_sent = @mail( $to, $subject, $message, $headers ); ?>
×
×
  • 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.