Jump to content

etrader

Members
  • Posts

    315
  • Joined

  • Last visited

    Never

Posts 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. 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?

  3. 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?

  4. 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?

     

  5. 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.

  6. 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.

  7. 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?

  8. 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.

  9. 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.

     

    Also note that if your php script is loading remote files your script will not load until it has finished receiving the remote content and doing whatever with the data collected that you decide.

     

    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.

  10. 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).

     

  11. 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 .....

  12. 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.

  13. 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.

  14. 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.