PHP: modifying rarfile comments and adding compressed files _ PHP Tutorial

Source: Internet
Author: User
Modify rarfile comments in PHP and add compressed files. To open the WINRAR help file, we mentioned in the help file that the two parameters for modifying the rarfile comment in command line mode and adding the compressed file are AC. the description file of WINRAR is as follows: when we open the WINRAR help file, the help file mentions that the two parameters for modifying the rarfile comment in command line mode and adding the compressed file are AC, respectively. the description file of WINRAR is as follows:
Add all *. hlp files from the current folder to the compressed file help.rar.

WinRAR a help *. hlp

You can use-z to add comments from a file. <文件> Switch.
WinRAR c -zinfo.txt dummy

In this way, we can use PHP to call CMD and run the above two WINRAR parameters to modify the annotations of rarfile in batches and add the files of the compressed package. note that CMD cannot be called directly When PHP is enabled in safe mode.

Both dig and CMD. EXE are in the same directory as 1.php.
The code is as follows:
$ Id = $ _ GET [id];
If ($ id = "")
{
Echo "Parameter error ";
Exit;
}
If ($ id> = 400)
{
Echo "all ends ";
Exit;
}
$ Db = odbc_connect ("dw ","","");
$ SQL = "select * from download where id = $ id ";
$ Query = odbc_exec ($ db, $ SQL );
$ Filename = odbc_result ($ query, 2 );
If ($ filename = "")
{

}
$ Filename = str_replace ("#1", "", $ filename );
$ Filename = str_replace ("#2", "", $ filename );
$ Filename = "soft/". $ filename;
Echo $ filename ."
";
If (! File_exists ($ filename ))
{
Echo "the file does not exist, go to the next ID ";
$ Id;
Echo"
CONTENT = 0; URL = ../test/1.php? Id = $ id> ";
Exit;
} // Read the file name and check whether the file exists
Else
{
WinRAR a $ filename usage description .txt;
Echo "the file is successfully inserted ";
$ Id;
Echo" ";
}
Odbc_close ($ db );
?>

*
Collection has become popular recently. many friends may try to build a site with rich content by collecting data.
However, in some cases, the rarfiles we normally collect are added with comments in batches. in this case, if we put the data on our own website, it would be tantamount to advertising for others.
Recently, I also encountered such a problem, which was a big headache. later, I carefully looked at the WINRAR help file and found that we can use the following methods to make batch modifications.
To open the WINRAR help file, we mentioned in the help file that the two parameters for modifying the rarfile comment in command line mode and adding the compressed file are AC. the description file of WINRAR is as follows:
Add all *. hlp files from the current folder to the compressed file help.rar.
WinRAR a help *. hlp

You can use-z to add comments from a file. <文件> Switch.
WinRAR c -zinfo.txt dummy

In this way, we can use PHP to call CMD and run the above two WINRAR parameters to modify the annotations of rarfile in batches and add the files of the compressed package. note that CMD cannot be called directly When PHP is enabled in safe mode.

The following code reads the file path from my database and finally implements the method of modifying rarfile comments in batches. because the database is ACCESS, I have created an ODBC source. RAR. EXE and CMD. EXE is in 1. under the same directory of PHP
The code is as follows:
$ Id = $ _ GET [id];
If ($ id = "")
{
Echo "Parameter error ";
Exit;
}
If ($ id> = 400)
{
Echo "all ends ";
Exit;
}
$ Db = odbc_connect ("dw ","","");
$ SQL = "select * from download where id = $ id ";
$ Query = odbc_exec ($ db, $ SQL );
$ Filename = odbc_result ($ query, 2 );
If ($ filename = "")
{
}
$ Filename = str_replace ("#1", "", $ filename );
$ Filename = str_replace ("#2", "", $ filename );
$ Filename = "soft/". $ filename;
Echo $ filename ."
";
If (! File_exists ($ filename ))
{
Echo "the file does not exist, go to the next ID ";
$ Id;
Echo"
CONTENT = 0; URL = ../test/1.php? Id = $ id> ";
Exit;
} // Read the file name and check whether the file exists
Else
{
WinRAR a $ filename usage description .txt;
Echo "the file is successfully inserted ";
$ Id;
Echo" ";
}
Odbc_close ($ db );
?>

Starting from when...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.