Example #1
0
<?php

/**
 * Example of render Phoenician language transliteration
 *
 * @category  I18N
 * @package   I18N_Arabic
 * @author    Khaled Al-Sham'aa <*****@*****.**>
 * @copyright 2006-2016 Khaled Al-Sham'aa
 *
 * @license   LGPL <http://www.gnu.org/licenses/lgpl.txt>
 * @link      http://www.ar-php.org
 */
error_reporting(E_STRICT);
!empty($_GET['w']) ? $word = $_GET['w'] : ($word = 'خالد الشمعة');
require '../../Arabic.php';
$x = new I18N_Arabic('Hiero');
$x->setLanguage('Phoenician');
$im = $x->str2graph($word, 'rtl', 'ar');
$w = imagesx($im);
$h = imagesy($im);
$bg = imagecreatefromjpeg('images/bg.jpg');
$bgw = imagesx($bg);
$bgh = imagesy($bg);
// Set the content-type
header("Content-type: image/png");
imagecopyresized($bg, $im, ($bgw - $w) / 2, ($bgh - $h) / 2, 0, 0, $w, $h, $w, $h);
imagepng($bg);
imagedestroy($im);
imagedestroy($bg);
Example #2
0
 * @category  I18N
 * @package   I18N_Arabic
 * @author    Khaled Al-Sham'aa <*****@*****.**>
 * @copyright 2006-2016 Khaled Al-Sham'aa
 *
 * @license   LGPL <http://www.gnu.org/licenses/lgpl.txt>
 * @link      http://www.ar-php.org
 */
error_reporting(E_STRICT);
$time_start = microtime(true);
date_default_timezone_set('UTC');
$time = time();
echo date('l dS F Y', $time);
echo '<br /><br />';
require '../../Arabic.php';
$Arabic = new I18N_Arabic('StrToTime');
$str = 'الخميس القادم';
$int = $Arabic->strtotime($str, $time);
$date = date('l dS F Y', $int);
echo "{$str} - {$int} - {$date}<br /><br />";
$str = 'الأحد الماضي';
$int = $Arabic->strtotime($str, $time);
$date = date('l dS F Y', $int);
echo "{$str} - {$int} - {$date}<br /><br />";
$str = 'بعد أسبوع و ثلاثة أيام';
$int = $Arabic->strtotime($str, $time);
$date = date('l dS F Y', $int);
echo "{$str} - {$int} - {$date}<br /><br />";
$str = 'منذ تسعة أيام';
$int = $Arabic->strtotime($str, $time);
$date = date('l dS F Y', $int);
Example #3
0
 * @category  I18N
 * @package   I18N_Arabic
 * @author    Khaled Al-Sham'aa <*****@*****.**>
 * @copyright 2006-2013 Khaled Al-Sham'aa
 *
 * @license   LGPL <http://www.gnu.org/licenses/lgpl.txt>
 * @link      http://www.ar-php.org
 */
error_reporting(E_STRICT);
$time_start = microtime(true);
date_default_timezone_set('GMT');
$time = time();
echo date('l dS F Y h:i:s A', $time);
echo '<br /><br />';
require '../../Arabic.php';
$Arabic = new I18N_Arabic('Date');
$correction = $Arabic->dateCorrection($time);
echo $Arabic->date('l dS F Y h:i:s A', $time, $correction);
$day = $Arabic->date('j', $time, $correction);
echo ' [<a href="Moon.php?day=' . $day . '" target=_blank>القمر الليلة</a>]';
echo '<br /><br />';
$Arabic->setMode(2);
echo $Arabic->date('l dS F Y h:i:s A', $time);
echo '<br /><br />';
$Arabic->setMode(3);
echo $Arabic->date('l dS F Y h:i:s A', $time);
echo '<br /><br />';
$Arabic->setMode(4);
echo $Arabic->date('l dS F Y h:i:s A', $time);
echo '<br /><br />';
$Arabic->setMode(5);
Example #4
0
header('Content-type: application/pdf');
/*
 * Needed for fpdf library not for ArPHP library
 */
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT);
date_default_timezone_set('UTC');
define('FPDF_FONTPATH', 'PDF/font/');
require 'PDF/ufpdf.php';
$pdf = new UFPDF();
$pdf->Open();
$pdf->SetTitle('UFPDF is Cool.');
$pdf->SetAuthor('Khaled Al-Shamaa');
$pdf->AddFont('ae_AlHor', '', 'ae_AlHor.php');
$pdf->AddPage();
require '../../Arabic.php';
$Arabic = new I18N_Arabic('Glyphs');
$text = "\n" . 'العنوان هو "AJAX era!" باللغة الإنجليزية';
$text .= "\n\n" . 'في حقيقة الأمر، لقد سبق لشركة Microsoft ذاتها التعامل مع تقنية Ajax هذه منذ أواخر تسعينات القرن الماضي, لا بل أنها لا تزال تستخدم تلك التقنية في تعزيز مقدرة برنامجها الشهير Outlook للبريد الإلكتروني. وعلى الرغم من كون تقنية Ajax تقنية قديمة العهد نسبيا، إلا أنها لم تلق (حين ظهورها أول مرة) الكثير من الاهتمام، إلا أن الفضل يعود إلى شركة Google في نفض الغبار عنها ولإعادة إكتشافها من جديد، وذلك من خلال طائفة من تطبيقاتها الجديدة والتي يقع على رأسها كل من غوغل Maps إضافة إلى مخدم البريد الإلكتروني Gmail واللذين شكلا فعلا علامة فارقة في عالم الويب وإشارة واضحة إلى ما ستؤول إليه تطبيقات الويب في المستقبل القريب. فهل أعجبتك الفكرة؟ سوريا، حلب في 13 أيار 2007 مـ';
$text .= "\n\nتصحيح طريقة عرض الأرقام المتصلة بأحرف إنجليزية كـ 3M و W3C على سبيل المثال";
$text .= "\n\nخالد الشمعة khaled@ar-php.org والموقع هو http://www.ar-php.org";
// Known bugs:
//$text = 'The title is "عصر الأجاكس!" in Arabic';
//$text = ' مؤسسة (World Wide Web Consortium) W3C';
//$text = ' ماذا لو كانت الجملة تنتهي بكلمة إنجليزية مثل Test?';
$font_size = 16;
$chars_in_line = $Arabic->a4MaxChars($font_size);
$total_lines = $Arabic->a4Lines($text, $font_size);
$text = $Arabic->utf8Glyphs($text, $chars_in_line);
$pdf->SetFont('ae_AlHor', '', $font_size);
$pdf->MultiCell(0, $total_lines, $text, 0, 'R', 0);
$pdf->Close();
Example #5
0
<?php

/**
 * Example of render Hiero language transliteration
 *
 * @category  I18N
 * @package   I18N_Arabic
 * @author    Khaled Al-Sham'aa <*****@*****.**>
 * @copyright 2006-2013 Khaled Al-Sham'aa
 *
 * @license   LGPL <http://www.gnu.org/licenses/lgpl.txt>
 * @link      http://www.ar-php.org
 */
error_reporting(E_STRICT);
!empty($_GET['w']) ? $word = $_GET['w'] : ($word = 'Khaled Shamaa');
require '../../Arabic.php';
$x = new I18N_Arabic('Hiero');
$im = $x->str2graph($word);
// Set the content-type
header("Content-type: image/png");
imagepng($im);
imagedestroy($im);
Example #6
0
<?php 
/**
 * Example of Arabic Text Compressor
 *
 * @category  I18N
 * @package   I18N_Arabic
 * @author    Khaled Al-Sham'aa <*****@*****.**>
 * @copyright 2006-2013 Khaled Al-Sham'aa
 *
 * @license   LGPL <http://www.gnu.org/licenses/lgpl.txt>
 * @link      http://www.ar-php.org
 */
error_reporting(E_STRICT);
$time_start = microtime(true);
require '../../Arabic.php';
$Arabic = new I18N_Arabic('CompressStr');
$Arabic->setInputCharset('windows-1256');
$file = 'Compress/ar_example.txt';
$fh = fopen($file, 'r');
$str = fread($fh, filesize($file));
fclose($fh);
$zip = $Arabic->compress($str);
$before = strlen($str);
$after = strlen($zip);
$rate = round($after * 100 / $before);
echo "String size before was: {$before} Byte<br>";
echo "Compressed string size after is: {$after} Byte<br>";
echo "Rate {$rate} %<hr>";
$Arabic->setInputCharset('utf-8');
$Arabic->setOutputCharset('windows-1256');
$str = $Arabic->decompress($zip);
Example #7
0
<?php 
/**
 * Example of Arabic Gender Guesser
 *
 * @category  I18N
 * @package   I18N_Arabic
 * @author    Khaled Al-Sham'aa <*****@*****.**>
 * @copyright 2006-2016 Khaled Al-Sham'aa
 *
 * @license   LGPL <http://www.gnu.org/licenses/lgpl.txt>
 * @link      http://www.ar-php.org
 */
error_reporting(E_STRICT);
$time_start = microtime(true);
require '../../Arabic.php';
$Arabic = new I18N_Arabic('Gender');
$names = array('أحمد بشتو', 'أحمد منصور', 'الحبيب الغريبي', 'المعز بو لحية', 'توفيق طه', 'جلنار موسى', 'جمال  ريان', 'جمانة نمور', 'جميل عازر', 'حسن جمول', 'حيدر عبد الحق', 'خالد صالح', 'خديجة بن قنة', 'ربى خليل', 'رشا عارف', 'روزي عبده', 'سمير سمرين', 'صهيب الملكاوي', 'عبد الصمد ناصر', 'علي الظفيري', 'فرح البرقاوي', 'فيروز زياني', 'فيصل القاسم', 'لونه الشبل', 'ليلى الشايب', 'لينا زهر الدين', 'محمد البنعلي', 'محمد الكواري', 'محمد خير البوريني', 'محمد كريشان', 'منقذ العلي', 'منى سلمان', 'ناجي سليمان', 'نديم الملاح', 'وهيبة بوحلايس');
echo <<<END
<center>
  <table border="0" cellspacing="2" cellpadding="5" width="60%">
    <tr>
      <td colspan="2">
        <b>Al Jazeera Reporters (Class Example):</b>
      </td>
    </tr>
    <tr>
      <td bgcolor="#27509D" align="center" width="50%">
        <b><font color="#ffffff">Name (sample input)</font></b>
      </td>
      <td bgcolor="#27509D" align="center" width="50%">
        <b><font color="#ffffff">Gender (auto generated)</font></b>
Example #8
0
<?php 
/**
 * Example of Arabic Stemmer
 *
 * @category  I18N
 * @package   I18N_Arabic
 * @author    Khaled Al-Sham'aa <*****@*****.**>
 * @copyright 2006-2013 Khaled Al-Sham'aa
 *
 * @license   LGPL <http://www.gnu.org/licenses/lgpl.txt>
 * @link      http://www.ar-php.org
 */
error_reporting(E_STRICT);
$time_start = microtime(true);
require '../../Arabic.php';
$Arabic = new I18N_Arabic('Stemmer');
$examples = array();
$examples[] = 'سيعرفونها من خلال العمل بالحاسوبين المستعملين لديهما';
$examples[] = 'الخيليات البرية المهددة بالإنقراض';
$examples[] = 'تزايدت الحواسيب الشخصية بمساعدة التطبيقات الرئيسية';
$examples[] = 'سيتعذر هذا على عمليات نشر المساعدات للجائعين بالطريقة الجديدة';
$examples[] = 'ليس هذا بالحل المثالي انظر  كتبي وكتابك';
foreach ($examples as $str) {
    echo $str . ' <br />(';
    $words = split(' ', $str);
    $stems = array();
    foreach ($words as $word) {
        $stem = $Arabic->stem($word);
        if ($stem) {
            $stems[] = $stem;
        }
Example #9
0
            <?php 
/**
 * Example of Arabic Normalise Examples
 *
 * @category  I18N
 * @package   I18N_Arabic
 * @author    Khaled Al-Sham'aa <*****@*****.**>
 * @copyright 2006-2016 Khaled Al-Sham'aa
 *
 * @license   LGPL <http://www.gnu.org/licenses/lgpl.txt>
 * @link      http://www.ar-php.org
 */
error_reporting(E_STRICT);
$time_start = microtime(true);
require '../../Arabic.php';
$Arabic = new I18N_Arabic('Normalise');
echo <<<END
<p>قال الشاعر حافظ إبراهيم على لسان اللغة العربية</p>
<table border="0" cellpadding="5" cellspacing="2" dir="rtl">
END;
$lines[] = 'وَسِعْتُ كِتابَ اللَّهِ لفظـــاً وَحِكمَــــةً **** وَما ضِقْتُ عن آيٍ به وَعِظــــاتِ';
$lines[] = 'فَكيفَ أَضيقُ اليومَ عن وَصْفِ آلــةٍ **** وَتَنسيـــقُ أسمــاءٍ لِمُخْتَرَعــــاتِ';
foreach ($lines as $line) {
    echo '<tr><th style="background-color: #E5E5E5">Function</th>
          <th style="background-color: #E5E5E5">Text</th></tr>';
    echo "<tr bgcolor=#F0F8FF><th>Original</th><td>{$line}</td></tr>";
    $n1 = $Arabic->unshape($line);
    echo "<tr bgcolor=#F0F8FF><th>Unshape</th><td>{$n1}</td></tr>";
    $n2 = $Arabic->utf8Strrev($n1);
    echo "<tr bgcolor=#F0F8FF><th>UTF8 Reverse</th><td>{$n2}</td></tr>";
    $n3 = $Arabic->stripTashkeel($n1);
Example #10
0
<?php 
/**
 * Example of Convert keyboard language programmatically (English - Arabic)
 *
 * @category  I18N
 * @package   I18N_Arabic
 * @author    Khaled Al-Sham'aa <*****@*****.**>
 * @copyright 2006-2013 Khaled Al-Sham'aa
 *
 * @license   LGPL <http://www.gnu.org/licenses/lgpl.txt>
 * @link      http://www.ar-php.org
 */
error_reporting(E_STRICT);
$time_start = microtime(true);
require '../../Arabic.php';
$Arabic = new I18N_Arabic('KeySwap');
$str = "Hpf lk hgkhs hglj'vtdkK Hpf hg`dk dldg,k f;gdjil Ygn\n,p]hkdm hgHl,v tb drt,k ljv]]dk fdk krdqdk>";
echo "<u><i>Before:</i></u><br />{$str}<br /><br />";
$text = $Arabic->swapEa($str);
echo "<u><i>After:</i></u><br />{$text}<br /><br /><b>جبران خليل جبران</b>";
?>
</div><br />
<div class="Paragraph">
<h2>Example Code 1:</h2>
<?php 
$code = <<<END
<?php
    require '../../Arabic.php';
    \$Arabic = new I18N_Arabic('KeySwap');

    \$str = "Hpf lk hgkhs hglj'vtdkK Hpf hg`dk dldg,k f;gdjil Ygn
Example #11
0
<?php 
/**
 * Example of Arabic Soundex Class
 *
 * @category  I18N
 * @package   I18N_Arabic
 * @author    Khaled Al-Sham'aa <*****@*****.**>
 * @copyright 2006-2013 Khaled Al-Sham'aa
 *
 * @license   LGPL <http://www.gnu.org/licenses/lgpl.txt>
 * @link      http://www.ar-php.org
 */
error_reporting(E_STRICT);
$time_start = microtime(true);
require '../../Arabic.php';
$Arabic = new I18N_Arabic('Soundex');
$Clinton = array('كلينتون', 'كلينتن', 'كلينطون', 'كلنتن', 'كلنتون', 'كلاينتون');
echo <<<END
<table border="0" cellpadding="5" cellspacing="2" align="center">
<tr>
    <td colspan="3">Listed below are 6 different spelling for the name
    <i><a href="http://en.wikipedia.org/wiki/Bill_Clinton" target=_blank>Clinton</a></i>
      found in collection of news articles in addition to original English spelling.</td>
</tr>
<tr>
    <td bgcolor=#000000 width=33%><b><font color=#ffffff>Function</font></b></td>
    <td bgcolor=#000000 width=33%><b><font color=#ffffff>Input</font></b></td>
    <td bgcolor=#000000 width=33%><b><font color=#ffffff>Output</font></b></td>
</tr>
END;
echo '<tr>
Example #12
0
 public function createOwnerSignature($dbh, $ownername, $ownerphone)
 {
     require './I18N/Arabic.php';
     $Arabic = new I18N_Arabic('Glyphs');
     //$font = 'C:\Windows\Fonts\arabtype.ttf';
     $font = '.\\arial.ttf';
     $fontsize = 14;
     $text = $Arabic->utf8Glyphs($ownername);
     //$text = "Abdalla Al Salem";
     // First we create our bounding box for the first text
     $bbox = imagettfbbox($fontsize, 0, $font, $text);
     //throw new Exception(print_r($bbox, true));
     // This is our cordinates for X and Y - center of the image created by imagecreatetruecolor function
     //$x = $bbox[0] + (imagesx($img) / 2) - ($bbox[4] / 2) - 25;
     //$y = $bbox[1] + (imagesy($img) / 2) - ($bbox[5] / 2) - 5;
     $width = $bbox[4] - $bbox[0] + 10;
     $y = $bbox[1] - $bbox[5];
     //$height = $y + 40;
     $height = $y + 10;
     //throw new Exception($width . " ----- " . $height);
     //$width = 184;
     //$y = $height = 24;
     $img = imagecreatetruecolor($width, $height);
     imagesavealpha($img, true);
     $trans_colour = imagecolorallocatealpha($img, 0, 0, 0, 127);
     //$trans_colour = imagecolorallocatealpha($img, 255, 255, 255, 127);
     imagefill($img, 0, 0, $trans_colour);
     //$white = imagecolorallocate( $img, 255, 255, 255 );
     //$grey = imagecolorallocate( $img, 128, 128, 128 );
     //$black = imagecolorallocate( $img, 0, 0, 0 );
     $blue = imagecolorallocate($img, 0, 0, 255);
     // Add the text
     imagettftext($img, $fontsize, 0, 0, $y, $blue, $font, $text);
     //$img2 = imagecreatetruecolor($width, $height);
     //imagesavealpha($img2, true);
     //imagefill($img2, 0, 0, $trans_colour);
     //imagecopyresampled($img2, $img, 0, 0, 0, 0, $width, $height, $width * 8, $height * 8);
     imagepng($img, "./my_image.png", 2);
     imagejpeg($img, "./my_image.jpg", 2);
     //$size = getimagesize("./my_image.png", $info);
     //throw new Exception(print_r($size, true));
     ob_start();
     imagepng($img, NULL, 2);
     $imgData = ob_get_contents();
     ob_end_clean();
     //$dbh = $this->connect();
     try {
         $ds = $dbh->query("SELECT EmployeeId FROM SignatureList WHERE EmployeeId = '{$ownerphone}'");
         if ($ds->fetchColumn() == 0) {
             $dbh->exec("INSERT INTO SignatureList(EmployeeId, Image, Width, Height, Resolution) VALUES ('{$ownerphone}', " . $dbh->quote($imgData) . ", {$width}, {$height}, 96)");
         } else {
             $dbh->exec("UPDATE SignatureList SET Image = " . $dbh->quote($imgData) . ", Width = {$width}, Height = {$height} WHERE EmployeeId = '{$ownerphone}'");
         }
     } catch (PDOException $e) {
         throw new Exception('Failed to execute/prepare query: ' . $e->getMessage());
     }
     //		finally {
     imagecolordeallocate($img, $trans_colour);
     //imagecolordeallocate( $img, $white );
     //imagecolordeallocate( $img, $grey );
     //imagecolordeallocate( $img, $black );
     imagecolordeallocate($img, $blue);
     imagedestroy($img);
     imagedestroy($img2);
     //		}
 }
Example #13
0
 static function convert_date_to_arabic_string($datetime = null)
 {
     global $arabic_date;
     if (!isset($arabic_date)) {
         $arabic_date = new I18N_Arabic('Date');
         $arabic_date->setMode(2);
     }
     if ($datetime == null) {
         $datetime = time();
     }
     return $arabic_date->date('l dS F Y', $datetime);
 }
Example #14
0
/**
 * Example of MakeTime for Arabic/Islamic Higri Calendar
 *
 * @category  I18N
 * @package   I18N_Arabic
 * @author    Khaled Al-Sham'aa <*****@*****.**>
 * @copyright 2006-2016 Khaled Al-Sham'aa
 *
 * @license   LGPL <http://www.gnu.org/licenses/lgpl.txt>
 * @link      http://www.ar-php.org
 */
error_reporting(E_STRICT);
$time_start = microtime(true);
date_default_timezone_set('UTC');
require '../../Arabic.php';
$Arabic = new I18N_Arabic('Mktime');
$correction = $Arabic->mktimeCorrection(9, 1429);
$time = $Arabic->mktime(0, 0, 0, 9, 1, 1429, $correction);
echo "Calculated first day of Ramadan 1429 unix timestamp is: {$time}<br>";
$Gregorian = date('l F j, Y', $time);
echo "Which is {$Gregorian} in Gregorian calendar<br>";
$days = $Arabic->hijriMonthDays(9, 1429);
echo "That Ramadan has {$days} days in total";
?>
</div><br />
<div class="Paragraph">
<h2>Example Code:</h2>
<?php 
$code = <<<END
<?php
    date_default_timezone_set('UTC');
Example #15
0
    نتائج البحث عن (Search for) <b><?php 
    echo $keyword;
    ?>
</b>:<br />
    <table cellpadding="5" cellspacing="2" align="center" width="80%">
        <tr>
            <td bgcolor="#004488" align="center">
                <font color="#ffffff" size="2">
                    <b>الخبر كما ورد في موقع الجزيرة<br />
                    Headline at Aljazeera.net</b>
                </font>
            </td>
        </tr>
    <?php 
    include '../../Arabic.php';
    $Arabic = new I18N_Arabic('Query');
    echo $Arabic->allForms('فلسطينيون');
    $dbuser = '******';
    $dbpwd = '';
    $dbname = 'test';
    try {
        $dbh = new PDO('mysql:host=localhost;dbname=' . $dbname, $dbuser, $dbpwd);
        // Set the error reporting attribute
        $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        $dbh->exec("SET NAMES 'utf8'");
        if ($_GET['keyword'] != '') {
            $keyword = @$_GET['keyword'];
            $keyword = str_replace('\\"', '"', $keyword);
            $Arabic->setStrFields('headline');
            $Arabic->setMode($_GET['mode']);
            $strCondition = $Arabic->getWhereCondition($keyword);
Example #16
0
/**
 * Example of Detect Arabic String Character Set
 *
 * @category  I18N
 * @package   I18N_Arabic
 * @author    Khaled Al-Sham'aa <*****@*****.**>
 * @copyright 2006-2016 Khaled Al-Sham'aa
 *
 * @license   LGPL <http://www.gnu.org/licenses/lgpl.txt>
 * @link      http://www.ar-php.org
 */
error_reporting(E_STRICT);
$time_start = microtime(true);
$text = '��� ���� ������ ������';
require '../../Arabic.php';
$Arabic = new I18N_Arabic('CharsetD');
$charset = $Arabic->getCharset($text);
echo "{$text} ({$charset}) <br/>";
print_r($Arabic->guess($text));
?>

        </div><br />
        <div class="Paragraph">
            <h2>Example Code:</h2>
            <?php 
$code = <<<END
<?php
    \$text = '��� ���� ������ ������';

    require '../../Arabic.php';
    \$Arabic = new I18N_Arabic('CharsetD');
Example #17
0
<?php 
/**
 * Example of Convert keyboard language programmatically (English - Arabic)
 *
 * @category  I18N
 * @package   I18N_Arabic
 * @author    Khaled Al-Sham'aa <*****@*****.**>
 * @copyright 2006-2016 Khaled Al-Sham'aa
 *
 * @license   LGPL <http://www.gnu.org/licenses/lgpl.txt>
 * @link      http://www.ar-php.org
 */
error_reporting(E_STRICT);
$time_start = microtime(true);
require '../../Arabic.php';
$Arabic = new I18N_Arabic('KeySwap');
$str = "Hpf lk hgkhs hglj'vtdkK Hpf hg`dk dldg,k f;gdjil Ygn\n,p]hkdm hgHl,v tb drt,k ljv]]dk fdk krdqdk>";
echo "<u><i>Before - English Keyboard:</i></u><br />{$str}<br /><br />";
$text = $Arabic->swapEa($str);
echo "<u><i>After:</i></u><br />{$text}<br /><br />";
?>
</div><br />
<div class="Paragraph">
<h2>Example Code 1 (a):</h2>
<?php 
$code = <<<END
<?php
    require '../../Arabic.php';
    \$Arabic = new I18N_Arabic('KeySwap');

    \$str = "Hpf lk hgkhs hglj'vtdkK Hpf hg`dk dldg,k f;gdjil Ygn
Example #18
0
            <?php 
/**
 * Example of Arabic-English Transliteration
 *
 * @category  I18N
 * @package   I18N_Arabic
 * @author    Khaled Al-Sham'aa <*****@*****.**>
 * @copyright 2006-2016 Khaled Al-Sham'aa
 *
 * @license   LGPL <http://www.gnu.org/licenses/lgpl.txt>
 * @link      http://www.ar-php.org
 */
error_reporting(E_STRICT);
$time_start = microtime(true);
require '../../Arabic.php';
$Arabic = new I18N_Arabic('Transliteration');
$ar_terms = array('خالِد الشَمعَة', 'جُبران خَليل جُبران', 'كاظِم الساهِر', 'ماجِدَة الرُومِي، نِزار قَبَّانِي', 'سُوق الحَمِيدِيَّة؟', 'مَغارَة
    جَعِيتَا', 'غُوطَة دِمَشق', 'حَلَب الشَهبَاء', 'جَزيرَة أَرواد', 'بِلاد
    الرافِدَين', 'أهرامات الجِيزَة', 'دِرْع', 'عِيد', 'عُود', 'رِدْء', 'إِيدَاء', 'هِبَة الله', 'قاضٍ');
echo <<<END
<center>
  <table border="0" cellspacing="2" cellpadding="5" width="500">
    <tr>
      <td bgcolor="#27509D" align="center" width="150">
        <b>
          <font color="#ffffff" face="Tahoma">
            English<br />(auto generated)
          </font>
        </b>
      </td>
      <td bgcolor="#27509D" align="center" width="150">
Example #19
0
 * @copyright 2006-2016 Khaled Al-Sham'aa
 *
 * @license   LGPL <http://www.gnu.org/licenses/lgpl.txt>
 * @link      http://www.ar-php.org
 */
error_reporting(E_STRICT);
// Set the content-type
header("Content-type: image/png");
// Create the image
$im = @imagecreatefromgif('GD/bg.gif');
// Create some colors
$black = imagecolorallocate($im, 0, 0, 0);
$blue = imagecolorallocate($im, 0, 0, 255);
$white = imagecolorallocate($im, 255, 255, 255);
// Replace by your own font full path and name
$path = substr($_SERVER['SCRIPT_FILENAME'], 0, strrpos($_SERVER['SCRIPT_FILENAME'], '/'));
$font = $path . '/GD/ae_AlHor.ttf';
// UTF-8 charset
$text = 'بسم الله الرحمن الرحيم';
imagefill($im, 0, 0, $white);
imagettftext($im, 20, 0, 10, 50, $blue, $font, 'UTF-8:');
imagettftext($im, 20, 0, 250, 50, $black, $font, $text);
require '../../Arabic.php';
$Arabic = new I18N_Arabic('Glyphs');
$text = 'بسم الله الرحمن الرحيم';
$text = $Arabic->utf8Glyphs($text);
imagettftext($im, 20, 0, 10, 100, $blue, $font, 'Arabic Glyphs:');
imagettftext($im, 20, 0, 250, 100, $black, $font, $text);
// Using imagepng() results in clearer text compared with imagejpeg()
imagepng($im);
imagedestroy($im);
Example #20
0
<?php 
/**
 * Example of English-Arabic Transliteration
 *
 * @category  I18N
 * @package   I18N_Arabic
 * @author    Khaled Al-Sham'aa <*****@*****.**>
 * @copyright 2006-2013 Khaled Al-Sham'aa
 *
 * @license   LGPL <http://www.gnu.org/licenses/lgpl.txt>
 * @link      http://www.ar-php.org
 */
error_reporting(E_STRICT);
$time_start = microtime(true);
include_once '../../Arabic.php';
$Arabic = new I18N_Arabic('Transliteration');
$en_terms = array('George Bush, Paul Wolfowitz', 'Silvio Berlusconi?', 'Guantanamo', 'Arizona', 'Maryland', 'Oracle', 'Yahoo', 'Google', 'Formula1', 'Boeing', 'Caviar', 'Telephone', 'Internet');
echo <<<END
<center>
  <table border="0" cellspacing="2" cellpadding="5" width="500">
    <tr>
      <td bgcolor="#27509D" align="center" width="150">
        <b>
          <font color="#ffffff">
            English<br />(sample input)
          </font>
        </b>
      </td>
      <td bgcolor="#27509D" align="center" width="150">
        <b>
          <font color="#ffffff" face="Tahoma">
Example #21
0
    <p><b><font color="red">This example needs MING extension which is not loaded in your PHP environment!</font></b></p>

    <p>Information for installing this PECL extension may be found in the manual chapter titled 
        <a href="http://php.net/manual/en/install.pecl.php" target=_blank>Installation of PECL extensions</a>. 
        Additional information such as new releases, downloads, source files, maintainer information, and a CHANGELOG, 
        can be located here: <a href="http://pecl.php.net/package/ming" target=_blank>http://pecl.php.net/package/ming</a>.</p>

    <p>This extension has been moved to the <a href="http://pecl.php.net/" target=_blank>PECL</a> repository and is 
        no longer bundled with PHP as of PHP 5.3.0</p>

    <?php 
    exit;
}
require '../../Arabic.php';
$Arabic = new I18N_Arabic('Glyphs');
$text_before = 'اللغة العربية';
$text_after = $Arabic->utf8Glyphs($text_before);
$f = new SWFFont(dirname(__FILE__) . '/GD/ae_AlHor.ttf');
$m = new SWFMovie();
$m->setRate(24.0);
$m->setDimension(520, 320);
$m->setBackground(105, 121, 47);
/**
 * This functions was based on the example from
 * http://ming.sourceforge.net/examples/animation.html
 *
 * @param integer $r      Red
 * @param integer $g      Green
 * @param integer $b      Blue
 * @param integer $a      Alpha
Example #22
0
            <?php 
/**
 * Example of Tagging Arabic Text
 *
 * @category  I18N
 * @package   I18N_Arabic
 * @author    Khaled Al-Sham'aa <*****@*****.**>
 * @copyright 2006-2016 Khaled Al-Sham'aa
 *
 * @license   LGPL <http://www.gnu.org/licenses/lgpl.txt>
 * @link      http://www.ar-php.org
 */
error_reporting(E_STRICT);
$time_start = microtime(true);
require '../../Arabic.php';
$Arabic = new I18N_Arabic('WordTag');
$str = 'وحسب إحصائية لوزارة الدفاع الأميركية ما زال نحو 375 معتقلا يقبعون في
غوانتانامو في إطار ما يسمى " الحرب على الإرهاب "، منهم كثيرون محتجزون منذ
أكثر من خمس سنوات ومن بينهم مصور قناة الجزيرة سامي الحاج الذي لم توجه له أي
تهمة رسمية ولم يحظ بأي محاكمة حتى الآن.';
$highlightStr = $Arabic->highlightText($str, 'noun');
echo '<div dir="rtl" align="justify">' . $str . '<hr />' . $highlightStr . '<hr /></div>';
$taggedText = $Arabic->tagText($str);
echo '<div dir="ltr" align="justify">';
foreach ($taggedText as $wordTag) {
    list($word, $tag) = $wordTag;
    if ($tag == 1) {
        echo "<font color=blue>{$word} is Noun</font>, ";
    }
    if ($tag == 0) {
        echo "<font color=red>{$word} is not Noun</font>, ";
Example #23
0
			<img  src="images/logo.png">
		</div>
		<div id="head-text">
				<p id="header"><small>مؤسسة </small> الكوثر <small>الثقافية</small></p><br>
			<p id="subHeader">Stichting Alcauther</p>
		</div>
			<div id="date" >
				<!-- The date  -->
				<?php 
date_default_timezone_set('UTC');
$time = time();
// TO control the data cahnge this variable
include "../../includes/connect2db.php";
// configration - connection and selection  \\
include "../../includes/functions.php";
$date = retrieve_data("alcDateTable", 1);
$t = (int) htmlentities(trim($date[0][0]));
//	if($numOfDays < 7){
$time = $time + 60 * 60 * 24 * $date[0][0];
//		}
require 'I18N/Arabic.php';
$obj = new I18N_Arabic('Date');
$fix = $obj->dateCorrection($time);
echo '<span style="color:#fff; padding: 0 0 4px 4px; " class="hidden-sm hidden-xs">';
echo $obj->date('dS F Y ', $time) . ' - ';
$fix = $obj->dateCorrection($time);
$obj->setMode(3);
echo $obj->date('l dS F Y ', $time, $fix) . '</span>';
?>
			</div>
</header>
Example #24
0
/**
 * Example of Muslim Prayer Times
 *
 * @category  I18N
 * @package   I18N_Arabic
 * @author    Khaled Al-Sham'aa <*****@*****.**>
 * @copyright 2006-2016 Khaled Al-Sham'aa
 *
 * @license   LGPL <http://www.gnu.org/licenses/lgpl.txt>
 * @link      http://www.ar-php.org
 */
error_reporting(E_STRICT);
$time_start = microtime(true);
date_default_timezone_set('UTC');
require '../../Arabic.php';
$Arabic = new I18N_Arabic('Salat');
// Latitude, Longitude, Zone, and Elevation
$Arabic->setLocation(33.52, 36.31, 3, 691);
// Month, Day, and Year
$Arabic->setDate(date('n'), date('j'), date('Y'));
echo "<b>Damascus, Syria</b> " . date('l F j, Y') . "<br /><br />";
// Salat calculation configuration: Egyptian General Authority of Survey
$Arabic->setConf('Shafi', -0.833333, -17.5, -19.5, 'Sunni');
$times = $Arabic->getPrayTime();
echo "<b>Imsak:</b> {$times[8]}<br />";
echo "<b>Fajr:</b> {$times[0]}<br />";
echo "<b>Sunrise:</b> {$times[1]}<br />";
echo "<b>Dhuhr:</b> {$times[2]}<br />";
echo "<b>Asr:</b> {$times[3]}<br />";
echo "<b>Sunset:</b> {$times[6]}<br />";
echo "<b>Maghrib:</b> {$times[4]}<br />";
Example #25
0
function ar2en($text)
{
    $obj = new I18N_Arabic('Transliteration');
    return $obj->ar2en($text);
}
Example #26
0
<?php 
/**
 * Example of Arabic Text ArStandard
 *
 * @category  I18N
 * @package   I18N_Arabic
 * @author    Khaled Al-Sham'aa <*****@*****.**>
 * @copyright 2006-2016 Khaled Al-Sham'aa
 *
 * @license   LGPL <http://www.gnu.org/licenses/lgpl.txt>
 * @link      http://www.ar-php.org
 */
error_reporting(E_STRICT);
$time_start = microtime(true);
require '../../Arabic.php';
$Arabic = new I18N_Arabic('Standard');
$content = <<<END
هذا نص عربي ، و فيه علامات ترقيم بحاجة إلى ضبط و معايرة !و كذلك نصوص( بين 
أقواس )أو حتى مؤطرة"بإشارات إقتباس "أو- علامات إعتراض -الخ......
<br>
لذا ستكون هذه المكتبة أداة و وسيلة لمعالجة مثل هكذا حالات، بما فيها الواحدات 1 
Kg أو مثلا MB 16 وسواها حتى النسب المؤية مثل 20% أو %50 وهكذا ...
END;
$str = $Arabic->standard($content);
echo '<b>Origenal:</b>';
echo '<p dir="rtl" align="justify">';
echo $content . '</p>';
echo '<b>Standard:</b>';
echo '<p dir="rtl" align="justify">';
echo $str . '</p>';
?>
            <?php 
/**
 * Example of Safe Upload Examples for Arabic Filename
 *
 * @category  I18N
 * @package   I18N_Arabic
 * @author    Khaled Al-Sham'aa <*****@*****.**>
 * @copyright 2006-2016 Khaled Al-Sham'aa
 *
 * @license   LGPL <http://www.gnu.org/licenses/lgpl.txt>
 * @link      http://www.ar-php.org
 */
if (isset($_POST['submit'])) {
    include '../../Arabic.php';
    $Arabic = new I18N_Arabic('Transliteration');
    // Continue only if the file was uploaded via HTTP POST
    if (is_uploaded_file($_FILES['image']['tmp_name'])) {
        // Is file size less than 1 MB = 1,048,576 Byte
        if ($_FILES['image']['size'] < 1048576) {
            // Detect MIME Content-type for a file
            if (function_exists('mime_content_type')) {
                $mime = mime_content_type($_FILES['image']['tmp_name']);
            } else {
                $mime = finfo_file(finfo_open(FILEINFO_MIME_TYPE), $_FILES['image']['tmp_name']);
            }
            // List of accepted MIME Content-type
            $images = array('image/jpeg', 'image/gif', 'image/png', 'image/svg+xml');
            if (in_array($mime, $images)) {
                // PHP5 is not capable of addressing files with multi-byte characters in their names at all.
                // This is why we use Transliteration functionality in Arabic class
Example #28
0
<?php 
/**
 * Example of Arabic Auto Summarize Class
 *
 * @category  I18N
 * @package   I18N_Arabic
 * @author    Khaled Al-Sham'aa <*****@*****.**>
 * @copyright 2006-2016 Khaled Al-Sham'aa
 *
 * @license   LGPL <http://www.gnu.org/licenses/lgpl.txt>
 * @link      http://www.ar-php.org
 */
error_reporting(E_STRICT);
$time_start = microtime(true);
require '../../Arabic.php';
$Arabic = new I18N_Arabic('AutoSummarize');
$rate = 25;
$title = 'أضخم تجربة علمية لدراسة بنية المادة المعتمة بمصادم الهدرونات الكبير';
$contents = <<<END
قال علماء في مركز أبحاث الفيزياء التابع للمنظمة الأوروبية للابحاث النووية يوم الجمعة
أنهم حققوا تصادما بين جسيمات بكثافة قياسية في إنجاز مهم في برنامجهم لكشف أسرار الكون. 
وجاء التطور في الساعات الأولى بعد تغذية مصادم الهدرونات الكبير بحزمة أشعة بها 
جسيمات أكثر بحوالي ستة في المئة لكل وحدة بالمقارنة مع المستوى القياسي السابق 
الذي سجله مصادم تيفاترون التابع لمختبر فرميلاب الأمريكي العام الماضي. 
وكل تصادم في النفق الدائري لمصادم الهدرونات البالغ طوله 27 كيلومترا تحت الأرض 
بسرعة أقل من سرعة الضوء يحدث محاكاة للانفجار العظيم الذي يفسر به علماء نشوء الكون 
قبل 13.7 مليار سنة. وكلما زادت "كثافة الحزمة" أو ارتفع عدد الجسيمات فيها زاد 
عدد التصادمات التي تحدث وزادت أيضا المادة التي يكون على العلماء تحليلها. 
ويجري فعليا انتاج ملايين كثيرة من هذه "الانفجارات العظيمة المصغرة" يوميا. 
وقال رولف هوير المدير العام للمنظمة الاوروبية للأبحاث النووية ومقرها على الحدود 
الفرنسية السويسرية قرب جنيف أن "كثافة الحزمة هي الأساس لنجاح مصادم الهدرونات الكبير 
Example #29
0
/**
 * Example of Arabic Charset Converter
 *
 * @category  I18N
 * @package   I18N_Arabic
 * @author    Khaled Al-Sham'aa <*****@*****.**>
 * @copyright 2006-2013 Khaled Al-Sham'aa
 *
 * @license   LGPL <http://www.gnu.org/licenses/lgpl.txt>
 * @link      http://www.ar-php.org
 */
error_reporting(E_STRICT);
$time_start = microtime(true);
$text = 'بسم الله الرحمن الرحيم';
require '../../Arabic.php';
$Arabic = new I18N_Arabic('CharsetC');
$Arabic->setInputCharset('utf-8');
if (isset($_GET['charset'])) {
    $Arabic->setOutputCharset($_GET['charset']);
}
$charset = $Arabic->getOutputCharset();
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<title>Arabic Character Set Converter</title>
<meta http-equiv="Content-Type" content="text/html;charset=<?php 
echo $charset;
?>
Example #30
-1
<?php 
/**
 * Example of Spell numbers in the Arabic idiom
 *
 * @category  I18N
 * @package   I18N_Arabic
 * @author    Khaled Al-Sham'aa <*****@*****.**>
 * @copyright 2006-2013 Khaled Al-Sham'aa
 *
 * @license   LGPL <http://www.gnu.org/licenses/lgpl.txt>
 * @link      http://www.ar-php.org
 */
error_reporting(E_STRICT);
$time_start = microtime(true);
require '../../Arabic.php';
$Arabic = new I18N_Arabic('Numbers');
$Arabic->setFeminine(1);
$Arabic->setFormat(1);
$integer = 14159265358979;
$text = $Arabic->int2str($integer);
echo "<center>{$integer}<br />{$text}</center>";
?>

</div><br />
<div class="Paragraph">
<h2>Example Code 1:</h2>
<?php 
$code = <<<END
<?php
    require '../../Arabic.php';
    \$Arabic = new I18N_Arabic('Numbers');