[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: StrToTime.php
<?php /** * ---------------------------------------------------------------------- * * Copyright (c) 2006-2016 Khaled Al-Sham'aa. * * http://www.ar-php.org * * PHP Version 5 * * ---------------------------------------------------------------------- * * LICENSE * * This program is open source product; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License (LGPL) * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see <http://www.gnu.org/licenses/lgpl.txt>. * * ---------------------------------------------------------------------- * * Class Name: Arabic StrToTime Class * * Filename: StrToTime.php * * Original Author(s): Khaled Al-Sham'aa <khaled@ar-php.org> * * Purpose: Parse about any Arabic textual datetime description into * a Unix timestamp * * ---------------------------------------------------------------------- * * Arabic StrToTime Class * * PHP class to parse about any Arabic textual datetime description into * a Unix timestamp. * * The function expects to be given a string containing an Arabic date format * and will try to parse that format into a Unix timestamp (the number of seconds * since January 1 1970 00:00:00 GMT), relative to the timestamp given in now, or * the current time if none is supplied. * * Example: * <code> * date_default_timezone_set('UTC'); * $time = time(); * * echo date('l dS F Y', $time); * echo '<br /><br />'; * * include('./I18N/Arabic.php'); * $obj = new I18N_Arabic('StrToTime'); * * $int = $obj->strtotime($str, $time); * $date = date('l dS F Y', $int); * echo "<b><font color=#FFFF00>Arabic String:</font></b> $str<br />"; * echo "<b><font color=#FFFF00>Unix Timestamp:</font></b> $int<br />"; * echo "<b><font color=#FFFF00>Formated Date:</font></b> $date<br />"; * </code> * * @category I18N * @package I18N_Arabic * @author Khaled Al-Sham'aa <khaled@ar-php.org> * @copyright 2006-2016 Khaled Al-Sham'aa * * @license LGPL <http://www.gnu.org/licenses/lgpl.txt> * @link http://www.ar-php.org */ /** * This PHP class parse about any Arabic textual datetime description into a * Unix timestamp * * @category I18N * @package I18N_Arabic * @author Khaled Al-Sham'aa <khaled@ar-php.org> * @copyright 2006-2016 Khaled Al-Sham'aa * * @license LGPL <http://www.gnu.org/licenses/lgpl.txt> * @link http://www.ar-php.org */ class I18N_Arabic_StrToTime { private static $_hj = array(); private static $_strtotimeSearch = array(); private static $_strtotimeReplace = array(); /** * Loads initialize values * * @ignore */ public function __construct() { $xml = simplexml_load_file(dirname(__FILE__).'/data/ArStrToTime.xml'); foreach ($xml->xpath("//str_replace[@function='strtotime']/pair") as $pair) { array_push(self::$_strtotimeSearch, (string)$pair->search); array_push(self::$_strtotimeReplace, (string)$pair->replace); } foreach ($xml->hj_month->month as $month) { array_push(self::$_hj, (string)$month); } } /** * This method will parse about any Arabic textual datetime description into * a Unix timestamp * * @param string $text The string to parse, according to the GNU » * Date Input Formats syntax (in Arabic). * @param integer $now The timestamp used to calculate the * returned value. * * @return Integer Returns a timestamp on success, FALSE otherwise * @author Khaled Al-Sham'aa <khaled@ar-php.org> */ public static function strtotime($text, $now) { $int = 0; for ($i=0; $i<12; $i++) { if (strpos($text, self::$_hj[$i]) > 0) { preg_match('/.*(\d{1,2}).*(\d{4}).*/', $text, $matches); include dirname(__FILE__).DIRECTORY_SEPARATOR.'Mktime.php'; $temp = new I18N_Arabic_Mktime(); $fix = $temp->mktimeCorrection($i+1, $matches[2]); $int = $temp->mktime(0, 0, 0, $i+1, $matches[1], $matches[2], $fix); $temp = null; break; } } if ($int == 0) { $patterns = array(); $replacements = array(); array_push($patterns, '/َ|ً|ُ|ٌ|ِ|ٍ|ْ|ّ/'); array_push($replacements, ''); array_push($patterns, '/\s*ال(\S{3,})\s+ال(\S{3,})/'); array_push($replacements, ' \\2 \\1'); array_push($patterns, '/\s*ال(\S{3,})/'); array_push($replacements, ' \\1'); $text = preg_replace($patterns, $replacements, $text); $text = str_replace( self::$_strtotimeSearch, self::$_strtotimeReplace, $text ); $pattern = '[ابتثجحخدذرزسشصضطظعغفقكلمنهوي]'; $text = preg_replace("/$pattern/", '', $text); $int = strtotime($text, $now); } return $int; } }
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server1.winmanyltd.com
Server IP: 203.161.60.52
PHP Version: 8.3.27
Server Software: Apache
System: Linux server1.winmanyltd.com 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64
HDD Total: 117.98 GB
HDD Free: 59.6 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
Yes
git:
Yes
User Info
Username: eliosofonline
User ID (UID): 1002
Group ID (GID): 1003
Script Owner UID: 1002
Current Dir Owner: 1002