Sunday, June 16, 2013
Sunday, April 7, 2013
Php Convert String Specific Words To Links In Paragraphs.
Php Convert String Specific Words Within Paragraphs Into Links.
This little jewel allows you to do some sneaky self made tags within your blog or forum. Can be used before input or even better on coming out of the database query. The thing to remeber is that arrays are mirrored within preg_replace and require the $replacements variables to be in numeric reverse order. If you add another to the list it will be $items[3] and the new $replacements var will become [0] which moves the replacements up one numeric order. This would place shoes replacement at [3] shirts at [2] and jeans at[1] then new item var at [0].
?php
$string = 'She has shirts in blue her jeans in black and her shoes are all faded.';
$items = array();
$items[0] = '/shoes/'; //List of items you want changed//
$items[1] = '/shirts/';
$items[2] = '/jeans/';
$replacements = array();
$replacements[2] = 'a href="http://www.example.com/foot/shoes.php">Shoes /a>';
$replacements[1] = 'a href="index.php?items=shirts">Shirts /a>';
$replacements[0] = 'a href="index.php?items=jeans">Jeans /a>';
$output = preg_replace($items, $replacements, $string);
echo $output;// OR QUERY BACK INTO DATABASE//
?
Outputs: The paragraph and links on the selected items.
?php
$string = 'She has shirts in blue her jeans in black and her shoes are all faded.';
$items = array();
$items[0] = '/shoes/'; //List of items you want changed//
$items[1] = '/shirts/';
$items[2] = '/jeans/';
$replacements = array();
$replacements[2] = 'a href="http://www.example.com/foot/shoes.php">Shoes /a>';
$replacements[1] = 'a href="index.php?items=shirts">Shirts /a>';
$replacements[0] = 'a href="index.php?items=jeans">Jeans /a>';
$output = preg_replace($items, $replacements, $string);
echo $output;// OR QUERY BACK INTO DATABASE//
?
Outputs: The paragraph and links on the selected items.
Sunday, February 24, 2013
Using Php To Switch Css Styles Function
Use Php To Switch Css Styles Function()
My Template Engine----> This is a secret ! Not
very many programers know of this. This can switch css style sheets
using php by calling this function verses another one,,in which many
think impossible.
?php start tag here
{
?> php end tag here
#header_grad {
background-image: url(/images/networks/header_grad.png);
background-position: 0 0;
background-repeat: no-repeat;
float: left;
width: 100%;
min-height: 130px;
}
#header h1 {
margin: 45px 28px 0 28px;
}
#header h2 {
margin: 0 28px 0 28px;
padding: 2px 0 26px 0;
}
#content_wrapper h3.pagetitle {
font-size: 22px;
font-weight: normal;
padding-top: 10px;
margin-bottom: 23px;
font-family: "Trebuchet MS";
}
#header .logo {
margin: 45px 0 45px 28px;
}
?php start tag hereAdd as many as you want using php if conditions= ??? if condition=true { echo csstemp1() } else { echo cssTemp2() } click a button to change templates.
Thursday, February 21, 2013
Php MVC Framework EssenceOne !
Php MVC Framework EssenceOne !
Simple
EssenceOne uses one Model index.php page to handle everything you can throw at it. Simply add new views and controllers functions and classes and include them within the indexer. Then simply route every link through the index.php file indexer. Thats it. Views take in their required functions and classes by simply including them within each view by echo. Comes with Bootstrap and sessions support for users.Can be Downloaded here----essenceone-php-framework/downloads/list
Requires Wamp/Xamp/Lamp/Vertrigo or Online Server using Php+ and Mysql.
Wednesday, February 20, 2013
User Roles Function
User Roles Php Function !
USER ROLES FUNCTIONSfunction errorRep()
{
$error='Un Authorised !';
echo $error;
} //end function errorRep()
function userRole() //PLACE ($uid) for production //testing value only
{
//PLACE QUERY HERE-$result=mysql_query("SELECT id, role FROM users where id=.$uid.");
$role=2; //data result
$id=2; // test only data result //use htacces with this script.
if ($role == 1) {
echo 'Is User
';
echo 'Dashboard';
}
if ($role == 2) {
echo 'Is Editor
';
echo 'Dashboard';
}
if ($role == 3) {
echo 'Is Publisher
';
echo 'Dashboard';
}
if ($role == 4 and $id==1) { //advised to add global $admin here
echo 'Is Admin
';
echo 'Admin Panel';
}
if ($role == '') {
echo errorRep();
}
} // end function userRole()
echo userRole(); //for production use echo userRole($uid);
Md5 Plus Endless Salt !
Md5 Plus Added Salts !
What would you give to have salts to add to md5 or sha1 and making them any length and still retrieve them for password validation?
Enter code here...THE MD5 HASH ONLY GOES UP TO 32 CHARS,,,,FOR SECURITY WHY NOT ADD MORE? Or better yet add all you want, because This script only retrieves the original Md5 hash. !!!
SALT
function saltIt()
{
$password='razorback';
$addsalt='a5jcmnb62sdx';
$pass=(md5($password));
$salt=$pass.$addsalt;
echo $salt;
} //end function saltIt()
echo saltIt(); // password hash by robin deatherage
// our md5+added salt = a618b59e86b0042f6eb0341d25aedc c1a5jcmnb62sdx
UNSALT
function unSalt()
{
$mystring1=' a618b59e86b0042f6eb0341d25aedc c1a5jcmnb62sdx';//our md5+salt
$Remove_Our_Added_Salt=' a5jcmnb62sdx';
$nosalt =(mb_substr($mystring1, 0,32));//THE-SALT-CAN-BE-ANY- LENGTH-THIS RETRIEVES ONLY THE MD5.
echo $nosalt;
//outputs the original md5 without the added salt a618b59e86b0042f6eb0341d25aedc c1
} //end function unSalt()
echo unSalt();
Tuesday, February 19, 2013
Url-Parser-Function
Url Parser Function !
Asign variables for each parse and build your own Framework !
function parseIt(){
$url = 'http://127.0.0.1/root/index.php?arg=value#3445678abcd';
print_r(parse_url($url));
echo'';
echo '
http://';
echo parse_url($url, PHP_URL_HOST);
echo '
';
echo parse_url($url, PHP_URL_PATH);
echo '
?';
echo parse_url($url, PHP_URL_QUERY);
echo '
#';
echo parse_url($url, PHP_URL_FRAGMENT);
//parse_str($str);
} //end function parseIt()
echo parseIt();
OUTPUTS:
Array ( [scheme] => http [host] => 127.0.0.1 [path] => /root/index.php [query] => arg=value [fragment] => 3445678abcd )
http://127.0.0.1
/root/index.php
?arg=value
#3445678abcd
Subscribe to:
Posts (Atom)
