Beispiel #1
0
            $i++;
            if ($i % 100 == 0) {
                echo $i . "<br />";
                $db_global->commit();
            }
        }
        if (!$error) {
            $db_global->commit();
        }
        fclose($handle);
    } else {
        // error opening the file.
    }
}
if (isset($_REQUEST["job"]) && $_REQUEST["job"] == "import") {
    insertRows();
    exit("ok");
}
if (isset($_REQUEST["job"]) && $_REQUEST["job"] == "phones") {
    $handle = fopen("/var/www/html/autoCaller/replacePhones.txt", "r");
    if ($handle) {
        $db_global->autocommit(false);
        //$db_global->query("TRUNCATE TABLE contacts");
        $error = false;
        $i = 0;
        while (($line = fgets($handle)) !== false) {
            $line = iconv("CP1251", "UTF8", $line);
            //echo $line ."\n<br />";
            $info = explode("\t", $line);
            $oldPhone = trim($info[0]);
            $newPhone = trim($info[1]);
Beispiel #2
0
if (!empty($apiResult)) {
    insertRows($conn, $apiResult);
    echo "data logged!\r\n";
    $apiResult = false;
} else {
    echo "No Data! ";
    print_r($fromDate);
    echo "\r\n";
}
// Checks current day in script vs acutal day
$checkDate = strtotime($fromDate['year'] . '-' . $fromDate['month'] . '-' . $fromDate['day'] . 'T' . $fromDate['hour'] . ":00:00");
$dayDate = strtotime($date['year'] . '-' . $date['mon'] . '-' . $date['mday'] . 'T' . "00:00:00");
while ($checkDate < $dayDate) {
    // Sanity check, really just helps keep my code clean for me
    if ($checkDate < $dayDate) {
        $apiResult = CallAPI($fromDate);
        if (!empty($apiResult)) {
            insertRows($conn, $apiResult);
            echo "data logged!\r\n";
            $apiResult = false;
        } else {
            var_dump(CallAPI($fromDate));
            echo "No Data! ";
            print_r($fromDate);
            echo "\r\n";
        }
    }
    // Goes to the next day and reformats the checkDate
    $fromDate = IncrementDate($fromDate);
    $checkDate = strtotime($fromDate['year'] . '-' . $fromDate['month'] . '-' . $fromDate['day'] . 'T' . $fromDate['hour'] . ":00:00");
}
Beispiel #3
0
            $raion = $info[5];
            $street = $info[6];
            $dom = $info[7];
            $korp = $info[8];
            $kv = $info[9];
            $phone = preg_replace("/[^0-9]+/", "", $info[10]);
            if ($phone == "") {
                $i++;
                continue;
            }
            $sql = "INSERT INTO contacts (id,name,bd,city,raion,street,dom,korp,kv,phone) VALUES ('{$id}','{$name}','{$bd}','{$city}','{$raion}','{$street}','{$dom}','{$korp}','{$kv}','{$phone}')";
            if ($db->query($sql)) {
                $error = true;
            }
            $i++;
            if ($i % 100 == 0) {
                echo $sql . "\n";
                echo "i = {$i}; i/100 = " . $i % 100 . "\n";
                $db->commit();
            }
        }
        if (!$error) {
            $db->commit();
        }
        fclose($handle);
    } else {
        // error opening the file.
    }
}
insertRows($db);
function insertRecord($db, $modelName, $record, $roles)
{
    global $config;
    $request = createRequest($modelName);
    $request["records"][] = array("values" => array());
    if (!checkRequest($db, $request, $record, "insert", $roles)) {
        return;
    }
    fillRequestWithRecords($request, $record);
    $insertedIDs = insertRows($db, $request, $roles);
    //insertRowsDynamoDB($request, $roles, $insertedIDs);
    $insertID = $insertedIDs[0];
    if ($modelName == "school") {
        $querySchoolUser = "******";
        $stmt = $db->prepare($querySchoolUser);
        $stmt->execute(array("insertID" => $insertID, "userID" => $record["userID"]));
    }
    if ($modelName === "user" && $config->email->bSendMailForReal) {
        sendValidationEmails($record);
    }
    echo json_encode(array("success" => true, "recordID" => $insertID));
}