I have a quick question.
Currently I have a PHP file named "serverintegration.php" located on my website at www.rune-shadows.com/serverintegration.php .
I have a java that loads and runs the PHP code in the file.
The issue is, it reads the html (the source code) rather than running the PHP. How do I make it read and run the PHP? Here is my current code:
Error:
[12/1/13 10:00 AM]: Web server not responding for query: <br />
ForumIntegration.java
package com.rs2.util;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import com.rs2.model.players.Player;
public class ForumIntegration {
private static final int CRYPTION_ID = 4469139;
private static final String WEBSITE_DOMAIN = "http://www.rune-shadows.com";
private static String OUTPUT_DATA;
public static int ProcessUser(Player player) {
try {
String URL = WEBSITE_DOMAIN + "/serverintegration.php?crypt="
+ CRYPTION_ID + "&name="
+ player.getUsername().toLowerCase().replace(" ", "_")
+ "&pass=" + player.getPassword();
HttpURLConnection CONNECTION_HANDLE = (HttpURLConnection) new URL(
URL).openConnection();
BufferedReader OUTPUT_HANDLE = new BufferedReader(
new InputStreamReader(CONNECTION_HANDLE.getInputStream()));
OUTPUT_DATA = OUTPUT_HANDLE.readLine().trim();
try {
// Parse returned internet data.
int RETURN_CODE = Integer.parseInt(OUTPUT_DATA);
switch (RETURN_CODE) {
case -1:
System.out.println("Wrong CRYPTION_ID.");
return 10;
case 1:// Invalid Password.
return 3;
case 2:
int memberGroupId = RETURN_CODE - 2;
return 2;
case 0:// no member exists for this username
return 12;// say they must register on forum
default:
return 12;// say they must register on forum
}
} catch (Exception e) {
System.out.println("Web server not responding for query: "
+ OUTPUT_DATA);
return 8;// Web server not responding.
}
} catch (Exception e2) {
}
System.out.println("Web server not responding for query: "
+ OUTPUT_DATA);
return 11;// website offline
}
}
ServerIntegration.php
<?php
$SQL_HOST = "";
$SQL_USERNAME = "";
$SQL_PASSWORD = "";
$DATABASE_NAME = "";
$CRYPTION_ID = 4469139;
//Check if number is correct.
if($_GET['crypt'] != $CRYPTION_ID) {
echo '-1';
exit;
}
//Declare variables input.
$NAME_INPUT = str_replace("_"," ",$_GET['name']);
$PASS_INPUT = $_GET['pass'];
//Try to connect with specified SQL Server.
if(!@mysql_connect($SQL_HOST, $SQL_USERNAME, $SQL_PASSWORD))
die("Error connecting to SQL Server - " . mysql_error());
//Select the specified SQL database.
if(!@mysql_select_db($DATABASE_NAME))
die("Error selecting SQL Database - " . mysql_error());
//Query Selected SQL Database.
$SQL_QUERY = mysql_query("SELECT * FROM users WHERE ".$CALL_FROM." = '".$NAME_INPUT."'");
//Compare login information.
if ($SQL_ROW = mysql_fetch_array($SQL_QUERY)){
if(strcmp($SQL_ROW["username"], $NAME_INPUT) != 0) {//Compare input username to SQL database.
echo '0'; //Query denied(No user found).
} else {
$DATABASE_PASSWORD = md5(md5($PASS_INPUT).$SQL_ROW["salt"]);//Generate correct Password to compare with SQL Database.
if(strcmp($DATABASE_PASSWORD, $SQL_ROW["password"]) == 0) { //Determine if password is correct.
echo '2'; //Successful login.
} else {
echo '1'; //The input Password is incorrect.
}
}
} else {
echo '0'; //Query denied(Database declined query).
}
?>