Ejemplo n.º 1
0
$formLang = new sfc\Form(SSP_Path(), "noTable", "languageform");
$formLang->tplf = "testDatatypeLanguage.tpl";
$formLang->formSubmitVar = 'testLanguagechange';
$formLang->fe('select', 'language', 'Language', Protect::$tranlator->getLanguages());
$formLang->fep('deflt = ' . $session->lang);
$formLang->fe('check', 'localError', 'Errors local to fields', array(0, 1));
$formLang->fep('deflt = ' . $errorLocal);
if ($formLang->processForm($_POST)) {
    $session->lang = $formLang->getField('language');
    if ($formLang->getField('localError') == 1) {
        $errorLocal = true;
    } else {
        $errorLocal = false;
    }
    session_write_close();
    SSP_Divert(SSP_Path());
} else {
    $setLanguage = $formLang->create();
}
$form = new sfc\Form("testcheckData.php", "TestSaveTable", "testdataform");
$form->tplf = "testCheckData_" . $session->lang . ".tpl";
$form->tda('lang', $session->lang);
$form->tda('setLanguage', $setLanguage);
if ($errorLocal) {
    $form->tda('localErrors', 1);
}
$form->errorsLocal = $errorLocal;
$form->errorAutoFormDisplay = false;
$form->fe("text", "textType", "Text input", ">");
$form->fe("text", "passwordType", "Password input", ">");
$form->fep("dataType=password");
Ejemplo n.º 2
0
*   as published by the Open Source Initiative.
*
*   SSP 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
*   The MIT License (MIT) for more details.
*
*   Revision:	a
*   Rev. Date	10/04/2009
*   Descrip:	Created.
*
*   Revision:	b
*   Rev. Date	18/01/2016
*   Descrip:	Composer implemented.
*/
namespace w34u\ssp;

die;
require 'includeheader.php';
$session = new Protect("admin");
$url = "http://www.localdomain.com/sspadmin/sspapi.php";
$cookieJar = $SSP_Config->cookieJarPath . "jar_" . $session->sessionToken . ".txt";
$api = new API_interface($SSP_Config->apiEncryptionKey, $url, $cookieJar);
$api->mirror = true;
$token = $api->sendRemoteLoginSetup("admin", $session->sessionToken, "admin", $_SERVER['REMOTE_ADDR']);
if ($api->error) {
    echo "Error " . $api->errorString;
} elseif ($token) {
    $path = "http://www.remoteDomain.com/sspadmin/index.php?remoteLoginToken=" . $token;
    SSP_Divert($path);
}
Ejemplo n.º 3
0
 /**
  * check for maintenance mode
  */
 private function maintenanceMode()
 {
     if ($this->cfg->siteInMaintenanceMode) {
         $siteMaintenenceMode = true;
         foreach ($this->cfg->siteInMaintenanceOverrideIps as $ipNumber => $name) {
             if (SSP_paddIp($ipNumber) == SSP_paddIp($_SERVER["REMOTE_ADDR"])) {
                 $siteMaintenenceMode = false;
                 break;
             }
         }
         if ($siteMaintenenceMode) {
             SSP_Divert($this->cfg->siteRoot . $this->cfg->siteInMaintenanceScreen);
         }
     }
 }
Ejemplo n.º 4
0
 function autoLogin($userTable)
 {
     // routine used in slave site to login remote user
     if (isset($_GET["remoteLoginToken"])) {
         $where = array("id" => $_GET["remoteLoginToken"], "userIp" => $_SERVER['REMOTE_ADDR']);
         $remoteLoginRecord = $this->db->get($this->sessionStatusTable, $where, "SSP Protect: gettting auto login record");
         if ($remoteLoginRecord) {
             $where = array("UserName" => $remoteLoginRecord->userName);
             $userLoginInfo = $this->db->get($userTable, $where, "SSP Protect: getting user login information");
             // create login record
             $login = new Logon($this, "", false, true);
             $login->logonCheck($userLoginInfo);
             session_write_close();
             SSP_Divert(SSP_Path());
         }
     }
 }
Ejemplo n.º 5
0
 /**
  * creates a template for admin page displays
  * @param array $contentMain the pages content
  * @param string $tpl alternative template name
  * @param bool $createMenu create the main menu
  * @param bool $suppressLangSelect - suppress the language selection dropdown
  * @return Template main template
  */
 function tpl($contentMain, $tpl = "", $createMenu = true, $suppressLangSelect = false)
 {
     // default to the main template if not other template not supplied
     if ($tpl != "") {
         $template = $tpl;
     } else {
         $template = $this->template;
     }
     // if the content suppied is just a string use it as the page title
     if (is_string($contentMain)) {
         $temp = $contentMain;
         $contentMain = array();
         $contentMain["title"] = $temp;
     }
     // build the page title from the supplied segments
     if (count($this->pageTitleSegments)) {
         if ($this->session->isTranslate()) {
             foreach ($this->pageTitleSegments as $key => $titlePart) {
                 $this->pageTitleSegments[$key] = $this->session->t($titlePart);
             }
         }
         $contentMain["title"] = $this->session->t($this->cfg->siteName) . $this->pageTitleSeperator . implode($this->pageTitleSeperator, $this->pageTitleSegments);
     } else {
         $contentMain["title"] = $this->session->t($this->cfg->siteName);
     }
     // add paths to various useful areas
     $contentMain["pathSite"] = $this->cfg->pathSite;
     $contentMain["pathAdmin"] = $this->cfg->adminDir;
     // create the language selection
     if ($this->cfg->translate and !$suppressLangSelect) {
         $formTemplate = array('<form action="{formAction}" method="post" id="languageSelectionform">', '{languageDropdown}', '{formHidden}', '</form>');
         $form = new sfc\Form(SSP_Path(true), 'notable', 'languageSelect');
         $form->translateDisable = true;
         $form->checkToken = false;
         $form->errorAutoFormDisplay = false;
         $form->formSubmitVar = 'languageSelectionformToken';
         $form->tplf = new Template("", $formTemplate);
         $languages = $this->session->getLanguages();
         $dropdownInformation = array();
         foreach ($languages as $lang => $languageInfo) {
             $dropdownInformation[$lang] = array('text' => $languageInfo['description'], 'dir' => $languageInfo['dir'], 'class' => 'lang_' . $lang, 'style' => 'background-image: url(/sspadmin/images/flag_' . $lang . '.png);');
         }
         $form->fe('select', 'languageDropdown', '', $dropdownInformation);
         $form->fep('deflt = ' . Protect::$tranlator->getLanguage());
         $form->setParam('script', 'onChange="this.form.submit()"');
         if ($form->processForm($_POST)) {
             if (!$form->error) {
                 $this->session->lang = $form->getField('languageDropdown');
                 session_write_close();
                 //echo 'code '. $_SESSION['SSP_currentLanguageCode'];
                 SSP_Divert(SSP_Path(true));
             }
         }
         $contentMain['languageSelectForm'] = $form->create();
     }
     if ($createMenu) {
         // generate main menu
         // highlight a main menu item
         if (isset($contentMain["mainSection"])) {
             $section = $contentMain["mainSection"];
         } else {
             $section = "";
         }
         $url = $_SERVER['REQUEST_URI'];
         $menu = new MenuGen();
         $menu->add($this->cfg->adminDir . 'useradmin/info/' . $this->session->userId, $this->session->t("User Details"), strpos($url, "useradmin") !== false);
         $menu->add($this->cfg->adminDir . 'adminusercreation', $this->session->t("New User"), strpos($url, "adminusercreation") !== false);
         $menu->add($this->cfg->userLister, $this->session->t("List Users"), $url === "/sspadmin/" or $url === '/sspadmin/filterChange' or $url === '/sspadmin/filterNormal' or $url === '/sspadmin/filterAdminPending');
         $menu->add($this->cfg->siteRoot, $this->session->t("Home"));
         $menu->add($this->cfg->logoffScript, $this->session->t("Log off"));
         $contentMain["mainMenu"] = $menu->cMenu();
     } else {
         $contentMain["mainMenu"] = "";
     }
     if (!isset($contentMain["menu"])) {
         $contentMain["menu"] = "";
     }
     if ($this->cfg->enableSetup === true) {
         $contentMain['showDisableSetupText'] = true;
     }
     $tpl = new Template($contentMain, $template, false);
     return $tpl;
 }
Ejemplo n.º 6
0
 /**
  * Delete a user
  * @param type $userId
  * @return string
  */
 public function deleteUser($userId)
 {
     // check for valid user id, ie. hex
     $check = new \w34u\ssp\CheckData();
     if ($check->check('hex', $userId) !== 0) {
         SSP_Divert($this->cfg->totalAdminScript);
     }
     // delete a user, not the current
     if (strcasecmp($userId, $this->session->userId) != 0) {
         if (isset($_POST["deleteUser"])) {
             $where = array("UserId" => $userId);
             $this->db->delete($this->cfg->userMiscTable, $where, "SSP Admin: deleting user misc data");
             $this->db->delete($this->cfg->userTable, $where, "SSP Admin: deleting user login data");
             SSP_Divert($this->cfg->totalAdminScript);
         } elseif (isset($_POST["preserveUser"])) {
             SSP_Divert($this->cfg->totalAdminScript);
         } else {
             // prompt to delete user
             $where = array("UserId" => $userId);
             $user = $this->db->get($this->cfg->userMiscTable, $where, "SSP Admin: Getting data to prompt for user delete");
             if ($user) {
                 $content = get_object_vars($user);
                 $content["path"] = SSP_Path();
                 $page = new Template($content, "userListerDeletePrompt.tpl", false);
                 $mainContent = array();
                 $mainContent["title"] = " - delete user " . $user->FirstName . " " . $user->FamilyName;
                 $mainContent["content"] = $page->output();
                 $tpl = $this->tpl($mainContent);
                 return $tpl->output();
             } else {
                 SSP_Divert($this->cfg->totalAdminScript);
             }
         }
     }
 }
Ejemplo n.º 7
0
 /**
  * Divert back to page login from which login was invoked
  * optionally display login success page.
  * @param string/bool $userId - users id
  */
 private function loginSuccess($userId = false)
 {
     $returnPage = $this->session->getReturnPage();
     if (trim($returnPage) != "") {
         // gotto page that diverted to login
         $returnPath = $returnPage;
     } else {
         // got back to site root
         $returnPath = $this->cfg->siteRoot;
     }
     if ($userId) {
         $logonSuccessContent = $this->loginSuccessDisplay($userId, $returnPath);
     } else {
         $logonSuccessContent = '';
     }
     SSP_Divert($returnPath, $logonSuccessContent, "logonsuccess.tpl", $this->cfg->autoReturnAfterLogin);
 }