Announcement

Collapse
No announcement yet.

PHP Widget error

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • PHP Widget error

    Hello,

    I am adding the code, but nothing appears. (php widget)

    the code I added:

    Click image for larger version

Name:	Ek Açıklama 2020-02-12 224805.png
Views:	62
Size:	100.3 KB
ID:	4434295

    PHP Code:
    setlocale(LC_ALL'tr_TR.UTF-8''tr_TR''tr''turkish');

    if(!empty(
    $_SERVER['HTTP_CLIENT_IP'])){
    $ip=$_SERVER['HTTP_CLIENT_IP'];
    }
    elseif(!empty(
    $_SERVER['HTTP_X_FORWARDED_FOR'])){
    $ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
    }
    else{
    $ip=$_SERVER['REMOTE_ADDR'];
    }
    $query = @unserialize(file_get_contents('http://ip-api.com/php/'.$ip));

    $sehirler = array(
    2344116 => "İstanbul",
    2343732 => "Ankara",
    2344117 => "İzmir",
    2343678 => "Adana",
    2343680 => "Adıyaman",
    2343682 => "Afyon",
    2343687 => "Ağrı",
    2343707 => "Aksaray",
    2343729 => "Amasya",
    2343733 => "Antalya",
    2343738 => "Ardahan",
    2343741 => "Artvin",
    2343751 => "Aydın",
    2343771 => "Balıkesir",
    2343781 => "Bartın",
    2343786 => "Batman",
    2343787 => "Bayburt",
    2343810 => "Bilecik",
    2343811 => "Bingöl",
    2343814 => "Bitlis",
    2343819 => "Bolu",
    2343840 => "Burdur",
    2343843 => "Bursa",
    2343859 => "Çanakkale",
    2343862 => "Çankırı",
    2343904 => "Çorum",
    2343920 => "Denizli",
    2343932 => "Diyarbakır",
    2343949 => "Edirne",
    2343954 => "Elazığ",
    2343976 => "Erzincan",
    2343977 => "Erzurum",
    2343980 => "Eskişehir",
    2343999 => "Gaziantep",
    2344018 => "Giresun",
    2344042 => "Gümüşhane",
    2344061 => "Hakkari",
    2344073 => "Hatay",
    2323778 => "Mersin",
    2344094 => "Iğdır",
    2344114 => "Isparta",
    2344125 => "Kahramanmaraş",
    2344140 => "Karabük",
    2344152 => "Karaman",
    2344165 => "Kars",
    2344169 => "Kastamonu",
    2344174 => "Kayseri",
    2344196 => "Kırıkkale",
    2344198 => "Kırklareli",
    2324643 => "Kırşehir",
    2344192 => "Kilis",
    2329471 => "Kocaeli",
    2344210 => "Konya",
    2344239 => "Kütahya",
    2344246 => "Malatya",
    2344250 => "Manisa",
    2344252 => "Mardin",
    2344271 => "Muğla",
    2344276 => "Muş",
    2344285 => "Nevşehir",
    2344286 => "Niğde",
    2344302 => "Ordu",
    2344312 => "Osmaniye",
    2344336 => "Rize",
    2344345 => "Sakarya",
    2344351 => "Samsun",
    2344385 => "Siirt",
    2344394 => "Sinop",
    2344398 => "Sivas",
    2344354 => "Şanlıurfa",
    2344396 => "Şırnak",
    2344436 => "Tekirdağ",
    2344446 => "Tokat",
    2344452 => "Trabzon",
    2344453 => "Tunceli",
    2344475 => "Uşak",
    2344480 => "Van",
    2344489 => "Yalova",
    2344529 => "Yozgat",
    2344539 => "Zonguldak" );

    function 
    Baglan($url)
    {
    $curl curl_init();
    curl_setopt($curlCURLOPT_URL$url);
    curl_setopt($curlCURLOPT_RETURNTRANSFERtrue);
    curl_setopt($curlCURLOPT_USERAGENT$_SERVER["HTTP_USER_AGENT"]);
    $cikti curl_exec($curl);
    curl_close($curl);
    return 
    $cikti;
    }

    $baglan Baglan("https://www.google.com.tr/search?sxsrf=ACYBGNQOWiBKMXsAMNvg2-SYSGUykvAjnA%3A1581527765167&source=hp&ei=1TJEXpKbB-KSrgS705bQBg&q=".$query['city']."+hava+durumu&oq=".$query['city']."+hava+durumu&gs_l=psy-ab.3..0i10i70i256j0i10l9.529.4717..4889...1.0..0.275.4246.0j21j4......0....1..gws-wiz.......0i131j0j35i39j0i67j0i22i10i30j0i22i30.n7cFMOIjDgU&ved=0ahUKEwjS2ZGFwsznAhViiYsKH bupBWoQ4dUDCAY&uact=5");



    preg_match_all('#<span class="wob_t" id="wob_tm" style="display:inline">(.*?)</span>#si'$baglan$sicaklik);
    preg_match_all('#<span id="wob_pp">(.*?)</span>#si'$baglan$durum);
    preg_match_all('#<span class="wob_t" style="display:inline">(.*?)</span>#si'$baglan$endusuk);
    preg_match_all('#<span id="wob_pp">(.*?)</span>#si'$baglan$enyuksek);




    if (
    $durum[0][0]!="%0") {

    echo 
    "Hava yağışlı dikkatli sürün. <br>";
    } else {

    echo 
    "Bugün yağış yok. <br>";
    }


    echo 
    "Sıcaklık : "$sicaklik[0][0]. " derece <br>";
    echo 
    "Bulunduğunuz il : " .$query['city']. " <br>";

    echo 
    "En düşük "$endusuk[0][0]. ", en yüksek ".$endusuk[0][1]. " derece";


    $hissedilen intval(strip_tags($hissedilen[0][0]))."°"
    vB 5.5.6!

  • #2
    There's probably an error in the code. We can't troubleshoot custom code for you I'm afraid.

    Your server error logs should provide more detail on what the problem is.
    MARK.B | vBULLETIN SUPPORT

    TalkNewsUK - My vBulletin 5.6.0 Demo
    AdminAmmo - My Cloud Demo

    Comment


    • #3
      yes I really found a mistake. but when it corrected a worse situation occurred.
      Click image for larger version

Name:	Ek Açıklama 2020-02-12 234044.png
Views:	54
Size:	54.6 KB
ID:	4434300
      vB 5.5.6!

      Comment


      • #4
        The code appears to work partially on my test installation:
        Click image for larger version

Name:	2020-02-12_12-43-05.png
Views:	43
Size:	3.5 KB
ID:	4434302



        A weather module could be useful to people.
        Translations provided by Google.

        Wayne Luke
        The Rabid Badger - a vBulletin Cloud demonstration site.
        vBulletin 5 API - Full / Mobile
        Vote for your favorite feature requests and the bugs you want to see fixed.

        Comment


        • #5
          Originally posted by semihcannet View Post
          yes I really found a mistake. but when it corrected a worse situation occurred.
          There is still an error in your code somewhere.

          You will now need to go here:

          AdminCP > Settings > Options > General Settings > Disable PHP, Static HTML, and Ad Module rendering

          Set this to Yes and save.

          This will allow you to edit the module and correct the problem.
          MARK.B | vBULLETIN SUPPORT

          TalkNewsUK - My vBulletin 5.6.0 Demo
          AdminAmmo - My Cloud Demo

          Comment


          • #6
            Yes, we want to tell motorcycle riders the weather and drive carefully.
            vB 5.5.6!

            Comment


            • #7
              Originally posted by Mark.B View Post

              There is still an error in your code somewhere.

              You will now need to go here:

              AdminCP > Settings > Options > General Settings > Disable PHP, Static HTML, and Ad Module rendering

              Set this to Yes and save.

              This will allow you to edit the module and correct the problem.
              When you do this process; Inside the widget it says: "Click Edit to configure this module."
              vB 5.5.6!

              Comment


              • #8
                Yes, because it is turned off. Editing the widget should still allow you to update the PHP code.
                Translations provided by Google.

                Wayne Luke
                The Rabid Badger - a vBulletin Cloud demonstration site.
                vBulletin 5 API - Full / Mobile
                Vote for your favorite feature requests and the bugs you want to see fixed.

                Comment


                • #9
                  I'm having an interesting problem. When I add the code, the site fails. When another friend adds it from their computer, the code works.

                  While the code is running, I enter sitebuilder. I never touch the code. I just change the module name. I approve the change and close the sitebuilder. the site does not work again.

                  computer problem or browser or browser plug-ins?

                  Google translate.
                  vB 5.5.6!

                  Comment


                  • #10
                    FWIW I'm seeing the same issue on a Static HTML widget I know works since the most recent Windows 10 update earlier today. The widget worked perfectly until the update. The issue is occurring in both Firefox and Chrome. It used to display a Twitter timeline. Now it displays "Click Edit to configure this module." Editing the module doesn't work. Neither, for that matter, did removing the module and creating a new one.

                    Comment


                    • In Omnibus
                      In Omnibus commented
                      Editing a comment
                      Here is the error it is showing:

                      [Exception... "Component returned failure code: 0x80520001 (NS_ERROR_FILE_UNRECOGNIZED_PATH) [nsIXPCComponents_Utils.readUTF8URI]" nsresult: "0x80520001 (NS_ERROR_FILE_UNRECOGNIZED_PATH)" location: "JS frame :: resource://gre/modules/L10nRegistry.jsm :: this.L10nRegistry.loadSync :: line 759" data: no]

                    • Wayne Luke
                      Wayne Luke commented
                      Editing a comment
                      Your error appears to point to a resource called Mozilla Searchfox. It is an indexing tool for searching pages. Your issue may be related to Microsoft's recent search issues in Windows.

                    • In Omnibus
                      In Omnibus commented
                      Editing a comment
                      I'm positive you're correct. I just wondered if the other customer was having the same issue for the same reason.

                  • #11
                    Originally posted by semihcannet View Post
                    I'm having an interesting problem. When I add the code, the site fails. When another friend adds it from their computer, the code works.

                    While the code is running, I enter sitebuilder. I never touch the code. I just change the module name. I approve the change and close the sitebuilder. the site does not work again.

                    computer problem or browser or browser plug-ins?
                    I'd lean towards browser plug-ins myself. Make sure you're not blocking any javascript for your site.

                    Translations provided by Google.

                    Wayne Luke
                    The Rabid Badger - a vBulletin Cloud demonstration site.
                    vBulletin 5 API - Full / Mobile
                    Vote for your favorite feature requests and the bugs you want to see fixed.

                    Comment


                    • #12
                      I took the PHP code for the widget and put it into a stand alone file. When run as a web page, it returns several undefined variable notices. This shouldn't cause the entire page to break but that depends on your site. Your friend's IP might work where you're own breaks things. I suggest running it outside of vBulletin to get it to work and then try incorporating it into the system.
                      Translations provided by Google.

                      Wayne Luke
                      The Rabid Badger - a vBulletin Cloud demonstration site.
                      vBulletin 5 API - Full / Mobile
                      Vote for your favorite feature requests and the bugs you want to see fixed.

                      Comment


                      • #13
                        Wayne Luke Mark.B In Omnibus thank you for your help.
                        we are finally done. I think it was nice.

                        https://motosikletforumu.com
                        vB 5.5.6!

                        Comment


                        • #14
                          I get a system error on that page. Not sure why but maybe you should default to some Turkish IP address/location if the person is outside the country.
                          Translations provided by Google.

                          Wayne Luke
                          The Rabid Badger - a vBulletin Cloud demonstration site.
                          vBulletin 5 API - Full / Mobile
                          Vote for your favorite feature requests and the bugs you want to see fixed.

                          Comment


                          • #15
                            We used HTML widgets instead of PHP. https://motosikletforumu.com
                            vB 5.5.6!

                            Comment

                            widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
                            Working...
                            X