09 dynamic rules page mod

Started by Jctheboss, February 20, 2016, 03:20:10 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Jctheboss

#9
Quote from: denede on February 22, 2016, 05:48:21 PM
that isn't an error.. what do you mean it doesn't work ?
post error log or something.
o

denede

that isn't an error.. what do you mean it doesn't work ?
post error log or something.

Jctheboss

Quote from: denede on February 21, 2016, 09:04:26 AM
why would i have if from the past 3 posts i'm telling you to edit the file directly.
post error why it doesn't work.



buttons dont work grr no delete / no edit ....

[attachment deleted by admin]

denede

why would i have if from the past 3 posts i'm telling you to edit the file directly.
post error why it doesn't work.

Jctheboss

#5
I know! I say this mod for 09tbdev... but dont work :/ you have the mod complete?


CREATE TABLE rules (
  id int(11) NOT NULL AUTO_INCREMENT,
  cid int(3) unsigned NOT NULL DEFAULT '0',
  heading varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
  body text COLLATE utf8_unicode_ci NOT NULL,
  ctime int(11) unsigned NOT NULL DEFAULT '0',
  mtime int(11) unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (id),
  KEY cat_id (cid)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci


CREATE TABLE rules_categories (
  cid int(3) unsigned NOT NULL AUTO_INCREMENT,
  rcat_name varchar(100) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
  min_class_read int(2) NOT NULL DEFAULT '0',
  PRIMARY KEY (cid)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci



INSERT INTO rules (id, cid, heading, body, ctime, mtime) VALUES
(1, 1, ':: ::General rules - ''Breaking these rules can and ...', ' FILTER_FLAG_STRIP_LOW, FILTER_FLAG_STRIP_HIGH, FILTER_FLAG_ENCODE_LOW, FILTER_FLAG_ENCODE_HIGH\r\n \r\nFILTER_FLAG_ALLOW_FRACTION, FILTER_FLAG_ALLOW_THOUSAND, FILTER_FLAG_ALLOW_SCIENTIFIC\r\n \r\nFILTER_FLAG_STRIP_LOW, FILTER_FLAG_STRIP_HIGH, FILTER_FLAG_ENCODE_HIGH\r\nFILTER_FLAG_NO_ENCODE_QUOTES, FILTER_FLAG_STRIP_LOW, FILTER_FLAG_STRIP_HIGH, FILTER_FLAG_ENCODE_LOW, FILTER_FLAG_ENCODE_HIGH, FILTER_FLAG_ENCODE_AMP\r\n \r\n \r\nFILTER_FLAG_STRIP_LOW, FILTER_FLAG_STRIP_HIGH, FILTER_FLAG_ENCODE_LOW, FILTER_FLAG_ENCODE_HIGH, FILTER_FLAG_ENCODE_AMP ', 1214338879, 1293054699),
(6, 14, 'What''s this for?', 'We''ve noticed that you''ve been inactive for over 10 minute(s).\r\nWe''ve stopped running the Shoutbox due to your inactivity.\r\nIf you are back again, please click the I''m Back button below. ', 1293321576, 0),
(2, 1, ':: ::Forum Rules blah', ' # Please, feel free to answer any questions but leave the moderating to the moderators.\r\n     # Don''t use all capital letters, excessive !!! (exclamation marks) or ??? (question marks)... it seems like you''re shouting.\r\n     # No posting of users stats without their consent is allowed in the forums or torrent comments regardless of ratio or class.  \r\n     # No trashing of other peoples topics.\r\n     # No systematic foul language (and none at all on titles).\r\n     # No double posting. If you wish to post again, and yours is the last post in the thread please use the EDIT function, instead of posting a double.    \r\n     # No bumping... (All bumped threads will be Locked.)  \r\n     # No direct links to internet sites in the forums.      \r\n     # No images larger than 400x400, and preferably web-optimised. Use the [imgw] tag for larger images.\r\n     # No advertising, mechandising or promotions of any sort are allowed on the site.    \r\n     # Do not tell people to read the Rules, the FAQ, or comment on their ratios and torrents.    \r\n     # No consistent off-topic posts allowed in the forums. (i.e. SPAM or hijacking)  \r\n     # The Trading/Requesting of invites to other sites is forbidden in the forums.  \r\n     # Do not post links to other torrent sites or torrents on those sites.    \r\n     # Users are not allowed, under any circumstance to create their own polls in the forum.    \r\n     # No self-congratulatory topics are allowed in the forums.    \r\n     # Do not quote excessively. One quote of a quote box is sufficient.    \r\n     # Please ensure all questions are posted in the correct section!     (Game questions in the Games section, Apps questions in the Apps section, etc.)    \r\n     # Please, feel free to answer any questions.. However remain respectful to the people you help ....nobodys better than anyone else.    \r\n     # Last, please read the FAQ before asking any question', 1214339023, 1293054699),
(3, 3, ':: ::Uploaders Rules', 'All uploaders are subject to follow the below rules in order to be a part of the  uploader team. We realize that it''s quite a list, and for new uploaders, it might seem a bit overwhelming, but as you spend time here, they''ll become second hat.\r\n\r\nTo apply to become a site uploader use the uploaders application form, contact staff to get the link.\r\n\r\nTorrents that do not follow the rules below will be deleted.  If you have any questions about the below rules, please feel free to PM them and I will clarify as best I can.\r\n\r\nWelcome to the team and happy uploading!\r\n\r\n# All Uploaders must upload a minimum of 3 unique torrents each week to retain their Uploader status.  Failure to comply will result in a demotion, and a minimum of a 2 week blackout period where they will not be able to return to the Uploader team.  If, after the 2 weeks, the Uploader can prove they will be active, they will be reinstated.  A second instance of inactivity will be cause for permanent removal from the Uploader team.  Extenuating circumstances will be considered if it is the cause of inactivity.  If you are going to be away, please let a staff member know so that your account is not affected.\r\n# All torrents must be rarred, no matter what the size or type.  The ONLY exception to this is MP3s.  Guidelines for rarring your own releases are as follows:\r\n', 1214339203, 1293048490),
(4, 4, ':: ::Free leech rules', '      From time to time we will have freeleech for 48hours. This means that when you download from site it will not count against your download ratio.\r\n\r\n      Whatever you seed back will add to your upload ratio.\r\n\r\nThis is a good opportunity for members with ratio''s below 1.0 to bring them back into line\r\n\r\nAnyone who hit and runs on a freeleech torrent will receive a mandatory 2 week warning. You must seed all torrents downloaded to  100% or for a minimum of 48 hours this is for free leech torrents only.\r\n\r\n', 1214339464, 1293048590),
(5, 5, ':: ::Downloading rules', 'No comments on torrents you are not about to download\r\nOnce download is complete, remember to seed for as long as possible or for a minimum of 36 hours or a ratio of 1:1\r\nLow ratios will be given the three strike warning from staff and can lead to a total ban', 1214339531, 0),
(8, 11, 'Downloaded', 'Remember, if you see any specific instance of this software running publicly, it''s within your rights under gpl to garner a copy of that derivative from the person responsible for that webserver.', 1293322039, 0)



INSERT INTO rules_categories (cid, rcat_name, min_class_read) VALUES
(1, ':: ::General Site Rules', 0),
(2, ':: ::Forum Rules', 0),
(3, ':: ::Uploaders Rules', 2),
(4, ':: ::Free leech rules', 0),
(5, ':: ::Downloading rules', 0),
(14, 'heading No.14', 6),
(12, 'Remember', 0),
(11, 'it''s within your rights under gpl', 0)

rules.php

<?php

/* Bigjoos, CoLdFuSiOn */

if ( ! defined'IN_TBDEV_ADMIN' ) )
{
print "<h1>Incorrect access</h1>You cannot access this file directly.";
exit();
}

require_once 
"include/user_functions.php";

    
$lang array_merge$langload_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. <br /><br />
      <span class='btn'><a href='
{$TBDEV['baseurl']}/admin.php?action=rules&amp;mode=cat_new'>Add Category</a></span>");

  
$htmlout '';

  
$htmlout .= "
                     <div class='cblock'>
                         <div class='cblock-header'>
                             
{$lang['rules_cat_title']}
                             <div style='float:right;'>
                                 <span class='btn'><a href='
{$TBDEV['baseurl']}/admin.php?action=rules&amp;mode=cat_new'>{$lang['rules_btn_newcat']}</a></span>&nbsp;
                                 <span class='btn'><a href='
{$TBDEV['baseurl']}/admin.php?action=rules&amp;mode=rules_new'>{$lang['rules_btn_newrule']}</a></span>
                             </div>
                         </div>
                         <div class='cblock-content'>
                             <table style='width: 70%; cellpadding: 5px;'>"
;
  
  while (
$arr mysql_fetch_assoc($sql)) 
  {
    
$htmlout .= "
      <tr>
        <td>
{$arr['cid']}</td>
        <td><a href='
{$TBDEV['baseurl']}/admin.php?action=rules&amp;mode=rules_edit&amp;catid={$arr['cid']}'>{$arr['rcat_name']}</a></td>
        <td>
{$arr['min_class_read']}</td>
        <td><a href='
{$TBDEV['baseurl']}/admin.php?action=rules&amp;mode=cat_edit&amp;catid={$arr['cid']}'>{$lang['rules_edit']}</a></td>
        <td><a href='
{$TBDEV['baseurl']}/admin.php?action=rules&amp;mode=cat_delete&amp;catid={$arr['cid']}'>{$lang['rules_delete']}</a></td>
      </tr>"
;
  }
  

  
$htmlout .= "</table>
                           </div>
                     </div>"
;

  
//$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! <a href='admin.php?action=rules'>Go Back To Rules Admin?</a>");
}
// ====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! <br />
      <a href='admin.php?action=rules&amp;catid=
{$id}&amp;mode=cat_delete_chk'><span style='font-weight: bold; color: green'>CONTINUE</span></a>
       or <a href='admin.php?action=rules'><span style='font-weight: bold; color: red'>CANCEL</span></a>"
);
    }
    
    @
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! <a href='admin.php?action=rules'>Go Back To Rules Admin?</a>");
    
}

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 .= "<h2>heading No.{$row['cid']}</h2>

      <form name='inputform' method='post' action='admin.php?action=rules'>
      <input type='hidden' name='mode' value='takeedit_cat' />
      <input type='hidden' name='cat' value='
{$row['cid']}' />
      <input type='text' value='" 
htmlsafechars($row['rcat_name']) . "' name='rcat_name' style='width:380px;' />

      <select name='min_class_read'>"
;

      for (
$i 0$i <= $maxclass; ++$i)
      {
      
$htmlout .= '<option value="'.$i.'">'.get_user_class_name($i).'</option>';
      }

      
$htmlout .= "</select>

      <input type='submit' name='submit' value='Edit' class='button' />
      </form>"
;

    }

    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 .= "<form name='compose' method='post' action='admin.php?action=rules'>
    <!--<input type='hidden' name='mode' value='rules_update' />-->"
;
      
    while (
$row mysql_fetch_assoc($sql)) 
    {
      
$htmlout .= "<strong>Rules No.{$row['id']}</strong> - ".get_date($row['mtime'], 'DATE',0,1);
     
      
$htmlout .= "<!--
      <input type='hidden' name='rules_id' value='
{$row['id']}' />
      <input type='hidden' name='action' value='rules_delete' />
      <input type='hidden' name='id' value='
{$row['id']}' />-->
      <br />
      <div style='text-align: left; width: 70%; border: 1px solid;'>
      <input type='text' value='"
.htmlsafechars($row['heading'])."' name='fdata[{$row['id']}][heading]' style='width:650px;' />
      <span style='float:right;'>
      <input type='checkbox' name='fdata[
{$row['id']}][rules_id]' value='{$row['id']}' />
      </span>
      <br />
      <textarea name='fdata[
{$row['id']}][body]' rows='10' cols='20' style='width:650px;'>".htmlsafechars($row['body'])."</textarea>
      </div>
      <br />"
;


    }
    
    
$htmlout .= "<input type='submit' name='submit' value='With Selected' class='button' />&nbsp;
    <select name='mode'>
    <option value=''>--- Select One ---</option>
    <option value='takeedit_rules'>Update Rules</option>
    <option value='rules_delete'>Delete Rules</option>
    </select>
    </form>"
;
    
    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 '<pre>';
    print_r($updateset); 
    echo '</pre>';
    */
    
foreach( $updateset as $x )
    {
      @
mysql_query$x ) or sqlerr();
    }
    
    if (
mysql_affected_rows() == -1)
        
stderr("SQL Error""Update failed");

    
stderr("Info""Updated successfully <a href='admin.php?action=rules'>Go Back To Admin</a>");
}

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 <a href='admin.php?action=rules'>Go Back To Admin</a>");
   
}

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! <a href='admin.php?action=rules'>Go Back</a>");
    
      
    
$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 .= "<h2>Add A New heading</h2>

    <form name='inputform' method='post' action='admin.php?action=rules'>
    <input type='hidden' name='mode' value='cat_add' />
    
    <input type='text' value='' name='rcat_name' style='width:380px;' />
    
    <select name='min_class_read'>"
;
    
    for (
$i 0$i <= $maxclass; ++$i)
    {
    
$htmlout .= '<option value="'.$i.'">'.get_user_class_name($i).'</option>';
    }
    
    
$htmlout .= "</select>

    <input type='submit' name='submit' value='Add' class='button' />

    </form>"
;

    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. <br /><br />
        <span class='btn'><a href='
{$TBDEV['baseurl']}/admin.php?action=rules&amp;mode=cat_add'>Add Category</a></span>");

    
$htmlout .= "<h2>Add A New section</h2>
    <form name='inputform' method='post' action='admin.php?action=rules'>
    <input type='hidden' name='mode' value='takeadd_rules' />

    <input type='text' value='' name='heading' style='width:380px;' /><br /><br />

    <select name='cat'>
    <option value=''>--Select--</option>"
;

    while( 
$v mysql_fetch_assoc($sql) ) 
    {
        
$htmlout .= "<option value='{$v['cid']}'>{$v['rcat_name']}</option>";
    }

    
$htmlout .= "</select><br /><br />
    <textarea name='body' rows='15' cols='20' class='textbox' style='width:650px;'>
    </textarea><br />

    <input type='submit' name='save_cat' value='Add' class='button' />

    </form>"
;

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

    exit();
}

function 
Do_Info($text)
{
    
$info "<div class='infohead'><img src='{$TBDEV['pic_base_url']}warned0.gif' alt='Info' title='Info' /> Info</div><div class='infobody'>\n";
    
$info .= $text;
    
$info .= "</div>";
    
$info .= "<a href='admin.php?action=rules'>Go Back To Admin</a> OR Add another?";
    return 
$info;
}

function 
Do_Error($heading$text)
{
    
$htmlout='';
    global 
$TBDEV;
    
$htmlout .= "<div class='errorhead'><img src='{$TBDEV['pic_base_url']}warned.gif' alt='Warned' /> $heading</div><div class='errorbody'>\n";
    
$htmlout .=  "$text\n";
    
$htmlout .= "</div>";
    return 
$htmlout;
    print 
stdhead("Error") . $HTMLOUT stdfoot();
    exit;
}


?>



admin/index.php

<span class='btn'><a href='admin.php?action=rules'>rules</a></span>




lang_rules.php

<?php

$lang 
= array(

#Misc
'rules_rules' => "Rules Admin",
'stderr_error' => "Error",

#Texts
'rules_cat_title' => "Rules categories",
'rules_edit' => "Edit",
'rules_delete' => "Delete",
'rules_btn_newcat' => "Add New Category",
'rules_btn_newrule' => "Add New Rule",


);

?>

[attachment deleted by admin]

denede

edit the file and the lang file directly. :)

Jctheboss


denede

just edit the file itself? can't be that hard.
http://i.imgur.com/7bxB50N.png

looks casual enough...

Jctheboss


hello , anyone have this mod ( dynamic rules page mod) ? For  tbdev 2009? Our staff edit rules ?! 

Thanks ✌