[How To]Web Server Start and basic Services

11/04/2014 01:58 beetols#1
In this thread i will try to teach some of the basic things for a good website. I can't explain all details but i will try to be as detailed as possible. Some of the things that i will say here can be bullshits for a expert webmaster but i will try to make me understand for who don't know the web languages.

before buy a website that already have a space, you must know that you don't need it, you can manage your website from your own server-host.

there are more ways for install a webserver on your host, a good way is already explained by castor: [Only registered and activated users can see links. Click Here To Register...] using apache.

I start to explain how to install a webserver and configure it using IIS.

Installation IIS

1. Click Start -> All Programs -> Administrative Tools -> Server Manager.

[Only registered and activated users can see links. Click Here To Register...]

2. In the Server Manager window, scroll down to Roles Summary, and then click Add Roles. The Add Roles Wizard will start with a Before You Begin page.

3. Select Web Server (IIS) on the Select Server Roles page. An introductory page will open with links for further information.

[Only registered and activated users can see links. Click Here To Register...]

4. Select the IIS services to be installed on the Select Role Services page. Add only the modules necessary and click Next.

[Only registered and activated users can see links. Click Here To Register...]

5. Add any required role services.

[Only registered and activated users can see links. Click Here To Register...]

6. IIS is now installed with a default configuration for hosting, enable the "CGI" checkbox under "Application Development" and click Next

[Only registered and activated users can see links. Click Here To Register...]

7. Confirm that the Web server works by using [Only registered and activated users can see links. Click Here To Register...].


PHP Configuration

1. Download [Only registered and activated users can see links. Click Here To Register...], open it, go on Products and search 'PHP 5.3.28' press Add on the right of the page under the php version and press install.

[Only registered and activated users can see links. Click Here To Register...]

2. now open 'Internet Information Services(IIS) Manager' in the "Features View" page open the "Handler Mappings" feature.

[Only registered and activated users can see links. Click Here To Register...]

3. In the "Actions" pane click "Add Module Mapping..." and enter the following:
Request path: *.php
Module: FastCgiModule
Executable: C:\[Path to PHP installation]\php-cgi.exe
Name: PHP_via_FastCGI
Click "Request Restrictions" button and then configure the mapping to invoke handler only if request is mapped to a file or a folder, and click ok on all dialogs for safe the configuration.
and again "Add Module Mapping..." and enter the following:
Request path: *.php
Module: FastCgiModule
Executable: C:\[Path to PHP installation]\php-cgi.exe
Name: PHP53_via_FastCGI
Click "Request Restrictions" button and then configure the mapping to invoke handler only if request is mapped to a file or a folder, On Verbs select "One of the following verbs" and in the space insert 'GET,HEAD,POST', click ok on all dialogs for safe the configuration.

(Can be that after install the php version using the web platform installer this step is automatically done by the program)

[Only registered and activated users can see links. Click Here To Register...]

4. Now select 'root' under "Sites" and open the "Default Document" feature. Select index.php and move it Up to first position (if don't exist add ''index.php" and move it at first position).

[Only registered and activated users can see links. Click Here To Register...]

5. Now open MIME Types and press on Add..
File name extension: .ini
MIME type: text/plain
and OK. Now again Add..
File name extension: .patch
MIME type: application/octet-stream
OK. (this is needed for make work your updater)

6. Now open Program Files(x86) --> PHP --> v5.3 --> php.ini
on line 226 edit short_open_tag = On

7. Open the folder C: --> root delete all what there is and with your text editor create index.php
PHP Code:
<!doctype html>
<html>
<body>
<?
    phpinfo
(1);
?>
</body>
</html>
Launch your browser, type-in the url "localhost/index.php".
if work you have succesfully installed and configure PHP on IIS.
if don't work please check your error using google before ask here about a solution!



Web Site Start

This is only a quickly introdution to html side of a website, but i can't explain you how to create a template by 0, so i give you only some suggestions.

First of all you need a template and i suggest you to steal it from another website (always make a new one is better, but if you don't have experience you can learn more by a website that is already maked).. download [Only registered and activated users can see links. Click Here To Register...] search a website that you like and follow the instruction on this program for take the html/css codes. copy your 'new' template in the folder "root". now you have html,css,javascript that you can reconfigure as you like, but not php.

You can show your result opening it by your url "localhost/.."

Now you need a web editer and i suggest this one that is free: [Only registered and activated users can see links. Click Here To Register...]

Open Brackets and on the left open folder (root). Rename all .html files to .php (remember you need to edit in your website menu/buttons all the path from .html to .php). The next step you must make alone using a bit of intelligence and searching the language words that you don't understand. You need to make now your website and the only suggestion that i can give you is to learn more using this tutiorals:
[Only registered and activated users can see links. Click Here To Register...]
[Only registered and activated users can see links. Click Here To Register...]

I hope you will quickly learn to edit the html pages and the css.

For css a good way for edit is directly on your browser, open your website, press rightclick, press on 'Inspect Element' and you can manage from there your style editing and then replacing the codes on the css file.

You can already go on your website in remote using your IP, or you can register your self on [Only registered and activated users can see links. Click Here To Register...] for have a free url, or if you want to buy a web domain i suggest you to buy it on [Only registered and activated users can see links. Click Here To Register...] where the .net cost only 9eu/year or check for a domain that have a lower cost. Remember, you don't need a webspace, u need only a domain and the staff will help you to configure your webhost to the domain name!



Web Services using PHP

Php start ever with this command
PHP Code:
<?
and close with this one:
PHP Code:
?> 
We use php for send and get the results from SQL database and for execute them on our website. but php isn't only this, it allow you to make commands on your web pages.
You can open and close it where you want inside a php page, the fine of php page is that read as html when php is closed. For insert a text or a html language in php the line must be similar at this:
PHP Code:
echo "example text"
When you test your php and get a error the answer of your browser will ever say you what error and the line where it is. If you don't understand the error search it on google for a solution.
Here is a tutorial for learn how to use php: [Only registered and activated users can see links. Click Here To Register...]

You can add every php script that you have found for shaiya simple with a include or copying the script in one of your pages and not need to use iframe.
the include function is very simple: insert this php code in your own php page where you want show it editing the path:
PHP Code:
<?
include('./path');
?>
For First create a folder in 'root' and call it 'inc' where we create a new php file that we call 'pdoConnect.php', then open it and insert this script where you need to edit your server credentials.
PHP Code:
//    Connect to MSSQL server with Shaiya credentials using PDO
    
$sqlUser  'User';        //    YOUR SHAIYA ACCOUNT NAME
    
$sqlPass  'Password';    //    YOUR SHAIYA ACCOUNT PASSWORD
    
$database 'PS_UserData';

    try {
        
$conn  = new PDO("sqlsrv:Server=127.0.0.1;Database=$database"$sqlUser$sqlPass);
    }
    catch (
PDOException $e){
        die(
$e->getMessage());
    } 
(this is the same one from castor, so you can include him scripts to mines)

Now make a top account info using php, you need to add this script after the tag <body> in every web page or make it in a clean php page and call with a include.
PHP Code:
<?
if (session_id() == ""){
    
session_start();
}
if(!isset(
$_SESSION['UserUID'])){
        
$uid 0;
    }else{
        
$uid $_SESSION['UserUID'];
}
    include(
'./inc/pdoConnect.php');
    
// Account name
if ($uid != 0){
    
$query $conn->prepare('SELECT UserID FROM PS_UserData.dbo.Users_Master WHERE UserUID=?');
    if (
$query != null){
        if (
$query->bindValue(1$uidPDO::PARAM_INT) && $query->execute()){
            
$name $query->fetch(PDO::FETCH_NUM);
    
$usrname$name[0];
}        
        
$query->closeCursor();
        
$query null;
    }
// Account Points
    
$query $conn->prepare('SELECT Point FROM PS_UserData.dbo.Users_Master WHERE UserUID=?');
    if (
$query != null){
        if (
$query->bindValue(1$uidPDO::PARAM_INT) && $query->execute()){
            
$point $query->fetch(PDO::FETCH_NUM);
                       
$usrpoint $point[0];
        }        
        
$query->closeCursor();
        
$query null;
    }
    
$conn null;
} else {
$usrname"Guest";
$usrpoint "No";
}
    
?>
<div style='float: right; text-align: right;'>
<? 
echo "Welcome ".$usrname ." </br>You have " .$usrpoint " points";
?>
</div>
(all files where you edit it must be in the root path, not in a subfolder)

now you can proceed to login section button, insert where you have your login/logout button and edit only the <a></a>:
PHP Code:
<?
if ($uid == 0){
echo 
"<a href='login.php'>Login</a>";
} else {
echo 
"<a href='logout.php'>Logout</a>";
}
?>
now we create the login.php in the root folder.
Replace your template and in the middle insert this script:
PHP Code:
<?
//    placeholder for invalid verification attempt
    
$verificationFailed false;

//    upon form validation, this page is processed with posted params, check them
    
if (isset($_POST['name']) && isset($_POST['pass'])){
    
//    enable cookies
        
session_start();
    
//    clear any previously defined IDs
        
if (isset($_SESSION['UserUID']))
            unset(
$_SESSION['UserUID']);
    
    
//    connect to database using a PDO
        
include('./inc/pdoConnect.php');
    
//    setup a query to get information on player account
        
$query $conn->prepare('SELECT UserUID, Pw, Status FROM PS_UserData.dbo.Users_Master WHERE UserID=?');
        if (
$query === false)
            die(
FormatErrors($query->errorInfo()));
    
//    bind the parameter
        
$query->bindParam(1$_POST['name'], PDO::PARAM_STR);
    
//    execute the query
        
if ($query->execute() === false)
            die(
FormatErrors($query->errorInfo()));
    
//    get response (a single row is expected)
        
$row $query->fetch(PDO::FETCH_NUM);
        if (
$row == null){
        
//    UserID was invalid, loop back on login form or display error or ...
$query->closeCursor();
$verificationFailed true;
}
else {
$uid $row[0];
$pwd $row[1];
$status $row[2];
            
$query->closeCursor();
        
//    verify password, depending on actual DB you may have to verify a hash
            
if ($pwd == '' || ''.$pwd != $_POST['pass']){
            
//    password was invalid
                
$verificationFailed true;
            }
            else {
                if (
$status == '-5'){
                
$query null;
                
$conn  null;
            
//    redirect to ban section
                
header("Location: ban_status.php?uid=".$uid."");
                exit(); 
                } else {
            
//    UserID / Pwd are valid, store the UserUID (the numerical unique ID)
                
$_SESSION['UserUID'] = $uid;
                
            
//    release resources
                
$query null;
                
$conn  null;
            
//    redirect to Char selection page
                
header("Location: index.php");
                exit();
                }
            }
        }
    }
//    we continue with html code in case of error or first display (no form validated)
?>
<style>
#login {
    background: url('./png/login.png') no-repeat right top;
    color: #ffffff;
    font: normal 9pt Verdana, Arial, Helvetica, sans-serif;
    margin: 0px;
    padding: 0px;
    position: relative;
margin: 0 auto;
    width: 252px;
    height: 200px;
}
#login p{
    text-align: center;
}
#login form {
    position: relative;
    padding: 50px 20px 0px 20px;
}
label.capt {
    display: inline-block;
    font: normal 9pt Verdana, Arial, Helvetica, sans-serif;
    width: 70px;
    padding: 4px 0 6px 0;
}
#login input {
    width: 130px;
}
#login #submit {
    margin: 0;
    padding: 0;
    width:100%;
    text-align: center;
}
#login input.btn {
    color: transparent;
    background: url('./png/ok.png') 0 0;
    border: none;
    margin: 0;
    padding: 0;
    height: 26px;
    width: 65px;
}
#login input.btn:hover {
    background: url('./png/ok.png') 0 -26px;
}
</style>
<div id="login">
    <form method="post" action="login.php">
        <label for="name" class="capt">User ID:</label>
        <input id="name"  name="name" type="text"/>
        <br/>
        <label for="pass" class="capt">Password:</label>
        <input id="pass"  name="pass" type="password"/>
        <br/>
<?    if ($verificationFailed){    ?>
        <p>The ID and/or password was invalid. Type in them carefully.</p>
<?    }
    else {    
?>
        <p>Please type in your ID and password to login your game account.</p>
<?    }    ?>    
        <div id="submit"><input type="submit" value="OK" class="btn"/></div>
    </form>
    <a style="float: right; color: white" href="recover.php">Recover Date</a>
</div>
</body>
</html>
for have a images response download this png folder: [Only registered and activated users can see links. Click Here To Register...] and insert it in root. (my script is a bit different on the ones from castor so better if you use this but you can work with the files that castor had relase on him thread [how To]Shaiya Web Service. this script have days bann and recover date inside.)

The logout.php must only contain this code:
PHP Code:
<?
    session_start
();
    
$_SESSION = array();
    
session_destroy();
    
header("Location: index.php");
?>
11/04/2014 09:21 delux153#2
after installing IIS I does not display webmall
Help please
11/04/2014 14:33 beetols#3
More PHP Versions in same IIS server

Quote:
Originally Posted by delux153 View Post
after installing IIS I does not display webmall
Help please
Not all php scripts will work using the php version 5.3

but you can add more php versions in IIS.

Download a different php version (better if u don't use the windows platform installer but make it manually, so will not change your impostation that u have setup for work using principally the version 5.3.28).

Select the subfolder that will contain your scripts that need the different php version, by your "Internet Information Services(IIS) Manager"(Be sure to select only the subfolder that you want change or it will take effect to all things that are selected), open the "Handler Mappings" feature and in In the "Actions" panel click "Add Module Mapping..." and enter the following:
Request path: *.php
Module: FastCgiModule
Executable: C:\[Path to PHP installation from the new php version]\php-cgi.exe
Name: PHP(version)_via_FastCGI

Click "Request Restrictions" button and then configure the mapping to invoke handler only if request is mapped to a file or a folder, and click ok on all dialogs for safe the configuration.

Select the handler mapping for the PHP version that you want use for the new folder and use “Move Up” action to move it to the top of the list. This will enable that particular PHP version for the currently selected IIS configuration scope.
11/05/2014 15:24 beetols#4
Online Status Script
here is a online status script maked using PDO for the php version 5.3, insert it in your root
PHP Code:
<?php 
    
include ('./inc/pdoConnect.php');

    
$queryLogin=$conn->prepare("SELECT Family FROM PS_GameData.dbo.Chars WHERE LoginStatus=1");
    
$queryLogin->execute();
    
$rowLogin $queryLogin->fetch(PDO::FETCH_NUM);
    
$human 0;
    
$elf 0;
    
$vail 0;
    
$nordein 0;
    
$online 0;
    while (
$rowLogin $queryLogin->fetch(PDO::FETCH_NUM)){
    switch(
$rowLogin[0]){
                case 
0$human++;break;
                case 
1$elf++;break;
                case 
2$vail++;break;
                case 
3$nordein++;break;
             };
    }
    
    
$online$human $elf $vail$nordein;
    echo 
"<center>";
    echo 
"<table>
          <tr><td colspan=2>Players online: </td><td>"
.$online."</td></tr>
          <tr><td colspan=2>Human: </td><td>"
.$human."</td></tr>
          <tr><td colspan=2>Elf: </td><td>"
.$elf."</td></tr>
          <tr><td colspan=2>Vail: </td><td>"
.$vail."</td></tr>
          <tr><td colspan=2>Nordein: </td><td>"
.$nordein."</td></tr>
          </table>"
;
    echo 
"</center>";
?>
09/01/2015 02:06 beetols#5
IIS have a configuration file in root (predefinted folder: wwwroot) called web.config
if you open it will see a begin side
Code:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
And end with

Code:
    </system.webServer>
</configuration>
inside there are some others impostations like

Code:
<defaultDocument>
    ...
</defaultDocument>
at same level than this we can add our script side for remove the extension:

Code:
        <rewrite>
            <rules>
                <rule name="rewritephp">
                           <match url="(.*)" />
                           <conditions logicalGrouping="MatchAll">
                             <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                             <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                           </conditions>
                           <action type="Rewrite" url="{R:1}.php" />
                </rule>     
            </rules>
        </rewrite>
At this point you can remove the extension '.php' or '.html' in the urls!

IIS will continue to read both ways!
09/03/2015 13:43 SkuulCandy#6
Very nice
10/21/2015 18:51 admin_lewis#7
nice guide! you are the best!
10/22/2015 18:32 [ADM]Pain#8
IIS is abit more complicated why dont u use wamp or xamp they have most of the things presetuped and do the same job. When i coded the webmall i used mysql to store items tables. wamp with php 5.3 so mssql_connect string work.
10/23/2015 08:03 beetols#9
Quote:
Originally Posted by [ADM]Pain View Post
IIS is abit more complicated why dont u use wamp or xamp they have most of the things presetuped and do the same job. When i coded the webmall i used mysql to store items tables. wamp with php 5.3 so mssql_connect string work.
Wamp or xampp use apache as web server, and you need only apache, all other functions are not needed. Castor did a tutorial for apache and I for IIS.

None is more complicated than the others, install IIS don't take more to 5 minutes, and I know devs that have prefer use IIS instead xampp for the addictional features that IIS provide. I find IIS easy, if you think that is complicated is just because u didn't apply yourself about.
02/09/2017 15:25 balongskie123#10
i think iis is more safer than apache? am i right?
11/17/2018 11:55 copain#11
Quote:
Originally Posted by beetols View Post
Wamp or xampp use apache as web server, and you need only apache, all other functions are not needed. Castor did a tutorial for apache and I for IIS.

None is more complicated than the others, install IIS don't take more to 5 minutes, and I know devs that have prefer use IIS instead xampp for the addictional features that IIS provide. I find IIS easy, if you think that is complicated is just because u didn't apply yourself about.



does folder Shaiya and patch still needed in IIS ?
11/17/2018 12:08 beetols#12
Quote:
Originally Posted by copain View Post
does folder Shaiya and patch still needed in IIS ?
I have to admit that what you wrote make no sense at all to me.. if you can express yourself more clearly i may understand and give you a more supporting answer aswell.
11/17/2018 12:54 {Skrillex}#13
Code:
        $query = $conn->prepare('SELECT UserUID, Pw, Status FROM PS_UserData.dbo.Users_Master WHERE UserID=?');
        if ($query === false)
            die(FormatErrors($query->errorInfo()));
    //    bind the parameter
        $query->bindParam(1, $_POST['name'], PDO::PARAM_STR);
Why you dont escape UserID?....

Regards
11/17/2018 15:30 beetols#14
Quote:
Originally Posted by .:Skrillex:. View Post
Code:
        $query = $conn->prepare('SELECT UserUID, Pw, Status FROM PS_UserData.dbo.Users_Master WHERE UserID=?');
        if ($query === false)
            die(FormatErrors($query->errorInfo()));
    //    bind the parameter
        $query->bindParam(1, $_POST['name'], PDO::PARAM_STR);
Why you dont escape UserID?....

Regards
PDO BindParam() give the UserID as STR variable and cannot be injected and it's fine like this, if I right understood your question..
06/15/2019 07:34 anon112#15
Its giving me this problem