Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > .NET Languages
You last visited: Today at 15:38

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

Advertisement



[HELP] PHP in CSHTML

Discussion on [HELP] PHP in CSHTML within the .NET Languages forum part of the Coders Den category.

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 07/02/2013, 15:27   #2
 
»jD«'s Avatar
 
elite*gold: 237
Join Date: Sep 2010
Posts: 1,152
Received Thanks: 4,910
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 07/02/2013, 15:49   #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 07/03/2013, 04:25   #4
 
»jD«'s Avatar
 
elite*gold: 237
Join Date: Sep 2010
Posts: 1,152
Received Thanks: 4,910
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  

Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.