Jump to content

andrew_biggart

Members
  • Posts

    363
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by andrew_biggart

  1. Surely it's as simple as including your header and footer files? Look at single.php and use it as a template. Just replace the Wordpress loop, with what ever content you want to appear on that page.
  2. Why are you even allowing exe files to be uploaded? This can be avoiding easily...
  3. I've re-typed it, and it's working now. I think it might have been a caching issue. Dam Google chrome! <?php $today = date("Y-m-d"); $week = date("Y-m-d",strtotime("+1 week")); $sql1 = "SELECT * FROM jobsT WHERE job_status = 'Accepted' AND job_deadline BETWEEN '$today' AND '$week'"; $result1 = mysql_query($sql1); ?>
  4. Sorry, that's a typo. It's actually job_status. But thats's still not pulling any records through...
  5. I'm trying to add an additional parameter to the WHERE statement, which will only select jobs with a status of 'Accepted' and are within the next week. However when I add this parameter, it returns no results. i have checked, and there is definitely jobs which should be show. What am I doing wrong? <?php $today = date("Y-m-d"); $week = date("Y-m-d",strtotime("+1 week")); $sql1 = " SELECT * FROM jobsT WHERE job status = 'Accepted' AND job_deadline BETWEEN '$today' AND '$week'"; $result1 = mysql_query($sql1); ?>
  6. School boy syntax error. It's working now. <?php $today = date("Y-m-d"); $week = date("Y-m-d",strtotime("+1 week")); $sql = " SELECT * FROM jobsT WHERE job_deadline BETWEEN '$today' AND '$week'"; $result = mysql_query($sql); ?>
  7. I thought this would do it, but it isn't pulling out any records. <?php $today = date("Y-m-d"); $week = date("Y-m-d",strtotime("+1 week")); $sql = " SELECT * FROM jobsT WHERE job_deadline BETWEEN $today AND $week"; $result = mysql_query($sql); ?>
  8. I'm struggling to get my head around the logic of this, and wondering if someone can point me in the right direction. Overview What I'm trying to do is query the database and get all records which have a date which falls within the next week. Can anyone point me in the right direction?
  9. Hello, I created a simple login script with password hashing a while back here : https://github.com/andrewbiggart/phppass. It's slightly outdated, but might be useful, and fit your requirements. A
  10. I've made a few teaks and added this to Github incase anyone wants it. https://github.com/andrewbiggart/instafeed
  11. I've modified the code so that it only displays 20 images. It will create four different unordered lists which you can style however you want. <?php function getFollowgram() { $url = "http://instagram.com/tags/nfl/feed/recent.rss"; $s = file_get_contents($url); $ar = array(); $count = 0; $stop = 0; $limit = 20; // Limit the results $open = "<ul class=\"instagram\">"; // Set html wrapper class preg_match_all('#<item>(.*)</item>#Us', $s, $items); echo $open; // Open html wrapper for($i=0;$i<count($items[1]);$i++) { if($stop != $limit){ $item = $items[1][$i]; preg_match_all('#<link>(.*)</link>#Us', $item, $temp); $link = $temp[1][0]; preg_match_all('#<pubDate>(.*)</pubDate>#Us', $item, $temp); $date = date("d-m-Y H:i:s",strtotime($temp[1][0])); preg_match_all('#<title>(.*)</title>#Us', $item, $temp); $title = $temp[1][0]; preg_match_all('#<img src="([^>]*)">#Us', $item, $temp); $thumb = $temp[1][0]; $ar['date'][$i] = $date; $ar['image'][$i] = str_replace("_5.jpg","_6.jpg",$thumb); $ar['bigimage'][$i] = str_replace("_5.jpg","_7.jpg",$thumb); $ar['link'][$i] = $link; $ar['title'][$i] = $title; if($count != 5){ echo '<li><a href="' . $ar['link'][$i] . '" title="' . $ar['title'][$i] .'" target="_blank"><img src="' . $ar['link'][$i] .'" alt="' . $ar['title'][$i] .'"/></a></li>'; $count ++; } else { echo '</ul>' . $open .'<li><a href="' . $ar['link'][$i] . '" title="' . $ar['title'][$i] .'" target="_blank"><img src="' . $ar['link'][$i] .'" alt="' . $ar['title'][$i] .'"/></a></li>'; $count = 0; } $stop ++; } } echo "</ul>"; // Close html wrapper } getFollowgram(); ?> I've started some basic styling for you as well to resize the images. <style> .instagram { width:550px; margin:0; padding:0; list-style:none; } .instagram li { float:left; margin:0 10px 10px 0; } .instagram li a img { width:100px; } </style>
  12. So I clearly didn't read what you wrote. However I've modified the script to pull most recent instagram shots from public users. <?php function getFollowgram() { $url = "http://instagram.com/tags/nhl/feed/recent.rss"; $s = file_get_contents($url); preg_match_all('#<item>(.*)</item>#Us', $s, $items); $ar = array(); for($i=0;$i<count($items[1]);$i++) { $item = $items[1][$i]; preg_match_all('#<link>(.*)</link>#Us', $item, $temp); $link = $temp[1][0]; preg_match_all('#<pubDate>(.*)</pubDate>#Us', $item, $temp); $date = date("d-m-Y H:i:s",strtotime($temp[1][0])); preg_match_all('#<title>(.*)</title>#Us', $item, $temp); $title = $temp[1][0]; preg_match_all('#<img src="([^>]*)">#Us', $item, $temp); $thumb = $temp[1][0]; $ar['date'][$i] = $date; $ar['image'][$i] = str_replace("_5.jpg","_6.jpg",$thumb); $ar['bigimage'][$i] = str_replace("_5.jpg","_7.jpg",$thumb); $ar['link'][$i] = $link; $ar['title'][$i] = $title; echo '<a href="' . $ar['link'][$i] . '" title="' . $ar['title'][$i] .'" target="_blank"><img src="' . $ar['link'][$i] .'" alt="' . $ar['title'][$i] .'"/></a>'; } } getFollowgram(); ?>
  13. This is the method I used to display my latest instagram snaps on my portfolio. Although videos are a no no at the minute. It will just display the cover photo instead. Firstly register with http://followgram.me/. Next add this script were you want the images to appear, change the username and edit the html to fit into your site. <?php function getFollowgram($u) { $url = "http://followgram.me/" . $u . "/rss"; $s = file_get_contents($url); preg_match_all('#<item>(.*)</item>#Us', $s, $items); $ar = array(); for($i=0;$i<count($items[1]);$i++) { $item = $items[1][$i]; preg_match_all('#<link>(.*)</link>#Us', $item, $temp); $link = $temp[1][0]; preg_match_all('#<pubDate>(.*)</pubDate>#Us', $item, $temp); $date = date("d-m-Y H:i:s",strtotime($temp[1][0])); preg_match_all('#<title>(.*)</title>#Us', $item, $temp); $title = $temp[1][0]; preg_match_all('#<img src="([^>]*)">#Us', $item, $temp); $thumb = $temp[1][0]; $ar['date'][$i] = $date; $ar['image'][$i] = str_replace("_5.jpg","_6.jpg",$thumb); $ar['bigimage'][$i] = str_replace("_5.jpg","_7.jpg",$thumb); $ar['link'][$i] = $link; $ar['title'][$i] = $title; echo '<a href="' . $ar['bigimage'][$i] . '" title="' . $ar['title'][$i] .'" target="_blank"><img src="' . $ar['image'][$i] .'" alt="' . $ar['title'][$i] .'"/></a>'; } } getFollowgram(andrew_biggart); ?> Bob's your uncle. BOOM!
  14. Jaxxman1 you're my hero. I had to remove the debug.php part, but it worked a treat. Thanks so much for your help. RewriteEngine On RewriteCond %{REQUEST_URI} ^/blog/$ RewriteCond %{QUERY_STRING} ^tag=([a-z]+)/page/([0-9]+)/$ RewriteRule ^(.*)$ http://example.co.uk/blog/?tag=%1&paged=%2 [R,L]
  15. jazzman1 What is your local setup? Apache or FastCGI? The links are in the following format. http://example.co.uk/blog/?tag=facebook/page/5/ They also have integers which can vary. The live url link is as follows if you want to check it out. http://peppermintsoda.co.uk/blog/
  16. Amended issue. I've been trying to fix this problem for 3 days and can't find the answer so I'm hopeful someone will be able to shed some light on this. I am looking to dynamically re-write URLs as permanent 301 re-directs for SEO purposes using .htaccess. I'm looking to change the following: OLD URL EXAMPLE: http://example.co.uk/blog/?tag=facebook/page/5/ OLD URL EXAMPLE: http://example.co.uk/blog/?tag=twitter/page/2/ OLD URL EXAMPLE: http://example.co.uk/blog/?tag=google/page/12/ to NEW URL: http://example.co.uk/blog/?tag=facebook&paged=5 NEW URL: http://example.co.uk/blog/?tag=twitter&paged=2 NEW URL: http://example.co.uk/blog/?tag=google&paged=12 I need to be able to re-use two dynamic properties, the tag e.g.('facebook') and the pagination number e.g.('5') for each url request that comes in as these could be different with each request. The reason for this is because we are trying to resolve 404 errors from our old wordpress blog that didn't use pagination, just 'next' and 'previous', which displayed as '/page/5'. The new blog uses pagination which displays as '&paged=5'. This is an example of what I've tried. RewriteEngine On RewriteCond %{REQUEST_URI} ^/blog/$ RewriteCond %{QUERY_STRING} ^tag=([a-z]+)/page/([0-9])$ RewriteRule ^(.*)$ http://example.co.uk/blog/?tag=%1&paged=%2 [R,L] PHP is running as CGI, and can't change to apache, causes lots of permission issues across the site. I've tried a number of combinations of RewriteRules, RewriteConds and %{QUERY_STRING} requests and still no joy. Any help with this would be greatly appreciated!
  17. Yes this is exactly what I'm trying to do. jazzman1 Your suggested method didn't redirect as expected. It just forwarded me to a 404 page...
  18. I've been trying to fix this problem for 3 days and can't find the answer so I'm hopeful someone will be able to shed some light on this. I am looking to dynamically re-write URLs as permanent 301 re-directs for SEO purposes using .htaccess. I'm looking to change the following: OLD URL EXAMPLE: http://example.co.uk/blog/?tag=facebook/page/5/ OLD URL EXAMPLE: http://example.co.uk/blog/?tag=twitter/page/2/ OLD URL EXAMPLE: http://example.co.uk/blog/?tag=google/page/12/ to NEW URL: http://example.co.uk/blog/?tag=facebook&paged=5 NEW URL: http://example.co.uk/blog/?tag=twitter&paged=2 NEW URL: http://example.co.uk/blog/?tag=google&paged=12 I need to be able to re-use two dynamic properties, the tag e.g.('facebook') and the pagination number e.g.('5') for each url request that comes in as these could be different with each request. I've tried a number of combinations of RewriteRules, RewriteConds and %{QUERY_STRING} requests and still no joy. Any help with this would be greatly appreciated!
  19. To set: $_SESSION["uid"] = "Your value"; To retrieve: echo $_SESSION["uid"];
  20. It's fine, it was just me being stupid. I've moved the script to the very top of the page and used variables to output any errors. Thanks Andrew
  21. Hi worldcom, I have recently been working on a login script for my applications. I have created a login / account application using phpass for password hashing to help keep it secure. It's by no means water tight or completed, but you might find it useful. I have started to move this application to github, but haven't had time to create the instructions yet so apologies for that. But everything should be there that you need. Have a look as it might be useful for you. https://github.com/andrewbiggart/phppass Andrew
  22. Ok so I know this is a popular error and I've experienced it many times before, but it's driving me crazy and I can't find a solution. So i thought a fresh pair of eyes might be able to shed some light on it. I'm just re-writing this particular piece of code and not changing a great deal. It works fine on the old page, but not on the new one. I haven't changed anything apart from stripping it right back to the basics. I have included my config file at the top of the page. <?php // Turn php errors on / off $errors = true; if($errors){ ini_set('display_errors',1); error_reporting(E_ALL); } // Get the redirect if(isset($_GET['redirect'])){ $redirect = htmlspecialchars($_GET['redirect']); } if(isset($_COOKIE['authcode']) && isset($_COOKIE['userid'])){ // Get the auth code $authcode = htmlspecialchars($_COOKIE['authcode']); // Get the user id $userid = htmlspecialchars($_COOKIE['userid']); // Check auth code and user id against the database $sql = "SELECT * FROM staff_newT WHERE staff_id = '$userid' AND staff_authcode = '$authcode'"; $result = mysql_query($sql); $count = mysql_num_rows($result); if($count == 1){ echo "Both match <br /><br />"; } else { echo "Deleted <br /><br />"; // Delete authcode cookie. setcookie("authcode", "", time() - 3600); } // Check if the authcode and user id exist in the database } ?>
  23. I am currently trying to create an image uploading script that resizes the image if it over 570 pixels wide and saves the orignal image plus two different sized copies. I have got the script recreating jpg and png images, however when I upload a gif image the sized image no longer have a transparent background, they have a black background. Can anyone advise me what I am doing wrong please? <?php session_start(); $upload_dir = 'uploads/'; $medium_dir = 'medium/'; $thumbs_dir = 'thumbs/'; $medium_width = 570; $thumb_width = 50; $allowed_ext = array('jpg','jpeg', 'png','gif'); date_default_timezone_set('Europe/Dublin'); $unique_id = date("YmdHis"); $unique_id = $unique_id . rand(0,999999999); if(strtolower($_SERVER['REQUEST_METHOD']) != 'post'){ exit_status('Error! Wrong HTTP method!'); } if(array_key_exists('pic',$_FILES) && $_FILES['pic']['error'] == 0 ){ $file_tmp = $_FILES['pic']['tmp_name']; $file_name = $_FILES['pic']['name']; $file_size = $_FILES['pic']['size']; $file_ext = get_extension($_FILES['pic']['name']); $file_new = $unique_id . "." . $file_ext; $createdby = $_SESSION["ufullname"]; if(!in_array(get_extension($file_name),$allowed_ext)){ exit_status('Only '.implode(',',$allowed_ext).' files are allowed!'); } // Check the width of the uploaded image list($file_width,$file_height) = getimagesize($file_tmp); if($file_width > $medium_width) { // Move the uploaded file from the temporary // directory to the uploads folder: if(move_uploaded_file($file_tmp, $upload_dir . $file_new)){ include('functions.php'); connect(); $link = get_option('admin_url'); $sql = " INSERT into mediaT ( name, url, link, createdon, createdby ) VALUES ( '$name', '$upload_dir$file_new', '$link$upload_dir$file_new', NOW(), '$createdby' ) "; $result = mysql_query($sql); if($result) { if($file_ext == "jpg" || $file_ext == "jpeg" ){ $src = imagecreatefromjpeg($upload_dir . $file_new); } else if($file_ext == "png"){ $src = imagecreatefrompng($upload_dir . $file_new); } else if($file_ext == "gif"){ $src = imagecreatefromgif($upload_dir . $file_new); } //Create medium image. $file_height_medium = ($file_height/$file_width) * $medium_width; $medium_image = imagecreatetruecolor($medium_width,$file_height_medium); //Create small image. $file_height_thumb = ($file_height/$file_width) * $thumb_width; $thumb_image = imagecreatetruecolor($thumb_width,$file_height_thumb); if($file_ext == "jpg" || $file_ext == "jpeg" ){ imagecopyresized($medium_image,$src,0,0,0,0,$medium_width,$file_height_medium,$file_width,$file_height); imagecopyresized($thumb_image,$src,0,0,0,0,$thumb_width,$file_height_thumb,$file_width,$file_height); imagejpeg($medium_image,$upload_dir . $medium_dir . $file_new,100); imagejpeg($thumb_image,$upload_dir . $thumbs_dir . $file_new,100); } else if($file_ext == "png"){ imagesavealpha($medium_image, true); imagesavealpha($thumb_image, true); $color = imagecolorallocatealpha($medium_image,0x00,0x00,0x00,127); $color2 = imagecolorallocatealpha($thumb_image,0x00,0x00,0x00,127); imagefill($medium_image, 0, 0, $color); imagefill($thumb_image, 0, 0, $color2); imagecopyresized($medium_image,$src,0,0,0,0,$medium_width,$file_height_medium,$file_width,$file_height); imagecopyresized($thumb_image,$src,0,0,0,0,$thumb_width,$file_height_thumb,$file_width,$file_height); imagepng($medium_image,$upload_dir . $medium_dir . $file_new); imagepng($thumb_image,$upload_dir . $thumbs_dir . $file_new); } else if($file_ext == "gif"){ imagesavealpha($medium_image, true); imagesavealpha($thumb_image, true); $color = imagecolorallocatealpha($medium_image,0x00,0x00,0x00,127); $color2 = imagecolorallocatealpha($thumb_image,0x00,0x00,0x00,127); imagefill($medium_image, 0, 0, $color); imagefill($thumb_image, 0, 0, $color2); imagecopyresized($medium_image,$src,0,0,0,0,$medium_width,$file_height_medium,$file_width,$file_height); imagecopyresized($thumb_image,$src,0,0,0,0,$thumb_width,$file_height_thumb,$file_width,$file_height); imagegif($medium_image,$upload_dir . $medium_dir . $file_new); imagegif($thumb_image,$upload_dir . $thumbs_dir . $file_new); } exit_status('File was uploaded successfuly!'); imagedestroy($src); imagedestroy($medium_image); imagedestroy($thumb_image); } else { exit_status('Error! <i>File couldnt be saved to the database.</i>'); } } } else { // Move the uploaded file from the temporary // directory to the uploads folder: if(move_uploaded_file($file_tmp, $upload_dir . $file_new)){ include('functions.php'); connect(); $link = get_option('admin_url'); $sql = " INSERT into mediaT ( name, url, link, createdon, createdby ) VALUES ( '$name', '$upload_dir$file_new', '$link$upload_dir$file_new', NOW(), '$createdby' ) "; $result = mysql_query($sql); exit_status('File was uploaded successfuly!'); } } } exit_status('Something went wrong with your upload!'); // Helper functions function exit_status($str){ echo json_encode(array('status'=>$str)); exit; } function get_extension($file_name){ $ext = explode('.', $file_name); $ext = array_pop($ext); return strtolower($ext); } ?>
×
×
  • 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.