Exemplo n.º 1
0
function handle_upload($id, $sid, $cid)
{
    global $path, $config, $newname, $filename;
    $pth = realpath('.') . '\\images';
    if (!is_dir($pth)) {
        mkdir($pth);
    }
    $err = '';
    foreach ($_FILES as $file) {
        switch ($file['error']) {
            case 0:
                if ($file['name'] != NULL) {
                    $err = processFile($file['name'], $file['tmp_name'], $id, $sid, $cid);
                }
                break;
            case 1 | 2:
                $err = 'file upload is too large';
                break;
            case 6 | 7:
                $err = 'internal error – flog the webmaster';
                break;
        }
    }
    return $err;
}
Exemplo n.º 2
0
function scan($dir)
{
    global $skipping, $startFile, $accountId, $accounts, $basePath;
    $cdir = scandir($dir);
    foreach ($cdir as $key => $value) {
        if (!in_array($value, [".", ".."])) {
            if (is_dir($dir . DIRECTORY_SEPARATOR . $value)) {
                if (!$skipping) {
                    if (!isset($accounts[$accountId])) {
                        echo "Account #{$accountId} not exitst!\n\n";
                        return;
                    }
                    $EMAIL = $accounts[$accountId]['email'];
                    $PASS = $accounts[$accountId]['pass'];
                    $relativeDir = str_replace($basePath, '', $dir . DIRECTORY_SEPARATOR . $value);
                    `/usr/bin/megamkdir -u "{$EMAIL}" -p "{$PASS}" /Root/{$relativeDir}`;
                }
                scan($dir . DIRECTORY_SEPARATOR . $value);
            } else {
                if ($skipping) {
                    if ($startFile == $dir . DIRECTORY_SEPARATOR . $value) {
                        $skipping = false;
                        //                        processFile($dir . DIRECTORY_SEPARATOR .$value);
                    }
                    continue;
                }
                processFile($dir . DIRECTORY_SEPARATOR . $value);
            }
        }
    }
}
Exemplo n.º 3
0
function process($xml)
{
    /* load xsl*/
    $filter = true;
    //remember edit on js file
    if ($filter) {
        $xmlSession = $_SESSION["process"];
        //$xmlSession = simplexml_load_string($xmlSession);
        $xml = new DOMDocument();
        $xml->loadXML($xmlSession);
        $fileXSLPath = $GLOBALS["fileXSL_process"];
        $xslDoc = new DomDocument();
        $xslDoc->load($fileXSLPath);
        //combine xsl into xml
        $proc = new XSLTProcessor();
        $proc->importStyleSheet($xslDoc);
        $xmlTrans = $proc->transformToXML($xml);
        $xmlTrans = simplexml_load_string($xmlTrans);
        $resultXml = $xmlTrans->saveXML();
        processFile($xml);
        echo $resultXml;
    } else {
        echo $xml->saveXML();
        //way 2
        //echo $xml->asXML();
    }
}
Exemplo n.º 4
0
function processComponent($vendor, $component, $version, $dir = '')
{
    global $sqlite;
    $res = $sqlite->query(<<<SQL
SELECT versions.version AS version, components.id AS id FROM components 
        JOIN versions 
            ON versions.component_id = components.id
        WHERE vendor='{$vendor}' AND 
              component = '{$component}'
        ORDER BY versions.version DESC
SQL
);
    $res = $res->fetchArray(SQLITE3_ASSOC);
    if ($res) {
        $componentId = $res['id'];
        print substr("{$vendor}/{$component}" . str_repeat(' ', 50), 0, 50) . "{$version} / {$res['version']}\n";
        //        continue;
    } else {
        $date = time();
        $sqlite->query("INSERT INTO components (vendor, component, last_check) VALUES ('{$vendor}', '{$component}', {$date});");
        $componentId = $sqlite->lastInsertRowID();
        print "{$vendor}/{$component} newly inserted in reference ({$componentId})\n";
    }
    print "Reading {$vendor}/{$component} versions\n";
    $res = shell_exec('composer show ' . $vendor . '/' . $component);
    // remove colors
    $res = preg_replace('/\\x1B\\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]/s', '', $res);
    if (!preg_match_all("#versions : (.*?)\n#s", $res, $r)) {
        // Probably an error : ignoring the rest.
        print "Can't read {$vendor}/{$component} profile\n ";
        print_r($res);
        return;
    }
    $versions = explode(', ', $r[1][0]);
    if ($version == 'latest') {
        foreach ($versions as $v) {
            if (preg_match('/^\\d+\\.\\d+\\.\\d+$/', $v)) {
                break 1;
            }
        }
        // taking the last version used. This way, we always have a default value
        $version = $v;
    }
    $res = shell_exec('composer show ' . $vendor . '/' . $component . ' "' . $version . '" 2>&1');
    if (!preg_match_all("#versions : (.*?)\n#s", $res, $r)) {
        print 'composer show ' . $vendor . '/' . $component . ' "' . $version . '" 2>&1' . "\n";
        print_r($res);
        die;
    }
    $solvedVersions = explode(', ', $r[1][0]);
    foreach ($solvedVersions as &$sv) {
        if ($sv[0] == 'v') {
            $sv = substr($sv, 1);
        }
    }
    unset($sv);
    foreach ($versions as $v) {
        if ($v[0] == 'v') {
            $v = substr($v, 1);
        }
        $sqlite->query("INSERT OR IGNORE INTO versions (component_id, version) VALUES ({$componentId}, '{$v}');");
        if (in_array($v, $solvedVersions)) {
            // needsa a reading
            $res = $sqlite->query("SELECT id FROM versions WHERE component_id = {$componentId} AND version= '{$v}';");
            $versionId = $res->fetchArray(SQLITE3_ASSOC)['id'];
        }
    }
    if (empty($versionId)) {
        print "Couldn't find versions for '{$v}'\n";
        print "SELECT id FROM versions WHERE component_id = {$componentId} AND version= '{$v}';\n{$version} requested\n";
        die;
    }
    if ($dir === '') {
        print "Fetching {$vendor}/{$component}\n";
        $composer = new stdClass();
        $composer->require = new stdClass();
        $composer->require->{$vendor . '/' . $component} = $version;
        $json = json_encode($composer);
        $tmpdir = tempnam(sys_get_temp_dir(), 'exComposer');
        unlink($tmpdir);
        mkdir($tmpdir, 0755);
        file_put_contents($tmpdir . '/composer.json', $json);
        print shell_exec("cd {$tmpdir}; composer update 2>&1");
        print $tmpdir . '/vendor/' . $vendor . '/' . $component . "\n";
    } else {
        $tmpdir = $dir;
        print "Reusing dir {$tmpdir}\n";
    }
    $files = recursiveReaddir($tmpdir . '/vendor/' . $vendor . '/' . $component);
    $all = array();
    foreach ($files as $file) {
        $all[] = processFile($file);
    }
    $all = call_user_func_array('array_merge_recursive', $all);
    print "{$vendor}/{$component} / {$version} ({$componentId} / {$versionId})\n";
    $namespacesIds = array();
    foreach ($all as $type => $objects) {
        foreach (array_keys($objects) as $ns) {
            if (!isset($namespacesIds[$ns])) {
                $ns = $sqlite->escapeString($ns);
                $res = $sqlite->query("SELECT id FROM namespaces WHERE version_id = '{$versionId}' AND namespace = '{$ns}'");
                $nsid = $res->fetchArray(SQLITE3_ASSOC)['id'];
                if ($nsid) {
                    $namespacesIds[$ns] = $nsid;
                } else {
                    $sqlite->query("INSERT INTO namespaces (version_id, namespace) VALUES ('{$versionId}', '{$ns}');");
                    $namespacesIds[$ns] = $sqlite->lastInsertRowID();
                    print "Insertion du namespace '{$ns}'\n";
                }
            }
        }
    }
    if (isset($all['Class'])) {
        foreach ($all['Class'] as $ns => $classes) {
            foreach ($classes as $class) {
                // ignore classes with strange characters
                if (preg_match('/[^a-z0-9_\\\\]/i', $class)) {
                    continue;
                }
                $res = $sqlite->query("SELECT id FROM classes WHERE namespace_id = '{$namespacesIds[$ns]}' AND classname = '{$class}'");
                $nsid = $res->fetchArray(SQLITE3_ASSOC)['id'];
                if (!$nsid) {
                    $sqlite->query("INSERT INTO classes (namespace_id, classname) VALUES ('{$namespacesIds[$ns]}', '{$class}');");
                    print "Insertion de la classe '{$class}'\n";
                }
            }
        }
    }
    if (isset($all['Interface'])) {
        foreach ($all['Interface'] as $ns => $interfaces) {
            foreach ($interfaces as $interface) {
                $res = $sqlite->query("SELECT id FROM interfaces WHERE namespace_id = '{$namespacesIds[$ns]}' AND interfacename = '{$interface}'");
                $nsid = $res->fetchArray(SQLITE3_ASSOC)['id'];
                if (!$nsid) {
                    $sqlite->query("INSERT INTO interfaces (namespace_id, interfacename) VALUES ('{$namespacesIds[$ns]}', '{$interface}');");
                }
            }
        }
    }
    if (isset($all['Trait'])) {
        foreach ($all['Trait'] as $ns => $traits) {
            foreach ($traits as $trait) {
                $res = $sqlite->query("SELECT id FROM traits WHERE namespace_id = '{$namespacesIds[$ns]}' AND traitname = '{$trait}'");
                $nsid = $res->fetchArray(SQLITE3_ASSOC)['id'];
                if (!$nsid) {
                    $sqlite->query("INSERT INTO traits (namespace_id, traitname) VALUES ('{$namespacesIds[$ns]}', '{$trait}');");
                }
            }
        }
    }
    if ($dir === '' && file_exists($tmpdir . '/composer.lock')) {
        $installed = json_decode(file_get_contents($tmpdir . '/composer.lock'));
        if (!isset($installed->packages)) {
            print "{$file} has a pb with composer.lock\n";
            var_dump($installed);
            die;
        }
        foreach ($installed->packages as $package) {
            list($subVendor, $subComponent) = explode('/', $package->name);
            if ($package->version[0] == 'v') {
                $package->version = substr($package->version, 1);
            }
            print " + {$subVendor} / {$subComponent} " . $package->version . "\n";
            processComponent($subVendor, $subComponent, $package->version, $tmpdir);
        }
    }
}
Exemplo n.º 5
0
$col['Offices'] = '005c84';
$col['Stores'] = '0098c3';
$col['Tourism'] = 'abc785';
$col['Restaurants-and-Hotels'] = '6a4061';
$col['Transportation'] = '9b6e51';
$col['Media'] = '91baa3';
$col['Events'] = '983222';
$col['Culture-and-Entertainment'] = 'd490a8';
$col['Health'] = 'c60c30';
$col['Sports'] = 'dd4814';
$col['Education'] = 'f0ab00';
*/
//while (false !== ($file = readdir($handle))) {
//}
error_reporting(0);
processFile($argv[1], $argv[2]);
function processFile($category, $file)
{
    echo "Processing {$file} in category {$category}.\n";
    global $cat;
    global $col;
    global $argv;
    if ($argv[3] == 'nt') {
        $notail = true;
    }
    if ($argv[3] == 'ntw') {
        $notail = true;
        $wide = true;
    }
    $color = $col[$category];
    @mkdir($category . '/');
Exemplo n.º 6
0
$url = 'http://localhost:9000/post.php';
$token = "nesmar";
$app = new \Slim\Slim();
$app->get('/getFiles', function () use($app) {
    return validateToken($app->request->headers['TOKEN'], $app, $token) === true ? getFiles() : validateToken($app->request->headers['TOKEN'], $app, $token);
});
//Accept files to process from Netsuite
$app->post('/setToAccomplish', function () use($app) {
    $data = file_get_contents("php://input");
    //$data = json_encode($data, dio_truncate(fd, offset));
    $data = (array) json_decode($data);
    $client = new Client();
    //print_r($data);
    foreach ($data['po'] as $file) {
        echo $file . "<br/>";
        $client->post($url, ['body' => [json_encode(processFile($file))]]);
    }
    exit;
});
$app->post('/setDone:id', function ($id) {
    setDone($id);
});
$app->run();
function getFiles()
{
    $fs = new Filesystem();
    $dir = $fs->directories('../Repo');
    $array_of_files = [];
    foreach ($dir as $directories) {
        $files = $fs->files($directories);
        foreach ($files as $file) {
Exemplo n.º 7
0
    if ($in == 0) {
        $program = processFile($_FILES['program']);
        $poster = processFile($_FILES['poster']);
        $query = "Insert into events (eventName, startTime, endTime, program, pictures, summary, poster) VALUES ('" . $name . "','" . $startTime . "','" . $endTime . "','" . $program . "','" . $pictures . "','" . $summary . "','" . $poster . "');";
    } else {
        $query = 'Select * from events where eventId="' . $in . '";"';
        $result = mysql_query("{$query}", $abc);
        $row = mysql_fetch_array($result);
        if ($_FILES['poster']['name'] != '') {
            unlink($row['poster']);
        }
        if ($_FILES['program']['name'] != '') {
            unlink($row['program']);
        }
        $program = processFile($_FILES['program']);
        $poster = processFile($_FILES['poster']);
        $query = "Update events Set eventName='" . $name . "', startTime='" . $startTime . "', endTime='" . $endTime . "', program='" . $program . "', pictures='" . $pictures . "', summary='" . $summary . "', poster='" . $poster . "' where eventId='" . $in . "';";
    }
    echo $query;
    if (!$mysqli->query($query)) {
        $text = "Hiba az adatbázisba mentéskor. " . $mysqli->error();
    } else {
        header("Location: eventlist.php");
        exit;
    }
}
?>
<HTML xmlns="http://www.w3.org/1999/xhtml">
<HEAD>
<META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=utf-8">
<TITLE>Párbeszéd egy Élhetőbb Jövőért</TITLE>
Exemplo n.º 8
0
            processFile(1, $path, $path, $scoringMethod, $substringLength, $snortFile);
        } else {
            if (isset($_POST['network'])) {
                $ip = $_POST['ip'];
                $user = $_POST['user'];
                $pass = $_POST['pass'];
                $path = $_POST['path'];
                $netPath = "//" . $ip . ($path[0] == "/" ? $path : "/" . $path);
                $parts = explode("/", $path);
                //get our path element parts
                $fileName = array_pop($parts);
                $path = implode("/", $parts);
                //rebuild our path
                $netPath = "//" . $ip . ($path[0] == "/" ? $path : "/" . $path) . ($path[strlen($path) - 1] == "/" ? "" : "/");
                $path = openShare($ip, $user, $pass, $path) . $fileName;
                processFile(1, $path, $netPath, $scoringMethod, $substringLength, $snortFile);
                closeShare();
            }
        }
    }
}
?>
	<div id="page">
		<div id="content">
		  <div class="post">
				<div class="entry">
				
				<h2 class="title">Process Network File</a></h2>
					<form action="inputFile.php" method="post">
						<table>
						<tr><td><b>IP Address: </b></td<td><input type="text" id="ip" name="ip"/></td>
Exemplo n.º 9
0
<?php

//written by Shannon Klett & Lexi Flynn
require_once "../connection.php";
require_once "groupFunctions.php";
require_once "../uploadFile.php";
require_once "../util.php";
//Get parameters from frontend
$groupID = $_POST['groupID'];
// reads in file and returns an array of contents, one for each non-empty line
// each element should be the userID of a user to be added to the group
$fileLines = processFile();
if (!$fileLines) {
    //error occured with file upload
    http_response_code(400);
    //Bad request
    die;
}
// array of group info containing (addHrsType, hours, hasBookingDurationRestriction, startDate, endDate)
$groupInfo = getGroupInfo($db, $groupID);
$specialHrs = 0;
if (strcmp($groupInfo['addHrsType'], "special") == 0) {
    $specialHrs = $groupInfo['hours'];
}
$insertString = "";
$curWeekUpdateString = "";
$nextWeekUpdateString = "";
$restUpdateString = "";
//Array to hold users being added (error-free)
$usersAddedArray = array();
//Array holding users + info to be added to permission table
Exemplo n.º 10
0
$db = mysql_connect("localhost", "root", "qu-cg123");
if (!$db) {
    die('Could not connect: ' . mysql_error());
}
mysql_select_db("sams", $db);
$sql = "select device_id,sales_id,customer_id,status from product where product_id='" . $_POST["product_id"] . "'";
$result = mysql_query($sql, $db);
if (mysql_num_rows($result) <= 0) {
    echo makeRetHtml("数据提交失败!您的产品序列号不正确。", false);
    die(1);
}
$myrow = mysql_fetch_array($result);
$filename1 = processFile($_FILES["file1"]["error"], $_FILES["file1"]["type"], $_FILES["file1"]["size"], $_FILES["file1"]["tmp_name"]);
$filename2 = processFile($_FILES["file2"]["error"], $_FILES["file2"]["type"], $_FILES["file2"]["size"], $_FILES["file2"]["tmp_name"]);
$filename3 = processFile($_FILES["file3"]["error"], $_FILES["file3"]["type"], $_FILES["file3"]["size"], $_FILES["file3"]["tmp_name"]);
$filename4 = processFile($_FILES["file4"]["error"], $_FILES["file4"]["type"], $_FILES["file4"]["size"], $_FILES["file4"]["tmp_name"]);
$sql = "SET CHARACTER_SET_CONNECTION=utf8";
$result = mysql_query($sql, $db);
$sql = "SET CHARACTER_SET_CLIENT=utf8";
$result = mysql_query($sql, $db);
$sql = "insert into feedback (customer_id,sales_id,device_id,feedback,filename1,filename2,filename3,filename4) values('" . $myrow["customer_id"] . "','" . $myrow["sales_id"] . "','" . $myrow["device_id"] . "','" . $_POST["feedback"] . "','" . $filename1 . "','" . $filename2 . "','" . $filename3 . "','" . $filename4 . "');";
$result = mysql_query($sql, $db);
echo makeRetHtml("数据提交成功!感谢您的支持!", false);
mysql_close($db);
function randString($len)
{
    $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz';
    // characters to build the password from
    $string = '';
    for (; $len >= 1; $len--) {
        $position = rand() % strlen($chars);
Exemplo n.º 11
0
            $result[$sections[$j]] = $values[$j];
        } else {
            $result[] = $values[$j];
        }
    }
    return $result + $globals;
}
function processFile($from, $to)
{
    echo "Processing " . basename($from) . "...\n";
    $raw_data = parse_ini_file_php($from, false, false);
    $out = '';
    foreach ($raw_data as $key => $line) {
        $out .= $key . '="';
        $out .= str_replace('"', '', $line);
        // I hate myself, I hate Joomla! for relying on the f*cking PHP INI parser :(
        $out .= "\"\n";
    }
    echo ">>> {$to}\n";
    file_put_contents($to, $out);
}
$base_path = dirname(__FILE__) . DS . '..' . DS . 'translations';
$target_base = dirname(__FILE__);
$files = scanDirectory($base_path . DS . 'backend');
foreach ($files as $file) {
    processFile($file, $target_base . DS . 'backend' . DS . basename($file));
}
$files = scanDirectory($base_path . DS . 'frontend');
foreach ($files as $file) {
    processFile($file, $target_base . DS . 'frontend' . DS . basename($file));
}
Exemplo n.º 12
0
if (isset($_POST['product'])) {
    $product = (array) json_decode(base64_decode($_POST['product']));
    if ($field = Submission::checkFields(array("name", "price", "description", "available"), $product)) {
        die(Submission::createResult(ucfirst($field) . " is missing or invalid"));
    } else {
        if (!isset($_FILES) || ($field = Submission::checkFields(array("bigimage", "productfile"), $_FILES))) {
            die(Submission::createResult(ucfirst($field) . " is missing or invalid"));
        }
    }
    $imagePath = null;
    $bigImagePath = null;
    $productPath = null;
    if (($res = processImages("bigimage", $imagePath, $bigImagePath)) || is_null($imagePath) || is_null($bigImagePath)) {
        die(Submission::createResult("Failed to process image -> " . $res));
    }
    if (($res = processFile("productfile", $productPath)) || is_null($productPath)) {
        die(Submission::createResult("Failed to process Product File -> " . $res));
    }
    if (floatval($product['price']) == 0) {
        die(Submission::createResult("Price can not be 0"));
    }
    $soldOut = intval($product['available']) == 0 ? 1 : 0;
    $insert = DbManager::i()->insert("sf_products", array("name", "price", "description", "available", "image", "bigimage", "file", "soldOut"), array($product['name'], floatval($product['price']), $product['description'], intval($product['available']), $imagePath, $bigImagePath, $productPath, $soldOut));
    if ($insert) {
        Logger::i()->writeLog("Added Product successfully");
        echo Submission::createResult("Product added successfully", true);
    } else {
        Logger::i()->writeLog("Could not add product. error = " . DbManager::i()->error, 'dev');
        echo Submission::createResult("Could not add product");
    }
    unset($product);
Exemplo n.º 13
0
             return false;
         }
         foreach ($valid_files as $file) {
             $zip->addFile($file, $file);
         }
         //debug
         //echo 'The zip archive contains ',$zip->numFiles,' files with a status of ',$zip->status;
         $zip->close();
         return file_exists($destination);
     } else {
         return false;
     }
 }
 $folder = $_POST['destino'] . "/";
 $source = processFile($_FILES['source']);
 $bg = processFile($_FILES['bg']);
 $dir = 'resultado/' . $folder . '';
 $formato = array($_POST['ancho'], $_POST['alto']);
 $archivos = array();
 if (!file_exists($dir)) {
     mkdir($dir, 0777, true);
 }
 $arr = getNombres($source);
 $cont = 0;
 $pos = array('x' => $_POST['posx'] ? $_POST['posx'] : 40, 'y' => $_POST['posy'] ? $_POST['posy'] - 10 : 40);
 switch ($_POST['textAlign']) {
     case 'C':
         $pos['x'] = $pos['x'] - 20;
         break;
     case 'R':
         $pos['x'] = $pos['x'] - 40;
Exemplo n.º 14
0
    $content = file_get_contents($path);
    $lines = explode("\n", $content);
    $header = explode(VALUE_SEPARATOR, $lines[0]);
    //for($i = 0; $i < count($header); $i++)
    //	echo $header[$i] . "<br>";
    //echo $content;
    for ($i = 1; $i < count($lines); $i++) {
        $oneLine = explode(VALUE_SEPARATOR, addslashes($lines[$i]));
        $supplierID = getSupplierID($oneLine[0]);
        $categoryID = getCategoryID($oneLine[1]);
        $producyTypeID = getProductTypeID($oneLine[2]);
        $producyID = getProduct($supplierID, $categoryID, $producyTypeID, $oneLine[3], $oneLine[4], $oneLine[5], $oneLine[6]);
        /*
        echo "$oneLine[0] ($supplierID)<br>";
        echo "$oneLine[1] ($categoryID)<br>";
        echo "$oneLine[2] ($producyTypeID)<br>";
        echo "$oneLine[3] ($producyID)<br>";
        */
    }
    echo "<hr>\n\n";
}
resetDatabase();
if ($handle = opendir(DIR_PATH)) {
    while (false !== ($file = readdir($handle))) {
        if (is_file(DIR_PATH . "/" . $file)) {
            processFile(DIR_PATH . "/" . $file);
        }
    }
    closedir($handle);
}
echo "totalProducts = {$totalProducts} <br>totalCategories={$totalCategories}<br>totalProductType={$totalProductType}<br>totalSuppliers={$totalSuppliers}";
Exemplo n.º 15
0
    return validateToken($app->request->headers['TOKEN'], $app) === true ? getSyncFiles($data['date'], $data['store']) : validateToken($app->request->headers['TOKEN'], $app);
});
//Accept files to process from Netsuite
$app->post('/setToAccomplish', function () use($app) {
    logMessage("Accepted Request: setToAccomplish " . date('m/d/Y h:i:s') . ".\n");
    //log something
    $data = file_get_contents("php://input");
    //$data = json_encode($data, dio_truncate(fd, offset));
    $data = (array) json_decode($data);
    $client = new Client();
    //print_r($data);
    foreach ($data['po'] as $file) {
        echo $file . "<br/>";
        logMessage("Send Request: http://localhost:9000/post.php " . date('m/d/Y h:i:s') . ".\n");
        //log something
        $client->post('http://localhost:9000/post.php', ['body' => [json_encode(processFile($file))]]);
    }
    exit;
});
$app->post('/setDone/:id', function ($id) {
    logMessage("Accepted Request: setDone " . date('m/d/Y h:i:s') . ".\n");
    //log something
    setDone($id);
});
$app->run();
function getFiles()
{
    $fs = new Filesystem();
    $dir = $fs->directories('../Repo');
    $array_of_files = [];
    foreach ($dir as $directories) {
Exemplo n.º 16
0
/**
 * Crawl a directory a process each file found.
 * 
 * Used by folderPath.php
 * 
 * @param $startingDirectory - the directory to begin crawling for files (will be the local mounted directory ("/mnt/share"))
 * @param $netPath - used to store the actual location in the database, instead of using the local mounted directory ("/mnt/share")
 * @param $includeSubfolders - binary variable that if true will include sub folders
 * @param $scoringMethod - the scoring method chosen (i.e. histogram, random, etc.)
 * @param $substringLength - length of the substring from the config table
 * @param $snortFile - location of the snort file from the config table
 */
function processFolder($startingDirectory, $netPath, $includeSubfolders, $scoringMethod, $substringLength, $snortFile)
{
    if ($dObj = dir($startingDirectory)) {
        while ($thisEntry = $dObj->read()) {
            if ($thisEntry != "." && $thisEntry != "..") {
                $path = "{$startingDirectory}{$thisEntry}";
                //process the file we found
                if (!is_dir($path)) {
                    processFile(2, $path, $netPath, $scoringMethod, $substringLength, $snortFile);
                    //if the found file is not a directory, process it
                }
                // If we are processing subdirectories and the entry is a directory, recursively call our function on it
                if ($includeSubfolders && is_dir($path)) {
                    $netPathTemp = ($netPath[strlen($netPath) - 1] == "/" ? $netPath : $netPath . "/") . $thisEntry . "/";
                    //gets the new path to add to the db
                    processFolder($path . "/", $netPathTemp, $includeSubfolders, $scoringMethod, $substringLength, $snortFile);
                }
            } else {
                //ignore "." and ".." to prevent an infinite loop
            }
        }
    }
}
Exemplo n.º 17
0
}
//  Display the output
if ($total > 0) {
    if ($all_files === false && $single_file === false) {
        displayFileTotal();
        displayFileList();
    } else {
        if ($single_file !== false) {
            displaySingleFile($single_file);
            processFile($single_file, false);
            displaySummary();
        } else {
            if ($all_files !== false) {
                displayFileTotal();
                foreach ($filelist as $key => $value) {
                    processFile($value, true);
                }
                displaySummary();
            }
        }
    }
} else {
    displayNoFilesFound();
}
function displayNoFilesFound()
{
    global $input_dir;
    echo "<p>No ActionScript files found in {$input_dir} or folder doesn't exist.</p>";
    echo "<p>Please copy some across and <a href=\"index.php\">refresh this page</a>.</p>";
}
function displayFileTotal()
    $dir = substr($ballot_set_name, -3);
    $filepath = $basedir . '/' . $dir . '/' . $ballot_set_name . '.json';
    if (is_file($filepath)) {
        $contents = file_get_contents($filepath);
        if ('-' != $contents) {
            $files[] = $filepath;
        }
    }
}
print "\"total condorcet prob\",filename,approval,borda,stv\n";
foreach ($files as $file) {
    $data = json_decode(file_get_contents($file), 1);
    $cprob = condProb($data);
    //if ($cprob) {
    print "{$cprob},";
    print join(',', processFile($file));
    print "\n";
    //}
}
function processFile($file)
{
    $res = array();
    $res[] = $file;
    $data = json_decode(file_get_contents($file), 1);
    foreach (array('approv', 'borda', 'stv') as $method) {
        $res[] = calculateProb($data, $method);
    }
    return $res;
}
function condProb($data)
{
Exemplo n.º 19
0
                    $error = array("success" => "false", "message" => mysql_errno());
                    echo json_encode($error);
                } else {
                    $response = array("success" => "true", "results" => array("id" => $inserted));
                    echo json_encode($response);
                }
            }
        }
    }
    $request_body = file_get_contents('php://input');
    $_POST = json_decode($request_body, false);
    $db->connect();
    if (is_array($_POST)) {
        processFiles($_POST);
    } else {
        processFile($_POST);
    }
    $db->close();
} elseif ($_SERVER["REQUEST_METHOD"] == "DELETE") {
    $request_body = file_get_contents('php://input');
    $_DELETE = json_decode($request_body, true);
    if (!isset($_DELETE["appid"])) {
        $error = array("senchafiddle" => array("error" => "App id is required."));
        echo json_encode($error);
        exit(0);
    }
    if (!isset($_DELETE["name"])) {
        $error = array("senchafiddle" => array("error" => "File name is required."));
        echo json_encode($error);
        exit(0);
    }