Jump to content

myscripting

New Members
  • Posts

    8
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

myscripting's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I have two scripts. One is a tinyurl API and the other gnerates random strings. What I want to do it pass a random string into the tiny URL API script such that the tiny URL generated is always different <?php function createRandomPassword() { $chars = "abcdefghijkmnopqrstuvwxyz023456789"; srand((double)microtime()*1000000); $i = 0; $pass = '' ; while ($i <= 7) { $num = rand() % 33; $tmp = substr($chars, $num, 1); $pass = $pass . $tmp; $i++; } return $pass; } // Usage $password = createRandomPassword(); ?> <?php //gets the data from a URL function get_tiny_url($url) { $ch = curl_init(); $timeout = 5; curl_setopt($ch,CURLOPT_URL,'http://tinyurl.com/api-create.php?url='.$url); curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout); $data = curl_exec($ch); curl_close($ch); return $data; } //test it out! $new_url = get_tiny_url('http://domain.com/?password); echo $new_url ?> where it says http://domain.com/?password i want the password value in the first script to be passed before a tiny url is generated thanks
  2. i tried it and i wonder why i'm getting a 500 Servlet Exception error. do I need to pass cookies?
  3. Can you create a php script that executes or visits a set of dynamic urls such as http://www.mysite.com/blah&u=y http://www.mysite.com/blah&u=y+1 http://www.mysite.com/blah&u=y+2 http://www.mysite.com/blah&u=y+3 . . . http://www.mysite.com/blah&u=x a range y though x? and with a delay of n seconds between urls? thanks PS i know it's something link this: http://www.askapache.com/php/curl-multi-downloads.html but how do you do it for an arbitrary range array?
  4. I read the tutorial http://www.phpfreaks.com/tutorial/basic-pagination do how do I break the results such that it resembles google? I'm sure it involves something like this: I tried pasting it into my original code but it made no difference ****** build the pagination links ******/ // range of num links to show $range = 3; // if not on page 1, don't show back links if ($currentpage > 1) { // show << link to go back to page 1 echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=1'><<</a> "; // get previous page num $prevpage = $currentpage - 1; // show < link to go back to 1 page echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$prevpage'><</a> "; } // end if // loop to show links to range of pages around current page for ($x = ($currentpage - $range); $x < (($currentpage + $range) + 1); $x++) { // if it's a valid page number... if (($x > 0) && ($x <= $totalpages)) { // if we're on current page... if ($x == $currentpage) { // 'highlight' it but don't make a link echo " [<b>$x</b>] "; // if not current page... } else { // make it a link echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$x'>$x</a> "; } // end else } // end if } // end for // if not on last page, show forward and last page links if ($currentpage != $totalpages) { // get next page $nextpage = $currentpage + 1; // echo forward link for next page echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$nextpage'>></a> "; // echo forward link for lastpage echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$totalpages'>>></a> "; } // end if /****** end build pagination links ******/
  5. I have this RSS parsing code and it paginates , but only uses next and previous links instead of how google does it. I want it to read like this: first 1 2 3.... last <?php require_once('simplepie.inc'); // Set your own configuration options as you see fit. $feed = new SimplePie(); $feed->set_feed_url(array( 'http://feeds2.feedburner.com/MishsGlobalEconomicTrendAnalysis', 'http://feeds.feedburner.com/TheBigPicture', 'http://feeds2.feedburner.com/ChartsAndCoffee', 'http://feeds.feedburner.com/typepad/tradeblogs/the_slope_of_hope_with_ti', )); $success = $feed->init(); // Make sure the page is being served with the right headers. $feed->handle_content_type(); // Set our paging values $start = (isset($_GET['start']) && !empty($_GET['start'])) ? $_GET['start'] : 0; // Where do we start? $length = (isset($_GET['length']) && !empty($_GET['length'])) ? $_GET['length'] : 5; // How many per page? $max = $feed->get_item_quantity(); // Where do we end? // When we end our PHP block, we want to make sure our DOCTYPE is on the top line to make // sure that the browser snaps into Standards Mode. ?><!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" xml:lang="en-US" lang="en-US"> <head> <title>SimplePie: Demo</title> <link rel="stylesheet" href="styles.css" type="text/css" media="screen, projector" /> </head> <body> <div id="site"> <?php // If we have an error, display it. if ($feed->error()) { echo '<div class="sp_errors">' . "\r\n"; echo '<p>' . htmlspecialchars($feed->error()) . "</p>\r\n"; echo '</div>' . "\r\n"; } ?> <?php if ($success): ?> <?php // get_items() will accept values from above. foreach($feed->get_items($start, $length) as $item): $feed = $item->get_feed(); ?> <div class="chunk"> <h4><?php if ($item->get_permalink()) echo '<a href="' . $item->get_permalink() . '">'; echo $item->get_title(true); if ($item->get_permalink()) echo '</a>'; ?></h4> <p class="footnote">Source: <a href="<?php echo $feed->get_permalink(); ?>"><?php echo $feed->get_title(); ?></a> | <?putenv("TZ=US/Pacific"); echo $item->get_date('j M Y | g:i a'); ?></p> </div> <?php endforeach; ?> <?php endif; ?> <?php // Let's do our paging controls $next = (int) $start + (int) $length; $prev = (int) $start - (int) $length; // Create the NEXT link $nextlink = '<a href="?start=' . $next . '&length=' . $length . '">Next »</a>'; if ($next > $max) { $nextlink = 'Next »'; } // Create the PREVIOUS link $prevlink = '<a href="?start=' . $prev . '&length=' . $length . '">« Previous</a>'; if ($prev < 0 && (int) $start > 0) { $prevlink = '<a href="?start=0&length=' . $length . '">« Previous</a>'; } else if ($prev < 0) { $prevlink = '« Previous'; } // Normalize the numbering for humans $begin = (int) $start + 1; $end = ($next > $max) ? $max : $next; ?> <p>Showing <?php echo $begin; ?>–<?php echo $end; ?> out of <?php echo $max; ?> | <?php echo $prevlink; ?> | <?php echo $nextlink; ?> | <a href="<?php echo '?start=' . $start . '&length=5'; ?>">5</a>, <a href="<?php echo '?start=' . $start . '&length=10'; ?>">10</a>, or <a href="<?php echo '?start=' . $start . '&length=20'; ?>">20</a> at a time.</p> </div> </body> </html>
  6. Any ideas of what such a code would look like or a program that can do it?
  7. if you go to the website http://bluechipbluedog.blgospot.com you will see a blogroll that contains the title, picture, and snipets for each blog in its blog roll Is there any way of getting the code so I can do this for my non-blogspot website?
  8. I have a text file of email addresses that is all squished together. It looks like this: [email protected]@[email protected]@mail.net... What I want to do is insert a paragraph after every instance of "com" or "net" etc so I can read it as a list like this: [email protected] [email protected] [email protected] [email protected] thanks
×
×
  • 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.