QuickOldCar
Staff Alumni-
Posts
2,972 -
Joined
-
Last visited
-
Days Won
28
Everything posted by QuickOldCar
-
Need help in creating bmp to png in php.
QuickOldCar replied to ShivaGupta's topic in PHP Coding Help
works with saved local images <?php function ConvertBMP2GD($src, $dest = false) { if(!($src_f = fopen($src, "rb"))) { return false; } if(!($dest_f = fopen($dest, "wb"))) { return false; } $header = unpack("vtype/Vsize/v2reserved/Voffset", fread($src_f, 14)); $info = unpack("Vsize/Vwidth/Vheight/vplanes/vbits/Vcompression/Vimagesize/Vxres/Vyres/Vncolor/Vimportant", fread($src_f, 40)); extract($info); extract($header); if($type != 0x4D42) { // signature "BM" return false; } $palette_size = $offset - 54; $ncolor = $palette_size / 4; $gd_header = ""; // true-color vs. palette $gd_header .= ($palette_size == 0) ? "\xFF\xFE" : "\xFF\xFF"; $gd_header .= pack("n2", $width, $height); $gd_header .= ($palette_size == 0) ? "\x01" : "\x00"; if($palette_size) { $gd_header .= pack("n", $ncolor); } // no transparency $gd_header .= "\xFF\xFF\xFF\xFF"; fwrite($dest_f, $gd_header); if($palette_size) { $palette = fread($src_f, $palette_size); $gd_palette = ""; $j = 0; while($j < $palette_size) { $b = $palette{$j++}; $g = $palette{$j++}; $r = $palette{$j++}; $a = $palette{$j++}; $gd_palette .= "$r$g$b$a"; } $gd_palette .= str_repeat("\x00\x00\x00\x00", 256 - $ncolor); fwrite($dest_f, $gd_palette); } $scan_line_size = (($bits * $width) + 7) >> 3; $scan_line_align = ($scan_line_size & 0x03) ? 4 - ($scan_line_size & 0x03) : 0; for($i = 0, $l = $height - 1; $i < $height; $i++, $l--) { // BMP stores scan lines starting from bottom fseek($src_f, $offset + (($scan_line_size + $scan_line_align) * $l)); $scan_line = fread($src_f, $scan_line_size); if($bits == 24) { $gd_scan_line = ""; $j = 0; while($j < $scan_line_size) { $b = $scan_line{$j++}; $g = $scan_line{$j++}; $r = $scan_line{$j++}; $gd_scan_line .= "\x00$r$g$b"; } } else if($bits == { $gd_scan_line = $scan_line; } else if($bits == 4) { $gd_scan_line = ""; $j = 0; while($j < $scan_line_size) { $byte = ord($scan_line{$j++}); $p1 = chr($byte >> 4); $p2 = chr($byte & 0x0F); $gd_scan_line .= "$p1$p2"; } $gd_scan_line = substr($gd_scan_line, 0, $width); } else if($bits == 1) { $gd_scan_line = ""; $j = 0; while($j < $scan_line_size) { $byte = ord($scan_line{$j++}); $p1 = chr((int) (($byte & 0x80) != 0)); $p2 = chr((int) (($byte & 0x40) != 0)); $p3 = chr((int) (($byte & 0x20) != 0)); $p4 = chr((int) (($byte & 0x10) != 0)); $p5 = chr((int) (($byte & 0x08) != 0)); $p6 = chr((int) (($byte & 0x04) != 0)); $p7 = chr((int) (($byte & 0x02) != 0)); $p8 = chr((int) (($byte & 0x01) != 0)); $gd_scan_line .= "$p1$p2$p3$p4$p5$p6$p7$p8"; } $gd_scan_line = substr($gd_scan_line, 0, $width); } fwrite($dest_f, $gd_scan_line); } fclose($src_f); fclose($dest_f); return true; } function imagecreatefrombmp($filename) { $tmp_name = tempnam("/tmp", "GD"); if(ConvertBMP2GD($filename, $tmp_name)) { $img = imagecreatefromgd($tmp_name); unlink($tmp_name); return $img; } return false; } //change these to yours $source_image = "source.bmp"; $output_image = "test.png"; $img = imagecreatefrombmp($source_image); imagepng($img,$output_image); imagedestroy($img); //display image echo "<img src='$output_image'>"; ?> -
jwplayer can do rtmp http://www.longtailvideo.com/jw-player/download/ http://www.longtailvideo.com/support/jw-player/28854/using-rtmp-streaming/
-
Let me know what you think of this site I built
QuickOldCar replied to thara's topic in Website Critique
Custom error pages or defaulting to the main page on any errors might be better. Try http://www.lankainstitute.com/nothing When at http://www.lankainstitute.com/1261/Pradeep+Galabadage/# most of the navigation links no longer work, home,about us and contact do, the others do not. For your search, if I insert the word science and press Search, it does nothing, I must select something from a dropdown for it to work. -
I use wordpress and enable mulitsites.
-
Try this out, works pretty good. http://wordpress.org/plugins/stop-spammer-registrations-plugin/
-
Please Help: Parse error: syntax error, unexpected '}
QuickOldCar replied to jase2903's topic in PHP Coding Help
Probably have an extra curly brace at the end. <?php add_action('admin_init', 'backgroundmenuregs'); add_action('wp_head', 'add_bg_changerstyle'); function backgroundmenuregs() { wp_enqueue_script('jquery'); wp_register_style('FlowTypographyMainStylesheet', WP_PLUGIN_URL . '/typography/js/colorpicker/css/colorpicker.css'); wp_register_style('FlowTypographyLayoutStylesheet', WP_PLUGIN_URL . '/typography/js/colorpicker/css/layout.css'); wp_register_script('jquery_colorpicker_script', WP_PLUGIN_URL . '/typography/js/colorpicker/js/colorpicker.js', array( 'jquery' ), '1.0'); wp_enqueue_style('FlowTypographyMainStylesheet'); wp_enqueue_style('FlowTypographyLayoutStylesheet'); wp_enqueue_script('jquery_colorpicker_script'); } function add_bg_menu() { //must check that the user has the required capability if (!current_user_can('manage_options')) { wp_die(__('You do not have sufficient permissions to access this page.')); } echo '<div class="wrap">'; echo "<h2>" . __('Styling', 'menu-test') . "</h2>"; if ($_POST['bg_submit_h'] && $_POST['bg_submit_h'] == "Y") { $bgrepeat = array( "repeat" => "repeat", "repeatx" => "repeat-x", "repeaty" => "repeat-y", "norepeat" => "no-repeat" ); update_option("bgchanger_color", $_POST['bc']); update_option("bgchanger_imgsrc", $_POST['bi']); if ($_POST['bpx'] == "left" || $_POST['bpx'] == "center" || $_POST['bpx'] == "right") { update_option("bgchanger_posx", $_POST['bpx']); } if ($_POST['bpy'] == "top" || $_POST['bpy'] == "center" || $_POST['bpy'] == "bottom") { update_option("bgchanger_posy", $_POST['bpy']); } if ($_POST['ba'] == "fixed" || $_POST['ba'] == "scroll") { update_option("bgchanger_attach", $_POST['ba']); } if (array_key_exists($_POST['br'], $bgrepeat)) { update_option("bgchanger_repeat", $bgrepeat[$_POST['br']]); } ?> <div class="updated"> <p><strong> <?php _e('settings saved.', 'menu-test');?> </strong></p></div> <?php } $bgcval_bc = get_option("bgchanger_color"); $bgcval_bi = get_option("bgchanger_imgsrc"); $bgcval_bpx = get_option("bgchanger_posx"); $bgcval_bpy = get_option("bgchanger_posy"); $bgcval_ba = get_option("bgchanger_attach"); $bgcval_br = get_option("bgchanger_repeat"); ?> <script type="text/javascript">jQuery(document).ready(function(){ jQuery(".attcolorpicker").each(function(){jQuery(this).ColorPicker({ onShow:function(cp){jQuery(cp).fadeIn(500); return false; } ,onHide:function(cp){jQuery(cp).fadeOut(500);return false;},onChange:function(hsb, hex, rgb){jQuery(this).parent().find('.attcolorpicker').val('#'+hex);jQuery(this).parent().find('.colorSelector div').css('backgroundColor', '#'+hex);jQuery(this).parent().find('.colorSelector').ColorPickerSetColor(hex);}});jQuery(this).parent().find('.colorSelector').ColorPicker({onShow:function(cp){jQuery(cp).fadeIn(500);return false;},onHide:function(cp){jQuery(cp).fadeOut(500);return false;},onChange:function(hsb, hex, rgb){jQuery(this).parent().find('.attcolorpicker').val('#'+hex);jQuery(this).parent().find('.colorSelector div').css('backgroundColor', '#'+hex);jQuery(this).parent().find('.attcolorpicker').ColorPickerSetColor(hex);}});});}); </script> <form method="post" action=""> <table class="form-table"> <tr><th>Background color</th><td> <input type="text" class="attcolorpicker" name="bc" value="<?php if ($bgcval_bc) print($bgcval_bc); ?>"> <div class="colorSelector"><div<?php if ($bgcval_bc) print(" style=\"background-color:" . $bgcval_bc . ";\""); ?>></div></div> </td></tr> <tr><th>Background image</th><td><input type="text" name="bi" value="<?php if ($bgcval_bi) print($bgcval_bi); ?>"><span href="#" title="" class="briskuploader button">Upload</span><br/><div class="briskuploader_preview"></div></td></tr> <tr><th>Background position</th><td><select name="bpx"><option value="left"<?php if ($bgcval_bpx == "left") print(" selected=\"selected\""); ?>>left</option><option value="center"<?php if ($bgcval_bpx == "center") print(" selected=\"selected\""); ?>>center</option><option value="right"<?php if ($bgcval_bpx == "right") print(" selected=\"selected\""); ?>>right</option></select><select name="bpy"><option value="top"<?php if ($bgcval_bpy == "top") print(" selected=\"selected\""); ?>>top</option><option value="center"<?php if ($bgcval_bpy == "center") print(" selected=\"selected\""); ?>>center</option><option value="bottom"<?php if ($bgcval_bpy == "bottom") print(" selected=\"selected\""); ?>>bottom</option></select></td></tr> <tr><th>Background attachment</th><td><select name="ba"><option value="scroll"<?php if ($bgcval_ba == "scroll") print(" selected=\"selected\""); ?>>Scroll</option><option value="fixed"<?php if ($bgcval_ba == "fixed") print(" selected=\"selected\""); ?>>Fixed</option></select></td></tr> <tr><th>Background repeat</th><td><select name="br"><option value="repeat"<?php if ($bgcval_br == "repeat") print(" selected=\"selected\""); ?>>repeat</option><option value="repeatx"<?php if ($bgcval_br == "repeat-x") print(" selected=\"selected\""); ?>>repeat-x</option><option value="repeaty"<?php if ($bgcval_br == "repeat-y") print(" selected=\"selected\""); ?>>repeat-y</option><option value="norepeat"<?php if ($bgcval_br == "no-repeat") print(" selected=\"selected\""); ?>>no-repeat</option></td></tr> </table> <p class="submit"> <input type="hidden" name="bg_submit_h" value="Y"> <input type="submit" name="Submit" class="button-primary" value="<?php esc_attr_e('Save Changes'); ?>" /> </p> </form> </div> <?php } function add_bg_changerstyle() { $bgcval_bc = get_option("bgchanger_color"); $bgcval_bi = get_option("bgchanger_imgsrc"); if ($bgcval_bc || $bgcval_bi) { print("<style type=\"text/css\"> body{ "); if ($bgcval_bc) { print("background-color:" . $bgcval_bc . ";"); } if ($bgcval_bi) { if ($bgcval_bi == "none") { print("background-image:none;"); } else { print("background-image:url(" . $bgcval_bi . ");"); $bgcval_bpx = get_option("bgchanger_posx"); $bgcval_bpy = get_option("bgchanger_posy"); $bgcval_ba = get_option("bgchanger_attach"); $bgcval_br = get_option("bgchanger_repeat"); if ($bgcval_bpx == "left" || $bgcval_bpx == "center" || $bgcval_bpx == "right") { if ($bgcval_bpy == "top" || $bgcval_bpy == "center" || $bgcval_bpy == "bottom") { print("background-position:" . $bgcval_bpx . " " . $bgcval_bpy . ";"); } } if ($bgcval_ba == "fixed" || $bgcval_ba == "scroll") { print("background-attachment:" . $bgcval_ba . ";"); } if ($bgcval_br == "repeat" || $bgcval_br == "repeat-x" || $bgcval_br == "repeat-y" || $bgcval_br == "no-repeat") { print("background-repeat:" . $bgcval_br . ";"); } } } print(" } </style>"); } } ?> -
I think the best thing to do would be to use mysqls built in autoincrement for id's but if you wanted to, you can assign them qr codes by using an md5 of uniqid() $qr_code = md5(uniqid(rand(), true)); Save that $qr_code value into that users account so it links their info to that code
-
I installed ubuntu server many times at my house download and install Ubuntu Server 12.04 LTS There is a decent tutorial here on setting it all up with ispconfig http://www.howtoforge.com/perfect-server-ubuntu-12.04-lts-apache2-bind-dovecot-ispconfig-3 If you already have the server installed you can use taskel and add anything additional sudo apt-get install tasksel sudo tasksel Select what you want additional This is how to add the desktop gui to the server edition (I like kubuntu) http://www.ubuntugeek.com/install-gui-in-ubuntu-server.html You'll see webmin there which is also handy phpmyadmin for managing your databases sudo apt-get install phpmyadmin and then do this so apache finds it sudo ln -s /usr/share/phpmyadmin /var/www Something you may be interested in is turnkey virtual appliances, download,burn,install and ready to go solutions http://www.turnkeylinux.org/ I've done them in vmware,virtualbox and virtualpc, they work pretty good.
-
Welcome to the site.
-
bbcode on urls within php code tags
QuickOldCar replied to QuickOldCar's topic in PHPFreaks.com Website Feedback
Another minor problem would be the urls truncating. -
Is there a way to eliminate bbcode within php tags on a post. You can look at this link here as an example http://forums.phpfreaks.com/topic/277548-php-coding-for-xml-feed-to-parse-and-work/?do=findComment&comment=1428150 I inserted $xml = simplexml_load_file('http://steamcommunity.com/stats/AgeofEmpiresIIHDEdition/leaderboards/131879/?xml=1'); and the user sees $xml = simplexml_load_file('[url=http://steamcommunity.com/stats/AgeofEmpiresIIHDEdition/leaderboards/131879/?xml=1]http://steamcommunity.com/stats/AgeofEmpiresIIHDEdition/leaderboards/131879/?xml=1%5B/url%5D');
-
in your footer.php file change the href links to go to your same urls as your top navigation does, I'll include your home_url() to make sure it will always go there <a href="<?php echo home_url(); ?>"><img src="<?php bloginfo( 'template_directory' ); ?>/_/img/menu_home.png"/></a> <a href="<?php echo home_url(); ?>/history"><img src="<?php bloginfo( 'template_directory' ); ?>/_/img/menu_history.png"/></a> <a href="<?php echo home_url(); ?>/benefits"><img src="<?php bloginfo( 'template_directory' ); ?>/_/img/menu_benefits.png"/></a> <a href="<?php echo home_url(); ?>/products"><img src="<?php bloginfo( 'template_directory' ); ?>/_/img/menu_products.png"/></a> <a href="<?php echo home_url(); ?>/contact"><img src="<?php bloginfo( 'template_directory' ); ?>/_/img/menu_contact.png"/></a>
-
You can use datetime in mysql with a structure like 0000-00-00 00:00:00 $date = date('Y-m-d H:i:s');
-
Ever see sphinxsearch ? But they have all the documentation needed at their site and also in the source files. http://lucene.apache.org/core/old_versioned_docs/versions/2_9_1/gettingstarted.html http://www.lucenetutorial.com/lucene-in-5-minutes.html
-
Here you go. Change the $show_result_amount value to how many results you want. <style> table, td, th body { font-family:Verdana, Arial, Helvetica; font-size: 81%; margin: 0px; color: #5c3d0b; font-weight:bold; } { border:1px solid black; } th { background-color:e6cb9c; } </style> <?php $xml = simplexml_load_file('http://steamcommunity.com/stats/AgeofEmpiresIIHDEdition/leaderboards/131879/?xml=1'); //print_r($xml); $entries = $xml->entries->entry; $str = "http://steamcommunity.com/profiles/{{STEAMID64}}/?xml=1"; $count = 1; $show_result_amount = 10; echo "<table border='1' bordercolor='#FFCC00' style='background-color:#e6cb9c' width='100%' cellpadding='3'> <tr> <th colspan='4'> <h3><br>Steam Top Players</h3> </th> </tr> <th>Player Name</th> <th>Score</th> <th>Rank</th> <th>Ugcid</th>"; foreach( $entries as $key => $entry ) { $userURL = str_replace( "{{STEAMID64}}", $entry->steamid, $str ); $userXML = simplexml_load_string( file_get_contents( $userURL ) ); $username = $userXML->steamID; $score = $entry->score; $rank = $entry->rank; $ugcid = $entry->ugcid; echo "<tr><td>".$username."</td>"; echo "<td>".$score."</td>"; echo "<td>".$rank."</td>"; echo "<td>".$ugcid."</td></tr>"; $count++; if( $count > $show_result_amount ){break;} } echo "</table>"; ?>
-
Minimum characters in search setting, and pagination.
QuickOldCar replied to strago's topic in PHP Coding Help
I just wrote this function up for you so can do more than one word. I know there are simpler ways to do this, but I did it this way. single or more search terms single or multiple fields can set the minimum character count for each word, any that are less never get into the actual mysql query option to use AND/OR to get different results Is a demo there with it so can try it out and see the results it gets To use this, check that the function does not return an empty value, and be sure to filter/escape anything going into the mysql query <?php //build query searches from multiple words function querySearch($search, $field, $search_term_length = NULL, $and_or = NULL) { //check if search is not empty if ($search == '') { return ''; exit(); } if ($field == '') { return ''; exit(); } if (is_array($field)) { $field = implode(",", $field); } //only do the search if word has more than 3 characters unless set different function if (is_null($search_term_length)) { $search_term_length = "3"; } if (is_null($and_or)) { $and_or = "OR"; } //create an array to eliminate errors checking array $search_exploded = array(); //create a new array exploding the spaces of multiple search terms $search_exploded = explode(" ", $search); //if is multiple search terms if (count($search_exploded > 0)) { //loop through array foreach ($search_exploded as $search_term) { //only with certain amount of characters if (strlen($search_term) >= $search_term_length) { //create new array and lower all the words $search_terms[] = strtolower($search_term); } } } else { //if is a single search term $search_terms = strtolower($search); } //build the search query $construct_query = array(); if ($search_terms != '' && !is_array($search_terms)) { $construct_query = "WHERE (" . $field . ") LIKE '%" . $search_terms . "%'"; } elseif (is_array($search_terms) && count($search_terms) > 0) { $construct_query[] = "WHERE (" . $field . ") LIKE '%" . $search_terms['0'] . "%'"; unset($search_terms['0']); foreach ($search_terms as $additional_term) { $construct_query[] = " $and_or (" . $field . ") LIKE '%" . $additional_term . "%'"; } } $query_term = ''; if (count($construct_query) > 0) { $query_term = implode('', $construct_query); } return $query_term; } //end querySearch function //usage $search = trim($_GET['search']); if (isset($_GET['search']) && $search != '') { //run function to insert into query echo querySearch($search, "title", 2, "AND"); //search term,database field,minimum character length,and/or for different results echo "<br />"; echo querySearch($search, "cars", 3, "OR"); echo "<br />"; echo querySearch($search, array("cats","dogs"), 3, "OR"); //using more than one field with an array } else { echo "Insert a search term"; } ?> <form action="" method="get"> <input type="text" name="search" value=""/> <input type="submit" value="Search"/> </form> -
Setting up then fetching data from another internal page?
QuickOldCar replied to MrTIMarshall's topic in PHP Coding Help
For your first question, you would make a script and use a GET request, it does not require a form, but can use one as well. http://php.net/manual/en/reserved.variables.get.php http://www.tizag.com/phpT/postget.php For the second question, ajax as ignace stated if want it dynamic without leaving the original page. https://developer.mozilla.org/en-US/docs/AJAX/Getting_Started -
By looking at the plugin, changing the original code to this should work fine. 'rewrite' => array( 'slug' => 'list', 'with_front' => false ) Did you follow the step of saving the permalink structure? Navigate to Settings > Permalinks and save them. Yes, just click save. Trust me.
-
You could use a meta refresh, can also place a die() or exit() after it <meta http-equiv="refresh" content="0;URL='http://mysite.com/'">
- 14 replies
-
lol@requinix, at least we gave same advice
-
I added form to it, also you didn't have $_POST['cancel'] <?php $id = 776; print '$id ' . "$id\n"; if(isset($_POST['cancel'])){ print "Exiting"; exit(); } if(isset($_POST['submitted'])){ print '$id ' . "$id"; } print " <form action=\"\" method=\"post\"> <input type=\"submit\" value=\"Save\" name=\"submitted\"> <input type=\"submit\" value=\"Cancel\" name=\"cancel\"> </form> "; ?>
-
also don't forget to add your curly brace at the end to wrap your if statement, I didn't see it in your posted code }
-
if ($v['tickets_left'] >= 1 && $v['tickets_left'] <= 40) {
-
Instead of the commented out line, place this there. The below code should show only when there are 1 to 29 tickets left. if($v['tickets_left'] < 30 && $v['tickets_left'] >= 1){ echo "<div class='tickets'>" . ($v['tickets_left'] < 30 ? "<span class='tickets_low'>" . escape($v['tickets_left']) . "</span>" : "" . escape($v['tickets_left']) . "") . " tickets left to buy for this match</div>"; }