Another easy mod that i would want..

All web design discussion, including Ultimate Quiz MOD support.

Moderator: CricketMX Forum Moderators

Post Reply
Leon
Know-It-All
Know-It-All
Posts: 282
Joined: Tue Feb 07, 2006 11:09 am
Contact:

I got alittle help with a new script when i asked in an admin forum.
But there seemed to be a bug in it (atlest he said it was one)

he uploaded the script here (it works quite good)..
http://hem.mjoelkbar.net/ekonomi.php

Code can be seen here:
http://hem.mjoelkbar.net/ekonomi.phps

But ok, that was only alittle bit of what i was after.
So i then created an html demo of it here:
http://www.volunteerforum.se/economy.php
(does not work, only a html demo)

So, anyone know how to change that script
(or how to make a new one) to fit my demo ?

his script was so mixed with html/php/html/php
so its impossibly to use with phpBB, atlest for me to implant it =/


Also, im my demo this is seen as the admin see it, for other later the
EDIT/DELETE and SUBMIT box will be gone..

Perhaps with help of the code:
if( $userdata['user_level'] != ADMIN )
{
}
Talk, discuss or debate everything about Volunteer 'ing at this forum!
Volunteer Forum Community
Leon
Know-It-All
Know-It-All
Posts: 282
Joined: Tue Feb 07, 2006 11:09 am
Contact:

Rootfile (php file)...

Code: Select all

<?php 

// standard hack prevent 
define('IN_PHPBB', true); 
$phpbb_root_path = './'; 
include($phpbb_root_path . 'extension.inc'); 
include($phpbb_root_path . 'common.'.$phpEx); 

// standard session management 
$userdata = session_pagestart($user_ip, PAGE_ECONOMY); 
init_userprefs($userdata); 

// set page title 
$page_title = 'Economy'; 

// standard page header 
include($phpbb_root_path . 'includes/page_header.'.$phpEx); 


// assign template 
$template->set_filenames(array( 
        'body' => 'economy.tpl') 
); 

$template->pparse('body'); 

// standard page footer 
include($phpbb_root_path . 'includes/page_tail.'.$phpEx); 

?>

standard tpl file

Code: Select all

<HTML>
<BODY>

{TPL_HDR1}Economy{TPL_HDR2}<table width="100%" cellpadding="2" cellspacing="1" border="0" class="forumline">
<th nowrap="nowrap" colspan="2">  
Economy
</th>
<tr>
<td class="row1" align="center">


{economy}


</tr>
</td>
</table>{TPL_FTR}

</BODY>
</HTML>

Then use of this for edit/delit and submit box

Code: Select all

if( $userdata['user_level'] != ADMIN )
{

}
Talk, discuss or debate everything about Volunteer 'ing at this forum!
Volunteer Forum Community
User avatar
battye
Site Admin
Site Admin
Posts: 14391
Joined: Sun Jan 11, 2004 8:26 am
Location: Australia
Contact:

Code: Select all

/* funktioner */
function mConnect($database,$user,$pass) {
    global $id;
    if (!($id=mysql_connect('localhost',$user,$pass))) {
        die('ingen anslutning till mysql');
    }
    if (!mysql_select_db($database)) {
        die('databasen finns inte');
    }
}

function mDisconnect() {
    global $id;
    mysql_close($id);
}

function mDo($query) {
    global $id;
    $result = mysql_query($query,$id);
    if ($result == false) { 
        die('fel i frågan: ' . $query );
    }
    return($result);
} 
Put that directly before:

Code: Select all

// set page title
$page_title = 'Economy'; 




Put

Code: Select all

if (isset($_POST['summa'])) {
    $sql = sprintf("INSERT INTO rad (tillagd,beskrivning,summa) VALUES(NOW(),'%s','%f')",
                                    mysql_real_escape_string($_POST['besk']),
                                    $_POST['summa']
                                );
    #echo $sql;
    if (mDo($sql)) { // lite överflödig, men heey
        $msg = 'Kärleken flödade och ditt entry är tillagd i databasen.';
        header('Location: ekonomi.php?msg=' . $msg);
    }
}

if (isset($_GET['del']) && is_numeric($_GET['del'])) {
    $sql = sprintf('UPDATE rad SET deleted = 1 WHERE id  = %d',$_GET['del']);
    mDo($sql);
    header('Location: ekonomi.php?msg=' . $msg);
}
?> 
after

Code: Select all

// standard page header
include($phpbb_root_path . 'includes/page_header.'.$phpEx); 





Then type

Code: Select all

?>
After that, put:

Code: Select all

<body>
<h1>Ekonomiscriptet som gud glömde</h1>
<?
if (isset($msg)) {
    ?>
    <h2><?=htmlentities($msg)?></h2>
    <?
}
?>
<form method="post" action="">
<fieldset>
<legend>Lägg till rader</legend>
<p><span>Anledning</span> <input type="text" name="besk" /></p>
<p><span>Summa</span> <input type="text" name="summa" /></p>
<p><input type="submit" value="Lägg till" /></p>
</fieldset>
</form>
<table id="tabell">
<tr><th>Tillagd</th><th>Beskrivning</th><th>Radsumma</th><th>Summa</th><th>Ta bort</th></tr>
<?


$offset = isset($_GET['o']) && is_numeric($_GET['o']) ? $_GET['o'] : 0;



$sql = sprintf('SELECT SQL_CALC_FOUND_ROWS id,tillagd,beskrivning,summa FROM rad WHERE deleted = 0 ORDER BY tillagd DESC LIMIT %d,%d',$offset*$raderPerSida,$raderPerSida);
#echo $sql;
$ekonomi_res = mDo($sql);

/* antalet rader totalt */
$sql = 'SELECT FOUND_ROWS() AS hittade_resultat';
$totalt_res = mDo($sql);
$antal_row = mysql_fetch_assoc($totalt_res);
$antal_rader = $antal_row['hittade_resultat'];
#echo $antal_rader;
/* kika igen och plocka fram äldsta datumet .. */
while ($rad = mysql_fetch_assoc($ekonomi_res)) {
    $lokalSumma += $rad['summa'];
    $aldstaDatum = $rad['tillagd'];
}

$sql = sprintf("SELECT SUM(summa) AS innansumma FROM rad WHERE deleted = 0 AND tillagd < '%s'",$aldstaDatum);
$saldo_res = mDo($sql);
$saldo = mysql_fetch_assoc($saldo_res);
$innanSumma = $saldo['innansumma'];
#echo $sql;
#echo $totsumma;
@mysql_data_seek($ekonomi_res,0);

while ($rad = mysql_fetch_assoc($ekonomi_res)) {
    
    ?>
    <tr><td><?=substr($rad['tillagd'],0,19)?></td><td><?=$rad['beskrivning']?></td><td><?=$rad['summa']?></td><td><?=$lokalSumma+$innanSumma?></td><td><a href="?del=<?=$rad['id']?>">Ta bort</a></td></tr>
    <?
    $lokalSumma+=$rad['summa']*-1;
}
?>
</table>
<p>
<?
for ($i=0;$i<=floor($antal_rader/$raderPerSida);$i++) {
    ?>
    <a href="?o=<?=$i?>"><?=$i?></a> 
    <?
} 
I hope that does the trick.
CricketMX.com in 2022: Still the home of bat's, rat's and other farmyard animals!

"OK, life [as you chose to define it] repeats until there are no more lessons to be learned." - nrnoble (June 12, 2005)
"the new forum looks awesome, it's getting bigger & better" - p2p-sharing-rules (11 Jan, 2008)
"Looks like CMX is not only getting bigger...but, also getting better!!" - moongirl (14 Dec, 2007)
Leon
Know-It-All
Know-It-All
Posts: 282
Joined: Tue Feb 07, 2006 11:09 am
Contact:

And what about all the extra suff i made in the demo ?

The link/date etc ?

And how do i create the SQL ?
Talk, discuss or debate everything about Volunteer 'ing at this forum!
Volunteer Forum Community
User avatar
battye
Site Admin
Site Admin
Posts: 14391
Joined: Sun Jan 11, 2004 8:26 am
Location: Australia
Contact:

I will have a think about this for you as I'm very busy this weekend, and this sounds quite involved.

I will try and post some more code for you on Monday or Tuesday. :)

Thanks
CricketMX.com in 2022: Still the home of bat's, rat's and other farmyard animals!

"OK, life [as you chose to define it] repeats until there are no more lessons to be learned." - nrnoble (June 12, 2005)
"the new forum looks awesome, it's getting bigger & better" - p2p-sharing-rules (11 Jan, 2008)
"Looks like CMX is not only getting bigger...but, also getting better!!" - moongirl (14 Dec, 2007)
Leon
Know-It-All
Know-It-All
Posts: 282
Joined: Tue Feb 07, 2006 11:09 am
Contact:

Perhaps it wasen't that easy as the totic said then =/

Thanks, i will wait until then, then... :)
Talk, discuss or debate everything about Volunteer 'ing at this forum!
Volunteer Forum Community
Leon
Know-It-All
Know-It-All
Posts: 282
Joined: Tue Feb 07, 2006 11:09 am
Contact:

Any success ?
Talk, discuss or debate everything about Volunteer 'ing at this forum!
Volunteer Forum Community
User avatar
battye
Site Admin
Site Admin
Posts: 14391
Joined: Sun Jan 11, 2004 8:26 am
Location: Australia
Contact:

To have the date appear, use

Code: Select all

$box = '<input type="text" name="time" value="' . date('F d Y') . '" />';
CricketMX.com in 2022: Still the home of bat's, rat's and other farmyard animals!

"OK, life [as you chose to define it] repeats until there are no more lessons to be learned." - nrnoble (June 12, 2005)
"the new forum looks awesome, it's getting bigger & better" - p2p-sharing-rules (11 Jan, 2008)
"Looks like CMX is not only getting bigger...but, also getting better!!" - moongirl (14 Dec, 2007)
Leon
Know-It-All
Know-It-All
Posts: 282
Joined: Tue Feb 07, 2006 11:09 am
Contact:

Perhaps, but then it isen't changebly ?

Well, seems like this mod need to be rewriten
from start, thats for sure =(
Talk, discuss or debate everything about Volunteer 'ing at this forum!
Volunteer Forum Community
User avatar
battye
Site Admin
Site Admin
Posts: 14391
Joined: Sun Jan 11, 2004 8:26 am
Location: Australia
Contact:

Yes, it will need a fair bit of modification to work in your page.
CricketMX.com in 2022: Still the home of bat's, rat's and other farmyard animals!

"OK, life [as you chose to define it] repeats until there are no more lessons to be learned." - nrnoble (June 12, 2005)
"the new forum looks awesome, it's getting bigger & better" - p2p-sharing-rules (11 Jan, 2008)
"Looks like CMX is not only getting bigger...but, also getting better!!" - moongirl (14 Dec, 2007)
Leon
Know-It-All
Know-It-All
Posts: 282
Joined: Tue Feb 07, 2006 11:09 am
Contact:

Yes it will...

Well just put that to on the self for later then =(

Thanks anyway...
Talk, discuss or debate everything about Volunteer 'ing at this forum!
Volunteer Forum Community
Post Reply