PHP Classes

File: examples/adjuster.php

Recommend this page to a friend!
  Classes of Saeed Hubaishan   PHP Hijri Date Calendar   examples/adjuster.php   Download  
File: examples/adjuster.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP Hijri Date Calendar
Convert and manipulate Hijri dates
Author: By
Last change: Update of examples/adjuster.php
Date: 1 year ago
Size: 5,969 bytes
 

Contents

Class file image Download
<?php
/** adjuster for hijridatetime class
 * by hubaishan http://salafitech.net
 * ver 2.1
 * 8 dulqidah 1436 h
 *
 */
// These setting can by edited
define("our_pwd", "hijri"); // password
$hijri_settings = array('umalqura' => TRUE, 'langecode' => 'ar');



// example when using file
// END of edit able setting
// do not edit below
require_once ("../hijri.class.php");
session_start();
if (
array_key_exists('adj_data', $_SESSION)) {
   
$hijri_settings['adj_data'] = $_SESSION['adj_data'];
}

$adj = new hijri\calendaradjustment();

$msg = '';
if (!empty(
$_POST['login'])) {
   
$_SESSION['password'] = $_POST['password'];
   
header("Location: " . $_SERVER["SCRIPT_NAME"]);
    exit();
} elseif (
array_key_exists('add', $_GET)) {
   
header("Location: " . $_SERVER["SCRIPT_NAME"] . "?action=add&month=" . $_GET['month'] . "&year=" . $_GET['year']);
    exit();
} elseif (
array_key_exists('exit', $_POST)) {
   
session_destroy();
   
header("Location: " . $_SERVER["SCRIPT_NAME"]);
    exit();
} elseif (
array_key_exists('addadj', $_POST)) {
   
$adj->add_adj($_POST['month'], $_POST['year'], $_POST['v']);
   
$_SESSION['adj_data'] = $adj->get_adjdata(TRUE);
   
header("Location: " . $_SERVER["SCRIPT_NAME"]);
    exit();
} elseif (
array_key_exists('deladj', $_POST)) {
   
$adj->del_adj($_POST['month'], $_POST['year']);
   
$_SESSION['adj_data'] = $adj->get_adjdata(TRUE);
   
header("Location: " . $_SERVER["SCRIPT_NAME"]);
    exit();
}
?>
<html dir="rtl">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>????? ????? ?? ?????</title>
</head>

<body>
<?php
$no_session
= TRUE;
if (
array_key_exists('password', $_SESSION)) {
    if (
$_SESSION['password'] == our_pwd) {
       
$no_session = FALSE;
    }
}
if (
$no_session) {
    echo
'
    <br><br><center>
    <form method="post">
    ???? ??????
    <input type="password" name="password" value="" /><br>
    <input type="submit" name="login" value="????" />
    </form>'
;
    exit();
}

$hmonths = array(1 => "????", "???", "???? ?????", "???? ??????", "????? ??????", "????? ??????", "???", "?????", "?????", "????", "?? ??????", "?? ?????");

if (isset(
$_GET['action'])) {
    if (
$_GET['action'] == 'del') {
        echo
"?? ???? ???????? ??? ????? ?????" . $hmonths[$_GET['month']] . " ?? ????? " . $_GET['year'];
       
$auto_del = $adj->auto_del_info($_GET['month'], $_GET['year']);
        if (!empty(
$auto_del)) {
            echo
" ???? ??? ??????? ?????? ";
            foreach (
$auto_del as $k) {
                echo
$hmonths[$k['month']] . ' ?? ??? ' . $k['year'];
            }
            echo
"???????";
        }
        echo
"\n" . '<form method="post"><input type="hidden" name="deladj" value=1><input type="hidden" name="month" value=' . $_GET['month'] . '><input type="hidden" name="year" value=' . $_GET['year'] . '><input type="submit" name="submit" value="??? ????????" /></from>';
        echo
'<a href="' . $_SERVER['SCRIPT_NAME'] . '">?????</a>';
    } elseif (
$_GET['action'] == 'edit' or $_GET['action'] == 'add') {
       
$hm = $_GET['month'];
       
$hy = $_GET['year'];
        echo
"????? ????? ????? " . $hmonths[$hm] . " ?? ??? $hy ???:";
        echo
'<form method="post"><input type="hidden" name="addadj" value=1><input type="hidden" name="month" value=' . $hm . '><input type="hidden" name="year" value=' . $hy . '><select name="v">';
       
$starts = $adj->get_possible_starts($hm, $hy);
        foreach (
$starts as $start) {
            echo
'<option value="' . $start['jd'] . '"' . (($start['currentset']) ? ' selected' : '') . ' >' . $start['grdate'];
            foreach (
$start['alsoadjdata'] as $v) {
                echo
" ????? ???? ????? ????? ??? " . $hmonths[$v['month']] . " ?? ??? " . $v['year'] . " ???:" . $v['grdate'];
            }
            echo
"</option>";
        }
        echo
'</select><input type="submit" name="submit" value="?????" />';
        echo
'<a href="' . $_SERVER['SCRIPT_NAME'] . '">?????</a>';
    }
} else {
   
    echo
'<h2>????????? ??????? ??? ????? ?? ?????</h2>';
    echo
$msg . '<br/>';
    foreach (
$adj->get_current_adjs() as $v) {
        echo
$v['year'] . "/ " . $v['month'] . " - " . $hmonths[$v['month']] . " => " . $v['current'] . " ????????? ?? " . $v['default'] . " [<a href='" . $_SERVER['SCRIPT_NAME'] . "?action=del&amp;month=" . $v['month'] . "&amp;year=" . $v['year'] . "'>???</a>] [<a href='" . $_SERVER['SCRIPT_NAME'] . "?action=edit&amp;month=" . $v['month'] . "&amp;year=" . $v['year'] . "'>?????</a>]<br/>";
    }
    echo
'<h2>????? ????? ??? ????? ?? ?????</h2>';
    echo
hijri\datetime::createFromHijri(1436, 11, 0)->format('_d _M _Y=d M Y') . '<br/>';
    echo
hijri\datetime::createFromHijri(1436, 12, 0)->format('_d _M _Y=d M Y') . '<br/>';
    echo
hijri\datetime::createFromHijri(1437, 1, 0)->format('_d _M _Y=d M Y') . '<br/>';
    echo
hijri\datetime::createFromHijri(1437, 2, 0)->format('_d _M _Y=d M Y') . '<br/>';
    echo
hijri\datetime::createFromHijri(1437, 3, 0)->format('_d _M _Y=d M Y') . '<br/>';
    echo
'<form method="get">????? :<select name="year">';
   
$d = new hijri\datetime();
    list(
$mymonth, $myyear) = explode(' ', $d->format('_m _Y'));
    for (
$n = hijri\Calendar::umstartyear; $n < hijri\Calendar::umendyear + 1; $n++) {
        echo
"<option value='$n'";
        if (
$n == $myyear) {
            echo
" selected ";
        }
        echo
">$n</option>\n";
    }
    echo
'</select> ????? :<select name="month">';
    for (
$n = 1; $n < 13; $n++) {
        echo
"<option value='$n'";
        if (
$n == $mymonth) {
            echo
"selected";
        }
        echo
">" . $hmonths[$n] . "</option>\n";
    }
    echo
'</select><input type="submit" name="add" value="??? ?????" /></form>';
    echo
'<br/>?????? ???????<br/><textarea rows="6" cols="50" style="text-align:left;direction: ltr;">';
    echo
$adj->get_adjdata(TRUE);
    echo
'</textarea><br/>';
    echo
'<br/><form method="post"><input type="submit" name="exit" value="????" /></form>';
}
?>

    </body>

</html>