Jump to content

QuickOldCar

Staff Alumni
  • Posts

    2,972
  • Joined

  • Last visited

  • Days Won

    28

Everything posted by QuickOldCar

  1. I would think this should work. Give it a try. <?php // Set up the page links and pass any needed variables to the next page by including them in the href after the page variable. if (!$prev_page < 1) { print "<p style='clear:both;'><a href='results.php?page=$prev_page&num_pages=$num_pages'>< Previous page.</p>"; } if ($page >= 1 && $num_pages >= 2) { if ($page != $num_pages) { print "<p style='clear:both;'><a href='results.php?page=$next_page&num_pages=$num_pages'> Next page.></p>"; } } ?>
  2. http://php.net/manual/en/function.imagedestroy.php
  3. So really you want to make your own template engine. Something like smarty, savant, dwoo and so on that uses classes. Well can always download theirs and see how they go about it.
  4. From what I get out of this you think you are supposed to save the entire template in a table or something? Make folders naming each of your different templates/themes, and make a table that just refers to the location of the folder for that theme. More like options can do in the table, for users, theme selection and so on. When the template is called for it would then look at mysql for which theme is selected by the file location, and then display the proper files from the correct theme folder for that user.
  5. http://tools.pingdom.com/ That's what I used, I know nothing is 100% accurate, but I feel gives a basic realistic value.
  6. These files are all missing http://www.disami.com/Themes/Dark/Images/Buttons/save.png http://www.disami.com/Themes/Dark/Images/Buttons/savehover.png http://www.disami.com/Themes/Dark/Images/Buttons/accept.png http://www.disami.com/Themes/Dark/Images/Buttons/accepthover.png http://www.disami.com/Includes/Assets/ChatBar/themes/dark/images/pencil.png http://www.disami.com/Includes/Assets/ChatBar/themes/dark/images/pencil.gif Is no description or keywords for meta data. Personally I don't mind black myself, but the dark blood red is kinda hard to see. Why ask questions, What is Disami?, just tell them what you are. [ Page Generation: 0.01 Seconds | Memory Usage: 340.23 KB | DB Queries: 0 ] Actual: Website information Total loading time: 4.2 seconds Total objects: 61 (946.5 KB) External objects: 1 (2.3 KB) HTML (X)HTML: 1 (14.7KB) RSS RSS/XML: 0 CSS CSS: 4 (60.7KB) Scripts Scripts: 8 (205.5KB) Images Images: 48 (665.7KB) Plugins Plugins: 0 Other Other: 0 Redirected Redirected: 0 That's too heavy for a front page.
  7. Gonna take a guess here. If works fine locally but not at the new server then must be your host somehow. Does host have limits, is server actually live, it seems more like a 500 internal error. Whatever http://www.craigwatcher.me/playground/units.php is times out or I should say just sits there forever in my browser doing nothing.
  8. What sucks about iframes is.....the site can do a "jump out of frame". Did a few times for me whenever a youtube and anything else is selected.
  9. Ever try this? http://www.icecast.org/
  10. Is a pile of plugins for wordpress, I know there is a few for thumbnails out there. http://wordpress.org/extend/plugins/tags/thumbnails Here's a for instance http://markjaquith.wordpress.com/2009/12/23/new-in-wordpress-2-9-post-thumbnail-images/
  11. I had some time waiting for huge sized folders to transfer, I thought I'd be nice and write up a function to clean the url's and then another to check them if similar. So the concept is to eliminate all the stuff that would make them different, but ultimately would go to the same or similar url. That would include any protocols, the www , end slash , # at end , ? at end. The www and end slash you will find out sometimes are or are not required because the website owners did not allow for that. Best to use curl to try and resolve the urls first. But then the url the user inserted would be different if was a normal redirect. Lowercase anything from the domain name forward. Here's the function file compareurl.php <?php function cleanUrl($input_url) { if ($input_url == '') { echo "EMPTY URL VALUE"; DIE;//redirect on empty value somewhere } else { $input_url = trim($input_url); $input_url = rtrim($input_url,"/"); if ((substr($input_url, 0, == "https://") OR (substr($input_url, 0, 7) == "http://") OR (substr($input_url, 0, 6) == "ftp://") OR (substr($input_url, 0, 7) == "feed://")) { $new_url = $input_url; } else { /*replace uppercase or unsupported to normal*/ $url_input .= str_replace(array('feed://www.','feed://','HTTP://','HTTP://www.','HTTP://WWW.','http://WWW.','HTTPS://','HTTPS://www.','HTTPS://WWW.','https://WWW.'), '', $input_url); $new_url = "http://www.$url_input"; } $get_parse_url = parse_url($new_url, PHP_URL_HOST);//the parsed host $host_parse_url .= str_replace(array('Www.','WWW.'), '', $get_parse_url);//replace any uppers $host_parse_url = strtolower($host_parse_url);//lowercase host area $port_parse_url = parse_url($new_url, PHP_URL_PORT);//the port, omitted from clean_url $user_parse_url = parse_url($new_url, PHP_URL_USER);//users account $pass_parse_url = parse_url($new_url, PHP_URL_PASS);//users password $get_path_parse_url = parse_url($new_url, PHP_URL_PATH);//the file location or path $path_parse_url .= str_replace(array('Www.','WWW.'), '', $get_path_parse_url);//don't recall why I did this $query_add_parse_url = parse_url($new_url, PHP_URL_QUERY);//the query $query_add_parse_url = "?$query_add_parse_url";//add the ? back to front of query $query_add_parse_url = rtrim($query_add_parse_url, "#");//remove # from end $fragment_parse_url = parse_url($new_url, PHP_URL_FRAGMENT);//the end fragment $fragment_parse_url = "#$fragment_parse_url";//add # back to beginning fragment $fragment_parse_url = rtrim($fragment_parse_url,"#");//remove any # from end fragment $hostpath_url = "$host_parse_url$path_parse_url";//combine parsed url and path $hostpath_url = rtrim($hostpath_url, '?');//remove ? from parsed url and path $query_add_parse_url = rtrim($query_add_parse_url, '?');//remove ? from end of query $hostpathquery_url = "$host_parse_url$path_parse_url$query_add_parse_url";//host path and query combined $complete_url = "$host_parse_url$user_parse_url$pass_parse_url$path_parse_url$query_add_parse_url$fragment_parse_url";//all combined minus port $cleaned_url = "$host_parse_url$user_parse_url$pass_parse_url$path_parse_url$query_add_parse_url$fragment_parse_url";//all combined minus port, if want query or fragment gone remove it $cleaned_url = trim($cleaned_url);//double check is no whitespace $cleaned_url = rtrim($cleaned_url,"?");//remove ? from end of url $cleaned_url = rtrim($cleaned_url,"#");//remove # from end of url $cleaned_url = rtrim($cleaned_url,"/");//remove end slash $cleaned_url = ltrim($cleaned_url, "www.");//remove www. if exists RETURN $cleaned_url; } } function compareUrl($url1,$url2) { if (cleanUrl($url1) == cleanUrl($url2)) { RETURN TRUE; } } ?> here's some example url's and usage: <?php //usage //compareUrl() requires 2 variables to check against include('compareurl.php'); //sample url's $url1 = "http://www.site.com/mail/"; $url2 = "HTTP://SITE.com/mail?"; $url3 = "site.com/mail/"; $url4 = "https://site.com/mail?"; $url5 = "site.com/mail/"; $url6 = "mysite.com"; $url7 = "http://site.com?"; $url8 = "http://site.com/index.php?"; $url9 = "HTTP://SITE.COM/index.php/?"; $url10 = "http://site.com/index.php"; //check url 1 versus 2 if (compareUrl($url1,$url2) == TRUE) { echo "$url1 and $url2 are the same <br />";//reject insert code } else { echo "$url1 and $url2 are different <br />";//accept insert code } //check url 3 versus 4 if (compareUrl($url3,$url4) == TRUE) { echo "$url3 and $url4 are the same <br />"; } else { echo "$url3 and $url4 are different <br />"; } //check url 5 versus 6 if (compareUrl($url5,$url6) == TRUE) { echo "$url5 and $url6 are the same <br />"; } else { echo "$url5 and $url6 are different <br />"; } //check url 6 versus 7 if (compareUrl($url6,$url7) == TRUE) { echo "$url6 and $url7 are the same <br />"; } else { echo "$url6 and $url7 are different <br />"; } //check url 8 versus 9 if (compareUrl($url8,$url9) == TRUE) { echo "$url8 and $url9 are the same <br />"; } else { echo "$url8 and $url9 are different <br />"; } //check url 9 versus 10 if (compareUrl($url9,$url10) == TRUE) { echo "$url9 and $url10 are the same <br />"; } else { echo "$url9 and $url10 are different <br />"; } ?>
  12. What I did was drop off any protocols like http://, https, www, and so on. Also remove the end slashes. In my case I use these as my titles, but you can use them just for checking purposes. Is actually a lot to this, need to lowercase just the domain area in case they capitalize. Checks for inserting in the form so they can type it in any way, like http://aol.com,http://www.aol.com,http://www.aol.com/,aol.com or anything similar can be inserted and be the same values. I then resolve them through curl. Then you get url's such as http://mysite.com, which could also be the same exact url as http://mysite.com/index.html or http://mysite.com/index.php or http://mysite.com/index.asp and on and on. That's why I try to let curl resolve them. Javascript redirects aren't too pleasant, but you should be able to follow any normal redirects. I been working on my login system so you can't browse my index right now, but the system I described works for me and took me a great deal of time to figure out. I did leave the non login areas live though like the add. So try a url in any way and will see it will not do a duplicate. http://dynaindex.com/add
  13. When you say no success what does or does not happen. Are you doing a check to see if there is at least 1 or more posts after your query? So you are saying that the home page will always just display that one post query and never a posts loop...correct? If so try this: <?php $url = the_permalink(); echo "<meta http-equiv='refresh' content='0;url=$url'>";//0 is instant, if want delay increase number exit();//added this for good measure in case more code was to execute ?>
  14. Ha, so it is, good eye. Corrected: <?php if($_POST['table']=='stationary') { include('birthdays_insert_record.php'); } elseif ($_POST['table']=='reception') { include('insert_reception.php'); } else { echo "Nothing was inserted"; } ?>
  15. Is there a reason why need the 5 sizes for all premade. I understand are already into doing what you are and I believe you are deleting your original images. Well here was a thought for you. When image of certain size gets called upon... have gd do a dynamic size, store to a cache folder of images that particular filename for size, cache the images. So when get a request for that size can check cache folder first, if not then execute gd resize and place into cache folder. I hope you got all that. The point is why make many images if not using them all, I don't know your exact process here or what doing with them, but if have a real lot and worried about space is something to consider.
  16. Try from this: <?php if($_POST['table']=='stationary' 'birthdays_insert_record.php') else if($_POST['table']=='reception' 'insert_reception.php') ?> To this: <?php if($_POST['table']=='stationary') { include('birthdays_insert_record.php'): } elseif ($_POST['table']=='reception') { include('insert_reception.php'); } else { echo "Nothing was inserted"; } ?>
  17. More information would be needed if wanted help. The code you posted is incomplete and just a bunch of echoed "text" and partial select statements. Can't even tell what or where $var would be anywhere in there.
  18. You can even just pull a random md5 if wanted, and do range for length 1 to 32 <?php function uniqueString($length) { $string = substr(md5(uniqid()), 0,$length); return $string; } //usage $random_string = uniqueString(10);//min 1 to max 32 for length echo $random_string; ?>
  19. oops forgot to add the -1 to define also added more numbers to offset the letters more <?php function generateString($length) { $characters = "0123456789abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; $string = ""; for ($s = 0; $s < $length; $s++) { $string .= $characters[mt_rand(0, strlen($characters)-1)]; } return $string; } //usage $randomstring = generateString(32);//define amount of characters echo $randomstring; ?>
  20. or a function <?php function generateString($length) { $characters = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; $string = ""; for ($s = 0; $s < $length; $s++) { $string .= $characters[mt_rand(0, strlen($characters))]; } return $string; } //usage $randomstring = generateString(32);//define amount of characters echo $randomstring; ?>
  21. Is a post on that here, not to mention a few others in the forums dealing with random generation and from arrays/lists. http://www.phpfreaks.com/forums/php-coding-help/building-strings/
  22. It's always best to post your current code so people know what it is. can swoop all your code and just press the php button in the editor.
  23. Here, just made this up for you. I tried to handle if no http or if they type uppercase. <?php function getparsedHost($new_parse_url) { $parsedUrl = parse_url(trim($new_parse_url)); return trim($parsedUrl[host] ? $parsedUrl[host] : array_shift(explode('/', $parsedUrl[path], 2))); } $url = mysql_real_escape_string($_GET['url']); $url_input = mysql_real_escape_string($url); $input_parse_url = strtolower(getparsedHost($url_input)); /*check for valid urls*/ if ((substr($input_parse_url, 0, == "https://") OR (substr($input_parse_url, 0, 12) == "https://www.") OR (substr($input_parse_url, 0, 7) == "http://") OR (substr($input_parse_url, 0, 11) == "http://www.") OR (substr($input_parse_url, 0, 6) == "ftp://") OR (substr($input_parse_url, 0, 11) == "feed://www.")OR (substr($input_parse_url, 0, 7) == "feed://")) { $new_parse_url = $input_parse_url; } else { /*replace uppercase or unsupported to normal*/ $clean_url .= str_replace(array('feed://www.','feed://','HTTP://','HTTP://www.','HTTP://WWW.','http://WWW.','HTTPS://','HTTPS://www.','HTTPS://WWW.','https://WWW.'), '', $input_parse_url); $new_parse_url = "http://$clean_url"; } if (!isset($_GET['url'])) { $new_parse_url = "http://www.google.com"; } ?> <div align="center">; <form action="" method="get"> Insert url: <input type="text" name="url" value="<?php echo $new_parse_url;?>" class="text" style="width:480px; height:25px;" /> <input type="submit" value="Go" class="button" style="width:80px; height:30px;" /> </form> </div> <iframe src ="<?php echo $new_parse_url;?>" width="100%" height="500"> <p>Your browser does not support iframes.</p> </iframe>
  24. <?php $php_var = 100; echo " <SCRIPT type='text/javascript'> var js_var = $php_var; function display_var() { alert(js_var); } </SCRIPT> <body onload='display_var()'> .......... .......... </body>"; ?>
  25. Here's the way I use to do either an insert or update First I do a check if it exists, I do not want duplicates. If already exists, then update the information keeping same id. For my case I want to update the information, but some may not want to, or just do a few fields. If it doesn't exist, then insert as new (id not required because using id auto increment) Of course you would need to change any values you needed different. $con_add = mysql_connect("server","username","password"); if (!$con_add) { die('Could not connect: ' . mysql_error()); } mysql_select_db("databasename", $con_add); $query_check = mysql_query("SELECT* FROM table WHERE post_title = '".$post_title."'"); $check = mysql_num_rows($query_check); $row = mysql_fetch_array($query_check); $the_ID = $row['ID']; if($check > 0) { mysql_query("SET NAMES 'utf8'"); mysql_query("UPDATE table SET post_title='$escaped_post_title', title_2='$escaped_title', post_description='$escaped_description', post_keywords='$escaped_keywords', post_date='$my_date', post_modified='$my_date', post_date_gmt='$my_date', post_status='$the_status', post_name='$post_name', guid='./index.php?post=$post_name', link_rss='$feed_array' WHERE ID='$the_ID'"); } else { mysql_query("SET NAMES 'utf8'"); mysql_query("INSERT INTO posts (post_title, title_2, post_description, post_keywords, post_date, post_modified, post_date_gmt, post_status, post_name, guid, link_rss) VALUES ('$escaped_post_title', '$escaped_title', '$escaped_description', '$escaped_keywords', '$my_date', '$my_date', '$my_date', '$the_status', '$post_name', ' ./index.php?post=$post_name', '$feed_array')"); } mysql_free_result($query_check); mysql_close($con_add);
×
×
  • 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.