PHP Classes

File: taskmanager/container.php

Recommend this page to a friend!
  Classes of Sildaekar Decrura   PTM   taskmanager/container.php   Download  
File: taskmanager/container.php
Role: Auxiliary script
Content type: text/plain
Description: Container
Class: PTM
Manage PHP tasks running in parallel processes
Author: By
Last change: Fixed error reporting
Date: 11 years ago
Size: 706 bytes
 

Contents

Class file image Download
<?php
/**
 * get_tasks()
 * * Grabs all tasks in the "tasks" directory and loads them into memory *
 * @return
 */
error_reporting(0);
function
get_tasks($cwd){
   
$tasks=array();
   
$err=array();
    if (
$h = opendir($cwd)) {
        while (
false !== ($file = readdir($h))) {
            if(
$file!="."&&$file!=".."){
               
$tasks[]=$file;
            }
        }
       
closedir($h);
        return
$tasks;
    }else{
       
$err[]=FALSE;
       
$err[]="Error opening tasks directory!";
        return
$err;
    }
}

$cwd=getcwd();
$cwd=$cwd."/taskmanager/tasks";
$r=get_tasks($cwd);
if(
$r[0]==FALSE){
    echo
$r[1];
}else{
    include(
"manager.task.php");
    include(
"worker.task.php");
    foreach(
$r as $task){
        include(
$cwd."/".$task);
    }
}
?>