[HELP] PHP in CSHTML

07/02/2013 13:27 Minotaurus-Rappelz#1
Hi! I've started to code my site and I am stopped at a bug. I'm coding with ASPX. My default is in CSHTML and I'm trying to put in a PHP variable. I have a php script on the side and I'm wodering how to put it in. (Server Status, Connection on the site and Registery is in cause)
07/02/2013 15:27 »jD«#2
You can't integrate PHP and ASP into a single file (unless there is some really messed up library to do it). Both are handled by different pre-processors. What would probably be best is to get your ASP code to invoke the PHP runtime on the PHP script you want and read the output. You can do that easily by calling "php.exe" followed by a path to your PHP script and then "ReadToEnd"-ing on the processes out stream.

Have you considered converting the PHP code to ASP?

-jD
07/02/2013 15:49 Minotaurus-Rappelz#3
I'm kind of new at this. I'm just trying to find a way to create a server status, registery and connection function.

The server status in php is:

Code:
$ip= "7.63.91.132"; //IP Server.
 $port= "4504"; //Port

 @$fp = fsockopen ($ip ,$port , $errno, $errstr, 1);
 if (!$fp)
 echo '<b>Login Server:<font color="#FF0000"><b> Offline</b></font></b>';

 else
 echo '<b>Login Server:<font color="#008000"><b> Online</b></font></b>';

 ?></li>
<li>	
<?php

 $ip= "127.0.0.1"; //IP Server.
 $port= "4515"; //Port

 @$fp = fsockopen ($ip ,$port , $errno, $errstr, 1);
 if (!$fp)
 echo '<b>GameServer:<font color="#FF0000"><b> Offline</b></font></b>';

 else
 echo '<b>GameServer:<font color="#008000"><b> Online</b></font></b>';

 ?></li>
But for the register and connection I don't know. And I dont know how to make the server status work in ASPX
07/03/2013 04:25 »jD«#4
Open a socket and catch the socket exception. If it throws, the socket failed, if it didn't its ok.

EG.

Code:
Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
try 
{
	s.Connect("7.63.91.132", 4504);
	// Code to execute when successful!
}
catch(SocketException)
{
	// Code to run when not successful
}
finally
{
	s.Close();
	s.Dispose();
}
-jD