function parseCronFile($cronTabFile)
{
    global $debug;
    $file = file($cronTabFile);
    $job = array();
    $jobs = array();
    for ($i = 0; $i < count($file); $i++) {
        if ($file[$i][0] != '#') {
            if (preg_match("~^([-0-9,/*]+)\\s+([-0-9,/*]+)\\s+([-0-9,/*]+)\\s+([-0-9,/*]+)\\s+([-0-7,/*]+|(-|/|Sun|Mon|Tue|Wed|Thu|Fri|Sat)+)\\s+([^#]*)\\s*(#.*)?\$~i", $file[$i], $job)) {
                $jobNumber = count($jobs);
                //DL+- DEBUG - AVOID PHP NOTICES WHEN NO COMMENT IS GIVEN
                if (!array_key_exists(PC_COMMENT, $job)) {
                    $job[PC_COMMENT] = '';
                }
                $jobs[$jobNumber] = $job;
                if ($jobs[$jobNumber][PC_DOW][0] != '*' and !is_numeric($jobs[$jobNumber][PC_DOW])) {
                    $jobs[$jobNumber][PC_DOW] = str_replace(array("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"), array(0, 1, 2, 3, 4, 5, 6), $jobs[$jobNumber][PC_DOW]);
                }
                $jobs[$jobNumber][PC_CMD] = trim($job[PC_CMD]);
                $jobs[$jobNumber][PC_COMMENT] = trim(substr($job[PC_COMMENT], 1));
                $jobs[$jobNumber][PC_ARGS] = array();
                if (preg_match_all('~(("([^"]*)")|(\\S+))\\s*~i', $jobs[$jobNumber][PC_CMD], $jobArgs, PREG_PATTERN_ORDER)) {
                    for ($ii = 0; $ii < count($jobArgs[1]); $ii++) {
                        $jobArg = $jobArgs[3][$ii] === '' ? $jobArgs[1][$ii] : $jobArgs[3][$ii];
                        if ($ii == 0) {
                            $jobs[$jobNumber][PC_CMD] = $jobArg;
                        }
                        $jobs[$jobNumber][PC_ARGS][$ii] = str_replace(array('\\r', '\\n'), array("\r", "\n"), $jobArg);
                    }
                }
                $jobs[$jobNumber][PC_CRONLINE] = $file[$i];
            }
            $jobs[$jobNumber]["lastActual"] = getLastActualRunTime($jobs[$jobNumber]);
            $jobs[$jobNumber]["lastScheduled"] = getLastScheduledRunTime($jobs[$jobNumber]);
        }
    }
    multisort($jobs, "lastScheduled");
    if ($debug) {
        var_dump($jobs);
    }
    return $jobs;
}
Ejemplo n.º 2
0
            }
            if (isset($key4)) {
                $return_array[$pos][$key4] = $array[$pos][$key4];
            }
            if (isset($key5)) {
                $return_array[$pos][$key5] = $array[$pos][$key5];
            }
            if (isset($key6)) {
                $return_array[$pos][$key6] = $array[$pos][$key6];
            }
        }
        return $return_array;
    }
}
//usage (only enter the keys you want sorted):
$inventory_array = multisort($inventory_array, 'description', 'description', 'quantity', 'product_name', 'number_of_products');
// Post the update queries to the database
foreach (array_values($update_query) as $query) {
    $result = @mysql_query($query, $connection) or die(debug_print("ERROR: 155863 ", array($query, mysql_error()), basename(__FILE__) . ' LINE ' . __LINE__));
}
// Show the inventory-control form
$display = '
<div style="width:95%;margin:auto;">
  <table id="inventory_help">
    <tr>
      <td>
        ' . ($message ? '<p style="color:#800;">' . $message . '</p>' : '') . '
        <p>Use this page to update your inventory quantities and add/delete inventory types.</p>
        <p><strong>UPDATE:</strong> Multiple products may draw from the same inventory &quot;buckets&quot; and may draw
        at different rates.  Assign the inventory &quot;bucket&quot; to your products on the regular product editing
        screen.</p>
Ejemplo n.º 3
0
        			$clsindex = intval(end($clsindex)) + 1;
        		}*/
        if (!empty($tagutclass)) {
            in_array($tagutclass, $clscname) && amessage('utcls_exist', axaction(1, M_REFERER));
            #			$tagclasses[$utc.$clsindex] = array(
            $tagclasses[auto_utc_index()] = array('cname' => $tagutclass, 'vieworder' => max(0, intval($tagutclassorder)));
        }
        if (!empty($utclassnew)) {
            foreach ($utclassnew as $key => $clsnew) {
                if (array_key_exists($key, $tagclasses)) {
                    !empty($clsnew['cname']) && !in_array($clsnew['cname'], $clscname) && ($tagclasses[$key]['cname'] = $clsnew['cname']);
                    $tagclasses[$key]['vieworder'] = max(0, intval($clsnew['vieworder']));
                }
            }
        }
        multisort($tagclasses);
        cache2file($tagclasses, 'tagclasses', 'usualtags', $sid);
        adminlog(lang('edit_tagclasses_mlist'));
        amessage('utcls_fin', axaction(1, M_REFERER));
    }
}
function multisort(&$arr)
{
    if (!is_array($arr) || empty($arr) || !function_exists('array_multisort')) {
        return;
    }
    foreach ($arr as $k => $v) {
        $vorder[$k] = $v['vieworder'];
        $eorder[$k] = $k;
    }
    array_multisort($vorder, SORT_ASC, $eorder, SORT_ASC, $arr);
            }
        } elseif ($i > 0) {
            $rows[] = $row_prev;
        }
        $row_prev = $row;
    }
}
function multisort(&$array, $key)
{
    $cmp = create_function('$a, $b', 'if ($a["' . $key . '"] == $b["' . $key . '"]) return 0;' . 'return ($a["' . $key . '"] > $b["' . $key . '"]) ? -1 : 1;');
    usort($array, $cmp);
}
if ($sort == 'config') {
    sort($rows);
} else {
    multisort($rows, $sort);
}
function detect_language($DirLang)
{
    $Lang = '';
    foreach (explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']) as $Lang) {
        $Lang = strtolower(trim(substr($Lang, 0, 2)));
        if (is_dir("{$DirLang}/awstats-{$Lang}.txt")) {
            break;
        } else {
            $Lang = '';
        }
    }
    if (!$Lang) {
        $Lang = 'en';
    }