Example #1
0
function GetData($val)
{
    $jd = GregorianToJD(1, 1, 1970);
    $gregorian = JDToGregorian($jd + intval($val) - 25569);
    return $gregorian;
    /**显示格式为 “月/日/年” */
}
Example #2
0
 public function getday($date = null)
 {
     $date22 = explode(" ", $date);
     $tgl1 = $date22[0];
     // 1 Oktober 2010
     $tgl2 = date("Y-m-d");
     // 24 Oktober 2010
     $pecah1 = explode("-", $tgl1);
     $date1 = $pecah1[2];
     $month1 = $pecah1[1];
     $year1 = $pecah1[0];
     $pecah2 = explode("-", $tgl2);
     $date2 = $pecah2[2];
     $month2 = $pecah2[1];
     $year2 = $pecah2[0];
     $jd1 = GregorianToJD($month1, $date1, $year1);
     $jd2 = GregorianToJD($month2, $date2, $year2);
     // hitung selisih hari kedua tanggal
     $selisih = $jd2 - $jd1;
     //echo $selisih;
     switch ($selisih) {
         case 0:
             return "Hari ini " . $this->getampm($date22[1]);
             break;
         case 1:
             return "Kemarin " . $this->getampm($date22[1]);
             break;
         default:
             $epldate = explode("-", $tgl1);
             return date("F j, Y", mktime(0, 0, 0, $epldate[1], $epldate[2], $epldate[0])) . " " . $this->getampm($date22[1]);
             break;
     }
 }
Example #3
0
 function nextMonth($date)
 {
     $this->JDtoYMD($date, $year, $month, $day);
     if (++$month > 12) {
         $month = 1;
         ++$year;
     }
     return GregorianToJD($month, $day, $year);
 }
Example #4
0
 /**
  * 规范读入的时间,该函数暂时未用到
  * @param unknown $val
  * @return string
  */
 function GetData($val)
 {
     $jd = GregorianToJD(1, 1, 1970);
     $gregorian = JDToGregorian($jd + intval($val) - 25569);
     return $gregorian;
     /**
      * 格林威治时间的转换
      */
 }
Example #5
0
 public function insert_pistahan($date, $event)
 {
     $jdate = $value;
     $jmonth = date("m", strtotime($value));
     $jday = date('j', strtotime($value));
     $jyear = date('Y', strtotime($value));
     $GregorianToJD = GregorianToJD($jmonth, $jday, $jyear);
     $query = "INSERT INTO `pistahan` (`juliandate`, `event_id`,`jdate`,`jday`,`jmonth`,`jyear`) VALUES (" . $GregorianToJD . "," . $value . "," . $jdate . "," . $jday . "," . $jmonth . "," . $jyear . ")";
     run_mysql_query($query);
     return;
 }
Example #6
0
function excelTime($days, $time = false)
{
    if (is_numeric($days)) {
        //based on 1900-1-1
        $jd = GregorianToJD(1, 1, 1970);
        $gregorian = JDToGregorian($jd + intval($days) - 25569);
        $myDate = explode('/', $gregorian);
        $myDateStr = str_pad($myDate[2], 4, '0', STR_PAD_LEFT) . "-" . str_pad($myDate[0], 2, '0', STR_PAD_LEFT) . "-" . str_pad($myDate[1], 2, '0', STR_PAD_LEFT) . ($time ? " 00:00:00" : '');
        return $myDateStr;
    }
    return $days;
}
function DaysBetween($date1, $date2)
{
    $date1 = getdate($date1);
    $date2 = getdate($date2);
    $first = GregorianToJD($date1[mon], $date1[mday], $date1[year]);
    $second = GregorianToJD($date2[mon], $date2[mday], $date2[year]);
    if ($first > $second) {
        return $first - $second;
    } else {
        return $second - $first;
    }
}
Example #8
0
function insertToEventTable($eventName, $eventDate, $duration)
{
    $calendar->insert_pistahan($eventDate, $eventName);
    // adjust duration
    $duration -= 1;
    // if duration is already 0, then exit. else call the function again to continue the insert
    if ($duration == 0) {
        return;
    }
    $eventDate = JDToGregorian(GregorianToJD(date("m", strtotime($eventDate)), date('j', strtotime($eventDate)), date('Y', strtotime($eventDate))) - 1);
    insertToEventTable($eventName, $eventDate, $duration);
    return;
}
function excelTime($days, $time = false)
{
    // 如果需要导入年月日的时候采用,第一参数是PHPExcel取出来的,第二参数给false就行了
    // 把phpexcel读出的日期数据转换成xxxx-m-y
    if (is_numeric($days)) {
        $jd = GregorianToJD(1, 1, 1970);
        $gregorian = JDToGregorian($jd + intval($days) - 25569);
        $myDate = explode('/', $gregorian);
        $myDateStr = str_pad($myDate[2], 4, '0', STR_PAD_LEFT) . "-" . str_pad($myDate[0], 2, '0', STR_PAD_LEFT) . "-" . str_pad($myDate[1], 2, '0', STR_PAD_LEFT) . ($time ? " 00:00:00" : '');
        return $myDateStr;
    }
    return $days;
}
Example #10
0
 function get_schedule_by_date($event, $date, $shift)
 {
     $date = explode("-", $date);
     $slot = GregorianToJD($date[1], $date[2], $date[0]) % $this->get_length_schedule($event) + 1;
     $this->db->select(array('user.nickname as nickname'));
     $this->db->where('event', $event);
     $this->db->where('slot', $slot);
     $this->db->where('shift', $shift);
     $this->db->join('user', 'schedule.user=user.kode', 'left');
     $this->db->order_by('user', 'asc');
     $result = $this->db->get($this->tbl_name)->result();
     $data = '';
     foreach ($result as $r) {
         $data .= '<div>' . $r->nickname . '</div>';
     }
     return $data;
 }
Example #11
0
function excelTime($date, $time = false)
{
    if (function_exists('GregorianToJD')) {
        if (is_numeric($date)) {
            $jd = GregorianToJD(1, 1, 1970);
            $gregorian = JDToGregorian($jd + intval($date) - 25569);
            $date = explode('/', $gregorian);
            $date_str = str_pad($date[2], 4, '0', STR_PAD_LEFT) . "-" . str_pad($date[0], 2, '0', STR_PAD_LEFT) . "-" . str_pad($date[1], 2, '0', STR_PAD_LEFT) . ($time ? " 00:00:00" : '');
            return $date_str;
        }
    } else {
        $date = $date > 25568 ? $date + 1 : 25569;
        /* There was a bug if Converting date before 1-1-1970 (tstamp 0) */
        $ofs = (70 * 365 + 17 + 2) * 86400;
        $date = date("Y-m-d", $date * 86400 - $ofs) . ($time ? " 00:00:00" : '');
    }
    return $date;
}
 function selisihTGl($tgl1, $tgl2)
 {
     $pecah1 = explode("-", $tgl1);
     $date1 = $pecah1[2];
     $month1 = $pecah1[1];
     $year1 = $pecah1[0];
     // memecah tanggal untuk mendapatkan bagian tanggal, bulan dan tahun
     // dari tanggal kedua
     $pecah2 = explode("-", $tgl2);
     $date2 = $pecah2[2];
     $month2 = $pecah2[1];
     $year2 = $pecah2[0];
     // menghitung JDN dari masing-masing tanggal
     $jd1 = GregorianToJD($month1, $date1, $year1);
     $jd2 = GregorianToJD($month2, $date2, $year2);
     // hitung selisih hari kedua tanggal
     $selisih = $jd2 - $jd1;
     return $selisih;
 }
Example #13
0
 function selisihHari($tglAwal, $tglAkhir)
 {
     // list tanggal merah selain hari minggu
     $tglLibur = array("2013-01-04", "2013-01-05", "2013-01-17");
     // memecah string tanggal awal untuk mendapatkan
     // tanggal, bulan, tahun
     $pecah1 = explode("-", $tglAwal);
     $date1 = $pecah1[2];
     $month1 = $pecah1[1];
     $year1 = $pecah1[0];
     // memecah string tanggal akhir untuk mendapatkan
     // tanggal, bulan, tahun
     $pecah2 = explode("-", $tglAkhir);
     $date2 = $pecah2[2];
     $month2 = $pecah2[1];
     $year2 = $pecah2[0];
     // mencari total selisih hari dari tanggal awal dan akhir
     $jd1 = GregorianToJD($month1, $date1, $year1);
     $jd2 = GregorianToJD($month2, $date2, $year2);
     $selisih = $jd2 - $jd1;
     // proses menghitung tanggal merah dan hari minggu
     // di antara tanggal awal dan akhir
     $libur1 = 0;
     $libur2 = 0;
     for ($i = 1; $i <= $selisih; $i++) {
         // menentukan tanggal pada hari ke-i dari tanggal awal
         $tanggal = mktime(0, 0, 0, $month1, $date1 + $i, $year1);
         $tglstr = date("Y-m-d", $tanggal);
         // menghitung jumlah tanggal pada hari ke-i
         // yang masuk dalam daftar tanggal merah selain minggu
         if (in_array($tglstr, $tglLibur)) {
             $libur1++;
         }
         // menghitung jumlah tanggal pada hari ke-i
         // yang merupakan hari minggu
         if (date("N", $tanggal) == 7) {
             $libur2++;
         }
     }
     // menghitung selisih hari yang bukan tanggal merah dan hari minggu
     return $selisih - $libur1 - $libur2;
 }
Example #14
0
	function selisihHari($tglAwal, $tglAkhir)
	{
	$tglLibur = Array("2015-08-05", "2013-01-05", "2013-01-17");
	$tahun=date('Y');
	$bulanini=date('m');
	$libur1=mysql_query("select * from hari_libur where BULAN='$bulanini' and YEAR(TANGGAL)='$tahun'");
	while($viewdata=mysql_fetch_object($libur1)){
	$harilibur1=array();
	$harilibur1=explode(",",$viewdata->TANGGAL);
		foreach($harilibur1 as $datalibur1){
		} 
	}
	$jumlahlibur1=count($harilibur1);
    $pecah1 = explode("-", $tglAwal);
    $date1 = $pecah1[2];
    $month1 = $pecah1[1];
    $year1 = $pecah1[0];
	$pecah2 = explode("-", $tglAkhir);
    $date2 = $pecah2[2];
    $month2 = $pecah2[1];
    $year2 =  $pecah2[0];
	$jd1 = GregorianToJD($month1, $date1, $year1);
    $jd2 = GregorianToJD($month2, $date2, $year2);

    $selisih = $jd2 - $jd1;
	for($i=1; $i<=$selisih; $i++)
    {
        
        $tanggal = mktime(0, 0, 0, $month1, $date1+$i, $year1);
        $tglstr = date("Y-m-d", $tanggal);
		if (in_array($tglstr, $tglLibur))
        {
           $libur1++;
        }
		if ((date("N", $tanggal) == 7))
        {
           $libur2++;
        }
    }
    return $selisih-$jumlahlibur1-$libur2;
}
 private function jvdate($day, $month, $year)
 {
     $julian = GregorianToJD($month, $day, $year);
     if ($julian >= 1937808 && $julian <= 536838867) {
         $date = cal_from_jd($julian, CAL_GREGORIAN);
         $d = $date['day'];
         $m = $date['month'] - 1;
         $y = $date['year'];
         $mPart = ($m - 13) / 12;
         $jd = $this->intPart(1461 * ($y + 4800 + $this->intPart($mPart)) / 4) + $this->intPart(367 * ($m - 1 - 12 * $this->intPart($mPart)) / 12) - $this->intPart(3 * $this->intPart(($y + 4900 + $this->intPart($mPart)) / 100) / 4) + $d - 32075;
         $l = $jd - 1948440 + 10632;
         $n = $this->intPart(($l - 1) / 10631);
         $l = $l - 10631 * $n + 354;
         $j = $this->intPart((10985 - $l) / 5316) * $this->intPart(50 * $l / 17719) + $this->intPart($l / 5670) * $this->intPart(43 * $l / 15238);
         $l = $l - $this->intPart((30 - $j) / 15) * $this->intPart(17719 * $j / 50) - $this->intPart($j / 16) * $this->intPart(15238 * $j / 43) + 29;
         $m = $this->intPart(24 * $l / 709);
         $d = $l - $this->intPart(709 * $m / 24);
         $y = 30 * $n + $j - 30;
         $yj = $y;
         //+512; Tahun jawa Tahun Hijriyah + 512
         $h = ($julian + 3) % 5;
         $i = $yj;
         if ($i >= 8) {
             while ($i > 7) {
                 $i = $i - 8;
                 $yn = $i;
             }
         } else {
             $yn = $i;
         }
         if ($julian <= 1948439) {
             $y--;
         }
         return array('dday' => $date['dow'], 'javaDay' => $d, 'javaMonth' => $m, 'javaYear' => $yj, 'javaDday' => $h, 'yearName' => $yn);
     } else {
         return false;
     }
 }
function selisihHari($tglAwal, $tglAkhir)
{
    // list tanggal merah selain hari minggu
    // memecah string tanggal awal untuk mendapatkan
    // tanggal, bulan, tahun
    $pecah1 = explode("-", $tglAwal);
    $date1 = $pecah1[2];
    $month1 = $pecah1[1];
    $year1 = $pecah1[0];
    // memecah string tanggal akhir untuk mendapatkan
    // tanggal, bulan, tahun
    $pecah2 = explode("-", $tglAkhir);
    $date2 = $pecah2[2];
    $month2 = $pecah2[1];
    $year2 = $pecah2[0];
    //exit("error:".$tglAwal."___".$tglAkhir);
    // mencari selisih hari dari tanggal awal dan akhir
    $jd1 = GregorianToJD($month1, $date1, $year1);
    $jd2 = GregorianToJD($month2, $date2, $year2);
    $selisih = $jd2 - $jd1;
    // menghitung selisih hari yang bukan tanggal merah dan hari minggu
    return $selisih;
}
Example #17
0
 public function __construct($birth_data)
 {
     $this->_birthLocation['longitude']['degree'] = $this->decimalDegree($birth_data['longitude']);
     $this->_birthLocation['longitude']['radian'] = deg2rad($this->_birthLocation['longitude']['degree']);
     $this->_birthLocation['longitude']['type'] = $this->birthLocationType(strtoupper($birth_data['longitude']['direction']));
     $this->_birthLocation['latitude']['degree'] = $this->decimalDegree($birth_data['latitude']);
     $this->_birthLocation['latitude']['radian'] = deg2rad($this->_birthLocation['latitude']['degree']);
     $this->_birthLocation['latitude']['type'] = $this->birthLocationType(strtoupper($birth_data['latitude']['direction']));
     $tz = $birth_data['timezone']['hours'] + $birth_data['timezone']['min'] / 60;
     $this->_timezone = $this->birthLocationType(strtoupper($birth_data['timezone']['direction'])) * $tz;
     $this->_birthTime['local']['HH'] = $birth_data['hour'];
     $this->_birthTime['local']['MM'] = $birth_data['min'];
     $this->_birthTime['local']['type'] = strtolower($birth_data['am_pm']);
     $this->_birthTime['local']['time24'] = $this->convertTime24($this->_birthTime['local']['HH'], $this->_birthTime['local']['MM'], $this->_birthTime['local']['type']);
     $this->convertTimeGMT();
     $this->_birthDay['DD'] = $birth_data['day'];
     $this->_birthDay['MM'] = $birth_data['month'];
     $this->_birthDay['YYYY'] = $birth_data['year'];
     $this->_jd = GregorianToJD($this->_birthDay['MM'], $this->_birthDay['DD'], $this->_birthDay['YYYY']) - 0.5;
     $this->_jd2000 = GregorianToJD(1, 1, 2000) - 0.5;
     $this->_d += $this->_jd - $this->_jd2000 + $this->_birthTime['GMT']['time24'] / 24 + 1;
     //+1 is neccesary to make this code work accurately.
     $this->_planet = array('Sun' => array(), 'Moon' => array(), 'Mercury' => array(), 'Venus' => array(), 'Mars' => array(), 'Jupiter' => array(), 'Saturn' => array(), 'Uranus' => array(), 'Neptune' => array(), 'Pluto' => array(), 'Rahu' => array(), 'Ketu' => array());
     if (!empty($birth_data['type']) && $birth_data['type'] == 'western') {
         $this->ayanansh = 0;
     } else {
         $this->ayanansh = $this->ayanansh($this->_d);
     }
     $this->calcLST();
     $this->getMidHeaven();
     $this->getAscendant();
     $this->housesEQUAL();
     $this->objPlanet = new Planet($this->_d, $this->ayanansh);
     $this->assignPlanet();
     //var_dump($this->_planet);
     //var_dump($this->_house);
 }
Example #18
0
 /**
  * Diese Methode aktualisiert die Zähler in der Datenbank und übergibt an
  * die lokalen Variablen alle nötigen Daten.
  **/
 public function refresh()
 {
     $cfg_tbl_users = $this->cfg_tbl_users;
     $cfg_tbl_save = $this->cfg_tbl_save;
     $cfg_online_time = $this->cfg_online_time;
     // Daten aus DB auslesen
     $sql = 'SELECT save_name, save_value FROM ' . $cfg_tbl_save;
     $command = Yii::app()->db->createCommand($sql);
     $dataReader = $command->query();
     $data = array();
     while (($row = $dataReader->read()) !== false) {
         $data[$row['save_name']] = $row['save_value'];
     }
     // Aktuellen Tag als julianisches Datum
     $today_jd = GregorianToJD(date('m'), date('j'), date('Y'));
     // Prüfen ob wir schon einen neuen Tag haben
     if ($today_jd != $data['day_time']) {
         // Anzahl der Besucher von heute auslesen
         $sql = 'SELECT COUNT(user_ip) AS user_count FROM ' . $cfg_tbl_users;
         $command = Yii::app()->db->createCommand($sql);
         $dataReader = $command->query();
         $row = $dataReader->read();
         $today_count = $row['user_count'];
         // Anzahl der Tage zum letzten Update ermitteln
         $days_between = $today_jd - $data['day_time'];
         // Zählerwert von heute auf gestern setzen
         $sql = 'UPDATE ' . $cfg_tbl_save . ' SET save_value=' . ($days_between == 1 ? $today_count : 0) . ' WHERE save_name="yesterday"';
         $command = Yii::app()->db->createCommand($sql);
         $command->execute();
         // Auf neuen Besucherrekord prüfen
         if ($today_count >= $data['max_count']) {
             // Daten aktualisieren
             $data['max_time'] = mktime(12, 0, 0, date('n'), date('j'), date('Y')) - 86400;
             $data['max_count'] = $today_count;
             // Rekordwerd speichern
             $sql = 'UPDATE ' . $cfg_tbl_save . ' SET save_value=' . $today_count . ' WHERE save_name="max_count"';
             $command = Yii::app()->db->createCommand($sql);
             $command->execute();
             // Aktuellen Tag als neuen Rekordtag speichern
             $sql = 'UPDATE ' . $cfg_tbl_save . ' SET save_value=' . $data['max_time'] . ' WHERE save_name="max_time"';
             $command = Yii::app()->db->createCommand($sql);
             $command->execute();
         }
         // Gesamtzähler erhöhen
         $sql = 'UPDATE ' . $cfg_tbl_save . ' SET save_value=save_value+' . $today_count . ' WHERE save_name="counter"';
         $command = Yii::app()->db->createCommand($sql);
         $command->execute();
         // Alte Besucherdaten aus Tabelle entfernen
         $sql = 'TRUNCATE TABLE ' . $cfg_tbl_users;
         $command = Yii::app()->db->createCommand($sql);
         $command->execute();
         // Datum aktualisieren
         $sql = 'UPDATE ' . $cfg_tbl_save . ' SET save_value=' . $today_jd . ' WHERE save_name="day_time"';
         $command = Yii::app()->db->createCommand($sql);
         $command->execute();
         // Daten aktualisieren
         $data['counter'] += $today_count;
         $data['yesterday'] = $days_between == 1 ? $today_count : 0;
     }
     // IP des Besuchers ermitteln
     $user_ip = Yii::app()->db->quoteValue(isset($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR']);
     // Besucher speichern oder aktualisieren
     $sql = 'INSERT INTO ' . $cfg_tbl_users . ' VALUES ("' . $user_ip . '", ' . time() . ') ON DUPLICATE KEY UPDATE user_time=' . time();
     $command = Yii::app()->db->createCommand($sql);
     $command->execute();
     // Rückgabearray initialisieren
     $output = array();
     // Anzahl der heutigen Besucher auslesen
     $sql = 'SELECT COUNT(user_ip) AS user_count FROM ' . $cfg_tbl_users;
     $command = Yii::app()->db->createCommand($sql);
     $dataReader = $command->query();
     $row = $dataReader->read();
     $output['today'] = $row['user_count'];
     // Gesamte Besucherzahl und Besucher vom Vortag zurückgeben
     $output['counter'] = $data['counter'] + $output['today'];
     $output['yesterday'] = $data['yesterday'];
     // Aktuelle Besucher der letzten x Minuten auslesen
     $sql = 'SELECT COUNT(user_ip) AS user_count FROM ' . $cfg_tbl_users . ' WHERE user_time>=' . (time() - $cfg_online_time * 60);
     $command = Yii::app()->db->createCommand($sql);
     $dataReader = $command->query();
     $row = $dataReader->read();
     $output['online'] = $row['user_count'];
     // Wurde der aktuelle Besucherrekord heute überschritten?
     if ($output['today'] >= $data['max_count']) {
         // Heutigen Tag als Rekord zurückgeben
         $output['max_count'] = $output['today'];
         $output['max_time'] = time();
     } else {
         // Alten Rekord zurückgeben
         $output['max_count'] = $data['max_count'];
         $output['max_time'] = $data['max_time'];
     }
     $this->user_total = $output['counter'];
     $this->user_online = $output['online'];
     $this->user_today = $output['today'];
     $this->user_yesterday = $output['yesterday'];
     $this->user_max_count = $output['max_count'];
     $this->user_time = $output['max_time'];
 }
Example #19
0
 /**
  * Convert given Gregorian date into Hijri date
  *
  * @param integer $Y Year Gregorian year
  * @param integer $M Month Gregorian month
  * @param integer $D Day Gregorian day
  *
  * @return array Hijri date [int Year, int Month, int Day](Islamic calendar)
  * @author Khaled Al-Sham'aa <*****@*****.**>
  */
 protected function hjConvert($Y, $M, $D)
 {
     if (function_exists('GregorianToJD')) {
         $jd = GregorianToJD($M, $D, $Y);
     } else {
         $jd = $this->gregToJd($M, $D, $Y);
     }
     list($year, $month, $day) = $this->jdToIslamic($jd);
     return array($year, $month, $day);
 }
Example #20
0
 function doctype()
 {
     qa_html_theme_base::doctype();
     if (qa_opt('badge_active')) {
         // tabs
         if ($this->template == 'user' && !qa_opt('badge_admin_user_field_no_tab')) {
             if (!isset($this->content['navigation']['sub'])) {
                 $this->content['navigation']['sub'] = array('profile' => array('url' => qa_path_html('user/' . $this->_user_handle(), null, qa_opt('site_url')), 'label' => $this->_user_handle(), 'selected' => !qa_get('tab') ? true : false), 'badges' => array('url' => qa_path_html('user/' . $this->_user_handle(), array('tab' => 'badges'), qa_opt('site_url')), 'label' => qa_lang('badges/badges'), 'selected' => qa_get('tab') == 'badges' ? true : false));
             } else {
                 $this->content['navigation']['sub']['badges'] = array('url' => qa_path_html('user/' . $this->_user_handle(), array('tab' => 'badges'), qa_opt('site_url')), 'label' => qa_lang('badges/badges'), 'selected' => qa_get('tab') == 'badges' ? true : false);
             }
         }
         require_once QA_INCLUDE_DIR . 'qa-app-users.php';
         $userid = qa_get_logged_in_userid();
         if (!$userid) {
             return;
         }
         // not logged in?  die.
         // first visit check
         $user = @qa_db_read_one_assoc(qa_db_query_sub('SELECT ^achievements.user_id AS uid,^achievements.oldest_consec_visit AS ocv,^achievements.longest_consec_visit AS lcv,^achievements.total_days_visited AS tdv,^achievements.last_visit AS lv,^achievements.first_visit AS fv, ^userpoints.points as points FROM ^achievements, ^userpoints WHERE ^achievements.user_id=# AND ^userpoints.userid=#', $userid, $userid), true);
         if (!$user['uid']) {
             qa_db_query_sub('INSERT INTO ^achievements (user_id, first_visit, oldest_consec_visit, longest_consec_visit, last_visit, total_days_visited, questions_read, posts_edited) VALUES (#, NOW(), NOW(), #, NOW(), #, #, #) ON DUPLICATE KEY UPDATE first_visit=NOW(), oldest_consec_visit=NOW(), longest_consec_visit=#, last_visit=NOW(), total_days_visited=#, questions_read=#, posts_edited=#', $userid, 1, 1, 0, 0, 1, 1, 0, 0);
             return;
         }
         // check lapse in days since last visit
         // using julian days
         $todayj = GregorianToJD(date('n'), date('j'), date('Y'));
         $last_visit = strtotime($user['lv']);
         $lastj = GregorianToJD(date('n', $last_visit), date('j', $last_visit), date('Y', $last_visit));
         $last_diff = $todayj - $lastj;
         $oldest_consec = strtotime($user['ocv']);
         $oldest_consecj = GregorianToJD(date('n', $oldest_consec), date('j', $oldest_consec), date('Y', $oldest_consec));
         $oldest_consec_diff = $todayj - $oldest_consecj + 1;
         // include the first day
         $first_visit = strtotime($user['fv']);
         $first_visitj = GregorianToJD(date('n', $first_visit), date('j', $first_visit), date('Y', $first_visit));
         $first_visit_diff = $todayj - $first_visitj;
         if ($last_diff < 0) {
             return;
         }
         // error
         if ($last_diff < 2) {
             // one day or less, update last visit
             if ($oldest_consec_diff > $user['lcv']) {
                 $user['lcv'] = $oldest_consec_diff;
                 qa_db_query_sub('UPDATE ^achievements SET last_visit=NOW(), longest_consec_visit=#, total_days_visited=total_days_visited+#  WHERE user_id=#', $oldest_consec_diff, $last_diff, $userid);
             } else {
                 qa_db_query_sub('UPDATE ^achievements SET last_visit=NOW(), total_days_visited=total_days_visited+# WHERE user_id=#', $last_diff, $userid);
             }
             $badges = array('dedicated', 'devoted', 'zealous');
             qa_badge_award_check($badges, $user['lcv'], $userid, null, 2);
         } else {
             // 2+ days, reset consecutive days due to lapse
             qa_db_query_sub('UPDATE ^achievements SET last_visit=NOW(), oldest_consec_visit=NOW(), total_days_visited=total_days_visited+1 WHERE user_id=#', $userid);
         }
         $badges = array('visitor', 'trouper', 'veteran');
         qa_badge_award_check($badges, $user['tdv'], $userid, null, 2);
         $badges = array('regular', 'old_timer', 'ancestor');
         qa_badge_award_check($badges, $first_visit_diff, $userid, null, 2);
         // check points
         if (isset($user['points'])) {
             $badges = array('100_club', '1000_club', '10000_club');
             qa_badge_award_check($badges, $user['points'], $userid, null, 2);
         }
     }
 }
    $tgl2 = $_POST['tglabis'];
    // memecah tanggal untuk mendapatkan bagian tanggal, bulan dan tahun
    // dari tanggal pertama
    $pecah1 = explode("-", $tgl1);
    $date1 = $pecah1[2];
    $month1 = $pecah1[1];
    $year1 = $pecah1[0];
    // memecah tanggal untuk mendapatkan bagian tanggal, bulan dan tahun
    // dari tanggal kedua
    $pecah2 = explode("-", $tgl2);
    $date2 = $pecah2[2];
    $month2 = $pecah2[1];
    $year2 = $pecah2[0];
    // menghitung JDN dari masing-masing tanggal
    $jd1 = GregorianToJD($month1, $date1, $year1);
    $jd2 = GregorianToJD($month2, $date2, $year2);
    // hitung selisih hari kedua tanggal
    $selisih = $jd2 - $jd1;
    if (empty($idpem)) {
        ?>
<script>alert('Nama Pengguna tidak ada');</script>
<?php 
    } else {
        if (empty($idbuk)) {
            ?>
<script>alert('Buku tidak ada');</script>
<?php 
        } else {
            if (!empty($bu['id']) and empty($bu['tglkembali'])) {
                ?>
<script>alert('Pengguna sudah meminjam buku yang sama');</script>
Example #22
0
 /**
  * Returns an array of  month, day, year, ln: which is "Islamic lunation number 
  * (Births of New Moons)", int: The length of current month.
  * 
  * @param $day Integer Gregorian day of the month
  * @param $month Integer Gregorian month number
  * @param $year Integer Gregorian year in full (1999)
  * @return Array Hijri date[int month, int day, int year, int ln, int ml]
  * @see Robert Gent method maker (http://www.phys.uu.nl/~vgent/islam/ummalqura.htm)
  */
 public static function toHijri($day = 20, $month = 02, $year = 1976)
 {
     $jd = GregorianToJD($month, $day, $year);
     $mjd = $jd - 2400000;
     foreach (static::$jdl as $i => $v) {
         if ($v > $mjd - 1) {
             break;
         }
     }
     $iln = $i + 15588;
     // Islamic lunation number (Births of New Moons)
     $ii = floor(($i - 1) / 12);
     $year = 1300 + $ii;
     // year
     $month = $i - 12 * $ii;
     // month
     $day = $mjd - static::$jdl[$i - 1];
     //day
     $ml = static::$jdl[$i] - static::$jdl[$i - 1];
     // Month Length
     list($_Date["month"], $_Date["day"], $_Date["year"], $_Date["ln"], $_Date["ml"]) = array($month, $day, $year, $iln, $ml);
     return $_Date;
 }
Example #23
0
 function excelTime($date, $time = false)
 {
     if (is_numeric($date)) {
         $jd = GregorianToJD(1, 1, 1970);
         $gregorian = JDToGregorian($jd + intval($date) - 25569);
         $date = explode('/', $gregorian);
         $date_str = str_pad($date[2], 4, '0', STR_PAD_LEFT) . "-" . str_pad($date[0], 2, '0', STR_PAD_LEFT) . "-" . str_pad($date[1], 2, '0', STR_PAD_LEFT) . ($time ? " 00:00:00" : '');
         return $date_str;
     }
     return $date;
 }
 $tgl8 = $r['tgl_cair_4'];
 // memecah tanggal untuk mendapatkan bagian tanggal, bulan dan tahun
 // dari tanggal pertama
 $pecah7 = explode("-", $tgl7);
 $date7 = $pecah7[2];
 $month7 = $pecah7[1];
 $year7 = $pecah7[0];
 // memecah tanggal untuk mendapatkan bagian tanggal, bulan dan tahun
 // dari tanggal kedua
 $pecah8 = explode("-", $tgl8);
 $date8 = $pecah8[2];
 $month8 = $pecah8[1];
 $year8 = $pecah8[0];
 // menghitung JDN dari masing-masing tanggal
 $jd7 = GregorianToJD($month7, $date7, $year7);
 $jd8 = GregorianToJD($month8, $date8, $year8);
 // hitung selisih hari kedua tanggal
 $selisih4 = $jd8 - $jd7;
 $ccc = 90;
 $ddd = 30;
 $koe = 0;
 $eee = $selisih > $ccc;
 $fff = $selisih < $ddd;
 $ab = "CEK BSO";
 $ct = "OK";
 $a1 = $r[max_kredit] - $r[cair_1] - $r[cair_2] - $r[cair_3] - $r[cair_4];
 $a1 = number_format($a1, 0, ',', '.');
 $r[max_kredit] = number_format($r[max_kredit], 0, ',', '.');
 $r[cair_1] = number_format($r[cair_1], 0, ',', '.');
 $r[cair_2] = number_format($r[cair_2], 0, ',', '.');
 $r[cair_3] = number_format($r[cair_3], 0, ',', '.');
Example #25
0
 /**
  * Calculate the percent illumination of the moon (0 <= k <= 1) on the given input Julian Day
  *
  * @param double $inJulian Fractional Julian Day to calculate percent illumination of the moon's disc on
  * @return double illuminated fraction of moon's disc
  * @uses Revolution
  */
 function simple_illumination()
 {
     // From MyWee Pascal
     $DST = date("Z") / 3600;
     // 2;
     // $JOU = date("z");
     // $LAT = deg2rad( 42. );
     // $LON = deg2rad( 2. );
     // $SO = 1367.6;
     // $HOD = (date("G")*60 + date("i") - .5) / 60; //tSV
     // $HRA = 2*pi()*($HOD - 12.0) / 24.0; //Angle Horaire
     $jd = GregorianToJD(date("m"), date("d"), date("Y"));
     // $HD = ((date("G")+((date('i') + date('s') / 60)/60))/24);
     // correct for half-day offset
     $dayfrac = date('G') / 24 - 0.5;
     if ($dayfrac < 0) {
         $dayfrac += 1;
     }
     // now set the fraction of a day
     $frac = $dayfrac + (date('i') + date('s') / 60) / 60 / 24;
     $julianDate = $jd + $frac - $DST / 24;
     // pg. 131 */
     /**
      * Julian Centuries
      */
     $julian_centuries = ($julianDate - 2451545.0) / 36525.0;
     /**
      * mean elogation of the moon
      */
     $D = 297.8502042 + 445267.1115168 * $julian_centuries - 0.00163 * $julian_centuries * $julian_centuries + $julian_centuries * $julian_centuries * $julian_centuries / 545868 - $julian_centuries * $julian_centuries * $julian_centuries * $julian_centuries / 113065000;
     /**
      * sun's mean anomaly
      */
     $M = 357.5291092 + 35999.0502909 * $julian_centuries - 0.0001536 * $julian_centuries * $julian_centuries + $julian_centuries * $julian_centuries * $julian_centuries / 24490000;
     /**
      * moon's mean anomaly
      */
     $Mprime = 134.9634114 + 477198.8676313 * $julian_centuries + 0.008997 * $julian_centuries * $julian_centuries + $julian_centuries * $julian_centuries * $julian_centuries / 69699 - $julian_centuries * $julian_centuries * $julian_centuries * $julian_centuries / 14712000;
     $D = fmod($D, 360.0);
     $M = fmod($M, 360.0);
     $Mprime = fmod($Mprime, 360.0);
     $M = deg2rad($M);
     $Mprime = deg2rad($Mprime);
     /**
      * phase angle of the moon
      */
     $i = 180 - $D - 6.289 * sin($Mprime) + 2.1 * sin($M) - 1.274 * sin(2 * $D - $Mprime) - 0.658 * sin(2 * $D) - 0.214 * sin(2 * $Mprime) - 0.11 * sin(deg2rad($D));
     /**
      * illuminated fraction of moon's disc
      */
     $k = (1 + cos(deg2rad($i))) / 2;
     return $k;
 }
Example #26
0
																			<?php 
                $id_anggota_booking = $fetch_booking_cek['id_anggota'];
                $tempo_id = $fetch_booking_cek['tempo'];
                #tanggal tempo
                $tempo = explode("-", $fetch_booking_cek['tempo']);
                $tgl1 = $tempo[2];
                $bulan1 = $tempo[1];
                $tahun1 = $tempo[0];
                #tanggal skearang
                $sekarang = explode("-", date("Y-m-d"));
                $tgl2 = $sekarang[2];
                $bulan2 = $sekarang[1];
                $tahun2 = $sekarang[0];
                #transfomasi JD
                $jd1 = GregorianToJD($bulan1, $tgl1, $tahun1);
                $jd2 = GregorianToJD($bulan2, $tgl2, $tahun2);
                #menghitung selisih
                $selisih = $jd1 - $jd2;
                echo '<p>Buku yang anda booking adalah ' . $fetch_booking_cek['judul'] . '</p>';
                echo 'Sisa Tempo buku yang anda booking adalah ' . $selisih . ' Hari. Segera menghubungi petugas. Booking akan terhapus otomatis jika tempo telah selesai';
                if ($selisih <= 0) {
                    ?>
																						<script>
																							alert("Jatuh Tempo Booking telah selesai. Kami akan menghapus data buku yang anda booking");
																						</script>
																					<?php 
                    mysql_query("DELETE FROM t_booking WHERE id_anggota='{$id_anggota_booking}' AND tempo = '{$tempo_id}'");
                    mysql_query("UPDATE t_buku SET status='tersedia' WHERE kd_buku = '" . $fetch_booking_cek['kd_buku'] . "'");
                    ?>
																						<script>
																							location.href = "home.php";
Example #27
0
function long_carr($y, $mo, $d, $et, $helio_long)
{
    //; based on sun.pro code (SolarSoft)
    //;       Notes: based on the book Astronomical Formulae
    //;         for Calculators, by Jean Meeus.
    $jd = GregorianToJD($mo, $d, $y) - 0.5 + $et / 24.0;
    $PI = 3.14159265358979;
    $radeg = 180.0 / $PI;
    $T1900 = 2415020.0;
    //;        Julian Centuries from 1900.0               ;
    $t = ($jd - $T1900) / 36525.0;
    $t2 = $t * $t;
    $t3 = $t2 * $t;
    //;        Geometric Mean Longitude (deg)             ;
    $mnl = 279.69668 + 36000.76892 * $t + 0.0003025 * $t2;
    $mnl = fmod($mnl, 360.0);
    //;        Mean anomaly (deg)                         ;
    $mna = 358.47583 + 35999.04975 * $t - 0.00015 * $t2 - 3.3E-6 * $t3;
    $mna = fmod($mna, 360.0);
    //;        Sun's equation of center (deg)             ;
    $mna = $mna / $radeg;
    $c = (1.91946 - 0.004789 * $t - 1.4E-5 * $t2) * sin($mna) + (0.020094 - 0.0001 * $t) * sin(2 * $mna) + 0.000293 * sin(3 * $mna);
    //;        Sun's true geometric longitude (deg)       ;
    //;        refered to the mean equinox of date.       ;
    //;        Should the higher accuracy terms (not      ;
    //;        included here) be added to true_long?      ;
    //;        (from which app_long is derived).          ;
    $true_long = fmod($mnl + $c, 360.0);
    //;        Apparent longitude (deg) from true         ;
    //;        longitude.                                 ;
    $omega = 259.18 - 1934.142 * $t;
    //;        Heliographic coordinates                   ;
    $theta = ($jd - 2398220.0) * 360.0 / 25.38;
    $i = 7.25;
    $k = 74.3646 + 1.395833 * $t;
    $lambda = $true_long - 0.00569;
    $lambda2 = $lamda - 0.00479 * sin($omega / $radeg);
    $diff = ($lambda - $k) / $radeg;
    //;        Latitude at center of disk (deg)           ;
    $lat0 = asin(sin($diff) * sin($i / $radeg)) * $radeg;
    //;        Longitude at center of disk (deg)          ;
    $y = -sin($diff) * cos($i / $radeg);
    $x = -cos($diff);
    //convert x,y->r,eta /DEG
    $eta = atan($y / $x) * $radeg;
    if ($x < 0) {
        $eta += 180.0;
    }
    if ($eta < 0) {
        $eta += 360.0;
    }
    $long0 = fmod($eta - $theta, 360.0);
    if ($long0 < 0) {
        $long0 += 360.0;
    }
    $out = round(fmod($helio_long + $long0, 360.0), 2);
    return $out;
}
Example #28
0
 private function first_day_of_month($date)
 {
     list($aa, $mm, $dd) = explode('-', $date);
     return ($d = jddayofweek(GregorianToJD($mm, 1, $aa), 0)) == 0 ? 7 : $d;
 }
 function qa_check_all_users_badges()
 {
     $awarded = 0;
     $users;
     $temp = qa_db_query_sub('SELECT * FROM ^posts');
     while (($post = qa_db_read_one_assoc($temp, true)) !== null) {
         if (!$post['userid']) {
             continue;
         }
         $user = '******' . $post['userid'];
         $pid = $post['postid'];
         $pt = $post['type'];
         // get post count
         if (isset($users[$user]) && isset($users[$user][$pt])) {
             $users[$user][$pt]++;
         } else {
             $users[$user][$pt] = 1;
         }
         // get post votes
         if ($post['netvotes'] != 0) {
             $users[$user][$pt . 'votes'][] = array('id' => $pid, 'votes' => (int) $post['netvotes'], 'parentid' => $post['parentid'], 'created' => $post['created']);
         }
         // get post views
         if ($post['views']) {
             $users[$user]['views'][] = array('id' => $pid, 'views' => $post['views']);
         }
     }
     //votes received and given out
     $voter = qa_db_read_all_assoc(qa_db_query_sub('SELECT userid,qupvotes,qdownvotes,aupvotes,adownvotes,upvoteds FROM ^userpoints'));
     foreach ($voter as $idx => $votes) {
         $user = '******' . $votes['userid'];
         // votes
         $users[$user]['votes'] = (int) $votes['qupvotes'] + (int) $votes['qdownvotes'] + (int) $votes['aupvotes'] + (int) $votes['adownvotes'];
         // voteds
         $users[$user]['voted'] = (int) $votes['upvoteds'];
         unset($voter[$idx]);
     }
     // flags
     $flag_result = qa_db_read_all_values(qa_db_query_sub('SELECT userid FROM ^uservotes WHERE flag > 0'));
     foreach ($flag_result as $idx => $flag) {
         $user = '******' . $flag;
         // get flag count
         if (isset($users[$user]) && isset($users[$user]['flags'])) {
             $users[$user]['flags']++;
         } else {
             $users[$user]['flags'] = 1;
         }
         unset($flag_result[$idx]);
     }
     // per user loop
     foreach ($users as $user => $data) {
         $uid = (int) substr($user, 4);
         // bulk posts
         $badges = array('Q' => array('asker', 'questioner', 'inquisitor'), 'A' => array('answerer', 'lecturer', 'preacher'), 'C' => array('commenter', 'commentator', 'annotator'));
         foreach ($badges as $pt => $slugs) {
             if (!isset($data[$pt])) {
                 continue;
             }
             $awarded += count(qa_badge_award_check($slugs, $data[$pt], $uid, null, 0));
         }
         // nice Q&A
         $badges = array('nice_question', 'good_question', 'great_question', 'nice_answer', 'good_answer', 'great_answer');
         if ($this->badge_activated($badges)) {
             $badges = array('Q' => array('nice_question', 'good_question', 'great_question'), 'A' => array('nice_answer', 'good_answer', 'great_answer'));
             foreach ($badges as $pt => $slugs) {
                 foreach ($slugs as $badge_slug) {
                     if (!isset($data[$pt . 'votes'])) {
                         continue;
                     }
                     foreach ($data[$pt . 'votes'] as $idv) {
                         // poll plugin integration
                         if ($pt == 'A' && qa_opt('poll_enable')) {
                             $poll = qa_db_read_one_value(qa_db_query_sub('SELECT meta_value FROM ^postmeta WHERE post_id=# AND meta_key=$', $idv['id'], 'is_poll'), true);
                             if ($poll) {
                                 continue;
                             }
                         }
                         if ((int) $idv['votes'] >= (int) qa_opt('badge_' . $badge_slug . '_var') && qa_opt('badge_' . $badge_slug . '_enabled') !== '0') {
                             $result = qa_db_read_one_value(qa_db_query_sub('SELECT badge_slug FROM ^userbadges WHERE user_id=# AND object_id=# AND badge_slug=$', $uid, $idv['id'], $badge_slug), true);
                             if ($result == null) {
                                 // not already awarded this badge
                                 $this->award_badge($idv['id'], $uid, $badge_slug, false, true);
                                 $awarded++;
                             }
                             // old question answer vote checks
                             if ($pt == 'A') {
                                 $qid = $idv['parentid'];
                                 $create = strtotime($idv['created']);
                                 $parent = $this->get_post_data($qid);
                                 $pcreate = strtotime($parent['created']);
                                 $diff = round(abs($pcreate - $create) / 60 / 60 / 24);
                                 $badge_slug2 = $badge_slug . '_old';
                                 if ($diff >= (int) qa_opt('badge_' . $badge_slug2 . '_var') && qa_opt('badge_' . $badge_slug2 . '_enabled') !== '0') {
                                     $result = qa_db_read_one_value(qa_db_query_sub('SELECT badge_slug FROM ^userbadges WHERE user_id=# AND object_id=# AND badge_slug=$', $uid, $idv['id'], $badge_slug2), true);
                                     if ($result == null) {
                                         // not already awarded for this answer
                                         $this->award_badge($idv['id'], $uid, $badge_slug2);
                                         $awarded++;
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
         // votes per user badges
         if (isset($data['votes'])) {
             $votes = $data['votes'];
             $badges = array('voter', 'avid_voter', 'devoted_voter');
             $awarded += count(qa_badge_award_check($badges, $votes, $uid, null, 0));
         }
         // voted per user badges
         if (isset($data['voted'])) {
             $votes = $data['voted'];
             $badges = array('liked', 'loved', 'revered');
             $awarded += count(qa_badge_award_check($badges, $votes, $uid, null, 0));
         }
         // views per post badges
         if (isset($data['views'])) {
             $badges = array('notable_question', 'popular_question', 'famous_question');
             foreach ($data['views'] as $idv) {
                 $awarded += count(qa_badge_award_check($badges, $idv['views'], $uid, $idv['id'], 0));
             }
         }
         // flags per user
         if (isset($data['flags'])) {
             $flags = $data['flags'];
             $badges = array('watchdog', 'bloodhound', 'pitbull');
             $awarded += count(qa_badge_award_check($badges, $flags, $uid, null, 0));
         }
         unset($users[$user]);
     }
     // selects, selecteds
     $badges = array('gifted', 'wise', 'enlightened', 'grateful', 'respectful', 'reverential');
     if ($this->badge_activated($badges)) {
         $selects = qa_db_read_all_assoc(qa_db_query_sub('SELECT aselects, aselecteds, userid FROM ^userpoints'));
         foreach ($selects as $idx => $s) {
             $uid = $s['userid'];
             if (isset($s['aselecteds'])) {
                 $count = $s['aselecteds'];
                 $badges = array('gifted', 'wise', 'enlightened');
                 $awarded += count(qa_badge_award_check($badges, $count, $uid, null, 0));
             }
             if (isset($s['aselects'])) {
                 $count = $s['aselects'];
                 $badges = array('grateful', 'respectful', 'reverential');
                 $awarded += count(qa_badge_award_check($badges, $count, $uid, null, 0));
             }
             unset($selects[$idx]);
         }
     }
     // achievements
     $badges = array('dedicated', 'devoted', 'zealous', 'visitor', 'trouper', 'veteran', 'regular', 'old_timer', 'ancestor', 'reader', 'avid_reader', 'devoted_reader');
     if ($this->badge_activated($badges)) {
         $userq = qa_db_query_sub('SELECT user_id AS uid,questions_read AS qr,oldest_consec_visit AS ocv,longest_consec_visit AS lcv,total_days_visited AS tdv,last_visit AS lv,first_visit AS fv,posts_edited AS pe FROM ^achievements');
         while (($user = qa_db_read_one_assoc($userq, true)) !== null) {
             $uid = $user['uid'];
             // edits
             $count = $user['pe'];
             $badges = array('editor', 'copy_editor', 'senior_editor');
             $awarded += count(qa_badge_award_check($badges, $count, $uid, null, 0));
             // on-sign-in badges
             // check lapse in days since last visit
             // using julian days
             $todayj = GregorianToJD(date('n'), date('j'), date('Y'));
             $last_visit = strtotime($user['lv']);
             $lastj = GregorianToJD(date('n', $last_visit), date('j', $last_visit), date('Y', $last_visit));
             $last_diff = $todayj - $lastj;
             $first_visit = strtotime($user['fv']);
             $first_visitj = GregorianToJD(date('n', $first_visit), date('j', $first_visit), date('Y', $first_visit));
             $first_visit_diff = $todayj - $first_visitj;
             $badges = array('dedicated', 'devoted', 'zealous');
             $awarded += count(qa_badge_award_check($badges, $user['lcv'], $uid, null, 0));
             $badges = array('visitor', 'trouper', 'veteran');
             $awarded += count(qa_badge_award_check($badges, $user['tdv'], $uid, null, 0));
             $badges = array('regular', 'old_timer', 'ancestor');
             $awarded += count(qa_badge_award_check($badges, $first_visit_diff, $uid, null, 0));
             // views
             $badges = array('reader', 'avid_reader', 'devoted_reader');
             $awarded += count(qa_badge_award_check($badges, $user['qr'], $uid, null, 0));
         }
     }
     // points
     $badges = array('100_club', '1000_club', '10000_club');
     if ($this->badge_activated($badges)) {
         $userq = qa_db_query_sub('SELECT userid, points FROM ^userpoints');
         while (($user = qa_db_read_one_assoc($userq, true)) !== null) {
             $awarded += count(qa_badge_award_check($badges, $user['points'], $user['userid'], null, 0));
         }
     }
     if (!QA_FINAL_EXTERNAL_USERS) {
         // verified
         $badges = array('verified');
         if ($this->badge_activated($badges)) {
             $userq = qa_db_query_sub('SELECT userid, flags FROM ^users WHERE flags&#', QA_USER_FLAGS_EMAIL_CONFIRMED);
             while (($user = qa_db_read_one_assoc($userq, true)) !== null) {
                 $awarded += count(qa_badge_award_check($badges, false, $user['userid'], null, 0));
             }
         }
         // profile stuff
         $badges = array('avatar', 'profiler');
         if ($this->badge_activated($badges)) {
             $userq = qa_db_query_sub('SELECT userid FROM ^users');
             while (($userid = qa_db_read_one_value($userq, true)) !== null) {
                 list($useraccount, $userprofile, $userfields) = qa_db_select_with_pending(qa_db_user_account_selectspec($userid, true), qa_db_user_profile_selectspec($userid, true), qa_db_userfields_selectspec());
                 // avatar badge
                 if (qa_opt('avatar_allow_upload') && isset($useraccount['avatarblobid'])) {
                     $badges = array('avatar');
                     $awarded += count(qa_badge_award_check($badges, false, $userid, null, 0));
                 }
                 // profile completion
                 $missing = false;
                 foreach ($userfields as $userfield) {
                     if (!isset($userprofile[$userfield['title']]) || @$userprofile[$userfield['title']] === '') {
                         $missing = true;
                         break;
                     }
                 }
                 if (!$missing) {
                     $badges = array('profiler');
                     $awarded += count(qa_badge_award_check($badges, false, $userid, null, 0));
                 }
             }
         }
     }
     // rebuild badges from other plugins - experimental! - $module->custom_badges_rebuild() returns number of badges awarded.
     $moduletypes = qa_list_module_types();
     foreach ($moduletypes as $moduletype) {
         $modulenames = qa_list_modules($moduletype);
         foreach ($modulenames as $modulename) {
             $module = qa_load_module($moduletype, $modulename);
             if (method_exists($module, 'custom_badges_rebuild')) {
                 $awarded += $module->custom_badges_rebuild();
             }
         }
     }
     // badges
     $badges = array('medalist', 'champion', 'olympian');
     if ($this->badge_activated($badges)) {
         $badgelist = qa_db_read_all_values(qa_db_query_sub('SELECT user_id FROM ^userbadges'));
         $users = array();
         foreach ($badgelist as $idx => $medal) {
             $user = '******' . $medal;
             // get badge count
             if (isset($users[$user]) && isset($users[$user]['medals'])) {
                 $users[$user]['medals']++;
             } else {
                 $users[$user]['medals'] = 1;
             }
             unset($badgelist[$idx]);
         }
         foreach ($users as $user => $data) {
             $uid = (int) substr($user, 4);
             // check badges
             if (isset($data['medals'])) {
                 $uid = (int) substr($user, 4);
                 $count = $data['medals'];
                 $awarded += count(qa_badge_award_check($badges, $count, $uid, null, 0));
             }
             unset($users[$user]);
         }
     }
     // return ok text
     return $awarded . ' badge' . ($awarded != 1 ? 's' : '') . ' awarded.';
 }
Example #30
0
function gethariterlambat($tglAwal, $tglAkhir)
{
    // memecah string tanggal awal untuk mendapatkan
    // tanggal, bulan, tahun
    $pecah1 = explode("-", $tglAwal);
    $date1 = $pecah1[2];
    $month1 = $pecah1[1];
    $year1 = $pecah1[0];
    // memecah string tanggal akhir untuk mendapatkan
    // tanggal, bulan, tahun
    $pecah2 = explode("-", $tglAkhir);
    $date2 = $pecah2[2];
    $month2 = $pecah2[1];
    $year2 = $pecah2[0];
    $jd1 = GregorianToJD($month1, $date1, $year1);
    $jd2 = GregorianToJD($month2, $date2, $year2);
    $selisih = $jd2 - $jd1;
    if ($selisih <= 0) {
        $selisih = 0;
    }
    return $selisih;
}