Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $sql3 = "INSERT INTO CSI_Surveys(
- CSI_Surveys.header_id ,
- CSI_Surveys.summit_id ,
- CSI_Surveys.estimate_date ,
- CSI_Surveys.customer_email ,
- CSI_Surveys.customer_cell ,
- CSI_Surveys.estimate_dollars ,
- CSI_Surveys.insurer,
- CSI_Surveys.vin,
- CSI_Surveys.estimate_oem_make ,
- CSI_Surveys.estimate_oem_model ,
- CSI_Surveys.estimate_oem_year ,
- CSI_Surveys.estimate_oem_trim ,
- CSI_Surveys.vin_explosion ,
- CSI_Surveys.csi_program,
- CSI_Surveys.survey_status,
- CSI_Surveys.survey_name
- ) SELECT
- Estimate_Headers.id AS header_id ,
- Estimate_Headers.summit_id ,
- Estimate_Headers.estimate_date ,
- Estimate_Headers.customer_email ,
- Estimate_Headers.customer_cell ,
- Estimate_Headers.estimate_dollars ,
- Estimate_Headers.insurer,
- Estimate_Headers.vin,
- Estimate_Headers.vin_make,
- Estimate_Headers.vin_model,
- Estimate_Headers.vin_year,
- Estimate_Headers.vin_trim,
- Estimate_Headers.vin_exploded,
- '' as csi_program,
- 'initial',
- '' as survey_name
- FROM
- Estimate_Headers
- LEFT JOIN CSI_Surveys ON CSI_Surveys.header_id = Estimate_Headers.id
- WHERE
- ( Estimate_Headers.customer_email <> ''
- OR Estimate_Headers.customer_cell<> '' )
- AND Estimate_Headers.estimate_dollars > 0
- AND Estimate_Headers.vin <> ''
- AND CSI_Surveys.id IS NULL
- #AND Estimate_Headers.stamp >= :TODAY
- AND Estimate_Headers.estimate_date >= '2018-03-01'
- AND Estimate_Headers.summit_id <> 'NA'
- AND Estimate_Headers.id = :ROWID
- ORDER BY Estimate_Headers.summit_id";
- try {
- $STH = $_DBH->prepare($sql3);
- $STH->bindParam(':ROWID', $header_id);
- //$STH->bindParam(':TODAY', $today);
- $STH->setFetchMode(PDO::FETCH_ASSOC);
- $STH->execute();
- //return $STH->rowCount();
- }
- catch (PDOException $e) {
- return $e->getMessage();
- }
- $clefSecrete = "helob1ous";
- $sql = "SELECT
- CSI_Surveys.id ,
- CSI_Surveys.header_id ,
- CSI_Surveys.summit_id ,
- Estimate_Headers.vin ,
- CSI_Surveys.customer_email
- FROM
- CSI_Surveys
- LEFT JOIN Estimate_Headers ON Estimate_Headers.id = CSI_Surveys.header_id
- WHERE
- CSI_Surveys.survey_url IS NULL
- AND CSI_Surveys.header_id = " . $header_id;
- try {
- $STH = $_DBH->prepare($sql);
- $STH->setFetchMode(PDO::FETCH_ASSOC);
- $STH->execute();
- while ( $row = $STH->fetch() ) {
- //$urlString = $row['summit_id'] . $row['id'] . $row['header_id'] . $row['vin'] . $row['customer_email'];
- $urlString = $row['id'] . $row['vin'] . $row['customer_email'];
- $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC);
- $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
- $urlString = openssl_encrypt($urlString, 'aes-256-cbc', $clefSecrete, 0, $iv);
- $urlString = preg_replace('/[^a-zA-Z0-9_ %\[\]\.\(\)%&-]/s', '',$urlString);
- $urlString = strrev($urlString);
- // MAKE IT SMALL ENOUGH FOR SMS TEXT MESSAGE
- if ( strlen($urlString) > 15 )
- $urlString = substr($urlString, 0, 15);
- $sql2 = "UPDATE CSI_Surveys
- SET CSI_Surveys.survey_url = :SURVEYURL
- WHERE
- CSI_Surveys.id = :SURVEYID";
- try {
- $STH = $_DBH->prepare($sql2);
- $STH->bindParam(':SURVEYID', $row['id']);
- $STH->bindParam(':SURVEYURL', $surveyURL);
- $STH->setFetchMode(PDO::FETCH_ASSOC);
- $STH->execute();
- //return $STH->rowCount();
- } catch (PDOException $e) {
- return $e->getMessage();
- }
- $results = $results + $result;
- }
- //return $results;
- }
- catch (PDOException $e) {
- return $e->getMessage();
- }
- $csi_header_id = $header_id;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement