Dedecms has the cache clearing function, so I tried to study it. The result shows that I am in the fog. hi .... I checked the results on the Internet and wrote a Cache clearing function according to my website...
Dedecms has the cache clearing function, so I tried to study it. The result shows that I am in the fog. hi .... as a result, I checked it online and wrote a Cache clearing function based on my website.
Tp execution code:
- // Obtain the absolute path of the desired directory and Directory
- Public function cache (){
- /// The front-end submits the request in ajax get mode. here we will first judge
- If ($ _ POST ['type']) {
- // Obtain the passed value
- $ Type = $ _ POST ['type'];
- // Cut the passed value. I have "-" cut
- $ Name = explode ('-', $ type );
- // Obtain the number of slices to facilitate the following cycle
- $ Count = count ($ name );
- // Call the above method cyclically
- For ($ I = 0; $ I <$ count; $ I ++ ){
- // Obtain the absolute path of the object
- $ Abs_dir = dirname (_ FILE __))));
- // Combined path
- $ Pa = $ abs_dir. '\ index \ Runtime \\';
- $ Runtime = $ abs_dir. '\ index \ Runtime \~ Runtime. php ';
- If (file_exists ($ runtime) // checks whether the object exists.
- {
- Unlink ($ runtime); // delete a file
- }
- // Call the method to delete all objects in a folder
- $ This-> rmFile ($ pa, $ name [$ I]);
- }
- // Provides prompt information
- $ This-> ajaxReturn (1, 'cleared successfully', 1 );
- } Else {
- $ This-> display ();
- }
- }
- Public function rmFile ($ path, $ fileName) {// delete the execution method
- // Remove spaces
- $ Path = preg_replace ('/(\/) {2, }|{\\\}{ 1,}/', '/', $ path );
- // Obtain The Complete Directory
- $ Path. = $ fileName;
- // Determine whether the file is a file directory
- If (is_dir ($ path )){
- // Open the file
- If ($ dh = opendir ($ path )){
- // Retrieve the file directory name
- While ($ file = readdir ($ dh ))! = False ){
- // Delete one by one
- Unlink ($ path. '\'. $ file );
- }
- // Close the file
- Closedir ($ dh );
- }
- }
- }
Tp: front-end code (a little crude)
-
- -->