Login     Sign up
need help to delete this feature from admin.module page
john mor (@johninhell)
Join date: Oct 15th 2010
Community posts: 159
View Profile
Send Message

how to edit this :|

[img]http://jcowmaster.net/uploads/userfiles/201101/21_49_25s2y.jpg[/img]

==========================================================

<?php
/ ############################################################ \


* ############################################################ */

class junior {
function junior() {
do_auth(12);
clear_as();
clear_report();
set_title('junior Panel');
global $nav, $config, $menuon;
$menuon = 'junior';
$config['hide_ad'] = 1;
$nav[] = url('junior',t('junior Panel'));

}

function update($step) {
    global $nav;
    include "modules/junior/inc/update.php";
}
function blacklist($step,$id) {
    global $nav;
    $nav[] = url('junior/blacklist',t('Blacklist'));
    include "modules/junior/inc/blacklist.php";
}
function cache($step,$id) {
    global $nav;
    $nav[] = url('junior/cache',t('Cache controller'));
    include "includes/libs/junior_cache.module.php";
}

function members_quick($step) {
    global $menuon, $tab_menu, $nav, $config;
    set_title('Member quick management');
    $nav[] = url('junior/members_quick','Member quick management');
    include "modules/junior/inc/members_quick.php";
}
function stream_monitor($step) {
    global $menuon, $tab_menu, $nav, $config;
    set_title('Stream monitor');
    $nav[] = url('junior/stream_monitor','Stream monitor');
    include "modules/junior/inc/stream_monitor.php";
}

function index() {
    global $version, $client, $optional_apps, $config, $current_modules, $junior_menu;
    nav('Index');

    $s = str_replace('[url]http://','',uhome());[/url]
    $res = sql_query("select count(*) as num from ".tb()."accounts");
    $member = sql_fetch_array($res);
    section_content('
        <IFRAME SRC="[url]s='.urlencode($s).'&e='.urlencode($client['email']).'fn='.urlencode($client['fullname']).'&m='.$member['num'].'&br='.$_SESSION['br'].'"[/url] TITLE="Jcow News" WIDTH="580" HEIGHT="180" scrolling="no">

<a href="[url]">Visit[/url] Admin for News&Updates</a><br />
</IFRAME>
');
section_close('junior News');
$res = sql_query("select count() as num from ".tb()."accounts " );
$row = sql_fetch_array($res);
$members = $row['num'];
$res = sql_query("select count(
) as num from ".tb()."accounts where disabled=1" );
$row = sql_fetch_array($res);
$pending_members = $row['num'];
$res = sql_query("select count() as total from ".tb()."reports");
$row = sql_fetch_array($res);
$reports_all = $row['total'];
$res = sql_query("select count(
) as total from ".tb()."reports where hasread=0");
$row = sql_fetch_array($res);
$reports_unread = $row['total'];

    section_content('
    <ul>
    <li>Your own network Version: <strong>'.jversion().'</strong>. [<a href="[url]"[/url] target="_blank">Get <strong>nothing here</strong></a>]</li>
    <li>You have <a href="'.url('junior/users').'"><strong>'.$members.'</strong> Members</a>. (<strong>'.$pending_members.'</strong> pending)</li>
    <li>
    <a href="'.url('junior/reports').'">Member Reports (<strong>'.$reports_unread.'</strong>/'.$reports_all.')</a>
    </li>
    </ul>');
    section_content('<div>

    <div class="ai_items">'
    .url('junior/users','<img src="'.uhome().'/files/icons/admin/users.gif" />').
    '<br />'.url('junior/users',t('Members')).'</div>

    '.$ads_link.'

    <div class="ai_items">'
    .url('junior/blacklist','<img src="'.uhome().'/files/icons/admin/blacklist.gif" />').
    '<br />'.url('junior/blacklist',t('Black List')).'</div>

    <div class="ai_items">'
    .url('junior/members_quick','<img src="'.uhome().'/modules/admin/member_quick_management.gif" />').
    '<br />'.url('junior/members_quick','Members<br />Quick Manage').'</div>
    <div class="ai_items">'
    .url('junior/stream_monitor','<img src="'.uhome().'/modules/admin/stream_monitor.gif" />').
    '<br />'.url('junior/stream_monitor','Stream Monitor').'</div>

    <div class="ai_items">'
    .url('junior/cache','<img src="'.uhome().'/modules/admin/cache.gif" />').
    '<br />'.url('junior/cache','Cache Controller').'</div>

    <style>
    .ai_items {
        width:100px;
        height: 100px;
        overflow: hidden;
        float: left;
        text-align: center;
}
    .ai_items img {     
        border: #ccc 1px solid;
}
    </style>');
    section_close('Management Tools');

    c('<ul>');
    c('<li>'.url('junior/update', '<strong>Online Update</strong>').' - Get new  features and Security Patches</li>');
    if (is_array($junior_menu)) {
        foreach ($junior_menu as $item) {
            section_content('<li>'.url($item['path'],$item['name']).'</li>');
        }
    }
    c('</ul>');
    section_close('Addon Tools');
}

function jsql() {
    nav(url('junior/jsql','Execute SQL Query') );
    if ($_POST['step'] == 2) {
        if (!$_POST['query']) {
            sys_notice('Empty query');
        }
        else {
            $query = stripslashes($_POST['query']);
            $query = remove_remarks($query);
            $pieces = split_sql_file($query, ";");
            if (is_array($pieces)) {
                foreach ($pieces as $piece) {
                    $sql = trim($piece);
                    if(!empty($sql) and $sql[0] != "#") {
                        sql_query($sql);
                    }
                }
            }
            sys_notice('Query executed!');
        }
    }
    c('
    <p>Be <strong>Very</strong> careful when using this tool!<br />
    Do not execute queries from unknown source.
    </p>
    <form method="post" action="'.url('junior/jsql').'">
    <textarea name="query" rows="10" cols="50"></textarea><br />
    <input type="hidden" name="step" value="2" />
    <input type="submit" value="Execute!" />
    </form>');
}

function app_disable($key) {
    set_gvar('app_'.$key, 0);
    redirect('junior',1);
}
function app_enable($key) {
    set_gvar('app_'.$key, 1);
    redirect('junior',1);
}

function reports() {
    nav(url('junior/reports',t('Reports') ));
    global $current_sub_menu, $apps, $story_apps,$offset, $ubase, $num_per_page, $page, $content; 
    set_title('Reports');
    sql_query("update ".tb()."reports set hasread=1");
    $res = sql_query("SELECT r.*,u.username FROM ".tb()."reports as r left join `".tb()."accounts` as u on u.id=r.uid ORDER by r.id DESC LIMIT $offset,$num_per_page ");
    c('<table class="stories" cellspacing="1">');
    section_content('<tr class="table_line1">
        <td>Reports</td>
        </tr>');
        while ($row = sql_fetch_array($res)) {
        c('<tr class="row1">
        <td>'.get_date($row['created']).', url: '.url($row['url'],$row['url']).' was reported by '.url('u/'.$row['username'],$row['username']).':<br /><span class="sub">'.h($row['message']).'</span></td>
        </tr>');
    }
    c('</table>');

    // pager
    $res = sql_query("select count(*) as total from `".tb()."reports`");
    $row = sql_fetch_array($res);
    $total = $row['total'];
    $pb       = new PageBar($total, $num_per_page, $page);
    $pb->paras = $ubase.'junior/reports';
    $pagebar  = $pb->whole_num_bar();
    c($pagebar);
}

function users($filter = '') {
    nav(url('junior/users','Members'));
    global $current_sub_menu,$num_per_page,$offset,$page;
    section_content('
    <script>
    function sfilter() {
        var uname = document.getElementById("fusername").value;
        window.location = "'.url('junior/users').'/"+uname;
        }
    </script>
    ');
    c(t('Username').': 
    <input type="text" name="lastname" id="fusername" /> <input type="button" value="'.t('Search').'" onclick="javascript:sfilter();" />');

    section_content('<ul>');
    if (strlen($filter) && !eregi("^page",$filter)) {
        $pageb = "/$filter";
        $filter = " and username like '%$filter%' ";
    }
    else {
        $filter = '';
    }
    $res = sql_query("select * from `".tb()."accounts` "." where 1 $filter order by id DESC limit $offset,$num_per_page");
    while ($member = sql_fetch_array($res)) {
        $status = $member['disabled'] ? '(Pending)' : '';
        section_content('<li><span>'.url('junior/useredit/'.$member['id'],$member['username'].' '.$member['lastname']). $status.'</li>');
    }
    section_content('</ul>');

    $res = sql_query("select count(*) as total from `".tb()."accounts` "." where 1 $filter ");
    $row = sql_fetch_array($res);
    $total = $row['total'];
    $pb       = new PageBar($total, $num_per_page, $page);
    $pb->paras = url('junior/users'.$pageb);
    $pagebar  = $pb->whole_num_bar();
    c($pagebar);
    $current_sub_menu['href'] = url('junior/users');
}

function useredit($uid = 0) {
    global $nav;
    $nav[] = url('junior/users',t('Users'));
    $res = sql_query("select * from `".tb()."accounts` where id='$uid' ");
    $user = sql_fetch_array($res);
    $user['roles'] = explode('|',$user['roles']);
    if (!$user['id']) {
        die('wrong uid');
    }
    if ($user['featured']) $featured = 'checked';
    section_content('
    <p>
    '.t('Username').': 
    <strong>'.$user['username'].'</strong>
     ('.url('u/'.$user['username'],t('View profile')).')<br />
    Email: '.$user['email'].'<br />
    Location: '.h($user['location']).'
    </p>
    <p>
    <label>User IP</label>
    <strong>'.$user['ipaddress'].'</strong> (<a href="[url]http://www.google.ca/search?q='.$user['ipaddress'].'"[/url] target="_blank">Whois</a>)<form action="'.url('junior/blacklist').'" method="post">
    <input type="hidden" name="ip" value="'.$user['ipaddress'].'" /><input type="submit" value="Add this IP to Blacklist" /></form>
    </p>
    <fieldset>
    <form action="'.url('junior/usereditpost').'" method="post">
    <p>
    '.label('User Roles'));
    $res = sql_query("select * from ".tb()."roles where (id=3 or id>9) order by id");
    while ($role = sql_fetch_array($res)) {
        $checked = '';
        if (in_array($role['id'],$user['roles']))   $checked = ' checked ';
        section_content('<input type="checkbox" name="set_roles[]" value="'.$role['id'].'" '.$checked.' />'.h($role['name']).' ');
    }
    section_content('
    </p>

                <p>
                '.label(t('Status')).'
                <input type="radio" name="disabled" value=0 '.junior_check_status($user,0).' /> Active 
                <input type="radio" name="disabled" value=1 '.junior_check_status($user,1).' /> Pending 
                <input type="radio" name="disabled" value=2 '.junior_check_status($user,2).' /> Suspended<br />

                </p>
                <p>
                '.label(t('Featured')).'
                <input type="checkbox" name="set_featured" value=1 '.
                $featured.' /> Featured<br />
                <span class="sub">Featured members have more chance to be displayed.</span>
                </p>

    <p>
    <input type="hidden" name="uid" value="'.$user['id'].'" />
    <input type="submit" value="'.t('Save changes').'" class="button" />
    </p>
    </form>
    </fieldset>');

}

function usereditpost() {
    if ($_POST['delete']) {
        redirect('junior/users',1);
    }
    else {
        if (is_array($_POST['set_roles']))
        $roles = implode('|',$_POST['set_roles']);
        $featured = $_POST['set_featured'];
        $res = sql_query("select disabled,email from ".tb()."accounts where id='{$_POST['uid']}'");
        $user = sql_fetch_array($res);
        sql_query("update `".tb()."accounts` set disabled='{$_POST['disabled']}',roles='{$roles}',featured='{$featured}' $newpass where id={$_POST['uid']} ");
        if (!$_POST['disabled'] && $user['disabled'] == 1) {
            @jcow_mail($user['email'], 'Your account on '.get_gvar('site_name').' approved!', 'Congratulations! Your account on '.get_gvar('site_name').' has been approved! You can start posting now');
        }

        redirect('junior/useredit/'.$_POST['uid'],1);
    }
}

function userroleeditpost() {
    sql_query("update ".tb()."roles set name='{$_POST['name']}' where id='{$_POST['rid']}' ");
    redirect('junior/userroles',1);
}

function userroleadd() {
    if (!$_POST['name']) sys_back('Please input a valid role name');
    $res = sql_query("select max(id) as maxid from ".tb()."roles " );
    $row = sql_fetch_array($res);
    if ($row['maxid'] < 11) $id = 11;
    else $id = $row['maxid'] + 1;
    sql_query("insert into ".tb()."roles(id,name) values($id,'{$_POST['name']}')");
    redirect('junior/userroles',1);
}

function apps() {
    nav(t('Applications'));
    global $current_sub_menu, $all_apps;
    $current_sub_menu['href'] = url('junior/apps');
    $res = sql_query("select * from ".tb()."apps "." order by weight");
    section_content('<table class="stories" cellspacing="1">');
    section_content('<form action="'.url('junior/appspost').'" method="post" >');
    section_content('<tr class="table_line1"><td width="10">Actived</td><td>Application</td><td>Display</td><td>Weight</td></tr>');
    while($app = sql_fetch_array($res)) {
        $checked = $app['status'] ? 'checked':'';
        $readonly = $app['status'] ? '':'readonly';
        $app['dname'] = $app['name'];
        if ($app['dname'] == 'members') $app['dname'] = 'member listings';
        section_content('<tr class="row1"><td><input type="checkbox" name="'.$app['name'].'active" '.$checked.' value="1" /></td>
        <td>'.$app['dname'].'</td>
        <td><input type="text" name="'.$app['name'].'flag" value="'.h($app['flag']).'" '.$readonly.' /></td>
        <td><input type="text" name="'.$app['name'].'weight" size="2" value="'.$app['weight'].'" /></td>
        </tr>');
    }
    section_content('<tr class="row2"><td colspan="4"><input type="submit" value="'.t('Save changes').'" /></td></tr>
    </form>
    </table>');
}

function appspost() {
    $res = sql_query("select * from ".tb()."apps ");
    while($app = sql_fetch_array($res)) {
        $active = $app['name'].'active';
        $active = $_POST[$active];
        $flag = $app['name'].'flag';
        $flag = $_POST[$flag];
        $weight = $app['name'].'weight';
        $weight = $_POST[$weight];
        sql_query("update ".tb()."apps set status='$active',flag='$flag',weight='$weight' where id='{$app['id']}'");
    }
    redirect('junior/apps',1);
}

function plugins() {
    nav(t('Plugins'));
    global $current_sub_menu, $apps;
    $path='plugins/';
    if ($handle = opendir($path)) {
        c("Directory handle: $handle\n");
        c("Files:\n");
        while (false !== ($file = readdir($handle))) {
            $tmppath=rawurlencode($file);
            c("<a href=$path"."$tmppath>$file</a>\n");
                c("<br>");
        }
        while ($file = readdir($handle)) {
            c("$file\n");
        }
        closedir($handle);
    }
}

function pluginspost() {
    redirect('junior/apps',1);
}

}

function junior_check_status($user, $val) {
if ($user['disabled'] == $val) {
return 'checked';
}
}

function get_style_list($dirname) {
if ($handle = opendir($dirname)) {
while (false !== ($file = readdir($handle))) {
if (is_dir($dirname . '/' .$file) && $file != '.' && $file != '..' && $file != '.svn' ) {
$dirs[] = $file;
}
}
closedir($handle);

    if (is_array($dirs)) {
        asort($dirs);
        return $dirs;
    }
    else {
        return 0;
    }
}

}

function remove_remarks($sql)
{
$lines = explode("\n", $sql);

// try to keep mem. use down
$sql = "";

$linecount = count($lines);
$output = "";

for ($i = 0; $i < $linecount; $i++)
{
    if (($i != ($linecount - 1)) || (strlen($lines[$i]) > 0))
    {
        if ($lines[$i][0] != "#")
        {
            $output .= $lines[$i] . "\n";
        }
        else
        {
            $output .= "\n";
        }
        // Trading a bit of speed for lower mem. use here.
        $lines[$i] = "";
    }
}

return $output;

}

//

//
function split_sql_file($sql, $delimiter)
{
$tokens = explode($delimiter, $sql);

$sql = "";
$output = array();

$matches = array();

$token_count = count($tokens);
for ($i = 0; $i < $token_count; $i++)
{
    if (($i != ($token_count - 1)) || (strlen($tokens[$i] > 0)))
    {
        $total_quotes = preg_match_all("/'/", $tokens[$i], $matches);
        // Counts single quotes that are preceded by an odd number of backslashes, 
        // which means they're escaped quotes.
        $escaped_quotes = preg_match_all("/(?<!\\\\)(\\\\\\\\)*\\\\'/", $tokens[$i], $matches);

        $unescaped_quotes = $total_quotes - $escaped_quotes;

        if (($unescaped_quotes % 2) == 0)
        {
            // It's a complete sql statement.
            $output[] = $tokens[$i];
            // save memory.
            $tokens[$i] = "";
        }
        else
        {
            // incomplete sql statement. keep adding tokens until we have a complete one.
            // $temp will hold what we have so far.
            $temp = $tokens[$i] . $delimiter;
            // save memory..
            $tokens[$i] = "";

            // Do we have a complete statement yet? 
            $complete_stmt = false;

            for ($j = $i + 1; (!$complete_stmt && ($j < $token_count)); $j++)
            {
                // This is the total number of single quotes in the token.
                $total_quotes = preg_match_all("/'/", $tokens[$j], $matches);
                // Counts single quotes that are preceded by an odd number of backslashes, 
                // which means they're escaped quotes.
                $escaped_quotes = preg_match_all("/(?<!\\\\)(\\\\\\\\)*\\\\'/", $tokens[$j], $matches);

                $unescaped_quotes = $total_quotes - $escaped_quotes;

                if (($unescaped_quotes % 2) == 1)
                {
                    $output[] = $temp . $tokens[$j];

                    $tokens[$j] = "";
                    $temp = "";

                    $complete_stmt = true;
                    $i = $j;
                }
                else
                {
                    $temp .= $tokens[$j] . $delimiter;
                    $tokens[$j] = "";
                }

            }
        } 
    }
}

return $output;

}

170 months ago
Jcow Master (@falcone)
Join date: Sep 2nd 2010
Community posts: 917
View Profile
Send Message

in function useredit, remove this

[code]
<p>
'.label('User Roles'));
$res = sql_query("select * from ".tb()."roles where (id=3 or id>9) order by id");
while ($role = sql_fetch_array($res)) {
$checked = '';
if (in_array($role['id'],$user['roles'])) $checked = ' checked ';
section_content('<input type="checkbox" name="set_roles[]" value="'.$role['id'].'" '.$checked.' />'.h($role['name']).' ');
}
[/code]

also remove [code]</p>[/code] after [code]section_content('[/code]

and in function usereditpost

change this
[code]
else {
if (is_array($_POST['set_roles']))
$roles = implode('|',$_POST['set_roles']);
$featured = $_POST['set_featured'];
$res = sql_query("select disabled,email from ".tb()."accounts where id='{$_POST['uid']}'");
$user = sql_fetch_array($res);
sql_query("update ".tb()."accounts set disabled='{$_POST['disabled']}',roles='{$roles}',featured='{$featured}' $newpass where id={$_POST['uid']} ");
[/code]

into this

[code]
else {
if (is_array($_POST['uid']))
$featured = $_POST['set_featured'];
$res = sql_query("select disabled,email from ".tb()."accounts where id='{$_POST['uid']}'");
$user = sql_fetch_array($res);
sql_query("update ".tb()."accounts set disabled='{$_POST['disabled']}',featured='{$featured}' $newpass where id={$_POST['uid']} ");
[/code]

170 months ago
sujay sreedhar (@webkoot)
Join date: Nov 11th 2010
Community posts: 98
View Profile
Send Message

dude its 4 ur staff rit? I was workin on same thing can u share the whole code? Please!

170 months ago
john mor (@johninhell)
Join date: Oct 15th 2010
Community posts: 159
View Profile
Send Message

@ falcone thnanks a lot man ..

i did .. removed that.. b4..

but the for the.. next step of.. function "usereditpost"

yeh , sure.. :) . i'll share the code soon..! currently im not at home :| surfing net from cell

170 months ago
sujay sreedhar (@webkoot)
Join date: Nov 11th 2010
Community posts: 98
View Profile
Send Message

may be its easy to make <input
type="checkbox"
name="set_roles[]"
value="'.$role['id'].'" '.
$checked.' /> disabled there change above code
<input
type="checkbox" disabled="disabled"
name="set_roles[]"
value="'.$role['id'].'" '.
$checked.' /> its easy

170 months ago