khaled-alshamaa / ar-php Goto Github PK
View Code? Open in Web Editor NEWSet of functionalities enable Arabic website developers to serve professional search, present and process Arabic content in PHP
License: Other
Set of functionalities enable Arabic website developers to serve professional search, present and process Arabic content in PHP
License: Other
Assalam Alaikum,
First, thank you for your amazing work on this package. I have been using it for a while now and it has been very helpful.
I am writing to report a bug while using utf8Glyphs function. The bug occurs when the function is passed a string that starts with two consecutive ل characters (for example, للاستخدام). In this case, the function will throw an undefined offset: -1 error on Arabic.php at line 2400.
The error occurs because the function is looking for the previous character at index -2. However, since the string starts with two consecutive ل characters, there is no previous character at index -2.
I am not familiar enough with the code to submit a pull request to fix this bug. However, I would be happy to provide more information or help in any way that I can.
Thank you,
If trying to install any version above 6.0.0, Composer throw an error:
Install of khaled.alshamaa/ar-php failed
In Filesystem.php line 284:
Could not delete [path]/vendor/composer/c2b443c4\khaled-alshamaa-ar-php-1f31229\docs\pwa\pwa.zip:
This can be due to an antivirus or the Windows Search Indexer locking the file while they are analyzed
I am trying to install it on a Laravel project.
Tried to manually remove the file but it doesn't exist.
Finally, I rolled back to 6.0.0 version which installed successfully.
get the word سَنَةٌ to be more generic by removing the last vowel ٌ to become سَنَة so it will match all versions like سَنَةٍ etc
And then make it more generic to get السَنَة including بالسَنَة
or simple after using $Arabic->stripHarakat($content)
and then use all diacritics again
Lines 1143 to 1149 in 58046cd
In lines 1145 and 1148, specifically, the $d + $correction
portion. If the gregorian day is 1 and the $correction
value is -1
or the day is 31 and the $correction
value is 1
, this causes the day to be an invalid value 0
and 32
respectively. In this case the gregoriantojd()
function will return 0
as the passed day is invalid
This code snippet tells it all, the first part of this string become last part which make a sentence no readable. also it's adding \n
at the end of each line which not exist at the original string, i have fixed this $max
parameter to 300.
if you notice 'السلام '
was the in the bingeing at the string but after using utf8Glyphs it become the last one.
use ArPHP\I18N\Arabic;
$arabic = new Arabic();
$str = "السلام عليكم في البداية نقولها وهذا نص رقم ١ و بعده نصين رقم ٢ و بعده نصات ٣ وبالنهاية لا نقول الا الحمدلله حمدا كثيرا";
echo($arabic->utf8Glyphs($str,300));
/*
ﺍﺮﻴﺜﻛ ﺍﺪﻤﺣ ﻪﻠﻟﺪﻤﺤﻟﺍ ﻻﺍ ﻝﻮﻘﻧ ﻻ ﺔﻳﺎﻬﻨﻟﺎﺑﻭ ٣ ﺕﺎﺼﻧ ﻩﺪﻌﺑ ﻭ ٢ ﻢﻗﺭ ﻦﻴﺼﻧ ﻩﺪﻌﺑ ﻭ ١ ﻢﻗﺭ ﺺﻧ ﺍﺬﻫﻭ ﺎﻬﻟﻮﻘﻧ ﺔﻳﺍﺪﺒﻟﺍ ﻲﻓ ﻢﻜﻴﻠﻋ ﻡﻼﺴﻟﺍ
*/
is there a way to fix the Glyphs without changing the order of the string?
مرحبا,
عند استعمال فنكشن utf8Glyphs
كلمة "نتائج" تضهر كما في الصورة : https://i.imgur.com/VdezfNc.png
تنظيف وتنميط النص العربي بحذف العلامات المختلفة مثل :
مراجع:
الله يعطيكم العافية
في الملف التالي:
src/data/ar_numbers.json
ضمن:
individual > male
و
individual > female
الأعداد من 3 إلى 19 عكس القاعدة
فعندما يكون المعدود مذكراً تكون هذه الأعداد مؤنثة والعكس بالعكس.
والأمر الآخر هو أن الهمزة في العدد 2 دائماً همزة وصل؛ هكذا مثلاً:
اثنان / اثنا عشر... إلخ
It functions admirably for the Arabic language. Would it be possible to add support for Urdu characters in the next version?
The Error message:
Notice: Undefined offset: 248 in \ar-php-6.2.0\Arabic.php on line 1045
The month that does not displayed is جمادي الأولى
composer require khaled.alshamaa/ar-php
_Using version ^5.5 for khaled.alshamaa/ar-php
./composer.json has been updated
Running composer update khaled.alshamaa/ar-php
Loading composer repositories with package information
Updating dependencies
Lock file operations: 1 install, 0 updates, 0 removals
# composer dumpautoload
Generating optimized autoload files
**Class ArPHP\I18N\Arabic located in ./vendor/khaled.alshamaa/ar-php/src/arabic.php does not comply with psr-4 autoloading standard. Skipping.**
Example :
$Arabic = new \ArPHP\I18N\Arabic();
$Arabic->setNumberFeminine(1);
$Arabic->setNumberFormat(1);
$Arabic->money2str(45522.21, 'SAR', 'en');
Gave me this error : ( Undefined index: Halala )
I have Arabic text(html file) coming dynamically inside pdf using DomPdf and ar-php library.
I am just showing a line below in the $html variable but the text are not properly displaying, means they are not sorted altogether.
require_once 'ar-php/src/Arabic.php';
$Arabic = new ArPHP\I18N\Arabic();
$html = "يقول الله عز وجل :(وكلوا واشربوا ولا تسرفوا إنه لا يحب المسرفين) الأعراف";
$p = $Arabic->arIdentify($html);
for ($i = count($p)-1; $i >= 0; $i-=2) {
$utf8ar = $Arabic->utf8Glyphs(substr($html, $p[$i-1], $p[$i] - $p[$i-1]));
$html = substr_replace($html, $utf8ar, $p[$i-1], $p[$i] - $p[$i-1]);
}
but its coming like لا يحب المسرفين) الأعراف يقول الله عز وجل :(وكلوا واشربوا ولا تسرفوا إنه
Pls any help would be appreciated.
وبعد عرضه في PDF الجملة تبدأ من وسط السطر ويتم تقطيعها
لاحظ الصورة المرفق
ة
There is a XSS in the example files. The $_GET['keyword'] is not sanitized :
echo $_GET['keyword'];
Proof of Concept
We can read cookie contents : http://localhost/xxx/vendor/khaled.alshamaa/ar-php/examples/ar_query.php?keyword=%3Cscript%3Ealert(document.cookie)%3C/script%3E&submit=%D8%A8%D8%AD%D8%AB+%28Go%29&mode=0
Output:
csrftoken=Aj9xpc4O3p8Se553QLJNlhsFTUgJ3cCp; mode=light
Impact
With XSS, the attacker can read cookies and send requests ...
The example files are part of the composer package, so the likelyhood that these are distributed in applications using your library are very high.
مرحباً المهندس خالد،
@khaled-alshamaa
يوجد ثغرة أمنية XSS الإنعكاسية (Reflected XSS) خطيرة في ملف الأمثلة قبلة.
لم يتم عملية التحقق من المدخلات المتغير:
$_GET['d'];
تكمن الخطورة كمثال في قراءة محتويات ملف تعريف الارتباط الكوكيز.
hi,
your project is awesome and it help me a lot, but there is a problem I didn't know if it's a bug or a mistake from me,
there are some chars that don't display in the output and the direction is always from left to right take a look
my code :
public function generatePoster(Request $request,Arabic $obj) {
$title = $request->get('title');
$title =$obj->utf8Glyphs($title,20,false,true);
$imgPath = public_path('storage/ichecktemplate.jpg');
$image = imagecreatefromjpeg($imgPath);
$color = imagecolorallocate($image, 255, 255, 255);
$fontSize = 30 ;
$font = public_path('Almarai-Bold.ttf')
$x = 640;
$y = 364;
imagettftext($image, $fontSize, 0, $x, $y, $color, $font, $title);
imagejpeg($image, 'save.jpg', 100);
}
I'm getting the following error.
Undefined array key " " {"exception":"[object] (ErrorException(code: 0): Undefined array key " " at /var/www/vendor/khaled.alshamaa/ar-php/src/Arabic.php:2375
I'm facing this error in invoice print time.
Thanks in advance. :)
مرحباً المهندس خالد،
@khaled-alshamaa
عند استخدام الأحرف التالية (للإ) في بداية أي كلمة يظهر خطأ في الحزمة
أمثلة للجمل:
دورة للإحسان
للإضافة يجب عليك
مسار الملف: vendor\khaled.alshamaa\ar-php\src\Arabic.php
بارك الله فيك
السلام عليكم ورحمة الله وبركاته
لدي مشكله في بحث النتائج لا يبحث بالشبع أو التقريب
SELECT voted,voters.id as voters_id,gad_num,gad_f_chart,full_name,family_name,age,voters.gender as gender,location.name as location_name,Trusted,Proved_by,CONCAT(School.Name, ' - ',Lajna.Name) as job_title,lajna_id FROM
votersinner join location on Location_id=location.id inner join Lajna on Lajna.id=voters.lajna_id inner join School on Lajna.sid=School.id where 1=1 and ( REPLACE(voters.full_name, 'ـ', '') REGEXP 'ع(ا|أ|إ|آ)يش(ة|ه)') AND ( REPLACE(voters.full_name, 'ـ', '') REGEXP 'جم(ا|أ|إ|آ)ل') AND ( REPLACE(voters.full_name, 'ـ', '') REGEXP '(ا|أ|إ|آ)حمد') AND ( REPLACE(voters.full_name, 'ـ', '') REGEXP '((ا|أ|إ|آ)ل)?ه(ا|أ|إ|آ)ر(ون)?') ORDER BY
voters.
gad_num,full_name
Normalizing different digit styles as
توحيد الأرقام وتنميطها إلى شكل معين
Arabic western numeral: '0123456789'
Arabic eastern digit: '٠١٢٣٤٥٦٧٨٩'
Arabic eastern digit variant: '۰۱۲۳۴۵۶۷۸۹'
الوظائف functions
Normalize digits to Arabic western تنميط الأرقام للتنويعة العربية المغربية
Arabic eastern digit: '٠١٢٣٤٥٦٧٨٩' ==> '0123456789'
Arabic eastern digit variant: '۰۱۲۳۴۵۶۷۸۹' ==> '0123456789'
Normalize digits to Arabic eastern تنميط الأرقام للتنويعة العربية المشرقية
Arabic western numeral: '0123456789' ==> '٠١٢٣٤٥٦٧٨٩'
Arabic eastern digit variant: '۰۱۲۳۴۵۶۷۸۹' ==> '٠١٢٣٤٥٦٧٨٩'
Normalize digits to Arabic eastern variant: تنميط الأرقام للتنويعة العربية المشرقية المستعملة في شبه القارة الهندية وإيران
Arabic western numeral: '0123456789' ==> '۰۱۲۳۴۵۶۷۸۹'
Arabic eastern digit: '٠١٢٣٤٥٦٧٨٩' ==> '۰۱۲۳۴۵۶۷۸۹'
تحياتي لك أستاذنا العزيز
وشكراً جزيلاً لك على جهودك التي استفدت كثيراً منها منذ العام 2009 وحتى اللحظة
ما قمت به:
المطلوب مني طباعة نصوص عربية على صور باستخدام خطوط متعددة, استخدمت لذلك مكتبة Intervention عبر GD و ImageMagick,
بالإضافة قمت باستخدام مكتبتكم وبالتحديد دالة utf8Glyphs
وما يحدث هو أنه عند اختيار بعض انواع الخطوط مثل Vazirmatn أو Amiri وغيرها .. تظهر النصوص بشكل ممتاز جداً كما يجب.
لكن عند اختيار انواع اخرى من الخطوط مثل Tajawal أو Cairo وغيرها ايضاً, فتظهر الأحرف المتصلة بشكل ممتاز ولكن تظهر الاحرف المنفصلة على شكل اشارات غريبة او اشارات استفهام.
علماً أن جميع النصوص مرمزة باستخدام utf-8 (نفس المشكلة في ترميزات اخرى مثل windows-1256)
ونفس الامر عندما forcertl يكون true او false.
ورقم الاصدار
"khaled.alshamaa/ar-php": "^6.2",
الكود:
use ArPHP\I18N\Arabic;
.
.
.
$text = "فراس درويش";
$ar = new Arabic();
$ar->utf8Glyphs($text)
Hello Mr @khaled-alshamaa
I am using DomPdf (especially the Laravel version).
before using ArPHP the Arabic letters are separated:
After using the library the letters are fine but there is this initial margin:
the code I am using from the library is:
if ( ! class_exists( 'I18N_Arabic' ) ){
$Arabic = new Arabic();
$text = $Arabic->utf8Glyphs($text);
}
}
If there any detail you want, tell me to provide it..
Thanks
I'm getting Undefined offset: -1 for some strings at ar-php/src/Arabic.php:2268 with no special cases for strings with errors
code sample
$Arabic = new Arabic();
$p = $Arabic->arIdentify($html);
for ($i = count($p) - 1; $i >= 1; $i -= 2) {
$utf8ar = $Arabic->utf8Glyphs(substr($html, $p[$i - 1], $p[$i] - $p[$i - 1]));
$html = substr_replace($html, $utf8ar, $p[$i - 1], $p[$i] - $p[$i - 1]);
}
If we have a text that contains three stop words like ( والتي قد لا )
the word ( قد) wont be removed
so I have to run the arCleanCommon two or more times
In verse 46 Chapter 7, the following is an image generated by the library:
But the following is screenshot of the rendered text on the browser:
The original text in Arabic:
وَبَيْنَهُمَا حِجَابٌ ۚ وَعَلَى الْأَعْرَافِ رِجَالٌ يَعْرِفُونَ كُلًّا بِسِيمَاهُمْ ۚ وَنَادَوْا أَصْحَابَ الْجَنَّةِ أَنْ سَلَامٌ عَلَيْكُمْ ۚ لَمْ يَدْخُلُوهَا وَهُمْ يَطْمَعُونَ﴿46﴾
A UTF-8 encoded text file, created by Kate text editor (Kubuntu Linux) is attached
46.txt
$mode="1";
$Arabic = new Arabic();
$Arabic->setQueryStrFields('text');
$Arabic->setQueryMode($mode);
$keyword = str_replace('\"', '"', $string);
$strCondition = $Arabic->arQueryWhereCondition($keyword);
$strOrderBy = $Arabic->arQueryOrderBy($keyword);
$result=DB::table('verses')->select(DB::raw('text',$strCondition,$strOrderBy))->limit(10)->get();
dd(Verse::where('text','Like','ٱللَّهِ')->get());
i am trying to filter records based on a string but unable to find , i am using your package with laravel
When using $arabic->getPrayTime()
, I got this warning.
I think this is because these 3 lines:
$g = $g % 360 + ($g - ceil($g) + 1);
$q = $q % 360 + ($q - ceil($q) + 1);
$L = $L % 360 + ($L - ceil($L) + 1);
As php documentation says "Operands of modulo are converted to int before processing. For floating-point modulo, see fmod()
"
Arithmetic Operators
We can use fmod()
function
fmod
$g = fmod($g, 360) + ($g - ceil($g) + 1);
$q = fmod($q, 360) + ($q - ceil($q) + 1);
$L = fmod($L, 360) + ($L - ceil($L) + 1);
Hello @khaled-alshamaa ,
Hope you are doing great. Your project is awesome and helping us a lot, but I am facing a problem with "للإ" letter.
Here is the code which I have used to transform html to utf8 format to then provide to dompdf to generate a pdf.
$invoiceHtml = view('invoice', $invoiceData)->render();
$arabic = new Arabic();
$p = $arabic->arIdentify($invoiceHtml);
for ($i = count($p) - 1; $i >= 0; $i -= 2) {
$utf8ar = $arabic->utf8Glyphs(substr($invoiceHtml, $p[$i - 1], $p[$i] - $p[$i - 1]), 50, false);
$invoiceHtml = substr_replace($invoiceHtml, $utf8ar, $p[$i - 1], $p[$i] - $p[$i - 1]);
}
The text line having a problem:
شركة مكتب للإستشارات الهندسية
Output after applying the above code:
مكتب لإxFE#&ستشارات الهندسية شركة
By looking into the output, the issue seems to be with the letter "للإ" apprarently , but you can tell better.
I would really appreciate if you can look into it asap as we need to send invoices to our clients and we are stuck with this problem at the moment.
Thanks in advance.
@khaled-alshamaa
سلام عليكم باش مهندس خالد انا عندي مشكله لو في جمله اكتر من سطر الحروف بتدخل في بعض وانا دورت ولقيت حضرتك قايل لشخص كان عنده نفس المشكله انه يحدد اكتر عدد حروف في السطر وانا عملت كده وفعلا المشكله في الجمله دي اتحلت بس في جمله تانيه في نفس الملف ضربت ولما اغير في عدد الحروف بتظبط الجمله التانيه والاولي لا انا الجمل بتكوني dynamic مش ثابته وفي نفس الملف ممكن الجمل مختلف . انا عملت ال maxLineChr ب 30 فظبط الجملة دي
ولكن حصل مشكله في الجمله دي
علما بأني الجملتين في نفس الملف
وده نص الكود بتاعي
Hijri date will skip 1 day when the correction value is greater than 1 and the Hijri month end on the 29th instead of the 30th.
Here's an example:
I hardcoded the date so the issue can be reproduced easily.
correction = 0
$Arabic = new \ArPHP\I18N\Arabic();
$g_date = strtotime("2022-04-02");
$hijri = $Arabic->date('j F', $g_date, 0);
output: "29 شعبان"
correction = 1
$hijri = $Arabic->date('j F', $g_date, 1);
output: "30 شعبان"
correction = 2
$hijri = $Arabic->date('j F', $g_date, 2);
output: "2 رمضان"
Hi, do you have this project for laravel , can you provide an example for laravel project ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.