To fix this annoying error I got, when I tried to Re-Index the Data all you have to do is
deleting everything in the /var/locks folder
in your magento folder, of course.
That’s it!
in magento 1.5+ you cannot see what categories a product is assigned to in the admin. This feature for some reason was removed in magento. This is one of the stupidest things i have come across but kiwigrid has written a an extension to overide this behaviour and force the category tree to expand the category branches that have the product in it. It will not just expand the whole tree. The product category tab takes slightly longer to load whilst the code checks categories and then expands the tree where needed but you dont really notice.
This plugin is easy to install and does not overwrite any core code.
NB: do this on your demo site first before applying to your live store.
These are the links i came across whilst doing my research
The following is the research i did to show what easter eggs PHP had that could be accessed and then prevented form being access by using .htaccess.
This is a worked example of Rewrite rules. With special forcus on when you need to involve the = or ? in a url with a query which sometimes is recognised just as a url by some parts of mod_rewrite.
Below is some example urls that you can use to test the htaccess file with. Pay special attention to the = ?. Some of these URL will not be recognised as having queries.
Next to each line in the htacces codes is ome numbers that match to the example URLs. The numbers signify which successfully performed a rewrite.
1 - http://localhost/turnip.php?tool=PHPE9568F36-D428-11d2-A769-00AA001ACF42 (common exploits hits first) 2 - http://localhost/turnip.php=PHPE9568F36-D428-11d2-A769-00AA001ACF42 (this has no query) 3 - http://localhost/turnip.php?=PHPE9568F36-D428-11d2-A769-00AA001ACF42 4 - http://localhost/=PHPE9568F36-D428-11d2-A769-00AA001ACF42 5 - http://localhost/tmp/?=PHPE9568F36-D428-11d2-A769-00AA001ACF42
## Disallow PHP Easter Eggs (can be used in fingerprinting attacks to determine
## your PHP version). See http://www.0php.com/php_easter_egg.php and
## http://osvdb.org/12184 for more information
These success codes are valid on xammp only
#135# RewriteCond %{QUERY_STRING} ^(.)*PHPE9568F36-D428-11d2-A769-00AA001ACF42(.)* [NC] #135# RewriteCond %{QUERY_STRING} .*PHPE9568F36-D428-11d2-A769-00AA001ACF42 [NC] #135# RewriteCond %{QUERY_STRING} .*=PHPE9568F36-D428-11d2-A769-00AA001ACF42 [NC] #135# RewriteCond %{QUERY_STRING} (?=PHP).* [NC] "# PHP Version Probing" #135# RewriteCond %{QUERY_STRING} .*(?=PHP).* [NC] #35# RewriteCond %{QUERY_STRING} ^=PHPE9568F36-D428-11d2-A769-00AA001ACF42 [NC] #35# RewriteCond %{QUERY_STRING} (&|^){1,1}=PHPE9568F36-D428-11d2-A769-00AA001ACF42 [NC] #2# RewriteCond %{QUERY_STRING} ^(.)+PHPE9568F36-D428-11d2-A769-00AA001ACF42(.)+ [NC] #none# RewriteCond %{QUERY_STRING} ^%3F=PHPE9568F36-D428-11d2-A769-00AA001ACF42 [NC] #none# RewriteCond %{QUERY_STRING} ^(.*)\?=PHPE9568F36-D428-11d2-A769-00AA001ACF42 [NC] #24# RewriteCond %{REQUEST_URI} .*(=PHP).*[NC] #24# RewriteCond %{REQUEST_URI} .*(?=PHP).*[NC] #24# RewriteCond %{REQUEST_URI} ^(?=PHP).*[NC] #24# RewriteCond %{REQUEST_URI} (.*)(?=PHP).*[NC] #24# RewriteCond %{REQUEST_URI} (^(.*)?=PHP).*[NC] #24# RewriteCond %{REQUEST_URI} .*(=PHP).*[NC] #24# RewriteCond %{REQUEST_URI} (.*)(=PHP).*[NC] #24# RewriteCond %{REQUEST_URI} (^(.*)=PHP).*[NC] #24# RewriteCond %{REQUEST_URI} (PHP).*[NC] #none# RewriteCond %{REQUEST_URI} ^(=PHP).*[NC] #Rewrite rule forced on# RewriteCond %{REQUEST_URI} (?=PHP).* [NC] #Rewrite rule forced on# RewriteCond %{REQUEST_URI} ^.*(?=PHP).*[NC] #RewriteRule ^(.*)$ extra/joomla-fingerprinting.php [L] #RewriteRule ^(.*)$ extra/joomla-fingerprinting.html [L]
These codes are valid on my webserver with Extra Security Including suhosin
# RewriteCond %{QUERY_STRING} ^(.)*PHPE9568F36-D428-11d2-A769-00AA001ACF42(.)* [NC] # RewriteCond %{QUERY_STRING} .*PHPE9568F36-D428-11d2-A769-00AA001ACF42 [NC] # RewriteCond %{QUERY_STRING} .*=PHPE9568F36-D428-11d2-A769-00AA001ACF42 [NC] # RewriteCond %{QUERY_STRING} (?=PHP).* [NC] "# PHP Version Probing" # RewriteCond %{QUERY_STRING} .*(?=PHP).* [NC] #none# RewriteCond %{QUERY_STRING} ^=PHPE9568F36-D428-11d2-A769-00AA001ACF42 [NC] #none# RewriteCond %{QUERY_STRING} (&|^){1,1}=PHPE9568F36-D428-11d2-A769-00AA001ACF42 [NC] # RewriteCond %{QUERY_STRING} ^(.)+PHPE9568F36-D428-11d2-A769-00AA001ACF42(.)+ [NC] # RewriteCond %{QUERY_STRING} ^%3F=PHPE9568F36-D428-11d2-A769-00AA001ACF42 [NC] # RewriteCond %{QUERY_STRING} ^(.*)\?=PHPE9568F36-D428-11d2-A769-00AA001ACF42 [NC] #24# RewriteCond %{REQUEST_URI} .*(=PHP).*[NC] #24# RewriteCond %{REQUEST_URI} .*(?=PHP).*[NC] #24# RewriteCond %{REQUEST_URI} ^(?=PHP).*[NC] #24# RewriteCond %{REQUEST_URI} (.*)(?=PHP).*[NC] #24# RewriteCond %{REQUEST_URI} (^(.*)?=PHP).*[NC] #24# RewriteCond %{REQUEST_URI} .*(=PHP).*[NC] #24# RewriteCond %{REQUEST_URI} (.*)(=PHP).*[NC] #24# RewriteCond %{REQUEST_URI} (^(.*)=PHP).*[NC] #24# RewriteCond %{REQUEST_URI} (PHP).*[NC] #none# RewriteCond %{REQUEST_URI} ^(=PHP).*[NC] #Rewrite rule forced on# RewriteCond %{REQUEST_URI} (?=PHP).* [NC] #Rewrite rule forced on# RewriteCond %{REQUEST_URI} ^.*(?=PHP).*[NC] #RewriteRule ^(.*)$ extra/joomla-fingerprinting.php [L] #RewriteRule ^(.*)$ extra/joomla-fingerprinting.html [L]
These rules work on my Xampp:
Database Version: 5.1.33-community Database Collation: utf8_general_ci PHP Version: 5.2.9 Web Server: Apache/2.2.11 (Win32) DAV/2 mod_ssl/2.2.11 OpenSSL/0.9.8i PHP/5.2.9 Web Server to PHP interface: apache2handler
the rules
RewriteCond %{QUERY_STRING} (?=PHP).* [NC] "# Also PHP Version Probing" RewriteCond %{REQUEST_URI} .*(=PHP).* [NC] RewriteRule ^(.*)$ extra/joomla-fingerprinting.php [L]
The following occurs on my live server with those rules:
Database Version: 5.1.50 Database Collation: utf8_general_ci PHP Version: 5.3.2 Web Server: Apache/2.2.15 (Unix) mod_ssl/2.2.15 OpenSSL/0.9.8e-fips-rhel5 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635
the rules
1. 404 2. 403 3. shows elephant 4. 403 5. shows elephant
Simple Method
simply create a file on your website and run this, your IP will be displayed.
<? echo $_SERVER["REMOTE_ADDR"]; ?>
also
<?php $ip = getenv("REMOTE_ADDR") ; echo "Your IP is " . $ip; ?>
Displaying IP in a Graphic Mode
Show IP Display visitor's IP Address in an image with this simple php code.
Your IP Address: 40.206.137.115
Create a new page, copy the text below and save it as image.php (or whatever you wish)
<?php $img_number = imagecreate(275,25); $backcolor = imagecolorallocate($img_number,102,102,153); $textcolor = imagecolorallocate($img_number,255,255,255); imagefill($img_number,0,0,$backcolor); $number = " Your IP is $_SERVER[REMOTE_ADDR]"; Imagestring($img_number,10,5,5,$number,$textcolor); header("Content-type: image/jpeg"); imagejpeg($img_number); ?>
All you'll need to display on other pages is the code below.
<img src="http://mysite.com/image.php" border="1">
Links
A simple page for testing and troubleshooting a connection to a MySQL database. The PHP script will test the server address, username and password. If the database field is left empty, it will return a list of available databases. Testing a specific database is optional, but if a database name is supplied, it will return a list of the tables in that database (if any exist).
This script is from here:
http://www.ardamis.com/2008/05/26/a-php-script-for-testing-a-mysql-database-connection/
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>MySQL Connection Test</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <style type="text/css"> #wrapper { width: 600px; margin: 20px auto 0; font: 1.2em Verdana, Arial, sans-serif; } input { font-size: 1em; } #submit { padding: 4px 8px; } </style> </head> <body> <div id="wrapper"> <?php $action = htmlspecialchars($_GET['action'], ENT_QUOTES); ?> <?php if (!$action) { ?> <h1>MySQL connection test</h1> <form action="<?php echo $_SERVER['PHP_SELF']; ?>?action=test" id="mail" method="post"> <table cellpadding="2"> <tr> <td>Hostname</td> <td><input type="text" name="hostname" id="hostname" value="" size="30" tabindex="1" /></td> <td>(usually "localhost")</td> </tr> <tr> <td>Username</td> <td><input type="text" name="username" id="username" value="" size="30" tabindex="2" /></td> <td></td> </tr> <tr> <td>Password</td> <td><input type="text" name="password" id="password" value="" size="30" tabindex="3" /></td> <td></td> </tr> <tr> <td>Database</td> <td><input type="text" name="database" id="database" value="" size="30" tabindex="4" /></td> <td>(optional)</td> </tr> <tr> <td></td> <td><input type="submit" id="submit" value="Test Connection" tabindex="5" /></td> <td></td> </tr> </table> </form> <?php } ?> <?php if ($action == "test") { // The variables have not been adequately sanitized to protect against SQL Injection attacks: http://us3.php.net/mysql_real_escape_string $hostname = trim($_POST['hostname']); $username = trim($_POST['username']); $password = trim($_POST['password']); $database = trim($_POST['database']); $link = mysql_connect("$hostname", "$username", "$password"); if (!$link) { echo "<p>Could not connect to the server '" . $hostname . "'</p>\n"; echo mysql_error(); }else{ echo "<p>Successfully connected to the server '" . $hostname . "'</p>\n"; printf("MySQL client info: %s\n", mysql_get_client_info()); // printf("MySQL host info: %s\n", mysql_get_host_info()); } if ($link && !$database) { echo "<p>No database name was given. Available databases:</p>\n"; $db_list = mysql_list_dbs($link); echo "<pre>\n"; while ($row = mysql_fetch_object($db_list)) { echo $row->Database . "\n"; } echo "</pre>\n"; } if ($database) { $dbcheck = mysql_select_db("$database"); if (!$dbcheck) { echo mysql_error(); }else{ echo "<p>Successfully connected to the database '" . $database . "'</p>\n"; // Check tables $sql = "SHOW TABLES FROM $database"; $result = mysql_query($sql); if (mysql_num_rows($result) > 0) { echo "<p>Available tables:</p>\n"; echo "<pre>\n"; while ($row = mysql_fetch_row($result)) { echo "{$row[0]}\n"; } echo "</pre>\n"; } else { echo "<p>The database '" . $database . "' contains no tables.</p>\n"; echo mysql_error(); } } } } ?> </div><!-- end #wrapper --> </body> </html>
This code simply display time and date when run.
<?php print date("l dS of F Y h:i:s A"); ?>
To do a lot of php.ini overides you need to get the system php.ini before you can start but this can be a tricky thing. This script will read and then dump the system php.ini
Alter the code below to fit your server and then create grab.php with the altered code and upload to your website public directory.
<? copy('/usr/local/lib/php.ini', '/home/example/public_html/php.ini'); ?>If you do not know your physical paths you can create a file called info.phpwith the following code, upload it to your root public folder and run it. The script will display all of the required information including the physical path.
<? phpinfo() ?>
http://www.example.com/grab.php
The following snippets are simple methods of adding HTML and text in to the DOM tree with javascript.
//Add some text in to the variable sometext - note it adds it as text not html - also next section is required var sometext = document.createTextNode("Z<br /><br />"); // This appends the variable some text to cellRightSel cellRightSel.appendChild(sometext); //-- // This adds the text straight on to cellRightSel, no variable required cellRightSel.appendChild(document.createTextNode('Here is some syndicated content.')); //- // didnt work cellRightSel.appendChild(create('<div>Hello!</div><br /><br />')); //- // this makes a variable newElement populated with the following html (this does actually paste the html) var newElement = '<p id="foo">This is some dynamically added HTML. Yay!</p>'; var bodyElement = cellRightSel; bodyElement.innerHTML = newElement + bodyElement.innerHTML; // same as above but shorter and quickr, you can probably alter the order appropiately cellRightSel.innerHTML = '<p id="foo">This is some dynamically added HTML. Yay!</p>' + cellRightSel.innerHTML;
This is my collection of php snippets that flatten arrays. There are scripts that work on traditional arrays and some that work on objects. I have tried to include where i got them from aswell.
1
// possibly from here - http://www.phpro.org/examples/Convert-Object-To-Array-With-PHP.html /** * * Convert an object to an array * * @param object $object The object to convert * @reeturn array * */ function objectToArray( $object ) { if( !is_object( $object ) && !is_array( $object ) ) { return $object; } if( is_object( $object ) ) { $object = get_object_vars( $object ); } return array_map( 'objectToArray', $object ); } /*** convert the array to object ***/ //$array = objectToArray( $obj ); /*** show the array ***/ //print_r( $array );
2
// not all of these flatteners can handle objects or associative arrays, experiment to find one that works // i think associated arrays are different, and require different looping // see - http://stackoverflow.com/questions/1319903/how-to-flatten-a-multidimensional-array function flatten(array $array) { $return = array(); array_walk_recursive($array, function($a) use (&$return) { $return[] = $a; }); return $return; } // does not flatten array completely, same as above function array_flatten($array) { $return = array(); foreach ($array as $key => $value) { if (is_array($value)){ $return = array_merge($return, array_flatten($value));} else {$return[$key] = $value;} } return $return; }
3
// WORKS // this works but murders all the keys and flattens them all to strings // see - http://www.cowburn.info/2012/03/17/flattening-a-multidimensional-array-in-php/ // works on objects function jon_flatten ($input) { $output = iterator_to_array(new RecursiveIteratorIterator( new RecursiveArrayIterator($input)), FALSE); return $output; }
4
// see - http://stackoverflow.com/questions/526556/how-to-flatten-a-multi-dimensional-array-to-simple-one-in-php function flatten_array($array, $preserve_keys = 0, &$out = array()) { # Flatten a multidimensional array to one dimension, optionally preserving keys. # # $array - the array to flatten # $preserve_keys - 0 (default) to not preserve keys, 1 to preserve string keys only, 2 to preserve all keys # $out - internal use argument for recursion foreach($array as $key => $child) if(is_array($child)) $out = flatten_array($child, $preserve_keys, $out); elseif($preserve_keys + is_string($key) > 1) $out[$key] = $child; else $out[] = $child; return $out; }
5
// flatten multidimensional arrary into single dimension // see - http://davidwalsh.name/flatten-nested-arrays-php function array_flatten($array,$return) { for($x = 0; $x < count($array); $x++) { if(is_array($array[$x])) { $return = array_flatten($array[$x],$return); } else { if($array[$x]) { $return[] = $array[$x]; } } } return $return; }
6
// flattenEachArrayToAnyDepth-------------------// // see - http://davidwalsh.name/flatten-nested-arrays-php in the coments //$res = array_flatten($myarray,array()); function array_flatten($array,$return){ foreach($array as $key => $value){ if(@is_array($value)){ $return = $this->array_flatten($value,$return); }elseif(@$value){ $return[$key] = $value; } } return $return; }
7
// doesnt seem to work properely // see - http://davidwalsh.name/flatten-nested-arrays-php#comment-56256} /** * Flattens a nested array. * * Based on: * {@link http://davidwalsh.name/flatten-nested-arrays-php#comment-56256} * * @param array $array - The array to flatten. * @param int $max_depth - How many levels to flatten. Negative numbers * mean flatten all levels. Defaults to -1. * @param int $_depth - The current depth level. Should be left alone. */ function array_flatten(array $array, $max_depth = -1, $_depth = 0) { $result = array(); foreach ($array as $key => $value) { if (is_array($value) && ($max_depth < 0 || $_depth < $max_depth)) { $flat = array_flatten($value, $max_depth, $_depth + 1); if (is_string($key)) { $duplicate_keys = array_keys(array_intersect_key($array, $flat)); foreach ($duplicate_keys as $k) { $flat["$key.$k"] = $flat[$k]; unset($flat[$k]); } } $result = array_merge($result, $flat); } else { if (is_string($key)) { $result[$key] = $value; } else { $result[] = $value; } } } return $result; }
8
// WORKS // this works but kills the keys // see - http://davidwalsh.name/flatten-nested-arrays-php function array_flatten($array, $return=array()) { foreach ($array AS $key => $value) { if(is_array($value)) { $return = array_flatten($value,$return); } else { if($value) { $return[] = $value; } } } return $return; }
9
// Ennio Wolsink // @Manu: if you replace $return[] = $value; with $return[$key] = $value; you get the preserve the index names of the source array(s). Don’t know if that’s everyone preference, but that was what I was looking for. If one wanted to make this optional, he could add a 3rd optional parameter to this function to indicate wether or not to preserve index names, like so: function array_flatten($array, $return=array(), $preserve_index_names = false) { foreach ($array AS $key => $value) { if(is_array($value)) { $return = array_flatten($value,$return, $preserve_index_names); } else { if($value) { if($preserve_index_names === false) { $return[] = $value; } else { $return[$key] = $value; } } } } return $return; } And then run it like so to get a flattened array back with index names preserved: $result = array_flatten($input, array(), true); And like this if you don’t want the index names preserved: $result = array_flatten($input);
10
// recursively reduces deep arrays to single-dimensional arrays // $preserve_keys: (0=>never, 1=>strings, 2=>always) // see - http://www.php.net//manual/en/function.array-values.php function array_flatten($array, $preserve_keys = 1, &$newArray = Array()) { foreach ($array as $key => $child) { if (is_array($child)) { $newArray =& array_flatten($child, $preserve_keys, $newArray); } elseif ($preserve_keys + is_string($key) > 1) { $newArray[$key] = $child; } else { $newArray[] = $child; } } return $newArray; }
11
// same array_flatten function, compressed and preserving keys. // see - http://www.php.net//manual/en/function.array-values.php function array_flatten($a,$f=array()){ if(!$a||!is_array($a))return ''; foreach($a as $k=>$v){ if(is_array($v))$f=self::array_flatten($v,$f); else $f[$k]=$v; } return $f; }
This code allows you to stretch background images when you page expands to provide a better user experience.
HTML
<link href="/global.css" rel="stylesheet" type="text/css" /> <table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0"> <tr> <td class="header" colspan="2"> </td> </tr> <tr> <td class="top"> </td> <td> </td> </tr> <tr> <td class="middle"><img src="/middle.jpg" alt="background image" id="bg" /></td> <td> </td> </tr> <tr> <td class="bottom" colspan="2"> </td> </tr> </table>
CSS
.top { width: 130px; height: 143px; background: black url('top.jpg') left top no-repeat; } .middle { width: 130px; height: 100%; /* background: url('middle.jpg') no-repeat; */ background-size: 100%; } td.middle img#bg { width:100%; height:100%; } .bottom { height: 59px; background: #fff url('bottom.jpg') left top no-repeat; }
Although this code is rigged using tables the method can easily be changed to use <div> .
Click here for a demo of this code