Jump to content

etrader

Members
  • Posts

    315
  • Joined

  • Last visited

    Never

Everything posted by etrader

  1. I have a simple php, and now I created an admin folder for it. How I can make this folder password protected? Should I introduce a restricted folder in webserver (Nginx or Apache) or I should introduce an authentication system by php as the password is stored in mysql databse? or any other practical idea?
  2. Nice reference! I like when facing such creative ideas to handle an issue in php
  3. In a string containing a simple sentence as $str="word1 word2 word3 word4 word5" I want to split every two words. Actually, performing explode() for every other 'space' (not all of them). To create $array[0]="word1 word2"; $array[1]="word3 word4"; $array[2]="word5"; Any idea?
  4. Thanks Ken! Works like a charm
  5. I have a for loop as for ($i=0; $i < $pageLength; $i++) { ... echo "<tr class='odd'><td>...</td>"; How I can set class "odd" and "even" for the results?
  6. Thanks for your kind attention thorpe. I just figure it out. I am based in Nginx + php-fpm. I just needed to change Unix user/group of processes from apache to nginx. I do not know how this only affected simplexml_load_file, but it was simply resolved by this trick
  7. I just installed php 5.3.6 on Centos 5.5; everything is fine but simplexml_load_file and file_get_contents do not work (even if loading local files). cURL works perfectly.
  8. I want to store a list of strings in a file (to be called as an array) instead of database. Imagine that I have a string come out a search process $q = $_GET['q']; I can simply write the search history in a text file and call it by file() But I want to assign a unique ID to each search term as 1:word1 2:wordx 3:word... Now I can call each word by its given ID through an explode() process. But how I can assign the unique ID to each search-term?
  9. I think another important issue is to have reverse DNS. Should rDNS be pointed to the main domain or it is enough to be pointed to a subdomain of the main domain?
  10. Thanks for your informative reply, PFMaBiSmAd 1. My DNS is setup externally by Godaddy. I added SPF record through its DNS wizard. Do I need to setup OpenSPF on my Postfix in my VPS? Or it is merely a DNS issue? 2. I added all A records (including a subdomain hosted with a dedicated IP, different from main domain). Now can I run mail() on http://subdomain.domain.com for sending from sender@domain.com? or I must necessarily run the php script from http://domain.com?
  11. I explored the interest for tips for avoiding spam filtration of mails sent via mail(). My headers are: $headers = "From: Sender <sender@example.com>\r\n"; $headers .= "Reply-To: Sender <sender@example.com>\r\n"; $headers .= "Return-Path: Sender <sender@example.com>\r\n"; $headers .= "Organization: Sender Organization\r\n"; $headers .= "X-Priority: 1\r\n"; $headers .= "X-MSMail-Priority: High\n"; $headers .= "Importance: High\n"; $headers .= "X-Mailer: PHP". phpversion() ."\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/html; charset=utf-8\r\n"; 1. I am running the script on http://mail.example.com; do I need to run on http://example.com or subdomain is OK? 2. Do you have any other suggestion or advice to increase the chance of successful sending the emails?
  12. I append a string to a file by fwrite as $str= 'dynamic text from each run'; $myFile = "testFile.txt"; $fh = fopen($myFile, 'a') or die("can't open file"); $stringData = "$str\n"; fwrite($fh, $stringData); fclose($fh); but I want to avoid duplicate to keep the file small. I want to avoid writing if the term is already saved in the file. I want to have a file containing unique lines.
  13. How I can explode by a series of characters (not one single character)? For example, divide the string to an array by any of these characters "," and ";" and "." $string = "this, that;some.word;second"; I want to put all of these words into an array.
  14. Thanks, exactly what I needed
  15. How I can format the number in a string to be displayed as four-digit. I mean transforming 1 to 0001; and 54 to 0054.
  16. You are quite right Pikachu2000. This cannot be a practical solution. I resolved it by storing the last value.
  17. I have a php form for uploading file as the action sends to upload.php. How I can avoid any kind of direct access to upload.php? I want to kill the php process at the first line without performing the remaining code (it is very critical for me as I have a counter), except calls coming from form.php.
  18. I want to give a unique ID for each run of my php script. I was thinking of creating an array(1,2,3,4,5...), as I can regularly take the first value and delete. Is there any command like array_ shift to do so? array_ shift take the first item but does not permanently delete it; thus, it will be the first item again in the next run. Or do you have a subtle idea for assigning unique ID to each run?
  19. I have a series of string which can have a value or empty. I want to display them with echo. echo $string1 $string2 $string3; satisfies my need, as it shows available values, but with this method, I will get a PHP notice in my error_logs. What is your suggestion? Do I need to use "if (empty)" or "if(isset)"? The point is I have numerous strings and in each run only few of them have value.
  20. The file is a simple text file containing keywords, and I want to put them into an array; this is the reason that I use file() instead of file_get_contents(). It's mine but not on the same server. Is there a way to avoid this? I use this remote file for creating a side widget, which is not the main content. I do not want to delay the main content for it.
  21. The problem is exactly associated with this error [<a href='function.file'>function.file</a>]: failed to open stream: Connection timed out in The problem is related to $file="http://domain.com"; $content=file($file); When removing these lines the execution time reduces to 1s. The problem is merely related to file(). It seems it does not work in my settings (probably that of Virtualmin).
  22. Thanks for your attention. I tried on three different VPSs running CentOS 5.5 and Virtualmin. I checked with different php codes, the main delay appears when it writes these two types of errors: PHP Notice: Undefined variable: .... PHP Notice: Undefined offset: 0 .....
  23. I have a simple php script without mysql database. Normally it takes less than 1s to complete the process. But in high traffic (more than 10 concurrent processes), the execution time dramatically increases to 10-30s. This itself causes an increase in the concurrent processes. I think this behavior is not very common. Any idea? Btw, can huge error logs make the system slow? I have numerous php notices and it's growing.
  24. Thanks spiderwell, I hope to avoid mysql database, as the system is simple and I prefer not to get involved with slow queries. Regarding one single file, I was thinking of problem associated with large file; as in the case of separate file, only a small file is read for each query.
  25. I want to store a series of data which are called in a main php file. Do you suggest to store them in xml as file1.xml: <title>TITLE</title> <content>CONTENT</content> or file1.php: $title="TITLE"; $content="CONTENT"; AND is it better to create separate file for each article or storing all data in one single file?
×
×
  • 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.