%PDF- %PDF-
Direktori : /www/varak.net/www.varak.net/sig/ |
Current File : //www/varak.net/www.varak.net/sig/create_sig.php |
<? /******************************************************************************* Copyright (c) 2007, Chris Heald. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the Author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. * You are free to use this software in any commercial or non-commercial capacity you wish, provided that the following conditions are met: 1) The original author and any contributors are given visible credit for this tool any place it is used. The retention of the "http://wow.tachyonsix.com/armory" credit on generated images is appreciated, but not required. 2) You make a good-faith effort to contribute modifications, contributions, and changes to this tool back to the community by releasing them under a license similar to this one. This is non-binding, but is greatly appreciated. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ********************************************************************************/ include("_armory.php"); $options = parseIni("sig_config.ini", true); ini_set("user_agent", "Mozilla/5.0 Gecko/20070219 Firefox/2.0.0.2"); if(@$_REQUEST["r"] && @$_REQUEST["c"]) { $r = urlencode(stripslashes($_REQUEST["r"])); $c = urlencode(stripslashes($_REQUEST["c"])); $vars = array(); foreach(@$_REQUEST as $key => $val) { if($key == "loc" && $val == "US") continue; if($key == "bgcolor1") $key = "c1"; if($key == "bgcolor2") $key = "c2"; if($key == "stat1") $key = "s1"; if($key == "stat2") $key = "s2"; if($key == "stat3") $key = "s3"; if($key == "stat4") $key = "s4"; if($key == "stat5") $key = "s5"; $vars[] = "$key=" . urlencode($val); } $db = getDBCacheConnection(); $keys = array("r", "c", "loc", "c1", "c2", "tc1", "tc2", "s1", "s2", "s3", "s4", "s5", "si"); $params = array(); foreach($keys as $key) { $params[$key] = @$_REQUEST[$key]; } $params = mysql_real_escape_string((serialize($params)) ); $char = mysql_real_escape_string(@$_REQUEST["c"]); $server = mysql_real_escape_string(@$_REQUEST["r"]); $params_hash = md5($params); $sql = "select idstr from sigs where params_hash = '$params_hash'"; $result = mysql_query($sql, $db); $row = mysql_fetch_array($result); print_r($row); if($row && false) { $idstr = $row["idstr"]; } else { $base_url = $options["General"]["US_URL"]; if(@$_REQUEST["loc"] == "EU") $base_url = $options["General"]["EU_URL"]; $charData = getCharacterData($base_url, @$_REQUEST["r"], @$_REQUEST["c"]); // echo "<pre>"; // print_r($charData); // echo "</pre>"; $c = $charData->xpath("/page/characterInfo"); if(!$c) { ?> Invalid character data. <? return; } $ip = $_SERVER["REMOTE_ADDR"]; $sql = "insert into sigs (params, created_at, charname, server, params_hash, last_access, ipaddr) values (\"$params\", NOW(), '$char', '$server', '$params_hash', NOW(), '$ip')"; //echo $sql; mysql_query($sql, $db); echo mysql_error(); $id = mysql_insert_id($db); $str = "abcdefghijklmnopqrstuvwyxzABCDEFGHIJKLMNOPQRSTUVWYXZ"; $idstr = $id . substr($str, rand(0,51), 1) . substr($str, rand(0,51), 1) . substr($str, rand(0,51), 1). substr($str, rand(0,51), 1). substr($str, rand(0,51), 1); mysql_query("update sigs set idstr='$idstr', ipaddr = '$ip' where id = '$id'", $db); } $d = dirname($_SERVER["PHP_SELF"]); if($d == "/") $d = ""; $url = "http://" . $_SERVER["HTTP_HOST"] . "$d/sig.php/$idstr.png"; $self_url = "http://" . $_SERVER["HTTP_HOST"] . dirname($_SERVER["PHP_SELF"]); ?> <div id="preview"> <img src="sig.php/<?=$idstr?>.png" /> </div> <div id="copyurl"> <? /* <iframe width="728" scrolling="no" height="90" frameborder="0" allowtransparency="true" hspace="0" vspace="0" marginheight="0" marginwidth="0" src="http://pagead2.googlesyndication.com/pagead/ads?client=ca-pub-0438541591834443&dt=1177524684546&lmt=1177524683&prev_fmts=728x15_0ads_al_s&format=728x90_as&output=html&channel=9572249239&url=http%3A%2F%2Fwow.tachyonsix.com%2Farmory%2Fcreate_sig.php&ad_type=text&cc=100&u_h=1200&u_w=1920&u_ah=1088&u_aw=1920&u_cd=32&u_tz=-420&u_his=1&u_java=true&u_nplug=24&u_nmime=81" name="google_ads_frame"></iframe> */?> <table> <tr><td>Use this URL to access your new sig:</td><td><input id="url" style="width: 600px;" value="<?=$url?>" /></td></tr> <tr><td>BBCode:</td><td><input id="url2" style="width: 600px;" value="[url=<?=$self_url?>][img]<?=$url?>[/img][/url]"/></td></tr> <tr><td>HTML:</td><td><input id="url3" style="width: 600px;" value="<A href='<?=$self_url?>'><img src='<?=$url?>' border='0'></a>"/></td></tr> </table> <p /> Please do not copy the location on the image below. Hotlinking it is disabled. Use one of the links above. Feel free to "Save As" and rehost, but rehosted images will not be automatically updated. <p /> The above links make use of the <a href="http://www.coralcdn.org/">Coral caching system</a> to distribute the hosting load, so <b>you may hotlink them from the links above</b> - in fact, you're encouraged to do so. <p /> Please note that sigs won't be available behind firewalls that block requests on port 8080. This is unfortunate, but the alternative is that my server dies in a fiery ball of death, and as tempting as that sounds, I think this way is better. </div> <? return; } elseif (@$_REQUEST["v"]) { return; } logReferer("SigCreator"); ?> <html> <head> <script src="static/prototype.js"></script> <script src="static/effects.js"></script> <script src="static/colors.js"></script> <link rel="stylesheet" type="text/css" href="static/siggen.css" /> </head> <? $stats = array_keys($options["Stats"]); sort($stats); ?> <body> <div id="generator"> <script type="text/javascript"><!-- google_ad_client = "pub-0438541591834443"; google_ad_width = 728; google_ad_height = 15; google_ad_format = "728x15_0ads_al_s"; //2007-03-22: Armory Link Units google_ad_channel = "2089997824"; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script> <h1 style="text-align: left;">Antiarc's WoW Sig Image Generator</h1> <div style="text-align: left;"> Enter the parameters below to create a sig. This sig will auto-refresh every 12 hours. <p /> <? /* $db = getDBCacheConnection(); $row = mysql_fetch_row(mysql_query("select sum(hits) from referrer_log where app = 'SigEngine'", $db)); echo "<b>" . number_format($row[0]) . " unique sigs served!</b>"; */ ?> </div> <div style="text-align: left;"> <h3>Latest changes</h3> <ul> <li>I've switched sigs to 8-bit output for now to save bandwidth. They're about 1/3rd the size, which is pretty significant at current traffic levels. For those of you playing along in SVN, there's an INI option to toggle this.</li> <li>Added Avoidance rating for tanks. This is Dodge + Parry + NPC miss + extra NPC miss from defense. Thanks to rubik for the suggestion.</li> </ul> </div> <p /> <h3 style="text-align: left;">Create a .sig</h3> <div style="width: 336px; float: right; margin-left: 1em; padding: 4px;"> <script type="text/javascript"><!-- google_ad_client = "pub-0438541591834443"; google_ad_width = 336; google_ad_height = 280; google_ad_format = "336x280_as"; google_ad_type = "text"; //2007-03-22: Armory Wide Rectangle google_ad_channel = "4699061806"; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script> </div> <form id="sig-generator" onSubmit="return false;"> <table> <tr><td>Realm:</td><td><input type="text" name="r" /></td></tr> <tr><td> </td><td> <input type="radio" checked name="loc" value="US"> US <input type="radio" name="loc" value="EU"> EU </td></tr> <tr><td>Character:</td><td><input type="text" name="c" /></td></tr> <tr> <td>Custom avatar:<br /><font style="color: #888; font-size: 7pt;">Optional. Leave blank to use default. Must be a URL. Must be PNG, (non-animated) GIF, or JPG. Best results if images are 64x64.</font></td> <td valign="top"><input type="text" name="si" /></td> </tr> <tr><td>Background Color 1:</td><td> <div id="bgcolor1div" style="width: 16px; height: 16px; background-color: #000; border: 1px solid #000;"> </div> <input type="hidden" id="bgcolor1" name="c1" /> </td></tr> <tr><td>Background Color 2:</td><td> <div id="bgcolor2div" style="width: 16px; height: 16px; background-color: #0078FF; border: 1px solid #000;"> </div> <input type="hidden" id="bgcolor2" name="c2" /> </td></tr> <tr><td>Text Color 1:</td><td> <div id="tcolor1div" style="width: 16px; height: 16px; background-color: #FFD200; border: 1px solid #000;"> </div> <input type="hidden" id="tcolor1" name="tc1" /> </td></tr> <tr><td>Text Color 2:</td><td> <div id="tcolor2div" style="width: 16px; height: 16px; background-color: #ffffff; border: 1px solid #000;"> </div> <input type="hidden" id="tcolor2" name="tc2" /> </td></tr> <? for($i=1; $i<=5; $i++) { ?> <tr> <td>Stat <?=$i?>:</td> <td> <select name="s<?=$i?>"> <option value="">-- None --</option> <? foreach($stats as $name) { echo "<option>$name</option>\n"; } ?> </select> </td> </tr> <? } ?> <tr><td colspan="2" align="center" style="padding: 1em;"><input type="submit" value="Create my sig!" /></td></tr> </table> <input type="hidden" name="v" value="2" /> </form> </div> <p /> <div id="ajaxreturn"> </div> <p /> <? include("_footer.php"); ?> <script> function postForm() { new Ajax.Updater("ajaxreturn", "<?=@$_SERVER["PHP_SELF"]?>", { parameters: Form.serialize($("sig-generator")), onLoading: function() { $('ajax_loader').show() }, onFailure: function() { alert("Failed to create sig [failure]."); $('ajax_loader').hide() }, onException: function(a, b) { alert("Failed to create sig [exception] :: " + a + " :: " + b.message); $('ajax_loader').hide() }, onComplete: function() { $('ajax_loader').hide() } }); } Event.observe(window, 'load', function() { create_color_dropdown(); bgcolor1div.color_menu = true; bgcolor2div.color_menu = true; tcolor1div.color_menu = true; tcolor2div.color_menu = true; Event.observe("sig-generator", "submit", postForm); if($("bgcolor1").value) $("bgcolor1div").style.backgroundColor = "#" + $("bgcolor1").value; if($("bgcolor2").value) $("bgcolor2div").style.backgroundColor = "#" + $("bgcolor2").value; if($("tcolor1").value) $("tcolor1div").style.backgroundColor = "#" + $("tcolor1").value; if($("tcolor2").value) $("tcolor2div").style.backgroundColor = "#" + $("tcolor2").value; Event.observe("bgcolor1div", "click", function() { $("ttiw_color_dropdown").callback = function(v) { $("bgcolor1").value = v.substr(1, 6); $("bgcolor1div").style.backgroundColor = v; } $("ttiw_color_dropdown").open($("bgcolor1div")); }); Event.observe("bgcolor2div", "click", function() { $("ttiw_color_dropdown").callback = function(v) { $("bgcolor2").value = v.substr(1, 6); $("bgcolor2div").style.backgroundColor = v; } $("ttiw_color_dropdown").open($("bgcolor2div")); }); Event.observe("tcolor1div", "click", function() { $("ttiw_color_dropdown").callback = function(v) { $("tcolor1").value = v.substr(1, 6); $("tcolor1div").style.backgroundColor = v; } $("ttiw_color_dropdown").open($("tcolor1div")); }); Event.observe("tcolor2div", "click", function() { $("ttiw_color_dropdown").callback = function(v) { $("tcolor2").value = v.substr(1, 6); $("tcolor2div").style.backgroundColor = v; } $("ttiw_color_dropdown").open($("tcolor2div")); }); }); var ajaxLoaderLastX = 0; var ajaxLoaderLastY = 0; function updateAjaxLoaderPosition(e) { var ele = $("ajax_loader"); if (!e) e = window.event; var x = Event.pointerX(e) - 16; var y = Event.pointerY(e) - 16; if(x != ajaxLoaderLastX || y != ajaxLoaderLastY) { ajaxLoaderLastX = x; ajaxLoaderLastY = y; ele.setStyle({ left: x + "px", top: y + "px" }); } } Event.observe(window, "load", function() { var objBody = document.getElementsByTagName("body").item(0); var i = document.createElement("img"); Element.extend(i); i.setStyle({ position: 'absolute' }); i.src = "static/images/ajax_loader2.gif"; i.setAttribute('id','ajax_loader'); i.hide(); objBody.appendChild(i); Event.observe(window.document, "mousemove", updateAjaxLoaderPosition); }); </script> </body> </html> <? function parseIni($file) { $f = file($file); $sections = array(); $curSection = false; foreach($f as $fl) { if(!trim($fl)) continue; if(preg_match("/^\[(.*?)\]$/", trim($fl), $matches)) { $curSection = $matches[1]; } else { list($k, $v) = explode("=", trim($fl), 2); $sections[$curSection][$k] = $v; } } return $sections; } ?>