Here. This file is based on my ACP and in german but maybe you make it work without ACP. :)Quote:
Screen: [Only registered and activated users can see links. Click Here To Register...]
[ENG]Does anyone know how to add coupons to the database from the otherwise use Crasima.
PHP Code:
<?php
// Simple AdminUI
// Author: Jessi 4 psfgame.de
// You are allowed to modify and/or redistribute any part of this
require_once("backend/main.php"); // Corefile
loggedinorreturn(); // check
stdhead("CodeCP"); // header
dbconn(); // connect 2 DB
// Codegenerator
function zufallsstring($lang)
{
$zahl1=rand(1,10000000).rand(1,10000000).rand(1,10000000);
$zahl2=rand(1,10000000).rand(1,10000000).rand(1,10000000);
$Zufallsstring = md5($zahl1).md5($zahl2);
$Zufallsstring = strtoupper($Zufallsstring);
$Zufallsstring = substr($Zufallsstring, 0, $lang);
return $Zufallsstring;
}
// Codedaten aus der DB ziehen
$sql = "SELECT * FROM vouchers ORDER BY type ASC, amount DESC, used DESC";
$res = mysql_query($sql);
$numcodes = mysql_num_rows($res);
if($numcodes > 0)
{
$numcodes2 = $numcodes;
}
else
{
$numcodes2 = "0";
}
if(isset($_GET["del"]))
{
$idd = $_GET["del"];
mysql_query("DELETE FROM vouchers WHERE id=$idd");
?>
<table align="center" border="0" cellpadding="4" cellspacing="1" class="tableinborder" summary="none" width="200px">
<tr>
<td align="center" class="tablecat">Fertig!</td>
</tr>
<tr>
<td align="center" class="tableb"><a href="codecp.php">Weiter =-</a></td>
</tr>
</table>
<?php
}
if(isset($_GET["cpl"]))
{
?>
<table align="center" border="0" cellpadding="4" cellspacing="1" class="tableinborder" summary="none" width="350px">
<tr>
<td align="center" class="tablecat">C/P-Liste</td>
</tr>
<tr>
<td align="center" class="tableb">
<?php
while ($c = mysql_fetch_assoc($res))
{
echo $c["code"].", ";
}
?>
</td>
</tr>
<tr>
<td align="center" class="tableb"><a href="codecp.php">-= Zurück</a></td>
</tr>
</table>
<?php
}
if(isset($_POST["doit"]))
{
// $_POST-VARS 2 $vars
$wert = $_POST["val"];
$curre = $_POST["curr"];
$count = $_POST["cnt"];
$uses = $_POST["use"];
if($curre == "silver")
{
$ncnt = $wert*100;
}
else
{
$ncnt = $wert;
}
for ($x = 0; $x < $count; $x++)
{
$code = zufallsstring(10);
mysql_query("INSERT INTO vouchers(code, type, amount, used) VALUES('$code', '$curre', '$ncnt', '$uses')");
}
?>
<table align="center" border="0" cellpadding="4" cellspacing="1" class="tableinborder" summary="none" width="350px">
<tr>
<td align="center" class="tablecat">Fertig!</td>
</tr>
<tr>
<td align="center" class="tableb"><a href="codecp.php">Weiter =-</a></td>
</tr>
</table>
<?php
}
if(isset($_GET["create"]))
{
?>
<form action="<?=$_SERVER["PHP_SELF"] ?>" method="post" enctype="multipart/form-data" target="_self">
<table align="center" border="0" cellpadding="4" cellspacing="1" class="tableinborder" summary="none" width="350px">
<tr>
<td colspan="2" align="center" class="tablecat">Erstelle Codes</td>
</tr>
<tr>
<td align="left" class="tableb" width="150px">Wert</td>
<td align="left" class="tablea"><input type="text" size="10" name="val" /></td>
</tr>
<tr>
<td align="left" class="tableb">Währung</td>
<td align="left" class="tablea"><input type="radio" name="curr" value="mushroom"> Pilze <input type="radio" name="curr" value="silver"> Gold</td>
</tr>
<tr>
<td align="left" class="tableb">Anzahl</td>
<td align="left" class="tablea"><input type="text" size="10" name="cnt" /></td>
</tr>
<tr>
<td align="left" class="tableb">Benutzbar</td>
<td align="left" class="tablea"><input type="text" size="10" name="use" /></td>
</tr>
<tr>
<td colspan="2" align="center" class="tableb"><input type="submit" value="Erstellen" class=btn></td>
</tr>
</table>
<input type="hidden" name="doit" value="yes" />
</form>
<?php
}
if(!isset($_POST["doit"]) && !isset($_GET["create"]) && !isset($_GET["del"]) && !isset($_GET["cpl"]))
{
?>
<table align="center" border="0" cellpadding="4" cellspacing="1" class="tableinborder" summary="none" width="200px">
<tr>
<td align="center" class="tablecat">Menü</td>
</tr>
<tr>
<td align="center" class="tableb"><a href="codecp.php?create=1">Erstelle Codes</a></td>
</tr>
<tr>
<td align="center" class="tableb"><a href="codecp.php?cpl=1">Copy/Paste-Liste</a></td>
</tr>
</table>
<br>
<table align="center" border="0" cellpadding="4" cellspacing="1" class="tableinborder" summary="none" width="600px">
<tr>
<td colspan="4" align="center" class="tablecat">Aktive Codes (<?=$numcodes2?>)</td>
</tr>
<tr>
<td align="center" class="tableb"><b>Code</b></td>
<td align="center" class="tablea"><b>Wert</b></td>
<td align="center" class="tableb"><b>Nutzbar</b></td>
<td align="center" class="tablea"><b>Löschen</b></td>
</tr>
<?php
if($numcodes > 0)
{
while ($c = mysql_fetch_assoc($res))
{
if($c["type"] == "mushroom")
{
$w = "Pilz/e";
$v = $c["amount"];
}
else
{
$w = "Gold";
$v = $c["amount"]/100;
}
?>
<tr>
<td align="center" class="tableb"><?=$c["code"]?></td>
<td align="center" class="tablea"><?=$v?> <?=$w?></td>
<td align="center" class="tableb"><?=$c["used"]?></td>
<td align="center" class="tablea"><a href="codecp.php?del=<?=$c["id"]?>">Code löschen</a></td>
</tr>
<?php
}
}
else
{
?>
<tr>
<td colspan="4" align="center" class="tableb">Keine aktiven Codes vorhanden</td>
</tr>
<?php
}
?>
</table>
<?php
}
stdfoot();
?>