Posts: 7
Joined: Feb 2012
Reputation:
0
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?
Posts: 422
Joined: Aug 2010
Reputation:
27
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'] ?
Posts: 7
Joined: Feb 2012
Reputation:
0
2014-01-18, 00:28
(This post was last modified: 2014-01-18, 00:34 by jannik1979.)
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.
Posts: 7
Joined: Feb 2012
Reputation:
0
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.
Posts: 7
Joined: Feb 2012
Reputation:
0
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.
Posts: 422
Joined: Aug 2010
Reputation:
27
2014-01-18, 15:43
(This post was last modified: 2014-01-18, 15:43 by Regss.)
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?
Posts: 7
Joined: Feb 2012
Reputation:
0
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
Posts: 422
Joined: Aug 2010
Reputation:
27
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.
Posts: 422
Joined: Aug 2010
Reputation:
27
2014-01-19, 13:01
(This post was last modified: 2014-01-19, 13:17 by Regss.)
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.
Posts: 30
Joined: Dec 2013
Reputation:
0
2014-01-19, 14:41
(This post was last modified: 2014-01-19, 15:45 by Unr3aL67.)
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?
Posts: 422
Joined: Aug 2010
Reputation:
27
Do you have enabled auto refresh library on xbmc start?
Posts: 30
Joined: Dec 2013
Reputation:
0
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