Help needed: PHP scripting


#1

yes


#2

all ok


#3

but now i want to put quran files in a folder and translations files in translation folder

and want to creat options like that:


#4

From what I understand, the following changed script should work for what you want to do.

<?php



    $metadataFile = 'quran-data.xml';  // quran metadata file


    initSuraData();   // initialize sura data array



    //------------------ General Functions ---------------------



    // initialize sura data array

    function initSuraData()

    {

        global $suraData, $metadataFile;

        $dataItems = Array("index", "start", "ayas", "name", "tname", "ename", "type", "rukus");


        $quranData = file_get_contents($metadataFile);

        $parser = xml_parser_create();

        xml_parse_into_struct($parser, $quranData, $values, $index);

        xml_parser_free($parser);


        for ($i=1; $i<=114; $i++) 

        {

            $j = $index['SURA'][$i-1];

            foreach ($dataItems as $item)

                $suraData[$i][$item] = $values[$j]['attributes'][strtoupper($item)]; 

        }

    }



    // return given property of a sura

    function getSuraData($sura, $property) 

    {

        global $suraData;

        return $suraData[$sura][$property]; 

    }



    // return contents of a sura

    function getSuraContents($sura, $file) 

    {

        $text = file($file);

        $startAya = getSuraData($sura, 'start');

        $endAya = $startAya+ getSuraData($sura, 'ayas');

        $content = array_slice($text, $startAya, $endAya- $startAya); 

        return $content;

    }



    //------------------ Display Functions ---------------------



    // get sura number 

    import_request_variables("pg");

    if (isset($quranFile))     {

        $quranFile = dirname($_SERVER["SCRIPT_FILENAME"]).'/quran/'.$quranFile;   // quran file

    } else {

        $quranFile = dirname($_SERVER["SCRIPT_FILENAME"]).'/quran/simple.txt';   // quran file

    }

    if (isset($transFile))     {

        $transFile = dirname($_SERVER["SCRIPT_FILENAME"]).'/translation/'.$transFile.'.txt';  // translation file

    } else {

        $transFile = dirname($_SERVER["SCRIPT_FILENAME"]).'/translation/0.txt';  // translation file

    }

    if ($sura < 1) $sura = 1; 

    if ($sura > 114) $sura = 114; 



    // show sura contents

    function showSura($sura)

    {

        global $quranFile, $transFile;

        $suraName = getSuraData($sura, 'name');

        $suraText = getSuraContents($sura, $quranFile);

        $transText = getSuraContents($sura, $transFile);

        $showBismillah = false; // change to true to show Bismillahs

        $ayaNum = 1;


        echo "
???? $suraName
"; foreach ($suraText as $aya) { $trans = $transText[$ayaNum- 1]; // remove bismillahs, except for suras 1 and 9 if (!$showBismillah && $ayaNum == 1 && $sura !=1 && $sura !=9) $aya = preg_replace('/^(([^ ]+ ){4})/u', '', $aya); // display waqf marks in different style $aya = preg_replace('/ ([?-?])/u', ' $1', $aya); echo "
"; echo "
$ayaNum. $aya
"; echo "
$trans
"; echo "
"; $ayaNum++; } } ?> Show Sura <?= $sura ?> .suraName {text-align: center; font-size: 20px; padding: 10px 0px; border: 1px solid #D4DDCC; background-color: #E4EEDC; margin-top: 7px;} .aya {background-color: #EEF8E5; border: 1px solid #D4DDCC; border-top: 0px;} .quran { font-family: Traditional Arabic; font-size: 28px; direction: rtl;} .trans { font-family: Times New Roman; font-size: 20px; direction: ltr; background-color: #E7EFDF;} .quran, .trans {padding: 10px; text-align: right;} .ayaNum {color: green; font-size: smaller;} .sign {font-family: times new roman; font-size: 0.9em; color: #FB7600;} .footer {text-align: center; margin: 20px 0px; color: #222; font-family: Arial; background-color: #f4f4ff; border: 1px solid #ccd; padding: 3px; font: 12px Verdana;}
Select Quran Script:
SimplePak Script Simple (Minimal) Simple (Clean) UthmaniUthmani (Minimal)
<p>Select Translation: 
Arabic: تفسير الجلالين Arabic: تفسير المیسر Albanian: Efendi Nahi Albanian: Feti Mehdiu Albanian: Sherif Ahmeti Azerbaijani: Məmmədəliyev & Bünyadov Azerbaijani: Musayev Bengali: মুহিউদ্দীন খান Bosnian: Korkut Bosnian: Mlivo Bulgarian: Теофанов Chinese: Ma Jian Chinese: Ma Jian (Traditional) Czech: HrbekCzech: Nykl Divehi: ދިވެހި Dutch: Keyzer English: Ahmed Ali English: Ahmed Raza Khan English: Arberry English: Asad English: Daryabadi English: Hilali & Khan English: Maududi English: Pickthall English: Qaribullah & Darwish English: Sahih International English: Sarwar English: Shakir English: Yusuf Ali English: Transliteration French: Hamidullah German: Abu Rida German: Bubenheim & Elyas German: Khoury German: Zaidan Hausa: GumiHindi: फ़ारूक़ ख़ान & अहमद Hindi: फ़ारूक़ ख़ान & नदवी Indonesian: Bahasa Indonesia Italian: Piccardo Japanese: Japanese Kurdish: تهفسیری ئاسان Korean: Korean Malay: Basmeih Malayalam: അബ്ദുല് ഹമീദ് & പറപ്പൂര് Norwegian: Einar Berg Persian: الهی قمشهای Persian: انصاریان Persian: آیتی Persian: فولادوند Persian: معزی Persian: مکارم شیرازی Polish: Bielawskiego Portuguese: El-Hayek Romanian: Grigore Russian: Абу Адель Russian: Аль-Мунтахаб Russian: Крачковский Russian: Кулиев Russian: Османов Russian: Порохова Russian: Саблуков Sindhi: امروٽي Somali: Abduh Spanish: Asad Spanish: Cortes Swahili: Al-Barwani Swedish: Bernström Tajik: Оятӣ Tamil: தமிழ் Tatar: Yakub Ibn Nugman Thai: ภาษาไทย Turkish: Abdulbakî Gölpınarlı Turkish: Alİ Bulaç Turkish: Çeviriyazı Turkish: Diyanet İşleri Turkish: Diyanet Vakfı Turkish: Edip Yüksel Turkish: Elmalılı Hamdi Yazır Turkish: Öztürk Turkish: Suat Yıldırım Turkish: Süleyman Ateş Urdu: ابوالاعلی مودودی Urdu: احمد رضا خان Urdu: احمد علی Urdu: جالندہری Urdu: طاہر القادری Urdu: علامہ جوادی Uyghur: محمد صالح Uzbek: Мухаммад Содик
<p> Show Sura:

          <select name="sura" style="width: 230px;" size="1">

            <option value="1" selected="selected">1. Al-Fatiha [7]</option><option value="2">2. Al-Baqara [286]</option><option value="3">3. Aal-e-Imran [200]</option><option value="4">4. An-Nisa [176]</option><option value="5">5. Al-Maeda [120]</option><option value="6">6. Al-Anaam [165]</option><option value="7">7. Al-Araf [206]</option><option value="8">8. Al-Anfal [75]</option><option value="9">9. At-Taubah [129]</option><option value="10">10. Yunus [109]</option><option value="11">11. Hud [123]</option><option value="12">12. Yusuf [111]</option><option value="13">13. Ar-Rad [43]</option><option value="14">14. Ibrahim [52]</option><option value="15">15. Al-Hijr [99]</option><option value="16">16. An-Nahl [128]</option><option value="17">17. Al-Isra [111]</option><option value="18">18. Al-Kahf [110]</option><option value="19">19. Maryam [98]</option><option value="20">20. Taha [135]</option><option value="21">21. Al-Anbiya [112]</option><option value="22">22. Al-Hajj [78]</option><option value="23">23. Al-Mumenoon [118]</option><option value="24">24. An-Noor [64]</option><option value="25">25. Al-Furqan [77]</option><option value="26">26. Ash-Shuara [227]</option><option value="27">27. An-Naml [93]</option><option value="28">28. Al-Qasas [88]</option><option value="29">29. Al-Ankaboot [69]</option><option value="30">30. Ar-Room [60]</option><option value="31">31. Luqman [34]</option><option value="32">32. As-Sajda [30]</option><option value="33">33. Al-Ahzab [73]</option><option value="34">34. Saba [54]</option><option value="35">35. Fatir [45]</option><option value="36">36. Ya Seen [83]</option><option value="37">37. As-Saaffat [182]</option><option value="38">38. Sad [88]</option><option value="39">39. Az-Zumar [75]</option><option value="40">40. Ghafir [85]</option><option value="41">41. Fussilat [54]</option><option value="42">42. Ash-Shura [53]</option><option value="43">43. Az-Zukhruf [89]</option><option value="44">44. Ad-Dukhan [59]</option><option value="45">45. Al-Jathiya [37]</option><option value="46">46. Al-Ahqaf [35]</option><option value="47">47. Muhammad [38]</option><option value="48">48. Al-Fath [29]</option><option value="49">49. Al-Hujraat [18]</option><option value="50">50. Qaf [45]</option><option value="51">51. Adh-Dhariyat [60]</option><option value="52">52. At-tur [49]</option><option value="53">53. An-Najm [62]</option><option value="54">54. Al-Qamar [55]</option><option value="55">55. Al-Rahman [78]</option><option value="56">56. Al-Waqia [96]</option><option value="57">57. Al-Hadid [29]</option><option value="58">58. Al-Mujadila [22]</option><option value="59">59. Al-Hashr [24]</option><option value="60">60. Al-Mumtahina [13]</option><option value="61">61. As-Saff [14]</option><option value="62">62. Al-Jumua [11]</option><option value="63">63. Al-Munafiqoon [11]</option><option value="64">64. At-Taghabun [18]</option><option value="65">65. At-Talaq [12]</option><option value="66">66. At-Tahrim [12]</option><option value="67">67. Al-Mulk [30]</option><option value="68">68. Al-Qalam [52]</option><option value="69">69. Al-Haaqqa [52]</option><option value="70">70. Al-Maarij [44]</option><option value="71">71. Nooh [28]</option><option value="72">72. Al-Jinn [28]</option><option value="73">73. Al-Muzzammil [20]</option><option value="74">74. Al-Muddathir [56]</option><option value="75">75. Al-Qiyama [40]</option><option value="76">76. Al-Insan [31]</option><option value="77">77. Al-Mursalat [50]</option><option value="78">78. An-Naba [40]</option><option value="79">79. An-Naziat [46]</option><option value="80">80. Abasa [42]</option><option value="81">81. At-Takwir [29]</option><option value="82">82. AL-Infitar [19]</option><option value="83">83. Al-Mutaffifin [36]</option><option value="84">84. Al-Inshiqaq [25]</option><option value="85">85. Al-Burooj [22]</option><option value="86">86. At-Tariq [17]</option><option value="87">87. Al-Ala [19]</option><option value="88">88. Al-Ghashiya [26]</option><option value="89">89. Al-Fajr [30]</option><option value="90">90. Al-Balad [20]</option><option value="91">91. Ash-Shams [15]</option><option value="92">92. Al-Lail [21]</option><option value="93">93. Ad-Dhuha [11]</option><option value="94">94. Al-Inshirah [8]</option><option value="95">95. At-Tin [8]</option><option value="96">96. Al-Alaq [19]</option><option value="97">97. Al-Qadr [5]</option><option value="98">98. Al-Bayyina [8]</option><option value="99">99. Al-Zalzala [8]</option><option value="100">100. Al-Adiyat [11]</option><option value="101">101. Al-Qaria [11]</option><option value="102">102. At-Takathur [8]</option><option value="103">103. Al-Asr [3]</option><option value="104">104. Al-Humaza [9]</option><option value="105">105. Al-fil [5]</option><option value="106">106. Quraish [4]</option><option value="107">107. Al-Maun [7]</option><option value="108">108. Al-Kauther [3]</option><option value="109">109. Al-Kafiroon [6]</option><option value="110">110. An-Nasr [3]</option><option value="111">111. Al-Masadd [5]</option><option value="112">112. Al-Ikhlas [4]</option><option value="113">113. Al-Falaq [5]</option><option value="114">114. An-Nas [6]</option>              </select>

        <input type="submit" value=" Go ">  
<? showSura($sura); ?>

To use it, you need to;

  1. Create a subfolder named 'quran' in the directory where this script resides. Put quran script files in this folder.
  2. Similarly, put translation files in subfolder named 'translation'
  3. Rename translation files in correspondence with the numbered values of the SELECT options. (.txt extensions)

You can of course, name the subfolders anything else but then you will need to make changes at lines 57,59,62 & 64.

Also the above script will show translation '0.txt' as default, i.e, when the translation is not specified. You can change it by whatever translation you want as default at line 64.


#5

Jazak Allah for help but what do you mean by (#

Rename translation files in correspondence with the numbered values of the SELECT options. (.txt extensions))


#6

Well for e.g

Arabic: تفسير الجلالين

so translation file of arabic تفسير الجلالين should be named 0.txt as the option value is 0.

Otherwise you will have to change every option values to the corresponding names of the translation files without the '.txt' portion.


#7

Jazak Allah Khaira bhai problem has been solved, you are a great Person, and i am thanking you by the heart , it is sadqah jaria for you


#8

صاحب SupMA5TER جناب

جو قرآن کی خدمت کرے ھم اس کے خادم

آپ کو کراچی میں جو بھی کوئی کام ھو تو بندھ آپ کی خدمت کے لئے یہاں حاضر ھے۔


#9

So many thanks for your kind offer, I will inshallah remember it!

Keep up your site and keep spreading knowledge of Quran to the world. My prays are with you.


#10

if anyone wants to download this-one all script then go ahead to download

http://www.islamiceducationsystem.com/sham/quran_translations_script.zip


#11

java to php converter koi software he???

coz abhi me ne is script me bohot kaam karna baqi he

misaal ke toor par koi soorat poori na parhna chahe balke aayat number 7 se 17 tak read karna cahe to sirf utni hi aayaat aayen

or ye k mere paas poora quran verse by verse audio he is ki tilawat bhi saath saath suni ja sake


#12

mere paas to sirf 3 qarion ki tilawat verse by verse he jabke www.everyayah.com to bohot saare qarion ki tilawat de raha he balke wo to ye bhi keh rahe hen k apne server par audio files upload karne ke bajaye hamara server use karen.