예제 #1
0
    }
    return False;
}


if(array_key_exists("username", $_REQUEST) and array_key_exists("password", $_REQUEST)) {
    $link = mysql_connect('localhost', 'natas27', '<censored>');
    mysql_select_db('natas27', $link);


    if(validUser($link,$_REQUEST["username"])) {
        //user exists, check creds
        if(checkCredentials($link,$_REQUEST["username"],$_REQUEST["password"])){
            echo "Welcome " . htmlentities($_REQUEST["username"]) . "!<br>";
            echo "Here is your data:<br>";
            $data=dumpData($link,$_REQUEST["username"]);
            print htmlentities($data);
        }
        else{
            echo "Wrong password for user: "******"username"]) . "<br>";
        }
    }
    else {
        //user doesn't exist
        if(createUser($link,$_REQUEST["username"],$_REQUEST["password"])){
            echo "User " . htmlentities($_REQUEST["username"]) . " was created!";
        }
    }

    mysql_close($link);
} else {
예제 #2
0
    $dumpPaths = array('structure' => $tm->getDdlScript($table), 'data' => $tm->getDataScript($table));
    // Create parent directories
    foreach ($dumpPaths as $path) {
        if ($path) {
            FileSystem::createFilePath($path);
        }
    }
    $relPath = FileSystem::getRelativePath($workPath, $dumpPaths['structure']);
    echo "\n{$table} in {$relPath}: ";
    switch (dumpStructure($db, $table, $dumpPaths['structure'])) {
        case 0:
            echo "ok";
            break;
        case 1:
            echo "created";
            break;
        case 2:
            echo "updated";
            break;
    }
    if ($args->get('data')) {
        if ($dumpPaths['data'] === FALSE) {
            echo "\n   -> data dump skipped by config\n";
        } else {
            $relPath = FileSystem::getRelativePath($workPath, $dumpPaths['data']);
            echo "\n   -> data dumped in: {$relPath}\n";
            dumpData($db, $table, $dumpPaths['data']);
        }
    }
}
echo "\n\nDone :-)\n\n";
예제 #3
0
        $this->strategy = $strategy;
    }
    public function getItemData()
    {
        return $this->strategy->getData();
    }
}
/*
 * Client
 */
function dumpData($data)
{
    echo '<dl>';
    foreach ($data as $object) {
        echo '<dt>' . $object->item_name . '</dt>';
        echo '<dd>商品番号:' . $object->item_code . '</dd>';
        echo '<dd>\\' . number_format($object->price) . '-</dd>';
        echo '<dd>' . date('Y/m/d', $object->release_date) . '発売</dd>';
    }
    echo '</dl>';
}
// 固定長データを読み込む
$strategy1 = new ReadFixedLengthDataStrategy('fixed_length_data.txt');
$context1 = new ItemDataContext($strategy1);
dumpData($context1->getItemData());
echo '<hr>';
//タブ区切りデータを読み込む
$strategy2 = new ReadTabSeparatedDataStrategy('tab_separated_data.txt');
$context2 = new ItemDataContext($strategy2);
dumpData($context2->getItemData());
예제 #4
0
    }
    public final function __clone()
    {
        throw new RuntimeException('Clone is not allowed against ' . get_class($this));
    }
}
/**
 * Client Class
 */
function dumpData($data)
{
    echo '<dl>';
    foreach ($data as $object) {
        echo '<dt>' . htmlspecialchars($object->getName(), ENT_QUOTES, mb_internal_encoding()) . '</dt>';
        echo '<dd>商品番号:' . $object->getCode() . '</dd>';
        echo '<dd>\\' . number_format($object->getPrice()) . '-</dd>';
    }
    echo '</dl>';
}
$factory = ItemFactory::getInstance('data.txt');
$items = array();
$items[] = $factory->getItem('ABC0001');
$items[] = $factory->getItem('ABC0002');
$items[] = $factory->getItem('ABC0003');
if ($items[0] === $factory->getItem('ABC0001')) {
    echo '同一のオブジェクトです';
} else {
    echo '同一のオブジェクトではありません';
}
dumpData($items);