The only problem i see with this script is that if a user sets their template to "custom" then the webmaster deletes the template "custom" it will no longer allow them to log in until it is changed.
QuoteThe only problem i see with this script is that if a user sets their template to "custom" then the webmaster deletes the template "custom" it will no longer allow them to log in until it is changed.That's because you are "Guessing" what is in place and what is not, instead of checking that it exists.?Every template would need a file named the same as the template - like default.cfg in the default, and "black.cfg" for a template named black - for example.That file would only need to be at the minimum:<?php// This file needs to exist?>And this is where checking it with a variable takes the guesswork out of it.If (whatever($template/$template.cfg)) {do this}else{do that};
Actually i have redone this in the newest version of the script. It works a bit differently and if i remember correctly i put in a check to make sure it exists and if not it uses default, im not entirely sure because i havnt worked on it in a while because of the holiday.
<option value="default">default</option>'; $theme = "SELECT * FROM fas_themes WHERE `active`='1'"; $theme = sqlcache('themes', $cachelife, $theme); foreach($theme as $row2){ if ($row2['name'] == $utemplate) { $usel = "selected"; }else{ $usel = NULL; } echo"<option value=".$row2['name']." ".$usel." >".$row2['name']."</option>"; }echo' </select>
$query = $db->query(sprintf("SELECT template_name FROM " . THEMES_TABLE . " WHERE visible=1 ORDER BY template_name ASC")) or die(mysql_error()); $style_list = ' <select name="user_style">'; while($row = $db->fetch_row($query)){ $template_name = $row['template_name'] ; $selected = ''; if (!empty($user_style) && ($template_name == $user_style)) { $selected = 'selected="selected"'; } $style_list .= '<option style="width:100px;" value="'.$template_name.'"'.$selected.'>'.$template_name.'</option>';};$style_list .= '</select>';echo ''.$style_list.'
Quote from: spagetiokillers on January 08, 2013, 04:30:09 PMActually i have redone this in the newest version of the script. It works a bit differently and if i remember correctly i put in a check to make sure it exists and if not it uses default, im not entirely sure because i havnt worked on it in a while because of the holiday.I suspect that you unbanned me because you would like some help here. So what are all the other "Developers" doing?I took an interest in what you were trying to do with this because it's something that you have been working on for a long time.But you don't cache "User Themes", only the Default, because if they change it - They have to wait until the cache refreshes before they can see it. It's the Default that gets the hiding - Not the user-themes. And if you want to write this in a different way?Code: [Select]<option value="default">default</option>'; $theme = "SELECT * FROM fas_themes WHERE `active`='1'"; $theme = sqlcache('themes', $cachelife, $theme); foreach($theme as $row2){ if ($row2['name'] == $utemplate) { $usel = "selected"; }else{ $usel = NULL; } echo"<option value=".$row2['name']." ".$usel." >".$row2['name']."</option>"; }echo' </select>Try something like this.Code: [Select] $query = $db->query(sprintf("SELECT template_name FROM " . THEMES_TABLE . " WHERE visible=1 ORDER BY template_name ASC")) or die(mysql_error()); $style_list = ' <select name="user_style">'; while($row = $db->fetch_row($query)){ $template_name = $row['template_name'] ; $selected = ''; if (!empty($user_style) && ($template_name == $user_style)) { $selected = 'selected="selected"'; } $style_list .= '<option style="width:100px;" value="'.$template_name.'"'.$selected.'>'.$template_name.'</option>';};$style_list .= '</select>';echo ''.$style_list.'
if(isset($_SESSION['userid'])){ $suserid = $_SESSION['userid']; $usrdata = $db->fetch_row($db->query(sprintf('SELECT * FROM dd_users WHERE userid=\'%u\'', $suserid)));}else{ $suserid = NULL; $usrdata = NULL; }if(isset($suserid)){ $query = mysql_query("SELECT `template` FROM `dd_users` WHERE `userid`='$suserid'"); $row = mysql_fetch_array($query); $user_template = $row['template'];}else{ $user_template = '';}if(!empty($user_template) && $user_template != "default"){ $template = $user_template; }else{ $query = mysql_query("SELECT `template` FROM `fas_themes` WHERE `default`='1'"); $row = mysql_fetch_array($query); $template = $row['template']; }
I'll explain it a bit later - With this script, from what I can see - If you change the default style in the ACP to say "Blue" the user will be still be redirected to a theme called default? And if the "default" theme doesn't exist - as it doesn't in beta2 What happens if one is not logged in, or hasn't selected a theme, and the theme "default" doesn't exist?Code: [Select]if(isset($_SESSION['userid'])){ $suserid = $_SESSION['userid']; $usrdata = $db->fetch_row($db->query(sprintf('SELECT * FROM dd_users WHERE userid=\'%u\'', $suserid)));}else{ $suserid = NULL; $usrdata = NULL; }if(isset($suserid)){ $query = mysql_query("SELECT `template` FROM `dd_users` WHERE `userid`='$suserid'"); $row = mysql_fetch_array($query); $user_template = $row['template'];}else{ $user_template = '';}if(!empty($user_template) && $user_template != "default"){ $template = $user_template; }else{ $query = mysql_query("SELECT `template` FROM `fas_themes` WHERE `default`='1'"); $row = mysql_fetch_array($query); $template = $row['template']; }
if(isset($_SESSION['userid'])){ $suserid = $_SESSION['userid']; $usrdata = $db->fetch_row($db->query(sprintf("SELECT * FROM dd_users WHERE userid='%u'", $suserid))); $query = mysql_query("SELECT template FROM fas_themes WHERE visible=1 ORDER BY template ASC") or die(mysql_error()); while($row = mysql_fetch_array($query)) { $available = $row['template']; $style = $usrdata['user_template']; if((!$usrdata) || ($available != $style)){$template = $template; // Whatever is set in the ACP Settings }else{ if(!empty($style)) {$template = $style;} } } mysql_free_result($query);}
Bit confusing if not anything else?If you changed the user "template" to "user_template"You could use something like this.Code: [Select] if(isset($_SESSION['userid'])){ $suserid = $_SESSION['userid']; $usrdata = $db->fetch_row($db->query(sprintf("SELECT * FROM dd_users WHERE userid='%u'", $suserid))); $query = mysql_query("SELECT template FROM fas_themes WHERE visible=1 ORDER BY template ASC") or die(mysql_error()); while($row = mysql_fetch_array($query)) { $available = $row['template']; $style = $usrdata['user_template']; if((!$usrdata) || ($available != $style)){$template = $template; // Whatever is set in the ACP Settings }else{ if(!empty($style)) {$template = $style;} } } mysql_free_result($query);}Too easy.
Get what im saying?
Quote from: spagetiokillers on January 14, 2013, 09:08:48 PMGet what im saying?No I don't - The "default" theme in the ACP is the one Admin wants the Guests to see - Or "New" users to have when they register - Not force users to have it, just because he thinks they should. Doesn't make sense?
There's something else that is missing,Without logged Sessions or Cookie Sessions, I can't see how anything the user selects is going to be "Remembered" from page to page, or how things are going to be "Remembered" between login and logout. FAS has neither?