Advertisement
lil_bugga

Social Network - test2.php

Aug 8th, 2014
305
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. session_start();
  3. include_once("includes/check_login_status.php");
  4. include_once("includes/link_checker.php");
  5.  
  6. // AJAX CALLS THIS LOGIN CODE TO EXECUTE
  7. if (isset($_POST) && !empty($_POST)) {
  8.  check_links();
  9.  } else {
  10. ?>
  11.  
  12. <html>
  13. <head>
  14. <title>testing</title>
  15. <script type="text/javascript" src="js/main.js"></script>
  16. <script src="js/ajax.js"></script>
  17. <script>
  18. function emptyElement(x){
  19.     _(x).innerHTML = "";
  20. }
  21.  
  22. function cleanURL(){
  23.     var params = []; //creates an array to store the form data
  24.     var facebook_url = _("facebook_link").value;
  25.     var twitter_url = _("twitter_link").value;
  26.     var google_url = _("google_link").value;
  27.         google_url = google_url.replace(/\+/g, ":plus:");
  28.     var instagram_url = _("instagram_link").value;
  29.     var youtube_url = _("youtube_link").value;
  30.     var personal_url = _("personal_link").value;
  31.     var saved = "true";
  32.    
  33.     if(facebook_url == "" && twitter_url == "" && google_url == "" &&
  34.        instagram_url == "" && youtube_url == "" && personal_url == "" ){
  35.         _("status").innerHTML = "Please provide at least one link before clicking submit";
  36.     } else {_("submitbtn").style.display = "none";
  37.         _("status").innerHTML = 'please wait ...';
  38.         var ajax = ajaxObj("POST", "test2.php");
  39.        
  40.         if (facebook_url !== "") {
  41.             params.push("fb=" + facebook_url); //creates key value pair and adds to array
  42.         }
  43.        
  44.         if (twitter_url !== "") {
  45.              params.push("tw=" + twitter_url); //creates key value pair and adds to array
  46.         }
  47.        
  48.         if (google_url !== "") {
  49.             params.push("go=" + google_url); //creates key value pair and adds to array
  50.         }
  51.        
  52.         if (instagram_url !== "") {
  53.              params.push("in=" + instagram_url); //creates key value pair and adds to array
  54.         }
  55.        
  56.         if (youtube_url !== "") {
  57.             params.push("yt=" + youtube_url); //creates key value pair and adds to array
  58.         }
  59.        
  60.         if (personal_url !== "") {
  61.              params.push("pe=" + personal_url); //creates key value pair and adds to array
  62.         }
  63.  
  64.         ajax.onreadystatechange = function() {
  65.             if(ajaxReturn(ajax) == true) {
  66.                 if (ajax.responseText == "") {
  67.                 _("status").innerHTML = "Sorry";
  68.             } else {           
  69.                 result = ajax.responseText.split("|");
  70.                 var arrayLength = result.length;
  71.                
  72.                 // loop through all if statments for each element within the result[] array            
  73.                 for (var i = 0; i < arrayLength; i++) {
  74.                     // Check for facebook response strings
  75.                     if (result[i] == "fb1") {
  76.                       _("fb").innerHTML = "fb1 message";
  77.                     }
  78.                    
  79.                     if (result[i] == "fb2") {
  80.                       _("fb").innerHTML = "fb2 message";
  81.                     }
  82.                    
  83.                     if (result[i] == "fb3") {
  84.                       _("fb").innerHTML = "fb3 message";
  85.                     }
  86.                    
  87.                     if (result[i] == "fb4") {
  88.                       _("fb").innerHTML = "fb4 message";
  89.                     }
  90.                    
  91.                     // Check for twitter response strings
  92.                     if (result[i] == "tw1") {
  93.                       _("tw").innerHTML = "tw1 message";
  94.                     }
  95.                    
  96.                     if (result[i] == "tw2") {
  97.                       _("tw").innerHTML = "tw2 message";
  98.                     }
  99.                    
  100.                     if (result[i] == "tw3") {
  101.                       _("tw").innerHTML = "tw3 message";
  102.                     }
  103.                    
  104.                     if (result[i] == "tw4") {
  105.                       _("tw").innerHTML = "tw4 message";
  106.                     }
  107.                    
  108.                     // Check for google+ response strings
  109.                     if (result[i] == "go1") {
  110.                       _("go").innerHTML = "go1 message";
  111.                     }
  112.                    
  113.                     if (result[i] == "go2") {
  114.                       _("go").innerHTML = "go2 message";
  115.                     }
  116.                    
  117.                     if (result[i] == "go3") {
  118.                       _("go").innerHTML = "go3 message";
  119.                     }
  120.                    
  121.                     if (result[i] == "go4") {
  122.                       _("go").innerHTML = "go4 message";
  123.                     }
  124.                    
  125.                     // Check for instagram response strings
  126.                     if (result[i] == "in1") {
  127.                       _("in").innerHTML = "in1 message";
  128.                     }
  129.                    
  130.                     if (result[i] == "in2") {
  131.                       _("in").innerHTML = "in2 message";
  132.                     }
  133.                    
  134.                     if (result[i] == "in3") {
  135.                       _("in").innerHTML = "in3 message";
  136.                     }
  137.                    
  138.                     if (result[i] == "in4") {
  139.                       _("in").innerHTML = "in4 message";
  140.                     }
  141.                    
  142.                     // Check for youtube response strings
  143.                     if (result[i] == "yt1") {
  144.                       _("yt").innerHTML = "yt1 message";
  145.                     }
  146.                    
  147.                     if (result[i] == "yt2") {
  148.                       _("yt").innerHTML = "yt2 message";
  149.                     }
  150.                    
  151.                     if (result[i] == "yt3") {
  152.                       _("yt").innerHTML = "yt3 message";
  153.                     }
  154.                    
  155.                     if (result[i] == "yt4") {
  156.                       _("yt").innerHTML = "yt4 message";
  157.                     }
  158.                    
  159.                     // Check for personal response strings
  160.                     if (result[i] == "pe1") {
  161.                       _("pe").innerHTML = "pe1 message";
  162.                     }
  163.                    
  164.                     if (result[i] == "pe2") {
  165.                       _("pe").innerHTML = "pe2 message";
  166.                     }
  167.                    
  168.                     if (result[i] == "pe3") {
  169.                       _("pe").innerHTML = "pe3 message";
  170.                     }
  171.                    
  172.                     if (result[i] == "pe4") {
  173.                       _("pe").innerHTML = "pe4 message";
  174.                     }
  175.                 }
  176.             }
  177.         }
  178.     }
  179.     ajax.send(params.join("&")); // sends the array of key value pairs to php and joins enteries with &
  180.     }
  181. }
  182. </script>
  183. </head>
  184. <body>
  185.     <p id="status"></p>
  186.  
  187.     <form id="linkform" onSubmit="return false;">
  188.         <p>Facebook: <input type="text" id="facebook_link"><p id="fb"></p></p>
  189.         <p>Twitter: <input type="text" id="twitter_link"><p id="tw"></p></p>
  190.         <p>Google+: <input type="text" id="google_link"><p id="go"></p></p>
  191.         <p>Instagram: <input type="text" id="instagram_link"><p id="in"></p></p>
  192.         <p>YouTube: <input type="text" id="youtube_link"><p id="yt"></p></p>
  193.         <p>Personal: <input type="text" id="personal_link"><p id="pe"></p></p>
  194.         <br/><button id="submitbtn" onClick="cleanURL()">Save</button>
  195.     </form>
  196. <?php } ?>
  197. </body>
  198. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement