<?php /*~ tasks.inc.php
.---------------------------------------------------------------------------.
|  Software: Finalizing Tasks Library                                       |
|   Version: 0.1                                                            |
|   Contact: via http://www.uniwits.com/contact                             |
|      Info: http://www.uniwits.com/                                        |
|   Support: http://www.uniwits.com/support                                 |
|      Note: This library is designed for Linux and compatible systems.     |
| ------------------------------------------------------------------------- |
|     Admin: Yuxiang Mao (project admininistrator)                          |
|   Authors: Yuxiang Mao (Uniwits) contact@uniwits.com                      |
|   Founder: Yuxiang Mao                                                    |
| Copyright (c) 2010-2012, Yuxiang Mao. All Rights Reserved.                |
| ------------------------------------------------------------------------- |
|   License: Distributed under Uniwits Shareware License (USL)              |
|            http://www.uniwits.com/licenses/shareware/                     |
| This program is distributed as a part of software provided by Uniwits     |
| System WITHOUT ANY WARRANTY; without even the implied warranty of         |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                      |
| ------------------------------------------------------------------------- |
*/ function task_load_list() { global $Config; $tmpdir=$Config->Paths['tasklistbase'].'/tmp'; @mkdir($tmpdir,0755,true); $taskfiles=glob($Config->Paths['tasklistbase'].'/'.$_SERVER['SERVER_ADDR'].'-'.$_SERVER['SERVER_NAME'].'/*'); $tasklist=array(); foreach ($taskfiles as $file) { $tmpfile=tempnam($tmpdir,'task'); @rename($file,$tmpfile); $task=@unserialize(file_get_contents($tmpfile)); if ($task) array_push($tasklist,$task); @unlink($tmpfile); @unlink($file); } return $tasklist; } function task_send_request($taskdomain,$tasktype,$parameter) { global $Config; $requestname=implode('-',explode(" ",microtime())); foreach ($Config->ServerList as $target) { $path=$Config->Paths['tasklistbase'].'/'.$target; @mkdir($path,0755,true); $file=$path.'/'.$requestname; $taskdata=array( 'domain'=>$taskdomain, 'type'=>$tasktype, 'parameter'=>$parameter ); @file_put_contents($file,serialize($taskdata)); } } function task_process_list($tasklist) { global $Config; foreach ($tasklist as $task) { switch ($task['domain']) { case 'theme': task_process_theme($task['type'],$task['parameter']); break; } } } function task_process_theme($type,$parameter) { global $Config; switch ($type) { case 'clearcache': $cache_full_path=compute_theme_path($parameter,$Config->CachePrefix); remove_dir(realpath($cache_full_path),true); break; } } ?>