• Welcome to Auciou's Blog! Subscibe
  • HomeAbout AuciouArchivesContactSite MapLinks

  • Category: PHP  12 articles

    Diary: 2010-01-15

    January 15, 2010 at 21:35

    Because the demostic and overseas Linux hosting do not support the mod_expires module, as http://www.auciou.com/peace/89, can not directly set the expiring time by the .htaccess for the picture files.

    After the tests, finally there was a helpless way instead, create a .htaccess file in the picture folder, may use the 404 error or Rewrite module. Make the 404 error or Rewrite point to a file auf.php, set the expiring time in this auf.php and use header("Expires:"), intercept the picture's file name from the Address Bar as $a1, use include() function to include the picture file, as include($a1). So, the include() function of PHP is powerful.

    The long-range picture also can use file_get_contents() function to invoke, write in the auf.php, also can set the expiring time of long-range picture, so the function of PHP is powerful.

    Permalink | Comments (0) | Trackback (0)

    Many Linux hostings do not support the mod_expires module

    January 15, 2010 at 21:03

    "mod_expires" is a very important module of Apache, but currently many Linux hostings do not support this module. Use the mod_expires module, may set the expiring time by the .htaccess for the picture files, Flash files, .js files, midi files, etc., make the site's speed faster, save a lot of traffic.

    My Linux space of IXWebHosting, the free hostings which GoDaddy presented to me, and a domestic Linux space, all of them do not support the mod_expires module. At present, the newer version of Apache is 2.2.*, such as 2.2.14, this version contains the mod_expires module, but the default does not turn on this module, in the default httpd.conf file, there is a # symbol before the sentence which loads the mod_expires module. But the Linux hosting of GoDaddy, use the Apache 1.3 version all the same.

    I posted an Email to GoDaddy yesterday, hope to turn on the mod_expires module, I've just received the reply of GoDaddy, they said that they do not want to turn on this module now, maybe this clerk did not know the important action of the mod_expires module. It seems that if need use the mod_expires module, just can use the others hosting of provider, or VPS.

    I've downloaded the Apache 2.2.14 version, tested on the local computer, the mod_expires module can be used normally.

    Permalink | Comments (3) | Trackback (1)

    About the QUERY_STRING parameter of URL

    January 13, 2010 at 04:56

    In these 7 years program experiences, I often used the QUERY_STRING parameter. The active page needed use this QUERY_STRING parameter largely, It is also called "query parameter". Such as article.asp?id=52, main.php?violate=respond&aware=52&retail=75, etc., the parameters after the question mark. There are many sites use many query parameter in the Address Bar, make the URL longer. Actually some are not necessary, and some are necessary. The unnecessary query parameter, just works for adorning the URL, these noneffective query parameters do not affect the run of program.

    The query parameters may reduce largely, such as the documents of Blog and forum. In a site, the approach of differentiating 2 articles is that as the URL above, article.asp?id=52 or article.php?id=495, differentiate by the ?id=. All of the other parameters, may write in the database or Cookies. Because Apache provides the .htaccess, the URL may use the Rewrite module or 404 error, realise that the URL becomes static. The query parameters may write in the database or Cookies, many necessary parameters write on the Address Bar by the connective symbols / or -.

    For the immovable links of documents, you may reduce the QUERY_STRING parameters as possible. For the active URLs of search or query which submited by the users, the QUERY_STRING parameters may write on the Address Bar.

    Permalink | Comments (0) | Trackback (0)

    The relation between program and .htaccess file

    January 10, 2010 at 21:59

    This is just a diary. Apache provides the powerful .htaccess file, actually it realises some of the functions of server configuration. The .htaccess file may write the regular expression, write the correlative commands, etc., these commands will be parsed by Apache, these commands' essential are that start the correlative background programs.

    The functions of .htaccess file which provides by Apache, may realise the special functions, such as make every files invoke the Rewrite module, mod_expires module, every folder appoints the 404 error page, etc.. These are PHP, JSP, Perl and the other none of any language of program may realise directly, because the .htaccess file just realises the functions of server configuration. Whereas, if need the more complicated judgement, the .htaccess file will need to cooperate with the program. As the previous example, http://www.auciou.com/peace/83, use the .htaccess file to combine with PHP program, the .htaccess file appoints the 404 error page, it selects many 404 error page via the judgement of PHP program.

    All of the programs which use the Apache as the server background, such as PHP, may use the .htaccess file. ASP+IIS, or PHP+IIS, can not realise the functions of .htaccess file, because IIS does not support the .htaccess file.

    Permalink | Comments (0) | Trackback (0)

    Saved a delicated IP

    January 10, 2010 at 07:17

    Because IXWebHosting presents several IPs to us. I used one of the delicated IPs to parse unlimited sub domains' homepage and some inner pages (The different main domains and sub domains, used the same space, integrated them together); another delicated IP, used it to parse many domains' pan-domain. Finally, yesterday I merge the web pages of these 2 delicated IPs, via a judgment sentence, use a delicated IP to realise that many sub domains of different domains' resolution, and pan-domain resolution. After the tests of local and server, the program ran normally.

    So it saved a delicated IP, from now on if I change the provider of hosting, I may just buy a delicated IP, and need not buy 2 delicated IPs. My approach is that the sub domains and pan-domains point to this delicated IP, the control panel of site need not any setting, at the root directory of the corresponding space of this delicated IP, create a index.php file, use this PHP file to read the Address Bar, then use the include() function to include the homepage file of the corresponding sub domain or pan-domain. The prior order of include() is that judge whether the homepage file exists, if exists, it will include the homepage file of sub domain; if does not exist, it will include the homepage file of pan-domain.

    All of the inner pages of this delicated IP, just can use the 404 Error of .htaccess to realise. Create a .htaccess file at the root directory of this delicated IP's space, let the 404 error point to the auf.php. As the same steps above, the error page auf.php also write the judgment sentence, use the include() function to include the inner page of the corresponding sub domain or pan-domain, the prior order and judgement method are same with above.

    Employ this delicated IP to create many sites, such as the resolution of sub domain or pan-domain, these many sites are integrated together, can not realise all kinds of function as the delicated site. If need realise the functions of delicated site, you may use other approach, such as submit the functions to the delicated site to run, or create a sub domain or pan-domain on this delicated IP, make it can perform the corresponding function.

    Permalink | Comments (1) | Trackback (1)

    Judge that does a long-range file exist in PHP

    December 17, 2009 at 21:35

    There is no function to judge that does a long-range file exist. If a long-range file exists, it reruns the 200 status code, so we may check the status code to judge that does a long-range file exist. The program:

    <?$au="http://www.auciou.com/file.php";
    $j=get_headers($au);
    $j=$j[0];
    if (strpos($j,"200")) echo "Exist";?>

    Permalink | Comments (0) | Trackback (0)

    Use Apache as the local virtual hosting to preview the Blog

    October 12, 2009 at 22:08

    The setups of virtual directory, or virtual hosting are very convenient. In Apache, actually the virtual hosting is a virtual directory, so the setup of virtual hosting, and the setup of virtual hosting are complete the same. As the codes below which in the file of httpd.conf, is the default setting of http://localhost in the httpd.conf file:

    <VirtualHost *:80>
    ServerName localhost
    DocumentRoot F:/site
    </VirtualHost>

    Follow suit, if I want to use http://ww2.auciou.com to browse and test my Blog, copy the 4 lines of code as above, then change the values of ServerName in Line 2, and DocumentRoot in Line 3. The codes after change is as below:

    <VirtualHost *:80>
    ServerName ww2.auciou.com
    DocumentRoot F:/site/auciou
    </VirtualHost>

    Then restart Apache, as well you may create many virtual hostings at local.

    Open the file of C:\WINDOWS\system32\drivers\etc\hosts, write a line as below:
    127.0.0.1 ww2.auciou.com

    Then you may use Apache as the local virtual hosting to preview your own Blog, as the photo below:

    The simple and convenient installation of Apache and PHP, please view this article which was written by me http://www.auciou.com/peace/78. All of my present development environments, are based on this background of Apache and PHP, need not to reinstall Apache and PHP after reinstall the system.

    Permalink | Comments (0) | Trackback (0)

    Create the development environment of Apache

    October 09, 2009 at 00:25

    As the preceding approach, http://www.auciou.com/peace/78 (Reinstall Apache and PHP for one step), after create the development environment of Apache, while reinstall the system, you may reinstall Apache and PHP for just one step. The essential of create the development environment is revising the apache\conf\httpd.conf file, this file needs to be backuped, set for one time, hereafter need not to set it repeatedly. Here I'll briefly introduce the approach that change the port, create the virtual hosting, change the main directory of default local sites.

    Take the article before, for instance, all the same, the system is Win XP, create the folder D:\server:
    Apache extracts at D:\server\apache;
    PHP 5 extracts at D:\server\php5.

    All of the settings below, we will change the file D:\server\apache\conf\httpd.conf, please open this file by a text tool.

    1. Change the port. If you depend on PHP development, I suggest that do not change the port, the default port is 80. If you need to change the port, for instance, I change the port to 60. Find "Listen 80", change to Listen 60, restart Apache. Then you may use http://localhost:60 to visit the main directory.

    2. Create the virtual hosting. For instance, my site's long-distance address is http://www.auciou.com, in order to simulate the effect of long-distance, as well I can make my local computer as a server. In order to avoid that the accidental mess of operations of local and long-distance happens, we may use a sub domain to simulate, the sub domain of 3 characters is the best, as ww2.auciou.com, or wwa.auciou.com. (Commentary: this sub domain, just revise the local file "hosts", do not need to add on the domain management.)

      The approach of creating a virtual hosting: write the codes as below at any position in the httpd.conf file:

      <VirtualHost *:80>
      ServerName ww2.auciou.com
      DocumentRoot F:/site/auciou
      </VirtualHost>

      Commentary: the third line DocumentRoot F:/site/auciou, is the path of my blog in the local harddisk. Then open this file C:\WINDOWS\system32\drivers\etc\hosts, write a line as below:

      127.0.0.1 ww2.auciou.com

      The virtual hosting have been set up, restart Apache, then you may use http://ww2.auciou.com to visit the local sites. To set for many virtual hostings, are the same steps. (In addition, if you use IIS for a few, you may use the Port 80 for Apache and PHP, IIS uses the Port 50 or others.)

    3. Change the main directory of default local sites, that's to say that revise the corresponding directory of http://localhost.
      Find ServerRoot c:/www
      Change to ServerRoot F:/site

      At last, restart Apache.

    Permalink | Comments (1) | Trackback (1)

    Reinstall Apache and PHP for one step

    October 08, 2009 at 06:41

    The 2 softwares we need:
    MiniApache (V2.0.5.2)
    php-5.2.8-Win32.zip

    The development environment of this article is Win XP. While the PHP runs with IIS, it is very slow. Run PHP with Apache, the speed will be faster for much. MiniApache (2.0.5.2) is a simplified Apache, it is just 308 K. As the introduction said, the functions that used frequently are not reduced.

    After I installed and tested for many times, I've known well this installation of MiniApache. In order to avoid reinstalling Apache and PHP after reinstalling the system, please install them in the Disk D, for example, I install at D:\server. Create the development environmen of yourself first, the steps of installation are:

    1. Extract the MiniApache at D:\server\apache.
    2. Open the file D:\server\apache\setup.cmd, by a text tool, find that c:\www\bin\apache -k install, c:\www\bin\apache -k uninstall, and c:\www\bin\apache -k restart, delete all of the keyword "c:\www\", they will become bin\apache -k install, etc., this makes the DOS command become the relative path. Otherwise while run setup.cmd, it takes error, disable to install.
    3. Configure the file D:\server\apache\conf\httpd.conf first, then install Apache. Such as change the port, create the virtual hosting, change the main directory of local site, all of them are written the correlative codes in the httpd.conf configuration file, in order to understand more easily for you, I omit this step. (Please click here to view detail, http://www.auciou.com/peace/79)
      httpd.conf file must be written the 3 lines as below:

      PHPIniDir D:/server/php5
      LoadModule php5_module D:/server/php5/php5apache2.dll
      AddType application/x-httpd-php .php

      Explanation: the second line is "Load Module", if without the third line, PHP cannot run, it just can display the HTML page.
      DirectoryIndex index.html this line is the default document of the directory, change to DirectoryIndex index.php index.html

    4. In the file of httpd.conf, replace all of the keyword "c:/www" to "D:/server/apache", otherwise it cannot run. Because the MiniApache's default directory of installation is c:/www, I install at D:/server/apache.
    5. Then run setup.cmd, choose 1, press Enter, if favoring, the installation of Apache will finish.
    6. Install PHP 5. Extract php-5.2.8-Win32.zip at D:\server\php5, rename the D:\server\php5\php.ini-dist to php.ini, do not need to configure.
    7. At this time, Apache and PHP have been installed completely. If PHP does not run, please open D:\server\apache\setup.cmd, choose 3, Enter, restart Apache.

    Hereafer, after reinstall the system, just double click D:\server\apache\setup.cmd, choose 1, Enter, install, Apache and PHP will be installed for just one step.

    Permalink | Comments (2) | Trackback (2)

    The elements of program of preventing the spam and closing IP

    October 04, 2009 at 06:11

    The program of preventing the spam and closing IP which designed by me, had been used for several months on ufoaq.com, the effect was very good, not only simple, but also highly effect, it is simpler than the program which designed by me in 2006. Generally, the program of preventing the spam was via that write the Cookies, the program of closing IP was via that write the Cookies and read the IP list from the database, this article will take PHP, for instance. Because this program needs to write the Cookies, please write <?ob_start();?> at the very head of the very outer of such as post.php, reply.php, submit.php, otherwise it will take error.

    The elements of program of preventing is as below, this program is written in the common module such as judge.php, this file is includeed by the other files with the include() function.

    <?$te=30; //You could set this value for the time which just can post for one time in 30 seconds, if omit $te=30;, the default value is 60.
    if (!$te) $te=60;
    $t9=time();
    if ($t9-$_COOKIE[te]<$te) $kx.="The time between you post for 2 times should be more than ".$te." seconds, please post ".$te." seconds later.";
    if ($kx) {……} //Take error to the poster, and the program will not run.
    ?>

    Then write Cookies in post.php, as below:
    <?if (!$kx) setcookie("te",$t9,$t9+$te,"/");?>

    The program of closing IP is below:

    <?$ip=$_SERVER["REMOTE_ADDR"];
    $i=…… //$i was the IP list which reed from the database, such as the value of $i is "125.33.125.255,133.134.99.1", many IPs are spaced out by comma, this value can be revised in the background of site. Because the configurations of background of site are different, this article will not explain the program which how to revise this value, please write the program by yourself. Because the program below uses the strpos() function, not uses the circle program to judge that whether the IP of user exists in the $i value, you may set for many IPs which you want to close, several hundred IPs will not affect the efficiency of program for much. While the user-side write the Cookies, the user's IP is closed completely, you may delete all the value of $i.
    $j=$_COOKIE[pe];
    $h="Your IP is closed.";
    if ($j) $kx.=$h;
    elseif (strpos($i,$ip)!==false){$kx.=$h;
    if (!$j) setcookie("pe","50",time()+86400*9,"/");}
    if ($kx) {……} //Take error to the poster, and the program will not run.
    ?>

    Permalink | Comments (0) | Trackback (0)

    How to write the RSS in PHP

    April 11, 2009 at 12:27

    Create a file which extension name is .php, in this PHP file, write the sentence below, and write this sentence in the very beginning of this PHP file. Then the PHP format will be transformed to the XML format:

    <?header("Content-type: text/xml; charset=utf-8");?>

    Then you may find a RSS of other's for reference. Example: http://www.aufor.com/feed/ (The real path is http://www.aufor.com/feed/index.php)

    Chinese for this article http://www.auiou.com/relevant/00000469.jsp

    Permalink | Comments (1) | Trackback (0)

    Compare ASP and PHP (1): Speed

    Augest 29, 2005 at 11:38

    These days we are going to write a program to search from a large database, before this project I did one of the tests in order to wonder the speed of this big project.

    The PHP program:

    <?
    for ($i=1; $i<=1000000; $i++){
    echo "$i, ";}
    ?>

    The ASP program:

    <%
    for i=1 to 1000000
    response.write i&", "
    next
    %>

    On this test, I wanted it to print the numbers until one million. The test result: PHP program couldn't finish that just could print until 328125 and tell me "Fatal error: Maximum execution time of 30 seconds exceeded in F:\cww\php\re.php on line 3", it spent me 31 seconds; but ASP program could be finished, it spent me 18 seconds.

    Permalink | Comments (2) | Trackback (0)

  • Auciou: Programmer

    Peaceful Seabed | My column

    Category:
    Program | Internet | Computer
    Blog Research | PHP | Philosophy


    TDNote | Gratitude | Matnue | Aucist | Aroat | Aufirm | IXNes | Anydiary | Cersta | Coumit | Tovate | Aroat | Aucist | Matnue | Sinvide | Serble | Auciou's column | Peaceful Seabed | Webshu | Sail every day | Sail every day

    Archives:
    January 2011 | January 2010
    December 2009 | October 2009 | September 2009 | April 2009
    December 2008 | November 2008
    May 2007 | April 2007
    August 2005 | July 2005 | June 2005
    May 2005 | April 2005 | March 2005
    February 2005 | January 2005

    Recent articles:
    My Go Daddy hosting is fast
    Create a house with your spouse on the interest
    Pending time which add a domain of hosting, was more than 36 hours
    Diary: 2010-01-15
    Many Linux hostings do not support the mod_expires module
    Figured out, there is still a way
    About the delicated IP of IXWebHosting
    About the QUERY_STRING parameter of URL
    About the ping value and speed of site
    The relation between program and .htaccess file
    Saved a delicated IP
    Judge that does a long-range file exist in PHP
    How to call the Confederation of Planets and the high evolving beings of alien/pray/make a wish
    Use Apache as the local virtual hosting to preview the Blog
    Create the development environment of Apache
    Reinstall Apache and PHP for one step
    The elements of program of preventing the spam and closing IP
    How to close the visit log of ixwebhosting
    Happy Wedding to a friend
    Make an easy Audio/Video converter


  • Copyright © 2007-2025 auciou.com All rights reserved.
    Programmed by Auciou.