Example #1
1
function Check($va)
{
    global $scDb;
    $cUserName = strtolower($va['cUser']);
    $cPassword = $va['cPassword'];
    $cPassword = scCrypt::CryptPass($cPassword);
    $dbData = $scDb->Browse("username", "*", "UserName = '******' and Password like '{$cPassword}%'");
    if ($dbRow = $scDb->GetRow($dbData)) {
        $cNama = "Administrator";
        SaveSession("cSession_UserName", $cUserName);
        SaveSession("cSession_FullName", $dbRow['FullName']);
        SaveSession("cSession_Foto", $dbRow['Foto']);
        SaveSession("cSession_UserName_Target", $dbRow['UserName_Target']);
        //new sc levelup
        $cLevel = scCrypt::GetLevelPass($dbRow['Password']);
        SaveSession("cSession_SCLevel", $cLevel);
        SaveSession("cSession_SCLevelmd5", scSys::GetKeteranganOne("Isi", "Kode = '{$cLevel}'", "username_level"));
        //update login and last login
        $vaArray = array("LastLogin" => date("Y-m-d h:i:s"));
        $scDb->Edit("username", $vaArray, "UserName = '******' and Password like '{$cPassword}%'");
        SaveSession("bismillahauth", md5(time() . $cUserName));
        //reload me
        echo '  
				window.location = "./" ;
				';
    } else {
        echo '
					$("#login.panel .panel-body .error").slideDown(800,function(){
						$(this).html("User or Password not found") ; 
					}) ;  
				';
    }
}
Example #2
0
function SavingFoto($va)
{
    $cDim = $va['cDim'];
    $cReturn = null;
    $cDir = "./uploaded/";
    foreach ($va['file'] as $vaFile) {
        $vaInfo = pathinfo($vaFile['name']);
        $nRand = rand(0, time());
        $nRand = substr($nRand, 0, 4);
        $cDir = $cDir . $vaInfo['filename'] . "_" . $nRand . "." . $vaInfo['extension'];
        if (is_file($cDir)) {
            unlink($cDir);
        }
        if (move_uploaded_file($vaFile['tmp_name'], $cDir)) {
            $cReturn = $cDir;
        } else {
            $cReturn = "";
        }
    }
    SaveSession("fileFoto" . $cDim, $cReturn);
    if ($cDim == "1") {
        echo 'oSys.SavingFoto2() ; ';
    } else {
        echo 'oSys.Saving() ; ';
    }
}
Example #3
0
 public static function GetData_Menu($cPath = "", $cSession = "", $cmenu_key_set = "", $cmodul_name = "")
 {
     $vaReturn = array();
     $vaReturn_Menu = array();
     $lEmpty = true;
     if ($cSession !== "") {
         $vaReturn = GetSession($cSession);
         if ($vaReturn !== "") {
             $lEmpty = false;
             $vaReturn = json_decode($vaReturn, true);
         }
     }
     if ($lEmpty) {
         if ($cPath == "") {
             $cFileLoc = self::$cFileLoc;
         } else {
             $cFileLoc = $cPath . "scmenu.menu.php";
         }
         if (is_file($cFileLoc)) {
             $vaFile = file($cFileLoc);
             if (is_array($vaFile)) {
                 $vaReturn_Menu = $nkey_pos = 0;
                 $ckey_pos = 0;
                 $vakey_pos = array();
                 $vaSet = array();
                 foreach ($vaFile as $ckeyfile => $cvalue) {
                     $cIdentifier = strpos($cvalue, "#");
                     if ($cIdentifier === false && trim($cvalue) !== "" && strpos($cvalue, "<?php die('Sapeltu Inc.'); ?>") !== 0) {
                         $nPos = strpos($cvalue, "[");
                         $vaMenu = scArray::Menu2Array($cvalue, $cPath, $cmodul_name);
                         if ($nPos == 0) {
                             $vakey_pos = array();
                         }
                         $cmenu_key = $vaMenu['cMd5'];
                         $vakey_pos[$nPos] = $cmenu_key;
                         self::SetArray_Tree($vaReturn, $vakey_pos, $nPos, $cmenu_key, $vaMenu);
                     }
                 }
             }
             if (is_array($vaReturn)) {
                 SaveSession($cSession, json_encode($vaReturn));
                 $vaReturn_Menu = $vaReturn;
             }
             if ($cmenu_key_set !== "") {
                 $vaReturn_Menu = self::GetData_Menu($cFileLoc, $cSession, $cmenu_key_set);
             }
         }
     } else {
         if ($cmenu_key_set == "") {
             $vaReturn_Menu = $vaReturn;
         } else {
             $vaReturn_Menu = self::GetData_Menuchildren($vaReturn, $cmenu_key_set);
         }
     }
     return $vaReturn_Menu;
 }
Example #4
0
function SetDefine()
{
    //set define harus dipanggil setiap saat karena define jika direload akan hilang
    //ex define("sapeltu","isi",true) ;
    //location
    if (!defined("SYS_Url")) {
        define("SYS_Url", scSys::GetConfig("sc_front_url"));
    }
    if (!defined("SYS_UrlCore")) {
        define("SYS_UrlCore", SYS_Url . "sapeltucore/");
    }
    if (!defined("SYS_UrlImages")) {
        define("SYS_UrlImages", SYS_Url . "/uploaded/");
    }
    if (!defined("SYS_Title")) {
        define("SYS_Title", scSys::GetConfig("sc_front_title"));
    }
    if (!defined("SYS_ImgHeader")) {
        define("SYS_ImgHeader", scSys::GetConfig("sc_header"));
    }
    if (!defined("SYSCORE_VER")) {
        define("SYSCORE_VER", "0.0.1");
    }
    if (!defined("SYCORE_MAIL")) {
        define("SYCORE_MAIL", "SMTP");
    }
    //pdf setup
    if (!defined('PDF_MARGIN_FOOTER')) {
        define('PDF_MARGIN_FOOTER', 10);
    }
    if (!defined('PDF_MARGIN_TOP')) {
        define('PDF_MARGIN_TOP', 10);
    }
    if (!defined('PDF_MARGIN_BOTTOM')) {
        define('PDF_MARGIN_BOTTOM', 10);
    }
    if (!defined('PDF_MARGIN_LEFT')) {
        define('PDF_MARGIN_LEFT', 13);
    }
    if (!defined('PDF_MARGIN_RIGHT')) {
        define('PDF_MARGIN_RIGHT', 7);
    }
    if (!defined('SYSCORE_VER')) {
        define('SYSCORE_VER', '0.0.2');
    }
    if (GetSession("scDatabase") == "") {
        SCDatabase();
        SaveSession("scDatabase", "oke");
    }
}
Example #5
0
function SavingFoto($va)
{
    $cDim = GetSession("cSession_UserName");
    $cReturn = null;
    $cDir = "./uploaded/profile/";
    foreach ($va['file'] as $vaFile) {
        $vaInfo = pathinfo($vaFile['name']);
        $cDir = $cDir . $cDim . "." . $vaInfo['extension'];
        if (is_file($cDir)) {
            unlink($cDir . ".tmp");
            unlink($cDir);
        }
        if (move_uploaded_file($vaFile['tmp_name'], $cDir . ".tmp")) {
            scImages::GenerateThumbnail($cDir . ".tmp", $cDir, 599, 399);
            unlink($cDir . ".tmp");
            $cReturn = $cDir;
        } else {
            $cReturn = "";
        }
    }
    SaveSession("g" . $cDim, $cReturn);
    echo 'oProfile.Saving() ; ';
}
Example #6
0
 public static function GetLvAccess($cFileLoc, $lCek = true)
 {
     $cMd5 = GetSession("cSession_SCLevelmd5");
     $cLevel = GetSession("cSession_SCLevel");
     if ($lCek) {
         $cFileLoc = str_replace("./pages/", "", GetLocationFile($cFileLoc));
     }
     $vaReturn = array("lMaker" => false, "lChecker" => false, "lSigner" => false);
     if ($cLevel == "0000") {
         $vaReturn = array("lMaker" => false, "lChecker" => false, "lSigner" => true);
     } else {
         if (strpos($cMd5, md5($cFileLoc . ".index.1")) > -1) {
             $vaReturn['lMaker'] = true;
         }
         if (strpos($cMd5, md5($cFileLoc . ".index.2")) > -1) {
             $vaReturn['lChecker'] = true;
         }
         if (strpos($cMd5, md5($cFileLoc . ".index.3")) > -1) {
             $vaReturn['lSigner'] = true;
         }
     }
     SaveSession("lFOTO_DELETE", "1");
     return $vaReturn;
 }
Example #7
0
 public function SetMenu()
 {
     //ambil dahulu nama file menunya
     $this->GetFileMenu();
     //get session dahulu
     //$this->cSCMenu 	 = unserialize(GetSession("cSession_SCMenu")) ;
     if (is_file($this->cNamaFileDef) && $this->cSCMenu == "") {
         $vaFile = file($this->cNamaFileDef);
         //load file menu menjadikan array
         if ($this->lWithCase) {
             $this->cSCMenu = '<ul class="sidebar-menu">';
         }
         //awal dari navigation menu
         $nBertingkat = 0;
         foreach ($vaFile as $nKey => $cValue) {
             $cIdentifier = strpos($cValue, "#");
             if ($cIdentifier === false && trim($cValue) !== "" && strpos($cValue, "<?php die('Sapeltu Inc.'); ?>") !== 0 && (strpos($vaFile[$nKey], "Dashboard") === false || strpos($vaFile[$nKey], "index.") === false) && (strpos($vaFile[$nKey], "Lv") === false || strpos($vaFile[$nKey], "index.") === false)) {
                 //jika diawal value terisi # maka tidak dieksekusi
                 //ambil posisi [ karna untuk menentukan sub sub menu
                 $vaMenu = scArray::Menu2Array($cValue);
                 $lValid = strpos($this->cLevel_md5, $vaMenu['cMd5']) > -1 ? true : ($this->cLevel == "0000" ? true : false);
                 $nPos = strpos($cValue, "[");
                 $lTop = $nPos == 0 ? true : false;
                 //userlevel access
                 //untuk menentukan sub menu / menutup sub menu maka harus dicek menu setelah menu ini
                 $lParent = false;
                 $lParentEnd = false;
                 $lBertingkatEnd = false;
                 $nNextKey = $this->CekSelanjutnya($nKey);
                 if (isset($vaFile[$nNextKey])) {
                     $nPosNext = strpos($vaFile[$nNextKey], "[");
                     $lParent = $nPosNext > $nPos ? true : false;
                     $lParentEnd = $nPosNext >= $nPos ? false : true;
                     $lBertingkatEnd = $nPosNext == 0 ? true : false;
                 } else {
                     //$lParentEnd    = true ;
                     $lBertingkatEnd = true;
                 }
                 if ($lValid) {
                     $cDash = GetSession("cSession_Dashboard");
                     if (trim($cDash) == "") {
                         SaveSession("cSession_Dashboard", $vaMenu['cJs']);
                     }
                     $liClass = $lParent ? "class='treeview'" : "";
                     $this->cSCMenu .= '<li ' . $liClass . '>';
                     if ($lParent) {
                         //jika jadi parent maka
                         $this->cSCMenu .= $this->SetDetailMenu($vaMenu, $lTop, $lParent) . '<ul class="treeview-menu">';
                         $nBertingkat++;
                     } else {
                         $this->cSCMenu .= $this->SetDetailMenu($vaMenu) . "</li>";
                     }
                     if ($lParentEnd) {
                         //ditutup parent end
                         //$nBertingkat-- ;
                         //$this->cSCMenu .= "</ul></li>" ;
                         while ($nBertingkat > $nPosNext) {
                             $nBertingkat--;
                             $this->cSCMenu .= "</ul></li>";
                         }
                     }
                 }
                 if ($nBertingkat > 0 && $lBertingkatEnd) {
                     while ($nBertingkat > 0) {
                         $nBertingkat--;
                         $this->cSCMenu .= "</ul></li>";
                     }
                 }
             }
         }
         if ($this->lWithCase) {
             $this->cSCMenu .= '</ul>';
         }
         //penutup dari navigation menu
         SaveSession("cSession_SCMenu", serialize($this->cSCMenu));
     }
     echo $this->cSCMenu;
 }
Example #8
0
function SCDefine($cLocDev = '')
{
    $cFileConnect = "./sapeltucore/sc.config.ini";
    if ($cLocDev == "") {
        if (!is_file($cFileConnect)) {
            $cFileConnect = "./system/sc.config.ini";
        }
    } else {
        $cFileConnect = $cLocDev . "system/sc.config.ini";
    }
    if (is_file($cFileConnect)) {
        $vaFile = file($cFileConnect);
        foreach ($vaFile as $cKey => $cValue) {
            if (strpos($cValue, "#") != 0 || strpos($cValue, "#") == false) {
                $vaValue = explode("=", trim($cValue));
                $cKeyye = trim($vaValue[0]);
                $cVal = trim($vaValue[1]);
                SaveSession("SYS." . $cKeyye, $cVal);
            }
        }
    }
}
Example #9
0
function InitRestore($va)
{
    global $scDb;
    $cFile = GetSession("cRestore_DB");
    $cDirTmp = "./tmp/db_restore/folder/";
    if (!is_dir($cDirTmp)) {
        mkdir($cDirTmp, 0777);
    } else {
        delDir($cDirTmp);
        mkdir($cDirTmp, 0777);
    }
    //open file
    $objZip = new ZipArchive();
    if ($objZip->open($cFile) === true) {
        if (is_dir($cDirTmp)) {
            $objZip->extractTo($cDirTmp);
        }
        $objZip->close();
        $lValid = true;
    } else {
        echo "\$('#cmdRestore').button('reset') ; alert('Error') ; ";
    }
    if ($lValid) {
        //scan file
        $files = array_diff(scandir($cDirTmp), array('.', '..'));
        $vaFile = array();
        $vaFileN = array();
        foreach ($files as $file) {
            $cLoopDir = $cDirTmp . $file;
            if (!is_dir($cLoopDir)) {
                $vaInfo = pathinfo($cLoopDir);
                $vaNameFile = explode("-", $vaInfo['filename']);
                if (!isset($vaFileN[$vaNameFile[0]])) {
                    $vaFileN[$vaNameFile[0]] = "1";
                }
                if ($vaNameFile[0] !== "ddl") {
                    $vaFile[] = $cLoopDir;
                }
            }
        }
        SaveSession("cRestore_File", serialize($vaFile));
        $nFile = count($vaFile) + 1;
        echo 'onProgress_Restore(0,' . $nFile . ') ;';
    }
}
Example #10
0
 public static function GetCabangInduk()
 {
     $cCabang = GetSession("cSession_CabangInduk");
     if ($cCabang == "") {
         $cCabang = scSys::GetConfig("Sys_CabangInduk");
         SaveSession("cSession_CabangInduk", $cCabang);
     }
     return $cCabang;
 }