allerdings weis ich nicht wie ich den in die handler.php reinbekomme.
Ich habe schon versucht die orginaldaten zu ersetzen, aber dies schlug bisher fehl.
Deswegen die frage an euch, vielleicht weis ja einer wie ich das machen muss.
Handler.php
PHP Code:
<?php
#Security
define( 'IN_MALL' , 0 );
#Include config
require_once( './config.php' );
#Include bootstrap
require_once( './bootstrap.php' );
#Logged In
if( isset( $_SESSION['userName'] ) )
{
#Lel
if( $_SESSION['logIP'] != $_SERVER['REMOTE_ADDR'] )
{
session_destroy();
exit;
}
#Trying to buy
if( isset( $_POST['buy'] ) )
{
$Item = $_POST['buy'];
#Numbers only
if( preg_match( '/^[0-9][0-9]*$/' , $Item ) == 1 )
{
#Get Info
$ItemInfo = Functions::GetItemInfo( $Item );
#Item doesn't exist
if( count( $ItemInfo ) == 0 )
{
Functions::Error( 'Invalid item' );
}
#Fucking nest
$ItemInfo = $ItemInfo[0];
#Get user points
$Points = Functions::GetUserPoints( $_SESSION['nEMID'] );
#Failed to get user points
if( count( $Points ) == 0 )
{
Functions::Error( 'Server error' );
}
#Fucking nest
$Points = $Points[0]['nAGPoints'];
#Enough points?
if( $ItemInfo['nPrice'] > $Points )
{
Functions::Error( 'You do not have enough points' );
}
#Deduct points
Functions::SubtractPoints( $_SESSION['nEMID'] , $ItemInfo['nPrice'] );
#Give item
Functions::AddItem( $_SESSION['nEMID'] , $ItemInfo );
Functions::Error( 'Item bought' );
}
else
{
Functions::Error( "Invalid item" );
}
}
#Coins
else if( isset( $_GET['coins'] ) )
{
$Coins = functions::GetUserPoints( $_SESSION['nEMID'] );
$Coins = $Coins[0]['nAGPoints'];
echo $Coins;
}
#Specific category
else if( isset( $_GET['cat'] ) )
{
$Cat = $_GET['cat'];
#Valid sub-category?
#Sub-Cats are number indexed
if( preg_match( '/^[0-9][0-9]*$/' , $Cat ) == 1 )
{
$Results = Functions::GetCat( $Cat );
#Category is real
if( count( $Results ) > 0 )
{
$Results = $Results[0]['nCat'];
$Items = Functions::GetItemsByCat( $Results );
#No items in category
if( count( $Items ) > 0 )
{
echo '<ul class="thumbnails">';
foreach( $Items as $Key => $Info )
{
$Info = (object) $Info;
functions::PrintItem( $Info );
}
echo '</ul>';
}
else
{
Functions::Error( 'No items in this category' , true );
}
}
else
{
Functions::Error( 'Invalid category' , true );
}
}
else if( $Cat == -1 )
{
echo '<iframe
src="https://api.***********.com/api/subscription
?key=79e2eeb73688f48286d5a613826058b8
&uid=user42
&widget=p10
&email=user%40hostname.com
&sign_version=3
&sign=SIGNATURE" width="750" height="800" frameborder="0">
</iframe>';
}
else if( $Cat == -2 )
{
echo "Yo! Paypal!";
}
else
{
Functions::Error( "Invalid category" , true );
}
}
#Tried to log out?
else if( isset( $_GET['logout'] ) )
{
Functions::LogOut();
Functions::Redirect( 'index.php' );
}
#Default
else
{
$Coins = functions::GetUserPoints( $_SESSION['nEMID'] );
$Coins = $Coins[0]['nAGPoints'];
echo '<div class="navbar">
<div class="navbar-inner">
<ul class="nav">';
$i = Functions::PrintCategories();
echo '</ul><div class="btn-group" style="float:right;">
<a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
Options
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li><a href="#">' . sprintf( "Logged in as, <b style=\"color:red;\">%s</b>" , htmlentities( $_SESSION['userName'] ) ) . '</a></li>
<li><a id="coins_lbl" href="#" onclick="updateCoins(); return false;">' . sprintf( "Coins:<b style=\"color:red;\">%s</b>" , htmlentities( $Coins ) ) . '</a></li>
<li id="lbl_-1"><a href="#" onclick="loadCat(-1); return false;"><img src="./Template/img/dollar.png" alt="" /> Payment Wall</a></li>
<!--<li><a href="#" onclick="loadCat(-2); return false;"><img src="./Template/img/dollar.png" alt="" /> Paypal</a></li>-->
<li><a href="#" onclick="Logout(); return false;"><b>Logout<b/></a></li>
</ul>
</div>';
echo '</div></div>';
if( $i == 0 )
{
Functions::Error( "There are no mall items yet!" , true );
}
else
{
echo '<script>$("#main").html(\'<div class="alert alert-info">Klicke auf eine kategorie um dir deine Items zu Kaufen! <button type="button" class="close" data-dismiss="alert">×</button></div>\');</script>';
}
}
}
#Not logged in
else
{
#Tried to log in?
if( isset( $_POST['username'] ) && isset( $_POST['password'] ) )
{
$Username = $_POST['username'];
$Password = $_POST['password'];
#Validate input
if( strlen( $Username ) < 3 || strlen( $Username ) > 15 || preg_match( '/[^a-zA-Z0-9]/' , $Username ) > 0 )
{
Functions::Error( '3' );
}
elseif( strlen( $Password ) < 5 || strlen( $Password ) > 20 )
{
Functions::Error( '2' );
}
#Hash password
$Password = Functions::MakePw( $Username , $Password );
#User didn't exist
if( $Password == null )
{
Functions::Error( '1' );
}
#Validate login
$Results = Functions::LoginValidate( $Username , $Password );
if( count( $Results ) > 0 )
{
$Results = $Results[0];
Functions::SetLogin( $Results );
Functions::Error( '4' );
}
#Invalid
else
{
Functions::Error( '1' );
}
}
#Nada
else
{
Functions::LoggedOut();
}
}
?>






