Jump to content

ammar77

New Members
  • Posts

    5
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

ammar77's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi, i have an error message while running this random link redirection script, this script uses a urls.txt file to select random links.. link structure of urls.txt http://www.yahoo.com http://www.google.com http://www.live.com random.php <? $file = "urls.txt"; $fp = file($file); $urls = $fp[array_rand($fp)]; header("Location: $urls"); ?> error i got: Warning: Cannot modify header information - headers already sent by (output started at /home/user/public_html/random.php:1) in /home/user/public_html/random.php on line 5 kindly do some needful. thanks.
  2. not worked Parse error: syntax error, unexpected T_ELSE in /home/user/public_html/wp-content/themes/default/single.php on line 35
  3. Hi, I have a php code which generates random number if visitor comes to my wordpress blog from yahoo.com (search.yahoo.com) and if the random number is less than 10 then display a welcome message else display normal blog. Or if visitor come to my blog without any referrer or from other sources then dipslay normal blog. but i have parse, syuntax error ehich i couldn't solve, kindly do some favourable.... **code** <?php $match = false; $sites = array("search.yahoo.com"); if(strlen($_SERVER['HTTP_REFERER'])) { $referer = parse_url($_SERVER['HTTP_REFERER']); $referer['host'] = str_replace("www.", "", strtolower($referer['host'])); $match = in_array($referer['host'], $sites); } if($match) { ?> $rand_num = rand(1, 100); if($rand_num < 10) echo "you comes from yahoo, click the link to proceed."; else // if random no. is > 10 then display normal blog // // single.php code below // <?php get_header(); ?> <div id="content" class="widecolumn"> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <div class="navigation"> <div class="alignleft"><?php previous_post_link('« %link') ?></div> <div class="alignright"><?php next_post_link('%link »') ?></div> </div> <div <?php post_class() ?> id="post-<?php the_ID(); ?>"> <h2><?php the_title(); ?></h2> <div class="entry"> <?php the_content('<p class="serif">Read the rest of this entry »</p>'); ?> <?php wp_link_pages(array('before' => '<p><strong>Pages:</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?> <?php the_tags( '<p>Tags: ', ', ', '</p>'); ?> <p class="postmetadata alt"> <small> This entry was posted <?php /* This is commented, because it requires a little adjusting sometimes. You'll need to download this plugin, and follow the instructions: http://binarybonsai.com/archives/2004/08/17/time-since-plugin/ */ /* $entry_datetime = abs(strtotime($post->post_date) - (60*120)); echo time_since($entry_datetime); echo ' ago'; */ ?> on <?php the_time('l, F jS, Y') ?> at <?php the_time() ?> and is filed under <?php the_category(', ') ?>. You can follow any responses to this entry through the <?php post_comments_feed_link('RSS 2.0'); ?> feed. <?php if (('open' == $post-> comment_status) && ('open' == $post->ping_status)) { // Both Comments and Pings are open ?> You can <a href="#respond">leave a response</a>, or <a href="<?php trackback_url(); ?>" rel="trackback">trackback</a> from your own site. <?php } elseif (!('open' == $post-> comment_status) && ('open' == $post->ping_status)) { // Only Pings are Open ?> Responses are currently closed, but you can <a href="<?php trackback_url(); ?> " rel="trackback">trackback</a> from your own site. <?php } elseif (('open' == $post-> comment_status) && !('open' == $post->ping_status)) { // Comments are open, Pings are not ?> You can skip to the end and leave a response. Pinging is currently not allowed. <?php } elseif (!('open' == $post-> comment_status) && !('open' == $post->ping_status)) { // Neither Comments, nor Pings are open ?> Both comments and pings are currently closed. <?php } edit_post_link('Edit this entry','','.'); ?> </small> </p> </div> </div> <?php comments_template(); ?> <?php endwhile; else: ?> <p>Sorry, no posts matched your criteria.</p> <?php endif; ?> </div> <?php get_footer(); ?> ?> <?php } else { ?> // Display normal blog if visitor comes without referrer // // single.php code below // <?php get_header(); ?> <div id="content" class="widecolumn"> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <div class="navigation"> <div class="alignleft"><?php previous_post_link('« %link') ?></div> <div class="alignright"><?php next_post_link('%link »') ?></div> </div> <div <?php post_class() ?> id="post-<?php the_ID(); ?>"> <h2><?php the_title(); ?></h2> <div class="entry"> <?php the_content('<p class="serif">Read the rest of this entry »</p>'); ?> <?php wp_link_pages(array('before' => '<p><strong>Pages:</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?> <?php the_tags( '<p>Tags: ', ', ', '</p>'); ?> <p class="postmetadata alt"> <small> This entry was posted <?php /* This is commented, because it requires a little adjusting sometimes. You'll need to download this plugin, and follow the instructions: http://binarybonsai.com/archives/2004/08/17/time-since-plugin/ */ /* $entry_datetime = abs(strtotime($post->post_date) - (60*120)); echo time_since($entry_datetime); echo ' ago'; */ ?> on <?php the_time('l, F jS, Y') ?> at <?php the_time() ?> and is filed under <?php the_category(', ') ?>. You can follow any responses to this entry through the <?php post_comments_feed_link('RSS 2.0'); ?> feed. <?php if (('open' == $post-> comment_status) && ('open' == $post->ping_status)) { // Both Comments and Pings are open ?> You can <a href="#respond">leave a response</a>, or <a href="<?php trackback_url(); ?>" rel="trackback">trackback</a> from your own site. <?php } elseif (!('open' == $post-> comment_status) && ('open' == $post->ping_status)) { // Only Pings are Open ?> Responses are currently closed, but you can <a href="<?php trackback_url(); ?> " rel="trackback">trackback</a> from your own site. <?php } elseif (('open' == $post-> comment_status) && !('open' == $post->ping_status)) { // Comments are open, Pings are not ?> You can skip to the end and leave a response. Pinging is currently not allowed. <?php } elseif (!('open' == $post-> comment_status) && !('open' == $post->ping_status)) { // Neither Comments, nor Pings are open ?> Both comments and pings are currently closed. <?php } edit_post_link('Edit this entry','','.'); ?> </small> </p> </div> </div> <?php comments_template(); ?> <?php endwhile; else: ?> <p>Sorry, no posts matched your criteria.</p> <?php endif; ?> </div> <?php get_footer(); ?> <?php }
  4. Hi guys, This little code accept only alphabets and numbers but i want to customize it to accept "-" "_" and "." values, kindly help me in this regard..thanks code =============== <? include("config.php"); if (strstr($_SERVER['HTTP_REFERER'], $root)); else { header ("Location: $rooturl"); } $ip = $_SERVER['REMOTE_ADDR']; $url = mysql_real_escape_string($_POST['url']); if(preg_match('|^http(s)?://[a-z0-9-]+(\.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i', $url)) { if (empty($_POST['tag'])) { $query = mysql_query("INSERT INTO $table (ip,url) VALUES ('$ip','$url')") or die('MySQL error: '.mysql_error()); $qs = mysql_insert_id(); } else { if (ereg('^[a-zA-Z0-9]+[a-zA-Z0-9]+$', $_POST['tag'])) { $tag = mysql_real_escape_string($_POST['tag']); $query = mysql_query("select * from $table where `tag` = '$tag';") or die('MySQL error: '.mysql_error()); if (mysql_num_rows($query) != 0) die("This tag has already been taken! Please press the back button on your browser and choose another tag!"); else { $query = mysql_query("insert $table (ip,url,tag) VALUES ('$ip','$url','$tag')") or die('MySQL error: '.mysql_error()); $qs = $tag; } } else die('Your tag consists of invalid characters! Only alphabets and numbers allowed! Please press the back button on your browser and choose another tag!'); } $link = $destination . $qs; require 'create_template.php'; } else echo 'Your URL is invalid'; ?> ===========================
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.