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
This is a method to disable 'Magic Quotes' when you need to turn them off for such things as joomla. The following instructions are to get your system php.ini file, disable Magic Quotes in this file, and then get the system to load the new file and overide the system php.ini using a command in your .htaccess file.
Please follow the instructions below:
; Magic quotes for incoming GET/POST/Cookie data.To
magic_quotes_gpc = On
; Magic quotes for incoming GET/POST/Cookie data.
magic_quotes_gpc = Off
<IfModule mod_suphp.c>
suPHP_ConfigPath /home/example/public_html
<Files php.ini>
order allow,deny
deny from all
</Files>
</IfModule>
There are a couple of ways to overide the PHP settings as defined in /usr/local/lib/php.ini (the system php.ini) and i will list them below.
NB: DO NOT PUT php.ini IN THE PUBLIC_HTML, they can be read and downloaded., only put them in there or any subfolder if they are protected.
You can just place a copy of your modified php.ini file, altered to your needs, in to any folder and all scripts run from that folder will run using the php.ini in the folder, instead of the system php.ini.
This is set in the .htaccess file and points to a php.ini of your choice. It is preferable to place this php.ini outside the public_html folders.
Examples
1 - This is the most basic of the command and will work for most people
suPHP_ConfigPath /home/example/php-folder/php.ini
2 - This example shows how you can put the php.ini in a public_html folder and prevent access to it. The suphp command will also not run unless the module is installed and this can prevent errors upon installation.
<IfModule mod_suphp.c> suPHP_ConfigPath /home/example/public_html <Files php.ini> order allow,deny deny from all </Files> </IfModule>
This is set in the .htaccess file and points to a php.ini of your choice. It is preferable to place this php.ini outside the public_html folders.
Examples
SetEnv PHPRC /home/example/php-folder/php.ini
Links
This assumes that you webhost company has already sideloaded the appropriate version of PHP you want to use. This is the .htaccess code required to tell the server to use the alternative version.
Sideloading PHP allows you to have mulitple PHP versions running on the same hosting account/server. You have the default PHP version and then the sideloaded ones which you can access by using an alternative php.ini defined by a .htaccess file. Using suPHP will override the default php.ini recursively.
This code below is put in your .htaccess file and configures the host to use a sideloaded version of PHP, in this case PHP 5.5.
# Custom Legacy PHP 5.5 handler placed by host AddType application/x-httpd-php55 .php5 .php4 .php .php3 .php2 .phtml suPHP_ConfigPath /usr/local/lib/php55.ini # End Custom Legacy PHP 5.5 handler placed by host
The target version of PHP needs to be installed by your host provider for this to work.
These instructions assume your phone has been unlocked/rooted, if not you should use the cyanogenmod windows installer to do the work for you.
The current ROM I am using is cm-11-20141230-NIGHTLY-i9100 on my Samsung Galaxy S2 i9100 (intl) from http://download.cyanogenmod.org/?device=i9100 and I used GApps from http://slimroms.net/index.php/downloads/dlsearch/viewcategory/1150-addons4-4 - I used the Slim_mini_gapps.4.4.4.build.8.x-385 og
When install a ROM it just replaces the /system/ partition (and cyanogen it also does the /boot/ partition) thus all system settings are saved which are stored in /data/
Does the following
Notes
Android 5.1.1 on Samsung S2 Links
Both my internal and external SDCards dissapered on my Samsung s2. The external SD Card when I removed it and put it in my windows PC it read normally and had no errors.
I do not know what the exact cause is but possibly one of the following, but you should consider that both of my SD Cards stopped working.
So Basically it appears that the partitions are mounted but the filessytem that is mounted is corrupt so it almost appears as if they are not mounted.
After days of research I did the following to get my SD Cards to work
External SD Card (sdcard1)
Internal Card (sdcard / sdcard0)
This is more tricky because it cannot be removed and this solution is currently the best I could come up with
These are my notes on all of the googleing and trying of different solutions
The terminal is a powerful tool to be able to help diagnose partion and disk issues
** add websites where appropriate to my links directory
My Samsung was already rooted so if yours is skip to the next section………
{Picture of odin here}
In the picture you can see the ROM is cut up into sections
So I Flashed by
Files I used for a successful flash
My Phone was already Rooted