Advertisement
Guest User

Untitled

a guest
Dec 18th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.88 KB | None | 0 0
  1. $sql3 = "INSERT INTO CSI_Surveys(
  2. CSI_Surveys.header_id ,
  3. CSI_Surveys.summit_id ,
  4. CSI_Surveys.estimate_date ,
  5. CSI_Surveys.customer_email ,
  6. CSI_Surveys.customer_cell ,
  7. CSI_Surveys.estimate_dollars ,
  8. CSI_Surveys.insurer,
  9. CSI_Surveys.vin,
  10. CSI_Surveys.estimate_oem_make ,
  11. CSI_Surveys.estimate_oem_model ,
  12. CSI_Surveys.estimate_oem_year ,
  13. CSI_Surveys.estimate_oem_trim ,
  14. CSI_Surveys.vin_explosion ,
  15. CSI_Surveys.csi_program,
  16. CSI_Surveys.survey_status,
  17. CSI_Surveys.survey_name
  18.  
  19. ) SELECT
  20. Estimate_Headers.id AS header_id ,
  21. Estimate_Headers.summit_id ,
  22. Estimate_Headers.estimate_date ,
  23. Estimate_Headers.customer_email ,
  24. Estimate_Headers.customer_cell ,
  25. Estimate_Headers.estimate_dollars ,
  26. Estimate_Headers.insurer,
  27. Estimate_Headers.vin,
  28. Estimate_Headers.vin_make,
  29. Estimate_Headers.vin_model,
  30. Estimate_Headers.vin_year,
  31. Estimate_Headers.vin_trim,
  32. Estimate_Headers.vin_exploded,
  33. '' as csi_program,
  34. 'initial',
  35. '' as survey_name
  36.  
  37. FROM
  38. Estimate_Headers
  39. LEFT JOIN CSI_Surveys ON CSI_Surveys.header_id = Estimate_Headers.id
  40. WHERE
  41. ( Estimate_Headers.customer_email <> ''
  42. OR Estimate_Headers.customer_cell<> '' )
  43. AND Estimate_Headers.estimate_dollars > 0
  44. AND Estimate_Headers.vin <> ''
  45. AND CSI_Surveys.id IS NULL
  46. #AND Estimate_Headers.stamp >= :TODAY
  47. AND Estimate_Headers.estimate_date >= '2018-03-01'
  48. AND Estimate_Headers.summit_id <> 'NA'
  49. AND Estimate_Headers.id = :ROWID
  50. ORDER BY Estimate_Headers.summit_id";
  51.  
  52. try {
  53.  
  54. $STH = $_DBH->prepare($sql3);
  55.  
  56. $STH->bindParam(':ROWID', $header_id);
  57. //$STH->bindParam(':TODAY', $today);
  58.  
  59. $STH->setFetchMode(PDO::FETCH_ASSOC);
  60. $STH->execute();
  61.  
  62. //return $STH->rowCount();
  63. }
  64. catch (PDOException $e) {
  65. return $e->getMessage();
  66. }
  67.  
  68.  
  69. $clefSecrete = "helob1ous";
  70.  
  71. $sql = "SELECT
  72. CSI_Surveys.id ,
  73. CSI_Surveys.header_id ,
  74. CSI_Surveys.summit_id ,
  75. Estimate_Headers.vin ,
  76. CSI_Surveys.customer_email
  77. FROM
  78. CSI_Surveys
  79. LEFT JOIN Estimate_Headers ON Estimate_Headers.id = CSI_Surveys.header_id
  80. WHERE
  81. CSI_Surveys.survey_url IS NULL
  82. AND CSI_Surveys.header_id = " . $header_id;
  83.  
  84. try {
  85.  
  86. $STH = $_DBH->prepare($sql);
  87.  
  88. $STH->setFetchMode(PDO::FETCH_ASSOC);
  89. $STH->execute();
  90.  
  91. while ( $row = $STH->fetch() ) {
  92.  
  93. //$urlString = $row['summit_id'] . $row['id'] . $row['header_id'] . $row['vin'] . $row['customer_email'];
  94. $urlString = $row['id'] . $row['vin'] . $row['customer_email'];
  95.  
  96. $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC);
  97. $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
  98.  
  99. $urlString = openssl_encrypt($urlString, 'aes-256-cbc', $clefSecrete, 0, $iv);
  100. $urlString = preg_replace('/[^a-zA-Z0-9_ %\[\]\.\(\)%&-]/s', '',$urlString);
  101. $urlString = strrev($urlString);
  102.  
  103. // MAKE IT SMALL ENOUGH FOR SMS TEXT MESSAGE
  104. if ( strlen($urlString) > 15 )
  105. $urlString = substr($urlString, 0, 15);
  106.  
  107.  
  108.  
  109. $sql2 = "UPDATE CSI_Surveys
  110. SET CSI_Surveys.survey_url = :SURVEYURL
  111. WHERE
  112. CSI_Surveys.id = :SURVEYID";
  113.  
  114. try {
  115.  
  116. $STH = $_DBH->prepare($sql2);
  117.  
  118. $STH->bindParam(':SURVEYID', $row['id']);
  119. $STH->bindParam(':SURVEYURL', $surveyURL);
  120.  
  121. $STH->setFetchMode(PDO::FETCH_ASSOC);
  122. $STH->execute();
  123.  
  124. //return $STH->rowCount();
  125.  
  126. } catch (PDOException $e) {
  127.  
  128. return $e->getMessage();
  129. }
  130.  
  131.  
  132.  
  133.  
  134. $results = $results + $result;
  135.  
  136. }
  137.  
  138. //return $results;
  139.  
  140. }
  141. catch (PDOException $e) {
  142. return $e->getMessage();
  143. }
  144.  
  145.  
  146.  
  147.  
  148.  
  149. $csi_header_id = $header_id;
  150. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement