Advertisement
Guest User

lol.php

a guest
Jun 22nd, 2018
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.68 KB | None | 0 0
  1. private var formNick = ""; //this is the field where the player will put the name to login
  2. private var formPassword = ""; //this is his password
  3. private var RformNick = ""; //this is the field where the player will put the name to login
  4. private var RformPassword = "";
  5. private var Remail = "";
  6. private var TRformPassword = "";
  7. public var guiSkin : GUISkin;
  8. var LoadOut : System.Boolean;
  9. var LoadOutText = "";
  10. var formText = ""; //this field is where the messages sent by PHP script will be in
  11.  
  12. var URL = "http://credmanager.username.c9.io/Login.php"; //change for your URL
  13. // var hash = "812ca28212be5705ad52010bccc9ea3f"; //change your secret code, and remember to change into the PHP file too
  14. var DoLogin : System.Boolean;
  15.  
  16. private var textrect = Rect (10, 150, 500, 500); //just make a GUI object rectangle
  17. function Start (){
  18. PlayerPrefs.DeleteAll();
  19.  
  20.  
  21. }
  22. function OnGUI() {
  23. if(LoadOut){
  24. GUI.skin = guiSkin;
  25. GUI.Box (new Rect(Screen.width/2 - 150, Screen.height/2 - 30, 300, 60), LoadOutText);
  26.  
  27.  
  28. }else{
  29. GUI.Window (0, new Rect (Screen.width/2 - 250, Screen.height/2 - 150, 500, 400),Login, "");
  30. }
  31. }
  32. function Login (id : int){
  33.  
  34. if(DoLogin){
  35.  
  36. GUILayout.BeginVertical();
  37.  
  38. GUI.skin = guiSkin;
  39.  
  40. GUILayout.Box (/* new Rect (Screen.width/2 - 250, Screen.height/2 - 150, 500, 400),*/"Login");
  41.  
  42. GUILayout.BeginHorizontal();
  43. GUILayout.FlexibleSpace();
  44. GUILayout.Label( "Username:" ); //text with your nick
  45. formNick = GUILayout.TextField ( formNick , 15, GUILayout.Width(345), GUILayout.Height(35));
  46. GUILayout.EndHorizontal();
  47. GUILayout.Space(10);
  48.  
  49. GUILayout.BeginHorizontal();
  50. GUILayout.FlexibleSpace();
  51. GUILayout.Label( "Password:" );
  52. formPassword = GUILayout.TextField (formPassword , 15, GUILayout.Width(345), GUILayout.Height(35) ); //same as above, but for password
  53. GUILayout.EndHorizontal();
  54. GUILayout.Space(10);
  55. GUILayout.BeginHorizontal();
  56. GUILayout.Space(5);
  57. if ( GUILayout.Button ("Login" ) ){ //just a button
  58. Action("Login");
  59. }
  60. if ( GUILayout.Button ( "Sign Up" ) ){ //just a button
  61. DoLogin = false;
  62.  
  63. }
  64. GUILayout.EndHorizontal();
  65. GUILayout.EndVertical();
  66.  
  67. }else{
  68.  
  69. GUI.skin = guiSkin;
  70.  
  71. GUILayout.Box ("Register");
  72.  
  73. GUILayout.BeginHorizontal();
  74. GUILayout.FlexibleSpace();
  75. GUILayout.Label("Username:" );
  76. RformNick = GUILayout.TextField (RformNick, 15,GUILayout.Width(300) ,GUILayout.Height(35) );
  77.  
  78. GUILayout.EndHorizontal();
  79.  
  80. GUILayout.BeginHorizontal();
  81. GUILayout.FlexibleSpace();
  82. GUILayout.Label("Password:" );
  83. RformPassword = GUILayout.TextField (RformPassword , 15,GUILayout.Width(300) , GUILayout.Height(35) );
  84. GUILayout.EndHorizontal();
  85.  
  86. GUILayout.BeginHorizontal();
  87. GUILayout.FlexibleSpace();
  88. GUILayout.Label("Password:" );
  89.  
  90. TRformPassword = GUILayout.TextField (TRformPassword , 15,GUILayout.Width(300) , GUILayout.Height(35) );
  91. GUILayout.EndHorizontal();
  92.  
  93. GUILayout.BeginHorizontal();
  94. GUILayout.FlexibleSpace();
  95. GUILayout.Label("Email:" );
  96. Remail = GUILayout.TextField (Remail, 75,GUILayout.Width(300) , GUILayout.Height(35) );
  97. GUILayout.EndHorizontal();
  98.  
  99.  
  100. if ( GUILayout.Button ("Finish" ) ){ //just a button
  101. Action("Register");
  102. }
  103. if ( GUILayout.Button ("Back" ) ){ //just a button
  104. DoLogin = true;
  105.  
  106. }
  107.  
  108.  
  109.  
  110. }
  111.  
  112.  
  113. //GUI.TextArea( textrect, formText );
  114. }
  115.  
  116. function Action(Act : String) {
  117.  
  118.  
  119. var form = new WWWForm(); //here you create a new form connection
  120. //add your hash code to the field myform_hash, check that this variable name is the same as in PHP file
  121. var tempURL : String;
  122. if(Act =="Login"){
  123. tempURL = URL + "?User="+formNick+"&Pass="+formPassword+"&Act="+Act;
  124. }else{
  125. tempURL = URL + "?User="+RformNick+"&Pass="+RformPassword+"&Act="+Act+"&Email="+Remail;
  126. }
  127. var w = WWW(tempURL); //here we create a var called 'w' and we sync with our URL and the form
  128.  
  129. yield w; //we wait for the form to check the PHP file, so our game dont just hang
  130.  
  131. if (w.error != null) {
  132. //print(w.error); //if there is an error, tell us
  133. } else {
  134. if(w.data == " Correct"){
  135. print("Logging In...");
  136. LoadOut = true;
  137. LoadOutText = "Signing In...";
  138. yield WaitForSeconds(5);
  139. PlayerPrefs.SetString("RegUser",formNick);
  140.  
  141. Application.LoadLevel(1);
  142. }
  143. if(w.data == " Wrong"){
  144. LoadOut = true;
  145. LoadOutText = "Wrong Password";
  146. yield WaitForSeconds(3);
  147. LoadOut = false;
  148. }
  149. if(w.data == " No User"){
  150. LoadOut = true;
  151. LoadOutText = "No Registered User Found";
  152. yield WaitForSeconds(3);
  153. LoadOut = false;
  154. }
  155. if(w.data == " ILLEGAL REQUEST"){
  156. LoadOut = true;
  157. LoadOutText = "Server Error";
  158. yield WaitForSeconds(3);
  159. LoadOut = false;
  160. }
  161. if(w.data == " Registered"){
  162. print("Account Created. Logging In.");
  163. LoadOut = true;
  164. LoadOutText = "Creating Account Logging In...";
  165. PlayerPrefs.SetString("RegUser",RformNick);
  166. yield WaitForSeconds(5);
  167. Application.LoadLevel(1);
  168.  
  169. }
  170. if(w.data == " ERROR"){
  171. LoadOut = true;
  172. LoadOutText = "Login Error. Restarting.";
  173. yield WaitForSeconds(3);
  174. Application.LoadLevel(0);
  175. }
  176. print(w.data);
  177.  
  178. // formText = w.data; //here we return the data our PHP told us
  179. w.Dispose(); //clear our form in game
  180. }
  181.  
  182. formNick = ""; //just clean our variables
  183. formPassword = "";
  184.  
  185.  
  186. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement