Advertisement
Guest User

Untitled

a guest
Jan 8th, 2018
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 24.43 KB | None | 0 0
  1. <?php
  2.  
  3. include("db.php");
  4. include("db_prod.php");
  5. error_reporting(0);
  6. // Fill in all the info we need to connect to the database.
  7. // This is the same info you need even if you're using the old mysql_ library.
  8. $host = 'localhost';
  9. $port = 3306; // This is the default port for MySQL
  10. $database = 'mdataa5_mguides_stage';
  11. $username = 'mdataa5_mguides';
  12. $password = '+64^_hO@P3$H';
  13.  
  14. // Construct the DSN, or "Data Source Name". Really, it's just a fancy name
  15. // for a string that says what type of server we're connecting to, and how
  16. // to connect to it. As long as the above is filled out, this line is all
  17. // you need :)
  18. $dsn = "mysql:host=$host;port=$port;dbname=$database";
  19.  
  20. // Connect!
  21. try {
  22. $db_stage = new PDO("mysql:host=$host;dbname=$database", $username, $password);
  23. $db_stage->exec("SET time_zone='Europe/Athens';");
  24. $db_stage->exec("SET NAMES utf8;");
  25. $db_stage->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
  26. $db_stage->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  27. $db_stage->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true);
  28. }
  29. catch(PDOException $e)
  30. {
  31. echo $e->getMessage();
  32. }
  33.  
  34. date_default_timezone_set('Europe/Athens');
  35. $cur_date = date("Y-m-d H:i");
  36.  
  37. // Get all the events checked by the user
  38. $sel_events = $_POST['migrate'];
  39.  
  40. // File update with the migrate log
  41. $my_file = 'log_'.$cur_date.'.txt';
  42. $handle = fopen('../../log_files/'.$my_file, 'w') or die('Cannot open file: '.$my_file); //implicitly creates file
  43. $data = 'Log Date: '.$cur_date."\n";
  44. echo $data."<br/>";
  45. fwrite($handle, pack("CCC",0xef,0xbb,0xbf));
  46. fwrite($handle, $data);
  47. fclose($handle);
  48.  
  49. $venue_ids = array();
  50. $organizer_ids = array();
  51.  
  52. if(empty($sel_events)) {
  53. echo("You didn't select any events.");
  54. }
  55. else {
  56. events_to_prod(getLastUpdated('events'),$sel_events,$my_file);
  57. event_kind_to_prod(getLastUpdated('event_kind'),$sel_events,$my_file);
  58. event_type_to_prod(getLastUpdated('event_type'),$sel_events,$my_file);
  59. organizers_to_prod(getLastUpdated('organizers'),$organizer_ids,$my_file);
  60. venues_to_prod(getLastUpdated('venues'),$venue_ids,$my_file);
  61. cities_to_prod(getLastUpdated('cities'),$my_file);
  62. // regions_to_prod(getLastUpdated('regions'),$my_file);
  63. // countries_to_prod(getLastUpdated('countries'),$my_file);
  64. // continents_to_prod(getLastUpdated('continents'),$my_file);
  65. files_to_prod(getLastUploaded('venue_uploads'),$my_file);
  66. }
  67.  
  68. function getLastUpdated($table) {
  69.  
  70. include("db_prod.php");
  71. $query='SELECT Datetime_updated FROM '.$table.' ORDER BY Datetime_updated DESC limit 0,1';
  72. $statement = $db_prod->prepare($query);
  73. $statement->execute();
  74.  
  75. while ($result = $statement->fetchObject()) {
  76.  
  77. $venue_last_updated= $result->Datetime_updated;
  78.  
  79. }
  80.  
  81. $venue_last_updated = date('Y-m-d H:i:s', strtotime($venue_last_updated) - 14400); // $today is today date
  82.  
  83. return $venue_last_updated;
  84.  
  85. }
  86.  
  87. function getLastUploaded($table) {
  88.  
  89. include("db_prod.php");
  90. $query='SELECT date_uploaded FROM '.$table.' ORDER BY date_uploaded DESC limit 0,1';
  91. $statement = $db_prod->prepare($query);
  92. $statement->execute();
  93.  
  94. while ($result = $statement->fetchObject()) {
  95.  
  96. $pdf_last_updated= $result->date_uploaded;
  97.  
  98. }
  99.  
  100. // $pdf_last_updated = date('Y-m-d H:i:s', strtotime($pdf_last_updated) - 14400); // $today is today date
  101.  
  102. return $pdf_last_updated;
  103.  
  104. }
  105.  
  106. function events_to_prod($since_date, $sel_events, $my_file) {
  107. include("db.php");
  108. include("db_mguides_stage.php");
  109.  
  110. $place_holders = implode(',', array_fill(0, count($sel_events), '?'));
  111.  
  112. $statement = $db->prepare("select * from events where id in ($place_holders)");
  113. $statement->execute($sel_events);
  114.  
  115. $count = $statement->rowCount();
  116. if($count < 1) {
  117. $msg = "Events table is already updated!"."\n";
  118. }
  119. else {
  120. $msg = "<b>Events table is being updated....</b>"."\n";
  121. }
  122. echo $msg."<br/>";
  123.  
  124. $handle = fopen('../../log_files/'.$my_file, 'a') or die('Cannot open file: '.$my_file);
  125. fwrite($handle, pack("CCC",0xef,0xbb,0xbf));
  126. fwrite($handle, $msg);
  127.  
  128. $since_date = date('Y-m-d H:i:s', strtotime($since_date) + 14400);
  129. // $since_date = date('Y-m-d H:i:s');
  130. $todays_date = date('Y-m-d H:i:s');
  131. // $statement2 = $db->prepare("UPDATE events SET Datetime_updated='$since_date' WHERE id IN ($place_holders)");
  132. // $statement2->execute($sel_events);
  133.  
  134. include("db_prod.php");
  135.  
  136. while ($result = $statement->fetchObject()) {
  137.  
  138. $id=$result->id;
  139. $title_en=$result->title_en;
  140. $title_gr=$result->title_gr;
  141. $starting_datetime=$result->starting_datetime;
  142. $starting_datetime = DateTime::createFromFormat('d/m/Y H:i', $starting_datetime)->format('Y/m/d H:i:s');
  143.  
  144. $ending_datetime=$result->ending_datetime;
  145. $ending_datetime = DateTime::createFromFormat('d/m/Y H:i', $ending_datetime)->format('Y/m/d H:i:s');
  146.  
  147. $language='BOTH';
  148. $description_en=$result->description_en;
  149. $description_gr=$result->description_gr;
  150. $schedule=$result->schedule;
  151. $website=$result->website;
  152. $eof_category=$result->eof_category;
  153. $specialties_id=$result->specialties_id;
  154. $organizer_id=$result->organizer_id;
  155. $organizer_person_id=$result->organizer_person_id;
  156. $PCO_id=$result->PCO_id;
  157. $pco_person_id=$result->pco_person_id;
  158. $venue_id=$result->venue_id;
  159. $informationsource=$result->informationsource;
  160. $event_kind_id=$result->event_kind_id;
  161. $event_type_id=$result->event_type_id;
  162. $master_conference_id=$result->master_conference_id;
  163. $keywords=$result->keywords;
  164. $apple_store=$result->apple_store;
  165. $play_store=$result->play_store;
  166. $windows_store=$result->windows_store;
  167. $Date_created=$result->Date_created;
  168. $Last_updated_by=$result->Last_updated_by;
  169. $hide=$result->hide;
  170. $deleted_by=$result->deleted_by;
  171.  
  172. array_push($GLOBALS['venue_ids'], $venue_id);
  173. array_push($GLOBALS['organizer_ids'], $organizer_id);
  174. array_push($GLOBALS['organizer_ids'], $PCO_id);
  175.  
  176. if(ltrim($result->title_gr)!='' && ltrim($result->title_en)!='') {$title=$result->title_gr.' ('.$result->title_en.')'; }
  177. else if(ltrim($result->title_gr)=='') {$title= $result->title_en; }
  178. else {$title= $result->title_gr; }
  179.  
  180. $smt = $db_stage->prepare("REPLACE INTO events (id, title_en, title_gr, starting_datetime, ending_datetime, language, website, organizer_id,organizer_person_id,Date_created, Datetime_updated, hide, event_kind_id, event_type_id,venue_id,keywords,description_en,description_gr) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
  181. $smt->bindValue(1, $id);
  182. $smt->bindValue(2, $title_en);
  183. $smt->bindValue(3, $title_gr);
  184. $smt->bindValue(4, $starting_datetime);
  185. $smt->bindValue(5, $ending_datetime);
  186. $smt->bindValue(6, $language);
  187. $smt->bindValue(7, $website);
  188. $smt->bindValue(8, 1);
  189. $smt->bindValue(9, $organizer_id);
  190. $smt->bindValue(10, $todays_date);
  191. $smt->bindValue(11, $todays_date);
  192. $smt->bindValue(12, $hide);
  193. $smt->bindValue(13, $event_kind_id);
  194. $smt->bindValue(14, $event_type_id);
  195. $smt->bindValue(15, $venue_id);
  196. $smt->bindValue(16, $keywords);
  197. $smt->bindValue(17, $description_en);
  198. $smt->bindValue(18, $description_gr);
  199.  
  200. /* $smt->bindValue(7, $description_en);
  201. $smt->bindValue(8, $description_gr);
  202. $smt->bindValue(9, $schedule);
  203. $smt->bindValue(10, $website);
  204. $smt->bindValue(11, $specialties_id);
  205. $smt->bindValue(12, $organizer_id);
  206. $smt->bindValue(13, $organizer_person_id);
  207. $smt->bindValue(14, $PCO_id);
  208. $smt->bindValue(15, $pco_person_id);
  209. $smt->bindValue(16, $venue_id);
  210. $smt->bindValue(17, $informationsource);
  211. $smt->bindValue(18, $event_kind_id);
  212. $smt->bindValue(19, $event_type_id);
  213. $smt->bindValue(20, $master_conference_id);
  214. $smt->bindValue(21, $keywords);
  215. $smt->bindValue(22, $apple_store);
  216. $smt->bindValue(23, $play_store);
  217. $smt->bindValue(24, $windows_store);
  218. $smt->bindValue(25, $Date_created);
  219. $smt->bindValue(26, $since_date);
  220. // $smt->bindValue(26, $cur_date);
  221. $smt->bindValue(27, $Last_updated_by);
  222. $smt->bindValue(28, $hide);
  223. $smt->bindValue(29, $deleted_by);
  224. $smt->bindValue(30, $eof_category);
  225. */
  226.  
  227. $smt->execute();
  228.  
  229. $message = "Event with id = ".$id." & name = '".$title."'' was inserted succesfully."."\n";
  230. echo $message."<br/>";
  231. fwrite($handle, pack("CCC",0xef,0xbb,0xbf));
  232. fwrite($handle, $message);
  233. }
  234. echo "Events updated:".count($sel_events)."<br/>";
  235. fclose($handle);
  236. }
  237.  
  238. function organizers_to_prod($since_date,$organizer_ids, $my_file) {
  239. include("db.php");
  240. include("db_mguides_stage.php");
  241.  
  242. $place_holders = implode(',', array_fill(0, count($organizer_ids), '?'));
  243.  
  244. $statement = $db->prepare("select * from organizers where id in ($place_holders)");
  245. $statement->execute($organizer_ids);
  246.  
  247. $count = $statement->rowCount();
  248. if($count < 1) {
  249. $msg = "Organizers table is already updated!"."\n";
  250. }
  251. else {
  252. $msg = "<b>Organizers table is being updated....</b>"."\n";
  253. }
  254. echo $msg."<br/>";
  255.  
  256. $handle = fopen('../../log_files/'.$my_file, 'a') or die('Cannot open file: '.$my_file);
  257. fwrite($handle, pack("CCC",0xef,0xbb,0xbf));
  258. fwrite($handle, $msg);
  259.  
  260. $since_date = date('Y-m-d H:i:s', strtotime($since_date) + 14400);
  261. $todays_date = date('Y-m-d H:i:s');
  262.  
  263. include("db_prod.php");
  264.  
  265. while ($result = $statement->fetchObject()) {
  266.  
  267. $id=$result->id;
  268. $type_id=$result->type_id;
  269. $name=$result->name;
  270. $telephone=$result->telephone;
  271. $email=$result->email;
  272. $address=$result->address;
  273. $zip=$result->zip;
  274. $city_id=$result->city_id;
  275. $website=$result->website;
  276. $fax=$result->fax;
  277. $type=$result->type;
  278. $hide=$result->hide;
  279. $Last_updated_by=$result->Last_updated_by;
  280. $deleted_by=$result->deleted_by;
  281. $Datetime_updated=$result->Datetime_updated;
  282.  
  283. //app_organizer_lang
  284.  
  285. $smt = $db_stage->prepare("REPLACE INTO app_organizer_lang (id,organizer_id,locale,title,about,summary,detail_info,address,createdon,updatedon,hide) VALUES (?,?,?,?,?,?,?,?,?,?,?); ");
  286. $smt->bindValue(1, $id);
  287. $smt->bindValue(2, $id);
  288. $smt->bindValue(3, 'en');
  289. $smt->bindValue(4, $name);
  290. $smt->bindValue(5, '');
  291. $smt->bindValue(6, '');
  292. $smt->bindValue(7, '');
  293. $smt->bindValue(8, $address);
  294. $smt->bindValue(9, $todays_date);
  295. $smt->bindValue(10, $todays_date);
  296. $smt->bindValue(11, $hide);
  297. $smt->execute();
  298.  
  299. $message = "Organizer with id = ".$id." & name = '".$name."'' was inserted succesfully."."\n";
  300. echo $message."<br/>";
  301. fwrite($handle, pack("CCC",0xef,0xbb,0xbf));
  302. fwrite($handle, $message);
  303.  
  304. //app_organizer
  305.  
  306. $smt = $db_stage->prepare("REPLACE INTO app_organizer (id,organizer_id,sponser_type_id,image,website,mobile,telephone,email,facebook,youtube,twitter,linkedin,createdon,updatedon,ordering,hide) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?); ");
  307. $smt->bindValue(1, $id);
  308. $smt->bindValue(2, $id);
  309. $smt->bindValue(3, 0);
  310. $smt->bindValue(4, '');
  311. $smt->bindValue(5, $website);
  312. $smt->bindValue(6, '');
  313. $smt->bindValue(7, $telephone);
  314. $smt->bindValue(8, $email);
  315. $smt->bindValue(9, '');
  316. $smt->bindValue(10, '');
  317. $smt->bindValue(11, '');
  318. $smt->bindValue(12, '');
  319. $smt->bindValue(13, $todays_date);
  320. $smt->bindValue(14, $todays_date);
  321. $smt->bindValue(15, '');
  322. $smt->bindValue(16, $hide);
  323. $smt->execute();
  324.  
  325. $message = "Organizer with id = ".$id." & name = '".$name."'' was inserted succesfully."."\n";
  326. echo $message."<br/>";
  327. fwrite($handle, pack("CCC",0xef,0xbb,0xbf));
  328. fwrite($handle, $message);
  329. }
  330. echo "Organizers / PCOs updated:".count(array_unique(array_filter($organizer_ids)))."<br/>";
  331. fclose($handle);
  332. }
  333.  
  334. function event_kind_to_prod($since_date,$organizer_ids, $my_file) {
  335. include("db.php");
  336. include("db_mguides_stage.php");
  337. $todays_date = date('Y-m-d H:i:s');
  338. $place_holders = implode(',', array_fill(0, count($organizer_ids), '?'));
  339.  
  340. $statement = $db->prepare("select * from event_kind");
  341. $statement->execute();
  342.  
  343. $count = $statement->rowCount();
  344. if($count < 1) {
  345. $msg = "Event kind table is already updated!"."\n";
  346. }
  347. else {
  348. $msg = "<b>Event kind table is being updated....</b>"."\n";
  349. }
  350. echo $msg."<br/>";
  351.  
  352. $handle = fopen('../../log_files/'.$my_file, 'a') or die('Cannot open file: '.$my_file);
  353. fwrite($handle, pack("CCC",0xef,0xbb,0xbf));
  354. fwrite($handle, $msg);
  355.  
  356. $since_date = date('Y-m-d H:i:s', strtotime($since_date) + 14400);
  357. $todays_date = date('Y-m-d H:i:s');
  358.  
  359. include("db_prod.php");
  360.  
  361. while ($result = $statement->fetchObject()) {
  362.  
  363. $id=$result->id;
  364. $name_en=$result->name_en;
  365. $name_gr=$result->name_gr;
  366. $Datetime_updated=$result->Datetime_updated;
  367. $hide=$result->hide;
  368.  
  369. //Event kind
  370.  
  371. $smt = $db_stage->prepare("REPLACE INTO event_kind (id,name_en,name_gr,Datetime_updated,hide) VALUES (?,?,?,?,?); ");
  372. $smt->bindValue(1, $id);
  373. $smt->bindValue(2, $name_en);
  374. $smt->bindValue(3, $name_gr);
  375. $smt->bindValue(4, $todays_date);
  376. $smt->bindValue(5, $hide);
  377. $smt->execute();
  378. }
  379. fclose($handle);
  380. }
  381.  
  382. function event_type_to_prod($since_date,$organizer_ids, $my_file) {
  383. include("db.php");
  384. include("db_mguides_stage.php");
  385. $todays_date = date('Y-m-d H:i:s');
  386. $place_holders = implode(',', array_fill(0, count($organizer_ids), '?'));
  387.  
  388. $statement = $db->prepare("select * from event_type");
  389. $statement->execute();
  390.  
  391. $count = $statement->rowCount();
  392. if($count < 1) {
  393. $msg = "Event type table is already updated!"."\n";
  394. }
  395. else {
  396. $msg = "<b>Event type table is being updated....</b>"."\n";
  397. }
  398. echo $msg."<br/>";
  399.  
  400. $handle = fopen('../../log_files/'.$my_file, 'a') or die('Cannot open file: '.$my_file);
  401. fwrite($handle, pack("CCC",0xef,0xbb,0xbf));
  402. fwrite($handle, $msg);
  403.  
  404. $since_date = date('Y-m-d H:i:s', strtotime($since_date) + 14400);
  405. $todays_date = date('Y-m-d H:i:s');
  406.  
  407. include("db_prod.php");
  408.  
  409. while ($result = $statement->fetchObject()) {
  410.  
  411. $id=$result->id;
  412. $name_en=$result->name_en;
  413. $name_gr=$result->name_gr;
  414. $Datetime_updated=$result->Datetime_updated;
  415. $hide=$result->hide;
  416.  
  417. //Event kind
  418.  
  419. $smt = $db_stage->prepare("REPLACE INTO event_type (id,name_en,name_gr,Datetime_updated,hide) VALUES (?,?,?,?,?); ");
  420. $smt->bindValue(1, $id);
  421. $smt->bindValue(2, $name_en);
  422. $smt->bindValue(3, $name_gr);
  423. $smt->bindValue(4, $todays_date);
  424. $smt->bindValue(5, $hide);
  425. $smt->execute();
  426. }
  427. fclose($handle);
  428. }
  429.  
  430. function venues_to_prod($since_date,$venue_ids,$my_file) {
  431. include("db.php");
  432. include("db_mguides_stage.php");
  433. $todays_date = date('Y-m-d H:i:s');
  434. $place_holders = implode(',', array_fill(0, count($venue_ids), '?'));
  435.  
  436. $statement = $db->prepare("select * from venues where id in ($place_holders)");
  437. $statement->execute($venue_ids);
  438.  
  439. $count = $statement->rowCount();
  440. if($count < 1) {
  441. $msg = "Venues table is already updated!"."\n";
  442. }
  443. else {
  444. $msg = "<b>Venues table is being updated....</b>"."\n";
  445. }
  446. echo $msg."<br/>";
  447.  
  448. $handle = fopen('../../log_files/'.$my_file, 'a') or die('Cannot open file: '.$my_file);
  449. fwrite($handle, pack("CCC",0xef,0xbb,0xbf));
  450. fwrite($handle, $msg);
  451.  
  452. $since_date = date('Y-m-d H:i:s', strtotime($since_date) + 14400);
  453.  
  454. include("db_prod.php");
  455.  
  456. while ($result = $statement->fetchObject()) {
  457.  
  458. $id=$result->id;
  459. $name=$result->name;
  460. $type=$result->type;
  461. $address=$result->address;
  462. $zip=$result->zip;
  463. $longtitude=$result->longtitude;
  464. $latitude=$result->latitude;
  465. $city_id=$result->city_id;
  466. $telephone=$result->telephone;
  467. $website=$result->website;
  468. $email=$result->email;
  469. $fax=$result->fax;
  470. $supervisor_name=$result->supervisor_name;
  471. $supervisor_last=$result->supervisor_last;
  472. $supervisor_phone=$result->supervisor_phone;
  473. $supervisor_email=$result->supervisor_email;
  474. $material_url = $result->material_url;
  475. $venue_pdf=$result->venue_pdf;
  476. $Datetime_updated=$result->Datetime_updated;
  477. $hide=$result->hide;
  478. $Last_updated_by=$result->Last_updated_by;
  479. $deleted_by=$result->deleted_by;
  480.  
  481. $smt = $db_stage->prepare("REPLACE INTO venues (id,name,address,name_en,address_en,longtitude,latitude,city_id,telephone,website,email,Datetime_updated,hide,organizer_id) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?); ");
  482. $smt->bindValue(1, $id);
  483. $smt->bindValue(2, $name);
  484. $smt->bindValue(3, $address);
  485. $smt->bindValue(4, $name);
  486. $smt->bindValue(5, $address);
  487. $smt->bindValue(6, $longtitude);
  488. $smt->bindValue(7, $latitude);
  489. $smt->bindValue(8, $city_id);
  490. $smt->bindValue(9, $telephone);
  491. $smt->bindValue(10, $website);
  492. $smt->bindValue(11, $email);
  493. $smt->bindValue(12, $todays_date);
  494. $smt->bindValue(13, $hide);
  495. $smt->bindValue(14, 1);
  496. $smt->execute();
  497.  
  498. $message = "Venue with id = ".$id." & name ='".$name."'' was inserted succesfully "."\n";
  499. echo $message."<br/>";
  500. fwrite($handle, pack("CCC",0xef,0xbb,0xbf));
  501. fwrite($handle, $message);
  502.  
  503. }
  504. echo "Venues updated:".count(array_unique(array_filter($venue_ids)))."<br/>";
  505. fclose($handle);
  506. }
  507.  
  508. function cities_to_prod($since_date,$my_file) {
  509. include("db.php");
  510. include("db_mguides_stage.php");
  511. $todays_date = date('Y-m-d H:i:s');
  512. $query='select * from cities where Datetime_updated > ?';
  513. $statement = $db->prepare($query);
  514. $statement->execute(array($since_date));
  515. //var_dump($result);
  516. $count = $statement->rowCount();
  517. if($count < 1) {
  518. $msg = "Cities table is already updated!"."\n";
  519. }
  520. else {
  521. $msg = "<b>Cities table is being updated....</b>"."\n";
  522. }
  523. echo $msg."<br/>";
  524.  
  525. $handle = fopen('../../log_files/'.$my_file, 'a') or die('Cannot open file: '.$my_file);
  526. fwrite($handle, pack("CCC",0xef,0xbb,0xbf));
  527. fwrite($handle, $msg);
  528. include("db_prod.php");
  529.  
  530. while ($result = $statement->fetchObject()) {
  531.  
  532. $id=$result->id;
  533. $name_gr=$result->name_gr;
  534. $name_en=$result->name_en;
  535. $region_id=$result->region_id;
  536. $latitude=$result->latitude;
  537. $longitude=$result->longitude;
  538. $description=$result->description;
  539. $Last_updated_by=$result->Last_updated_by;
  540. $hide=$result->hide;
  541. $deleted_by=$result->deleted_by;
  542.  
  543.  
  544. $smt = $db_stage->prepare("REPLACE INTO cities (id,name_gr,name_en,region_id,latitude,longitude,description,Last_updated_by,hide,deleted_by) VALUES (?,?,?,?,?,?,?,?,?,?); ");
  545. $smt->bindValue(1, $id);
  546. $smt->bindValue(2, $name_gr);
  547. $smt->bindValue(3, $name_en);
  548. $smt->bindValue(4, $region_id);
  549. $smt->bindValue(5, $latitude);
  550. $smt->bindValue(6, $longitude);
  551. $smt->bindValue(7, $description);
  552. $smt->bindValue(8, $Last_updated_by);
  553. $smt->bindValue(9, $hide);
  554. $smt->bindValue(10, $deleted_by);
  555.  
  556. $smt->execute();
  557.  
  558. $message = "city with id = ".$id." & name = '".$name_gr."'' was inserted succesfully."."\n";
  559. echo $message."<br/>";
  560. fwrite($handle, pack("CCC",0xef,0xbb,0xbf));
  561. fwrite($handle, $message);
  562.  
  563. }
  564. fclose($handle);
  565. }
  566.  
  567. function continents_to_prod($since_date,$my_file) {
  568. include("db.php");
  569. $query='select * from continents where Datetime_updated > ?';
  570. $statement = $db->prepare($query);
  571. $statement->execute(array($since_date));
  572. //var_dump($result);
  573. $count = $statement->rowCount();
  574. if($count < 1) {
  575. $msg = "Continents table is already updated!"."\n";
  576. }
  577. else {
  578. $msg = "<b>Continents table is being updated....</b>"."\n";
  579. }
  580. echo $msg."<br/>";
  581.  
  582. $handle = fopen('../../log_files/'.$my_file, 'a') or die('Cannot open file: '.$my_file);
  583. fwrite($handle, pack("CCC",0xef,0xbb,0xbf));
  584. fwrite($handle, $msg);
  585. include("db_prod.php");
  586.  
  587. while ($result = $statement->fetchObject()) {
  588.  
  589. $id=$result->id;
  590. $name_gr=$result->name_gr;
  591. $name_en=$result->name_en;
  592. $hide=$result->Hide;
  593. $Last_updated_by=$result->Last_updated_by;
  594. $deleted_by=$result->deleted_by;
  595.  
  596. $smt = $db_prod->prepare("REPLACE INTO continents (id,name_gr,name_en,Hide,Last_updated_by,deleted_by) VALUES (?,?,?,?,?,?); ");
  597. $smt->bindValue(1, $id);
  598. $smt->bindValue(2, $name_gr);
  599. $smt->bindValue(3, $name_en);
  600. $smt->bindValue(4, $hide);
  601. $smt->bindValue(5, $Last_updated_by);
  602. $smt->bindValue(6, $deleted_by);
  603.  
  604. $smt->execute();
  605.  
  606. $message = "Continent with id = ".$id." & name = '".$name_gr."'' was inserted succesfully."."\n";
  607. echo $message."<br/>";
  608. fwrite($handle, pack("CCC",0xef,0xbb,0xbf));
  609. fwrite($handle, $message);
  610.  
  611. }
  612. fclose($handle);
  613. }
  614.  
  615. function countries_to_prod($since_date,$my_file) {
  616. include("db.php");
  617. $query='select * from countries where Datetime_updated > ?';
  618. $statement = $db->prepare($query);
  619. $statement->execute(array($since_date));
  620. //var_dump($result);
  621. $count = $statement->rowCount();
  622. if($count < 1) {
  623. $msg = "Countries table is already updated!"."\n";
  624. }
  625. else {
  626. $msg = "<b>Countries table is being updated....</b>"."\n";
  627. }
  628. echo $msg."<br/>";
  629.  
  630. $handle = fopen('../../log_files/'.$my_file, 'a') or die('Cannot open file: '.$my_file);
  631. fwrite($handle, pack("CCC",0xef,0xbb,0xbf));
  632. fwrite($handle, $msg);
  633. include("db_prod.php");
  634.  
  635. while ($result = $statement->fetchObject()) {
  636.  
  637. $id=$result->id;
  638. $name_gr=$result->name_gr;
  639. $name_en=$result->name_en;
  640. $continent_id=$result->continent_id;
  641. $hide=$result->hide;
  642. $Last_updated_by=$result->Last_updated_by;
  643. $deleted_by=$result->deleted_by;
  644.  
  645.  
  646. $smt = $db_prod->prepare("REPLACE INTO countries (id,name_gr,name_en,continent_id,hide,Last_updated_by,deleted_by) VALUES (?,?,?,?,?,?,?); ");
  647. $smt->bindValue(1, $id);
  648. $smt->bindValue(2, $name_gr);
  649. $smt->bindValue(3, $name_en);
  650. $smt->bindValue(4, $continent_id);
  651. $smt->bindValue(5, $hide);
  652. $smt->bindValue(6, $Last_updated_by);
  653. $smt->bindValue(7, $deleted_by);
  654.  
  655. $smt->execute();
  656.  
  657. $message = "Country with id = ".$id." & name = '".$name_gr."'' was inserted succesfully."."\n";
  658. echo $message."<br/>";
  659. fwrite($handle, pack("CCC",0xef,0xbb,0xbf));
  660. fwrite($handle, $message);
  661.  
  662. }
  663. fclose($handle);
  664. }
  665.  
  666. function regions_to_prod($since_date,$my_file)
  667. {
  668. include("db.php");
  669. $query='select * from regions where Datetime_updated > ?';
  670. $statement = $db->prepare($query);
  671. $statement->execute(array($since_date));
  672. //var_dump($result);
  673. $count = $statement->rowCount();
  674. if($count < 1) {
  675. $msg = "Regions table is already updated!"."\n";
  676. }
  677. else {
  678. $msg = "<b>Regions table is being updated....</b>"."\n";
  679. }
  680. echo $msg."<br/>";
  681.  
  682. $handle = fopen('../../log_files/'.$my_file, 'a') or die('Cannot open file: '.$my_file);
  683. fwrite($handle, pack("CCC",0xef,0xbb,0xbf));
  684. fwrite($handle, $msg);
  685. include("db_prod.php");
  686.  
  687. while ($result = $statement->fetchObject()) {
  688.  
  689. $id=$result->id;
  690. $name_gr=$result->name_gr;
  691. $name_en=$result->name_en;
  692. $country_id=$result->country_id;
  693. $hide=$result->hide;
  694. $Last_updated_by=$result->Last_updated_by;
  695. $deleted_by=$result->deleted_by;
  696.  
  697.  
  698. $smt = $db_prod->prepare("REPLACE INTO regions (id,name_gr,name_en,country_id,hide,Last_updated_by,deleted_by) VALUES (?,?,?,?,?,?,?); ");
  699. $smt->bindValue(1, $id);
  700. $smt->bindValue(2, $name_gr);
  701. $smt->bindValue(3, $name_en);
  702. $smt->bindValue(4, $country_id);
  703. $smt->bindValue(5, $hide);
  704. $smt->bindValue(6, $Last_updated_by);
  705. $smt->bindValue(7, $deleted_by);
  706.  
  707. $smt->execute();
  708.  
  709. $message = "region with id = ".$id." & name = '".$name_gr."'' was inserted succesfully."."\n";
  710. echo $message."<br/>";
  711. fwrite($handle, pack("CCC",0xef,0xbb,0xbf));
  712. fwrite($handle, $message);
  713.  
  714. }
  715. fclose($handle);
  716. }
  717.  
  718. function files_to_prod($since_date,$my_file) {
  719. include("db.php");
  720. include("db_mguides_stage.php");
  721. $todays_date = date('Y-m-d H:i:s');
  722. $query='select * from venue_uploads where date_uploaded > ?';
  723. $statement = $db->prepare($query);
  724. $statement->execute(array($since_date));
  725. //var_dump($result);
  726. $count = $statement->rowCount();
  727. if($count < 1) {
  728. $msg = "Files table is already updated!"."\n";
  729. }
  730. else {
  731. $msg = "<b>Files table is being updated....</b>"."\n";
  732. }
  733. echo $msg."<br/>";
  734.  
  735. $handle = fopen('../../log_files/'.$my_file, 'a') or die('Cannot open file: '.$my_file);
  736. fwrite($handle, pack("CCC",0xef,0xbb,0xbf));
  737. fwrite($handle, $msg);
  738. include("db_prod.php");
  739.  
  740. while ($result = $statement->fetchObject()) {
  741.  
  742. $id=$result->id;
  743. $name=$result->name;
  744. $file_path=$result->file_path;
  745. $date_uploaded=$result->date_uploaded;
  746.  
  747. $smt = $db_prod->prepare("REPLACE INTO event_document (id,name,file_path,date_uploaded) VALUES (?,?,?,?); ");
  748. $smt->bindValue(1, $id);
  749. $smt->bindValue(2, $name);
  750. $smt->bindValue(3, $file_path);
  751. $smt->bindValue(4, $date_uploaded);
  752.  
  753. $smt->execute();
  754.  
  755. $message = "File with id = ".$id." & name = '".$name."'' was inserted succesfully."."\n";
  756. echo $message."<br/>";
  757. fwrite($handle, pack("CCC",0xef,0xbb,0xbf));
  758. fwrite($handle, $message);
  759.  
  760. }
  761. fclose($handle);
  762. }
  763.  
  764. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement