Guys,
I have a web page where customers can login with their info they created. My web site has a standard logo and an option to upload a logo to overwrite the standard one so that each time they login they instead see their own logo
My problem is how do i archive this. I have so far developed a code that stores a user logo with their own login info (hence every user has a unique logo name).
I have also developed some code that dynamically create a "changeLogo.css" file (see code below) then store it in the user's directory if they opt in for this option.
But my problem is how do i use this created css file for each user to overwrite the standard logo if the user did opt in for the option to change the logo?
here is my script that creats a logo dir and a css file for each user that needs one
function css(){
$headerLogo = getLogoFromDB();
$css = <<<EOF
#header h1 a{
background: $headerLogo;
display:block;
text-indent:-9000px;
height:61px;
width:250px;
}
EOF;
return $css;
}
global $COMPANY_LOGOS;
$campaign_name = $_SESSION['campaign_name'];//user name
$company_logo_dir =$COMPANY_LOGOS;//directory to where each user logo file is created i.e /opt/logo/
$dirRoot = $company_logo_dir . $campaign_name;// opt/logo/USER_Name
if(!file_exists($dirRoot)){
mkdir($dirRoot, 0777);
chmod($dirRoot, 0777);
$uploaded_Logo = $COMPANY_LOGOS.$img_name; //temp uploaded file
$new_Logo = $dirRoot.'/'.$img_newname; //name to rename the temp file.
if(!file_exists($new_Logo)){ //check to make sure the file is not already there
copyFile($uploaded_Logo,$new_Logo); //copy the file to the new Campaign name folder
} else { //if it does exist, then rename it to the user's info.
rename($dirRoot .'/'. $img_name, $dirRoot .'/'. $img_newname);
}
}
$css = css();
$cssFile_Name ='changeLogo.css';
$campaign_name = $_SESSION['campaign_name'];
global $USER_CSS_FILES;
$new_cssFile ='';
$company_css_dir =$USER_CSS_FILES;
$dirRoot = $company_css_dir . $campaign_name;
if(!file_exists($dirRoot)){
mkdir($dirRoot, 0777);
chmod($dirRoot, 0777);
file_put_contents($dirRoot.'/'.$cssFile_Name, $css);
} else {//no copies allowed so overwrite the current one
file_put_contents($dirRoot.'/'.$cssFile_Name, $css);
}