-
Posts
3,368 -
Joined
-
Last visited
-
Days Won
126
Content Type
Profiles
Forums
Events
Everything posted by Dave
-
Paid mods.
-
$userid is alot quicker to type ;) and It was a free mod so I wasn't going to spend years trying to make sure the message output was 100% safe. Thanks for the feedback though.
-
I've made a simple free shoutbox for you guys. [mccode v2.x] Simple jQuery Ajax Shoutbox
-
Thanks :) me and Djkanna noticed that it didn't work without short open tags on yesterday :) Thus why I added the text to the originally post.. But no one reads anything unless it's in bright red :L
-
Someone had requested this to be made and because it's generally a simple task I thought I'd put together a simple free one. This mod is very simple and lacks decent features (Such as smileys, Ban/Delete and so on.) I'd appreciate if others could reply to this with those features so I don't have to create the whole modification. Little terms of use: If you have any paid mods that you have not paid for installed on your site you are not allowed to use this modification. Not for re-sale or re-distribution. The comments at the top of the files must stay in place. Firstly add this to the bottom of globals.php (Just before the ?>) //Shoutbox Modification //Created by Dave Macaulay //Not for re-sale of re-distrubtion ?> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script> <script type="text/javascript"> function showShoutbox(element) { if($('#shoutbox').css('display') == 'none') { $('#shoutbox').slideDown(300); $('#hdtxt').fadeOut(500, function () { $(this).html('Hide Shoutbox').fadeIn(500); }); } else { $('#shoutbox').slideUp(300); $('#hdtxt').fadeOut(500, function () { $(this).html('Show Shoutbox').fadeIn(500); }); } } function updateShoutbox() { $.ajax({ url: 'xml_shoutbox.php', cache: false, success: function(data) { $('#shouts').html(data); } }); } function sendShout() { $('#input_data').attr("disabled", true); var text = $('[name=shout]'); if(text) { $.ajax({ type: "POST", url: 'xml_shoutbox.php', data: { 'shout' : text.val() }, cache: false, success: function(data) { text.val(''); updateShoutbox(); $('#input_data').attr("disabled", false); } }); } } setInterval('updateShoutbox();', 1000); </script> <?php echo '<center> <div style="background: #ffffd3;border: 1px #ffff99 solid;width:650px;padding: 2px;cursor: pointer;margin: 3px;" onclick="showShoutbox(this);">>> <span id="hdtxt">Hide Shoutbox</span> <<</div> <div id="shoutbox" style="background: #ffffd3;border: 1px #ffff99 solid;width:650px;margin: 3px;height: 170px;"> <div id="shouts" style="overflow-y: hidden;width: 100%;height: 150px;text-align: left;padding: 5px;"> Loading shouts... </div> <form action="" method="post" onsubmit="sendShout();return false;"><span style="float: left;"><input type="text" name="shout" id="input_data" style="width: 570px;"></span><span style="float:right;"><input type="submit" id="input_data" value="Shout!" style="width: 75px;"/></span></form> </div> </center> '; //Shoutbox Create a file called xml_shoutbox.php <?php // Mod created by Dave Macaulay // Not to be sold or re-distributed session_start(); require_once('config.php'); global $_CONFIG; define("MONO_ON", 1); require_once('class/class_db_'.$_CONFIG['driver'].'.php'); $db=new database; $db->configure($_CONFIG['hostname'], $_CONFIG['username'], $_CONFIG['password'], $_CONFIG['database'], $_CONFIG['persistent']); $db->connect(); $c=$db->connection_id; require_once('global_func.php'); $userid = $_SESSION['userid']; $is = $db->query("SELECT * FROM `users` WHERE `userid` = ".$userid) or die(mysql_error()); $ir = $db->fetch_row($is); function getUsername($userid) { global $db; $select = $db->query("SELECT `username` FROM `users` WHERE `userid` = ".$userid); if($db->num_rows($select)) { $user = $db->fetch_row($select); return $user['username']; } } if($_POST['shout']) { $db->query("INSERT INTO shout_box VALUES(null, ".$userid.", ".time().", '".htmlentities(mysql_real_escape_string($_POST['shout']))."')") or die(mysql_error()); exit; } $fetch = $db->query("SELECT `id`,`user`,`time`,`message` FROM shout_box ORDER BY time DESC"); if(!$db->num_rows($fetch)) { echo 'There are currently no shouts! Make one below!'; exit; } while($f = $db->fetch_row($fetch)) { echo '[url="viewuser.php?u='.$f['user'].'"]'.getUsername($f['user']).'[/url] [i]['.date('H:i', $f['time']).'][/i] - '.htmlentities(stripslashes($f['message'])).' '; } ?> Then run the following SQL's CREATE TABLE `shout_box` ( `id` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY , `user` INT( 11 ) NOT NULL , `time` TEXT NOT NULL , `message` TEXT NOT NULL ) ENGINE = MYISAM ;
-
It was there :) I just made it red so people would notice it. Make sure you restart your LAMP/WAMP when you have turned it on.
-
Guys... Please atleast read the text in the original post... It clearly states that Short tags must be turned on in PHP, Generally in WAMP, LAMP installations this wont be turned on!
-
Thanks :) I haven't released any work to the community recently I believe, so all the recent scripts are showing you my skills :]
-
I dont use __FILE__ anywhere? I use __THIS__ and because it's my coding preference. [rant] Danny stop posting on threads trying to sound clever it's actually annoying me to the extent where I want to post this to you :L. Most the things you post are to do with people's preferences and don't really need to be questioned. [/rant]
-
Yeah kind of :) Look up define on php.net I just prefer to use define because Its global :)
-
I like to make my mods interesting and different :)
-
Woo money =D What features you after? and budget? Would also develop a lite version for this "community" of lovely people.
-
Why would It cause a problem having jQuery in there? and due to some small child handing around my paid mods. I do not do requests generally.
-
I hadn't done any testing as of yet :) Just wrote it while using chrome. I imagine your a FF guy?
-
Unfortunatly your ShoutBox wasn't released on here it was linked to what I think to be PHP-Forums. [McCodes V2] ShoutBox How ever I did happen to find your Ajax Shoutbox :P [McCodes V2]Ajax ShoutBox [$12.00] Ahh was a while back now ^^ and I no longer sell that mod, Cause tbh it was useless :L Might write a new free shoutbox using jQuery cause I love it :)
-
$.post and $.get basically do the same thing, I just used them because I didn't need any of the features that $.ajax has. (Except json which isn't supported in IE so decided not to use.)
-
I use the methods that jQuery provide to do Ajax requests because in most of my scripts I personally use it for I'm already using jQuery for effects.
-
Hey guys, You need short open tags turned on for this mod to work! I wanted to make a bank where from opening the account to depositing money was all done with ajax so no need to reload. With this mod I have done this! I just wanted to get it posted up but if you can inform me of any bugs whilst I am sleeping it would be appreciated. <?php // ----------------------------------- // Mod created by Dave Macaulay ([email protected]) // For free use only with Mccodes V2 // For use of mod this must remain intack! // ------------------------------------ if (!$_GET['print']) { require_once ('globals.php'); echo '<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script> [b]Bank Account[/b] '; } else { session_start(); require_once ('config.php'); global $_CONFIG; define("MONO_ON", 1); require_once ('class/class_db_' . $_CONFIG['driver'] . '.php'); $db = new database; $db->configure($_CONFIG['hostname'], $_CONFIG['username'], $_CONFIG['password'], $_CONFIG['database'], $_CONFIG['persistent']); $db->connect(); $c = $db->connection_id; require_once ('global_func.php'); $userid = $_SESSION['userid']; $is = $db->query("SELECT bankmoney,money FROM `users` WHERE `userid` = " . $userid) or die(mysql_error()); $ir = $db->fetch_row($is); } define('__BANKPRICE__', 5000); define('__THIS__', basename($_SERVER['SCRIPT_FILENAME'])); $_POST['amount'] = abs((int)$_POST['amount']); if ($_GET['get_bank']) { echo ($_GET['simple'] ? $ir['bankmoney'] : money_formatter($ir['bankmoney'])); exit; } if ($_GET['get_hand']) { echo ($_GET['simple'] ? $ir['money'] : money_formatter($ir['money'])); exit; } if ($ir['bankmoney'] < 0) { new_account(); if (!$_GET['print']) { $h->endpage(); } exit; } switch ($_GET['a']) { case 'deposit': deposit(); break; case 'withdraw': withdraw(); break; default: index(); break; } function new_account() { global $ir, $db, $c, $userid; if (!$_GET['print']) { ?> <script type="text/javascript"> function openAccount() { var c = confirm("Are you sure you want to open a bank account for <?php echo money_formatter(__BANKPRICE__) ?>?"); if(c) { $('#main_text').html('Opening account... '); $('#main_text').append('Checking you have the correct funds... '); if(<?php echo $ir['money'] ?> < <?php echo __BANKPRICE__ ?>) { $('#main_text').append('<span style="color: red;">Incorrect funds, You need another <?php echo money_formatter((__BANKPRICE__) - $ir['money']) ?>... '); } else { $.post('<?php echo __THIS__ ?>?open=true&print=1', function(data) { if(data == 'not_enough_money') { $('#main_text').append('<span style="color: red;">Incorrect funds... '); } else if(data == 'opened') { $('#main_text').append('<span style="color: green;">You have succesfully opened your brand new bank account!</span> > [url="javascript:void(0);"]View Account[/url]'); } }); } } } function showBank() { $.get('<?php echo __THIS__ ?>?print=1', function(data) { $('#main_text').html(data); }); } </script> <?php } if ($_GET['open']) { if ($ir['money'] < __BANKPRICE__) { echo 'not_enough_money'; exit; } else { $db->query("UPDATE `users` SET `money` = `money` - " . __BANKPRICE__ . ", `bankmoney` = 0 WHERE `userid` = " . $userid); echo 'opened'; exit; } } else { echo ' <span id="main_text"> You currently don\'t have a bank account with us, Would you like to open an account for only [i]' . money_formatter(__BANKPRICE__) . '[/i]! > [url="javascript:void(0);"]Open an account![/url] </span>'; } } function index() { global $ir, $db, $c, $userid; ?> <script type="text/javascript"> function makeTrans(type) { if(type != 'withdraw' && type != 'deposit') { alert("Script Error!"); } else { var data = $('[name='+type+']'); $.post('<?php echo __THIS__ ?>?print=true&a=' + type, { 'amount' : data.val() }, function(data) { $('#' + type + '_callback').html(data); $.post('<?php echo __THIS__ ?>?print=true&get_bank=true', function(data) { $('#bank_money').html(data); }); $.post('<?php echo __THIS__ ?>?print=true&get_bank=true&simple=true', function(data) { $('[name=withdraw]').val(data); }); $.post('<?php echo __THIS__ ?>?print=true&get_hand=true&simple=true', function(data) { $('[name=deposit]').val(data); }); }); } } </script> <?php echo 'You currently have [i]<span id="bank_money">' . money_formatter($ir['bankmoney']) . '</span>[/i] in your bank account. You are earning 2% interest on this daily. [url="javascript:void(0);"]> Withdraw[/url] <div id="withdraw" style="background: #ffffd3;border: 1px #ffff99 solid;display: none;padding: 20px;width: 250px;margin: 5px;"> <form action="" method="post" onsubmit="makeTrans(\'withdraw\');return false;"><input type="text" name="withdraw" value="' . ($ir['bankmoney'] ? $ir['bankmoney'] : 0) . '" /> <input type="submit" value="Withdraw" /></form> <div id="withdraw_callback"> [size="1"]Please select the amount you wish to withdraw then hit the withdraw button next to it.[/size] </div> </div> [url="javascript:void(0);"]> Deposit[/url] <div id="deposit" style="background: #ffffd3;border: 1px #ffff99 solid;display: none;padding: 20px;width: 250px;margin: 5px;"> <form action="" method="post" onsubmit="makeTrans(\'deposit\');return false;"><input type="text" name="deposit" value="' . ($ir['money'] ? $ir['money'] : 0) . '" /> <input type="submit" value="Deposit" /></form> <div id="deposit_callback"> [size="1"]Please choose the amount of money you wish to store in your account.[/size] </div> </div> '; } function deposit() { global $db, $ir, $c, $userid; if ($_POST['amount'] > $ir['money']) { echo '<span style="color:red;">You do not have that much money to deposit!</span>'; } else { $fee = ceil($_POST['amount'] * 15 / 100); $fee = ($fee > 3000 ? 3000 : $fee); $gain = $_POST['amount'] - $fee; $db->query("UPDATE `users` SET `bankmoney` = `bankmoney` + " . $gain . ", `money` = `money` - " . $_POST['amount'] . " WHERE userid=" . $userid); echo 'You deposited ' . money_formatter($_POST['amount']) . ' into your account. [size="1"]The 15% fee of ' . money_formatter($fee) . ' was taken depositing you a final amount of ' . money_formatter($gain) . '.[/size]'; } } function withdraw() { global $db, $ir, $c, $userid; if ($_POST['amount'] > $ir['bankmoney']) { echo '<span style="color:red;">You dont have enough money saved to withdraw that much!</span>'; } else { $db->query("UPDATE `users` SET `bankmoney` = `bankmoney` - " . $_POST['amount'] . ", `money` = `money` + " . $_POST['amount'] . " WHERE userid=" . $userid); $ir['money']+= $_POST['amount']; echo 'You withdrew ' . money_formatter($_POST['amount']) . ' into your hand from your account. [size="1"]You know have ' . money_formatter($ir['money']) . ' in your hand.[/size]'; } } if (!$_GET['print']) { $h->endpage(); } ?>
-
Sign of a decent code ;)
-
Follow this video.. You need to view the actual site. This video should make it easy to understand http://davemacaulay.com/blog.php?entry=3
-
Cause I wrote this before it was out.. Pointless question much.
-
Why did you say "shoutbox help" when you should of said "Shoutbox request". Then the use of extra large text. I released one ages ago search the forum you'll find one.
-
Been a while since I coded on the original Mccode script.. Mine secures itself by file name within sglobals... But I shall add this in :)
-
I doubt you made this.. Considering I've heard allot about you passing around mine and others mods.