Author |
Message |
hicuxunicorniobestbuildpc
The Mouse Is Extension Of Arm
Joined: Aug 13, 2009
Posts: 1123
|
Posted:
Mon Nov 23, 2020 4:41 pm |
|
I am getting some errors now from this RN Module made it from Guardian
Notice: Undefined offset: 1 in /www.bestbuildpc.org/modules/RN_Subscription/index.php on line 37
Code:$username = $cookie[1];
|
Notice: Undefined offset: 1 in /www.bestbuildpc.org/modules/RN_Subscription/index.php on line 44
$username = $cookie[1];
Notice: Undefined offset: 1 in /www.bestbuildpc.org/modules/RN_Subscription/index.php on line 46
Code:list($uid, $username) = explode(":", $nukeuser);
|
part of the index.php
Code:if (!defined('MODULE_FILE')) {
die('Illegal Access Detected!!!');
}
require_once 'mainfile.php';
$index = 0;
if (!defined('INDEX_FILE'))
define('INDEX_FILE', true);
// Set to FALSE to hide right blocks
if (defined('INDEX_FILE') AND INDEX_FILE === true) {
$index = 1;
}
$module_name = 'RN_Subscription';
get_lang($module_name);
$pagetitle = '- ' . $module_name;
define('RNS_BUTTONS', true); // comment out to use images
if (!isset($op))
$op = '';
global $user, $cookie, $prefix, $nukeuser, $db, $prefix, $name;
cookiedecode($user);
$username = $cookie[1];
// Front Page
function rn_sub_fp() {
global $user, $cookie, $username, $nukeuser, $prefix, $db, $module_name, $nukeurl;
cookiedecode($user);
$username = $cookie[1];
list($uid, $username) = explode(":", $nukeuser);
$capt_uid = $uid;
addCSSToHead('modules/' . $module_name . '/style.css', 'file');
include_once 'header.php';
|
Guardian's website is not anymore. I wonder if he or someone else could fix this issue. Thanks in advance. |
|
|
|
|
neralex
Site Admin
Joined: Aug 22, 2007
Posts: 1774
|
Posted:
Wed Nov 25, 2020 2:52 pm |
|
Some old coding-stuff like this is not more working correctly on php7:
php Code:cookiedecode($user);
$username = $cookie[1];
list($uid, $username) = explode(":", $nukeuser);
|
Remove the code-lines above and remove $cookie, $nukeuser and add $user, $username, $uid to the the globals. After the changes, you can get the user's database-fields with this RN25x approach:
php Code:global $user, $username, $uid, $prefix, $db, $module_name, $nukeurl;
if (is_user($user)) {
$userinfo = getusrinfo($user);
$uid = $userinfo['user_id'];
$username = $userinfo['username'];
} else {
$userinfo = array();
}
|
|
_________________ Github: RavenNuke |
|
|
|
hicuxunicorniobestbuildpc
|
Posted:
Wed Nov 25, 2020 5:29 pm |
|
hmmm now I see this became old so this is a fix but when I want to add a subscriber it is giving me a white page. NO ERROR but I have everything ON to show errors
admin.php?op=admin_rn_sub_add_sub
I can not add any username
Code:Fatal error: Uncaught Error: Call to undefined function striptags() in /www.bestbuildpc.org/modules/RN_Subscription/admin/private/RNS_Add_Sub.php:23 Stack trace: #0 /www.bestbuildpc.org/modules/RN_Subscription/admin/index.php(72): include_once() #1 /www.bestbuildpc.org/modules/RN_Subscription/admin/case.php(35): include_once('/www...') #2 /www.bestbuildpc.org/admin.php(121): include_once('/www...') #3 {main} thrown in /www.bestbuildpc.org/modules/RN_Subscription/admin/private/RNS_Add_Sub.php on line 23
|
Code:<?php
/**
* @author Dawg and Guardian
* @copyright Dawg and Guardian
* @license Affero GPL {@link http://www.gnu.org/licenses/agpl.html}
* @package RN Subscription for RavenNuke
* @since February 2012
* @subpackage
* @todo
* @version 0.1
*/
if (!defined('RNS_ADMIN')) die();
global $prefix, $db, $module_name;
if(!isset($errmsg)) $errmsg = '';
OpenTable();
include_once 'modules/' . $module_name . '/admin/private/RNS_MainMenu.php';
CloseTable();
// intercept $_POST
if(isset($_POST['submit'])){
$uname = striptags($_POST['uname']);
$group = $_POST['group'];
$amount = intval($_POST['amount']);
$unit = strtolower($_POST['unit']);
// validate username
$result = $db->sql_query('SELECT `user_id` FROM `'.$prefix.'_users` WHERE `username` = \''.$uname.'\'');
if ($db->sql_numrows($result) > 0) {
$row = $db->sql_fetchrow($result);
$uid = $row['user_id'];
} else {
$errmsg = '<div class="error">'.RNS_A_NO_USER.'</div>';
$stop = 1;
}
// convert group name to guid
$query3 = 'SELECT `gid`, `gname` FROM `'.$prefix.'_nsngr_groups` WHERE `gname` = \''.$group.'\'';
$result3 = $db->sql_query($query3) or die(mysql_error());
$row3 = $db->sql_fetchrow($result3);
$gid = $row3['gid'];
// do the math bit for the end date
$edate = strtotime('+' . $amount . ' '.$unit.'', strtotime("now"));
$sdate = strtotime("now"); // start date
// make sure we are not in an error state before doing the SQL
if($stop !='1'){
$query2 = 'INSERT INTO `'.$prefix.'_nsngr_users` (`gid`, `uid`, `trial`, `notice`, `sdate`, `edate`)
VALUES (\''.$gid.'\', \''.$uid.'\', \'\', \'\', \''.$sdate.'\', \''.$edate.'\')';
$result2 = $db->sql_query($query2) or die('<div class="errore">A fatal MySQL error occured: Query: '.$query2.'</div>');
}
// paranoia
$_POST = ''; $uname = ''; $group = ''; $amount = ''; $unit = ''; $uid = '';
$edate = ''; $sdate = ''; $query2 = '';
}
// POST processing finished
// render the page
OpenTable();
echo '<div align="center">
<form method="post" action="admin.php?op=RNS_Add_Sub">
<fieldset><legend>'.RNS_A_ADD_SUBSCRIBER.'</legend>
<label for="uname">'.RNS_A_USERNAME.': </label><input type="text" name="uname" />
<label for="group">'.RNS_A_GROUP.': </label>
<select name="group">
<option>'.RNS_A_SELECT_GROUP.'</option>';
$query1 = 'SELECT `gid`, `gname` FROM `'.$prefix.'_nsngr_groups`';
$result1 = $db->sql_query($query1, $db) or die(mysql_error());
$numrows1 = $db->sql_numrows($result1);
for ($m = 0; $m < $numrows1; $m++) {
list ($gid, $gname) = $db->sql_fetchrow($result1);
echo '<option>'.$gname.'</option>';
}
echo '</select>';
echo '<label for="amount">'.RNS_A_AMOUNT.': </label>
<select name="amount">
<option>'.RNS_A_SELECT_AMOUNT.'</option>';
$i = 1;
while ($i < 32) {
echo '<option value="'.$i.'">'.$i.'</option>';
$i++;
}
echo '</select>';
echo '<label for="unit">'.RNS_A_UNIT.': </label>
<select name="unit">
<option>'.RNS_A_SELECT_TIME.'</option>
<option>'.RNS_A_DAY.'</option>
<option>'.RNS_A_WEEK.'</option>
<option>'.RNS_A_MONTH.'</option>
<option>'.RNS_A_YEAR.'</option>
</select>';
echo '<br />
<input type="hidden" name="op" value="RNS_Add_Sub" />
<input type="submit" class="button" name="submit" value="submit" />
</fieldset></form>
</div>';
CloseTable();
include_once 'footer.php';
|
Line 23
Code:
// intercept $_POST
if(isset($_POST['submit'])){
$uname = striptags($_POST['uname']);
$group = $_POST['group'];
$amount = intval($_POST['amount']);
$unit = strtolower($_POST['unit']);
// validate username
|
|
|
|
|
|
neralex
|
Posted:
Thu Nov 26, 2020 1:14 am |
|
Note: There is an typo in the function strip_tags() but this function is not a solid approach to filter the database-input. So try this please.
Find:
php Code:$uname = striptags($_POST['uname']);
|
Replace:
php Code:$uname = $db->sql_escape_string($_POST['uname']);
|
On this way you can find also this:
php Code:$group = $_POST['group'];
|
Replace:
php Code:$group = $db->sql_escape_string($_POST['group']);
|
|
|
|
|
|
hicuxunicorniobestbuildpc
|
Posted:
Thu Nov 26, 2020 5:02 pm |
|
Dank u
Now I get this error.
Notice: Undefined variable: stop in /www.bestbuildpc.org/modules/RN_Subscription/admin/private/RNS_Add_Sub.php on line 47
Code:// make sure we are not in an error state before doing the SQL
if($stop !='1'){
$query2 = 'INSERT INTO `'.$prefix.'_nsngr_users` (`gid`, `uid`, `trial`, `notice`, `sdate`, `edate`)
VALUES (\''.$gid.'\', \''.$uid.'\', \'\', \'\', \''.$sdate.'\', \''.$edate.'\')';
$result2 = $db->sql_query($query2) or die('<div class="errore">A fatal MySQL error occured: Query: '.$query2.'</div>');
}
// paranoia
$_POST = ''; $uname = ''; $group = ''; $amount = ''; $unit = ''; $uid = '';
$edate = ''; $sdate = ''; $query2 = '';
}
// POST processing finished
|
Line 47
I sent u pm. |
|
|
|
|
neralex
|
Posted:
Fri Nov 27, 2020 1:44 am |
|
Find:
php Code:if ($db->sql_numrows($result) > 0) {
$row = $db->sql_fetchrow($result);
$uid = $row['user_id'];
} else {
$errmsg = '<div class="error">'.RNS_A_NO_USER.'</div>';
$stop = 1;
}
|
Replace:
php Code:if ($db->sql_numrows($result) > 0) {
$row = $db->sql_fetchrow($result);
$uid = $row['user_id'];
$stop = 0; // added to prevent: Undefined variable: stop
} else {
$errmsg = '<div class="error">'.RNS_A_NO_USER.'</div>';
$stop = 1;
}
|
|
|
|
|
|
hicuxunicorniobestbuildpc
|
Posted:
Fri Nov 27, 2020 6:14 am |
|
That helped a lot but new one came out.
Code: Undefined variable: errmsg in /www.bestbuildpc.org/home/modules/RN_Subscription/admin/private/RNS_Edit_Sub.php on line 57
Notice: Use of undefined constant RNA_A_MOD_SUBSCRIPTION_PERIOD - assumed 'RNA_A_MOD_SUBSCRIPTION_PERIOD' in /www.bestbuildpc.org/modules/RN_Subscription/admin/private/RNS_Edit_Sub.php on line 147
Edit Users data for Moderators Group
RNA_A_MOD_SUBSCRIPTION_PERIOD
|
Why do I get Undefined variable all the time? I never see this before.
Code:Notice: Use of undefined constant RNS_A_GEN_ERRORE - assumed 'RNS_A_GEN_ERRORE' in /www.bestbuildpc.org/modules/RN_Subscription/admin/private/RNS_Subscription_Add.php on line 295
Notice: Undefined index: rn_sub_sandbox_enabled in /www.bestbuildpc.org/modules/RN_Subscription/admin/private/RNS_Subscription_Add.php on line 48
Notice: Undefined index: rn_sub_trial_enabled in /www.bestbuildpc.org/modules/RN_Subscription/admin/private/RNS_Subscription_Add.php on line 55
|
|
|
|
|
|
neralex
|
Posted:
Fri Nov 27, 2020 8:42 am |
|
hicuxunicorniobestbuildpc wrote: | That helped a lot but new one came out. |
There is no way to help without to see the current state of the file. Just post it, tagged as PHP-code. I don't have the time to debug the whole module, so you have to feed me with crumbs.
hicuxunicorniobestbuildpc wrote: | Why do I get Undefined variable all the time? I never see this before. |
This is a normal bevehaviour in php7, when variables, constants or array-indexes are undefined. The constants are language-definitions, which the script can not find. Probably the language-files isn't included in the case.php or the language-definitions are not exist in your used language-*.php. |
|
|
|
|
hicuxunicorniobestbuildpc
|
Posted:
Fri Nov 27, 2020 9:09 pm |
|
Notice: Undefined variable: errmsg in /www.bestbuildpc.org/modules/RN_Subscription/admin/private/RNS_Edit_Sub.php on line 57
Code:line 57
if ($errmsg) {
|
Code:// DISPLAY the FORM
OpenTable();
include_once 'modules/' . $module_name . '/admin/private/RNS_MainMenu.php';
include_once 'modules/' . $module_name . '/admin/private/RNS_MenuGroups.php';
CloseTable();
// do error msg and die
if ($errmsg) {
OpenTable();
echo '<div class="error">'.$errmsg.'</div>';
CloseTable();
}
|
Code:Notice: Use of undefined constant RNA_A_MOD_SUBSCRIPTION_PERIOD - assumed 'RNA_A_MOD_SUBSCRIPTION_PERIOD' in /www.bestbuildpc.org/modules/RN_Subscription/admin/private/RNS_Edit_Sub.php on line 147
Edit Users data for Moderators Group
RNA_A_MOD_SUBSCRIPTION_PERIOD
|
|
|
|
|
|
neralex
|
Posted:
Sat Nov 28, 2020 2:13 am |
|
There is no way to help without to see the current state of the file. Just post it, tagged as PHP-code. |
|
|
|
|
hicuxunicorniobestbuildpc
|
Posted:
Sat Nov 28, 2020 5:23 am |
|
Code:<?php
if (!defined('RNS_ADMIN')) die();
global $admin, $bgcolor2, $prefix, $db, $module_name;
// check for incoming userid
if (isset($uid)) {
$uid = intval($uid);
} else {
$errmsg = 'No User id passed or user id invalid';
}
// do POST processing
if(isset($_POST['Submit']) && $_POST['edit'] == 'edit') {
$gid = intval($_POST['gid']);
$uid = intval($_POST['uid']);
$enddate = $_POST['enddate'];
$add_sub = $_POST['add_sub'];
// convert $add_sub for calculation
if($add_sub == 'Add') {
$add_sub = '+';
} else {
$add_sub = '-';
}
$amount = intval($_POST['amount']);
// convert $unit to lowercase for strtotime
$unit = strtolower($_POST['unit']);
$updatedDate = CalculateChange($add_sub, $amount, $unit);
$query = 'UPDATE `'.$prefix.'_nsngr_users` SET edate =\''.$updatedDate.'\' WHERE gid=\''.$gid.'\' AND uid=\''.$uid.'\'';
$result = $db->sql_query($query) or die(mysql_error());
//$displayDate = date('Y-m-j', $updatedDate);
// paranoia and make sure everything except uid is clear for the form
$_POST = ''; $gid = ''; $enddate = ''; $add_sub = ''; $amount = ''; $unit = '';
$updatedDate = ''; $query = ''; $result = '';
}
// DISPLAY the FORM
OpenTable();
include_once 'modules/' . $module_name . '/admin/private/RNS_MainMenu.php';
include_once 'modules/' . $module_name . '/admin/private/RNS_MenuGroups.php';
CloseTable();
// do error msg and die
if ($errmsg) {
OpenTable();
echo '<div class="error">'.$errmsg.'</div>';
CloseTable();
}
// get the users info - pretty sure we don't need all this info but hey-ho
$query1 = 'SELECT `user_id`, `name`, `username`, `user_email`, `user_avatar`,
`user_regdate`, `user_active`, `user_lastvisit`, `last_ip`, `lastsitevisit`
FROM `'.$prefix.'_users`
WHERE user_id = \''.$uid.'\'';
$result1 = $db->sql_query($query1) or die(mysql_error());
$row1 = $db->sql_fetchrow($result1);
$user_id = $row1['user_id'];
$name = $row1['name'];
$username = $row1['username'];
$user_email = $row1['user_email'];
$user_avatar = $row1['user_avatar'];
$user_regdate = $row1['user_regdate'];
$user_active = $row1['user_active'];
$user_lastvisit = $row1['user_lastvisit'];
$last_ip = $row1['last_ip'];
$lastsitevisit = $row1['lastsitevisit'];
$lv = date('m-d-Y', $user_lastvisit);
OpenTable();
echo '<div align="center"><h2>' . RNS_A_EDIT_SUBSCRIBER . '</h2></div>
<table style="width:100%;">
<tr>
<td style="width:45%; text-align:right;">'.RNS_A_USERNAME.': <span class="title">'.$username.'</span><br />
'.RNS_A_REG_SINCE.': '.$user_regdate.'<br />
'.RNS_A_LAST_VISIT.': ' . $lv . '<br />
'.RNS_A_IP.': ' . $last_ip . '<br />
<a href="mailto:' . $user_email . ';">'.RNS_A_SEND_MAIL.'</a><br />
</td>
<td style="width:45%;">';
// only display avatart if it exists!!
if(file_exists('modules/Forums/images/avatars/'.$user_avatar.'')){
echo '<img src="/modules/Forums/images/avatars/'.$user_avatar.'" alt="avatar" />';
}
echo '</td>';
echo '</table>';
echo '<hr class="sub" width="100%" />';
$query2 = 'SELECT `gid`, `uid`, `trial`, `notice`, `sdate`, `edate`
FROM `'.$prefix.'_nsngr_users`
WHERE uid = \''.$uid.'\'';
$result2 = $db->sql_query($query2) or die(mysql_error());
$numrows2 = $db->sql_numrows($result2);
if ($db->sql_numrows($result2) > 0) {
for ($m = 0; $m < $numrows2; $m++) {
list ($gid, $uid, $trial, $notice, $sdate, $edate) = $db->sql_fetchrow($result2);
{
$query3 = 'SELECT `gid`, `gname`, `gdesc`, `gpublic`, `glimit`, `phpBB`, `muid`
FROM `'.$prefix.'_nsngr_groups`
WHERE gid = \''.$gid.'\'';
$result3 = $db->sql_query($query3) or die(mysql_error());
list ($gid, $gname, $gdesc, $gpublic, $glimit, $phpBB, $muid) = $db->sql_fetchrow($result3);
{
echo '<table width="80%" border="0" align="center">
<tr>
<td width="33%"> </td>
<td width="33%"><div align="center"><span class="subscription10">'.RNS_A_GROUP.': ' . $gname . '</span></div>
<table width="100%" border="0" align="center">
<tr>';
////I Know this sucks but it is the only way I could get the math right...
//This one for math
$startdate = date('Y-m-j', $sdate);
///This one for display
$sdate2 = date('m-j-Y', $sdate);
echo '<td width="50%"><div align="center"><span class="title">'.RNS_A_STARTDATE.'<br />' . $sdate2 . '</span></div></td>';
//This one for math
$enddate = date('Y-m-j', $edate);
///This one for display
$edate2 = date('m-j-Y', $edate);
////////////////////////////////
echo '<td width="50%"><div align="center"><span class="title">'.RNS_A_ENDDATE.'<br />' . $edate2 . '</span></div></td>
</tr>
</table>';
// render the form
echo '<div align="center">
<form name="edit" method="post" action="admin.php?op=RNS_Edit_Sub&' . $uid . '">
<fieldset><legend>'.RNS_A_EDIT_USERDATE.' '.$gname.' '.RNS_A_GROUP.'</legend>
<input name="edit" type="hidden" value="edit" />
<input name="gid" type="hidden" value="' . $gid . '" />
<input name="uid" type="hidden" value="' . $uid . '" />
<input name="enddate" type="hidden" value="' . $enddate . '" />
<label for="add_sub">'.RNA_A_MOD_SUBSCRIPTION_PERIOD.'</label>
<select name="add_sub">
<option>+/-</option>
<option>Add</option>
<option>Substract</option>
</select>
<label for="amount">'.RNS_A_AMOUNT.' </label>
<select name="amount">
<option>'.RNS_A_SELECT_AMOUNT.'</option>';
$i = 1;
while ($i < 32) {
echo '<option value="' . $i . '">' . $i . '</option>';
$i++;
}
echo '</select>';
echo '<br /><label for="unit">'.RNS_A_UNIT.' </label>
<select name="unit">
<option>'.RNS_A_SELECT_TIME.'</option>
<option>'.RNS_A_DAY.'</option>
<option>'.RNS_A_WEEK.'</option>
<option>'.RNS_A_MONTH.'</option>
<option>'.RNS_A_YEAR.'</option>
</select>
<input type="submit" class="button" name="Submit" value="Submit" />
</fieldset>
</form>
</div>
<hr class="sub" width="100%" />
</td>
<td width="33%"> </td>
</tr>
</table>';
}
}
}
}
CloseTable();
include_once 'footer.php';
// functions only
function CalculateChange($add_sub, $amount, $unit) {
$newdate = strtotime(''.$add_sub.' ' . $amount . ' '.$unit.'', strtotime($enddate));
return $newdate;
}
|
|
|
|
|
|
neralex
|
Posted:
Sat Nov 28, 2020 8:21 am |
|
Find:
php Code:f (!defined('RNS_ADMIN')) die();
|
Add after:
php Code:if(!isset($errmsg)) $errmsg = '';
|
Open the admin language-*.php files of this module and try to find: "RNA_A_MOD_SUBSCRIPTION_PERIOD". Exists this constant in the file of your used language? |
|
|
|
|
hicuxunicorniobestbuildpc
|
Posted:
Sat Nov 28, 2020 5:50 pm |
|
Yes this one is there.
Code:define('RNS_A_MOD_SUBSCRIPTION_PERIOD','Modify Subscription period');
|
but I am still getting this error
Code:Notice: Use of undefined constant RNA_A_MOD_SUBSCRIPTION_PERIOD - assumed 'RNA_A_MOD_SUBSCRIPTION_PERIOD' in /www.bestbuildpc.org/modules/RN_Subscription/admin/private/RNS_Edit_Sub.php on line 147
Edit Users data for Moderators Group
RNA_A_MOD_SUBSCRIPTION_PERIOD
|
|
|
|
|
|
hicuxunicorniobestbuildpc
|
Posted:
Sat Nov 28, 2020 5:59 pm |
|
Now when I add a subscription I get a bunch of errors
Notice: Use of undefined constant RNS_A_GEN_ERRORE - assumed 'RNS_A_GEN_ERRORE' in /www.bestbuildpc.org/modules/RN_Subscription/admin/private/RNS_Subscription_Add.php on line 295
Notice: Undefined index: rn_sub_plan_enabled in /www.bestbuildpc.org/modules/RN_Subscription/admin/private/RNS_Subscription_Add.php on line 41
Notice: Undefined index: rn_sub_sandbox_enabled in /www.bestbuildpc.org/modules/RN_Subscription/admin/private/RNS_Subscription_Add.php on line 48
Code:<?php
if (!defined('RNS_ADMIN')) die();
global $prefix, $db, $rn_sub_description, $rn_sub_trial_enabled, $rn_sub_group, $rn_sub_sandbox_enabled, $rn_sub_price, $rn_sub_sandbox_enabled, $rn_sub_plan_enabled, $module_name;
if(!isset($errmsg)) $errmsg = '';
$stop = 0;
global $stop, $errmsg, $rn_sub_name;
OpenTable();
include_once 'modules/'.$module_name.'/admin/private/RNS_MainMenu.php';
if(isset($_POST['submit']) && $_POST['submit'] == 'submit'){
$rn_sub_name = check_required($_POST['rn_sub_name'], ''.RNS_A_MISSING_SUB_NAME.'');
if(SubPlanExists($rn_sub_name)) $errmsg .= '<div class="warning">'.RNS_A_GROUP_NAME.' '.$rn_sub_name . ' '.RNS_A_EXISTS.'</div>';
$rn_sub_description = check_required($_POST['rn_sub_description'], ''.RNS_A_MISSING_DESC.'');
check_required($_FILES['file']['name'], ''.RNS_A_MISSING_IMAGE.'' );
$rn_sub_price = check_required($_POST['rn_sub_price'], ''.RNS_A_MISSING_PRICE.'');
if($_POST['rn_sub_group'] == 'Select Group') $_POST['rn_sub_group'] = '';
$rn_sub_group = check_required($_POST['rn_sub_group'], ''.RNS_A_MISSING_GROUP.'');
if($_POST['rn_sub_amount'] == 'Select Amount') $_POST['rn_sub_amount'] = '';
$rn_sub_amount = check_required($_POST['rn_sub_amount'],''.RNS_A_MISSING_AMOUNT.''); intval($rn_sub_amount);
if($_POST['rn_sub_unit'] == 'Select Time') $_POST['rn_sub_unit'] = '';
$rn_sub_unit = check_required($_POST['rn_sub_unit'], ''.RNS_A_MISSING_UNIT.''); // Week
$rn_sub_weight = check_required(intval($_POST['rn_sub_weight']), ''.RNS_A_MISSING_WEIGHT.''); //[rn_sub_weight] => 1
$rn_sub_payment_email = check_required($_POST['rn_sub_payment_email'], ''.RNS_A_MISSING_PP.'');
$rn_sub_notify_email = check_required($_POST['rn_sub_notify_email'], ''.RNS_A_MISSING_NOTE_MAIL.'');
// checkbox test - convert human readable to logic
if($_POST['rn_sub_plan_enabled'] == 'on') {
$rn_sub_plan_enabled = 1;
} else {
$rn_sub_plan_enabled = 0;
}
// checkbox test
if($_POST['rn_sub_sandbox_enabled'] == 'on') {
$rn_sub_sandox_enabled = 1;
} else {
$rn_sub_sandox_enabled = 0;
}
// checkbox test
if($_POST['rn_sub_trial_enabled'] == 'on'){
$rn_sub_trial_enabled = 1;
} else {
$rn_sub_trial_enabled = 0;
}
// checkbox test and reset trial data if not enabled
if($rn_sub_trial_enabled == '1') {
if($_POST['rn_sub_trial_unit'] == 'Select Trial Time') $_POST['rn_sub_trial_unit'] = '';
$rn_sub_trial_unit = check_required($_POST['rn_sub_trial_unit'],''.RNS_A_MISSING_TRIAL_DUR.'');
$rn_sub_trial_amount = check_required(intval($_POST['rn_sub_trial_amount']),''.RNS_A_MISSING_TRIAL_AMOUNT.'');
} else {
$rn_sub_trial_unit = 0;
$rn_sub_trial_amount = 0;
}
// http://www.9lessons.info/2009/03/upload-and-resize-image-with-php.html
// image upload handling
// set maximum file size
$img_err = 0;
define('MAX_IMAGE_SIZE','50000'); //500k
$saved_image = mt_rand(); // just to give the saved image a random filename
$image = $_FILES['file']['name'];
$uploadedfile = $_FILES['file']['tmp_name'];
if ($image){
$filename = stripslashes($_FILES['file']['name']);
$extension = getExtension($filename);
$extension = strtolower($extension); // force extension into lowercase
// check for correct extensions
if(($extension != 'jpg') && ($extension != 'jpeg')
&& ($extension != 'png') && ($extension != 'gif')){
$errmsg .= '<div class="validation">'.RNS_A_UNKNOWN_EXT.'</div>';
$img_err = 1;
}
// check for exceeded max file size
$size = filesize($_FILES['file']['tmp_name']);
if ($size > MAX_IMAGE_SIZE*1024){
$errmsg .= '<div class="warning">'.RNS_A_FILE_SIZE_EXCEEDED.'</div>';
$img_err = 1;
}
if($extension == 'jpg' || $extension =='jpeg' ){
$uploadedfile = $_FILES['file']['tmp_name'];
$src = imagecreatefromjpeg($uploadedfile);
}
else if($extension == 'png'){
$uploadedfile = $_FILES['file']['tmp_name'];
$src = imagecreatefrompng($uploadedfile);
} else {
$src = imagecreatefromgif($uploadedfile);
}
// if we have errors, halt everything
if($img_err =='0') {
list($width,$height) = getimagesize($uploadedfile);
$newwidth = 200;
$newheight = ($height/$width)*$newwidth;
$tmp = imagecreatetruecolor($newwidth,$newheight);
imagecopyresampled($tmp, $src, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
//$filename = 'modules/'.$module_name.'/images/plan_img/'.$_FILES['file']['name'].'';
$filename = 'modules/'.$module_name.'/images/plan_img/'.$saved_image.'.'.$extension.'';
$rn_sub_img = $filename;
imagejpeg($tmp, $filename, 200);
imagedestroy($src);
imagedestroy($tmp);
} else {
echo $errmsg;
$stop = 1;
}
}
// we are using $stop to determine if a DN insert is needed
// proceed to do the DB stuff
if($stop == '0'){
$query2 = 'INSERT INTO `'.$prefix.'_rn_subscription` (`rn_sub_name`, `rn_sub_description`, `rn_sub_img`,
`rn_sub_price`, `rn_sub_group`, `rn_sub_amount`, `rn_sub_unit`, `rn_sub_weight`, `rn_sub_payment_email`,
`rn_sub_notify_email`, `rn_sub_plan_enable`, `rn_sub_sandbox_enabled`, `rn_sub_trial_enabled`,
`rn_sub_trial_unit`, `rn_sub_trial_amount` )
VALUES (\''.$rn_sub_name.'\', \''.$rn_sub_description.'\', \''.$rn_sub_img.'\', \''.$rn_sub_price.'\',
\''.$rn_sub_group.'\', \''.$rn_sub_amount.'\', \''.$rn_sub_unit.'\', \''.$rn_sub_weight.'\',
\''.$rn_sub_payment_email.'\', \''.$rn_sub_notify_email.'\', \''.$rn_sub_plan_enabled.'\',
\''.$rn_sub_sandbox_enabled.'\', \''.$rn_sub_trial_enabled.'\', \''.$rn_sub_trial_unit.'\',
\''.$rn_sub_trial_amount.'\')';
$result2 = $db->sql_query($query2) or die('<div class="error"><strong>A fatal MySQL error occured</strong> Query: '.$query2.'</div>');
// paranoia - just in case we have an admin with an itchy trigger finger
// we clear everything so the form is blank and the query is empty
$rn_sub_name = ''; $rn_sub_description = ''; $rn_sub_img = ''; $rn_sub_price = ''; $rn_sub_group = '';
$rn_sub_amount = ''; $rn_sub_unit = ''; $rn_sub_weight = ''; $rn_sub_payment_email = ''; $rn_sub_notify_email = '';
$rn_sub_plan_enabled = ''; $rn_sub_sandbox_enabled = ''; $rn_sub_trial_enabled = ''; $rn_sub_trial_unit = '';
$rn_sub_trial_amount = ''; $_POST = ''; $query2 = '';
echo '<div class="success">'.RNS_A_PLAN_CREATED.'</div>';
CloseTable();
include_once 'footer.php';
die();
} else {
echo '<div class="warning">'.RNS_A_GEN_ERROR.'</div>';
}
}
/// RENDER THE FORM
// since we don't have any styling in the stylesheet for forms, I'm hard coding it
echo '<div>
<form method="post" action="admin.php?op=RNS_Subscription_Add" enctype="multipart/form-data">
<fieldset><legend><span class="subscription_heading">'.RNS_A_ADD_PLAN.'</span></legend>
<label style="width:170px; display:block; float:left;" for="rn_sub_name">'.RNS_A_SUBSCRIPTION_NAME.'</label>
<input type="text" name="rn_sub_name" value="'.$rn_sub_name.'" size="50" /><br />
<label style="width:170px; display:block; float:left;" for="rn_sub_descrption">'.RNS_A_SUBSCRIPTION_DESC.'</label>
<input type="text" size="50" name="rn_sub_description" value="'.$rn_sub_description.'" /><br />
<label style="width:170px; display:block; float:left;" for="image">'.RNS_A_PLAN_IMAGE.'</label>
<input type="file" name="file" id="file" /> 200w x 100h<br />
<label style="width:170px; display:block; float:left;" for="rn_sub_price">'.RNS_A_PRICE.'</label>
<input type="text" name="rn_sub_price" value="'.$rn_sub_price.'" /> ie: 19.99<br />
<label style="width:170px; display:block; float:left;" for="rn_sub_group">'.RNS_A_SELECT_GROUP.'</label>
<select name="rn_sub_group">';
if($rn_sub_group =='') {
echo '<option>'.RNS_A_SELECT_GROUP.'</option>';
} else {
echo '<option>'.$rn_sub_group.'</option>';
}
$query1 = 'SELECT `gid`, `gname` FROM `'.$prefix.'_nsngr_groups`';
$result1 = $db->sql_query($query1, $db) or die(mysql_error());
$numrows1 = $db->sql_numrows($result1);
for ($m = 0; $m < $numrows1; $m++) {
list ($gid, $gname) = $db->sql_fetchrow($result1);
echo '<option>'.$gname.'</option>';
}
echo '</select>
<br />
<label style="width:170px; display:block; float:left;" for="rn_sub_amount">'.RNS_A_SELECT_AMOUNT.'</label>
<select name="rn_sub_amount">';
if($rn_sub_amount == '') {
echo '<option>'.RNS_A_SELECT_AMOUNT.'</option>';
} else {
echo '<option>'.$rn_sub_amount.'</option>';
}
$i = 1;
while ($i < 32) {
echo '<option value="'.$i.'">'.$i.'</option>';
$i++;
}
echo '</select><br />
<label style="width:170px; display:block; float:left;" for="rn_sub_unit">'.RNS_A_SELECT_TIME.'</label>
<select name="rn_sub_unit">';
if($rn_sub_unit == ''){
echo '<option>'.RNS_A_SELECT_TIME.'</option>';
} else {
echo '<option>'.$rn_sub_unit.'</option>';
}
echo '<option>'.RNS_A_DAY.'</option>
<option>'.RNS_A_WEEK.'</option>
<option>'.RNS_A_MONTH.'</option>
<option>'.RNS_A_YEAR.'</option>
</select>
<br />
<label style="width:170px; display:block; float:left;" for="rn_sub_weight">'.RNS_A_SUBSCRIPTION_WEIGHT.'</label>
<input type="text" name="rn_sub_weight" value="'.$rn_sub_weight.'" /> '.RNS_A_ORDER.'<br />
<label style="width:170px; display:block; float:left;" for="rrn_sub_payment_email">'.RNS_A_PP_EMAIL.'</label>
<input type="text" name="rn_sub_payment_email" size="50" value="'.$rn_sub_payment_email.'" /><br />
<label style="width:170px; display:block; float:left;" for="rn_sub_notify_email">'.RNS_A_NOTIGY_EMAIL.'</label>
<input type="text" name="rn_sub_notify_email" size="50" value="'.$rn_sub_notify_email.'" /><br />
<br />
<label style="width:150px; display:block; float:left;" for="rn_sub_plan_enable">'.RNS_A_PLAN.' '.RNS_A_ENABLED.'</label>';
if($rn_sub_plan_enabled == '1') {
echo '<input type="checkbox" name="rn_sub_plan_enabled" checked="checked" />';
} else {
echo '<input type="checkbox" name="rn_sub_plan_enabled" />';
}
echo '<br />
<label style="width:150px; display:block; float:left;" for="rn_sub_sandbox_enabled">'.RNS_A_SANDBOX.' '.RNS_A_ENABLED.'</label>';
if($rn_sub_sandbox_enabled == '1') {
echo '<input type="checkbox" name="rn_sub_sandbox_enabled" checked="checked" />';
} else {
echo '<input type="checkbox" name="rn_sub_sandbox_enabled" />';
}
echo '<br /><br />
<p>
<label style="width:150px; display:block; float:left;" for="rn_sub_trial_enabled">'.RNS_A_TRIAL.' '.RNS_A_ENABLED.'</label>';
if($rn_sub_trial_enabled == '1') {
echo '<input type="checkbox" name="rn_sub_trial_enabled" checked="checked" />';
} else {
echo '<input type="checkbox" name="rn_sub_trial_enabled" />';
}
echo '<label for="rn_sub_trial_unit">'.RNS_A_SELECT_TRIAL_DURATION.'</label>
<select name="rn_sub_trial_unit">
<option>'.RNS_A_SELECT_TRIAL_DURATION.'</option>
<option>'.RNS_A_DAY.'</option>
<option>'.RNS_A_WEEK.'</option>
<option>'.RNS_A_MONTH.'</option>
<option>'.RNS_A_YEAR.'</option>
</select>
<label for="rn_sub_trial_amount">'.RNS_A_SELECT_AMOUNT.'</label>
<select name="rn_sub_trial_amount">
<option>'.RNS_A_SELECT_AMOUNT.'</option>';
$i = 1;
while ($i < 32) {
echo '<option value="'.$i.'">'.$i.'</option>';
$i++;
}
echo '</select></p>';
echo '<input type="hidden" name="op" value="RNS_Subscription_Add" />
<p><input type="submit" name="submit" class="button" value="submit" /></p>
</fieldset>
</form>
</div>';
CloseTable();
include_once 'footer.php';
/////////////////////
//functions only
/**
*
* @global int $stop
* @param string $data
* @param string $problem
* @return string - error message
*/
function check_required($data, $problem=''){
global $stop;
$data = htmlspecialchars($data);
if ($problem && strlen($data) == 0){
show_error($problem);
$stop = 1;
}
return $data;
}
/**
*
* @param string $errmsg
*/
function show_error($errmsg){
echo '<div class="error"><strong>'.RNS_A_GEN_ERRORE.':</strong> - <span class="title">'.$errmsg.'</span></div>';
//exit();
}
/**
*
* @param string $str
* @return string
*/
function getExtension($str){
$i = strrpos($str,".");
if(!$i){
return '';
}
$l = strlen($str) - $i;
$ext = substr($str,$i+1,$l);
return $ext;
}
/**
*
* @global method $db
* @global string $prefix
* @param string $rn_sub_name
* @return bool
*/
function SubPlanExists($rn_sub_name){
global $db, $prefix;
$result = $db->sql_query('SELECT `rn_sub_name` FROM `'.$prefix.'_rn_subscription` WHERE rn_sub_name = \''.$rn_sub_name.'\'');
if ($db->sql_numrows($result) > 0){
$stop = 1;
return true;
}
}
|
|
|
|
|
|
neralex
|
Posted:
Sun Nov 29, 2020 2:43 am |
|
hicuxunicorniobestbuildpc wrote: | Yes this one is there.
Code:define('RNS_A_MOD_SUBSCRIPTION_PERIOD','Modify Subscription period');
| |
Nope, please open your eyes and re-check the error message. There is an typo...
hicuxunicorniobestbuildpc wrote: | Code:Notice: Use of undefined constant RNA_A_MOD_SUBSCRIPTION_PERIOD - assumed 'RNA_A_MOD_SUBSCRIPTION_PERIOD' in /www.bestbuildpc.org/modules/RN_Subscription/admin/private/RNS_Edit_Sub.php on line 147
Edit Users data for Moderators Group
RNA_A_MOD_SUBSCRIPTION_PERIOD
| |
|
|
|
|
|
neralex
|
Posted:
Sun Nov 29, 2020 2:46 am |
|
hicuxunicorniobestbuildpc wrote: | Now when I add a subscription I get a bunch of errors
Notice: Use of undefined constant RNS_A_GEN_ERRORE - assumed 'RNS_A_GEN_ERRORE' in /www.bestbuildpc.org/modules/RN_Subscription/admin/private/RNS_Subscription_Add.php on line 295
Notice: Undefined index: rn_sub_plan_enabled in /www.bestbuildpc.org/modules/RN_Subscription/admin/private/RNS_Subscription_Add.php on line 41
Notice: Undefined index: rn_sub_sandbox_enabled in /www.bestbuildpc.org/modules/RN_Subscription/admin/private/RNS_Subscription_Add.php on line 48 |
Same here, re-check the error-message with the language-constant and fix the typos in the related module/admin files. |
|
|
|
|
hicuxunicorniobestbuildpc
|
Posted:
Sun Nov 29, 2020 5:51 pm |
|
I guess I am blind because I don't see the error. |
|
|
|
|
neralex
|
Posted:
Mon Nov 30, 2020 12:53 pm |
|
You posted it already and I quoted both together in a single-post. Compare the error-messages with the codelines from your language-*.php ... small simple typos - easy to fix |
|
|
|
|
hicuxunicorniobestbuildpc
|
Posted:
Mon Nov 30, 2020 5:18 pm |
|
Do you mean this
Code:function show_error($errmsg){
echo '<div class="error"><strong>' . RNS_A_GEN_ERRORE . ':</strong> - <span class="title">' . $errmsg .'</span></div>';
//exit();
}
|
replace with
Code:
function show_error($errmsg){
if(!isset($errmsg)) $errmsg = '';
echo '<div class="error"><strong>' . RNS_A_GEN_ERRORE . ':</strong> - <span class="title">' . $errmsg .'</span></div>';
//exit();
|
|
|
|
|
|
neralex
|
Posted:
Tue Dec 01, 2020 1:47 pm |
|
Nope! I mean this...
Code:Notice: Use of undefined constant RNA_A_MOD_SUBSCRIPTION_PERIOD - assumed 'RNA_A_MOD_SUBSCRIPTION_PERIOD'
Notice: Use of undefined constant RNS_A_GEN_ERRORE - assumed 'RNS_A_GEN_ERRORE'
|
and this is not correct:
php Code:function show_error($errmsg){
if(!isset($errmsg)) $errmsg = ''; // wrong placed
echo '<div class="error"><strong>' . RNS_A_GEN_ERRORE . ':</strong> - <span class="title">' . $errmsg .'</span></div>';
//exit();
|
Check this: [ Only registered users can see links on this board! Get registered or login! ] |
|
|
|
|
hicuxunicorniobestbuildpc
|
Posted:
Tue Dec 01, 2020 4:21 pm |
|
No No
I did this
Code:f (!defined('RNS_ADMIN')) die();
if(!isset($errmsg)) $errmsg = '';
|
but the error is showing again. |
|
|
|
|
neralex
|
Posted:
Wed Dec 02, 2020 12:55 am |
|
The info about the $errmsg was a side-note, it's not related to the undefined constants. You make a mess of everything yourself. Please check the error-message of the undefined constant and compare it with the constants in your language-files... |
|
|
|
|
hicuxunicorniobestbuildpc
|
Posted:
Thu Dec 03, 2020 4:14 pm |
|
I found it.
Search for
Code:define('RNS_A_GEN_ERROR','There are some errors that need fixing');
|
Replace with
Code:define('RNS_A_GEN_ERRORE','There are some errors that need fixing');
|
I was looking for something more difficult but it was a piece of cake.
Thanks for not telling me neralex. U are right. Dank u
another one
Code:define('RNA_A_MOD_SUBSCRIPTION_PERIOD','Modify Subscription period');
|
replace with
Code:define('RNS_A_MOD_SUBSCRIPTION_PERIOD','Modify Subscription period');
|
I can't believe my eyes!!! |
|
|
|
|
|