Bravo List

Bravo List (http://www.bvlist.com/index.php)
-   Mods & Themes (http://www.bvlist.com/forumdisplay.php?f=109)
-   -   09 dynamic rules page mod (http://www.bvlist.com/showthread.php?t=10751)

CAGADA 22nd February 2016 18:50

09 dynamic rules page mod
 
1 Attachment(s)
hello , anyone have this complet mod ( dynamic rules page mod) ? For tbdev 2009? Our staff edit rules ?!

pls,Thanks ✌

DND 22nd February 2016 19:11

for tbdev09 ? what source are you using? and what is the problem ?
post error log or something.. errors will tell you what is the problem and how to fix it.

CAGADA 22nd February 2016 22:00

1 Attachment(s)
Quote:

Originally Posted by DND (Post 48512)
for tbdev09 ? what source are you using? and what is the problem ?
post error log or something.. errors will tell you what is the problem and how to fix it.



use TBdev 2009 final

It does not appear error. the code works, only that when I edit or delete the rules does not work.

admin/rules.php
Code:


/* Bigjoos, CoLdFuSiOn */

if ( ! defined( 'IN_TBDEV_ADMIN' ) )
{
    print "

Incorrect access

You cannot access this file directly.";
    exit();
}
require_once "include/user_functions.php";

    $lang = array_merge( $lang, load_language('ad_rules') );
   
    $params = array_merge( $_GET, $_POST );
   
    $params['mode'] = isset($params['mode']) ? $params['mode'] : '';
   
    switch($params['mode'])
    {
     
      case 'cat_new':
        New_Cat_Form();
        break;
     
      case 'cat_add':
        Do_Cat_Add();
        break;
       
      case 'cat_edit':
        Show_Cat_Edit_Form();
        break;
         
      case 'takeedit_cat':
        Do_Cat_Update();
        break;
       
      case 'cat_delete':
        Cat_Delete();
        break;
       
      case 'cat_delete_chk':
        Cat_Delete(true);
        break;
     
      case 'rules_new':
        New_Rules_Form();
        break;
       
      case 'rules_edit':
        Show_Rules_Edit();
        break;
     
      case 'takeedit_rules':
        Do_Rules_Update();
        break;
     
      case 'takeadd_rules':
        Do_Rules_Add();
        break;
       
      case 'rules_delete':
        Do_Rules_Delete();
        break;

      default:
        Do_show();
        break;
    }



function Do_show() {
  global $TBDEV, $lang;
 
  $sql = mysql_query("SELECT * FROM rules_categories") or die("Ooops");

  if ( !mysql_num_rows($sql) )
    stderr("ERROR", "There Are No Categories.
      Add Category");

  $htmlout = '';

  $htmlout .= "
                   

                       

                            {$lang['rules_cat_title']}
                           

                                {$lang['rules_btn_newcat']} 
                                {$lang['rules_btn_newrule']}
                           

                       

                       

                            ";
 
  while ($arr = mysql_fetch_assoc($sql))
  {
    $htmlout .= "
     
       
       
       
       
       
      ";
  }
 

  $htmlout .= "
{$arr['cid']}{$arr['rcat_name']}{$arr['min_class_read']}{$lang['rules_edit']}{$lang['rules_delete']}

                         

                   
";

  //$htmlout .= New_Cat_Form();

  //$htmlout .= New_rules_form();



  print stdhead("{$lang['rules_rules']}") . $htmlout . stdfoot();
  exit();
}

// ===added delete
function Do_Rules_Delete()
{
    if( !isset($_POST['fdata']) OR !is_array($_POST['fdata']) )
      stderr("Error", "Bad data!");
   
    $id = array();
   
    foreach( $_POST['fdata'] as $k => $v )
    {
      if( isset($v['rules_id']) AND !empty($v['rules_id']) )
      {
        $id[] = intval($v['rules_id']);
      }
    }
   
    if( !count($id) )
      stderr("Error", "No rules selected!");
   
    mysql_query("DELETE FROM rules WHERE id IN( ".implode(',', $id)." )") or stderr("SQL Error", "OOps!");
   
    stderr("Info", "Rules successfully Deleted! Go Back To Rules Admin?");
}
// ====end


function Cat_Delete($chk=false)
{
    $id = isset($_GET['catid']) ? (int)$_GET['catid'] : 0;
   
    if (!is_valid_id($id))
        stderr("Error", "Bad ID!");
   
    if( !$chk )
    {
      stderr("Sanity Check!", "You're about to delete a rules category, this will delete ALL content within that category!
      CONTINUE
      or CANCEL");
    }
   
    @mysql_query("DELETE FROM rules WHERE id = $id") or stderr("SQL Error", "1OOps!");
    @mysql_query("DELETE FROM rules_categories WHERE cid = $id") or stderr("SQL Error", "2OOps!");
    stderr("Info", "Rules category deleted successfully! Go Back To Rules Admin?");
   
}

function Show_Cat_Edit_Form()
{
   
    global $lang, $CURUSER;
   
    $htmlout='';
   
    $maxclass = $CURUSER['class'];

    if (!isset($_GET['catid']) || empty($_GET['catid']) || !is_valid_id($_GET['catid']))
    $htmlout .= Do_Error("Error", "No Section selected");

    $cat_id = (int)$_GET['catid'];

    $sql = mysql_query("SELECT * FROM rules_categories WHERE cid = {$cat_id}") or stderr("SQL Error", "OOps!");

    if (!mysql_num_rows($sql))
        stderr("SQL Error", "Nothing doing here!");
       
    while ($row = mysql_fetch_assoc($sql))
    {
       
      $htmlout .= "

heading No.{$row['cid']}



     

     
     
     

     

     
     
";

    }

    print stdhead("Edit options") . $htmlout . stdfoot();
    exit();
}


function Show_Rules_Edit()
{
    global $lang, $CURUSER;
   
    $htmlout='';
   
    $maxclass = $CURUSER['class'];

    if (!isset($_GET['catid']) || empty($_GET['catid']) || !is_valid_id($_GET['catid']))
      stderr("Error", "No Section selected");

    $cat_id = (int)$_GET['catid'];

    $sql = mysql_query("SELECT * FROM rules WHERE cid = {$cat_id}") or stderr("SQL Error", "OOps!");

    if (!mysql_num_rows($sql))
        stderr("SQL Error", "Nothing doing here!");
       
    $htmlout .= "

    ";
     
    while ($row = mysql_fetch_assoc($sql))
    {
      $htmlout .= "Rules No.{$row['id']} - ".get_date($row['mtime'], 'DATE',0,1);
   
      $htmlout .= "
     
     

     
     
     
     

     
     
     

      ";


    }
   
    $htmlout .= " 
   
   
";
   
    print stdhead("Edit options") . $htmlout . stdfoot();
    exit();
}

function Do_Rules_Update()
{
   
    $time = TIME_NOW;
    $updateset = array();
   
   
    if (!isset($_POST['fdata']) || !is_array($_POST['fdata']) )
      stderr("Error", "Don't leave any fields blank");
   
   
    foreach( $_POST['fdata'] as $k => $v )
    {
      $holder ='';
      if( isset($v['rules_id']) AND !empty($v['rules_id']) )
      {
        foreach( array('heading', 'body') as $x )
        {
        isset($v[ $x ]) AND !empty($v[ $x ]) ? $holder .= "{$x} = ".sqlesc(strip_tags($v[ $x ])).", " : stderr('Error', "{$x}  is empty");
        }
        $updateset[] = "UPDATE rules SET {$holder} mtime = {$time} WHERE id = ".intval($v['rules_id']);
      }
    }
    /*
    echo '
';
    print_r($updateset);
    echo '
';
    */
    foreach( $updateset as $x )
    {
      @mysql_query( $x ) or sqlerr();
    }
   
    if (mysql_affected_rows() == -1)
        stderr("SQL Error", "Update failed");

    stderr("Info", "Updated successfully Go Back To Admin");
}

function Do_Cat_Update()
{
    $cat_id = (int)$_POST['cat'];
   
    $min_class_read = sqlesc(intval($_POST['min_class_read']));

    if (!is_valid_id($cat_id))
        stderr("Error", "No values");

    if (empty($_POST['rcat_name']) || (strlen($_POST['rcat_name']) > 100))
        stderr("Error", "No value or value too big");

    $sql = "UPDATE rules_categories SET rcat_name = " . sqlesc(strip_tags($_POST['rcat_name'])) . ", min_class_read=$min_class_read WHERE cid=$cat_id";

    @mysql_query($sql);

    if (mysql_affected_rows() == -1)
        stderr("Warning", "Could not carry out that request");

    stderr("Info", "Updated successfully Go Back To Admin");
 
}

function Do_Cat_Add()
{
    global $TBDEV;
   
    $htmlout='';
   
    if (empty($_POST['rcat_name']) || strlen($_POST['rcat_name']) > 100)
        stderr("Error", "Field is blank or length too long!");

    $cat_name = sqlesc(strip_tags($_POST['rcat_name']));
   
    $min_class_read = sqlesc(strip_tags($_POST['min_class_read']));

    $sql = "INSERT INTO rules_categories (rcat_name,min_class_read) VALUES ($cat_name, $min_class_read)";

    @mysql_query($sql);

    if (mysql_affected_rows() == -1)
        stderr("Warning", "Couldn't forefill that request");


    $htmlout .= New_Cat_Form(1);
    //return $htmlout;

    print stdhead("Add New Heading") . $htmlout . stdfoot();

    exit();
}

function Do_Rules_Add()
{

    global $lang;
   
    $cat_id = (int)$_POST['cat'];

    if (!is_valid_id($cat_id))
      stderr("Error", "No heading");
   
    if (empty($_POST['heading']) || empty($_POST['body']) || strlen($_POST['heading']) > 100)
      stderr("Error", "Field is blank or length too long! Go Back");
   
     
    $heading = sqlesc(strip_tags($_POST['heading']));
   
    $body = sqlesc(strip_tags($_POST['body']));
   
    $sql = "INSERT INTO rules (cid, heading, body, ctime) VALUES ($cat_id, $heading, $body, ".TIME_NOW."+(3600*24*3))";

    @mysql_query($sql);

    if (mysql_affected_rows() == -1)
        stderr("Warning", "Couldn't forefill that request");

    New_rules_Form(1);

    exit();
}

function New_Cat_Form()
{
    global $CURUSER, $lang;
   
    $htmlout = '';
   
    $maxclass = $CURUSER['class'];

    $htmlout .= "

Add A New heading



   

   
   
   
   
   

   

   
";

    print stdhead("Add New Category") . $htmlout . stdfoot();

    exit();
}

function New_rules_Form()
{
    global $CURUSER, $lang;
   
    $htmlout = '';
   
    $sql = mysql_query("SELECT * FROM rules_categories") or die("Ooops");

    if ( !mysql_num_rows($sql) )
      stderr("ERROR", "There Are No Categories.
        Add Category");

    $htmlout .= "

Add A New section


   

   

   

   
   

   

   
";

    print stdhead("Add New Rule") . $htmlout . stdfoot();

    exit();
}

function Do_Info($text)
{
    $info = "
Info Info
\n";
    $info .= $text;
    $info .= "
";
    $info .= "Go Back To Admin OR Add another?";
    return $info;
}

function Do_Error($heading, $text)
{
    $htmlout='';
    global $TBDEV;
    $htmlout .= "
Warned $heading
\n";
    $htmlout .=  "$text\n";
    $htmlout .= "
";
    return $htmlout;
    print stdhead("Error") . $HTMLOUT . stdfoot();
    exit;
}


?>


DND 22nd February 2016 22:27

error appears in error.log file
it doesnt appear because you dont have it set in php.ini to appear


All times are GMT +2. The time now is 12:30.

Powered by vBulletin® Version 3.8.11 Beta 3
Copyright ©2000 - 2024, vBulletin Solutions Inc.