Пример #1
0
function upload()
{
    $file = file_get_contents($_FILES['fileToUpload']['tmp_name']);
    // Grab file
    // Specifies Files endpoint
    $url = 'https://api.parse.com/1/files/' . $_FILES['fileToUpload']['name'];
    $headers = array("Content-Type:" . file_get_contents($_FILES['fileToUpload']['type']), "X-Parse-REST-API-Key: " . restKey, "X-Parse-Application-Id: " . appId);
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $file);
    $response = json_decode(curl_exec($ch), true);
    curl_close($ch);
    if (isset($response['name'])) {
        // Checks for 'name' in JSON response
        if (associate($response['name'])) {
            Header('Location: https://parse-api-fileuploader.herokuapp.com/index.html');
            // Redirect the user
        } else {
            echo 'A fatal error has occured.';
        }
    }
}
function associateClusters($req)
{
    global $CONFIG;
    set_time_limit(0);
    //this avoids timeouts
    require_once $CONFIG->path . "mod/profile_manager/views/default/profile_manager/members/config.php";
    require_once $CONFIG->path . "mod/profile_manager/views/default/profile_manager/members/classes.php";
    $outputfile = $CONFIG->path . "mod/profile_manager/views/default/profile_manager/members/output.log";
    file_put_contents($outputfile, "Starting association clusters (this might require some time)...\n", FILE_APPEND);
    $clusters_metadata = unserialize(file_get_contents($IOdir . "clusters_metadata"));
    $clusters_uses = unserialize(file_get_contents($IOdir . "clusters_uses"));
    $clusters_tags = unserialize(file_get_contents($IOdir . "clusters_tags"));
    $clusters_replinks = unserialize(file_get_contents($IOdir . "clusters_replinks"));
    reset_association($clusters_metadata);
    reset_association($clusters_uses);
    reset_association($clusters_tags);
    reset_association($clusters_replinks);
    //associate metadata clusters to others
    associate($clusters_metadata, $clusters_metadata, "metadata", $minimum_association_threshold);
    associate($clusters_metadata, $clusters_uses, "uses", $minimum_association_threshold);
    associate($clusters_metadata, $clusters_tags, "tags", $minimum_association_threshold);
    associate($clusters_metadata, $clusters_replinks, "replinks", $minimum_association_threshold);
    associate($clusters_uses, $clusters_metadata, "metadata", $minimum_association_threshold);
    associate($clusters_uses, $clusters_uses, "uses", $minimum_association_threshold);
    associate($clusters_uses, $clusters_tags, "tags", $minimum_association_threshold);
    associate($clusters_uses, $clusters_replinks, "replinks", $minimum_association_threshold);
    associate($clusters_tags, $clusters_metadata, "metadata", $minimum_association_threshold);
    associate($clusters_tags, $clusters_uses, "uses", $minimum_association_threshold);
    associate($clusters_tags, $clusters_tags, "tags", $minimum_association_threshold);
    associate($clusters_tags, $clusters_replinks, "replinks", $minimum_association_threshold);
    associate($clusters_replinks, $clusters_metadata, "metadata", $minimum_association_threshold);
    associate($clusters_replinks, $clusters_uses, "uses", $minimum_association_threshold);
    associate($clusters_replinks, $clusters_tags, "tags", $minimum_association_threshold);
    associate($clusters_replinks, $clusters_replinks, "replinks", $minimum_association_threshold);
    file_put_contents($IOdir . 'clusters_metadata', serialize($clusters_metadata));
    if (PHP_OS == "Linux" && posix_getuid() == fileowner($IOdir . 'clusters_metadata')) {
        chmod($IOdir . 'clusters_metadata', 0666);
    }
    //set rw permissions for everybody for this file
    file_put_contents($IOdir . 'clusters_uses', serialize($clusters_uses));
    if (PHP_OS == "Linux" && posix_getuid() == fileowner($IOdir . 'clusters_uses')) {
        chmod($IOdir . 'clusters_uses', 0666);
    }
    //set rw permissions for everybody for this file
    file_put_contents($IOdir . 'clusters_tags', serialize($clusters_tags));
    if (PHP_OS == "Linux" && posix_getuid() == fileowner($IOdir . 'clusters_tags')) {
        chmod($IOdir . 'clusters_tags', 0666);
    }
    //set rw permissions for everybody for this file
    file_put_contents($IOdir . 'clusters_replinks', serialize($clusters_replinks));
    if (PHP_OS == "Linux" && posix_getuid() == fileowner($IOdir . 'clusters_replinks')) {
        chmod($IOdir . 'clusters_replinks', 0666);
    }
    //set rw permissions for everybody for this file
    file_put_contents($outputfile, "\nClusters associated\n", FILE_APPEND);
    file_put_contents($outputfile, "\nClassification finished\n\n", FILE_APPEND);
    return "OK";
}
 * @param $lang
 * @param $pair
 * @param $answer
 * @param $type
 * @return array|bool|null
 */
function stats($link, $group, $user, $lang, $pair, $answer, $type)
{
    $sql = "SELECT * FROM `vassociations` \n        WHERE \n            assigned_group = :group \n            AND user = :user \n            AND lang = :lang \n            AND id1 = :pairzero \n            AND id2 = pairone \n            AND word = :answer \n            AND type = :type \n        GROUP BY word";
    $stmt = $link->prepare($sql);
    $stmt->bindValue(':group', $group, PDO::PARAM_STR);
    $stmt->bindValue(':user', $user, PDO::PARAM_STR);
    $stmt->bindValue(':lang', $lang, PDO::PARAM_STR);
    $stmt->bindValue(':pairzero', $pair[0], PDO::PARAM_STR);
    $stmt->bindValue(':pairone', $pair[1], PDO::PARAM_STR);
    $stmt->bindValue(':answer', $answer, PDO::PARAM_STR);
    $stmt->bindValue(':type', $type, PDO::PARAM_INT);
    if ($stmt->execute() !== false) {
        $row = $stmt->fetch(PDO::FETCH_ASSOC);
        return $row;
    } else {
        return false;
    }
}
if (!isset($_SESSION['hashed_ticket']) || !$_SESSION['hashed_ticket'] === hash("sha256", $_POST['ticket'] . $_POST['id1'] . $_POST['id2'])) {
    die("Bad ticket.");
}
unset($_SESSION['hashed_ticket']);
$link = connect();
associate($link, $_SESSION['user_array']['working_group'], $_SESSION['user_array']['user'], $_SESSION['user_array']['input_language'], array($_POST['id1'], $_POST['id2']), $_POST['input'], $_POST['type']);
$link = null;
Пример #4
0
        exit(1);
    }
    $data_rra = explode(':', $rra);
    if (sizeof($data_rra)) {
        foreach ($data_rra as $rra_id) {
            $rra_curr = db_fetch_row("SELECT * FROM rra WHERE id=" . $rra_id);
            if (sizeof($rra_curr)) {
                if (!$quietMode) {
                    print "Working on RRA Id {$rra_id}:" . $rra_curr["name"] . ":" . $rra_curr["x_files_factor"] . ":" . $rra_curr["steps"] . ":" . $rra_curr["rows"] . ":" . $rra_curr["timespan"] . "\n";
                }
            } else {
                print "ERROR: Invalid rra id given: {$rra_id}\n";
                exit(1);
            }
        }
        associate($data_template["id"], $data_rra, $debug, $quietMode);
    } else {
        print "ERROR: Invalid rra definition given: {$rra}\n";
        exit(1);
    }
} else {
    display_help($me);
    exit(0);
}
function associate($data_template_id, $data_rra, $debug, $quiet)
{
    /* get a list of data sources using this template 
     * including the template itself */
    $data_sources = db_fetch_assoc("SELECT\n\t\t\tdata_template_data.id\n\t\t\tFROM data_template_data\n\t\t\tWHERE data_template_id={$data_template_id}");
    if (sizeof($data_sources) > 0) {
        foreach ($data_sources as $data_source) {
function associate_clusters($array_clusters)
{
    global $minimum_association_threshold;
    $clusters_metadata = $array_clusters["metadata"];
    $clusters_uses = $array_clusters["uses"];
    $clusters_tags = $array_clusters["tags"];
    $clusters_replinks = $array_clusters["replinks"];
    reset_association($clusters_metadata);
    reset_association($clusters_uses);
    reset_association($clusters_tags);
    reset_association($clusters_replinks);
    //associate metadata clusters to others
    associate($clusters_metadata, $clusters_metadata, "metadata", $minimum_association_threshold);
    associate($clusters_metadata, $clusters_uses, "uses", $minimum_association_threshold);
    associate($clusters_metadata, $clusters_tags, "tags", $minimum_association_threshold);
    associate($clusters_metadata, $clusters_replinks, "replinks", $minimum_association_threshold);
    associate($clusters_uses, $clusters_metadata, "metadata", $minimum_association_threshold);
    associate($clusters_uses, $clusters_uses, "uses", $minimum_association_threshold);
    associate($clusters_uses, $clusters_tags, "tags", $minimum_association_threshold);
    associate($clusters_uses, $clusters_replinks, "replinks", $minimum_association_threshold);
    associate($clusters_tags, $clusters_metadata, "metadata", $minimum_association_threshold);
    associate($clusters_tags, $clusters_uses, "uses", $minimum_association_threshold);
    associate($clusters_tags, $clusters_tags, "tags", $minimum_association_threshold);
    associate($clusters_tags, $clusters_replinks, "replinks", $minimum_association_threshold);
    associate($clusters_replinks, $clusters_metadata, "metadata", $minimum_association_threshold);
    associate($clusters_replinks, $clusters_uses, "uses", $minimum_association_threshold);
    associate($clusters_replinks, $clusters_tags, "tags", $minimum_association_threshold);
    associate($clusters_replinks, $clusters_replinks, "replinks", $minimum_association_threshold);
    $array_clusters["metadata"] = $clusters_metadata;
    unset($clusters_metadata);
    $array_clusters["uses"] = $clusters_uses;
    unset($clusters_uses);
    $array_clusters["tags"] = $clusters_tags;
    unset($clusters_tags);
    $array_clusters["replinks"] = $clusters_replinks;
    unset($clusters_replinks);
    return $array_clusters;
}