emprit

chapps

Mar 13th, 2013
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 6.45 KB | None | 0 0
  1. <?php
  2. /*
  3.  * Dibuat           : Alcom Edunet
  4.  * Alamat           : Gondang, Wonosobo Jateng
  5.  * Oleh             : Chabib Nurozak
  6.  * Dikerjakan pada  : 23 Juni 2012
  7.  * Email            : [email protected]
  8.  * Versi/PHP        : chapps-1.2/5.3.x
  9. */
  10. /* start program */
  11. function chappsstart($title=null,$data=null){
  12.     $title = (isset($title))? $title : 'Selamat Datang';
  13.     if (isset($data)){
  14.         if (is_array($data)){
  15.             extract($data);
  16.             echo (isset($doctype))? "<!$doctype><html><head>" : "<!doctype html><html><head>";
  17.             echo "<title>$title</title>";
  18.             echo (isset($favicon))? "<link rel='shortcut icon' href='$favicon'/>" : "<link rel='shortcut icon' href='http://fbcdn-sphotos-a.akamaihd.net/hphotos-ak-ash4/321273_186478848101769_100002189661207_438871_2102331646_n.jpg'/>";
  19.             echo (isset($contenttype))? "<meta http-equiv='content-type' content='$contenttype'/>" : "<meta http-equiv='content-type' content='text/html; charset=UTF-8'/>";
  20.             echo (isset($keywords))? "<meta name='keywords' content='$keywords'/>" : '';
  21.             echo (isset($discription))? "<meta name='discription' content='$discription'/>" : '';
  22.             echo (isset($revised))? "<meta name='revised' content='$revised'/>" : '';
  23.             echo (isset($generator))? "<meta name='generator' content='$generator'/>" : '';
  24.         }
  25.         else {}
  26.     }
  27.     else {echo "<!doctype html><html><head><title>$title</title>";}
  28.     echo "<link rel='stylesheet' type='text/css' href='c/button.css'/>";
  29.     echo "</head><body>";
  30. }
  31. function chappsend(){
  32.     echo "</body></html>";
  33. }
  34. /* function form */
  35. function chappsstartform($action,$method,$formtitle){
  36.     echo "<form action='$action' method='$method'>";
  37.     echo "<table>\n";
  38.     echo "<tr><th colspan='2'>$formtitle</th></tr>\n";
  39. }
  40. function chappsinputtext($title,$name,$val=null){
  41.     echo "<tr><td>$title</td><td>: <input type='text' name='$name' placeholder='$title' value='$val'/></td></tr>\n";
  42. }
  43. function chappsselectcategory($title,$table='category'){
  44.     echo "<tr><td>$title</td><td>: <select name='category'>";
  45.     $query = mysql_query("SELECT * FROM `$table`");
  46.     while($cat=  mysql_fetch_assoc($query)){
  47.         echo "<option value='". $cat['id_category'] ."'>".$cat['name_category']."</option>";
  48.     }
  49.     echo "</select></td></tr>\n";
  50. }
  51. function chappsinputhidden($name,$val){
  52.     echo "<input type='hidden' name='$name' value='$val'/>";
  53. }
  54. function chappsbutton($valsubmit,$valreset){
  55.     echo "<tr><td colspan='2' align='center'><input type='submit' name='submit' value='$valsubmit'/> <input type='reset' value='$valreset'/></td></tr>";
  56. }
  57. function chappsendform(){
  58.     echo "</table></form>";
  59. }
  60. /* end function form */
  61. /*rupiah */
  62. function chappsrupiah($uang){
  63.     return "<div style='text-align: right;'><span style='float:left'>Rp. </span>".number_format($uang,2,',','.')."</div>";
  64. }
  65.  
  66. /*end rupiah */
  67. /* pagging */
  68. function chappspagginglimit(){
  69.     global $limit;
  70.     $lim = (isset($limit))? $limit : 10;
  71.     $limaw = (isset($_GET['page']) AND $_GET['page'] != 0) ? (intval($_GET['page']) - 1) * $lim : 0;
  72.     return "$limaw,$lim";
  73. }
  74. function chappsnumstart(){
  75.     global $limit;
  76.     $lim = (isset($limit))? $limit : 10;
  77.     $start = (isset($_GET['page']) AND $_GET['page'] != 0) ? (intval($_GET['page']) - 1) * $lim : 0;
  78.     return $start;
  79. }
  80. function chappspagging($num,$addlink=null){
  81.     global $limit;
  82.     $h_p = "http://".$_SERVER['SERVER_NAME'].$_SERVER['PHP_SELF'];
  83.     $lim = (isset($limit))? $limit : 10;
  84.     $addurl = (isset($addlink) AND $addlink != '') ? $addlink."&" : '';
  85.     $jumlahpagging = ceil($num/$lim);
  86.     $nprev = "Prev";
  87.     $nnext = "Next";
  88.     if (isset($_GET['page'])){
  89.         $page = $_GET['page'];
  90.         $pprev = $page-1;
  91.         $pnext = $page+1;
  92.         if ($jumlahpagging<=1){
  93.             $prev = $nprev;
  94.             $next = $nnext;
  95.         }
  96.         elseif ($page == '' || $page-1 == 0){
  97.             $prev = "$nprev";
  98.             $next = "<li><a href='$h_p?".$addurl."page=$pnext'>$nnext</a></li>";
  99.         }
  100.         elseif ($page+1 > $jumlahpagging){
  101.             $prev = "<li><a href='$h_p?".$addurl."page=$pprev'>$nprev</a></li>";
  102.             $next = "$nnext";
  103.         }
  104.        
  105.         else{
  106.            
  107.             $prev = "<li><a href='$h_p?".$addurl."page=".$pprev."'>$nprev</a></li>";
  108.             $next = "<li><a href='$h_p?".$addurl."page=".$pnext."'>$nnext</a></li>";
  109.         }
  110.        
  111.     }
  112.     else {
  113.         if ($jumlahpagging<=1){
  114.             $prev = $nprev;
  115.             $next = $nnext;
  116.         }
  117.         else {
  118.         $prev = "$nprev";
  119.         $next = "<li><a href='$h_p?".$addurl."page=2'>$nnext</a></li>";
  120.         }
  121.     }
  122.     echo "$prev";
  123.     for ($pagging = 1; $pagging <= $jumlahpagging; $pagging++){
  124.         $e = " <li><a href='$h_p?".$addurl."page=$pagging'>$pagging</a></li>";
  125.         if (isset($_GET['page'])){
  126.             if ($_GET['page'] != ''){
  127.                 echo ($_GET['page'] == $pagging) ? " <b>$pagging</b>" : $e;
  128.             }
  129.             else {
  130.                 echo ($pagging == 1) ? " <b>$pagging</b>" : $e;
  131.             }
  132.         }
  133.         else {
  134.             echo ($pagging == 1) ? " <b>$pagging</b>" : $e;
  135.         }
  136.     }
  137.     echo " $next ";
  138. }
  139. /* end pagging */
  140.  
  141. /* date  time day */
  142. function chappsdate($waktu){
  143.     if (isset($waktu)){
  144.     $waktu_bulan= substr($waktu,5,2)-1;
  145.     $bulan_aray= array('Januari','Februari','Maret','April','Mei','Juni','Juli','Agustus','September','Oktober','November','Desember');
  146.     return substr($waktu,8,2)." ".$bulan_aray[$waktu_bulan]." ".substr($waktu,0,4);
  147.     }
  148. }
  149. function chappsdatetime($waktu){
  150.     if (isset($waktu)){
  151.     $waktu_bulan= substr($waktu,5,2)-1;
  152.     $bulan_aray= array('Januari','Februari','Maret','April','Mei','Juni','Juli','Agustus','September','Oktober','November','Desember');
  153.     return "<div>".substr($waktu,8,2)." ".$bulan_aray[$waktu_bulan]." ".substr($waktu,0,4)." ".substr($waktu,11,8)."</div>";
  154.     }
  155. }
  156.  
  157. function chappsday($date){
  158.     $hari = array('Minggu','Senin','Selasa','Rabu','Kamis','Jumat','Sabtu');
  159.     return $hari[$date];
  160. }
  161. /* end date time day */
  162.  
  163. /*file open */
  164. function chappsopenfile($dir){
  165. if ($handle = opendir($dir."/")) { //opendir diisi sama dir target
  166.     while (false !== ($file = readdir($handle))) {
  167.         if ($file != "." && $file != "..") {
  168.             if (is_file($dir."/".$file)){
  169.             }
  170.         }
  171.     }
  172.     closedir($handle);
  173.     }  
  174. }
Advertisement
Add Comment
Please, Sign In to add comment