Need help easy fix I think!

Discussion in 'Programming' started by bbrian017, Oct 13, 2008.

  1. #1
    I'm not too sure is this is php or Java so I'm simply posting it here in the general forums!

    Some how this code adds a vote image to the index page and the single.php

    Can I remove the code that ads the image to the index and keeps only the single.php?

    This is the wp-blogengage.php

    <?php
    
    /*
    
    Plugin Name: WP-Blogengage
    Version: 1.0.2
    Plugin URI: http://www.blogengage.com/profile_promo.php
    Description: Adds a Blogengage vote button to your posts.
    
    
    Author: Blog Engage
    Author URI: http://www.blogengage.com
    */
    
    $message = "";
    
    if (!function_exists('blogeng_request_handler')) {
        function blogeng_request_handler() {
            global $message;
    
            if ($_POST['blogeng_action'] == "update options") {
                $blogeng_align_v = $_POST['blogeng_align_sl'];
    
        		if(get_option("blogeng_box_align")) {
        			update_option("blogeng_box_align", $blogeng_align_v);
        		} else {
        			add_option("blogeng_box_align", $blogeng_align_v);
        		}
    
                $message = '<br clear="all" /> <div id="message" class="updated fade"><p><strong>Option saved. </strong></p></div>';
            }
        }
    }
    
    if(!function_exists('blogeng_add_menu')) {
        function blogeng_add_menu () {
            add_options_page("Blogengage Options", "Blogengage Options", 8, basename(__FILE__), "blogeng_displayOptions");
        }
    }
    
    if (!function_exists('blogeng_displayOptions')) {
        function blogeng_displayOptions() {
    
            global $message;
            echo $message;
    
    		print('<div class="wrap">');
    		print('<h2>Blogengage Options</h2>');
    
            print ('<form name="blogeng_form" action="'. get_bloginfo("wpurl") . '/wp-admin/options-general.php?page=wp-blogengage.php' .'" method="post">');
    ?>
    
    		<p>Align:
            <select name="blogeng_align_sl" id="blogeng_align_sl">
    			<option value="Top Left"   <?php if (get_option("blogeng_box_align") == "Top Left") echo " selected"; ?> >Top Left</option>
    			<option value="Top Right"   <?php if (get_option("blogeng_box_align") == "Top Right") echo " selected"; ?> >Top Right</option>
    			<option value="Bottom Left"  <?php if (get_option("blogeng_box_align") == "Bottom Left") echo " selected"; ?> >Bottom Left</option>
    			<option value="Bottom Right"  <?php if (get_option("blogeng_box_align") == "Bottom Right") echo " selected"; ?> >Bottom Right</option>
    			<option value="None"  <?php if (get_option("blogeng_box_align") == "None") echo " selected"; ?> >None</option>
    		</select><br /><br /> </p>
    
    <?php
    		print ('<p><input type="submit" value="Save &raquo;"></p>');
    		print ('<input type="hidden" name="blogeng_action" value="update options" />');
    		print('</form></div>');
    
        }
    }
    
    
    if (!function_exists('blogeng_blogengagehtml')) {
    	function blogeng_blogengagehtml($float) {
    		global $wp_query;
    		$post = $wp_query->post;
    		$permalink = get_permalink($post->ID);
            $title = urlencode($post->post_title);
    		$blogengagehtml = <<<CODE
    
        <span style="margin: 0px 6px 0px 0px; float: $float;">
    
    <script type="text/javascript" src="http://www.blogengage.com/evb/button.php"></script>
    	</span>
    CODE;
    	return  $blogengagehtml;
    	}
    }
    
    
    if (!function_exists('blogeng_addbutton')) {
    	function blogeng_addbutton($content) {
    
    		if ( !is_feed() && !is_page() && !is_archive() && !is_search() && !is_404() ) {
        		if(! preg_match('|<!--blogengage-->|', $content)) {
        		    $blogeng_align = get_option("blogeng_box_align");
        		    if ($blogeng_align) {
                        switch ($blogeng_align) {
                            case "Top Left":
            		              return blogeng_blogengagehtml("left").$content;
                                  break;
                            case "Top Right":
            		              return blogeng_blogengagehtml("Right").$content;
                                  break;
                            case "Bottom Left":
            		              return $content.blogeng_blogengagehtml("left");
                                  break;
                            case "Bottom Right":
            		              return $content.blogeng_blogengagehtml("right");
                                  break;
                            case "None":
            		              return $content;
                                  break;
                            default:
            		              return blogeng_blogengagehtml("left").$content;
                                  break;
                        }
                    } else {
            		      return blogeng_blogengagehtml("left").$content;
                    }
    
        		} else {
                      return str_replace('<!--blogengage-->', blogeng_blogengagehtml(""), $content);
                }
            } else {
    			return $content;
            }
    	}
    }
    
    if (!function_exists('show_blogengage')) {
    	function show_blogengage($float = "left") {
            global $post;
    		$permalink = get_permalink($post->ID);
    		echo <<<CODE
    
        <span style="margin: 0px 6px 0px 0px; float: $float;">
    
    	<script type="text/javascript">
    	submit_url = "$permalink";
    	</script>
        echo '<script type="text/javascript" src="http://www.blogengage.com/evb/button.php"></script>';
    	</span>
    CODE;
        }
    }
    
    add_filter('the_content', 'blogeng_addbutton', 999);
    add_action('admin_menu', 'blogeng_add_menu');
    add_action('init', 'blogeng_request_handler');
    
    ?>
    Code (markup):
    But what's happening is on the index it's grabbing the .com domains and not the permalink titles of the topic so it's showing 0 votes on all articles if you never submitted your .com website! Technically it should be showing the article submission but I'm not too sure how to fix that! This also means for every article displaued on the index it will show the same votes all the way down seeing it's only referring to the .com and not the actual article.

    I think that's in the url.php

    <?php
    if(empty($_GET['url'])) die;
    @include_once('../libs/dbconnect.php');
    
    $web1 = 'Blog Engage'; //will appear within tooltip
    $web2 = 'Vote'; //will appear on evb
    $db_table = 'pligg_links'; //the name of your links database table
    $server = 'http://www.blogengage.com'; //enter the url to your pligg installation (no trailing slash)
    
    $url = htmlspecialchars(strip_tags($_GET['url']));
    
    $url1 = ""; $url2 = "";
    $slash_check = substr($url, -1);
    if($slash_check == '/') {
    	$url1 = substr($url, 0, -1);
    	$url2 = $url;
    } else {
    	$url1 = $url;
    	$url2 = $url."/";
    }
    
    $connect = @mysql_connect(EZSQL_DB_HOST, EZSQL_DB_USER, EZSQL_DB_PASSWORD);
    $database = @mysql_select_db(EZSQL_DB_NAME, $connect);
    $url1 = @mysql_real_escape_string($url1);
    $url2 = @mysql_real_escape_string($url2);
    $link_query = @mysql_query("SELECT link_id,link_votes FROM $db_table WHERE (link_url=\"$url1\" OR link_url=\"$url2\") AND (link_status='published' OR link_status='queued') LIMIT 1");
    $link_rows = @mysql_num_rows($link_query);
    if($link_rows == 1) {
    	while($row = @mysql_fetch_array($link_query)) {
    		$id = $row['link_id'];
    		$votes = $row['link_votes'];
    	}
    }
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Earners Club EVB</title>
    <style type="text/css">
    body			{ border: 0; margin: 0;	padding: 0; }
    img, img a		{ border: none; }
    .evb
    {
    	background: url(<?php echo $server ?>/evb/img/Vote.gif) top left no-repeat;
    	font-family: Verdana, Arial, Helvetica, sans-serif;
    	font-size: 12px;
    	font-weight: bold;
    	line-height: 14px;
    	margin: 0;
    	padding: 0;
    	white-space: nowrap;
    	width: 90px;
    }
    .evb a,
    .evb a:link		{ color: #fff; text-decoration: none; }
    .evb a:hover	{ color: #3e8505; text-decoration: none; }
    
    .evb_logo		{ float: left; display: inline; position: relative; width: 22px; }
    .evb_data		{ float: right; position: relative; width: 68px; }
    	.evb_num	{ float: left; position: relative; width: 23px; }
    		.evb_number		{ padding: 2px 0 3px; text-align: center; }
    	.evb_vote	{ float: right; position: relative; width: 45px; }
    		.evb_votes		{ padding: 6px 0 4px; text-align: center; }
    .evb:after		{ visibility: hidden; display: block; font-size: 0; content: " "; clear: both; height: 0; }
    .evb			{ display: inline-block; }
    /* start commented backslash hack \*/
    * html .evb		{ height: 1%; }
    .evb			{ display: block; }
    /* close commented backslash hack */
    </style>
    </head>
    <body>
    <div class="evb">
    	<div class="evb_logo">&nbsp;</div>
    	<div class="evb_data">
    		<?php if($link_rows == 1) { ?>
    		<div class="evb_num">
    			<div class="evb_number"><a href="<?php echo $server ?>/story.php?id=<?php echo $id ?>" title="Vote for this story on <?php echo $web1 ?>" target="_blank"><?php echo $votes ?></a></div>
    		</div>
    		<div class="evb_vote">
    			<div class="evb_votes"><a href="<?php echo $server ?>/story.php?id=<?php echo $id ?>" target="_parent"><img src="<?php echo $server ?>/evb/img/Label_Vote.gif" alt="<?php echo $web2 ?>" /></a></div>
    		</div>
    		<?php } else { ?>
    		<div class="evb_num">
    			<div class="evb_number"><a href="<?php echo $server ?>/submit.php?url=<?php echo $url ?>" title="Vote for this story on <?php echo $web1 ?>" target="_blank"><?php echo $votes ?></a></div>
    		</div>
    		<div class="evb_vote">
    			<div class="evb_votes"><a href="<?php echo $server ?>/submit.php?url=<?php echo $url ?>" target="_parent"><img src="<?php echo $server ?>/evb/img/Label_Vote.gif" alt="<?php echo $web2 ?>" /></a></div>
    		</div>
    		<?php } ?>
    	</div>
    </div>
    </body>
    </html>
    Code (markup):
    Now seeing I don't know what to change so the index also picks up the topic article vote amounts (and not .com domains) I was thinking it would be easier to just notdisplay the image all together on the index and only on the single.php

    This is the button.php

    <?php
    
    header('Content-Type: text/javascript; charset=UTF-8');
    header("Expires: " . gmdate("D, d M Y H:i:s", time() + 3600) . " GMT");
    header("Cache-Control: max-age=3600, must-revalidate");
    $server = 'http://www.blogengage.com'; //enter the url to your pligg installation (no trailing slash)
    $url_mod = 0; //change value to 1 if you are having problems with 406 errors, otherwise don't touch!
    ?>
    
    function pliggit() {
    	var check = window.parent.submit_url;
    	if(!check) { 
    		var url1 = document.URL; 
    	} else { 
    		var url1 = window.parent.submit_url; 
    	}
    	<?php if($url_mod == 1) { ?>
    	url1 = url1.replace(/http:\/\//i,'');
    	<?php } ?>
    	var url2 = '<?php echo $server; ?>/evb/url.php?url='+url1;
    	document.write('<iframe name="pliggit" width="90" height="20" scrolling="no" frameborder="0" src="'+url2+'"></iframe>');	
    }
    pliggit();
    Code (markup):
    Well this only adds the code to a blog that will pull the image!

    The code is as follows

    <script type="text/javascript" src="http://www.blogengage.com/evb/button.php"></script>
    Code (markup):
    now that code pulls a file that pulls the image!

    so maybe look at that codes location?

    or find out why it's pulling to the index and single.php

    so you can use a different image by changing the buton1.php, button2.php, button3.php, and button4.php

    Technically this in itself is a wordpress plugin!
     
    bbrian017, Oct 13, 2008 IP
  2. Bohra

    Bohra Prominent Member

    Messages:
    12,573
    Likes Received:
    537
    Best Answers:
    0
    Trophy Points:
    310
    #2
    What image is it ... i mean whats the file named
     
    Bohra, Oct 13, 2008 IP
  3. bbrian017

    bbrian017 Well-Known Member

    Messages:
    2,990
    Likes Received:
    66
    Best Answers:
    0
    Trophy Points:
    170
    #3
    I have also edited the first post again!
     
    bbrian017, Oct 13, 2008 IP
  4. kmap

    kmap Well-Known Member

    Messages:
    2,215
    Likes Received:
    29
    Best Answers:
    2
    Trophy Points:
    135
    #4
    its too vague

    Are you adding and showing the most voted page on WP?

    Regards

    Alex
     
    kmap, Oct 13, 2008 IP
  5. bbrian017

    bbrian017 Well-Known Member

    Messages:
    2,990
    Likes Received:
    66
    Best Answers:
    0
    Trophy Points:
    170
    #5
    I have edited the first post to show more information!
     
    bbrian017, Oct 13, 2008 IP