Ejemplo n.º 1
0
function parse_update_customers($xml_file, $username, $pw)
{
    //Checks if there are any customers on Imonggo
    if ($xml_file != NULL) {
        foreach ($xml_file->customer as $customer) {
            //Checks if customer is posted on Imonggo through database
            $query = "SELECT bigcommerce_id FROM customer where imonggo_id='{$customer->id}'";
            $result1 = mysql_query($query);
            $row = mysql_fetch_array($result1);
            //If customer exists in Bigcommerce, check its status
            if ($row[0] == NULL) {
            } else {
                //Checks if customer is not deleted on Imonggo
                if ($customer->status != "D") {
                    //Parses customer name and posts customer updates on Bigcommerce
                    $customer_name = explode(" ", $customer->name);
                    $xml_content = '<?xml version="1.0" encoding="UTF-8"?>
              <customer>
                <first_name>' . (string) $customer_name[0] . '</first_name>
                <last_name>' . (string) $customer_name[1] . '</last_name>
                <email>' . (string) $customer->email . '</email>
              </customer>';
                    $url_put = $GLOBALS['bigcommerce_URL'] . '/api/v2/customers/' . $row[0];
                    $put_result = put_file($url_put, $xml_content, $username, $pw);
                }
            }
        }
    }
}
Ejemplo n.º 2
0
if ($err = mysqli_error($conn)) {
    echo '{"success":false, "error":"' . $err . '", "sql":"' . $sql . '"}';
    exit(1);
}
if (mysqli_num_rows($result)) {
    echo '{"success":false, "error":"Ref codes must be unique; ' . $bib_code . ' exists already.", "sql":"' . $sql . '"}';
    exit(2);
}
# Check for a file upload, if so save it. Mark the path in the database
if (is_uploaded_file($_FILES['pdf']['tmp_name'])) {
    $dest_name = $_SERVER['DOCUMENT_ROOT'] . '/snips/pdfs/';
    $first_author = $posted_vars['authors'][0];
    $dest_name .= $first_author[0] . '.' . $first_author[1];
    $dest_name .= '.' . $posted_vars['pub_date'];
    $dest_extension = 'pdf';
    $path = put_file('pdf', $dest_name, $dest_extension, TRUE);
    if (!$path) {
        echo '{"success":false, "error":"There was a problem uploading ' . 'the file."}';
        exit(3);
    }
    $path = explode('/', $path);
    $insert_vars['path'] = array_pop($path);
}
# Make an sql insert statement
$sql = get_sql_insert_query($conn, $TABLE_NAME, $insert_vars);
$sql .= ", create_date=NOW()";
# Insert into the db
$result = mysqli_query($conn, $sql);
if ($err = mysqli_error($conn)) {
    echo '{"success":false, "error":' . $err . ', "sql":"' . $sql . '"}';
} else {