Dołącz do zespołu ekspertów! Backend lub Frontend Developer?

Sprawdź najnowsze oferty pracy naszego partnera - 8lines.io!

Zmiana nazw tabel w pluginie

Konfiguracja  Założony przez  Dawid1998PRO.

WITAM,
Chciałbym się dowiedzieć, czy można w pluginie zmienić ( przed instalacją ) nazwy prefiksów tabel które stworzą się w bazie danych po instalacji pluginu.
PLUGIN:
<?php
/** 
* Polish Language File developed by mybboard.pl for Bank System 2.0 
* Tłumaczenie: Schocker
* Poprawki: Ekipa Polskiego Supportu MyBB (mybboard.pl)
* Wersja 1.0
**/

/******************************************************************************
 *   Bank plugin for NewPoints (/inc/plugins/newpoints/newpoints_bank.php)
 *     Author: Pirata Nervo
 *   Copyright: © 2009-2010 Pirata Nervo
 *   Website: http://www.mybb-plugins.com
 *   Integrates a bank system with NewPoints. This plugin was modified by Mihu.
 ******************************************************************************/

/****************************************************************************
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
    
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/

//Disallow direct access to this file for security reasons
if(!defined("IN_MYBB"))
{
    die(
"Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}
//Our hook
$plugins->add_hook("newpoints_start""newpoints_bank_page");
$plugins->add_hook("newpoints_default_menu""newpoints_bank_menu");
$plugins->add_hook("member_profile_end""newpoints_bank_profile");
//new hooks - penalties
$plugins->add_hook("newthread_start""newpoints_bank_postingpenalties");
$plugins->add_hook("newreply_start""newpoints_bank_postingpenalties");
$plugins->add_hook("showthread_start""newpoints_bank_viewingpenalties");
//$plugins->add_hook("global_end", "newpoints_bank_update");
if (defined("IN_ADMINCP"))
{
    
$plugins->add_hook("newpoints_admin_stats_noaction_start""newpoints_bank_stats");
    
$plugins->add_hook("newpoints_admin_maintenance_edituser_form""newpoints_bank_edituser");
    
$plugins->add_hook("newpoints_admin_maintenance_edituser_commit""newpoints_bank_edituser_do");
}
else
{
    
$plugins->add_hook("newpoints_stats_start""newpoints_bank_stats");
}
// backup bank fields too
$plugins->add_hook("newpoints_task_backup_tables""newpoints_bank_backup");
function 
newpoints_bank_info()
{
    return array(
        
"name"            => "Bank",
        
"description"    => "Dodaje do systemu NewPoints funkcjonalność banku.",
        
"website"        => "http://www.mybb-plugins.com",
        
"author"        => "Pirata Nervo",
        
"authorsite"    => "http://www.mybb-plugins.com",
        
"version"        => "2.0",
        
"guid"             => "",
        
"compatibility" => ""
                
);
}
//install the bank plugin
function newpoints_bank_install()
{
    global 
$db$mybb$lang;
    
//add more user table fields
    
$db->write_query("ALTER TABLE `".TABLE_PREFIX."users` ADD `newpoints_bankoffset` DECIMAL(20,10) NOT NULL DEFAULT '0';");
    
$db->write_query("ALTER TABLE `".TABLE_PREFIX."users` ADD `newpoints_bankbasetime` BIGINT(30) NOT NULL DEFAULT '0';");
    
$db->write_query("CREATE TABLE `".TABLE_PREFIX."imprumuturi` (
      `id` int(11) NOT NULL auto_increment,
      `tip` int(1) NOT NULL default '1',
      `username` text NOT NULL,
      `data` bigint(30) NOT NULL,
      `suma_imprumut` decimal(20,2) NOT NULL,
      `suma_platita` decimal(20,2) NOT NULL,
      `sanctiuni` text NOT NULL,
      `observatii` text NOT NULL,
      PRIMARY KEY  (`id`)) TYPE=MyISAM"
);
    
//add settings
    
newpoints_add_setting('newpoints_bank_dep_fee''newpoints_bank''Opłata za wpłatę''Ilość punktów wymagana do wpłacenia punktów do banku (kwota ta jest pobierana od użytkownika przy dokonywaniu wpłaty).''text''10.00'1);
    
newpoints_add_setting('newpoints_bank_with_fee''newpoints_bank''Opłata za wypłatę''Ilość punktów wymagana do wypłacenia punktów z banku (kwota ta jest pobierana od użytkownika przy dokonywaniu wypłaty).''text''10.00'2);
    
newpoints_add_setting('newpoints_bank_commission''newpoints_bank''Prowizja kredytu''Wpisz, jaki procent kwoty kredytu będzie pobierany przez bank przy zaciąganiu nowej pożyczki (prowizja jest naliczana codziennie).''text''5.00'3);
    
newpoints_add_setting('newpoints_bank_rate''newpoints_bank''Oprocentowanie banku''Wpisz, ile procent kwoty wpłaconej do banku będzie do niej doliczane.''text''3.00'4);
    
newpoints_add_setting('newpoints_bank_period''newpoints_bank''Skala oprocentowania''Wpisz, co ile godzin ma być naliczane oprocentowanie.''text''24'5);
    
newpoints_add_setting('newpoints_bank_max_borrow''newpoints_bank''Maksymalna kwota pożyczki''Wpisz maksymalną ilość punktów, jaką użytkownik będzie mógł pożyczyć od banku.''text''10'6);
    
newpoints_add_setting('newpoints_bank_max_stats''newpoints_bank''Ilość pokazywanych pożyczek w statystykach NewPoints''Wpisz, ile pożyczek ma być pokazywanych na stronie statystyk NewPoints. Uwaga: jeśli wpiszesz 0, tabela statystyk banku nie będzie wyświetlana.''text''0'7);
    
newpoints_add_setting('newpoints_bank_enable_borrow''newpoints_bank''Włączyć pożyczki?''Czy użytkownicy mogą zaciągać pożyczki w banku?''yesno'08);
    
newpoints_add_setting('newpoints_bank_enable_resaccesdonation''newpoints_bank''Zablokować przekazywanie darowizn?''Czy zablokować opcję przekazywania darowizn użytkownikom z zaciągniętymi pożyczkami?''yesno'19);
    
newpoints_add_setting('newpoints_bank_enable_showprofilebank''newpoints_bank''Pokazywać stan konta w profilu?''Czy w profilu użytkownika ma być wyświetlany stan jego konta w banku?''yesno'010);
    
newpoints_add_setting('newpoints_bank_restrictviewingforums''newpoints_bank''Blokowanie dostępu do działów''Wpisz tutaj ID działów, których użytkownik nie będzie mógł przeglądać w razie nie spłacenia zaciągniętej pożyczki.''text'''11);
    
newpoints_add_setting('newpoints_bank_restrictpostingforums''newpoints_bank''Blokowanie pisania postów w działach''Wpisz tutaj ID działów, w których użytkownik nie będzie mógł pisać postów (ani zakładać nowych wątków) w razie niespłacenia zaciągniętej pożyczki.''text'''12);
    
//rebuild all settings
    
rebuild_settings();
    
//insert bank account
       
newpoints_lang_load("newpoints_bank");
    
$row = array(
        
"tip" => 0,
        
"username" => $lang->newpoints_bank,  
        
"data" => time(),
        
"suma_imprumut" => 1000000,
        
"suma_platita" => 0,
        
"sanctiuni" => "",
        
"observatii" => "",
                ); 
    
$db->insert_query('imprumuturi'$row);
    
//we insert a new task
    
$second_row = array (
        
"title" => "NewPoints Bank System",
        
"description" => "To uruchamiane codziennie zadanie jest częścią pluginu Bank System przeznaczonego dla NewPoints.",  
        
"file" => "newpoints_bank_task",
        
"minute" => "0",
        
"hour" => "12",
        
"day" => "*",
        
"month" => "*",
        
"weekday" => "*",
        
"nextrun" => 0,
        
"lastrun" => 0,
        
"enabled" => 0,
        
"logging" => 1,
        
"locked" => 0,
                        );
    
$db->insert_query('tasks'$second_row);
}
//uninstall the bank plugin
function newpoints_bank_uninstall()
{
    global 
$db;
    
//drop users table structure
    
$db->write_query("ALTER TABLE `".TABLE_PREFIX."users` DROP `newpoints_bankoffset`;");
    
$db->write_query("ALTER TABLE `".TABLE_PREFIX."users` DROP `newpoints_bankbasetime`;");
    
$db->write_query("DROP TABLE `".TABLE_PREFIX."imprumuturi`;");
    
$db->write_query("DELETE FROM `".TABLE_PREFIX."tasks` WHERE file='newpoints_bank_task';");
    
// delete all bank settings
    
newpoints_remove_settings("'newpoints_bank_dep_fee','newpoints_bank_with_fee','newpoints_bank_rate','newpoints_bank_commission','newpoints_bank_period','newpoints_bank_max_borrow','newpoints_bank_enable_borrow','newpoints_bank_max_stats','newpoints_bank_enable_resaccesdonation','newpoints_bank_enable_showprofilebank','newpoints_bank_restrictviewingforums','newpoints_bank_restrictpostingforums'");
    
//rebuild all settings
    
rebuild_settings();
}
//is already installed?
function newpoints_bank_is_installed()
{
    global 
$db;
    if(
$db->table_exists('imprumuturi'))
    {
        return 
true;
    }
    return 
false;
}
//now we activate the plugin
function newpoints_bank_activate()
{
    global 
$db$mybb;
    
//enable the bank task
    
$db->query("UPDATE ".TABLE_PREFIX."tasks SET enabled = 1 WHERE file = 'newpoints_bank_task'");  
    
//add all the templates
    
newpoints_add_template('newpoints_bank''
<html>
<head>
<title>{$mybb->settings[\'bbname\']} - {$lang->newpoints_bank}</title>
{$headerinclude}
{$javascript}
</head>
<body>
{$header}
<table width="100%" border="0" align="center">
<tr>
<td valign="top" width="180">
<table border="0" cellspacing="{$theme[\'borderwidth\']}" cellpadding="{$theme[\'tablespace\']}" class="tborder">
<tr>
<td class="thead"><strong>{$lang->newpoints_menu}</strong></td>
</tr>
{$options}
</table>
</td>
<td valign="top">
<form action="newpoints.php" method="POST" name="bank_form">
<input type="hidden" name="postcode" value="{$mybb->post_code}">
<input type="hidden" name="action" value="do_bank">
<table border="0" cellspacing="{$theme[\'borderwidth\']}" cellpadding="{$theme[\'tablespace\']}" class="tborder">
<tr>
<td class="thead" colspan="2"><strong>{$lang->newpoints_bank}</strong></td>
</tr>
<tr>
<td width="100%" colspan="2">
<table>
<tr>
<td class="trow1" width="90%">{$lang->newpoints_bank_fee}</td>
<td class="trow1" width="10%"><img src="inc/plugins/newpoints/images/bank.png"/></td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="tcat" width="100%" colspan="2">{$lang->newpoints_bank_transactions}</td>
</tr>
<tr>
<td class="trow2" width="100%" colspan="2"><b>{$mybb->user[\'username\']}</b> {$ihaveborrow}</td>
</tr>
<tr>
<td class="trow2" width="50%"><strong>{$lang->newpoints_bank_onhand}:</strong></td>
<td class="trow2" width="50%">{$mybb->user[\'newpoints\']}</td>
</tr>
<tr>
<td class="trow1" width="50%"><strong>{$lang->newpoints_bank_inbank}:</strong></td>
<td class="trow1" width="50%">{$mybb->user[\'newpoints_bankoffset\']}</td>
</tr>
<tr>
<td class="trow1" width="50%"><strong>{$lang->newpoints_amount}:</strong></td>
<td class="trow1" width="50%"><input class="textbox" type="text" value="0" name="amount"/></td>
</tr>
<tr>
<td class="trow2" width="50%"><strong>{$lang->newpoints_action}:</strong></td>
<td class="trow2" width="50%"><select name="bank_action" onchange="changevalue(this)">
        <option value="1">{$lang->newpoints_bank_withdraw}</option>
        <option value="2">{$lang->newpoints_bank_deposit}</option>
        <option value="3">{$lang->newpoints_bank_borrow}</option>
        <option value="4">{$lang->newpoints_bank_payborrow}</option>
                              </select></td>
</tr>
<tr>
<td class="trow2" width="100%" colspan="2">{$lang->newpoints_bank_performaction} <b id="text_schimbat">0</b> {$lang->newpoints_bank_points}!</td>
</tr>
<tr>
<td class="tfoot" width="100%" colspan="2" align="center"><input type="submit" name="submit" value="{$lang->newpoints_submit}"></td>
</tr>
</table>
</form>
</td>
</tr>
</table>
{$footer}
</body>
</html>'
);
    
newpoints_add_template('newpoints_bank_profile''<tr>
    <td class="trow2"><strong>{$currency} {$lang->newpoints_bank_profileinbank}:</strong></td>
    <td class="trow2"><a href="{$mybb->settings[\'bburl\']}/newpoints.php?action=bank">{$points_inbank}</a></td>
</tr>'
);
    
newpoints_add_template('newpoints_bank_stats_loan''
<table border="0" cellspacing="{$theme[\'borderwidth\']}" cellpadding="{$theme[\'tablespace\']}" class="tborder">
<tr>
<td class="thead" colspan="4"><strong>{$lang->newpoints_bank_stats_lastloans}</strong></td>
</tr>
<tr>
<td class="tcat" width="30%"><strong>{$lang->newpoints_bank_stats_loanuser}</strong></td>
<td class="tcat" width="30%" align="center"><strong>{$lang->newpoints_bank_stats_amountborrowed}</strong></td>
<td class="tcat" width="20%" align="center"><strong>{$lang->newpoints_bank_stats_amountpaid}</strong></td>
<td class="tcat" width="20%" align="center"><strong>{$lang->newpoints_bank_stats_loandata}</strong></td>
</tr>
{$last_bankloans}
</table><br />'
);
    
newpoints_add_template('newpoints_bank_stats_loans''
<tr>
<td class="{$namebankclass}" width="30%">{$bank_loanstats[\'user\']}</td>
<td class="{$namebankclass}" width="30%" align="center">{$bank_loanstats[\'suma_imprumut\']}</td>
<td class="{$namebankclass}" width="20%" align="center">{$bank_loanstats[\'suma_platita\']}</td>
<td class="{$namebankclass}" width="20%" align="center">{$bank_loanstats[\'data\']}</td>
</tr>'
);
    
newpoints_add_template('newpoints_bank_stats_noloan''
<tr>
<td class="trow1" width="100%" colspan="4">{$lang->newpoints_bank_stats_noloans}</td>
</tr>'
);
    
newpoints_find_replace_templatesets('newpoints_statistics''#'.preg_quote('width="60%">').'#''width="60%">{$newpoints_bank_lastlons}');
    require_once 
MYBB_ROOT."inc/adminfunctions_templates.php";
    
find_replace_templatesets("member_profile"'#'.preg_quote('{$newpoints_profile}').'#''{$newpoints_profile}'.'{$newpoints_bank_profile}');
}
//deactivate plugin
function newpoints_bank_deactivate()
{
    global 
$db$mybb;
    
//disable the bank task
    
$db->query("UPDATE ".TABLE_PREFIX."tasks SET enabled = 0 WHERE file = 'newpoints_bank_task'"); 
    
//remove all bank templates
    
newpoints_remove_templates("'newpoints_bank','newpoints_bank_profile','newpoints_bank_stats_loan','newpoints_bank_stats_loans','newpoints_bank_stats_noloan'");
    
//find and replace modified templates
    
newpoints_find_replace_templatesets('newpoints_statistics''#'.preg_quote('{$newpoints_bank_lastlons}').'#''');
    require_once 
MYBB_ROOT."inc/adminfunctions_templates.php";
    
find_replace_templatesets("member_profile"'#'.preg_quote('{$newpoints_bank_profile}').'#'''0);
}
// show bank in the list menu
function newpoints_bank_menu(&$menu)
{
    global 
$mybb$lang;
    
newpoints_lang_load("newpoints_bank");
    if (
$mybb->input['action'] == 'bank')
        
$menu[] = "&raquo; <a href=\"{$mybb->settings['bburl']}/newpoints.php?action=bank\">".$lang->newpoints_bank."</a>";
    else
        
$menu[] = "<a href=\"{$mybb->settings['bburl']}/newpoints.php?action=bank\">".$lang->newpoints_bank."</a>";
}
//this function calculate user points
function newpoints_calculate_points($offset$basetime)
{
    global 
$mybb;
    if (!
$basetime)
        return;
    
$period intval($mybb->settings['newpoints_bank_period'])*3600;
    
// prevent devide by zero errors
    
if($period 1)
    {
        
$period 24*3600
        
// 24 * 3600 seconds (one hour) = 1 day (24 hours)
    
}
    
// make rate
    
$rate floatval($mybb->settings['newpoints_bank_rate'])/100;
    
// if we have a period, rate and basetime, calculate money
    
if ($period && $rate && $basetime)
    {
        
$offset round(pow($ratefloor((TIME_NOW-intval($basetime)) / $period)) * floatval($offset), $mybb->settings['newpoints_main_decimal']);
        return 
$offset;
    }
    else
    {
        
// just return the passed offset
        
return $offset
    }
}
//update bank values
function newpoints_bank_update_values($totalamount$uid 0$curuser false)
{
    global 
$mybb$db;
    if (!
is_array($uid))
    {
        
$uid intval($uid);
        if (
$uid == 0)
            return 
false;
    }
    else
        
$user $uid;
    
$totalamount floatval($totalamount);    
    
$period intval($mybb->settings['newpoints_bank_period'])*3600;
    
// prevent devide by zero errors
    
if($period 1)
        
$period 24*3600// 24 * 3600 seconds (one hour) = 1 day (24 hours)    
    
$user = array();
    
$user['newpoints_bankbasetime'] = TIME_NOW - (TIME_NOW $period);
    
$user['newpoints_bankoffset'] = round(floatval($totalamount) / (pow(+ (floatval($mybb->settings['newpoints_bank_rate']) / 100), floor((TIME_NOW-intval($user['newpoints_bankbasetime'])) / $period))), $mybb->settings['newpoints_main_decimal']);    
    
$db->update_query('users', array('newpoints_bankbasetime' => $user['newpoints_bankbasetime'], 'newpoints_bankoffset' => $user['newpoints_bankoffset']), 'uid=\''.$uid.'\'');    
    if (
$curuser)
    {
        
$mybb->user['newpoints_bankbasetime'] = $user['newpoints_bankbasetime'];
        
$mybb->user['newpoints_bankoffset'] = $user['newpoints_bankoffset'];
    }    
    return 
true;
}
//bank standard page
function newpoints_bank_page()
{
    global 
$mybb$db$lang$cache$theme$header$templates$plugins$headerinclude$footer$options;
    if (!
$mybb->user['uid'])
        return;    
    
// bank page
    
if ($mybb->input['action'] == "bank")
    {
        
$plugins->run_hooks("newpoints_bank_start");
        
newpoints_lang_load("newpoints_bank");
        
$mybb->user['newpoints'] = newpoints_format_points($mybb->user['newpoints']);
        
$period intval($mybb->settings['newpoints_bank_period'])*3600;
        
// prevent devide by zero errors
        
if($period 1)
        {
            
$period 24*3600
            
// 24 * 3600 seconds (one hour) = 1 day (24 hours)    
        
}
        if (
TIME_NOW-$period $mybb->user['newpoints_bankbasetime'])
        {
            
// update bank values
            
$mybb->user['newpoints_bankoffset'] = newpoints_format_points(newpoints_calculate_points($mybb->user['newpoints_bankoffset'], $mybb->user['newpoints_bankbasetime']));
        }
        else
            
$mybb->user['newpoints_bankoffset'] = newpoints_format_points($mybb->user['newpoints_bankoffset']);
        
$lang->newpoints_bank_fee $lang->sprintf($lang->newpoints_bank_feenewpoints_format_points($mybb->settings['newpoints_bank_dep_fee']), newpoints_format_points($mybb->settings['newpoints_bank_with_fee']), $mybb->settings['newpoints_bank_rate'], $mybb->settings['newpoints_bank_period'], $mybb->settings['newpoints_bank_commission']);    
        if (
$db->num_rows($db->simple_select("imprumuturi""*""username='".$mybb->user['username']."'","")) > 0)
        {
            
$query $db->simple_select("imprumuturi""*""username='".$mybb->user['username']."'","");
            
$row $db->fetch_array($query);
            
$difference floatval($row['suma_imprumut']) - floatval($row['suma_platita']);
            
$date my_date($mybb->settings['dateformat'], $row['data']);
            
$ihaveborrow $lang->sprintf($lang->newpoints_bank_user_borrow_remainnewpoints_format_points($difference), newpoints_format_points($row['suma_imprumut']), $date);
        }
        else
        {
            
$ihaveborrow $lang->newpoints_bank_user_noborrow;
        }
        
$javascript "<script type=\"text/javascript\">
function changevalue(value_selected)
{
    amountval = document.bank_form.amount.value;
    switch(value_selected.value)
    {
    case '1':
        tax = "
.$mybb->settings['newpoints_bank_with_fee'].";
        calc = parseFloat(tax);
        document.getElementById('text_schimbat').innerHTML = calc;
    break
    case '2':
        tax = "
.$mybb->settings['newpoints_bank_dep_fee'].";
        calc = parseFloat(amountval) + parseFloat(tax);
        document.getElementById('text_schimbat').innerHTML = calc;
    break
    case '3':
        tax = 0;
        calc = parseFloat(tax);
        document.getElementById('text_schimbat').innerHTML = calc;
    break
    case '4':
        tax = 0;
        calc = parseFloat(amountval) + parseFloat(tax);
        document.getElementById('text_schimbat').innerHTML = calc;
    break
   }
}
</script>"
;
        eval(
"\$page = \"".$templates->get('newpoints_bank')."\";");
        
$plugins->run_hooks("newpoints_bank_end");
        
output_page($page);
    }
    elseif ((
$mybb->input['action'] == "do_bank"))
    {
        
verify_post_check($mybb->input['postcode']);
        
$plugins->run_hooks("newpoints_do_bank_start");
        if (
$mybb->input['bank_action'] != && $mybb->input['bank_action'] != && $mybb->input['bank_action'] != && $mybb->input['bank_action'] != 4)
        {
            
error($lang->newpoints_bank_invalid_action);
        }
        switch (
$mybb->input['bank_action'])
        {
            
//withdraw money
            
case 1:
                
// do we have enough money to pay the fee?
                
if (floatval($mybb->settings['newpoints_bank_with_fee']) > $mybb->user['newpoints'])
                {
                    
error($lang->newpoints_bank_cant_pay_fee);
                }
                
// do we even have such amount in bank?
                
$amount abs(floatval($mybb->input['amount']));
                if (
$amount $mybb->user['newpoints_bankoffset'])
                {
                    
error($lang->newpoints_bank_not_enough_bank);
                }
                
// add money to user - fee
                
newpoints_addpoints($mybb->user['uid'], $amount-(floatval($mybb->settings['newpoints_bank_with_fee'])));
                
// update bank values
                
newpoints_bank_update_values($mybb->user['newpoints_bankoffset']-$amount$mybb->user['uid'], true);
                
// if the amount of points is less than 0 in bank (for some weird reason, this could happen?)
                
if ($mybb->user['newpoints_bankoffset'] < 0)
                    
newpoints_bank_update_values(0$mybb->user['uid'], true);
                
// log withdrawal
                
newpoints_log('bank_withdraw'$lang->sprintf($lang->newpoints_bank_withdrawn_log$amount));
                
redirect($mybb->settings['bburl']."/newpoints.php?action=bank"$lang->sprintf($lang->newpoints_bank_withdrawnnewpoints_format_points($amount)));    
            break;
            
//deposit money
            
case 2:        
                
// do we have enough money to pay the fee plus the amount on hand?
                
$amount abs(floatval($mybb->input['amount']));
                if ((
$amount floatval($mybb->settings['newpoints_bank_dep_fee'])) > $mybb->user['newpoints'])
                {
                    
error($lang->newpoints_bank_not_enough_hand);
                }
                
// get money from user
                
newpoints_addpoints($mybb->user['uid'], -($amount+floatval($mybb->settings['newpoints_bank_dep_fee'])));
                
// update bank values
                
newpoints_bank_update_values($amount+$mybb->user['newpoints_bankoffset'], $mybb->user['uid']);
                
// log deposit
                
newpoints_log('bank_deposit'$lang->sprintf($lang->newpoints_bank_deposited_log$amount));
                
redirect($mybb->settings['bburl']."/newpoints.php?action=bank"$lang->sprintf($lang->newpoints_bank_depositednewpoints_format_points($amount)));
            break;
            
//borrow money from bank
            
case 3:
                
$banca $db->fetch_array($db->simple_select("imprumuturi""*""tip = 0",array("limit" => 1)));
                
$amount abs(floatval($mybb->input['amount']));
                
//check if this option is enabled from AdminCP
                
if ($mybb->settings['newpoints_bank_enable_borrow'] == 0)
                {
                    
error($lang->newpoints_bank_not_enabled_borrow);   
                }
                
//we check if the amount is less than the maximum borrow amount
                
if ($amount floatval($mybb->settings['newpoints_bank_max_borrow']))
                {
                    
error($lang->sprintf($lang->newpoints_bank_max_borrowpoints$mybb->settings['newpoints_bank_max_borrow']));
                }
                
//we check if the bank have enough money to pay you
                
if ($amount $banca['suma_imprumut'])
                {
                    
error($lang->newpoints_bank_not_bank_funds);
                }
                
//check if you have already a loan
                
if ($db->num_rows($db->simple_select("imprumuturi""*""username='".$mybb->user['username']."'","")) > 0)
                {
                    
error($lang->newpoints_bank_another_borrow);
                }
                
$infos = array(
                        
"tip" => 1,
                        
"username" => $mybb->user['username'],  
                        
"data" => time(),
                        
"suma_imprumut" => $amount,
                        
"suma_platita" => 0,
                        
"sanctiuni" => "",
                        
"observatii" => "",
                                   );         
                
$valoare floatval($banca['suma_imprumut']) - $amount;
                
$old_points $db->fetch_array($db->simple_select("users""newpoints""username='".$mybb->user['username']."'",array("limit" => 1)));
                
$db->query("UPDATE ".TABLE_PREFIX."imprumuturi SET suma_imprumut=".$valoare." WHERE tip = 0");
                
$new_points floatval($old_points['newpoints']) + floatval($amount);
                
$db->query("UPDATE ".TABLE_PREFIX."users SET newpoints=".floatval($new_points)." WHERE username='".$mybb->user['username']."'");
                
//insert loan in database
                
$db->insert_query("imprumuturi"$infos);
                
//log new borrow
                
newpoints_log('bank_newborrow'$lang->sprintf($lang->newpoints_bank_newborrow_log$amount));
                
//redirect - cu succes
                
redirect($mybb->settings['bburl']."/newpoints.php?action=bank"$lang->sprintf($lang->newpoints_bank_borrowednewpoints_format_points($amount)));
            break;
            
//pay a borrow
            
case 4:
                
$banca $db->fetch_array($db->simple_select("imprumuturi""*""tip = 0", array("limit" => 1)));
                
$amount abs(floatval($mybb->input['amount']));
                
//se verifica daca ai ce sa platesti
                
if ($db->num_rows($db->simple_select("imprumuturi""*""username='".$mybb->user['username']."'","")) == 0)
                {
                    
error($lang->newpoints_bank_not_active_borrow);
                }
                
$imprumut $db->fetch_array($db->simple_select("imprumuturi""*""username='".$mybb->user['username']."'", array("limit" => 1)));
                
$diferenta_ramasa floatval($imprumut['suma_imprumut']) - floatval($imprumut['suma_platita']);
                
//se plateste
                
if ($amount >= $diferenta_ramasa)
                {
                    
newpoints_addpoints($mybb->user['uid'], -floatval($diferenta_ramasa), 1true);   
                    
$db->query("DELETE FROM ".TABLE_PREFIX."imprumuturi WHERE username='".$mybb->user['username']."'");
                    
$value floatval($banca['suma_imprumut']) + floatval($imprumut['suma_imprumut']);
                    
$db->query("UPDATE ".TABLE_PREFIX."imprumuturi SET suma_imprumut=".$value." WHERE tip = 0");  
                    
redirect($mybb->settings['bburl']."/newpoints.php?action=bank"$lang->sprintf($lang->newpoints_bank_payborrowednewpoints_format_points($diferenta_ramasa))); 
                }
                else
                {
                    
newpoints_addpoints($mybb->user['uid'], -floatval($amount), 1true); 
                    
$value floatval($banca['suma_imprumut']) + floatval($amount); 
                    
$db->query("UPDATE ".TABLE_PREFIX."imprumuturi SET suma_imprumut=".$value." WHERE tip = 0"); 
                    
$value floatval($amount) + floatval($imprumut['suma_platita']);  
                    
$db->query("UPDATE ".TABLE_PREFIX."imprumuturi SET suma_platita=".$value." WHERE username='".$mybb->user['username']."'");     
                    
redirect($mybb->settings['bburl']."/newpoints.php?action=bank"$lang->sprintf($lang->newpoints_bank_payborrowednewpoints_format_points($amount)));
                }
            break;
        }
        
$plugins->run_hooks("newpoints_do_bank_end");
    }
}
//this function will restrict acces to the donation page for all the users who have an active loan
function newpoints_bank_restrictaccestodon($username)
{
    global 
$db$lang;
    if (
$db->num_rows($db->simple_select("imprumuturi""*""username='".$username."'","")) > 0)
    {
        
error($lang->newpoints_bank_restrict_donation);
    }    
}
//bank posting denied penalties - if you don`t pay
function newpoints_bank_postingpenalties()
{
    global 
$db$mybb$fid$lang;
    
//we check if a user has an active loan
    
if ($db->num_rows($db->simple_select("imprumuturi""*""username='".$mybb->user['username']."'","")) > 0)
    {
        
//if yes, we check if he or she has penalties
        
$row $db->fetch_array($db->simple_select("imprumuturi""*""username='".$mybb->user['username']."'"));
        if (!empty(
$row['sanctiuni']))
        {
            
$penalties_array explode(","$row['sanctiuni']);
            
$forums_array explode(","$mybb->settings['newpoints_bank_restrictviewingforums']);
            if (
in_array($fid$forums_array) && in_array("blockposting"$penalties_array))
            {
                
newpoints_lang_load("newpoints_bank");
                
error($lang->newpoints_bank_restrictpostacces);
            }
        }
    }
}
//bank viewing denied penalties - if you don`t pay
function newpoints_bank_viewingpenalties()
{
    global 
$db$mybb$fid$lang;
    
//we check if a user has an active loan
    
if ($db->num_rows($db->simple_select("imprumuturi""*""username='".$mybb->user['username']."'","")) > 0)
    {
        
//if yes, we check if he or she has penalties
        
$row $db->fetch_array($db->simple_select("imprumuturi""*""username='".$mybb->user['username']."'"));
        if (!empty(
$row['sanctiuni']))
        {
            
$penalties_array explode(","$row['sanctiuni']);
            
$forums_array explode(","$mybb->settings['newpoints_bank_restrictpostingforums']);
            if (
in_array($fid$forums_array) && in_array("blockviewing"$penalties_array))
            {
                
newpoints_lang_load("newpoints_bank");
                
error($lang->newpoints_bank_restrictviewacces);
            }
        }
    }
}
//show money in bank - member profile
function newpoints_bank_profile()
{
    global 
$db$mybb$templates$memprofile$newpoints_bank_profile$lang;
    if (
$mybb->settings['newpoints_bank_enable_showprofilebank'] == 1)
    {
        
newpoints_lang_load("newpoints_bank");
           
$currency $mybb->settings['newpoints_main_curname'];
        
$points_inbank newpoints_format_points($memprofile['newpoints_bankoffset']);  
        eval(
"\$newpoints_bank_profile = \"".$templates->get('newpoints_bank_profile')."\";"); 
    }
    else
    {
        eval(
"\$newpoints_bank_profile = '';");    
    }
}
//show the bank stats
function newpoints_bank_stats()
{
    global 
$db$mybb$lang$templates$cache$theme$last_bankloans$newpoints_bank_lastlons;
    if (
intval($mybb->settings['newpoints_bank_max_stats']) == 0)
    {
        eval(
"\$newpoints_bank_lastlons = '';");    
    }
    else
    {
    
$query $db->simple_select('imprumuturi''*''tip = 1', array('order_by' => 'data''order_dir' => 'DESC''limit' => intval($mybb->settings['newpoints_bank_max_stats'])));
       
$last_bankloans '';
    while(
$row $db->fetch_array($query)) 
    {
        
$namebankclass alt_trow();
        
$user $db->fetch_array($db->simple_select("users""uid""username='".$row['username']."'", array("limit" => 1)));
        
$link build_profile_link(htmlspecialchars_uni($row['username']), intval($user['uid']));
        
$bank_loanstats['user'] = $link;
        
$bank_loanstats['suma_imprumut'] = number_format($row['suma_imprumut'], 2'.''');
          
$bank_loanstats['suma_platita'] = number_format($row['suma_platita'], 2'.''');
        
$bank_loanstats['data'] = my_date($mybb->settings['dateformat'], intval($row['data']), ''false);
        eval(
"\$last_bankloans .= \"".$templates->get('newpoints_bank_stats_loans')."\";");
    }
    if (!
$last_bankloans)
    {
        eval(
"\$last_bankloans = \"".$templates->get('newpoints_bank_stats_noloan')."\";");
    }
    eval(
"\$newpoints_bank_lastlons = \"".$templates->get('newpoints_bank_stats_loan')."\";");
    }
}
//backup bank information
function newpoints_bank_backup(&$backup_fields)
{
    global 
$db$table;
    
$backup_fields[] = 'newpoints_bankbasetime';
    
$backup_fields[] = 'newpoints_bankoffset';
}
//edit user from AdminCP - action do
function newpoints_bank_edituser_do()
{
    global 
$db$updates$mybb$user;    
    
$period intval($mybb->settings['newpoints_bank_period'])*3600;
    
// prevent devide by zero errors
    
if($period 1)
    {
        
$period 24*3600
        
// 24 * 3600 seconds (one hour) = 1 day (24 hours)
    
}
    
$updates['newpoints_bankoffset'] = floatval($mybb->input['bankmoney']);
    
$updates['newpoints_bankbasetime'] = TIME_NOW - (TIME_NOW $period);
}
//edit user from AdminCP
function newpoints_bank_edituser()
{
    global 
$db$mybb$form$lang$user;
    
newpoints_lang_load("newpoints_bank");
    
$form_container = new FormContainer($lang->newpoints_bank_money_inbank);
    
$form_container->output_row($lang->newpoints_bank_money_inbank$lang->newpoints_bank_money_inbank_desc$form->generate_text_box('bankmoney'round(newpoints_calculate_points($user['newpoints_bankoffset'], $user['newpoints_bankbasetime']), intval($mybb->settings['newpoints_main_decimal'])), array('id' => 'bankmoney')), 'bankmoney');
    
$form_container->end();
}
?>
TABLE_PREFIX jest taki sam jak reszta tabel podana podczas instalacji forum, zawsze możesz to zmienić w pliku pluginu, ale nie wiem jak zachowa się podczas użytkowania.



Użytkownicy przeglądający ten wątek:

1 gości