예제 #1
0
function addDir($phar, $sDir, $baseDir = null)
{
    $oDir = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($sDir), RecursiveIteratorIterator::SELF_FIRST);
    foreach ($oDir as $sFile) {
        if (preg_match('/\\.php$/i', $sFile)) {
            addFile($phar, $sFile, $baseDir);
        }
    }
}
예제 #2
0
/**
 * Add a directory in phar removing whitespaces from PHP source code
 *
 * @param Phar $phar
 * @param string $sDir
 */
function addDir($phar, $sDir, $baseDir = null)
{
    $oDir = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($sDir), RecursiveIteratorIterator::SELF_FIRST);
    $allowedExtensions = array('php', 'phtml', 'xsd', 'xml', 'properties');
    foreach ($oDir as $sFile) {
        if (in_array(pathinfo($sFile, PATHINFO_EXTENSION), $allowedExtensions)) {
            addFile($phar, $sFile, $baseDir);
        }
    }
}
function addFilesInDir($dir, $handleRequire = false, $recursive = false)
{
    $files = scandir($dir);
    foreach ($files as $file) {
        if (substr($file, 0, 1) == '.') {
            continue;
        }
        if (substr($file, -4, 4) != '.php') {
            continue;
        }
        addFile($dir . $file, false, $handleRequire);
    }
}
예제 #4
0
파일: tune.php 프로젝트: bjurban/Autotune
case 2: input only is provided
	combine both inputs
case 3: files and input are provided
	combine if compatible, otherwise keep file
	
compatible - both contain the same number of rows
*/
$dateTimeNeeded = true;
if ($eFile && isCompatible($eFile, $uDataArray)) {
    addFile($eFile, $uDataArray, $dateTimeNeeded);
}
if ($gFile && isCompatible($gFile, $uDataArray)) {
    addFile($gFile, $uDataArray, $dateTimeNeeded);
}
if ($tFile && isCompatible($tFile, $uDataArray)) {
    addFile($tFile, $uDataArray, $dateTimeNeeded);
}
if ($dateTimeNeeded && ($energyFilledOut || $gasFilledOut)) {
    addMonthlyCol(12, $uDataArray);
}
$monthlyCompatible = numRows($uDataArray) == 13 || numRows($uDataArray) == 0;
// 12 months + 1 header, or no files have been added
if ($energyFilledOut && $monthlyCompatible && !$eFile) {
    addEnergyUsage($energyUsages, $uDataArray);
}
//if($gasFilledOut && $monthlyCompatible && !$gFile) addGasUsage($gasUsages, $uDataArray);
$userData = createSpreadsheet($uDataArray);
//Get parameter file contents
include 'paramMatch.php';
$paramFileName = getParamFileName($model);
$paramContents = file_get_contents($paramFileName);
예제 #5
0
function PackDir($dira = '')
{
    $current_dir = getcwd();
    if ($dira != '') {
        chdir($dira);
    }
    $row = array();
    foreach (glob("*") as $file) {
        $row[] = $file;
    }
    chdir($current_dir);
    for ($a = 0; $a < count($row); $a++) {
        if ($row[$a] != "." && $row[$a] != "..") {
            if ($dira != '') {
                if (is_dir($dira . "/" . $row[$a])) {
                    PackDir($dira . "/" . $row[$a]);
                } else {
                    addFile($dira . "/" . $row[$a]);
                }
            } else {
                if (is_dir($row[$a])) {
                    PackDir($row[$a]);
                } else {
                    addFile($row[$a]);
                }
            }
        }
    }
}
예제 #6
0
        $db = null;
        header("Content-type:application/json; charset=utf-8");
        $msg007 = "The input was saved (time";
        // 入力を保存しました(時刻
        echo json_encode(array('success' => true, 'msg' => \Sop\Api::htmlEncodeLines(array('{$msg007} ' . date('H:i:s') . ')')), 'file_id' => $file_id, 'div' => 'upd'));
        exit;
    }
}
// ---------------------------
// DB 登録 更新
// ---------------------------
$db->beginTransaction();
if ($div == 'add') {
    // --- TBL: file
    $file_id = -1;
    $rslt = addFile($db, $file_id, $pj_id, $sop_id, $tpl_id, $schema_id, $schema_type, $smpl_given_no, $FILE_STATUS_INP, $date, $user_id, $user_id_2, $request_time, $seq_no);
    if (!$rslt) {
        \Sop\Log::error(__FILE__, __LINE__, 'Failed to add file.');
        $msg008 = "The registration failed.: file";
        // 登録に失敗しました: file"
        \Sop\Api::exitWithError(array($msg008));
    }
    $file_id = getLastId($db);
    // --- TBL: val
    $val_id = -1;
    foreach ($_REQUEST as $val_name => $value) {
        if (strpos($val_name, 'input_') !== false) {
            $value = urldecode($value);
            $rslt = addVal($db, $val_id, $file_id, $val_name, $value);
            if (!$rslt) {
                \Sop\Log::error(__FILE__, __LINE__, 'Failed to add val.');
예제 #7
0
function addDir($dirname, $mask)
{
    $dirhandle = @opendir($dirname);
    if (!$dirhandle) {
        echo "Cannot open directory \"{$dirname}\".";
        exit;
    }
    while ($folderentry = readdir($dirhandle)) {
        if ($folderentry[0] != '.' && !is_dir("{$dirname}/{$folderentry}")) {
            if (preg_match($mask, $folderentry)) {
                addFile("{$dirname}/{$folderentry}", $folderentry);
            }
        }
    }
    closedir($dirhandle);
}
예제 #8
0
function addPendingFile($folderId, $filePath, $fileSize, $dropFolderPlugin)
{
    $file = addFile($folderId, $filePath, $fileSize, $dropFolderPlugin);
    updateFile($file->id, $fileSize, $filePath, $dropFolderPlugin);
    return $file;
}
예제 #9
0
 /**
  * @test
  */
 public function shouldReturnNullWhenFileInfoIsEmpty()
 {
     //when
     $file = addFile();
     //then
     $this->assertNull($file);
 }
예제 #10
0
        echo "{$key} - {$path}\n";
    }
    $phar[$key] = file_get_contents($path);
}
$phar = new Phar(DEST_PATH, 0, 'terminus.phar');
$phar->startBuffering();
// PHP files
$finder = new Finder();
$finder->files()->ignoreVCS(true)->in('./assets')->in('./php')->in('./vendor')->in('./config')->exclude('test')->exclude('tests')->exclude('Tests')->exclude('php-cli-tools/examples');
foreach ($finder as $file) {
    addFile($phar, $file);
}
// Non-PHP Files
$finder = new Finder();
$finder->files()->ignoreVCS(true)->ignoreDotFiles(false)->in('./templates');
foreach ($finder as $file) {
    addFile($phar, $file);
}
addFile($phar, './vendor/autoload.php');
addFile($phar, './vendor/rmccue/requests/library/Requests/Transport/cacert.pem');
$phar->setStub(<<<EOB
#!/usr/bin/env php
<?php
Phar::mapPhar();
include 'phar://terminus.phar/php/boot-phar.php';
__HALT_COMPILER();
?>
EOB
);
$phar->stopBuffering();
echo "Generated " . DEST_PATH . "\n";
예제 #11
0
파일: replica2.php 프로젝트: wozzup/redbean
    addFile(DIR . 'Repository/Frozen.php');
    addFile(DIR . 'OODB.php');
    addFile(DIR . 'ToolBox.php');
    addFile(DIR . 'Finder.php');
    addFile(DIR . 'AssociationManager.php');
    addFile(DIR . 'BeanHelper.php');
    addFile(DIR . 'BeanHelper/SimpleFacadeBeanHelper.php');
    addFile(DIR . 'SimpleModel.php');
    addFile(DIR . 'SimpleModelHelper.php');
    addFile(DIR . 'TagManager.php');
    addFile(DIR . 'LabelMaker.php');
    addFile(DIR . 'Facade.php');
    addFile(DIR . 'DuplicationManager.php');
    addFile(DIR . 'Util/ArrayTool.php');
    addFile(DIR . 'Util/DispenseHelper.php');
    addFile(DIR . 'Util/Dump.php');
    addFile(DIR . 'Util/MultiLoader.php');
    addFile(DIR . 'Util/Transaction.php');
    addFile(DIR . 'Plugin.php');
    $func = file_get_contents(DIR . 'Functions.php');
    $code .= "\n\tnamespace {\n\n\t//make some classes available for backward compatibility\n\tclass RedBean_SimpleModel extends \\RedBeanPHP\\SimpleModel {};\n\n\tif (!class_exists('R')) {\n\t\tclass R extends \\RedBeanPHP\\Facade{};\n\t}\n\n\t{$func}\n\n\t}\n\t";
    $code = '<?php' . str_replace('<?php', '', $code);
    echo 'Okay, seems we have all the code.. now writing file: rb.php', PHP_EOL;
    $b = file_put_contents('rb.php', $code);
    echo 'Written: ', $b, ' bytes.', PHP_EOL;
    if ($b > 0) {
        echo 'Done!', PHP_EOL;
    } else {
        echo 'Hm, something seems to have gone wrong... ', PHP_EOL;
    }
}
예제 #12
0
            $f = fopen($_FILES['upl']['tmp_name'], 'r');
            $contents = fread($f, $size);
            fclose($f);
        }
    }
    if (!$error) {
        $result = getSize($conn, $_SESSION['id']);
        if (!is_numeric($result) || $result > $UPLOAD_LIMIT) {
            $error = "You cannot have more than 15 MB of uploaded content.";
        }
    }
    if (!$error) {
        $contents = $contents;
        $filename = basename($_FILES['upl']['name']);
        //make call to function that adds to db
        $error = addFile($conn, $filename, $_FILES['upl']['type'], $size, $contents, $_SESSION['id']);
        //disallow sql errors from showing
        if ($error) {
            $error = "There was a database error.";
        }
    }
}
$conn->close();
?>
<!doctype html>
<html>
<head>
<title>Upload - Mega File</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="application/x-javascript"> addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false); function hideURLbar(){ window.scrollTo(0,1); } </script>
예제 #13
0
파일: make.php 프로젝트: raykai/porter
<?php 
header('Content-Type: text/plain');
// Make the final vanilla2export.php file from the other sources.
$path = dirname(__FILE__) . '/vanilla2export.php';
if (file_exists($path)) {
    $r = unlink($path);
    if (!$r) {
        echo "Could not delete {$path}.\n";
        die;
    }
}
// Open the file.
echo "Opening {$path}\n";
$fp = fopen($path, 'w');
fwrite($fp, "<?php /* This file was automatically generated by make.php. DO NOT EDIT. */ ?>\n\n");
addFile($fp, 'index.php');
fclose($fp);
echo "Make Complete.\n";
/// Functions ///
function addFile($fp, $filename)
{
    // Recursively build file
    $contents = getFile($filename);
    // Include individual software porters (undo MAKESKIP)
    $paths = glob('packages/*.php');
    $exporters = '';
    foreach ($paths as $path) {
        $exporters .= getFile($path);
    }
    $contents = str_replace('// [EXPORTERS]', ' ?>' . $exporters . '<?php ', $contents);
    // Write the all-in-one file
예제 #14
0
파일: ws.php 프로젝트: alexlqi/sdk
$operdb = "rw";
include_once '../includes/class.modelo.php';
switch ($_POST["ctrl"]) {
    case 'putIncidencia':
        array_push($_POST, $_FILES);
        echo json_encode($_POST);
        break;
    case 'addFile':
        if (!empty($_FILES)) {
            //move_uploaded_file($_FILES["tmp_name"], destination)
            $archivo = $_FILES["file"];
            $files["uuid"] = strtoupper(UUID::v4());
            $files["name"] = $archivo["name"];
            $files["mime"] = $archivo["type"];
            $files["tmp_name"] = $archivo["tmp_name"];
            $r = addFile($files);
            $r["uuid"] = $files["uuid"];
            echo json_encode($r);
        }
        break;
    case 'delFile':
        $r = delFile($_POST["uuid"]);
        echo json_encode($r);
        break;
    default:
        # code...
        break;
}
function addFile($archivo)
{
    global $modelo;
예제 #15
0
session_start();
$root = '../';
include $root . 'includes.php';
$childDao = new ChildDAO(DynamoDbClientBuilder::get());
$email = $_POST['childEmail'];
$child = $childDao->get($email);
$fileName = $_POST['file'];
$adultEmail = $_POST['adultEmail'];
$type = $_POST['type'];
if (!empty($_POST['dateEnd'])) {
    $dateEnd = $_POST['dateEnd'];
    $dateStart = $_POST['dateStart'];
    echo $dateEnd . '  ' . $dateStart;
    echo 'FILENAME = ' . $fileName;
    addFile($fileName, $child, $dateStart, $dateEnd, $type, $adultEmail);
} else {
    deleteFile($child, $type, $adultEmail, $fileName);
}
//echo $child->getTeacherId();
echo $type . $adultEmail . $fileName;
function addFile($fileName, $child, $dateStart, $dateEnd, $type, $adultEmail)
{
    $content = new Content();
    $content->setName($fileName);
    $content->setEmailOwner($adultEmail);
    $content->setType($type);
    $child->addContent($content, $dateStart, $dateEnd);
    $childDao = new ChildDAO(DynamoDbClientBuilder::get());
    $childDao->update($child);
}
예제 #16
0
// hash of files where we can sort them by time:
//   - the key is epoch time from the filename (eg "Oct 15 2011")
//   - the value is the actual HTML to put into a list (hacky)
$ghFiles = array();
// Add files that are on the Internet Archive storage.
if (is_file("downloads/archived.json")) {
    $archived = json_decode(file_get_contents("downloads/archived.json"), true);
    foreach ($archived as $filename => $fileData) {
        if (array_key_exists('verified', $fileData) && $fileData['verified']) {
            addFile($ghFiles, $filename, $fileData['url'], $fileData['size']);
        }
    }
}
// Add files from the local directory (if any).
foreach (glob("downloads/httparchive_*.gz") as $filename) {
    addFile($ghFiles, $filename, $filename, filesize($filename));
}
// Given a dump file's info, create the HTML to be put in a list.
// Add it to hash of files passed in.
function addFile(&$hFiles, $filename, $url, $size)
{
    $epoch = dumpfileEpochTime($filename);
    if ($epoch) {
        if (!array_key_exists($epoch, $hFiles)) {
            $hFiles[$epoch] = array();
        }
        $browser = strpos($filename, "_mobile_") ? 'iPhone' : 'IE';
        if (strpos($filename, "_requests.csv")) {
            // There should be 4 files: _pages.gz, _pages.csv.gz, _requests.gz, _requests.csv.gz
            // If we see _requests.csv we assume the other 3 exist and format accordingly and
            // we'll overwrite any previously saved results.
예제 #17
0
function controlFile($id)
{
    $app = Slim\Slim::getInstance();
    $app->contentType('application/json');
    $server = $id[0];
    $path = implode("/", array_slice($id, 1));
    if (!$path) {
        $path = "/";
    } else {
        $path = "/" . $path;
    }
    $id = implode("/", $id);
    $file = getOption('root') . '/' . $id;
    $request = $app->request();
    $control = $request->getBody();
    $response = $app->response();
    $result = "error";
    if (is_file($file)) {
        switch ($control["command"]) {
            case "play":
                $result = play($file);
                break;
            case "add":
                $result = addFile($file);
                break;
            case "remove":
                $result = removeFile($file);
                break;
            default:
                $result = "illegal command";
                $response->status(400);
                break;
        }
    } else {
        if (is_dir($file)) {
            switch ($control["command"]) {
                case "play":
                    $result = playFolder($file);
                    break;
                case "add":
                    $result = addFolder($file);
                    break;
                case "remove":
                    $result = removeFolder($file);
                    break;
                case "search":
                    return search($server, "/_search/" . $control["value"]);
                default:
                    $result = "illegal command";
                    $response->status(400);
                    break;
            }
        } else {
            $response->status(404);
        }
    }
    $body = array();
    $body['command'] = $control["command"];
    $body['result'] = $result;
    echo json_encode($body);
}
예제 #18
0
 function query($str)
 {
     $T0 = microtime(true);
     $this->res = mysql_query($str, $this->link);
     $T1 = microtime(true) - $T0;
     if ($T1 > 0.05) {
         $str = str_replace("\n", ' ', $str);
         $str = str_replace("\r", ' ', $str);
         $str = str_replace("\t", ' ', $str);
         addFile(projectPath . '/db.log', date('d.m.Y H:i:s') . "\t" . number_format($T1, 8, ".", "") . "\t" . $str . "\n");
     }
     return $this->res;
 }
/**
 * Recursively traverses directories calling #addFile on each file encountered
 * @param $dir   string name of directory relative to PATH in the format 'some/directory/'; may be an empty string
 * @param $stmts array of prepared statements; see #getPreparedStatements for details
 * @param $options array of options; see declaration for details
 */
function addFiles($dir, array $stmts, array $options = array())
{
    $results = array('added' => array(), 'failed' => array());
    $path = PATH . $dir;
    if (is_dir($path)) {
        if ($dh = opendir($path)) {
            while (($file = readdir($dh)) !== false) {
                if ($file[0] === '.') {
                    continue;
                    // skips ., .., and hidden files and directories
                } elseif (is_dir($path . $file)) {
                    if (!empty($options['recursive'])) {
                        $results = array_merge_recursive($results, addFiles("{$dir}{$file}/", $stmts, $options));
                    }
                } elseif (addFile($dir, $file, $stmts, $options, $message)) {
                    $results['added'][] = "File: {$path}" . formatName($file) . $message;
                } else {
                    $results['failed'][] = "File: " . PATH . $dir . formatName($file) . $message;
                }
            }
            closedir($dh);
        }
    } elseif (is_file($path)) {
        $parts = explode('/', $dir);
        $file = array_pop($parts);
        $dir = implode('/', $parts);
        if (!empty($dir)) {
            $dir .= '/';
        }
        if (addFile($dir, $file, $stmts, $options, $message)) {
            $results['added'][] = "File: " . PATH . $dir . formatName($file) . $message;
        } else {
            $results['failed'][] = "File: " . PATH . $dir . formatName($file) . $message;
        }
    } else {
        $results['failed'][] = "Invalid file or directory: {$path}";
    }
    return $results;
}