Guest User

Untitled

a guest
May 21st, 2018
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.93 KB | None | 0 0
  1. <?php
  2. /* Get Data From Flash*/
  3. $choice = $_GET['choice'];
  4.  
  5. /* Get Data From XML*/
  6. $xml = simplexml_load_file('intelpoll.xml');
  7. $choice1 = (string)$xml->choice1;
  8. $choice2 = (string)$xml->choice2;
  9. $choice3 = (string)$xml->choice3;
  10. $choice4 = (string)$xml->choice4;
  11. $choice5 = (string)$xml->choice5;
  12. $choice6 = (string)$xml->choice6;
  13. $choice7 = (string)$xml->choice7;
  14. $choice8 = (string)$xml->choice8;
  15. $choice9 = (string)$xml->choice9;
  16. $choice10 = (string)$xml->choice10;
  17. $choice11 = (string)$xml->choice11;
  18. $choice12 = (string)$xml->choice12;
  19. $choice13 = (string)$xml->choice13;
  20. $choice14 = (string)$xml->choice14;
  21. $choice15 = (string)$xml->choice15;
  22. $choice16 = (string)$xml->choice16;
  23. $choice17 = (string)$xml->choice17;
  24. $choice18 = (string)$xml->choice18;
  25. $choice19 = (string)$xml->choice19;
  26. $choice20 = (string)$xml->choice20;
  27. $choice21 = (string)$xml->choice21;
  28. $choice22 = (string)$xml->choice22;
  29. $choice23 = (string)$xml->choice23;
  30. $choice24 = (string)$xml->choice24;
  31. $choice25 = (string)$xml->choice25;
  32.  
  33. /*Compute Poll Data*/
  34. for ( $i = 1; $i <= 25; $i++) {
  35.     if($choice == $i){
  36.         $chosen = 'choice'.$i;
  37.         $$chosen = $$chosen + 1;
  38.         echo 'choice'.$i.': '.$$chosen;
  39.     }
  40. }
  41.  
  42. /* Create RSS/XML */
  43. $feedContent = "<?xml version='1.0' encoding='UTF-8'?>\r\n";
  44. $feedContent = $feedContent . "<items type='array'>\r\n";
  45. $feedContent = $feedContent . "<choice1>" . $choice1 . "</choice1>\r\n";
  46. $feedContent = $feedContent . "<choice2>" . $choice2 . "</choice2>\r\n";
  47. $feedContent = $feedContent . "<choice3>" . $choice3 . "</choice3>\r\n";
  48. $feedContent = $feedContent . "<choice4>" . $choice4 . "</choice4>\r\n";
  49. $feedContent = $feedContent . "<choice5>" . $choice5 . "</choice5>\r\n";
  50. $feedContent = $feedContent . "<choice6>" . $choice6 . "</choice6>\r\n";
  51. $feedContent = $feedContent . "<choice7>" . $choice7 . "</choice7>\r\n";
  52. $feedContent = $feedContent . "<choice8>" . $choice8 . "</choice8>\r\n";
  53. $feedContent = $feedContent . "<choice9>" . $choice9 . "</choice9>\r\n";
  54. $feedContent = $feedContent . "<choice10>" . $choice10 . "</choice10>\r\n";
  55. $feedContent = $feedContent . "<choice11>" . $choice11 . "</choice11>\r\n";
  56. $feedContent = $feedContent . "<choice12>" . $choice12 . "</choice12>\r\n";
  57. $feedContent = $feedContent . "<choice13>" . $choice13 . "</choice13>\r\n";
  58. $feedContent = $feedContent . "<choice14>" . $choice14 . "</choice14>\r\n";
  59. $feedContent = $feedContent . "<choice15>" . $choice15 . "</choice15>\r\n";
  60. $feedContent = $feedContent . "<choice16>" . $choice16 . "</choice16>\r\n";
  61. $feedContent = $feedContent . "<choice17>" . $choice17 . "</choice17>\r\n";
  62. $feedContent = $feedContent . "<choice18>" . $choice18 . "</choice18>\r\n";
  63. $feedContent = $feedContent . "<choice19>" . $choice19 . "</choice19>\r\n";
  64. $feedContent = $feedContent . "<choice20>" . $choice20 . "</choice20>\r\n";
  65. $feedContent = $feedContent . "<choice21>" . $choice21 . "</choice21>\r\n";
  66. $feedContent = $feedContent . "<choice22>" . $choice22 . "</choice22>\r\n";
  67. $feedContent = $feedContent . "<choice23>" . $choice23 . "</choice23>\r\n";
  68. $feedContent = $feedContent . "<choice24>" . $choice24 . "</choice24>\r\n";
  69. $feedContent = $feedContent . "<choice25>" . $choice25 . "</choice25>\r\n";
  70. $feedContent = $feedContent . "</items>";
  71.  
  72. /* Save Generated Data */
  73. $local_file = 'intelpoll.xml';
  74. if (strlen($feedContent) > 10)
  75. {
  76. file_put_contents($local_file, $feedContent);
  77. $destination_file = 'intel/'.$local_file;
  78.     #"/developers/uploadftp/aditya/".$myFileName;  //where you want to throw the file on the webserver (relative to your login dir)
  79.    
  80.     // connection settings
  81.     $ftp_server = 'ftp.cachefly.com';  //address of ftp server.
  82.     $ftp_user_name = 'joystick'; // Username
  83.     $ftp_user_pass = '440236b0';   // Password
  84.    
  85.     $conn_id = ftp_connect($ftp_server) or die("<span style='color:#FF0000'><h2>Couldn't connect to $ftp_server</h2></span>");        // set up basic connection
  86.     #print_r($conn_id);
  87.     $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass) or die("<span style='color:#FF0000'><h2>You do not have access to this ftp server!</h2></span>");   // login with username and password, or give invalid user message
  88.     if ((!$conn_id) || (!$login_result)) {  // check connection
  89.          // wont ever hit this, b/c of the die call on ftp_login
  90.          echo "<span style='color:#FF0000'><h2>FTP connection has failed! <br />";
  91.          echo "Attempted to connect to $ftp_server for user $ftp_user_name</h2></span>";
  92.          exit;
  93.      } else {
  94.      //    echo "Connected to $ftp_server, for user $ftp_user_name <br />";
  95.     }
  96.    
  97.     $upload = ftp_put($conn_id, $destination_file, $local_file, FTP_BINARY);  // upload the file
  98.     if (!$upload) {  // check upload status
  99.      echo "<span style='color:#FF0000'><h2>FTP upload of $myFileName has failed!</h2></span> <br />";
  100.     } else {
  101.      echo "<span style='color:#339900'><h2>Uploading $myFileName Completed Successfully!</h2></span><br /><br />";
  102.     }
  103.    
  104.     ftp_close($conn_id); // close the FTP stream
  105. }
  106. ?>
Add Comment
Please, Sign In to add comment