Current File : //root/panel/modules/change_appearance/code/controller.ext.php
<?php

/**
 * @copyright 2014-2015 Sentora Project (http://www.sentora.org/) 
 * Sentora is a GPL fork of the ZPanel Project whose original header follows:
 *
 * ZPanel - A Cross-Platform Open-Source Web Hosting Control panel.
 *
 * @package ZPanel
 * @version $Id$
 * @author Bobby Allen - ballen@bobbyallen.me
 * @copyright (c) 2008-2014 ZPanel Group - http://www.zpanelcp.com/
 * @license http://opensource.org/licenses/gpl-3.0.html GNU Public License v3
 *
 * This program (ZPanel) is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */


class module_controller extends ctrl_module
{
    static $favheighterror;
    static $favwidtherror; 
    static $logowidtherror;
    static $logoheighterror;
    static $logo_error;
    static $fav_error;
    static $error;
    static $nothingerror;
    static $logo_upload_error;
    static $logo_img_upload_error;
    static $logo_same_upload_error;
    static $theme_logo_upload_error;
    static $theme_logo_img_upload_error;
    static $theme_logo_same_upload_error;
    
    static function doUpdateimage()
    {
        global $zdbh;
        global $controller;
        runtime_csfr::Protect();
        //$currentuser = ctrl_users::GetUserDetail();
        //$logoimg= $_POST['logom_img'];
        //$favicon =$_POST['favicon_img'];

       
    $logoimg= $_FILES['logom_img']['name'];
    $favicon =$_FILES['favicon_img']['name'];
    $logofilenametest=$_FILES["logom_img"]['name'];
    $faviconfilenametest=$_FILES["favicon_img"]['name'];
    $logofilename=time()."_".$_FILES["logom_img"]['name'];
    $faviconfilename=time()."_".$_FILES["favicon_img"]['name'];
//$allowed = array("jpg" => "image/jpg", "jpeg" => "image/jpeg", "gif" => "image/gif", "png" => "image/png");
//         $uploads_dir='/etc/sentora/panel/upload/'. $_FILES["logom_img"]['name'];
    $uploads_dir='/etc/sentora/panel/etc/styles/CstyleX-master/images/hostingrajalogo.jpg';
    $uploads_dir1='/etc/sentora/panel/etc/static/disabled/hostingrajalogo.jpg';
    $uploads_dire='/etc/sentora/panel/etc/styles/CstyleX-master/images/favicon.ico';
    $uploads_dire1='/etc/sentora/panel/etc/static/disabled/favicon.ico';    	
// $_FILES["logom_img"]["tmp_name"];   
    $image_info_logo = getimagesize($_FILES["logom_img"]["tmp_name"]);
    $image_info_fav = getimagesize($_FILES["favicon_img"]["tmp_name"]);
    $width_logo = $image_info_logo [0];
    $height_logo = $image_info_logo [1];
    $width_fav = $image_info_fav [0];
    $height_fav = $image_info_fav [1];
    $hostname=$_POST["textbox"];
    $hostflag=$_POST["prefer"];
    $imageFileType = pathinfo($logofilename,PATHINFO_EXTENSION);
    $imageFileTypee = pathinfo($faviconfilename,PATHINFO_EXTENSION);
    $logo_error=false;
    $fav_error=false;     



    if($imageFileType == "jpg" || $imageFileType == "png" || $imageFileType == "jpeg"
             || $imageFileType == "gif" || $logofilenametest == "")
     {

     }
    else{
          self::$logo_error = true;
    	return false;
    }
    if($imageFileTypee == "jpg" || $imageFileTypee == "png" || $imageFileTypee == "jpeg"
             || $imageFileTypee == "gif" || $faviconfilenametest == "")
    {
    }
    else
    {
    self::$fav_error = true;
    return false;
    }

    /* ///////////////////////////////////  Added For New theme Images start //////////////////////////////// */

    $target_dir = "/etc/sentora/panel/etc/styles/Zentora-master/img/style/";
    $target_file = $target_dir . basename($_FILES["theme_logo_file_name"]["name"]);
    $theme_logo_file_name=$_FILES["theme_logo_file_name"]['name'];
    $theme_upload_file="";
    $theme_logo_error=0;
    $uploadOk = 1;
    $ok_logo_theme_upload=0;
    if($theme_logo_file_name != "")
    {
                $imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
                $check = getimagesize($_FILES["theme_logo_file_name"]["tmp_name"]);
                if($check !== false) 
                {
                    $uploadOk = 1;
                } else {
                     $uploadOk = 0;
                     self::$logo_upload_error=true;
                     return false;
                }
            
            if (file_exists($target_file)) {
                     $uploadOk = 0;
                     self::$logo_same_upload_error=true;
                     return false;
            }
            if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg"
            && $imageFileType != "gif" ) {
                    $uploadOk = 0;
                    self::$logo_img_upload_error=true;
                    return false;
            }
            if ($uploadOk == 0) 
            {
            // echo "Sorry, your file was not uploaded.";
            // if everything is ok, try to upload file
            } 
            else 
            {
                $ok_logo_theme_upload=1;
            }
    }


    $target_dir = "/etc/sentora/panel/etc/styles/Zentora-master/img/style/";
    $target_file = $target_dir . basename($_FILES["theme_logo_file_name"]["name"]);
    $theme_logo_file_name=$_FILES["theme_logo_file_name"]['name'];
    $theme_upload_file="";
    $theme_logo_error=0;
    $uploadOk = 1;
    $ok_logo_theme_upload=0;
    if($theme_logo_file_name != "")
    {
                $imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
                $check = getimagesize($_FILES["theme_logo_file_name"]["tmp_name"]);
                if($check !== false) 
                {
                    $uploadOk = 1;
                } else {
                     $uploadOk = 0;
                     self::$logo_upload_error=true;
                     return false;
                }
            
            if (file_exists($target_file)) {
                     $uploadOk = 0;
                     self::$logo_same_upload_error=true;
                     return false;
            }
            if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg"
            && $imageFileType != "gif" ) {
                    $uploadOk = 0;
                    self::$logo_img_upload_error=true;
                    return false;
            }
            if ($uploadOk == 0) 
            {
            // echo "Sorry, your file was not uploaded.";
            // if everything is ok, try to upload file
            } 
            else 
            {
                $ok_logo_theme_upload=1;
            }
    }

    $theme_target_dir = "/etc/sentora/panel/etc/styles/Zentora-master/img/style/";
    $theme_target_file = $target_dir . basename($_FILES["powered_by_file_name"]["name"]);
    $theme_theme_logo_file_name=$_FILES["powered_by_file_name"]['name'];
    $theme_theme_upload_file="";
    $theme_theme_logo_error=0;
    $uploadOk = 1;
    $theme_ok_logo_theme_upload=0;
    if($theme_theme_logo_file_name != "")
    {
                $imageFileType = strtolower(pathinfo($theme_target_file,PATHINFO_EXTENSION));
                $check = getimagesize($_FILES["powered_by_file_name"]["tmp_name"]);
                if($check !== false) 
                {
                    $uploadOk = 1;
                } else {
                     $uploadOk = 0;
                     self::$theme_logo_upload_error=true;
                     return false;
                }
            
            if (file_exists($theme_target_file)) {
                     $uploadOk = 0;
                     self::$theme_logo_same_upload_error=true;
                     return false;
            }
            if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg"
            && $imageFileType != "gif" ) {
                    $uploadOk = 0;
                    self::$theme_logo_img_upload_error=true;
                    return false;
            }
            if ($uploadOk == 0) 
            {
            // echo "Sorry, your file was not uploaded.";
            // if everything is ok, try to upload file
            } 
            else 
            {
                $theme_ok_logo_theme_upload=1;
            }
    }

   /* ///////////////////////////////////  Added For New theme Images end //////////////////////////////// */
$loginpagecontent=$_POST["editor1"];
if($loginpagecontent != "")
{
$sql = $zdbh->prepare("UPDATE  datacont SET data='$loginpagecontent' WHERE id=1");
$sql->execute();
self::$error ="ok";
}
if($logo_error==false && $logofilenametest !="")
{
        
         move_uploaded_file($_FILES["logom_img"]["tmp_name"], $uploads_dir);
    	// move_uploaded_file($_FILES["logom_img"]["tmp_name"], $uploads_dir1);
        unlink($uploads_dir1);
        copy($uploads_dir,$uploads_dir1);
       $sql = $zdbh->prepare("UPDATE  x_picdata SET logo_path='$logofilename' WHERE id=1");
       $sql->execute();
       self::$error ="ok";

}
if($fav_error==false && $faviconfilenametest !="")
{
      move_uploaded_file($_FILES["favicon_img"]["tmp_name"], $uploads_dire);
     // move_uploaded_file($_FILES["favicon_img"]["tmp_name"], $uploads_dire1);
        unlink($uploads_dire1);
     copy($uploads_dire,$uploads_dire1);
 $sql = $zdbh->prepare("UPDATE  x_picdata SET favicon_path='$faviconfilename' WHERE id=1");
      $sql->execute();
      self::$error ="ok";
}
/*if($logofilenametest == "" && $faviconfilenametest == "" && $loginpagecontent == "" && $hostname=="")
{
self::$nothingerror ="ok";
}*/

/* //////////////////////////////////////  Added By Saravana start //////////////////////////////////////  */

if($ok_logo_theme_upload==1)
{
    if (move_uploaded_file($_FILES["theme_logo_file_name"]["tmp_name"], $target_file)) 
    {
        //$theme_logo_file_name need to update 
        $content=$sql= $zdbh->prepare("UPDATE  x_new_theme_settings SET x_value='$theme_logo_file_name' WHERE x_key='theme_logo_file_name'");
        $sql->execute();
    } else {
 //       echo "Sorry, there was an error uploading your file.";
    }
}


if($theme_ok_logo_theme_upload==1)
{
    if (move_uploaded_file($_FILES["powered_by_file_name"]["tmp_name"], $theme_target_file)) 
    {
        //$theme_logo_file_name need to update 
        $content=$sql= $zdbh->prepare("UPDATE  x_new_theme_settings SET x_value='$theme_theme_logo_file_name' WHERE x_key='powered_by_file_name'");
        $sql->execute();
    } else {
 //       echo "Sorry, there was an error uploading your file.";
    }
}

$content=$sql= $zdbh->prepare("SELECT  data FROM datacont  WHERE id=1");
$sql->execute();
$sql = $zdbh->prepare("UPDATE  x_picdata SET flag='$hostflag' WHERE id='1'");
$sql->execute();
$sql = $zdbh->prepare("UPDATE x_settings SET so_value_tx='true'WHERE so_name_vc='apache_changed'");
$sql->execute();
$link1_caption=trim($_POST['link1_caption']);
$link1_value=trim($_POST['link1_value']);
$sql = $zdbh->prepare("UPDATE  x_new_theme_settings SET x_value='$link1_caption' WHERE x_key='link1_caption'");
$sql->execute();
$sql = $zdbh->prepare("UPDATE  x_new_theme_settings SET x_value='$link1_value' WHERE x_key='link1_value'");
$sql->execute();
$link2_caption=trim($_POST['link2_caption']);
$link2_value=trim($_POST['link2_value']);
$sql = $zdbh->prepare("UPDATE  x_new_theme_settings SET x_value='$link2_caption' WHERE x_key='link2_caption'");
$sql->execute();
$sql = $zdbh->prepare("UPDATE  x_new_theme_settings SET x_value='$link2_value' WHERE x_key='link2_value'");
$sql->execute();
$link3_caption=trim($_POST['link3_caption']);
$link3_value=trim($_POST['link3_value']);
$sql = $zdbh->prepare("UPDATE  x_new_theme_settings SET x_value='$link3_caption' WHERE x_key='link3_caption'");
$sql->execute();
$sql = $zdbh->prepare("UPDATE  x_new_theme_settings SET x_value='$link3_value' WHERE x_key='link3_value'");
$sql->execute();
$notice_settings=trim($_POST['notice_settings']);
$sql = $zdbh->prepare("UPDATE  x_new_theme_settings SET x_value='$notice_settings' WHERE x_key='x_notice_settings'");
$sql->execute();
$powered_by_URL=trim($_POST['powered_by_URL']);
$sql = $zdbh->prepare("UPDATE  x_new_theme_settings SET x_value='$powered_by_URL' WHERE x_key='powered_by_URL'");
$sql->execute();
$powered_by_content=trim($_POST['powered_by_content']);
$sql = $zdbh->prepare("UPDATE  x_new_theme_settings SET x_value='$powered_by_content' WHERE x_key='powered_by_content'");
$sql->execute();
$themed_by_content=trim($_POST['themed_by_content']);
$sql = $zdbh->prepare("UPDATE  x_new_theme_settings SET x_value='$themed_by_content' WHERE x_key='themed_by_content'");
$sql->execute();



/* //////////////////////////////////////  Added By Saravana End  //////////////////////////////////////  */
self::$error ="ok";
}

static function getResult()
    {
         if(self::$logo_error==true)
            {
                return ui_sysmessage::shout(ui_language::translate("Sorry your logo should be in the jpg png jpeg or jpeg format only "), "zannounceerror");
            }

            if(self::$fav_error==true)
            {
                return ui_sysmessage::shout(ui_language::translate("Sorry your favicon should be in the jpg png jpeg or jpeg format only."), "zannounceerror");
            }
            if(self::$nothingerror=="ok")
            {
                return ui_sysmessage::shout(ui_language::translate("Nothing is selected to upload."), "zannounceerror");
            }
        
        
            if (self::$error == "ok")
             {
                return ui_sysmessage::shout(ui_language::translate("Changes have been updated successfully!"), "zannounceok");
             }
    /*  if (self::$error == "dataok")
             {
                return ui_sysmessage::shout(ui_language::translate("Your content has been updated successfully!"), "zannounceok")
             }*/
            if (self::$logowidtherror == true)
             {
                return ui_sysmessage::shout(ui_language::translate("maximum width of logo should be 345px!"), "zannounceerror");
             }
                if (self::$logoheighterror == true)
             {
                return ui_sysmessage::shout(ui_language::translate("maximum height for logo should be 140px!!"),    "zannounceerror");
             }
            if (self::$favwidtherror == true)
             {
                return ui_sysmessage::shout(ui_language::translate("maximum width for favicon should be 18px!"), "zannounceerror");
             }
                if (self::$favheighterror == true)
             {
                return ui_sysmessage::shout(ui_language::translate("maximum height for favicon should be 18px!"),  "zannounceerror");
             }
             if (self::$logo_upload_error == true)
             {
                return ui_sysmessage::shout(ui_language::translate("Kindly update image file only."),  "zannounceerror");
             }
             if (self::$logo_img_upload_error == true)
             {
                return ui_sysmessage::shout(ui_language::translate("Kindly update image file only"),  "zannounceerror");
             }
             if (self::$logo_same_upload_error == true)
             {
                return ui_sysmessage::shout(ui_language::translate("Already file exists with same name, Kindly update some other image"),  "zannounceerror");
             }
             if (self::$theme_logo_upload_error == true)
             {
                return ui_sysmessage::shout(ui_language::translate("Kindly update image file only."),  "zannounceerror");
             }
             if (self::$theme_logo_img_upload_error == true)
             {
                return ui_sysmessage::shout(ui_language::translate("Kindly update image file only"),  "zannounceerror");
             }
             if (self::$theme_logo_same_upload_error == true)
             {
                return ui_sysmessage::shout(ui_language::translate("Already file exists with same name, Kindly update some other image"),  "zannounceerror");
             }

            
}
static function getContent()
{
 global $zdbh;
 global $controller;
$sql= $zdbh->prepare("SELECT  data FROM datacont  WHERE id=1");
$sql->execute();
$content=$sql->fetch();
return $content['data'];
}

static function getoff_notice_settings()
{
    global $zdbh;
    global $controller;
    $sql= $zdbh->prepare("SELECT x_value FROM x_new_theme_settings where x_key='x_notice_settings'");
    $sql->execute();
    $contentl=$sql->fetch();
    if($contentl['x_value']=='0')
    {
    return "checked";
    }
    else
{}

}

static function geton_notice_settings()
{
    global $zdbh;
    global $controller;
    $sql= $zdbh->prepare("SELECT x_value FROM x_new_theme_settings where x_key='x_notice_settings'");
    $sql->execute();
    $contentl=$sql->fetch();
    if($contentl['x_value']=='1')
    {
    return "checked";
    }
    else
{}

}

static function getLink1_caption()
{
    global $zdbh;
    global $controller;
    $sql= $zdbh->prepare("SELECT x_value FROM x_new_theme_settings where x_key='link1_caption'");
    $sql->execute();
    $contentl=$sql->fetch();
    return  $contentl['x_value'];
}


static function getLink1_value()
{
    global $zdbh;
    global $controller;
    $sql= $zdbh->prepare("SELECT x_value FROM x_new_theme_settings where x_key='link1_value'");
    $sql->execute();
    $contentl=$sql->fetch();
    return  $contentl['x_value'];
}

static function getpoweredbyURL()
{
    global $zdbh;
    global $controller;
    $sql= $zdbh->prepare("SELECT x_value FROM x_new_theme_settings where x_key='powered_by_URL'");
    $sql->execute();
    $contentl=$sql->fetch();
    return  $contentl['x_value'];
}


static function getPowered_By_Content()
{
    global $zdbh;
    global $controller;
    $sql= $zdbh->prepare("SELECT x_value FROM x_new_theme_settings where x_key='powered_by_content'");
    $sql->execute();
    $contentl=$sql->fetch();
    return  $contentl['x_value'];
}

static function getThemed_By_Content()
{
    global $zdbh;
    global $controller;
    $sql= $zdbh->prepare("SELECT x_value FROM x_new_theme_settings where x_key='themed_by_content'");
    $sql->execute();
    $contentl=$sql->fetch();
    return  $contentl['x_value'];
}

static function getshow_theme_logo_file_name()
{

    global $zdbh;
    global $controller;
    $sql= $zdbh->prepare("SELECT x_value FROM x_new_theme_settings where x_key='theme_logo_file_name'");
    $sql->execute();
    $contentl=$sql->fetch();
    return  "<img src='etc/styles/Zentora-master/img/style/".$contentl['x_value']."' style='background: #cfcfcf;padding: 5px;'/>";   
}

static function getshow_powered_by_file_name()
{

    global $zdbh;
    global $controller;
    $sql= $zdbh->prepare("SELECT x_value FROM x_new_theme_settings where x_key='powered_by_file_name'");
    $sql->execute();
    $contentl=$sql->fetch();
    return  "<img src='etc/styles/Zentora-master/img/style/".$contentl['x_value']."' style='background: #cfcfcf;padding: 5px;'/>";   
}


static function getLink2_caption()
{
    global $zdbh;
    global $controller;
    $sql= $zdbh->prepare("SELECT x_value FROM x_new_theme_settings where x_key='link2_caption'");
    $sql->execute();
    $contentl=$sql->fetch();
    return  $contentl['x_value'];
}


static function getLink2_value()
{
    global $zdbh;
    global $controller;
    $sql= $zdbh->prepare("SELECT x_value FROM x_new_theme_settings where x_key='link2_value'");
    $sql->execute();
    $contentl=$sql->fetch();
    return  $contentl['x_value'];
}

static function getLink3_caption()
{
    global $zdbh;
    global $controller;
    $sql= $zdbh->prepare("SELECT x_value FROM x_new_theme_settings where x_key='link3_caption'");
    $sql->execute();
    $contentl=$sql->fetch();
    return  $contentl['x_value'];
}


static function getLink3_value()
{
    global $zdbh;
    global $controller;
    $sql= $zdbh->prepare("SELECT x_value FROM x_new_theme_settings where x_key='link3_value'");
    $sql->execute();
    $contentl=$sql->fetch();
    return  $contentl['x_value'];
}

  static function gethelpicon()
    {
        global $zdbh;
        global $controller;
        $temp=$controller->GetControllerRequest('URL','module') ;
        $val = '/assets/one.txt';
        $val1 = '/modules/';
        $name=file_get_contents("modules/$temp/assets/helpicon.txt");
        return $name;
    }

static function getFcontent()
{
 global $zdbh;
 global $controller;
$sql= $zdbh->prepare("SELECT flag FROM x_picdata where id='1'");
$sql->execute();
$contentl=$sql->fetch();
if($contentl['flag']=='0')
{
return "checked";
}
else
{}

}
static function getMcontent()
{
 global $zdbh;
 global $controller;
$sql= $zdbh->prepare("SELECT flag FROM x_picdata where id='1'");
$sql->execute();
$contentm=$sql->fetch();
if($contentm['flag']=='1')
{
return "checked";
}
else
{}

}


}

?>