1 (edited by Cursed1 2006-10-05 00:08)

Topic: so i have cash mod 1.2 by pandark and i would like to add a shop- read

i my self can't code php for crap i just use readme's but i found this on the site its a shop mod for some other type of point system, could anyone smart possibly make this shop work with pandarks cash mod 1.2?

heres the topic of his cash mod http://www.punres.org/viewtopic.php?id=1276

let me know if it can or can't be done ty smile

heres the code

<?php

// This is by me, myself, and I, all written from scratch.

define('PUN_ROOT', './');
require PUN_ROOT.'include/common.php';

if ($pun_user['g_read_board'] == '0' || !$pun_config['o_pms_enabled'] || $pun_user['is_guest'])
    message($lang_common['No permission']);
    
$page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / Store';
require PUN_ROOT.'header.php';

//Get your points
$result = $db->query('SELECT points FROM '.$db->prefix.'users WHERE id='.$pun_user['id']) or error('Unable to fetch points', __FILE__, __LINE__, $db->error());
$your_points = $db->result($result);

//Get donatee
if(isset($_GET['user'])) $user=$_GET['user'];
else $user='';

//Donating?
if(isset($_POST['donatee']) && isset($_POST['points']) && is_numeric($_POST['points']))
{
    $donatee=pun_trim($_POST['donatee']);
    $donatee=addslashes($donatee);
    $donate_amount=$_POST['points'];
    $donate_amount=addslashes($donate_amount);
    if($donate_amount<0) $donate_amount=0;
    if($donate_amount==0) message('And I thought that you were actually going to donate something.');
    $result = $db->query('SELECT id FROM '.$db->prefix.'users WHERE username=\''.$donatee.'\'') or error('Unable to fetch the donatees id', __FILE__, __LINE__, $db->error());
    $donatee_id = $db->result($result);
    $num = mysql_num_rows($result);
    if($num==0) message('That user does not exist.');
    $result = $db->query('SELECT points FROM '.$db->prefix.'users WHERE username=\''.$donatee.'\'') or error('Unable to fetch the donatees points', __FILE__, __LINE__, $db->error());
    $donatee_points = $db->result($result);
    
    if($donatee==$pun_user['username']) message("You cannot donate to yourself!");
    else 
    {
        if($donate_amount > $your_points) message("You don't have enough points!");
        else
        {
            $donatee_points += $donate_amount;
            $your_points -= $donate_amount;
            $db->query('UPDATE '.$db->prefix.'users SET points='.$donatee_points.' WHERE username=\''.$donatee.'\'') or error('Unable to give points to the donatee.', __FILE__, __LINE__, $db->error());
            $db->query('UPDATE '.$db->prefix.'users SET points='.$your_points.' WHERE id='.$pun_user['id']) or error('Unable to take away your points.', __FILE__, __LINE__, $db->error());
            
            $smilies=1;
            $subject = 'Donation from '.$pun_user['username'].'';
            $message = 'Congratulations, you have recieved a donation of '.$donate_amount.' points from '.$pun_user['username'].'.';
            $db->query('INSERT INTO '.$db->prefix.'messages (owner, subject, message, sender, sender_id, sender_ip, smileys, posted) VALUES(
            \''.addslashes($donatee_id).'\',
            \''.addslashes($subject).'\',
            \''.addslashes($message).'\',
            \''.addslashes($pun_user['username']).'\',
            \''.$pun_user['id'].'\',
            \''.get_remote_address().'\',
            \''.$smilies.'\',
            \''.time().'\'
            )') or error('Unable to send private message', __FILE__, __LINE__, $db->error());
            
            $message = "Congratulations, you have just sent $donate_amount points to $donatee. You now have $your_points points.";            
            redirect('store.php', $message);
        }
    }
}

//Changing your title
if(isset($_POST['your_title']))
{
    $cost = 250;
    if($cost>$your_points) message("You can't afford a title change");
    else $your_points -= $cost;
    $your_title = pun_trim($_POST['your_title']);
    $your_title = addslashes($your_title);
    $db->query('UPDATE '.$db->prefix.'users SET points='.$your_points.' WHERE id='.$pun_user['id']) or error('Unable to take away your points.', __FILE__, __LINE__, $db->error());
    $db->query('UPDATE '.$db->prefix.'users SET title=\''.$your_title.'\' WHERE id='.$pun_user['id']) or error('Unable to change your title.', __FILE__, __LINE__, $db->error());
    $your_title=pun_htmlspecialchars($your_title);
    $message = "Congratulations, you have changed your title to $your_title. You now have $your_points points.";            
    redirect('store.php', $message);
}

//Change another user's title
if(isset($_POST['donatee']) && isset($_POST['another_title']))
{
    $cost = 500;
    if($cost>$your_points) message("You can't afford a title change");
    $donatee=pun_trim($_POST['donatee']);
    $donatee=addslashes($donatee);
    $another_title = pun_trim($_POST['another_title']);
    $another_title = addslashes($another_title);
    $result = $db->query('SELECT id FROM '.$db->prefix.'users WHERE username=\''.$donatee.'\'') or error('Unable to fetch the donatees id', __FILE__, __LINE__, $db->error());
    $donatee_id = $db->result($result);
    $num = mysql_num_rows($result);
    if($num==0) message('That user does not exist.');
    if($donatee==$pun_user['username']) message("You cannot purchase this for yourself!");
    $your_points -= $cost;
    $db->query('UPDATE '.$db->prefix.'users SET points='.$your_points.' WHERE id='.$pun_user['id']) or error('Unable to take away your points.', __FILE__, __LINE__, $db->error());
    $db->query('UPDATE '.$db->prefix.'users SET title=\''.$another_title.'\' WHERE username=\''.$donatee.'\'') or error('Unable to change their title.', __FILE__, __LINE__, $db->error());
    $your_title=pun_htmlspecialchars($your_title);
    $message = "Congratulations, you have changed $donatee's title to $another_title. You now have $your_points points.";            
    redirect('store.php', $message);    
}
?>
<div class="block">
    <h2><span><?php echo 'Store' ?></span></h2>
    <div class="box">
            <div class="inbox">
                <fieldset>
                    <legend>Your Points</legend>
                    <div class="infldset">
                        You currently have <?php echo $your_points ?> points.
                    </div>
                </fieldset>
            </div>
            <div class="inbox">
                <fieldset>
                    <legend>Donate to Another User</legend>
                    <div class="infldset">
                        <form id="donate" method="post" action="store.php">
                        <label><strong>User's Name</strong><br />
                        <input type="text" name="donatee" value="<?php echo $user ?>" size="20" maxlength="30" /><br />
                        </label>
                        <label><strong>Points</strong><br />
                        <input type="text" name="points" value="" size="10" maxlength="20" /><br />
                        </label>
                        <input type="submit" name="donate" value="Submit" />
                        </form>
                    </div>
                </fieldset>
            </div>
            <div class="inbox">
                <fieldset>
                    <legend>Customize Your Title</legend>
                    <div class="infldset">
                        <form id="title_your" method="post" action="store.php">
                        <label><strong>New Title</strong> (Leave blank to reset to default.)<br />
                        <input type="text" name="your_title" value="" size="30" maxlength="50" /><br />
                        </label>
                        <input type="submit" name="submit_your_title" value="Submit" />
                        <strong>Cost</strong>: 250 points
                        </form>
                    </div>
                </fieldset>
            </div>
            <div class="inbox">
                <fieldset>
                    <legend>Change Another User's Title</legend>
                    <div class="infldset">
                        <form id="title_another" method="post" action="store.php">
                        <label><strong>User's Name</strong><br />
                        <input type="text" name="donatee" value="<?php echo $user ?>" size="20" maxlength="30" /><br />
                        </label>
                        <label><strong>New Title</strong><br />
                        <input type="text" name="another_title" value="" size="30" maxlength="50" /><br />
                        </label>
                        <input type="submit" name="submit_another_title" value="Submit" />
                        <strong>Cost</strong>: 500 points
                        </form>
                    </div>
                </fieldset>
            </div>
    </div>
</div>
<?php require PUN_ROOT.'footer.php' ?>

^save as store.php

Re: so i have cash mod 1.2 by pandark and i would like to add a shop- read

Anyone can do this????????

Would be so awesome!

Re: so i have cash mod 1.2 by pandark and i would like to add a shop- read

Moved to Modifications