Ejemplo n.º 1
0
$jsn_layout = JRequest::getCmd('jsn_layout', '', 'GET');
$login = false;
$result_install = false;
$manual = false;
if (!$obj_utils->cURLCheckFunctions() && !$obj_utils->fOPENCheck() && !$obj_utils->fsocketopenCheck()) {
    $manual = true;
}
if ($jsn_layout != '' && $jsn_layout == 'manual') {
    $manual = true;
}
switch ($task) {
    case 'login':
        JRequest::checkToken() or jexit('Invalid Token');
        $username = JRequest::getVar('username', '', 'post', 'username');
        $password = JRequest::getString('password', '', 'post', JREQUEST_ALLOWRAW);
        $login = $obj_sampledata_helper->login($username, $password);
        $canDo = $obj_sampledata_helper->getUserActions();
        if ($login && $canDo->get('core.manage')) {
            if ($type == 'auto' && !$manual) {
                $session->set($login_identifier, true, 'jsntemplatesession');
            } else {
                $result_install = $obj_sampledata_helper->installSampleDataManually();
            }
        }
        break;
    case 'manual':
        JRequest::checkToken() or jexit('Invalid Token');
        if ($session->get($login_identifier, false, 'jsntemplatesession')) {
            $session->set($login_identifier, false, 'jsntemplatesession');
            $result_install = $obj_sampledata_helper->installSampleDataManually();
        }