Jump to content


  • Posts

  • Joined

  • Last visited


Profile Information

  • Gender
    Not Telling

etrader's Achievements

Advanced Member

Advanced Member (4/5)



  1. I use a simple php code (taken from php.net example) to resize an image list($width, $height) = getimagesize($filename); $new_height = $height / $width * 400; $image_p = imagecreatetruecolor(400, $new_height); $image = imagecreatefromjpeg($filename); imagecopyresampled($image_p, $image, 0, 0, 0, 0, 400, $new_height, $width, $height); imagejpeg($image_p, "new.jpg"); Here, we create a blank image and merge it with the resized image. I wonder if it is the simplest way to resize and save an image. Is it really necessary to create a blank background image?
  2. I have a normalized database in the form of ID user_id key value 1 3 first_name Brian 2 3 last_name Tardy 3 4 first_name John 4 4 last_name Wilson What is the fastest way to capture these values within php? I want to perform a SELECT to catch the values for every user as $result=mysql_query("SELECT * FROM users_data WHERE user_id = '$id'"); while($row=mysql_fetch_array($result)) { here we process all data for a given user and write it to text file as a single line } Since it is a long list (100K users with about 10M of rows in user_data), I am looking for the fastest and most reliable way to scan all the database. ?>
  3. I've read lots of articles and discussions about security issues for using session for user authentication; but I did not come to an explicit conclusion which is the best method. I decide to generate two session parameters (1) ID (2) a randomly generated Access Token which is stored in the database. I want to add more security: 1. Where to store session? server-side or client-side by session session.use_only_cookies ? 2. Is it good to check IP and User Agent before authentication by session? In this case I will lose the option of Remember Me as IP can be changed. 3. Which of the session parameters of http://php.net/manual/en/session.configuration.php is more practical to have a good security? Any additional idea?
  4. I want to make a local version of some variable taken from database to reduce the number of mysql queries. For example, creating a local menu as an array in php file instead of making a query every time to take list of menu from mysql database.
  5. I produce a series of php variables in a php strict (mostly come from mysql), and I want to save them as a php file. To be use for "include". What is the safest way to write them in a php file? I tried to save them in the manner of saving a text file with fwrite as $data='<?php $cat=array('array created in the text'); $string='some value';?>'; $fh = fopen("file.php", 'w'); fwrite($fh, $data); Now, file.php is a normal php file and I can call it with "include"; but the problem is that this method is not safe. For example, if the string is "There's something", php gives error for the presence of ' in the string. I can skip ' and " by backslash; but this method is costy, as I need to perform this process for all strings to be saved. Moreover, there might be other source of errors too (that I have not encountered yet). Is there a safe way for writing a php code to file?
  6. Thanks a million! It did lead me on the right direction. P.S. The wonderful quotation in your signature made my day I wish the best for your Roboroster project
  7. I have a mysql table with the structure of ID Menu_Name Parent_ID 1 Finance NULL 2 Business NULL 3 Investment 1 4 Trading 2 How can I create a html <ul><li> list based on the parent?
  8. No I meant the database system, db3, db4, gdbm, etc for configuring php. I have not installed dba yet. I want to know how to install php-dba by yum with BerkeleyDB
  9. All instructions for enabling php-dba is via fresh installation of php with --enable-dba=shared .... When php has been installed, one can install dba later by yum install php-dba. In this method there is no place to define the location of each database dir, as we need to enable some of them due to possible conflicts. How to install php-dba via yum?
  10. Is there something like str_pad to make a string with a fixed width on the bases of bytes (not characters). If not, is it possible to safely convert characters to bytes to have a fixed width (of bytes). As a matter of fact, I want to use the strings (to be written to a file) as offsets for reading lines with fseek. Thanks
  11. When I try to install dBase by yum install dbase, it says Package php-dbase is obsoleted by php-common, trying to install php-common-5.1.6-27.el5_5.3.i386 instead Package matching php-common- already installed. Checking for update. Nothing to do
  12. I have want to install dBase on my servers (CentOS and Ubuntu), but the problem is that PHP 5.3.6 has been installed by yum as php53. dBase is available in repositories as php-dbase, and this will have conflict with php-common. Alternatively, I tried to compile it from source, but after downloading php 5.3.8 (the latest version), I just found that dbase does not exist in ext folder. How can I enable dBase on php 5.3.6?
  13. I want to load and display the content of a text file (actually it is a cache file). I tested both method using a long for loop as for ($i=0; $i < 10000; $i++) { $handle = fopen("test.txt", "r"); $text = fread($handle, filesize("test.txt")); fclose($handle); echo $text; } and for ($i=0; $i < 10000; $i++) { $text = file_get_contents("test.txt"); echo $text; } but the results were similar, though with a large distribution of the comparative data. The speed of a method was 0.5 to 2.0 faster than the other one (in various runs). Which method do you recommend? Could you please quote the pros and cons of each method?
  14. I have a large number of files. It is recommended to save the files with hashing system to have fast access to files through the OS. But I have no practical knowledge about hash. Could you please give me a hint, how to save a file with hash coded system via php? and how to read the hash coded filename by php? Thank you in advance!
  15. I want to parse some tiny lines from a webpage. I have few questions: 1. What is faster and better: cURL or file_get_contents? 2. Is it better to run preg_match commands form every line I want OR first get a shorter part (e.g. between <head> tag) then running preg_match for the lines? 3. Actually, I need to load the whole page before parsing. Is there a way to stop loading the whole page. For example, when I want something between <head> tag; stop loading <body>? Thank you in advance!
  • 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.