Esempio n. 1
0
$request .= "&Signature=" . $signature;
$sporting_file = make_file('sporting', 18, "salesrank", $request);
// toys
$searchIndex = 'Baby';
$keyword = urlencode('おもちゃ');
$operation = 'ItemSearch';
$service = 'AWSECommerceService';
$version = '2011-08-01';
$responseGroup = 'ItemAttributes,Images';
$browseNode = 13299531;
// toys
$string_to_sign = build_request($keyword, $searchIndex, $operation, $service, $version, $responseGroup, 0, $browseNode);
$signature = get_signature($string_to_sign);
$request = $cg['amazonUrl'] . '?' . $string_to_sign;
$request .= "&Signature=" . $signature;
$toys_file = make_file('toys', 19, "salesrank", $request);
// watches
$searchIndex = 'Apparel';
$keyword = urlencode('腕時計');
$operation = 'ItemSearch';
$service = 'AWSECommerceService';
$version = '2011-08-01';
$responseGroup = 'ItemAttributes,Images';
$browseNode = 324025011;
// watches
$string_to_sign = build_request($keyword, $searchIndex, $operation, $service, $version, $responseGroup, 0, $browseNode);
$signature = get_signature($string_to_sign);
$request = $cg['amazonUrl'] . '?' . $string_to_sign;
$request .= "&Signature=" . $signature;
$watches_file = make_file('watches', 20, "salesrank", $request);
include $cg['viewdir'] . '/index_v.php';
Esempio n. 2
0
function new_config()
{
    #Begin creation of config.php
    $config = "<?php\n";
    #Define all the required variables for config.php
    $needed = array("os_ip", "os_pw", "pass_file", "cache_file", "log_file", "lang", "weather_provider", "wapikey");
    #Cycle through each needed key
    foreach ($needed as $key) {
        #If required variable is not submitted then fail
        if (!isset($_REQUEST[$key])) {
            fail();
        }
        $data = $_REQUEST[$key];
        #If processing OS IP then check if the IP is valid and if not, fail with error code 2
        if ($key == "os_ip") {
            if (!isValidUrl("http://" . $data)) {
                echo 2;
                exit;
            }
            $config .= "\$is_ospi = " . isOSPi("http://" . $data) . ";\n";
        }
        #If processing password file then go ahead and generate it with proper username/password hash
        if ($key == "pass_file") {
            #If username or password is not submitted fail
            if (!isset($_REQUEST["username"]) || !isset($_REQUEST["password"])) {
                fail();
            }
            $file = fopen($data, 'w');
            #If unable to open the pass file fail
            if (!$file) {
                fail();
            } else {
                $r = fwrite($file, $_REQUEST["username"] . ":" . base64_encode(sha1($_REQUEST["password"])));
                if (!$r) {
                    fail();
                }
                fclose($file);
            }
        }
        #Attempt to make the cache file and log file file
        if ($key == "cache_file" || $key == "log_file") {
            make_file($data);
        }
        #Append current key/data pair to config.php string.
        $config .= "\$" . $key . " = '" . $data . "';\n";
    }
    if (isset($_REQUEST["force_ssl"])) {
        $config .= "\$force_ssl=1;\n";
    } else {
        $config .= "\$force_ssl=0;\n";
    }
    if (isset($_REQUEST["local_assets"])) {
        $config .= "\$local_assets=1;\n";
    } else {
        $config .= "\$local_assets=0;\n";
    }
    #Attempt to open config.php for writing
    $file = fopen("config.php", 'w');
    #If unable, fail
    if (!$file) {
        fail();
    }
    #Write the config out
    $r = fwrite($file, $config . "?>");
    #If unable to write the config, fail
    if (!$r) {
        fail();
    }
    try {
        #Add the watcher for logs to crontab
        $output = shell_exec('crontab -l');
        if (strpos($output, "/watcher.php >/dev/null 2>&1") === false) {
            file_put_contents('/tmp/crontab.txt', $output . '* * * * * cd ' . dirname(__FILE__) . '; php ' . dirname(__FILE__) . '/watcher.php >/dev/null 2>&1' . PHP_EOL);
            exec('crontab /tmp/crontab.txt');
        }
    } catch (Exception $e) {
        echo 3;
        exit;
    }
    #Tell javascript action was succesful
    echo 1;
}
Esempio n. 3
0
make_file("../.htaccess", '<IfModule mod_rewrite.c>
	Options -MultiViews
	IndexIgnore *

	RewriteEngine On

	#Manager index.html
	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteRule ^manager/$ system/manager/index.html [L,QSA]

	#Manager files
	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteCond %{REQUEST_URI} !manager/api(.+)$
	RewriteRule ^manager(.+)$ system/manager$1 [L,QSA]

	#App assets
	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteRule ^assets(.+)$ app/assets$1 [L,QSA]

	#App public
	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteRule ^(.*)\\.(html|css|js|jpg|png|gif|ttf|eot|svg|woff|pdf) public/$1.$2 [QSA]

	#App public index.html
	RewriteRule ^$ public/index.html [QSA]

	#Routes
	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteRule ^(.+)$ index.php/$1 [L,QSA]

	#IE htc files
	AddType text/x-component .htc
</IfModule>', null, true);