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

function cssTemp()
{
?> 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 here

} //end function cssTemp()
?> php end tag here

Then simply call the function at the top of a page between the script tags.
Add 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 FUNCTIONS

function 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 = a618b59e86b0042f6eb0341d25aedcc1a5jcmnb62sdx

UNSALT
function unSalt()
{
$mystring1
='a618b59e86b0042f6eb0341d25aedcc1a5jcmnb62sdx';//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 a618b59e86b0042f6eb0341d25aedcc1
} //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

Friday, February 15, 2013

Simplist Php Framework Ever.

Simple Php Framework. 

 Make this your main controller index.php page and start creating. Include your modals, in turn they request your views and page controllers. To pass id's for user etc by using index.php?page=profile&id= etc. Links too can all be passed using index.php?page= etc.
Add more pages if needed.

include('head.php');                    //head section above body tag= one or two second for members
?>
if(isset($_GET['page']))
{
  $page = ($_GET['page']);

  if($page == 'home')
  {
  include('menu.php');          //or members menus after login with a duplicate member/index.php
  include('leftmenu.php');
  include('home.php');
  include('rightmenu.php');
  include('footer.php');
  }
    if($page == 'about')
    {
    include('menu.php');
    include('leftmenu.php');
    include('about.php');
    include('rightmenu.php');
    include('footer.php');
    }
       if($page == 'policy')
       {
       include('menu.php');
       include('leftmenu.php');
       include('policy.php');
       include('rightmenu.php');
       include('footer.php');
       }
           if($page == 'signup')
           {
            include('menu.php');
            include('leftmenu.php');
            include('signup.php');
            include('rightmenu.php');
            include('footer.php');
            }
               if($page =='')
               {
               include('menu.php');
               include('leftmenu.php');
               include('home.php');
               include('rightmenu.php');
               include('footer.php');
               }

} else {
       include('menu.php');
       include('leftmenu.php');
       include('home.php');
       include('rightmenu.php');
       include('footer.php');
}
?>

Monday, February 4, 2013

Php Percent Of Profit Calculator Function

To customize this remove the =100 and =50 from the variable values. Place this into a php page and use a form to pass the values and sanitize them then add the function call line  below that to show output of this calculator. You will need two inputs to be passed one for Retail and One for Cost.

function percentOf($retail=100, $cost=50)
{
 $profit = ($retail - $cost);
 $percent = ($profit / $retail);
 $totalpercent = ($percent * 100);
 echo 'Total Retail
$';
 echo $retail;
 echo '
Subtract Total Cost
$cost;
Equals Profit $';
 echo $profit;
 echo '
Percent Total=';
 echo $percent;
 echo '%
You made a ';
 echo $totalpercent;
 echo ' percent profit';
 
 
 
  //return $link;

} // end function percentOf()

echo percentOf();

Php Retail Grocery Daily Report Function

PHP Retail Grocery DAILY REPORT FUNCTION

function dailyRep($totalz=17098, $tax=57, $gaskey=1775, $gas=1772, $lot=412, $mo=275, $ccr=545, $nonfood=1270, $oring=23, $dep=15998)
{
 $premerch=($totalz - $gaskey - $tax - $lot - $mo - $oring);
 $totalsales=($premerch + $lot + $mo);
 $nontax=($premerch - $nonfood);
 $gasdif=($gas - $gaskey);
 $moneys=($premerch + $tax + $gas + $lot + $mo);
 $cash=($dep + $ccr);
 $cashshort=($dep + $ccr - $moneys);

 echo 'Total From Z Reading
$';
 echo $totalz;
 echo '
Less Overings
$';
 echo $oring;
 echo '
Less Gas Sales Actual-----------------------Gas Actual
$';
 echo $gas;
 echo '
Less Gas From Z Tape
$';
 echo $gaskey;
 echo '
Dif +/-
';
 echo $gasdif;
 echo '
Equals Non Taxable Grocery Sales
$';
 echo $nontax;
 echo '
Plus Taxable Grocery Sales
$';
 echo $nonfood;
 echo '
Equals Total Merchandise Sales--------------Total Merchandise Sales
$';
 echo $totalsales;
 echo '
Add Tax-------------------------------------Plus Tax
$';
 echo $tax;
 echo '
Money To Account For-----------MA-------------Money Accounting
$';
 echo $moneys;
 echo '
Credit Card Report (counts as money)--CCR-----Add To Cash Count
$';
 echo $ccr;
 echo '
Total Money Counted Including Checks & CCR----Cash Deposit Count
$';
 echo $cash;
 echo '
Cash +/-(If this line is less than M/A it is Short)Total Over/Short Cash
';
 echo $cashshort;
  //return $link;

} // end function myFunction()

echo dailyRep();  //OUR FUNCTION CALL

Saturday, February 2, 2013

Automatic Query Pagination

Automatic Pagination Using query_count And Limit Control !

Simply place then into a function and query a count from the database, and assign $total to your query returned value

$total = $result_count['value'];

//querymsql_count as $total then devide by rows !
$rows = 10; // how many rows to show on each page !
$total = 50; //taken from query_count rows in database.
$count = ($total / $rows); //devide $total by $rows and pass this for pagination foreach
foreach (range('1', ''.$count.'') as $char) {
 print '' . $char . ' | ';
}
?>