MovieLib - Your movie database on web - Printable Version +- Kodi Community Forum (https://forum.kodi.tv) +-- Forum: Support (https://forum.kodi.tv/forumdisplay.php?fid=33) +--- Forum: Supplementary Tools for Kodi (https://forum.kodi.tv/forumdisplay.php?fid=116) +--- Thread: MovieLib - Your movie database on web (/showthread.php?tid=167893) |
RE: MovieLib - Your movie database on web - jannik1979 - 2014-01-17 Hi Regss. I just installed your new version (2.2.0), but i have run into a problem with the get_setting function. The first time its called, a print_r($set); gives this output: Array ( [site_name] => vores site [language] => en [theme] => default [per_page] => 50 [panel_top_limit] => 10 [panel_top_time] => 5 [panel_top] => 1 [watched_status] => 1 [panel_overall] => 1 [panel_genre] => 1 [panel_year] => 1 [panel_country] => 1 [panel_v_codec] => 1 [panel_a_codec] => 1 [panel_a_chan] => 1 [show_fanart] => 1 [show_trailer] => 1 [protect_site] => 0 [token] => ) As you can see, everything looks great. When i refresh the page, the same command returns this: Array ( [site_name] => vores site [language] => Array ( [bg] => Bulgarian [cs] => Czech [da] => Danish [de] => German [en] => English [es] => Spanish [fr] => French [hu] => Hungarian [it] => Italian [nl] => Dutch [no] => Norwegian [pl] => Polish [pt] => Portuguese [ru] => Russian ) [theme] => default [per_page] => 50 [panel_top_limit] => 10 [panel_top_time] => 5 [panel_top] => 1 [watched_status] => 1 [panel_overall] => 1 [panel_genre] => 1 [panel_year] => 1 [panel_country] => 1 [panel_v_codec] => 1 [panel_a_codec] => 1 [panel_a_chan] => 1 [show_fanart] => 1 [show_trailer] => 1 [protect_site] => 0 [token] => ) So its the key named language that is confused with the array called $language during the get_settings function. So it seems it gets it right the first time, but not the 2nd time. I dont know if it has to do with the $_SESSION just beeing refreshed the first time the get_settings function is called, or if its something completly different. as a test, i tried renaming the language field in the database to 'dlanguage' and also change the reference to it in admin.php, sync.php, login.php and index.php. This makes everything works again. No one else is experiencing this? or can tell me what the problem is with my initial installation? RE: MovieLib - Your movie database on web - Regss - 2014-01-17 I can not get the idea why this happens in your installation. I'm trying to create the same situations but without success. What return echo $_SESSION['language'] ? RE: MovieLib - Your movie database on web - jannik1979 - 2014-01-18 Hi again. To help troubleshooting i changed the first part of index.php to look like this: <?PHP session_start(); header('Content-type: text/html; charset=utf-8'); require('config.php'); require('function.php'); if (file_exists('install.php') or !file_exists('db.php')) { header('Location:install.php'); die(); } // connect to database connect($mysql_ml); // get settings from db $set = get_settings($mysql_ml, $mysql_tables); echo 'Command: echo $_SESSION[\'language\'];, Output: '; echo $_SESSION['language']; echo chr(13),chr(10); echo 'Command: echo $set[\'language\'];, Output: '; echo $set['language']; echo chr(13),chr(10); echo 'Command: print_r($set);, Output: '; print_R($set); echo chr(13),chr(10); echo 'Command: print_r($_SESSION);, Output: '; print_R($_SESSION); echo chr(13),chr(10); require('lang/' . $set['language'] . '/lang.php'); Now. the output of this returns this: Command: echo $_SESSION['language'];, Output: Array Command: echo $set['language'];, Output: Array Command: print_r($set);, Output: Array ( [site_name] => MovieLib [language] => Array ( [bg] => Bulgarian [cs] => Czech [da] => Danish [de] => German [en] => English [es] => Spanish [fr] => French [hu] => Hungarian [it] => Italian [nl] => Dutch [no] => Norwegian [pl] => Polish [pt] => Portuguese [ru] => Russian ) [theme] => default [per_page] => 50 [panel_top_limit] => 10 [panel_top_time] => 5 [panel_top] => 1 [watched_status] => 1 [panel_overall] => 1 [panel_genre] => 1 [panel_year] => 1 [panel_country] => 1 [panel_v_codec] => 1 [panel_a_codec] => 1 [panel_a_chan] => 1 [show_fanart] => 1 [show_trailer] => 1 [protect_site] => 0 [token] => ) Command: print_r($_SESSION);, Output: Array ( [site_name] => MovieLib [language] => Array ( [bg] => Bulgarian [cs] => Czech [da] => Danish [de] => German [en] => English [es] => Spanish [fr] => French [hu] => Hungarian [it] => Italian [nl] => Dutch [no] => Norwegian [pl] => Polish [pt] => Portuguese [ru] => Russian ) [theme] => default [per_page] => 50 [panel_top_limit] => 10 [panel_top_time] => 5 [panel_top] => 1 [watched_status] => 1 [panel_overall] => 1 [panel_genre] => 1 [panel_year] => 1 [panel_country] => 1 [panel_v_codec] => 1 [panel_a_codec] => 1 [panel_a_chan] => 1 [show_fanart] => 1 [show_trailer] => 1 [protect_site] => 0 [token] => ) Warning: require(lang/Array/lang.php): failed to open stream: No such file or directory in /volume1/web/movielib2/index.php on line 36 Fatal error: require(): Failed opening required 'lang/Array/lang.php' (include_path='.:/usr/syno/php/lib/php') in /volume1/web/movielib2/index.php on line 36 Oh, and here is the exact same thing on the version of your script where i renamed the field called 'language' to 'dlanguage' in the database and in the php files: Command: echo $_SESSION['dlanguage'];, Output: en Command: echo $set['dlanguage'];, Output: en Command: print_r($set);, Output: Array ( [site_name] => vores site [dlanguage] => en [theme] => default [per_page] => 50 [panel_top_limit] => 10 [panel_top_time] => 5 [panel_top] => 1 [watched_status] => 1 [panel_overall] => 1 [panel_genre] => 1 [panel_year] => 1 [panel_country] => 1 [panel_v_codec] => 1 [panel_a_codec] => 1 [panel_a_chan] => 1 [show_fanart] => 1 [show_trailer] => 1 [protect_site] => 0 [token] => ) Command: print_r($_SESSION);, Output: Array ( [site_name] => vores site [dlanguage] => en [theme] => default [per_page] => 50 [panel_top_limit] => 10 [panel_top_time] => 5 [panel_top] => 1 [watched_status] => 1 [panel_overall] => 1 [panel_genre] => 1 [panel_year] => 1 [panel_country] => 1 [panel_v_codec] => 1 [panel_a_codec] => 1 [panel_a_chan] => 1 [show_fanart] => 1 [show_trailer] => 1 [protect_site] => 0 [token] => ) As you can see, everything comes out as its supposed to here. RE: MovieLib - Your movie database on web - Regss - 2014-01-18 Try in function.php replace: Code: function get_settings($mysql_ml, $mysql_tables) { to: Code: function get_settings($mysql_ml, $mysql_tables) { Clear the session before. RE: MovieLib - Your movie database on web - jannik1979 - 2014-01-18 Hi again. The first time the code execute, it works. the 2nd time (when it just returns the session without getting the results from the db first) it fails Works : language = en Fails : language = Array ( blblal) This also happened with the old code. Though, I tried changing the get_setting function to this: $set_sql = 'SELECT * FROM ' . $mysql_tables[1]; $set_result = mysql_query($set_sql); $get_set = mysql_fetch_assoc($set_result); $_SESSION = $get_set; return $_SESSION; And now it works every time. Soo I'm still at a loss here. i don't really see the difference in first setting the $_SESSION and then returning it, or just returning the same session after it was set previously.. Unless there is something else messing with the $_SESSION later on in the script that i haven't found yet. RE: MovieLib - Your movie database on web - jannik1979 - 2014-01-18 Just to do some more testing i tried adding a array called $theme in the config file like this: // theme test $theme = array( 'bg' => 'Bulgarian', 'cs' => 'Czech', 'da' => 'Danish', 'de' => 'German' ); Now. I rest the get_setting function to the one you suggested. The first output of the debug page is: Command: echo $_SESSION['language'];, Output: en Command: echo $set['language'];, Output: en Command: print_r($set);, Output: Array ( [site_name] => MovieLib [language] => en [theme] => default [per_page] => 50 [panel_top_limit] => 10 [panel_top_time] => 5 [panel_top] => 1 [watched_status] => 1 [panel_overall] => 1 [panel_genre] => 1 [panel_year] => 1 [panel_country] => 1 [panel_v_codec] => 1 [panel_a_codec] => 1 [panel_a_chan] => 1 [show_fanart] => 1 [show_trailer] => 1 [protect_site] => 0 [token] => ) Command: print_r($_SESSION);, Output: Array ( [site_name] => MovieLib [language] => en [theme] => default [per_page] => 50 [panel_top_limit] => 10 [panel_top_time] => 5 [panel_top] => 1 [watched_status] => 1 [panel_overall] => 1 [panel_genre] => 1 [panel_year] => 1 [panel_country] => 1 [panel_v_codec] => 1 [panel_a_codec] => 1 [panel_a_chan] => 1 [show_fanart] => 1 [show_trailer] => 1 [protect_site] => 0 [token] => ) The 2nd run (refresh) returns this: Command: echo $_SESSION['language'];, Output: Array Command: echo $set['language'];, Output: Array Command: print_r($set);, Output: Array ( [site_name] => MovieLib [language] => Array ( [bg] => Bulgarian [cs] => Czech [da] => Danish [de] => German [en] => English [es] => Spanish [fr] => French [hu] => Hungarian [it] => Italian [nl] => Dutch [no] => Norwegian [pl] => Polish [pt] => Portuguese [ru] => Russian ) [theme] => Array ( [bg] => Bulgarian [cs] => Czech [da] => Danish [de] => German ) [per_page] => 50 [panel_top_limit] => 10 [panel_top_time] => 5 [panel_top] => 1 [watched_status] => 1 [panel_overall] => 1 [panel_genre] => 1 [panel_year] => 1 [panel_country] => 1 [panel_v_codec] => 1 [panel_a_codec] => 1 [panel_a_chan] => 1 [show_fanart] => 1 [show_trailer] => 1 [protect_site] => 0 [token] => ) Command: print_r($_SESSION);, Output: Array ( [site_name] => MovieLib [language] => Array ( [bg] => Bulgarian [cs] => Czech [da] => Danish [de] => German [en] => English [es] => Spanish [fr] => French [hu] => Hungarian [it] => Italian [nl] => Dutch [no] => Norwegian [pl] => Polish [pt] => Portuguese [ru] => Russian ) [theme] => Array ( [bg] => Bulgarian [cs] => Czech [da] => Danish [de] => German ) [per_page] => 50 [panel_top_limit] => 10 [panel_top_time] => 5 [panel_top] => 1 [watched_status] => 1 [panel_overall] => 1 [panel_genre] => 1 [panel_year] => 1 [panel_country] => 1 [panel_v_codec] => 1 [panel_a_codec] => 1 [panel_a_chan] => 1 [show_fanart] => 1 [show_trailer] => 1 [protect_site] => 0 [token] => ) Warning: require(lang/Array/lang.php): failed to open stream: No such file or directory in /volume1/web/movielib2/index.php on line 36 Fatal error: require(): Failed opening required 'lang/Array/lang.php' (include_path='.:/usr/syno/php/lib/php') in /volume1/web/movielib2/index.php on line 36 As you can see, the problem is both happening with the language and the theme variable now. Apparently it does not like that a session variable shares name with another variable in the config file.. I don't understand why though, and i also dont understand why it only is a problem when you refresh the page. RE: MovieLib - Your movie database on web - Regss - 2014-01-18 I don't want call every time mysql query to get settings from database when reload page. So in my code is a condition. I do not see anything in the code of what could override sessions. The strangest thing that I don't have this error. What version of PHP, Mysql do you have? RE: MovieLib - Your movie database on web - jannik1979 - 2014-01-18 Mysql is : Database-server Server: Localhost via UNIX socket Programmel: MySQL Programmelversion: 5.1.49 - Source distribution Protokolversion: 10 Servers tegnsæt: UTF-8 Unicode (utf8) Webserver Apache Databaseklientversion: libmysql - 5.1.49 PHP Version 5.3.27 RE: MovieLib - Your movie database on web - Unr3aL67 - 2014-01-18 Hey there! First I'd really like to thank you for this great piece of work. Although I had absolutely no clue about PHP/MySQL I was now able to properly set it up on my free webspace which supports this. It's running the following: Code: MySQL I'm running XBMC 12.3 on Windows 7. I could get it to initiate syncing and as of yet about 120 of my 800 movies are synced. In order to get up to 120 I had to change the token about 10 times now... After setting the token in the add-on it sometimes runs for about 2 minutes and then displays "Can't connect to http://cstone.kilu.de/movies/". Within that time it may sync up to 20 movies, sometimes none. After restarting XBMC then i almost immediately get "Sync error". I have captured a log now with debug enabled in the add-on only and not in XBMC in general. Please forgive me if that was nonsense, but a quick look-through showed me all errors I got are in the log. You can find it HERE. Please forgive my noobishness but that is how I learn those things. i find myself unable to dig into advanced PHP/MySQL now, when it may only be a minor bug or mistake by myself... Greetz, Unr3aL67 RE: MovieLib - Your movie database on web - Regss - 2014-01-19 If sync only 20 movies and you get error, it can be a problem with the server that after many calls from the same IP returns an error. If you could run XBMC wait for the error and immediately get xbmc.log and paste again. RE: MovieLib - Your movie database on web - Unr3aL67 - 2014-01-19 OK, now this one was captured right after the popup "Can't connect..." occurred without exiting xbmc: http://pastebin.com/PdFk5dRJ I changed the token on the web interface, then changed it in the add-on and exited XBMC. Upon restarting XBMC it first displayed "Sync error" and after about 20 seconds it displayed "Can't connect...". I then immediately captured the log... Hope this helps! Greetz, Unr3aL67 RE: MovieLib - Your movie database on web - Regss - 2014-01-19 You runing script manually? I see in the log that the script is running double time. Some movies is added to movielib? Ok I see. A some movie is added. Is probably your server has protection and after a large number of calls returns a connection error. Remains you to successively run the script witch some time until you synchronize all movies, because it is a large database. Then add a few new movies will not cause an error. RE: MovieLib - Your movie database on web - Unr3aL67 - 2014-01-19 I guess you're right, no I usually don't try to run it manually... The log I sent you was all automatic sync on XBMC startup... Would there be any way for me to slow down the sync so it does not run into that problem? Maybe some kind of timeout logic would be a good idea like: Run into error -> Wait for 1 minute -> try again (max. 3-5 retries then error). What do you think? About the double running: I guess, if it really runs twice it would be best to stop it from doing that. That could namely be the cause for the sync errors. At some point I read an error in the log, something like "already exists"... Maybe the script at some point tried to create the same entry twice at the same time... Also it may create double the load on the server and makes it run into error faster... Do you have any idea how to stop it from running twice? Thanks for the help! Greetz, Unr3aL67 EDIT: The script creates ' as \' so "Ocean's Eleven" is created and displayed as "Ocean\'s Eleven", I can manually edit those entries but for the plot field that could be a lot of work. Is that a bug or is something wrong with my charset? If it's just a minor bug, is there an easy way to fix this? RE: MovieLib - Your movie database on web - Regss - 2014-01-19 Do you have enabled auto refresh library on xbmc start? RE: MovieLib - Your movie database on web - Unr3aL67 - 2014-01-19 Yes I have! Now I get it... Since it is triggered on the two events "Stop playing" and "Refresh library" it is triggered by the refresh on startup and also auto-starts on XBMC startup, am I right? Any Idea how to circumvent this without turning the refresh off? Greetz, Unr3aL67 |