if (isset($parents[$sid])) {
            foreach ($parents[$sid] as $cid) {
                $structure[$sid][$cid] = array();
            }
        }
    }
    file_put_contents("data/" . $tweetid . "/structure.json", json_encode($structure));
    chmod("data/" . $tweetid . "/structure.json", 0777);
}
if (!isset($argv[1])) {
    exit(0);
}
$tweetid = $argv[1];
if (strstr($tweetid, "/")) {
    $tweetid = explode("/", $tweetid);
    $tweetid = $tweetid[count($tweetid) - 1];
}
$replyingids = array();
$structure = array($tweetid => array());
$sourcetweet = @shell_exec("python retrieve.tweet.py " . $tweetid);
$sourcetweetobj = json_decode($sourcetweet);
if (isset($sourcetweetobj->id_str)) {
    $username = $sourcetweetobj->user->screen_name;
    @mkdir("data/" . $tweetid);
    @chmod("data/" . $tweetid, 0766);
    @mkdir("data/" . $tweetid . "/source-tweets/");
    @chmod("data/" . $tweetid . "/source-tweets/", 0766);
    file_put_contents("data/" . $tweetid . "/source-tweets/" . $tweetid . ".json", $sourcetweet);
    collect_replying_tweets($tweetid, $username);
    create_structure($tweetid);
}
Exemplo n.º 2
0
    $db = DB::getInstance();
    $sqls = array("\n\t\t\tCREATE TABLE IF NOT EXISTS `user` (\n\t\t\t\t`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,\n\t\t\t\t`email` VARCHAR(200) NOT NULL,\n\t\t\t\t`passwd` VARCHAR(200) NOT NULL,\n\t\t\t\t`name` VARCHAR(200) NOT NULL,\n\t\t\t\t`joined` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,\n\t\t\t\tPRIMARY KEY (`id`),\n\t\t\t\tUNIQUE INDEX `email` (`email`)\n\t\t\t) COLLATE='utf8_general_ci' ENGINE=InnoDB\n\t\t", "\n\t\t\tCREATE TABLE IF NOT EXISTS `file` (\n\t\t\t\t`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,\n\t\t\t\t`file_name` VARCHAR(250) NOT NULL,\n\t\t\t\t`user_id` BIGINT(20) UNSIGNED NOT NULL,\n\t\t\t\t`original_name` VARCHAR(250) NOT NULL,\n\t\t\t\t`type` VARCHAR(50) NOT NULL,\n\t\t\t\t`size` BIGINT(20) UNSIGNED NOT NULL,\n\t\t\t\t`description` TEXT NULL,\n\t\t\t\t`public` TINYINT(1) UNSIGNED NOT NULL DEFAULT '1',\n\t\t\t\t`comments` TINYINT(1) UNSIGNED NOT NULL DEFAULT '1',\n\t\t\t\t`upload` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,\n\t\t\t\tPRIMARY KEY (`id`),\n\t\t\t\tUNIQUE INDEX `file_name` (`file_name`)\n\t\t\t) COLLATE='utf8_general_ci' ENGINE=InnoDB\n\t\t", "\n\t\t\tCREATE TABLE IF NOT EXISTS `upload` (\n\t\t\t\t`file_id` BIGINT(20) UNSIGNED NOT NULL,\n\t\t\t\t`ip` INT(11) UNSIGNED NOT NULL,\n\t\t\t\t`user_agent` TEXT NOT NULL,\n\t\t\t\tUNIQUE INDEX `file_id` (`file_id`)\n\t\t\t) COLLATE='utf8_general_ci' ENGINE=InnoDB\n\t\t", "\n\t\t\tCREATE TABLE IF NOT EXISTS `comment` (\n\t\t\t\t`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,\n\t\t\t\t`file_id` BIGINT(20) UNSIGNED NOT NULL,\n\t\t\t\t`reply_to` BIGINT(20) UNSIGNED NULL DEFAULT NULL,\n\t\t\t\t`user_id` BIGINT(20) UNSIGNED NULL DEFAULT NULL,\n\t\t\t\t`comment` TEXT NOT NULL,\n\t\t\t\t`added` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,\n\t\t\t\tPRIMARY KEY (`id`)\n\t\t\t) COLLATE='utf8_general_ci' ENGINE=InnoDB\n\t\t");
    foreach ($sqls as $sql) {
        $db->exec($sql);
    }
}
/* PROCESS */
if (file_exists(CONFIG_FILE) && !confirm(sprintf("Config file '%s' exists. Continue and overwrite it?", CONFIG_FILE))) {
    exit;
}
$questions = array(array('name' => 'database', 'text' => _('Database connection string'), 'default' => 'mysql://*****:*****@localhost:3306/files', 'callback' => 'verify_connection_sting'), array('name' => 'repository', 'text' => _('Files location'), 'default' => dirname(__FILE__) . DIRECTORY_SEPARATOR . 'files', 'callback' => 'verify_directory'));
$config = array();
foreach ($questions as $question) {
    do {
        $answer = prompt($question['text'], $question['default']);
    } while (function_exists($question['callback']) && !call_user_func($question['callback'], $answer));
    $config[$question['name']] = $answer;
}
Config::setConfig($config);
try {
    create_structure();
} catch (Exception $e) {
    echo $e->getMessage() . "\n\n";
    die;
}
$config_file = fopen(ROOT_DIR . CONFIG_FILE, 'w');
foreach ($config as $option => $value) {
    fputs($config_file, "{$option} = {$value}\n");
}
fclose($config_file);
echo _("Configuration successful finished\n");