Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- * LSCU FACU DATA NIGHTLY MIGRATION BY CUSG
- * SCRIPT SHOULD RUN NIGHTLY AT 2 AM EST AS CRON JOB
- *
- * CRON TIME OPTION: 0 2 * * *
- *
- * CRON COMMAND OPTIONS:
- * php /path/to/script/cu_finder_cron.php
- * OR
- * wget -q -O /dev/null http://siteURL.org/path_to_script_from_doc_root/cu_finder_cron.php
- *
- * PLEASE CONTACT SUPPORT@CUSOLUTIONSGROUP.COM WITH ISSUES - SUBJECT "LSCU CRON ISSUES"
- *
- */
- // SET MySQL Parameters - DEFINED BY LSCU in CU-SOLUTIONS-DATA/CU-BRANCHES.PHP
- $dbhost = "localhost";
- $dbuser = "scoutbra";
- $dbpass = "J0S#n1Bo0";
- $dbname = "scoutbra_wrd1";
- // EMAIL ERRORS - PLEASE LEAVE THE TDB@MCUL.ORG/GZD@MCUL.ORG ADDRESSES IN THERE FOR TRACKING ON OUR END. ADD ADDITONAL ADDRESSES, SEPARATED BY COMMAS
- $errorto = 'tdb@mcul.org,gzd@mcul.org, dan@scoutbrand.com';
- $errorsub = 'LSCU FACU DATA MIGRATION ERROR';
- $successsub = 'LSCU FACU DATA MIGRATION COMPLETED';
- $errormess = '';
- $errorfrom = 'noreply@cu-village.com';
- /*
- * PLEASE DO NOT EDIT ANYTHING BELOW THIS LINE!!!!
- */
- // VARS
- $buffer = '';
- $sqlstatements = array();
- $sqldata = '';
- // TOKENIZED HASH TO PASS
- $TOKEN = 'CC56534uydR3w00-23DDf4Izzpl-09345';
- $hashtok = md5($TOKEN);
- // CALL TO FIND A CU SCRIPT
- $fields ="hashtok=".urlencode($hashtok);
- $ch=curl_init("https://natcufinder.secure.cu-village.com/client/lscu_finder/index.php");
- curl_setopt($ch, CURLOPT_HEADER, 0);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $fields); // set the fields to post
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // make sure we get the response back
- $buffer = curl_exec($ch); // execute the post
- curl_close($ch); // close our session
- if(empty($buffer) || $buffer == '-1'){
- // FAILED
- $errormess = 'Failed to communicated correctly with CUSG API';
- mail($errorto,$errorsub,$errormess,'From:'.$errorfrom);
- }else{
- // EXECUTE SQL CALLS
- $dblink = mysql_connect($dbhost,$dbuser,$dbpass);
- if (!$dblink) {
- $errormess = 'Failed to login correctly to MySQL service: '. mysql_error();
- mail($errorto,$errorsub,$errormess,'From:'.$errorfrom);
- die('Could not connect: ' . mysql_error());
- }
- $db_selected = mysql_select_db($dbname,$dblink);
- if (!$db_selected) {
- $errormess = 'Failed to communicated correctly with local DB: '. mysql_error();
- mail($errorto,$errorsub,$errormess,'From:'.$errorfrom);
- die ('Can\'t use WordPress DB: ' . mysql_error());
- }
- $sqlstatements = explode("\n",$buffer);
- foreach($sqlstatements as $query){
- $query = trim($query);
- if($query != ''){
- $res = mysql_query($query,$dblink);
- }
- }
- $errormess = 'Nightly data migration completed';
- mail($errorto,$successsub,$errormess,'From:'.$errorfrom);
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement