Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > .NET Languages
You last visited: Today at 18:21

  • Please register to post and access all features, it's quick, easy and FREE!

 

[HELP] PHP in CSHTML

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Jun 2013
Posts: 22
Received Thanks: 0
[HELP] PHP in CSHTML

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)



Minotaurus-Rappelz is offline  
Old   #2

 
elite*gold: 237
Join Date: Sep 2010
Posts: 1,151
Received Thanks: 4,894
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


»jD« is offline  
Old   #3
 
elite*gold: 0
Join Date: Jun 2013
Posts: 22
Received Thanks: 0
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
Minotaurus-Rappelz is offline  
Old   #4

 
elite*gold: 237
Join Date: Sep 2010
Posts: 1,151
Received Thanks: 4,894
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
»jD« is offline  
Reply



« Previous Thread | Next Thread »



All times are GMT +2. The time now is 18:21.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Abuse
Copyright ©2017 elitepvpers All Rights Reserved.