Current File : //root/panel/modules/password_strength/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 $ok;

    
    static function getResult()
    {
         if (!fs_director::CheckForEmptyValue(self::$ok)) {
                 return ui_sysmessage::shout(ui_language::translate("Changes has been saved successfully "), "zannounceok");
            }
            return;
    }
 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 doUpdatePasswordStrength()
    {
        global $controller;
        runtime_csfr::Protect();
        $currentuser = ctrl_users::GetUserDetail();
        $formvars = $controller->GetAllControllerRequests('FORM');
        if (self::ExecuteUpdatePasswordStrength($formvars['inEnabledcp'],$formvars['inEnabledea'],$formvars['inEnabledfa'],$formvars['inEnabledmu'], $currentuser['userid']))
          {
		self::$ok = TRUE;
            	return true;
          } else {
           	 return false;
        }
	 	return;  
           
    }

    static function ExecuteUpdatePasswordStrength($cpenable,$eaenable,$faenable,$muenable,$uid)
    {
        global $zdbh;
	global $controller;
        $datasql = $zdbh->prepare("SELECT * FROM  x_password_strength WHERE ps_user_vc='$uid'");
        $datasql->execute();
	$result = $datasql->fetch();
        $id = $result['ps_id_pk'];
        if($result != '')
        {       
        $sql = $zdbh->prepare("UPDATE x_password_strength SET ps_cpenabled_in=:cpenabled,ps_eaenabled_in=:eaenabled,ps_faenabled_in=:faenabled,ps_muenabled_in=:muenabled,ps_updated_vc=:date WHERE ps_id_pk=:id");
        $time = time();
        $sql->bindParam(':cpenabled', $cpenable);
	$sql->bindParam(':eaenabled', $eaenable);
	$sql->bindParam(':faenabled', $faenable);
	$sql->bindParam(':muenabled', $muenable);

        $sql->bindParam(':id', $id);
        $sql->bindParam(':date',$time);
        $sql->execute();
	return true;
        }
        else
        {
        $sql = $zdbh->prepare("INSERT INTO x_password_strength (ps_cpenabled_in,ps_eaenabled_in,ps_faenabled_in,ps_muenabled_in,ps_user_vc,ps_updated_vc) VALUES (:cpenabled,:eaenabled,:faenabled,:muenabled,:userid,:date)");
        $time = time();
        $sql->bindParam(':cpenabled', $cpenable);
	$sql->bindParam(':eaenabled', $eaenable);
	$sql->bindParam(':faenabled', $faenable);
	$sql->bindParam(':muenabled', $muenable);
        $sql->bindParam(':userid', $uid);
        $sql->bindParam(':date', $time);
        $sql->execute();
	return true;
        }
        
    }


    static function getCheckEnabled()
    {
        global $controller;
        return self::CheckEnabled($controller->GetControllerRequest('URL', 'other'));
    }


    static function CheckEnabled()
    {
	global $zdbh;
        global $controller;
        $currentuser = ctrl_users::GetUserDetail();
	$uid = $currentuser['userid'];
        $res = array();
        $datasql = $zdbh->prepare("SELECT * FROM  x_password_strength WHERE ps_user_vc='$uid'");
        $datasql->execute();
        $result = $datasql->fetch();
        $cpenabled = $result['ps_cpenabled_in'];
        $eaenabled = $result['ps_eaenabled_in'];
        $faenabled = $result['ps_faenabled_in'];
        $muenabled = $result['ps_muenabled_in'];
        if ($cpenabled == 1) {
            $echecked = "CHECKED";
            $dchecked = "";
        } else {
            $echecked = "";
            $dchecked = "CHECKED";
        }
        if ($eaenabled == 1) {
            $echecked1 = "CHECKED";
            $dchecked1 = "";
        } else {
            $echecked1 = "";
            $dchecked1 = "CHECKED";
        }
        if ($faenabled == 1) {
            $echecked2 = "CHECKED";
            $dchecked2 = "";
        } else {
            $echecked2 = "";
            $dchecked2 = "CHECKED";
        }
        if ($muenabled == 1) {
            $echecked3 = "CHECKED";
            $dchecked3 = "";
        } else {
            $echecked3 = "";
            $dchecked3 = "CHECKED";
        }

        array_push($res, array('echecked' => $echecked,
            'dchecked' => $dchecked,'status' => $cpenabled, 'echecked1' => $echecked1,  'dchecked1' => $dchecked1,'status1' => $eaenabled,
	    'echecked2' => $echecked2,  'dchecked2' => $dchecked2,'status2' => $faenabled,
	    'echecked3' => $echecked3,  'dchecked3' => $dchecked3,'status3' => $muenabled));
        return $res;
    }

}