Php ingame mailer system
verze: 2.0 GOLD RELEASE
Jelikož jsem jednou slyšel prosbu, zda by nějak nešlo posílat maily charum ve hře přes net, aniž by bylo potřeba mít wow klienta popřípadě se logovat ingame, tak mě napadlo proč neudělat jednoduchý mailer s pomocí php & MySQL
Upozornění: PŘED POUŽÍVÁNÍM TOHOTO MAILERU, NAHRAJTE DO SVÉ CHARACTERS DB, TENTO SQL!!!
Zdrojový kód
<?php
$adress = "localhost";
$user = "root";
$pass = "root";
$chardb = "characters";
if(array_key_exists("odesilatel", $_POST)
&& array_key_exists("prijemce", $_POST)
&& array_key_exists("nadpis",$_POST)
&& array_key_exists("text", $_POST))
{
mysql_connect($adress, $user, $pass);
mysql_select_db($chardb);
function GetIdSender($odesilatel)
{
$odesilatel = mysql_real_escape_string($odesilatel);
$Query = "SELECT guid, name FROM characters WHERE name='".$odesilatel."' LIMIT 1";
$DbResult = mysql_query($Query);
$DbRow = mysql_fetch_array($DbResult);
$Count = $DbRow["guid"];
mysql_free_result($DbResult);
return $Count;
}
function GetIdReceiver($prijemce)
{
$prijemce = mysql_real_escape_string($prijemce);
$Query = "SELECT guid, name FROM characters WHERE name='".$prijemce."' LIMIT 1";
$DbResult = mysql_query($Query);
$DbRow = mysql_fetch_array($DbResult);
$Count = $DbRow["guid"];
mysql_free_result($DbResult);
return($Count);
}
function CreateIdForItemText()
{
return GetMinIdForItemText() - 1;
}
function CreateIdForMail()
{
return GetMinIdForMail() - 1;
}
function GetIdText($text)
{
$text = mysql_real_escape_string($text);
$Query = "SELECT id FROM item_text WHERE text='".$text."' LIMIT 1";
$DbResult = mysql_query($Query);
$DbRow = mysql_fetch_array($DbResult);
$Count = $DbRow["id"];
mysql_free_result($DbResult);
return $Count;
}
function DeliverTime()
{
return Time() + 10;
}
function ExpireTime()
{
return Time() + 2592000;
}
function InsertItemText()
{
$Query = "INSERT INTO `item_text` (`id`, `text`) VALUES ('".CreateIdForItemText()."', '".$_POST["text"]."')";
$DbResult = mysql_query($Query);
}
function InsertMail()
{
$Query = "INSERT INTO mail (id, messageType, stationery, mailTemplateId, sender, receiver, subject, itemTextId, has_items, expire_time, deliver_time, money, cod, checked) VALUES ('".CreateIdForMail()."', '0', '41', '0', '".GetIdSender($_POST["odesilatel"])."', '".GetIdReceiver($_POST["prijemce"])."', '".$_POST["nadpis"]."', '".GetIdText($_POST["text"])."', '0', '".ExpireTime()."', '".DeliverTime()."', '0' ,'0', '0');";
$DbResult = mysql_query($Query);
}
function GetMinIdForMail()
{
$Query = "SELECT MIN(`id`) FROM mail";
$DbResult = mysql_query($Query);
$DbRow = mysql_fetch_array($DbResult);
$Count = $DbRow[0];
mysql_free_result($DbResult);
return($Count);
}
function GetMinIdForItemText()
{
$Query = "SELECT MIN(`id`) FROM item_text";
$DbResult = mysql_query($Query);
$DbRow = mysql_fetch_array($DbResult);
$Count = $DbRow[0];
mysql_free_result($DbResult);
return($Count);
}
echo InsertItemText();
echo InsertMail();
mysql_close()
}
?>
Jinak formulář a jeho zdrojový kód
<HTML>
<HEAD>
<TITLE>Mail sender by Clant</TITLE>
</HEAD>
<BODY>
<form action="send.php" method="post">
<b>Odesilatel:</b>
<input type="text" name="odesilatel">
<br>
<b>Prijemce:</b>
<input type="text" name="prijemce">
<br>
<b>Nadpis:</b>
<input type="text" name="nadpis">
<br>
<b>Text:</b>
<input type="text" name="text">
<br>
<input type="submit" name="odeslat" value="Poslat ingame mail">
</form>
</BODY>
</HTML>
Přečíslovac pro php ingame mailer system
verze: 1.0 GOLD RELEASE
O co jde? Do své webové složky rozbalíte archiv precislovac, ktery je ke stažení níže. Upravíte prozatím MySQL Connection information, nic víc. Přes localhost či webovou adresu se dostanete na index.php této složky. Script sám má napsanou funkci, aby zjistil zda je potřeba přečíslování tabulke nebo ne, když je potřeba tak máte k dispozici ihned odkaz, který Vám přečísluje id v tabulce.
UPOZORNĚNÍ: Než kliknete na přečíslování tabulky, zkontrolujte zda v config.php máte nastavené to co je napsáno na posledních 2 řádcích v index.php!
Download: Filebeam.com
Případné dotazy sem, budu rád za každou pomoc!