Exemplo n.º 1
0
    public function showNavBar()
    {
        if (loadvar(POST_PARAM_AJAX_LOAD) == AJAX_LOAD) {
            return;
        }
        $testActive = '';
        $reportedActive = '';
        if (!isset($_SESSION['LASTPAGE'])) {
            $_SESSION['LASTPAGE'] = 'tester.home';
        }
        if (strpos($_SESSION['LASTPAGE'], 'tester.tools.test') === 0) {
            $testActive = ' active';
        } else {
            if (strpos($_SESSION['LASTPAGE'], 'tester.tools.reported') === 0) {
                $testActive = '';
                $reportedActive = ' active';
            }
        }
        $returnStr = '
      <!-- Fixed navbar -->
      <div id="mainnavbar" class="navbar navbar-default navbar-fixed-top">
        <div class="container">
          <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
              <span class="icon-bar"></span>
              <span class="icon-bar"></span>
              <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="' . setSessionParams(array('page' => 'tester.home')) . '">' . Language::messageSMSTitle() . '</a>
          </div>
          <div class="collapse navbar-collapse">
            <ul class="nav navbar-nav">';
        $returnStr .= '<li class="' . $testActive . '">' . setSessionParamsHref(array('page' => 'tester.tools.test'), Language::linkTest()) . '</li>';
        $returnStr .= '<li class="' . $reportedActive . '">' . setSessionParamsHref(array('page' => 'tester.tools.reported'), Language::linkReported()) . '</li>';
        $returnStr .= '</ul>';
        $user = new User($_SESSION['URID']);
        $returnStr .= '<ul class="nav navbar-nav navbar-right">
            <li class="dropdown">
              <a data-hover="dropdown" class="dropdown-toggle" data-toggle="dropdown">' . $user->getUsername() . ' <b class="caret"></b></a>
                 <ul class="dropdown-menu">';
        $returnStr .= '<li><a ' . POST_PARAM_NOAJAX . '=' . NOAJAX . ' href="index.php?rs=1&se=2"><span class="glyphicon glyphicon-log-out"></span> ' . Language::linkLogout() . '</a></li>
                 </ul>
             </li>
            </ul>';
        $returnStr .= '
          </div><!--/.nav-collapse -->
        </div>
      </div>
';
        $returnStr .= "<div id='content'>";
        return $returnStr;
    }
Exemplo n.º 2
0
 function checkSMSAccess()
 {
     global $db;
     $username = loadvar('username');
     $password = loadvar('password');
     $result = $db->selectQuery('select count(*), urid from ' . Config::dbSurvey() . '_users where username=\'' . prepareDatabaseString($username) . '\' and status=1 and aes_decrypt(password, \'' . Config::smsPasswordKey() . '\') = \'' . prepareDatabaseString($password) . '\'');
     //echo 'select count(*), urid from ' . Config::dbSurvey() . '_users where username="******" and status=1 and aes_decrypt(password, "' . Config::smsPasswordKey() . '") = "' . prepareDatabaseString($password) . '"';
     $row = $db->getRow($result);
     if ($row[0] == 1) {
         $_SESSION['URID'] = $row['urid'];
         return true;
     } else {
         $logactions = new LogActions();
         $logactions->addAction('', '', "loginwrong", USCIC_SMS);
     }
     return false;
 }
Exemplo n.º 3
0
 function showUsersList($users)
 {
     $returnStr = '';
     $returnStr .= "<form id=refreshform method=post>";
     $returnStr .= '<input type=hidden name=page value="sysadmin.users">';
     $returnStr .= '<input type=hidden name="usertype" id="usertype_hidden">';
     $returnStr .= "</form>";
     $usertypes = array(-1 => Language::labelAll(), USER_INTERVIEWER => Language::labelInterviewer(), USER_NURSE => Language::labelNurse(), USER_SUPERVISOR => Language::labelSupervisor(), USER_TRANSLATOR => Language::labelTranslator(), USER_RESEARCHER => Language::labelResearcher(), USER_SYSADMIN => Language::labelSysadmin(), USER_TESTER => Language::labelTester());
     $usertype = loadvar('usertype', USER_INTERVIEWER);
     $returnStr .= Language::labelUserFilter() . $this->displaySelectFromArray($usertypes, $usertype, 'usertype');
     $returnStr .= "<script type='text/javascript'>";
     $returnStr .= '$( document ).ready(function() {
                                             $("#usertype").change(function (e) {
                                                 $("#usertype_hidden").val(this.value);                                                     
                                                 $("#refreshform").submit();
                                             });
                                             })';
     $returnStr .= "</script>";
     if (sizeof($users) > 0) {
         $returnStr .= $this->displayDataTablesScripts(array("colvis", "rowreorder"));
         $returnStr .= "<script type='text/javascript'>\n                        \$(document).ready(function(){\n                            \$('#usertable').dataTable(\n                                {\n                                    \"iDisplayLength\": " . sizeof($users) . ",\n                                    dom: 'C<\"clear\">lfrtip',\n                                    paginate: false,\n                                    colVis: {\n                                        activate: \"mouseover\",\n                                        exclude: [ 0 ]\n                                    }\n                                }    \n                             );                                         \n                       });</script>\n                        ";
         //
         $returnStr .= $this->displayPopoverScript();
         $returnStr .= '<br/><br/><table id="usertable" class="table table-striped table-bordered pre-scrollable table-condensed table-hover">';
         $returnStr .= '<thead><tr><th></td><th>' . Language::labelUserUserName() . '</th><th>' . Language::labelUserUserNameName() . '</th><th>' . Language::labelUserUserType() . '</th></tr></thead>';
         $returnStr .= '<tbody>';
         $usertypes = array(USER_INTERVIEWER => Language::labelInterviewer(), USER_NURSE => Language::labelNurse(), USER_SUPERVISOR => Language::labelSupervisor(), USER_TRANSLATOR => Language::labelTranslator(), USER_RESEARCHER => Language::labelResearcher(), USER_SYSADMIN => Language::labelSysadmin(), USER_TESTER => Language::labelTester());
         foreach ($users as $user) {
             $returnStr .= '<tr><td>';
             $content = '<a id="' . $user->getUrid() . '_edit" title="' . Language::linkEditTooltip() . '" href="' . setSessionParams(array('page' => 'sysadmin.users.edituser', 'urid' => $user->getUrid())) . '"><span class="glyphicon glyphicon-edit"></span></a>';
             $content .= '&nbsp;&nbsp;<a id="' . $user->getUrid() . '_copy" title="' . Language::linkCopyTooltip() . '" href="' . setSessionParams(array('page' => 'sysadmin.users.copyuser', 'urid' => $user->getUrid())) . '" ' . confirmAction(language::messageCopyUser($user->getName()), 'COPY') . '><span class="glyphicon glyphicon-copyright-mark"></span></a>';
             $content .= '&nbsp;&nbsp;<a id="' . $user->getUrid() . '_remove" title="' . Language::linkRemoveTooltip() . '" href="' . setSessionParams(array('page' => 'sysadmin.users.removeuser', 'urid' => $user->getUrid())) . '" ' . confirmAction(language::messageRemoveUser($user->getName()), 'REMOVE') . '><span class="glyphicon glyphicon-remove"></span></a>';
             $returnStr .= '<a rel="popover" id="' . $user->getUrid() . '_popover" data-placement="right" data-html="true" data-toggle="popover" data-trigger="hover" href="' . setSessionParams(array('page' => 'sysadmin.users.edituser', 'urid' => $user->getUrid())) . '"><span class="glyphicon glyphicon-hand-right"></span></a>';
             $returnStr .= '<td>' . $user->getUsername() . '</td><td>' . $user->getName() . '</td>';
             $returnStr .= '<td>' . $usertypes[$user->getUserType()] . '</td></tr>';
             $returnStr .= $this->displayPopover("#" . $user->getUrid() . '_popover', $content);
         }
         $returnStr .= '</tbody>';
         $returnStr .= '</table><br/><br/>';
     } else {
         $returnStr .= "<br/><br/>" . $this->displayWarning(Language::messageNoUsersYet());
     }
     return $returnStr;
 }
Exemplo n.º 4
0
 function generateCases()
 {
     $suid = loadvar("suid");
     if ($suid == "") {
         $suid = 1;
     }
     $seid = loadvar("seid");
     if ($seid == "") {
         $seid = 1;
     }
     $version = 1;
     setSurvey($suid);
     setSurveyLanguage(loadvar(POST_PARAM_LANGUAGE), true);
     setSurveyMode(loadvar(POST_PARAM_MODE), true);
     setSurveyVersion($version);
     /* generate cases */
     $number = loadvar("number");
     for ($i = 0; $i < $number; $i++) {
         //set_time_limit(0);
         $primkey = generateRandomPrimkey();
         $this->generateCase($suid, $primkey, session_id(), $version, $seid);
         //exit;
     }
 }
Exemplo n.º 5
0
     foreach ($mods as $m) {
         $user->setLanguages($this->addtosuid, $m, $survey->getAllowedLanguages($m));
     }
     $user->saveChanges();
     // return result
     return "";
 }
 function importMMIC()
 {
     set_time_limit(0);
     $this->importdb = new Database();
     $server = loadvar(SETTING_IMPORT_SERVER);
     if ($server == "") {
         $server = "localhost";
     }
     if ($this->importdb->connect($server, loadvar(SETTING_IMPORT_DATABASE), loadvar(SETTING_IMPORT_USER), loadvar(SETTING_IMPORT_PASSWORD)) == false) {
         $display = new Display();
         return $display->displayError(Language::messageToolsImportDbFailure());
     }
     $this->sourcetable = loadvar(SETTING_IMPORT_TABLE);
     // add
     if (loadvar(SETTING_IMPORT_AS) == IMPORT_TARGET_ADD) {
         $surveys = new Surveys();
         $this->addtosuid = $surveys->getMaximumSuid();
     } else {
         if (loadvar(SETTING_IMPORT_AS) == IMPORT_TARGET_REPLACE) {
             $this->addtosuid = 0;
             /* delete existing content */
             $tables = Common::surveyTables();
             foreach ($tables as $table) {
                 $query = "delete from " . Config::dbSurvey() . $table;
                 $this->db->executeQuery($query);
             }
             /* delete existing data */
             $tables = Common::surveyDataTables();
             foreach ($tables as $table) {
                 if ($table == "_actions") {
                     $query = "delete from " . Config::dbSurvey() . $table . " where suid != ''";
                 } else {
                     $query = "delete from " . Config::dbSurvey() . $table;
                 }
                 $this->db->executeQuery($query);
             }
             /* delete test data */
             $tables = Common::surveyTestDataTables();
             foreach ($tables as $table) {
                 if ($table == "_actions") {
                     $query = "delete from " . Config::dbSurvey() . $table . " where suid != ''";
                 } else {
                     $query = "delete from " . Config::dbSurvey() . $table;
                 }
                 $this->db->executeQuery($query);
             }
Exemplo n.º 6
0
}
/* survey entry */
if ($_SESSION['SYSTEM_ENTRY'] != USCIC_SMS) {
    $_SESSION['PARAMETER_RETRIEVAL'] = PARAMETER_SURVEY_RETRIEVAL;
    $engine = null;
    // global $engine object
} else {
    $_SESSION['PARAMETER_RETRIEVAL'] = PARAMETER_ADMIN_RETRIEVAL;
    $l = getSMSLanguage();
    if (file_exists("language/language" . getSMSLanguagePostFix($l) . ".php")) {
        require_once 'language_' . getSMSLanguagePostFix($l) . '.php';
    } else {
        require_once 'language_en.php';
        // fall back on english language  file
    }
}
if (loadvar(POST_PARAM_SMS_AJAX) == SMS_AJAX_CALL) {
    // sms ajax call
    require_once 'smsajax.php';
    $ajax = new SmsAjax();
    echo $ajax->getPage(loadvar('p'));
} else {
    // handle action
    $action = new Action($sesid);
    echo $action->getAction();
    // clear session locking (if not already done by earlier script exit)
    doExit();
}
?>

Exemplo n.º 7
0
 function showSearchRes()
 {
     if (dbConfig::defaultPanel() == PANEL_HOUSEHOLD) {
         //show household level
         $households = new Households();
         $households = $households->getHouseholdsByUserSearch($this->user, loadvar('searchterm'));
         $displaySupervisor = new DisplaySupervisor();
         return $displaySupervisor->showSearchRes($households);
     } else {
         $respondents = new Respondents();
         $respondents = $respondents->getRespondentsByUserSearch($this->user, loadvar('searchterm'));
         $displaySupervisor = new DisplaySupervisor();
         return $displaySupervisor->showSearchRes($respondents);
     }
 }
Exemplo n.º 8
0
 public function showLoginDirect($primkey, $message)
 {
     global $survey, $engine;
     require_once "display/templates/displayquestion_" . $survey->getTemplate() . ".php";
     $returnStr = $this->showHeader($survey->getTitle(), '<link href="bootstrap/css/sticky-footer-navbar.min.css" rel="stylesheet">');
     if (true) {
         if ($primkey != '') {
             $returnStr .= '<form method="post" id="startform">';
             $returnStr .= '<input type=hidden name="' . POST_PARAM_PRIMKEY . '" value="' . decryptC($primkey, Config::directLoginKey()) . '">';
             $returnStr .= '<input type=hidden name="' . POST_PARAM_SUID . '" value="' . $survey->getSuid() . '">';
             $returnStr .= '<input type=hidden name="' . POST_PARAM_LANGUAGE . '" value="' . loadvar(POST_PARAM_LANGUAGE) . '">';
             $returnStr .= '<input type=hidden name="' . POST_PARAM_PRELOAD . '" value="' . loadvar(POST_PARAM_PRELOAD) . '">';
             $returnStr .= '<input type=hidden name="' . POST_PARAM_MODE . '" value="' . loadvar(POST_PARAM_MODE) . '">';
             $returnStr .= '<input type=hidden name="' . POST_PARAM_URID . '" value="' . loadvar(POST_PARAM_URID) . '">';
             if (loadvar(POST_PARAM_URID) != '') {
                 $_SESSION['URID'] = loadvar(POST_PARAM_URID);
             }
             $returnStr .= '<div style="display: none;"><input type=submit></div>';
             $returnStr .= '</form>';
             $returnStr .= '<script>';
             $returnStr .= '$(document).ready(function(){ $("#startform").submit(); }); ';
             $returnStr .= '</script>';
         } else {
             $returnStr .= '<div id="wrap">';
             $returnStr .= '<div class="container"><p>';
             $engine = loadEngine($survey->getSuid(), $primkey, '', getSurveyVersion(), getBaseSectionSeid($survey->getSuid()));
             $do = $engine->getDisplayObject();
             $returnStr .= $do->showDirectAccessOnlySurvey();
             //$returnStr .= Language::errorDirectLogin();
         }
     } else {
         $returnStr .= '<div id="wrap">';
         $returnStr .= '<div class="container"><p>';
         //$returnStr .= Language::errorDirectLogin();
         $engine = loadEngine($survey->getSuid(), $primkey, '', getSurveyVersion(), getBaseSectionSeid($survey->getSuid()));
         $do = $engine->getDisplayObject();
         $returnStr .= $do->showDirectAccessOnlySurvey();
     }
     /* footer */
     $returnStr .= $this->showFooter();
     return $returnStr;
 }
Exemplo n.º 9
0
 function jumpRes()
 {
     global $db;
     $suid = getFromSessionParams('jumpsuid');
     $prim = getFromSessionParams('jumpprimkey');
     $jumpto = loadvar("jumpto");
     //echo $suid . '----' . $prim . '----' . $jumpto;
     $query = "delete from " . Config::dbSurveyData() . "_states where suid=" . $suid . " and primkey='" . $prim . "' and stateid > " . $jumpto;
     $db->executeQuery($query);
     $returnStr = "<html><head></head><body>";
     $returnStr .= "<script type='text/javascript'>\n    window.opener.location.reload();\n    window.close();\n</script>";
     $returnStr .= '</body></html';
     //container and wrap
     echo $returnStr;
 }
Exemplo n.º 10
0
 function captureScreenshot()
 {
     global $db;
     $l = $this->getParam(POST_PARAM_LANGUAGE);
     $m = $this->getParam(POST_PARAM_MODE);
     $v = $this->getParam(POST_PARAM_VERSION);
     $result = urldecode(loadvar(POST_PARAM_SCREENSHOT));
     $stateid = $this->getParam(POST_PARAM_STATEID);
     $primkey = $this->getParam(POST_PARAM_PRIMKEY);
     $suid = $this->getParam(POST_PARAM_SUID);
     $screen = gzcompress($result, 9);
     if ($stateid == "") {
         $stateid = 1;
     }
     $bp = new BindParam();
     $scid = null;
     $bp->add(MYSQL_BINDING_INTEGER, $scid);
     $bp->add(MYSQL_BINDING_INTEGER, $suid);
     $bp->add(MYSQL_BINDING_STRING, $primkey);
     $bp->add(MYSQL_BINDING_INTEGER, $stateid);
     $bp->add(MYSQL_BINDING_STRING, $screen);
     $bp->add(MYSQL_BINDING_INTEGER, $m);
     $bp->add(MYSQL_BINDING_INTEGER, $l);
     $bp->add(MYSQL_BINDING_INTEGER, $v);
     $key = $this->survey->getDataEncryptionKeyDirectly($m, $l, $this->getParam(POST_PARAM_DEFAULT_MODE), $this->getParam(POST_PARAM_DEFAULT_LANGUAGE));
     if ($key == "") {
         $query = "insert into " . Config::dbSurveyData() . "_screendumps(scdid, suid, primkey, stateid, screen, mode, language, version) values (?,?,?,?,?,?,?,?)";
     } else {
         $query = "insert into " . Config::dbSurveyData() . "_screendumps(scdid, suid, primkey, stateid, screen, mode, language, version) values (?,?,?,?,aes_encrypt(?, '" . $key . "'),?,?,?)";
     }
     //echo $query;
     //print_r($bp->get());
     $db->executeBoundQuery($query, $bp->get());
     exit;
 }
Exemplo n.º 11
0
 function SMSEntry()
 {
     // check for return from tester, in which case we need to switch back to normal mode to look in the correct actions table
     if (isset($_SESSION[SURVEY_EXECUTION_MODE]) && $_SESSION[SURVEY_EXECUTION_MODE] == SURVEY_EXECUTION_MODE_TEST) {
         $_SESSION[SURVEY_EXECUTION_MODE] = SURVEY_EXECUTION_MODE_NORMAL;
     }
     $logactions = new LogActions();
     $nosessionactions = $logactions->getNumberOfActionsBySession($this->phpid, USCIC_SMS);
     //echo 'ytytytyt';
     //echo ' [[[[' . $this->phpid;
     if ($nosessionactions == 0) {
         //no entry yet: ask for prim_key!
         $logactions->addAction('', '', "loginstart", USCIC_SMS);
         $login = new Login($this->phpid);
         return $login->getSMSLoginScreen();
     } else {
         //echo ']]]]]';
         $loggedin = $logactions->getLoggedInSMSSession($this->phpid);
         if ($loggedin["count"] == 0) {
             //no prim_key (=username in sms) assigned to this sessionid. Assign if given (and check for pwd etc??)!
             $username = loadvar('username');
             $_SESSION['username'] = $username;
             if ($username != '' && loadvar('password') != '') {
                 //check username!!
                 $login = new Login($this->phpid);
                 if ($login->checkSMSAccess()) {
                     $urid = $_SESSION['URID'];
                     $logactions->addAction('', $urid, "loggedin", USCIC_SMS);
                     $sms = new SMS($urid, $this->phpid);
                     return $sms->getPage();
                 } else {
                     // incorrect login..start new session
                     endSession();
                     session_start();
                     session_regenerate_id(true);
                     $logactions->addAction('', '', "loginempty", USCIC_SMS);
                     $login = new Login(session_id());
                     return $login->getSMSLoginScreen(Language::messageCheckUsernamePassword());
                 }
             } else {
                 $logactions->addAction('', '', "loginempty", USCIC_SMS);
                 $login = new Login($this->phpid);
                 return $login->getSMSLoginScreen(Language::messageEnterUsernamePassword());
             }
         } else {
             //continue with the sms! EXTRA CHECK!!!!
             $_SESSION['URID'] = $loggedin["urid"];
             if (isset($_SESSION['URID'])) {
                 $sms = new SMS($_SESSION['URID'], $this->phpid);
                 return $sms->getPage();
             } else {
                 //something went wrong.. no urid..start new session
                 //echo 'ohno';
                 endSession();
                 session_start();
                 session_regenerate_id(true);
                 $logactions->addAction('', '', "loginempty", USCIC_SMS);
                 $login = new Login(session_id());
                 return $login->getSMSLoginScreen(Language::messageCheckUsernamePassword());
             }
         }
     }
 }
Exemplo n.º 12
0
 You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 ------------------------------------------------------------------------
*/
error_reporting(E_ALL);
ini_set("display_errors", 1);
set_include_path(dirname(getcwd()));
require_once 'constants.php';
require_once 'functions.php';
require_once 'dbConfig.php';
require_once 'config.php';
require_once 'database.php';
require_once 'communication.php';
date_default_timezone_set(Config::timezone());
$p = loadvar('p');
$urid = loadvar('urid');
$db = new Database();
$communication = new Communication();
$returnValue = 'error';
if ($p == 'upload') {
    //upload data!
    $communication->storeUpload($_POST['query'], $urid);
    $communication->importTable($_POST['query']);
    $returnValue = 'ok';
} elseif ($p == 'updateavailable') {
    //is there an update available?
    $returnValue = 'no';
    if (sizeof($communication->getUserQueries($urid)) > 0) {
        $returnValue = 'yes';
    }
    if (sizeof($communication->getUserScripts($urid)) > 0) {
Exemplo n.º 13
0
*/
require_once "../constants.php";
require_once "../functions.php";
require_once "../dbConfig.php";
$_SESSION['SYSTEM_ENTRY'] = USCIC_SMS;
$loaded = dbConfig::load("../conf.php");
require_once "../config.php";
require_once "../globals.php";
require_once "../user.php";
require_once 'reportissue.php';
require_once 'watchwindow.php';
require_once 'jumpback.php';
require_once 'updater.php';
require_once "../display/templates/displayquestion_" . getSurveyTemplate() . ".php";
if (loadvar('r') != '') {
    getSessionParamsPost(loadvar('r'));
}
// include language
$l = getSMSLanguage();
if (file_exists("language/language" . getSMSLanguagePostFix($l) . ".php")) {
    require_once 'language_' . getSMSLanguagePostFix($l) . '.php';
} else {
    require_once 'language_en.php';
    // fall back on english language  file
}
$_SESSION['SYSTEM_ENTRY'] = USCIC_SURVEY;
// switch back to survey
$page = getFromSessionParams('testpage');
if (getFromSessionParams('type') != "2") {
    $_SESSION[SURVEY_EXECUTION_MODE] = SURVEY_EXECUTION_MODE_TEST;
}
Exemplo n.º 14
0
    function showSetupRes()
    {
        /* write conf.php file */
        if (is_writable('conf.php') == false) {
            $message = '<div class="alert alert-danger">' . Language::installWarning() . '</div>';
            return $this->getContent("setup", $message);
        } else {
            // TODO: FINISH ADDING POST SETTINGS TO THE CONFIG, ADD SAMPLE SETTINGS AND ANYTHING ELSE MISSING FROM THE SETUP WIZARD
            /* test db */
            $db = new Database();
            if ($db->connect(loadvar("databaseserver"), loadvar("databasename"), loadvar("databaseuser"), loadvar("databasepassword")) == false) {
                //no connection with DB.. Errormessage!
                $message = '<div class="alert alert-danger">' . Language::installWarningDatabase() . '</div>';
                return $this->getContent("setup", $message);
            } else {
                $file = fopen("conf.php", "w");
                $str = '<?php

$configuration = array(
    CONFIGURATION_DATABASE => array(
        CONFIGURATION_DATABASE_SERVER => "' . loadvar("databaseserver") . '",
        CONFIGURATION_DATABASE_NAME => "' . loadvar("databasename") . '",
        CONFIGURATION_DATABASE_TYPE => "1",
        CONFIGURATION_DATABASE_USER => "' . loadvar("databaseuser") . '",
        CONFIGURATION_DATABASE_PASSWORD => "' . loadvar("databasepassword") . '",
        CONFIGURATION_DATABASE_SURVEY => "' . loadvar("databasetablename") . '"
    ),
    CONFIGURATION_GENERAL => array(
        CONFIGURATION_GENERAL_STARTUP => "1",
        CONFIGURATION_GENERAL_DEVICE => "1"
    ),
    CONFIGURATION_SAMPLE => array(
        CONFIGURATION_SAMPLE_PANEL => "' . loadvar("sampletype") . '",
        CONFIGURATION_SAMPLE_TRACKING => "' . loadvar("sampletracking") . '",
        CONFIGURATION_SAMPLE_INTERVIEWADDRESS => "' . loadvar("sampleinterviewaddress") . '",
        CONFIGURATION_SAMPLE_PROXYCODE => "' . loadvar("sampleproxycode") . '",
        CONFIGURATION_SAMPLE_PROXYCONTACT => "' . loadvar("sampleproxycontact") . '",
        CONFIGURATION_SAMPLE_COMMUNICATION => "' . loadvar("samplecommunication") . '",
        CONFIGURATION_SAMPLE_FILELOCATION => "' . loadvar("samplefilelocation") . '"
    ),
    CONFIGURATION_ENCRYPTION => array(
        CONFIGURATION_ENCRYPTION_DATA => "' . loadvar("encryptiondata") . '",
        CONFIGURATION_ENCRYPTION_LOGINCODES => "' . loadvar("encryptionlogincodes") . '",
        CONFIGURATION_ENCRYPTION_ADMIN => "' . loadvar("encryptionadmin") . '",
        CONFIGURATION_ENCRYPTION_PERSONAL => "' . loadvar("encryptionrespondent") . '",
        CONFIGURATION_ENCRYPTION_REMARK => "' . loadvar("encryptionremarks") . '",
        CONFIGURATION_ENCRYPTION_CONTACTREMARK => "' . loadvar("encryptioncontactremarks") . '",
        CONFIGURATION_ENCRYPTION_CONTACTNAME => "' . loadvar("encryptioncontactnames") . '",
        CONFIGURATION_ENCRYPTION_ACTION_PARAMS => "' . loadvar("encryptionparameters") . '",
        CONFIGURATION_ENCRYPTION_DIRECT => "' . loadvar("encryptiondirect") . '",
        CONFIGURATION_ENCRYPTION_LAB => "' . loadvar("encryptionlab") . '",
        CONFIGURATION_ENCRYPTION_FILE => "' . loadvar("encryptionfile") . '"
    ),
    CONFIGURATION_DATETIME => array(
        CONFIGURATION_DATETIME_TIMEZONE => "' . loadvar("timezone") . '",
        CONFIGURATION_DATETIME_USFORMAT_SMS => "' . loadvar('timeformatsms') . '",
        CONFIGURATION_DATETIME_USFORMAT_SURVEY => "' . loadvar('timeformatsurvey') . '",
        CONFIGURATION_DATETIME_MINUTES_SMS => "' . loadvar('timeminutessms') . '",
        CONFIGURATION_DATETIME_MINUTES_SURVEY => "' . loadvar('timeminutessurvey') . '",
        CONFIGURATION_DATETIME_SECONDS_SMS => "' . loadvar('timesecondssms') . '",
        CONFIGURATION_DATETIME_SECONDS_SURVEY => "' . loadvar('timesecondssurvey') . '"
    ),
    CONFIGURATION_LOGGING => array(
        CONFIGURATION_LOGGING_TIMINGS => "' . loadvar('loggingtimings') . '",
        CONFIGURATION_LOGGING_PARAMS => "' . loadvar('loggingactions') . '",
        CONFIGURATION_LOGGING_ACTIONS => "' . loadvar('loggingactions') . '",
        CONFIGURATION_LOGGING_PARADATA => "' . loadvar('loggingparadata') . '",
        CONFIGURATION_LOGGING_TABSWITCH => "' . loadvar('loggingtabswitch') . '",
        CONFIGURATION_LOGGING_MOUSE => "' . loadvar('loggingmouse') . '"
    ),
    CONFIGURATION_SESSION => array(
        CONFIGURATION_SESSION_WARN => "' . loadvar('sessionwarn') . '",
        CONFIGURATION_SESSION_TIMEOUT => "' . loadvar('sessionduration') . '",
        CONFIGURATION_SESSION_LOGOUT => "' . loadvar('sessionlogout') . '",
        CONFIGURATION_SESSION_REDIRECT => "' . loadvar('sessionredirect') . '",
        CONFIGURATION_SESSION_PING => "' . loadvar('sessionping') . '"
    ),
    CONFIGURATION_PERFORMANCE => array(
        CONFIGURATION_PERFORMANCE_DATA_FROM_STATE => "' . loadvar('performancestate') . '",
        CONFIGURATION_PERFORMANCE_PREPARE_QUERIES => "' . loadvar('performancequeries') . '",
        CONFIGURATION_PERFORMANCE_UNSERIALIZE => "' . loadvar('performanceserialize') . '",
        CONFIGURATION_PERFORMANCE_USE_DATARECORDS => "' . loadvar('performancerecords') . '",
        CONFIGURATION_PERFORMANCE_USE_DYNAMIC_MINIFY => "' . loadvar('performanceminify') . '",
        CONFIGURATION_PERFORMANCE_USE_LOCKING => "' . loadvar('performancelocking') . '",
        CONFIGURATION_PERFORMANCE_USE_TRANSACTIONS => "' . loadvar('performancetransaction') . '"
    )
);
?>';
                fwrite($file, $str);
                fclose($file);
                // create tables
                $fr = file_get_contents(dirname(__FILE__) . "/admin/sql/createtables.sql");
                $str = str_replace("survey1", loadvar("databasetablename"), $fr);
                $db->executeQueries($str);
                $query = "REPLACE INTO `" . loadvar("databasetablename") . "_users` (`urid`, `status`, `name`, `username`, `password`, `usertype`, usersubtype, `sup`, `filter`, `regionfilter`, `testmode`, `communication`, `settings`, `access`, `lastdata`, `ts`) VALUES\n                (1, 1, 'Sysadmin', 'sysadmin', aes_encrypt('sysadmin','" . loadvar("encryptionadmin") . "'), 4, 1, NULL, 1, 0, 0, 2, 0x613a313a7b733a31303a226e6176696e6272656164223b733a313a2231223b7d, NULL, NULL, '2014-04-12 00:20:49');";
                $db->executeQuery($query);
                //echo $query;
                return $this->getContent("finish");
            }
        }
    }
Exemplo n.º 15
0
        $grid = "[]";
    }
    $gridentries = json_decode($grid);
    $currentnumber = $engine->getAnswer("hhmembernumber");
    for ($i = 1; $i <= $currentnumber; $i++) {
        $entry = $gridentries[$i - 1];
        // start at 0!
        $engine->setAnswer("hhmemberchanged[" . $i . ']', $entry->hhmemberchanged);
    }
}
function processGridAdditions()
{
    global $engine;
    $grid = $engine->getAnswer("hhgrid_new");
    if ($grid == "") {
        $grid = "[]";
    }
    $gridentries = json_decode($grid);
    $existingnumber = $engine->getAnswer("hhmembernumber");
    $newnumber = $engine->getAnswer("newhhmembernumber");
    // first time OR more members now
    if (inArray($newnumber, array(null, "")) || $newnumber < sizeof($gridentries)) {
        $newnumber = sizeof($gridentries);
    }
    $data = array();
    for ($u = 1; $u < 15; $u++) {
        if (isset($_POST["hhGrid_hhmemberfirstname_" . $u])) {
            $arr = array();
            $arr[] = $_POST["hhGrid_hhmemberfirstname_" . $u];
            //$arr[] = $_POST["hhGrid_hhmemberlastname_" . $u];
            $arr[] = $_POST["hhGrid_hhmembergender_" . $u];
            $arr[] = $_POST["hhGrid_hhmemberbirthmonth_" . $u];
            //$arr[] = $_POST["hhGrid_hhmemberbirthday_" . $u];
            $arr[] = $_POST["hhGrid_hhmemberbirthyear_" . $u];
            $arr[] = $_POST["hhGrid_hhmemberrelationship_" . $u];
            $data[] = implode(",", $arr);
        }
    }
    $engine->setAnswer("newgriddata", implode("~", $data));
    //echo implode("~",$data);
    // update new hhmember number
    $engine->setAnswer("newgridfilled", loadvar("newgridfilled"));
    // update new hhmember number
    $engine->setAnswer("newhhmembernumber", sizeof($gridentries));
    // update fields --> seems to work, but not showing yet --> array update perhaps!
    for ($i = 1; $i <= $newnumber; $i++) {
        $storeindex = $existingnumber + $i;
        // we lost entries, and so we need to clear the other ones we had
        if ($i > sizeof($gridentries)) {
            $engine->setAnswer("hhmemberfirstname[" . $storeindex . ']', null);
            $engine->setAnswer("hhmemberlastname[" . $storeindex . ']', null);
            $engine->setAnswer("hhmemberage[" . $storeindex . ']', null);
            $engine->setAnswer("hhmemberdateofbirth_day[" . $storeindex . ']', null);
            $engine->setAnswer("hhmemberdateofbirth_month[" . $storeindex . ']', null);
            $engine->setAnswer("hhmemberdateofbirth_year[" . $storeindex . ']', null);
            $engine->setAnswer("hhmembergender[" . $storeindex . ']', null);
            $engine->setAnswer("hhmemberrelationship[" . $storeindex . ']', null);
            $engine->setAnswer("hhmemberrelationship_other[" . $storeindex . ']', null);
            $engine->setAnswer("hhmemberactive[" . $storeindex . ']', null);
        } else {
            $entry = $gridentries[$i - 1];
            // start at 0!
            //print_r($entry);
            $engine->setAnswer("hhmemberfirstname[" . $storeindex . ']', $entry->hhmemberfirstname);
            $engine->setAnswer("hhmemberlastname[" . $storeindex . ']', $entry->hhmemberlastname);
            $engine->setAnswer("hhmemberdateofbirth_day[" . $storeindex . ']', $entry->hhmemberbirthday);
            $engine->setAnswer("hhmemberdateofbirth_month[" . $storeindex . ']', $entry->hhmemberbirthmonth);
            $engine->setAnswer("hhmemberdateofbirth_year[" . $storeindex . ']', $entry->hhmemberbirthyear);
            $age = floor((strtotime(date('Y-m-d')) - strtotime($entry->hhmemberbirthyear . '-' . $entry->hhmemberbirthmonth . '-' . $entry->hhmemberbirthday)) / 31556926);
Exemplo n.º 16
0
 function reportRes()
 {
     global $db;
     $query = "insert into " . Config::dbSurvey() . "_issues (urid,suid,primkey,mainseid,seid,rgid,displayed,category,comment,status,language,mode,version) values (";
     $query .= getFromSessionParams('reporturid') . ",";
     $query .= getFromSessionParams('reportsuid') . ",";
     $query .= "'" . getFromSessionParams('reportprimkey') . "',";
     $query .= "'" . getFromSessionParams('reportmainseid') . "',";
     $query .= "'" . getFromSessionParams('reportseid') . "',";
     $query .= "'" . getFromSessionParams('reportrgid') . "',";
     $query .= "'" . getFromSessionParams('reportdisplayed') . "',";
     $query .= "'" . loadvar('reportcategory') . "',";
     $query .= "'" . loadvar('reportcomment') . "',";
     $query .= ISSUE_REPORTED . ", ";
     $query .= "'" . getFromSessionParams('reportlanguage') . "',";
     $query .= "'" . getFromSessionParams('reportmode') . "',";
     $query .= "'" . getFromSessionParams('reportversion') . "'";
     $query .= ")";
     //echo $query;
     $db->executeQuery($query);
     $returnStr = $this->showHeader(Language::messageSMSTitle());
     $returnStr .= '<div id="wrap">';
     $returnStr .= '<div class="container"><p>';
     $returnStr .= $this->reportSub('<div class="alert alert-success">' . Language::reportProblemConfirmation() . '</div>');
     //'<button onclick="window.close();" type="cancel" class="btn btn-default" style="min-width:100px">' . Language::buttonClose() . '</button>';
     $returnStr .= '                </div></div>';
     $returnStr .= '</p></div>    </div>';
     //container and wrap
     $returnStr .= $this->showFooter();
     echo $returnStr;
 }
Exemplo n.º 17
0
 function showImport($content = "")
 {
     $returnStr = $this->showToolsHeader(Language::headerToolsImporter());
     $returnStr .= $this->displayComboBox();
     $returnStr .= $content;
     $returnStr .= "<form id=refreshform method=post>";
     $returnStr .= '<input type=hidden name=page value="sysadmin.tools.import">';
     $returnStr .= '<input type=hidden name="' . SMS_POST_IMPORTTYPE . '" id="' . SMS_POST_IMPORTTYPE . '_hidden" value="">';
     $returnStr .= "</form>";
     $returnStr .= '<form method="post" enctype="multipart/form-data">';
     $returnStr .= setSessionParamsPost(array('page' => 'sysadmin.tools.importres'));
     $returnStr .= '<span class="label label-default">' . Language::labelToolsImportSettings() . '</span>';
     $returnStr .= '<div class="well well-sm">';
     $returnStr .= '<table>';
     $sel = array(IMPORT_TYPE_BLAISE => "", IMPORT_TYPE_MMIC => "", IMPORT_TYPE_NUBIS => "");
     if (loadvar(SMS_POST_IMPORTTYPE) != "") {
         $sel[loadvar(SMS_POST_IMPORTTYPE)] = "SELECTED";
     }
     $returnStr .= '<tr><td>' . Language::labelToolsImportType() . "</td>\n                    <td><select onchange='document.getElementById(\"" . SMS_POST_IMPORTTYPE . "_hidden\").value=this.value; document.getElementById(\"refreshform\").submit();' class='selectpicker show-tick' name='" . SETTING_IMPORT_TYPE . "'>" . '                    
                 <option ' . $sel[IMPORT_TYPE_NUBIS] . ' value=' . IMPORT_TYPE_NUBIS . '>' . Language::labelToolsImportTypeNubis() . '</option>
                 <option ' . $sel[IMPORT_TYPE_MMIC] . '  value=' . IMPORT_TYPE_MMIC . '>' . Language::labelToolsImportTypeMMIC() . '</option>
                 </select></td>
                 </tr>';
     $returnStr .= '<tr><td>' . Language::labelToolsImportTarget() . '</td>
                 <td><select class="selectpicker show-tick" name="' . SETTING_IMPORT_AS . '">                    
                 <option value=' . IMPORT_TARGET_ADD . '>' . Language::labelToolsImportTargetAdd() . '</option>
                 <option value=' . IMPORT_TARGET_REPLACE . '>' . Language::labelToolsImportTargetReplace() . '</option>';
     $returnStr .= '</select></td>
                 </tr>';
     $returnStr .= '</table>';
     $returnStr .= '</div>';
     if (loadvar(SMS_POST_IMPORTTYPE) == IMPORT_TYPE_MMIC) {
         $returnStr .= '<span class="label label-default">' . Language::labelToolsImportDatabase() . '</span>';
         $returnStr .= '<div class="well well-sm">';
         $returnStr .= '<table>';
         $returnStr .= '<tr><td>' . Language::labelDatabaseServer() . '</td><td><input class="form-control" type=text name="' . SETTING_IMPORT_SERVER . '" placeholder="localhost" /></td></tr>';
         $returnStr .= '<tr><td>' . Language::labelDatabaseName() . '</td><td><input class="form-control" type=text name="' . SETTING_IMPORT_DATABASE . '" value="" /></td></tr>';
         $returnStr .= '<tr><td>' . Language::labelDatabaseUsername() . '</td><td><input class="form-control" type=text name="' . SETTING_IMPORT_USER . '" value="" /></td></tr>';
         $returnStr .= '<tr><td>' . Language::labelDatabasePassword() . '</td><td><input class="form-control" type=password name="' . SETTING_IMPORT_PASSWORD . '" /></td></tr>';
         $returnStr .= '<tr><td>' . Language::labelDatabaseTablename() . '</td><td><input class="form-control" type=text name="' . SETTING_IMPORT_TABLE . '" value="" /></td></tr>';
         $returnStr .= '</table>';
         $returnStr .= '</div>';
     } else {
         $returnStr .= '<span class="label label-default">' . Language::labelToolsImportFile() . '</span>';
         $returnStr .= '<div class="well well-sm">';
         //$returnStr .= "<textarea placeholder='Paste contents of export file here' class='form-control' style='min-width: 300px; width: 100%; min-height: 300px;' name='" . SETTING_IMPORT_TEXT . "'></textarea>";
         $returnStr .= '<div style="position:relative;"><a class="btn btn-primary" href="javascript:;">' . Language::buttonBrowse() . '
         <input type="file" style="position:absolute;z-index:2;top:0;left:0;filter: alpha(opacity=0);-ms-filter:\'progid:DXImageTransform.Microsoft.Alpha(Opacity=0)\';opacity:0;background-color:transparent;color:transparent;" name="' . SETTING_IMPORT_TEXT . '" size="40"  onchange=\'$("#upload-file-info").html($(this).val());\'>
     </a>
     &nbsp;
     <span class="label label-info" id="upload-file-info"></span></div>';
         $returnStr .= '</div>';
     }
     $returnStr .= '<input type="submit" class="btn btn-default" ' . confirmAction(language::messageImportSurvey(), 'IMPORT') . ' value="' . Language::buttonImport() . '"/>';
     $returnStr .= '</form>';
     //END CONTENT
     $returnStr .= '</p></div>    </div>';
     //container and wrap
     $returnStr .= $this->showBottomBar();
     $returnStr .= $this->showFooter(false);
     return $returnStr;
 }
Exemplo n.º 18
0
						Result.innerHTML= "Try: " + (scanNumbers) + " Decoding failed.";
					}
				}
				if (scanNumbers > 10){
				      clearInterval(scanInterval);
				      Result.innerHTML="Could not scan barcode please enter manually!";
				$("#answer2").val("timeout");
      $("#uscic-backbutton").prop("disabled", false);
      $("#uscic-nextbutton").prop("disabled", false);
                           }
Exemplo n.º 19
0
function getFromSessionParams($param, $ignorer = false)
{
    if (loadvar('r') == '') {
        if (!inArray($param, array(SESSION_PARAM_LANGUAGE, SESSION_PARAM_MODE, SESSION_PARAM_VERSION, SESSION_PARAM_MAINSEID, SESSION_PARAM_SEID))) {
            return '';
            // no submitted session post, so ignore anything in session from before (excluding language, mode)
        }
        //if (loadvarSurvey(POST_PARAM_NEW_PRIMKEY) == '1') { // interview start, then ignore everything!
        //     return '';
        //}
    }
    if (isset($_SESSION['PARAMS']) && isset($_SESSION['PARAMS'][$param])) {
        return strip_tags($_SESSION['PARAMS'][$param]);
    }
    return '';
}
Exemplo n.º 20
0
    function showOutputResponse()
    {
        $survey = new Survey(1);
        $returnStr = $this->displayHeaderForTable(Language::messageSMSTitle(), $message);
        $returnStr .= '<div id="wrap">';
        $returnStr .= $this->showNavBar();
        $returnStr .= '<div class="container"><p>';
        $returnStr .= '<ol class="breadcrumb">';
        $returnStr .= '<li class="active">' . Language::labelHome() . '</li>';
        $returnStr .= '</ol>';
        $rorh = loadvar('rorh', 1);
        $returnStr .= '<nav class="navbar navbar-default" role="navigation">
      <div class="container-fluid">
        <div class="navbar-header">
          <a class="navbar-brand">Set filter</a>
   </div>
        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-2">';
        $returnStr .= '<form method="post" class="navbar-form navbar-left">';
        $returnStr .= setSessionParamsPost(array('page' => 'supervisor.reports.statistics.response'));
        // $content .= $sessionparams;
        $returnStr .= '<div class="form-group">';
        $returnStr .= $this->displayRespondentOrHousehold($rorh);
        $returnStr .= '</div>';
        $returnStr .= '<button type="submit" class="btn btn-default">' . Language::labelSupervisorGo() . '</button>';
        $returnStr .= '</form>
        </div>
      </div>
</nav>';
        $returnStr .= '<script src="js/highcharts.js"></script>';
        $returnStr .= '<script src="js/modules/exporting.js"></script>';
        $returnStr .= '<div id="chart1" style="min-width: 310px; height: 400px; margin: 0 auto"></div>';
        //        echo '<br/><br/><br/><br><br/>' . $this->getContactData();
        //        echo '<hr><hr>';
        $returnStr .= $this->getResponseData($rorh);
        $returnStr .= '</p></div>    </div>';
        //container and wrap
        $returnStr .= $this->showBottomBar();
        $returnStr .= $this->showFooter(false);
        return $returnStr;
    }
Exemplo n.º 21
0
        $returnStr .= $this->showBottomBar();
        $returnStr .= $this->showFooter(false);
        return $returnStr;
    }
    /*
      function showMainHouseholds($households, $message){

      //"aLengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]]

      $returnStr = $this->displayHeaderForTable(Language::messageSMSTitle(), $message);

      $returnStr .= '<div id="wrap">';
      $returnStr .= $this->showNavBar();
      $returnStr .= '<div class="container"><p>';

      $returnStr .= '<ol class="breadcrumb">';
      $returnStr .= '<li class="active">Home</li>';
      $returnStr .= '</ol>';

      //CONTENT
      $returnStr .= $message;

      if (sizeof($households) > 0) {
      $returnStr .= Language::messageSelectRespondent();
      $returnStr .= $this->showHouseholdsTable($households);
      }
      else {    $content .= '<tr><td colspan=3><b>HH members</b></td></tr>';

      $respondents = $household->getRespondents();
      foreach($respondents as $respondent){
      $content .= '<tr><td colspan=3>' . $respondent->getFirstname() . '</td></tr>';
      }

      $returnStr .= $this->displayWarning(Language::messageNoRespondentsAssigned(), "outcomehelp"); // '<div class="alert alert-warning" id="outcomehelp">' . Language::errorNoRespondentsAssigned() . '</div>';
      }

      //END CONTENT
      $returnStr .= '</p></div></div>   '; // </div>'; //container and wrap
      $returnStr .= $this->showBottomBar();

      $returnStr .= $this->showFooter(false);
      return $returnStr;
      }

     */
    /*
      function showHouseholdInfo($household){
      $content = $message;

      $content .= '<div class="row">';
      $content .= '<div class="col-6 col-sm-6 col-lg-5">';

      $content .= $this->showInfoHouseholdSub($household);
      $content .= '</div>';
      $content .= '<div class="col-6 col-sm-6 col-lg-5">';
      $content .= '<table>';
      $content .= '<tr><td style="width:100px">Status:</td><td style="width:200px">' . $this->displayStatus($household) . '</td></tr>';
      $content .= '<tr><td># of contacts:</td><td>' . sizeof($household->getContacts()) . '</td></tr>';

      $content .= '<tr><td colspan=2><hr></td></tr>';

      $content .= '<tr><td colspan=3><b>HH members</b></td></tr>';

      $respondents = $household->getRespondents();
      foreach($respondents as $respondent){
      $content .= '<tr><td colspan=3>' . $respondent->getFirstname() . '</td></tr>';
      }


      $content .= '</table>';
      $content .= '</div>';

      $content .= '</div>';
      $content .= '<hr>';
      $content .= '<hr>';


      $content .= '<table width=100%><tr><td>';
      $content .= '<form method=post>';
      $content .= setSessionParamsPost(array('page' => 'interviewer.household.addcontact', 'hhid' => $household->getHhid()));
      $content .= '<button type="submit" class="btn btn-default navbar-btn">' . Language::buttonAddContact() . '</button>';
      $content .= '</form>';
      $content .= '</td><td align=right>';

      if ($household->getStatus() != 2){
      $content .= '<form method=post>';
      $content .= setSessionParamsPost(array('page' => 'interviewer.household.startsurvey', 'hhid' => $household->getHhid()));
      $content .= '<button type="submit" class="btn btn-default navbar-btn">' . Language::buttonStartSurvey() . '</button>';
      $content .= '</form>';
      }
      $content .= '</td></tr></table>';
Exemplo n.º 22
0
 You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 ------------------------------------------------------------------------
*/
error_reporting(E_ALL);
ini_set("display_errors", 1);
set_include_path(dirname(dirname(getcwd())));
require_once 'constants.php';
require_once 'functions.php';
require_once 'dbConfig.php';
require_once 'config.php';
require_once 'database.php';
date_default_timezone_set(Config::timezone());
$id = loadvar('id');
$fieldname = loadvar('fieldname');
$p = loadvar('p');
$db = new Database();
if ($id != '' && $fieldname != '') {
    if ($p == 'show') {
        //show image
        $query = 'select AES_DECRYPT(picture, "' . Config::filePictureKey() . '") as picture1 from ' . Config::dbSurveyData() . '_pictures where primkey="' . $id . '" and variablename = "' . $fieldname . '"';
        $result = $db->selectQuery($query);
        if ($result != null && $db->getNumberOfRows($result) > 0) {
            $row = $db->getRow($result);
            ob_clean();
            header('Content-type: image/jpg');
            if ($row['picture'] != null) {
                print $row['picture1'];
            } else {
                //display 'empty' image
                ob_clean();
Exemplo n.º 23
0
    function showBottomBar()
    {
        if (loadvar(POST_PARAM_AJAX_LOAD) == AJAX_LOAD) {
            return;
        }
        $returnStr = '</div>
    <div id="footer">
      <div class="container">
        <p class="text-muted credit" style="text-align:right">' . Language::nubisFooter() . '</p>
      </div>
    </div>
    <div class="waitmodal"></div>
';
        return $returnStr;
    }
Exemplo n.º 24
0
 function showOutputStatisticsParadataVariable($seid, $vsid)
 {
     if (loadvar(DATA_OUTPUT_TYPEDATA) != "") {
         if (loadvar(DATA_OUTPUT_TYPEDATA) == DATA_TEST) {
             $_SESSION[SURVEY_EXECUTION_MODE] = SURVEY_EXECUTION_MODE_TEST;
         } else {
             $_SESSION[SURVEY_EXECUTION_MODE] = SURVEY_EXECUTION_MODE_NORMAL;
         }
     } else {
         $_SESSION[SURVEY_EXECUTION_MODE] = SURVEY_EXECUTION_MODE_NORMAL;
     }
     $survey = new Survey($_SESSION['SUID']);
     $section = $survey->getSection($seid);
     $variable = $survey->getVariableDescriptive($vsid);
     $headers[] = array('link' => setSessionParamsHref(array('page' => 'sysadmin.output'), Language::headerOutput()), 'label' => Language::headerOutputData());
     $headers[] = array('link' => setSessionParamsHref(array('page' => 'sysadmin.output.statistics'), Language::headerOutputStatistics()), 'label' => Language::headerOutputStatistics());
     $headers[] = array('link' => setSessionParamsHref(array('page' => 'sysadmin.output.statistics.paradata'), Language::headerOutputStatisticsParadata()), 'label' => Language::headerOutputStatisticsParadata());
     $headers[] = array('link' => setSessionParamsHref(array('page' => 'sysadmin.output.statistics.paradata', 'suid' => $suid), $survey->getName()), 'label' => $survey->getName());
     $headers[] = array('link' => setSessionParamsHref(array('page' => 'sysadmin.output.statistics.paradata.section', 'seid' => $seid), $section->getName()), 'label' => $section->getName());
     $headers[] = array('link' => '', 'label' => $variable->getName());
     $returnStr = $this->showOutputHeader($headers);
     $returnStr .= '<form id=surveyform method="post">';
     $returnStr .= '<span class="label label-default">' . Language::labelAggregateDetails() . '</span>';
     $returnStr .= '<div class="well well-sm">';
     $returnStr .= '<table>';
     $returnStr .= $this->displayComboBox();
     $returnStr .= '<tr><td>' . Language::labelOutputDataType() . '</td><td>';
     $returnStr .= "<select id='typedata' class='selectpicker show-tick' name=" . DATA_OUTPUT_TYPEDATA . ">";
     $selected = array('', '');
     if (loadvar(DATA_OUTPUT_TYPEDATA) != "") {
         $selected[loadvar(DATA_OUTPUT_TYPEDATA)] = "selected";
     }
     //print_r($selected);
     $returnStr .= "<option " . $selected[0] . " value=" . DATA_REAL . ">" . Language::optionsDataReal() . "</option>";
     $returnStr .= "<option " . $selected[1] . " value=" . DATA_TEST . ">" . Language::optionsDataTest() . "</option>";
     $returnStr .= "</select>";
     $returnStr .= "</td></tr>";
     $returnStr .= '<script type=text/javascript>
                     $(document).ready(function(){
                         $("#typedata").on("change", function(event) {
                             document.getElementById("surveyform").submit();
                         });
                     });
                 </script>';
     $returnStr .= "</form>";
     $returnStr .= '</table>';
     $returnStr .= '<br/><table>';
     $returnStr .= '<tr><td valign=top style="min-width: 100px;">' . Language::labelTypeEditGeneralQuestion() . ": </td><td valign=top>";
     $returnStr .= $variable->getQuestion() . "</td></tr>";
     $returnStr .= '<tr><td valign=top>' . Language::labelTypeEditGeneralAnswerType() . ": </td><td valign=top>";
     $answertype = $variable->getAnswerType();
     $arr = Language::getAnswerTypes();
     $returnStr .= $arr[$answertype] . "</td></tr>";
     if (inArray($answertype, array(ANSWER_TYPE_ENUMERATED, ANSWER_TYPE_SETOFENUMERATED, ANSWER_TYPE_DROPDOWN, ANSWER_TYPE_MULTIDROPDOWN))) {
         $returnStr .= '<tr><td valign=top>' . Language::labelTypeEditGeneralCategories() . ": </td><td valign=top>";
         $returnStr .= str_replace("\r\n", "<br/>", $variable->getOptionsText()) . "</td></tr>";
     } else {
         if (inArray($answertype, array(ANSWER_TYPE_RANGE, ANSWER_TYPE_SLIDER))) {
             $returnStr .= '<tr><td valign=top>' . Language::labelTypeEditRangeMinimum() . ": </td><td valign=top>";
             $returnStr .= $variable->getMinimum() . "</td></tr>";
             $returnStr .= '<tr><td valign=top>' . Language::labelTypeEditRangeMaximum() . ": </td><td valign=top>";
             $returnStr .= $variable->getMaximum() . "</td></tr>";
         }
     }
     if ($variable->isArray()) {
         $returnStr .= $this->displayComboBox();
         $returnStr .= '<tr><td valign=top>' . Language::labelTypeEditGeneralArrayInstance() . ": </td><td valign=top>";
         $options = $this->getArrayData($_SESSION['SUID'], $variable->getName());
         $returnStr .= "<form id=instanceform method=post>";
         $returnStr .= "<select class='selectpicker show-tick' id='arrayinstance' name='arrayinstance'>";
         foreach ($options as $op) {
             $returnStr .= "<option value='" . $op . "'>" . $op . "</option>";
         }
         $returnStr .= "</select>";
         $returnStr .= "</td></tr>";
         $params = getSessionParams();
         $params['vsid'] = $variable->getVsid();
         $returnStr .= setSessionParamsPost($params);
         $returnStr .= "</form>";
         $returnStr .= "<script type='text/javascript'>";
         $returnStr .= "\$('#arrayinstance').change(function () {\n                                \$('#instanceform').submit();\n                            });";
         $returnStr .= "</script>";
     }
     $returnStr .= "</table></div>";
     $returnStr .= '<span class="label label-default">' . Language::labelAggregateData() . '</span>';
     $returnStr .= '<div class="well well-sm">';
     $data = new Data();
     $brackets = array();
     $varname = $variable->getName();
     if ($variable->isArray()) {
         if (loadvar("arrayinstance") != "") {
             $varname = loadvar("arrayinstance");
         } else {
             $varname = $varname . "[1]";
         }
     }
     $paradata = $data->getParaData($variable, $varname);
     //$aggdata = array(2,5);
     if (sizeof($paradata) == 0) {
         $returnStr .= "<br>" . $this->displayWarning(Language::messageNoData());
     } else {
         $returnStr .= '<script src="js/highcharts.js"></script>';
         $returnStr .= '<script src="js/modules/exporting.js"></script>';
         $returnStr .= '<script src="js/export-csv.js"></script>';
         $returnStr .= '<div id="chart1" style="min-width: 310px; height: 400px; margin: 0 auto"></div>';
         $errorlabels = Language::errorCodeLabels();
         $brackets = array();
         foreach ($paradata as $k => $p) {
             if (isset($errorlabels[$k])) {
                 $brackets[] = $errorlabels[$k];
             }
         }
         $returnStr .= $this->createParadataChart($variable->getName(), implode(",", array_values($paradata)), $brackets);
     }
     $returnStr .= "</div>";
     $returnStr .= '</p></div>    </div>';
     //container and wrap
     $returnStr .= $this->showBottomBar();
     $returnStr .= $this->showFooter(false);
     return $returnStr;
 }
Exemplo n.º 25
0
 function exportSQL()
 {
     global $db;
     $returnStr = "";
     $history = loadvar(SETTING_EXPORT_HISTORY);
     $create = loadvar(SETTING_EXPORT_CREATE);
     $alltables = Common::allTables();
     // create table statements
     if ($create == EXPORT_CREATE_YES) {
         foreach ($alltables as $export) {
             $create = "SHOW CREATE TABLE " . Config::dbSurvey() . $export;
             $rescreate = $db->selectQuery($create);
             if ($rescreate) {
                 $row2 = $db->getRow($rescreate);
                 $str = str_ireplace("CREATE TABLE", "CREATE TABLE IF NOT EXISTS", $row2[1]);
                 $str = str_ireplace(Config::dbSurvey() . $export, EXPORT_PLACEHOLDER_TABLE . $export, $str);
                 if ($returnStr != "") {
                     $returnStr .= "\r\n";
                 }
                 $returnStr .= $str . EXPORT_SQL_DELIMITER . "\r\n";
             }
         }
     }
     // content
     $exporttables = Common::surveyExportTables();
     /* based off https://davidwalsh.name/backup-mysql-database-php */
     foreach ($exporttables as $export) {
         if (strtoupper($export) == strtoupper("_tracks") && $history != EXPORT_HISTORY_YES) {
             continue;
         }
         $query = 'select * from ' . Config::dbSurvey() . $export . ' where suid=' . $this->suid;
         $result = $db->selectQuery($query);
         $num_fields = $db->getNumberOfFields($result);
         $fields = $db->getFields($result);
         $num_fields = sizeof($fields);
         $fieldstr = "";
         // `
         for ($i = 0; $i < $num_fields; $i++) {
             if ($fieldstr != "") {
                 $fieldstr .= ",";
             }
             $fi = $fields[$i];
             $fieldstr .= "`" . $fi->name . "`";
         }
         // add content (table name and suid are added as placeholders)
         while ($row = $db->getRow($result)) {
             $returnStr .= IMPORT_STATEMENT_INSERT . ' ' . EXPORT_PLACEHOLDER_TABLE . $export . ' (' . $fieldstr . IMPORT_STATEMENT_INSERT_VALUES;
             for ($j = 0; $j < $num_fields; $j++) {
                 $fi = $fields[$j];
                 if (strtoupper($fi->name) == strtoupper(EXPORT_COLUMN_SUID)) {
                     $returnStr .= '"' . EXPORT_PLACEHOLDER_SUID . '"';
                 } else {
                     if (strtoupper($fi->name) == strtoupper(EXPORT_COLUMN_URID)) {
                         $returnStr .= '"' . EXPORT_PLACEHOLDER_URID . '"';
                     } else {
                         if (isset($row[$j])) {
                             $returnStr .= '"' . prepareDatabaseString($row[$j]) . '"';
                         } else {
                             $returnStr .= '""';
                         }
                     }
                 }
                 if ($j < $num_fields - 1) {
                     $returnStr .= ',';
                 }
             }
             $returnStr .= ")" . EXPORT_SQL_DELIMITER . "\r\n";
         }
     }
     // output as SQL file
     /* allow for time */
     set_time_limit(0);
     // http://www.richnetapps.com/the-right-way-to-handle-file-downloads-in-php/
     /* declare headers */
     header("Content-Description: File Transfer");
     header("Content-Type: application/force-download");
     header("Content-Type: application/download");
     header('Content-Type: application/octet-stream');
     header("Content-Disposition: attachment; filename=" . Config::dbSurvey() . EXPORT_FILE_SQL . '; modification-date="' . date('r', time()) . '";');
     header("Content-Type: application/sql");
     /* prevent caching (http://stackoverflow.com/questions/13640109/how-to-prevent-browser-cache-for-php-site) */
     header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
     header("Cache-Control: post-check=0, pre-check=0", false);
     header("Pragma: no-cache");
     // http://stackoverflow.com/questions/15299325/x-download-options-noopen-equivalent
     header("X-Content-Type-Options: nosniff");
     // http://stackoverflow.com/questions/21723436/firefox-downloads-text-plain-instead-of-showing-it
     /* clean buffer before outputting file */
     ob_end_clean();
     // echo output
     echo $returnStr;
     // stop
     exit;
 }
Exemplo n.º 26
0
<?php

error_reporting(E_ALL);
ini_set("display_errors", 1);
define('directLoginKey', '43admafeifaqgfasdFDedfq34qfa#1sa');
require_once "../surveys/constants.php";
require_once "../surveys/functions.php";
require_once "../surveys/dbConfig.php";
require_once "../surveys/config.php";
echo '<html><head><title>UCNets Face-to-Face test site</title></head><body>';
$p = loadvar('p');
if ($p == 'login' && loadvar('primkey') != '') {
    echo startSurvey(loadvar('primkey'));
} else {
    echo enterId();
}
echo '</body></html>';
function enterId()
{
    $content = '<center><h2>UCNets Face-to-Face test site</h2><div style="margin-top: 100px;">Please enter an id to login: <br/><br/>';
    $content .= '<form method="post" action="index.php">';
    $content .= '<input type=hidden name="p" value="login">';
    $content .= '<input type=text name="primkey"><br/><br/>';
    $content .= '<button type="submit" class="btn btn-default">Start</button>';
    $content .= '</form></div></center>';
    return $content;
}
function gen_password($length = 8)
{
    mt_srand((double) microtime() * 1000000);
    $password = "";
Exemplo n.º 27
0
 function determineModeLanguage(&$de)
 {
     $user = new User($_SESSION['URID']);
     $modes = $user->getModes(loadvar('survey'));
     $mods = "";
     if (loadvar(DATA_OUTPUT_MODES) == "") {
         $mods = implode("~", $modes);
     } else {
         $ms = loadvar(DATA_OUTPUT_MODES);
         $ms1 = array();
         foreach ($ms as $m) {
             if (inArray($m, $modes)) {
                 $ms1[] = $m;
             }
         }
         $mods = implode("~", $ms1);
     }
     $de->setProperty(DATA_OUTPUT_MODES, $mods);
     $modes = explode("~", $mods);
     $langs = "";
     if (loadvar(DATA_OUTPUT_LANGUAGES) == "") {
         $langs = array();
         foreach ($modes as $m) {
             $langs = explode("~", $user->getLanguages(loadvar('survey'), $m));
         }
         $langs = implode("~", array_unique($langs));
     } else {
         $ls = loadvar(DATA_OUTPUT_LANGUAGES);
         $ls1 = array();
         foreach ($ls as $l) {
             foreach ($modes as $m) {
                 if (inArray($l, explode("~", $user->getLanguages(loadvar('survey'), $m)))) {
                     $ls1[] = $l;
                     break;
                 }
             }
         }
         $langs = implode("~", array_unique($ls1));
     }
     $de->setProperty(DATA_OUTPUT_LANGUAGES, $langs);
 }
Exemplo n.º 28
0
    function showFollowupInfo($respondent, $message = '')
    {
        $returnStr = $this->showNurseHeader(Language::messageSMSTitle());
        $returnStr .= '<div id="wrap">';
        $returnStr .= $this->showNavBar();
        $returnStr .= '<div class="container"><p>';
        $returnStr .= '<ol class="breadcrumb">';
        //        $returnStr .= '<li>' . setSessionParamsHref(array('page' => 'nurse.home'), 'Home') . '</li>';
        $returnStr .= '<li class="active">' . Language::labelNurseFollowUp() . '</li>';
        $returnStr .= '</ol>';
        //CONTENT
        $returnStr .= $message;
        $returnStr .= '<table>';
        $returnStr .= '<tr><td>' . Language::labelNurseFollowUpPhone1() . '</td><td>' . getData($respondent->getPrimkey(), 'TG003', 2) . '</td></tr>';
        $returnStr .= '<tr><td>' . Language::labelNurseFollowUpPhone2() . '</td><td>' . getData($respondent->getPrimkey(), 'TG004', 2) . '</td></tr>';
        $returnStr .= '<tr><td>' . Language::labelNurseFollowUpHouseholdHead() . '</td><td>' . getData($respondent->getPrimkey(), 'TG008', 2) . '</td></tr>';
        $returnStr .= '<tr><td>' . Language::labelNurseFollowUpSomeoneElse() . '</td><td>' . getData($respondent->getPrimkey(), 'TG010', 2) . '</td></tr>';
        $returnStr .= '</table>';
        //CALL AND INFO
        $returnStr .= '<hr>';
        $refpage = 'nurse.followup';
        $returnStr .= '<form method=post>';
        $returnStr .= setSessionParamsPost(array('page' => $refpage . '.addcontactres', 'primkey' => $respondent->getPrimkey()));
        $returnStr .= '<input type="hidden" name="contactwith" id="contactwith" value="' . loadvar('contactwith') . '">';
        $returnStr .= '<table width=100%>';
        $returnStr .= '<tr><td style="width:80px">' . Language::labelNurseFollowUpDateTime() . '</td><td style="width:220px">';
        if (loadvar('contactts') != '') {
            $returnStr .= $this->displayDateTimePicker('contactts', 'contactts', loadvar('contactts'), getSMSLanguagePostFix(getSMSLanguage()), "true", "true", Config::usFormatSMS());
        } else {
            $returnStr .= $this->displayDateTimePicker('contactts', 'contactts', date('m/d/Y h:i a'), getSMSLanguagePostFix(getSMSLanguage()), "true", "true", Config::usFormatSMS());
        }
        $returnStr .= '</td><td colspan=2></td></tr>';
        $returnStr .= '<tr><td style="width:90px">' . Language::labelOutcome() . '</td><td valign=top colspan=2>';
        $returnStr .= '<select class="form-control" name=contactcode id=outcomecode style="width:300px"><option value=-1>' . Language::labelPleaseSelect() . '</option>';
        $dispositionCodes = Language::optionsDispositionFollowupContactCode($respondent);
        foreach ($dispositionCodes as $option => $dispositionCode) {
            if ($dispositionCode[5] == 1) {
                //display in dropdown
                $selected = '';
                if (loadvar('contactcode') == $option) {
                    $selected = ' SELECTED';
                }
                $returnStr .= '<option value="' . $option . '"' . $selected . '>' . $option . ': ' . $dispositionCode[1] . '</option>';
            }
        }
        $returnStr .= '</select></td><td>

    <div id="contactwithdiv" style="display: none"><table width=100%><tr><td style="width:90px">' . Language::labelContactWith() . '</td><td>

			<div id="selector" class="btn-group">

				<button type="button" class="btn btn-default" value=1>' . Language::labelHouseholdMember() . '</button>

				<button type="button" class="btn btn-default" value=2>' . Language::labelProxy() . '</button>

			</div></td></tr></table>

      <div id="contactperson" style="display: none"><table width=100%><tr><td style="width:90px">' . Language::labelProxyName() . '</td><td>

        <input type=text class="form-control" name="contactperson"></td></tr></table>

      </div>



    </div>';
        $returnStr .= '<tr><td valign=top>' . Language::labelRemark() . '</td><td colspan=3>';
        $returnStr .= '<textarea class="form-control" name="contactremark">' . loadvar('contactremark') . '</textarea>';
        $returnStr .= '</td></tr>';
        /*
         $returnStr .= '<tr><td style="width:80px">' . Language::labelAppointment() . '</td><td style="width:220px">';
         $returnStr .= $this->displayDateTimePicker('contactappointment', 'contactappointment', loadvar('contactappointment'), getSMSLanguagePostFix(getSMSLanguage()), "true", "true", Config::usHourFormatSMS());
         $returnStr .= '</td><td colspan=2></td></tr>';
        */
        $returnStr .= '</table>';
        $returnStr .= '<hr>';
        $returnStr .= '<button type="submit" class="btn btn-default navbar-btn">' . Language::buttonAddContact() . '</button>';
        $returnStr .= '</form> <b> OR </b>';
        $returnStr .= $this->showStartButton($respondent, 7, false, 'Start follup survey', false);
        $returnStr .= '<br/>';
        $returnStr .= '

<script>





$(document).ready(function() {

    $(\'#outcomecode\').change(function() {

        $(\'#contactwithdiv\').css("display", "none");

        var element = $(this).find(\'option\').filter(\':selected\').val();';
        $check = array();
        $followup = Language::optionsDispositionFollowupContactCode($respondent);
        foreach ($followup as $option => $follow) {
            if ($follow[0] == '1') {
                $check[] = $option;
            }
        }
        $returnStr .= 'if (element == "' . implode($check, '" || element == "') . '") {';
        //$returnStr .= 'alert("ADASD");';
        $returnStr .= '$(\'#contactwithdiv\').css("display", "block"); }';
        $returnStr .= '   switch(element){';
        $messageDispositionCodes = Language::optionsDispositionContactCode($respondentOrHousehold);
        foreach ($messageDispositionCodes as $option => $message) {
            $returnStr .= 'case "' . $option . '":  $( "#outcomehelp" ).html("' . addslashes($message[2]) . '"); break;';
        }
        $returnStr .= 'default: $( "#outcomehelp" ).html("' . addslashes(Language::messageSelectContactOutcome()) . '");';
        $returnStr .= '    }



    });



  $(\'#outcomecode\').change(); //in case reloaded page



});



$(\'#selector button\').click(function() {

    $(\'#contactperson\').css("display", "none");

    $(\'#selector button\').addClass(\'active\').not(this).removeClass(\'active\');

    $(\'#contactwith\').val("1");

    if ($(this).val() == "2") {

      $(\'#contactperson\').css("display", "block");

      $(\'#contactwith\').val("2");

    }

});

if ($(\'#contactwith\').val() == "2"){

  $(\'#selector button\').click();

}

</script>

';
        //END CONTENT
        $returnStr .= '</p></div>    </div>';
        //container and wrap
        $returnStr .= $this->showBottomBar();
        $returnStr .= $this->showFooter(false);
        return $returnStr;
    }
Exemplo n.º 29
0
 function addParadata($lastrgid)
 {
     if ($this->getFlooding()) {
         return;
     }
     $localdb = null;
     if (Config::useTransactions() == true) {
         global $transdb;
         $localdb = $transdb;
     } else {
         global $db;
         $localdb = $db;
     }
     $pardata = loadvar(POST_PARAM_PARADATA);
     //echo $pardata;
     //$displayed = $this->getDisplayed();
     $display = array();
     $vars = splitString("/~/", getFromSessionParams(SESSION_PARAM_VARIABLES));
     foreach ($vars as $variablename) {
         $variablename = $this->prefixVariableName($variablename);
         $display[] = $variablename;
     }
     $displayed = implode("~", $display);
     $stateid = $this->getStateId();
     $primkey = $this->getPrimaryKey();
     $suid = $this->getSuid();
     $l = getSurveyLanguage();
     $m = getSurveyMode();
     $v = getSurveyVersion();
     $pid = null;
     $bp = new BindParam();
     $bp->add(MYSQL_BINDING_INTEGER, $pid);
     $bp->add(MYSQL_BINDING_INTEGER, $suid);
     $bp->add(MYSQL_BINDING_STRING, $primkey);
     $bp->add(MYSQL_BINDING_INTEGER, $stateid);
     $bp->add(MYSQL_BINDING_INTEGER, $lastrgid);
     $bp->add(MYSQL_BINDING_STRING, $displayed);
     $bp->add(MYSQL_BINDING_STRING, $pardata);
     $bp->add(MYSQL_BINDING_INTEGER, $m);
     $bp->add(MYSQL_BINDING_INTEGER, $l);
     $bp->add(MYSQL_BINDING_INTEGER, $v);
     global $survey;
     $key = $survey->getDataEncryptionKey();
     if ($key == "") {
         $query = "insert into " . Config::dbSurveyData() . "_paradata(pid, suid, primkey, stateid, rgid, displayed, paradata, mode, language, version) values (?,?,?,?,?,?,?,?,?,?)";
     } else {
         $query = "insert into " . Config::dbSurveyData() . "_paradata(pid, suid, primkey, stateid, rgid, displayed, paradata, mode, language, version) values (?,?,?,?,?,?,aes_encrypt(?, '" . $key . "'),?,?,?)";
     }
     //echo $query;
     //print_r($bp->get());
     $localdb->executeBoundQuery($query, $bp->get());
 }
Exemplo n.º 30
0
 function addSection()
 {
     $survey = new Survey($_SESSION['SUID']);
     $survey->addSection(loadvar('section'));
 }