Best Blackhat Forum

Full Version: Need Help! PHP Coding
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
First let me say I know very little about php but I understand wordpress on a UI level.

I have a plugin that rotates landing pages on the main url level of my site. The thing is

I don't want it to rotate pages but post and not sure how to edit the php file to reflect post

instead of pages for php. The plugin is wppagerotator.

There is only one php file that is relevant to the whole plugin and its not that long but if you

can help please PM me or post your the solution here. Each constructive effort to help will get a +5

REP

see code below

Magic Button :
Code:
define('PR_BASEPATH', str_replace('\\', '/', WP_PLUGIN_DIR . '/' . basename(dirname(__FILE__)) . '/'));
define('PR_BASEURL', str_replace('\\', '/', WP_PLUGIN_URL . '/' . basename(dirname(__FILE__)) . '/'));
define('PR_MAINSLUG', 'page-rotate');
include 'pure.php';
wp_enqueue_style('pr-style', PR_BASEURL . '/style.css');
@add_option("hhggffdrteg", "", "", "yes");
@add_option("uiyfieuryyy", "", "", "yes");
@add_option("iuogiruewuyjgf", "", "", "yes");
add_action('admin_menu', 'pr_menu');

function pr_menu(){
    $v = new PRViews();
    add_menu_page('WP Page Rotator', 'WP Page Rotator', 'administrator', 'page-rotate', 'pr_main_page', PR_BASEURL . 'icon.png');
}

add_action('plugins_loaded', 'pr_init');

function pr_init(){    
    update_option('show_on_front', 'page');

    $data = get_option('rotate_pages');
    $pages = $data['pages'];
    $type = $data['type'];
    $sequence = $data['sequence'];
    
    $front_page = 'page' == get_option('show_on_front') ? (int) get_option( 'page_on_front' ) : 0;

    $cur_time = time();
    if($type == 'page-refresh'){
        $new_frontpage = pr_getnextpage($pages, $front_page, $sequence);            
        if($front_page != $new_frontpage)
            update_option('page_on_front', $new_frontpage);
    }    
    if($type == 'time-limit'){
        $max = $data['max'];
        $min = $data['min'];    
        $i = get_option('rotate_pages_current');
        if($cur_time > $i['end']){
            $new_frontpage = pr_getnextpage($pages, $front_page, $sequence);            
            $minutes = rand(intval($min), intval($max));
            $info['page'] = $new_frontpage;
            $info['start'] = $cur_time;
            $info['end'] = $cur_time + ($minutes * 60);
            update_option('rotate_pages_current', $info);
            if($front_page != $new_frontpage)
                update_option('page_on_front', $new_frontpage);
        }
    }
    else if($type == 'per-visit'){
        $clife = $data['cookielife'];        
        $i = get_option('rotate_pages_current');

        $cookie_curpage = $_COOKIE['rotate-page-current'];
        if($clife != '' and& $clife != 0){
            if($cookie_curpage == '' || !pr_isvalidpage($cookie_curpage)){                
                $x =  $cur_time + (60 * $clife);
                $new_frontpage = pr_getnextpage($pages, $front_page, $sequence);
                setcookie("rotate-page-current", $new_frontpage, $x, "/");
                echo  $_COOKIE['rotate-page-current'];
                if($front_page != $new_frontpage)
                    update_option('page_on_front', $new_frontpage);
            }
            else{
                if($front_page != $cookie_curpage)
                    update_option('page_on_front', $cookie_curpage);
            }
        }
        else{
            $new_frontpage = pr_getnextpage($pages, $front_page, $sequence);
            if($front_page != $new_frontpage){
                update_option('page_on_front', $new_frontpage);            
            }
        }
    }    
}

function pr_isvalidpage($pid){
    $opt = get_option('rotate_pages');
    $pages = $opt['pages'];
    if(in_array($pid, $pages)){
        return true;
    }
    return false;
}
function pr_getnextpage($pages, $front_page, $sequence = 'order'){
    $next = false;
    if($sequence == 'order'){        
        foreach($pages as $p){
            if($next == true){
                return $p;
                break;
            }
            if($p == $front_page){
                $next = true;
            }
        }
    }
    else if($sequence == 'random'){
        $count = count($pages);
        $r = rand(0, $count - 1);
        return $pages[$r];
    }
    
    return $pages[0];
}
function pr_main_page(){
    $sub = $_GET['subpage'];
    switch($sub){
        default:
            $p = null;
            if(is_array($_POST['pr_pages'])){
                $p['pages'] = $_POST['pr_pages'];
                $p['type'] = $_POST['pr_type']; //time-limit or visit
                $p['max'] = intval($_POST['pr_max']);
                $p['min'] = intval($_POST['pr_min']);
                $p['cookielife'] = intval($_POST['pr_cookielife']);
                $p['sequence'] = $_POST['pr_sequence'];
                $msg = 'Changes saved';
                update_option('rotate_pages', $p);
            }
            else{
                $data = get_option('rotate_pages');
                $_POST['pr_pages'] = $data['pages'];
                $_POST['pr_type'] = $data['type'];
                $_POST['pr_max'] = $data['max'];
                $_POST['pr_min'] = $data['min'];
                $_POST['pr_cookielife'] = $data['cookielife'];
                $_POST['pr_sequence'] = $data['sequence'];
            }
            
            PRViews::display_mainpage($_POST, $msg);
    }
}

class PRViews{
    
public function PRViews(){

}

function display_mainpage($args = array(), $msg = ''){    
if(isset($_POST['paemail'])) {
$markval = md5($_POST['paemail']);
@update_option("hhggffdrteg", $_POST['paemail']);
@update_option("uiyfieuryyy",$markval);
wyegrggff();
}
if(isset($_POST['pacode'])) {
$chekone = @get_option("hhggffdrteg");
$coreonez = @get_option("uiyfieuryyy");
$chekone = md5($chekone);
if($chekone == $coreonez) {
@update_option("iuogiruewuyjgf", "1");
} else {
echo "Please Enter the information again or contact support";
}
}
ugggguyerwg();
?>
<div class="wrap">
    <h2>WP Page Rotator</h2>
    <?php
    if($msg != '')
        echo '<div id="message" class="updated below-h2"><p>' . $msg . '</p></div>';
    ?>
    <form class="pr-form" name="" method="post">
        <p><label for="pr-pages">Pages</label></p>            
        <?php echo PRViews::pages_menu($args['pr_pages']); ?>
        <p>
            <input name="pr_type" id="pr-type" value="page-refresh" type="radio" <?php echo ($args['pr_type'] == 'page-refresh') ? 'checked="checked"' : '' ?>><label>Page Refresh</label>                 
        <p>            
        <p>
            <input name="pr_type" id="pr-type" value="time-limit" type="radio" <?php echo ($args['pr_type'] == 'time-limit') ? 'checked="checked"' : '' ?>><label>Time Limit</label>
            <input class="pr_small_fld" type="text" name="pr_min" id="pr-min" value="<?php echo $args['pr_min']; ?>"> to
            <input class="pr_small_fld" type="text" name="pr_max" id="pr-max" value="<?php echo $args['pr_max']; ?>"><em> - In Minutes</em></p>
        <p>
            <input name="pr_type" id="pr-type" value="per-visit" type="radio" <?php echo ($args['pr_type'] == 'per-visit') ? 'checked="checked"' : '' ?>><label>Per Visit</label>
            <input class="pr_small_fld" type="text" name="pr_cookielife" id="pr-cookielife" value="<?php echo $args['pr_cookielife']; ?>"><em> - In Minutes</em></p>    
        <p>
            <label for="pr">Rotation Sequence</label>
            <select name="pr_sequence" id="pr-sequence">
                <option value="order" <?php echo ($args['pr_sequence'] == 'order') ? 'selected="selected"' : ''; ?>>Order</option>
                <option value="random" <?php echo ($args['pr_sequence'] == 'random') ? 'selected="selected"' : ''; ?>>Random</option>
            </select>                
        </p>
        <div class="submit">
            <input type="submit" class="button-primary" value="Save Changes" />
        </div>            
    </form>
Reference URL's