Jump to content

Wolphie

Members
  • Posts

    682
  • Joined

  • Last visited

    Never

Everything posted by Wolphie

  1. Just jumping in here real quick, using a proxy is often slow and it's restricted to the browser/applications that support proxies. I'd recommend going with a secure VPN service and although it may cost a little bit it will encrypt all of the data being sent and received from your entire computer. Anything that you communicate with outside of your local network will be encrypted by the VPN. Not to mention that most VPN services provide 100/1000Mbps connections. Check out http://www.sh3lls.net/, they're VPN service is pretty cheap and they support OpenVPN and PPTP which makes setting it up easy.
  2. The reason why yours wouldn't work is because the update query you were using for the points addition, you didn't use mysql_query() to actually execute the query. Therefore the query wasn't being executed on the server and the database remained unchanged.
  3. Try this: <?php include 'config.php'; if ($link = mysql_connect($dbhost, $dbuser, $dbpasswd)) { if (!mysql_select_db($dbname, $link)) { trigger_error('Could not select the database: ' . mysql_error(), E_USER_ERROR); } } else { trigger_error('Could not connect to the database: ' . mysql_error(), E_USER_ERROR); } if (isset($id)) { $query = "UPDATE league_matchresults SET result_1 = '%s', result_2 = '%s' WHERE id = %d"; $result = mysql_query(sprintf($query, mysql_real_escape_string($result_1), mysql_real_escape_string($result_2), mysql_real_escape_string($id) ), $link ); if ($result !== FALSE) { if ($result_1 >= 3) { $query = "UPDATE league_teamdata SET points = points + 2 WHERE team_1 = '%s'"; $result = mysql_query(sprintf($query, mysql_real_escape_string($team_name)), $link); if ($result !== FALSE) { echo $team_1; } else { trigger_error(mysql_error(), E_USER_ERROR); } } } else { trigger_error(mysql_error(), E_USER_ERROR); } } ?>
  4. No idea how to get votes, but this gets the tags and the authors name: <?php function video_entry($url) { if (strchr($url, 'http://')) { $video_id = parse_url($url, PHP_URL_QUERY); $video_id = str_replace('v=', '', $video_id); } else { $video_id = $url; } // Make the initial API request $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://gdata.youtube.com/feeds/api/videos/' . $video_id); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1); curl_setopt($ch, CURLOPT_PROXY, 'http://emeacache.uk.oracle.com:80'); // Store XML results in a string $result = curl_exec($ch); curl_close($ch); if ($xml = simplexml_load_string($result)) { $count = 0; foreach ($xml->category as $category) { if ($count > 1) { $xml->tags[] = $category[0]['term']; } $count++; } return $xml; } else { die ('An error occurred trying to load XML data.'); } } $video = video_entry('http://www.youtube.com/watch?v=kMAI26FPeyM'); echo $video->title; // Video title echo $video->content; // Description echo $video->published; // date echo $video->tags[0] . ' - ' . $video->tags[1]; // scooter - power echo $video->author->name; // author name ?>
  5. Give this a try. <?php function video_entry($url) { if (strchr($url, 'http://')) { $video_id = parse_url($url, PHP_URL_QUERY); $video_id = str_replace('v=', '', $video_id); } else { $video_id = $url; } // Make the initial API request $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://gdata.youtube.com/feeds/api/videos/' . $video_id); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // Store XML results in a string $result = curl_exec($ch); curl_close($ch); if ($xml = simplexml_load_string($result)) { return $xml; } else { die ('An error occurred trying to load XML data.'); } } $video = video_entry('http://www.youtube.com/watch?v=kMAI26FPeyM'); echo $video->title; // Scooter Power!! ?> You can use either the video id, or the entire URL. e.g. $video = video_entry('kMAI26FPeyM'); // or $video = video_entry('http://www.youtube.com/watch?v=kMAI26FPeyM'); Also if you use print_r on $video, it will give you all of the array and object information returned. E.g. $video = video_entry('http://www.youtube.com/watch?v=kMAI26FPeyM'); echo '<pre>'; print_r($video); echo '</pre>'; will return: SimpleXMLElement Object ( [id] => http://gdata.youtube.com/feeds/api/videos/kMAI26FPeyM [published] => 2010-08-22T08:24:02.000Z [updated] => 2010-08-23T09:15:57.000Z [category] => Array ( [0] => SimpleXMLElement Object ( [@attributes] => Array ( [scheme] => http://schemas.google.com/g/2005#kind [term] => http://gdata.youtube.com/schemas/2007#video ) ) [1] => SimpleXMLElement Object ( [@attributes] => Array ( [scheme] => http://gdata.youtube.com/schemas/2007/categories.cat [term] => Entertainment [label] => Entertainment ) ) [2] => SimpleXMLElement Object ( [@attributes] => Array ( [scheme] => http://gdata.youtube.com/schemas/2007/keywords.cat [term] => scooter ) ) [3] => SimpleXMLElement Object ( [@attributes] => Array ( [scheme] => http://gdata.youtube.com/schemas/2007/keywords.cat [term] => power ) ) ) [title] => Scooter Power!! [content] => sp [link] => Array ( [0] => SimpleXMLElement Object ( [@attributes] => Array ( [rel] => alternate [type] => text/html [href] => http://www.youtube.com/watch?v=kMAI26FPeyM&feature=youtube_gdata ) ) [1] => SimpleXMLElement Object ( [@attributes] => Array ( [rel] => http://gdata.youtube.com/schemas/2007#video.responses [type] => application/atom+xml [href] => http://gdata.youtube.com/feeds/api/videos/kMAI26FPeyM/responses ) ) [2] => SimpleXMLElement Object ( [@attributes] => Array ( [rel] => http://gdata.youtube.com/schemas/2007#video.related [type] => application/atom+xml [href] => http://gdata.youtube.com/feeds/api/videos/kMAI26FPeyM/related ) ) [3] => SimpleXMLElement Object ( [@attributes] => Array ( [rel] => http://gdata.youtube.com/schemas/2007#mobile [type] => text/html [href] => http://m.youtube.com/details?v=kMAI26FPeyM ) ) [4] => SimpleXMLElement Object ( [@attributes] => Array ( [rel] => self [type] => application/atom+xml [href] => http://gdata.youtube.com/feeds/api/videos/kMAI26FPeyM ) ) ) [author] => SimpleXMLElement Object ( [name] => josdoming [uri] => http://gdata.youtube.com/feeds/api/users/josdoming ) )
  6. These are the headers I use when I generate a CSV file. // Set the appropriate headers to tell the browser that it's a file to downlaod header('Content-Type: application/octet-stream'); header('Content-Description: File Transfer'); header('Content-Disposition: attachment; filename="'. $filename .'"'); header('Pragma: no-cache'); header('Expires: 0'); Just simply echo out the data after that and that will be the contents of the CSV file. I can't help you further without viewing your code.
  7. http://www.devarticles.com/c/a/PHP/Creating-a-MultiFile-Upload-Script-in-PHP/
  8. You're getting these errors because the key indexes you are using don't exist within the $_SERVER array. $postcardURL = "http://".$_SERVER["www.voluntary.awardspace.co.uk"].$_SERVER["Postcard.php"]; It should be: $postcardURL = 'http://www.voluntary.awardspace.co.uk/Postcard.php';
  9. Give this a try: <?php $path = 'path/to/dir'; if (is_dir($path)) { $contents = scandir($path); foreach ($contents as $file) { $full_path = $path . DIRECTORY_SEPARATOR . $file; if ($file != '.' && $file != '..') { if (is_dir($full_path)) { $dirs[filemtime($full_path)] = $file; } } } // Sort in reverse order to put newest modification at the top krsort($dirs); $iteration = 0; foreach ($dirs as $mtime => $name) { if ($iteration != 5) { echo $name . '<br />'; } $iteration++; } } ?>
  10. I've modified it a little bit and tested it, it works perfectly fine for me. <?php $filename = 'ip_collection.txt'; if (isset($_POST['submit'])) { if (!empty($_POST['firstName'])) { $first_name = trim($_POST['firstName']); } else { $errors[] = 'Please enter your first name.'; } if (!empty($_POST['lastName'])) { $last_name = trim($_POST['lastName']); } else { $errors[] = 'Please enter your last name.'; } if (empty($errors)) { if (is_writable($filename)) { // Get the contents of the file $contents = file_get_contents($filename); if ($fp = fopen($filename, 'w')) { $ip_addr = $_SERVER['REMOTE_ADDR']; if (filter_var($ip_addr, FILTER_VALIDATE_IP)) { $name_ip = $first_name . ', ' . $last_name . ' | ' . $ip_addr; // Sort alphabetically $output = explode("\n", $contents . "\n" . $name_ip); sort($output); // Put sorted contents of array back into a string $contents = implode("\n", $output); if (fwrite($fp, $contents) === FALSE) { die('Could not write to file: ' . $filename); } fclose($fp); } else { die('Invalid IP address.'); } } else { die('Could not open the file: ' . $filename); } } else { die('The file ' . $filename . ' is not writable.'); } } else { echo '<ul>'; foreach ($errors as $error) { echo '<li>' . $error . '</li>'; } echo '</ul>'; } } ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <input type="text" name="firstName" /> <input type="text" name="lastName" /> <input type="submit" name="submit" /> </form>
  11. Can you provide an example of what the "ip_collection.txt" file would contain?
  12. Try this, although I haven't tested it. It's quite difficult to work with since I don't know what the variable "$textFromFile" contains. <?php $filename = 'ip_collection.txt'; if (isset($_POST['submit'])) { if (!empty($_POST['firstName'])) { $first_name = trim($_POST['firstName']); } else { $errors[] = 'Please enter your first name.'; } if (!empty($_POST['lastName'])) { $last_name = trim($_POST['lastName']); } else { $errors[] = 'Please enter your last name.'; } if (empty($errors)) { if ($fp = fopen($filename, 'a+')) { $ip_addr = $_SERVER['REMOTE_ADDR']; if (filter_var($ip_addr, FILTER_VALIDATE_IP)) { $name_ip = $first_name . ', ' . $last_name . ' | ' . $ip_addr; // Sort alphabetically $output = explode("\n", $textFromFile . $name_ip); sort($output); // Put sorted contents of array back into a string $contents = implode("\n", $output); if (!fwrite($fp, $contents)) { die('Could not write to file: ' . $filename); } fclose($fp); } else { die('Invalid IP address.'); } } else { die('Could not open the file: ' . $filename); } } else { echo '<ul>'; foreach ($errors as $error) { echo '<li>' . $error . '</li>'; } echo '</ul>'; } } ?>
  13. Give this a try: <?php include 'includes/connection.php'; // Set a directory separator as a constant // for accessibility and compatibility define('DS', DIRECTORY_SEPARATOR); // Set web address $web_addr = 'prints2impress.co.uk'; if (isset($_POST['username']) && !empty($_POST['username'])) { $username = trim($_POST['username']); } else { $errors[] = 'Please enter a username.'; } // Change timezone to GMT date_default_timezone_set('Europe/London'); // Set new date format $date = date('D M j G:i:s'); if (isset($_FILES['ufile'])) { $filename = trim($_FILES['ufile']['name']); } else { $errors[] = 'Please select a file.'; } if (!empty($errors)) { // Path for the file copy to server $path = $_SERVER['DOCUMENT_ROOT'] . DS . $web_addr . DS . '/images/uploads' . $filename; if (copy($_FILES['ufile']['tmp_name'], $path)) { $sql = sprintf("INSERT INTO `uploads` ( `username`, `url`, `date_entered` ) VALUES ( '%s', '%s', '%s' )", mysql_real_escape_string($username), mysql_real_escape_string($filename), mysql_real_escape_string($date)); $result = mysql_query($sql); if ($result !== FALSE) { //include 'payment.php'; echo 'Done'; } else { die('Invalid query: ' . mysql_error()); } } } else { echo '<ul>'; foreach ($errors as $error) { echo '<li>' . $error . '</li>'; } echo '</ul>'; } ?>
  14. It would help if we saw your code.
  15. <?php $string = "House Full 2010 Hindi Movie Watch Online : Dailymotions Video Link : Alternative Link :"; $string = str_replace(':', '', $string); echo $string; // Result is: House Full 2010 Hindi Movie Watch Online Dailymotions Video Link Alternative Link ?>
  16. You can assign variables in a heredoc statement. <?php $subject = 'media-ondemand-contact.php'; $web_master = 'alextrashacc@hotmail.com'; $email = trim($_POST['email']); $name = trim($_POST['name']); $radio = trim($_POST['radiobuttons']); $where = trim($_POST['where']); $comments = trim($_POST['comments']); $newsletter = trim($_POST['newsletter']); $body = <<<EOD <br /><hr /><br /> E-mail: $email <br /> Name: $name <br /> Suggestions Etc: $radiobuttons <br /> Where did you hear about us: $where <br /> Comments: $comments <br /> Newsletter Sign-up: $newsletter EOD; $headers = $email . "\r\n"; $headers .= "Content-type: text/html\r\n"; $success = <<<EOD <html> <head> <meta http-equiv="refresh" content="3;//media-ondemand.com"> <title>Sent Message</title> <style type="text/css"> <!-- body { text-align: center; font-family: Verdana, Geneva, sans-serif; font-size: 36px; font-weight: bold; font-variant: normal; color: #666; } --> </style> </head> <body> <p>Thank You</p> <p> Your Message Has Been Sent </p> </body> </html> EOD; if (mail($web_master, $subject, $body, $headers) !== FALSE) { echo $success; } ?>
  17. $tickbox1 = array_key_exists('tickbox1', $_POST) ? 1 : 0; This basically checks to see if the 'tickbox1' key index has been set within the $_POST array. If it has, then set $tickbox1 to 1 (which it would be anyway), otherwise set it to zero if it hasn't been set.
  18. http://php.net/manual/en/function.eval.php
  19. Add a class to the cell and use this CSS: td.cell { max-width: 100px; word-wrap: break-word; } You can make the cell width any value you like.
  20. You shouldn't be encapsulating variables/objects in quotes anyway. $postvals[$result->field_name] = implode(',', $_POST[$result->field_name]);
  21. http://php.net/manual/en/book.simplexml.php should get you started.
  22. Try this: <?php function sprintify($args) { global $urls; $args = func_get_args(); $input = array_shift($args); return vsprintf($urls[$input], $args); } echo sprintify('default', 46, 464, 46); ?>
  23. I would suggest you remove all occurrences of return; since it isn't being used within a function.
  24. Try this: <!DOCTYPE html> <html lang="en"> <head> <meta charset=utf-8 /> <title>What ever you want your title to be!</title> <link rel="stylesheet" href="path/to/stylesheet" type="text/css" /> </head> <body> <?php $error = '<div id="conn_error">Error connecting to the database!</div>'; // Try making connection to the database $link = mysql_connect($host, $user, $pass); if ($link === FALSE) { echo $error; } else { // Connection succeeded; select the database or do what ever mysql_select_db('db_name', $link); } ?> </body> </html>
  25. Just out of curiosity, is there anymore code to this file? Also this line: $q = "UPDATE `tbl_hosting_domain` SET (ip = '$ip', ns1 = '$ns1', ns2 = '$ns2', ftpaddress = '$ftpserver', ftpuname = '$ftpuname', ftppword = '$ftppword', pop = '$pop', smtp = '$smtp', webmailaddress = '$webmailaddy', diskspace = '$adiskspace', bandwidth = '$ambw', nummailboxes = '$amboxes', mailboxquota = '$amboxesquota', numdatabases = '$adbases', exp = '$exp' WHERE cname='$idcname'"; Should be: $q = "UPDATE `tbl_hosting_domain` SET ip = '$ip', ns1 = '$ns1', ns2 = '$ns2', ftpaddress = '$ftpserver', ftpuname = '$ftpuname', ftppword = '$ftppword', pop = '$pop', smtp = '$smtp', webmailaddress = '$webmailaddy', diskspace = '$adiskspace', bandwidth = '$ambw', nummailboxes = '$amboxes', mailboxquota = '$amboxesquota', numdatabases = '$adbases', exp = '$exp' WHERE cname='$idcname'";
×
×
  • 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.