Aadwark skin changer for visitors

Status
Not open for further replies.

CrazyCoder

Member
Hi Basti, hi Mark !!!

So, i know this forum is about VisioList, but, as i started to talk about my project,
to code a visitors topsite skin changer,
i thought, you would not become angry after me,
if i put a new topic HERE, arfffff ooops :))))

SO, its about my idea of a Aardwark Topsite visitors skin changer.

1) i put this at the beginning of the index.php :

PHP:
<?php
$guest_skin = $_POST['stylesheet'];
2) i created this code.
Still index.php, AFTER :

PHP:
$CONF['skins_path'] = "{$CONF['path']}/skins";
$CONF['skins_url'] = "{$CONF['list_url']}/skins";
$TMPL['skins_url'] = $CONF['skins_url'];
$TMPL['list_name'] = $CONF['list_name'];
$TMPL['list_url'] = $CONF['list_url'];
 
// Combine the GET and POST input
$FORM = array_merge($_GET, $_POST);
 
 
 
############################################# BEGINING of NEXIA'S LANGUAGE HACK!
# here we create an array of the existing languages in the site:
$flagslist = '';
$langarray = array();
 
foreach(glob("languages/*.gif") as $langname)
{
    # we generate the array
    $langarray[] = $thislang = str_replace(array('languages/', '.gif'), '', $langname);
    # then we create the value for the flag displayed on the site.
    $TMPL['flagslist'] .= '<a href="'.$CONF['list_url'].'/index.php?setlang='.$thislang.'" title="'.$thislang.'"><img src="'.$langname.'" alt="'.$thislang.'" style="border:0;vertical-align:middle;" /></a> ';
}
 
 
# if the visitor click to choose a language, we set the cookie properly (if the file exists)
if(!empty($_GET['setlang']))
{
    if(in_array($_GET['setlang'], $langarray))
    {
        setcookie("setlang", $_GET['setlang'], time()+360000);
        $_COOKIE['setlang'] = $_GET['setlang'];
    }
}  # expire in 100 hour
# now we check if we have that cookie, replacing the default language with the cooked one!
$CONF['default_language'] = ($_COOKIE['setlang']) ? $_COOKIE['setlang'] : $CONF['default_language'];
################################################## END of NEXIA'S LANGUAGE HACK!
 
 
 
//##################################"""""
//determine the style
 
 
            // Checks for, and assigns cookie to local variable: 
if(!empty($_COOKIE['style'])) $TMPL['style'] = $_COOKIE['style']; 
            // If no cookie is present then set style as "day" (default): 
else $TMPL['style'] = 'redblack'; 
 
 
// The language file
require_once("{$CONF['path']}/languages/{$CONF['default_language']}.php");
 
// Determine the category and skin
if (isset($FORM['cat']) && isset($CONF['categories'][$FORM['cat']])) {
  $TMPL['skin_name'] = $CONF['categories'][$FORM['cat']];
}
else {
  $TMPL['skin_name'] = $CONF['default_skin'];
}
I put this code i just created this morning :

PHP:
//################################# determine the guest skin
// determine the skin from DB
 
if (!is_dir("{$CONF['path']}/skins/{$TMPL['skin_name']}/") || !$TMPL['skin_name']) {
  $TMPL['skin_name'] = $CONF['default_skin'];
}
/*
if (!is_dir("{$CONF['path']}/skins/{$CONF['default_skin']}/")) {
  $TMPL['skin_name'] = 'fusion';
}
*/
if (!is_dir("{$CONF['path']}/skins/{$CONF['default_skin']}/")) {
  $TMPL['skin_name'] = 'abstract';
}
//////////////////
 
 
 
//determine the guest skin
 
 
$TMPL['visitor_skin_list'] = '
</br /><br />
<div style="float:left;width:250px;height:50px;">
        <p style="text-align:center;"><b>Choix du Skin</b></p>
        <form method="post" action="index.php?guest_skin=stylesheet">
        <select class="blackonwhite" name="stylesheet"  size="1"
        onchange="this.form.submit();">
<option value="abstract">abstract</option>
<option value="fusion">fusion</option>
        </select>
        <input type="hidden">
        </form>
</div>
</br /><br />
';
 
 
 
 
 
// Checks for, and assigns cookie to local variable: 
 
if(!empty($_COOKIE['guest_skin'])) {
if($TMPL['skin_name'] != $_COOKIE['guest_skin'])
$TMPL['skin_name'] = $_COOKIE['guest_skin'];
}
 
elseif(empty($_COOKIE['guest_skin'])) {
if(!empty($guest_skin)) {
setcookie("guest_skin", $guest_skin, time()+360000);
$CONF['default_skin'] = ($_COOKIE['guest_skin']) ? $_COOKIE['guest_skin'] : $CONF['default_skin'];
}
elseif(empty($guest_skin))
echo ""; // on garde le $TMLP['skin_name'] par defaut de la DB !!!
 
}
 
 
/////////////////// NEW CODE about SKIN_CHANGER
re Oops , hihiiiiii first time its ok, index does refresh on submit and skin is changed

but after, oufff ouffffff i cant no more change the skin.

gonna find the bug, but am a few tired right now,

ITS JSUT A TEST ok ?
i wanted to share it with you , so Basti !!! maybe you are much much better than me,
lol, and you could look at my code and laugh a lot,
finding WHERE i could be mistaken, hihihiiiiii

See u later in the afternoon ....

Another ... Coffee Time !!!
yepaaaaaaaaaaaaaaaaaa
 

CrazyCoder

Member
hahaaa am so stupid, seems thsi week end am really too tired,
i mistaken on my code : look :
http://tip-top-torrents.net/index.php?guest_skin=stylesheet

First time i change the skin its almost ok, BUT its relaoding the index page keeping the defaut skin,
AFTER this, i refresh one time the page, and woooo its a miracle, cookie has been set,
the skin is changed ....
but i can no more change it, oufff oufffff

so i am doing several mistakes, lol :)

my var guest_skin is not correctly seted up the second time
AND anyway, even the first time, i did wrong on my if condition,
because i have to refresh the page, the first time, in order to see the new skin shown.

dont worry be happy, am on the right way,

gonna carefully re check my code,

BUT i am near the result i wnated to get , yepaaaaaaaaa
 

CrazyCoder

Member
haaaaaaaaaaaa i am closed to be done, i used the wrong var $conf instead of $tmpl, booo boooo shame on me

so my coide looks like now :

PHP:
//######## NEW CODE about SKIN_CHANGER  ########//
//
// determine the skin from DB - the defaut skin
//
if (!is_dir("{$CONF['path']}/skins/{$TMPL['skin_name']}/") || !$TMPL['skin_name']) {
  $TMPL['skin_name'] = $CONF['default_skin'];
}
 
if (!is_dir("{$CONF['path']}/skins/{$CONF['default_skin']}/")) {
  $TMPL['skin_name'] = 'abstract';
}
//
// determine the guest skin - test cookie and test form input value
//
 
// FIRST  the form, lol :)
 
$TMPL['visitor_skin_list'] = '
<div style="list-style:none;text-align:center;width:250px;height:50px;">
<ul>
<li style="text-align:center;">
<b>Choix du Skin</b>
</li>
<li>&nbsp;</li>
<li>
<form method="post" action="index.php">
<select class="blackonwhite" name="stylesheet"  size="1"
onchange="this.form.submit();">
<option value="">choisis un skin</option>
<option value="">---------------</option>
<option value="abstract">abstract</option>
<option value="fusion">fusion</option>
</select>
<input type="hidden">
</form>
</li>
</ul>
</div>';
 
// SECOND those tests
 
// Checks var from Form - var is there, set up the cookie
if(isset($guest_skin)) {
setcookie("guest_skin", $guest_skin, time()+360000);
$TMPL['skin_name'] = ($_COOKIE['guest_skin']) ? $_COOKIE['guest_skin'] : $TMPL['skin_name'];
}
 
// form var is not there
elseif(!isset($guest_skin)) {
 
// test the cookie - cookie is there
if(isset($_COOKIE['guest_skin'])) {
$TMPL['skin_name'] = ($_COOKIE['guest_skin']) ? $_COOKIE['guest_skin'] : $TMPL['skin_name'];
}
 
// cookie is not there - just do nothing, lol
elseif(!isset($_COOKIE['guest_skin'])) {
echo ""; // on garde le $TMLP['skin_name'] par defaut de la DB !!!
}
}
//######## NEW CODE about SKIN_CHANGER  ########//
 

CrazyCoder

Member
ouff oufffff its running well, except, i have to refresh the page, up to see the new skin,
after each skin change, so i need to fix it, heheeee
BUT later, now its time to relax a few :))))
Go to my site to test it, PLZ : http://tip-top-torrents.net/

site is in french, and not all is translated, when you select the english language, but its really simple to findd my skin changer , its on top , on the left :

Choix du Skin
the select is just under


:)
 
Status
Not open for further replies.
Top