Пример #1
0
 function Database()
 {
     $this->type = dbConfig::getProperty(CONFIGURATION_DATABASE, CONFIGURATION_DATABASE_TYPE);
     if ($this->db == null) {
         //$this->db = @mysqli_connect(Config::dbServer(), Config::dbUser(), Config::dbPassword());  //default mysql
         switch ($this->type) {
             case DB_SQLITE:
                 $this->db = new SQLite3('c:/myprograms/wamp/bart/nubis.sqlite');
                 $this->db->createFunction('aes_encrypt', 'aes_encrypt');
                 $this->db->createFunction('aes_decrypt', 'aes_decrypt');
                 break;
             default:
                 $this->db = @mysqli_connect(null, Config::dbUser(), Config::dbPassword());
                 //default mysql
                 if ($this->db != null) {
                     if (mysqli_select_db($this->db, Config::dbName())) {
                         @mysqli_query($this->db, 'SET CHARACTER SET utf8;');
                         @mysqli_query($this->db, 'SET collation_connection = \'utf8_general_ci\';');
                     } else {
                         $this->db = null;
                     }
                 }
                 break;
         }
     }
 }
 function __construct()
 {
     parent::setHost("lazuardi-pc");
     parent::setDbName("DBAkademik");
     parent::setUser("sa");
     parent::setPassword("P@ssw0rd");
 }
 function __construct()
 {
     /*parent::setHost("localhost");
     		parent::setDbName("unmerpon_web_tes");
     		parent::setUser("unmerpon_web_tes");
     		parent::setPassword("cakhadi123!@");  */
     parent::setHost("localhost");
     parent::setDbName("db_itk");
     parent::setUser("root");
     parent::setPassword("");
 }
Пример #4
0
function getMidScore()
{
    //connect to db
    $db = new dbConfig();
    $db->getDbParams();
    /*select main score*/
    $result_select = getSelectMidScore($db);
    $scoreTable = "";
    // html
    $scoreTable .= "<table id=\"midScore\" >\n";
    $scoreTable .= "<tr><th>dkbbg</th><th>querido_amigo</th></tr>";
    $data = array();
    while ($row = mysqli_fetch_array($result_select, MYSQL_ASSOC)) {
        $data[] = $row;
    }
    $scoreTable .= "<tr>";
    foreach ($data as $key => $value) {
        $scoreTable .= "<td id='D_mid'>" . $value['D_mid'] . "</td>";
        $scoreTable .= "<td id='S_mid'>" . $value['S_mid'] . "</td>";
    }
    $scoreTable .= "</tr>";
    $scoreTable .= "</table>\n";
    return $scoreTable;
}
 function __construct()
 {
     parent::createConfig();
     try {
         $dsn = 'mysql:host=' . $this->dbConfig['host'] . ';dbname=' . $this->dbConfig['dbname'];
         $this->connection = new PDO($dsn, $this->dbConfig['username'], $this->dbConfig['password'], $driver_options = array());
         $this->connection->query("SET NAMES utf8");
         $this->connection->query("SET CHARACTER SET utf8");
         $this->connection->query("SET COLLATION_CONNECTION = 'utf8_turkish_ci");
         return true;
     } catch (PDOException $error) {
         $errorMesage = 'Hata : Veritabanı bağlantısı kurulamadı !<br>Hata Mesajı =>' . $error->getMessage();
         echo $errorMesage;
     }
 }
Пример #6
0
 static function messageNoRespondentsAssignedNurse()
 {
     if (dbConfig::defaultPanel() == PANEL_HOUSEHOLD) {
         //show household level
         return 'No households or respondents found. Please try again.';
     }
     return 'No respondents found. Please try again.';
 }
Пример #7
0
     //return 'https://cesr.usc.edu/panel/index.php';
 }
 static function sessionRedirectURL()
 {
     return dbConfig::getProperty(CONFIGURATION_SESSION, CONFIGURATION_SESSION_REDIRECT);
     //return 'https://cesr.usc.edu/panel/index.php';
Пример #8
0
    function showSectionSideBar($respondentOrHousehold)
    {
        $refpage = 'interviewer.household';
        if ($respondentOrHousehold instanceof Respondent) {
            $refpage = 'interviewer.respondent';
        }
        $refpage = $this->setPrefix($refpage);
        $remarksStr = '';
        $remarks = $respondentOrHousehold->getRemarks();
        if (sizeof($remarks) > 0) {
            $remarksStr = ' <span class="badge pull-right">' . sizeof($remarks) . '</span>';
        }
        $contactsStr = '';
        $contacts = $respondentOrHousehold->getContacts();
        if (sizeof($contacts) > 0) {
            $contactsStr = ' <span class="badge pull-right">' . sizeof($contacts) . '</span>';
        }
        $returnStr = '



<div class="col-xs-6 col-sm-3 sidebar-offcanvas" id="sidebar" role="navigation">

          <div class="well sidebar-nav">

            <ul class="nav"><li>';
        if ($respondentOrHousehold instanceof Respondent) {
            $returnStr .= Language::labelRespondentRespondent() . ' ';
        } else {
            $returnStr .= Language::labelRespondentHousehold() . 'Household ';
        }
        $returnStr .= $respondentOrHousehold->getPrimkey() . '</li>

              <li class="active"><a href="' . setSessionParams(array('page' => $refpage . '.info', 'primkey' => $respondentOrHousehold->getPrimkey())) . '"><span class="glyphicon glyphicon-user"></span> ' . Language::labelInfo() . '</a></li>

              <li><a href="' . setSessionParams(array('page' => $refpage . '.contacts', 'primkey' => $respondentOrHousehold->getPrimkey())) . '"><span class="glyphicon glyphicon-calendar"></span> ' . Language::labelContacts() . $contactsStr . '</a></li>

              <li><a href="' . setSessionParams(array('page' => $refpage . '.history', 'primkey' => $respondentOrHousehold->getPrimkey())) . '"><span class="glyphicon glyphicon-time"></span> ' . Language::labelHistory() . '</a></li>

              <li><a href="' . setSessionParams(array('page' => $refpage . '.remarks', 'primkey' => $respondentOrHousehold->getPrimkey())) . '"><span class="glyphicon glyphicon-comment"></span> ' . Language::labelRemarks() . $remarksStr . '</a></li>';
        if (dbConfig::defaultTracking()) {
            $returnStr .= '<li><a href="' . setSessionParams(array('page' => $refpage . '.tracking', 'primkey' => $respondentOrHousehold->getPrimkey())) . '"><span class="glyphicon glyphicon-road"></span> ' . Language::labelTracking() . '</a></li>';
        }
        $returnStr .= '<li><a href="' . setSessionParams(array('page' => $refpage . '.edit', 'primkey' => $respondentOrHousehold->getPrimkey())) . '"><span class="glyphicon glyphicon-pencil"></span> ' . Language::labelEdit() . '</a></li>

            </ul>

          </div><!--/.well -->

        </div><!--/span-->';
        return $returnStr;
    }
Пример #9
0
        $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>
';
        $returnStr .= '</p></div>    </div>';
        //container and wrap
        $returnStr .= $this->showBottomBar();
        $returnStr .= $this->showFooter(false);
        return $returnStr;
    }
    function showCalendar()
    {
        $header = '
  <link rel="stylesheet" href="bootstrap/css/sticky-footer-navbar.min.css">	
	<link rel="stylesheet" href="css/calendar.css">
 ';
        $returnStr = $this->showHeader(Language::messageSMSTitle(), $header);
Пример #10
0
function getCommunicationServer()
{
    $server = dbConfig::defaultCommunicationServer();
    if (is_array($server)) {
        //echo "dsadsadsadsa";
        return $server[$_SESSION['COMMSERVER']];
    }
    return $server;
}
Пример #11
0
    function ShowCommunicationServerOptions()
    {
        if (is_array(dbConfig::defaultCommunicationServer())) {
            $returnStr = '';
            $active = array('', '', '', '', '', '', '', '');
            //if ($_SESSION['COMMSERVER'] == ''){ //init in index.php
            //    $_SESSION['COMMSERVER'] = 0;
            //}
            if (loadvar('commserver') != '') {
                $_SESSION['COMMSERVER'] = loadvar('commserver');
            }
            $active[$_SESSION['COMMSERVER']] = ' active';
            $returnStr .= '<form method="post" id="hiddenform">';
            $returnStr .= setSessionParamsPost(array('page' => 'interviewer.sendreceive'));
            $returnStr .= '<input type="hidden" name="commserver" id="commserver" value="' . $paneltype . '">';
            $returnStr .= '<div id="commserverselector" class="btn-group">
  	    <button type="button" class="btn btn-default' . $active[0] . '" value=0>' . Language::labelCommServerLocal() . '</button>
	    <button type="button" class="btn btn-default' . $active[1] . '" value=1>' . Language::labelCommServerOutside() . '</button>';
            $returnStr .= '</div>';
            $returnStr .= '</form>';
            $returnStr .= '<br/>';
            $returnStr .= '<script>';
            $returnStr .= '$(\'#commserverselector button\').click(function() {
		  $(\'#commserverselector button\').addClass(\'active\').not(this).removeClass(\'active\');
		  $(\'#commserver\').val("0");
		  if ($(this).val() == "1") {
		    $(\'#commserver\').val("1");
		  }
                  $("#hiddenform").submit();            

 	  });';
            $returnStr .= '</script>';
        }
        return $returnStr;
    }
Пример #12
0
 function showOtherData()
 {
     global $db;
     $type = getFromSessionParams('type');
     if ($type != '') {
         $filename = '_' . date('YmdHis');
         $query = '';
         switch ($type) {
             case 1:
                 $filename = 'households' . $filename;
                 $query = 'select primkey,urid,puid,status,ts from ' . dbConfig::dbSurvey() . '_households where test = 0 order by primkey';
                 break;
             case 2:
                 $filename = 'respondents' . $filename;
                 $query = 'select primkey,hhid,urid,status,selected,present,hhhead,finr,famr,permanent,validation,ts from ' . dbConfig::dbSurvey() . '_respondents where test = 0 order by primkey';
                 break;
             case 3:
                 $filename = 'contacts' . $filename;
                 $query = 'select primkey,code,contactts,proxy,urid, aes_decrypt(remark, "' . Config::smsContactRemarkKey() . '") as remark, ts from ' . dbConfig::dbSurvey() . '_contacts where primkey not like "999%"';
                 break;
             case 4:
                 $filename = 'remarks' . $filename;
                 $query = 'select primkey,urid, aes_decrypt(remark, "' . Config::smsRemarkKey() . '") as remark, ts from ' . dbConfig::dbSurvey() . '_remarks where primkey not like "999%"';
                 break;
         }
         if ($query != '') {
             $result = $db->selectQuery($query);
             createCSV($result, $filename);
         }
     }
 }
Пример #13
0
 function showUnassignedSample($message = '')
 {
     $returnStr = $this->showHeader(Language::messageSMSTitle(), '<link href="bootstrap/css/sticky-footer-navbar.min.css" rel="stylesheet"><link href="css/uscicadmin.css" rel="stylesheet">');
     $returnStr .= '<div id="wrap"><br/><br/><br/>';
     $returnStr .= $this->showNavBar();
     $returnStr .= '<div class="container"><p>';
     //CONTENT
     if (dbConfig::defaultPanel() == PANEL_HOUSEHOLD) {
         $returnStr .= '<h4>' . Language::labelSupervisorUnassignedHouseholds() . '</h4>';
     } else {
         $returnStr .= '<h4>' . Language::labelSupervisorUnassignedRespondents() . '</h4>';
     }
     $returnStr .= $message;
     $displaySms = new DisplaySms();
     $returnStr .= $displaySms->showAvailableUnassignedHouseholds();
     //END CONTENT
     $returnStr .= '</p></div>    </div>';
     //container and wrap
     $returnStr .= $this->showBottomBar();
     $returnStr .= $this->showFooter();
     return $returnStr;
 }
Пример #14
0
 function showScriptUpdateRes()
 {
     /* update last page */
     $_SESSION['LASTPAGE'] = 'sysadmin.sms.update';
     $communication = new Communication();
     //load script in mysql (from /var/haalsi/scripts .. follow same directy structure
     //filename + content in _communication
     $files = array();
     $communication->getScriptFiles($files, '/var/haalsi/scripts');
     $displaySms = new DisplaySms();
     if (true || sizeof($files) > 0) {
         $selected = loadvar("iwers");
         //echo $selected;
         if (!is_array($selected)) {
             $selected = array($selected);
         }
         if (loadvar("iwers") == "") {
             $message = $displaySms->displayInfo(Language::labelSMSLaptopSelectInterviewers());
             return $displaySms->showScriptUpdate($message);
         } else {
             $users = new Users();
             $users = $users->getUsers();
             foreach ($files as $key => $file) {
                 //$message .= $key . ':' . $file . '<br/>';
                 foreach ($users as $user) {
                     if ($user->getUserType() == USER_INTERVIEWER) {
                         //interviewer: get update ready!
                         if (inArray($user->getUrid(), $selected) || inArray(-1, $selected)) {
                             //this should be per laptop (id on macaddress??), not interviewer
                             //$communication->addScriptToUser($key, $file, $user->getUrid());
                         }
                     }
                 }
                 //$communication->addScriptToUser($key, $file, 14);
             }
             $message = $displaySms->displaySuccess(Language::labelSMSLaptopScriptUpdateReady());
         }
     } else {
         $message = $displaySms->displayInfo(Language::labelSMSLaptopScriptUpdateNoFiles(dbConfig::defaultFileLocation()));
         return $displaySms->showScriptUpdate($message);
     }
     return $this->showMetaDataUpdate($message);
 }
Пример #15
0
/*
 ------------------------------------------------------------------------
 Copyright (C) 2014 Bart Orriens, Albert Weerman

 This library/program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

 This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

 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
 ------------------------------------------------------------------------
*/
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';
Пример #16
0
<?php

include "../../DAL/dbConfig.php";
try {
    $userName = htmlspecialchars($_POST["user"]);
    $password = htmlspecialchars($_POST["password"]);
    $sqli = dbConfig::connectDb();
    $error = false;
    // Check connection
    if ($sqli->connect_error) {
        $sqli->exit();
        $error = true;
    }
    //insert variables
    $Categorys = array();
    $IDs = array();
    $stmt = $sqli->prepare("CALL getCategorys();");
    if ($stmt->execute() === TRUE) {
        $stmt->bind_result($idCategory, $category);
        while ($stmt->fetch()) {
            $IDs[] = $idCategory;
            $Categorys[] = $category;
        }
    } else {
        $error = true;
    }
    $stmt->close();
    $sqli->close();
} catch (Exception $e) {
    $error = true;
}
Пример #17
0
 function getPreload($startArray = array())
 {
     //imported into survey from sms
     $preload = $startArray;
     $user = new User($_SESSION['URID']);
     $preload['urid'] = $user->getUrid();
     $preload['hhid'] = $this->getHhid();
     $preload['hhorder'] = $this->getHhOrder();
     $preload['RConsentType'] = $this->getConsentType();
     if (dbConfig::defaultPanel() == PANEL_HOUSEHOLD) {
         $preload['Village_Anon'] = $this->getHousehold()->getAddress1();
         $preload['DwellingId'] = $this->getHousehold()->getCity();
     } else {
         $preload['Village_Anon'] = $this->getAddress1();
         $preload['DwellingId'] = $this->getCity();
     }
     return $preload;
 }
Пример #18
0
 function getRespondentsByUser(User $user, $filter = 0)
 {
     global $db;
     $respondents = array();
     $test = ' and test = 0';
     // this can be the supervisor looking
     $currentUser = new User($_SESSION['URID']);
     if ($currentUser->isTestMode()) {
         $test = ' and test = 1';
     }
     if ($currentUser->getRegionFilter() > 0 && $currentUser->getPuid() > 0) {
         //only certain region
         $test = ' and puid = ' . $currentUser->getPuid();
     }
     $result = $db->selectQuery('select *, ' . $this->getDeIdentified() . ' from ' . Config::dbSurvey() . '_respondents where urid = ' . prepareDatabaseString($user->getUrid()) . $test);
     while ($row = $db->getRow($result)) {
         $respondents[] = new Respondent($row);
     }
     if ($currentUser->getTestMode() && sizeof($respondents) == 0 && $currentUser->getRegionFilter() <= 0) {
         //psu filter!!
         if ($currentUser->getUserType() == USER_INTERVIEWER) {
             //only add if interviewer!
             if (dbConfig::defaultPanel() != PANEL_HOUSEHOLD) {
                 //only if not household sample
                 $respondents = $this->addTestRespondents($user);
             }
         }
     }
     if ($filter > 0) {
         //a filter!!
         $respondents = $this->filterRespondents($respondents, $filter);
     }
     return $respondents;
 }
Пример #19
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);
     }
 }
Пример #20
0
    function showAvailableUnassignedHouseholds()
    {
        $refpage = 'sysadmin.sms.sample';
        $currentUser = new User($_SESSION['URID']);
        if ($currentUser->getUserType() == USER_SUPERVISOR) {
            $refpage = 'supervisor.unassignedsample';
        } elseif ($currentUser->getUserType() == USER_RESEARCHER) {
            $refpage = 'researcher.sample';
        }
        $returnStr = '';
        //select psu
        $puid = loadvar('puid', 0);
        $returnStr .= $this->showActionBar(Language::labelSMSFilterPSU(), $this->displayPsus($puid, true), Language::labelSMSFilterShow(), setSessionParamsPost(array('page' => $refpage)));
        if (dbConfig::defaultPanel() == PANEL_HOUSEHOLD) {
            $households = new Households();
            $unassignedRespondentOrHouseholds = $households->getUnassigned($puid);
        } else {
            $respondents = new Respondents();
            $unassignedRespondentOrHouseholds = $respondents->getUnassigned($puid);
        }
        if (sizeof($unassignedRespondentOrHouseholds) > 0) {
            $returnStr .= '<form method="post">';
            $returnStr .= setSessionParamsPost(array('page' => $refpage . '.assign'));
            $returnStr .= '<input type=hidden name=puid value="' . $puid . '">';
            $returnStr .= '<table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered" id="example">
	    <thead>
	      <tr>
		<th><label><input type="checkbox" id="checkAll"/> &nbsp;&nbsp;id</label></th>
		<th>Name</th>';
            //echo 'here';
            $columns = $this->defaultDisplayOverviewAddressColumns();
            foreach ($columns as $column) {
                $returnStr .= '<th>' . $column . '</th>';
            }
            $returnStr .= '    </tr>
	    </thead>
	    <tbody>';
            foreach ($unassignedRespondentOrHouseholds as $respondentOrHousehold) {
                $returnStr .= '<tr><td>';
                $returnStr .= '<label><input type=checkbox name="assignid[]" value="' . $respondentOrHousehold->getPrimkey() . '">&nbsp;&nbsp;';
                $returnStr .= $respondentOrHousehold->getPrimkey() . '</label></td>';
                $returnStr .= '<td>' . $respondentOrHousehold->getName() . '</td>';
                foreach ($columns as $key => $column) {
                    $returnStr .= '<td>' . $respondentOrHousehold->getDataByField($key) . '</td>';
                }
                $returnStr .= '</tr>';
            }
            $returnStr .= '</table>';
            $returnStr .= '<script>
$("#checkAll").change(function () {
    $("input:checkbox").prop("checked", $(this).prop("checked"));
});

</script>';
            $returnStr .= '<nav class="navbar navbar-default" role="navigation">';
            $returnStr .= '<div class="container-fluid"><div class="navbar-header">';
            $returnStr .= '<table><tr><td valign=top><img src="images/arrow_ltr.png"></td><td><a class="navbar-brand">assign selected to:</a></td></tr></table>';
            $returnStr .= '</div><div class="collapse navbar-collapse" id="bs-example-navbar-collapse-2">';
            $returnStr .= '<div class="navbar-form navbar-left">';
            $returnStr .= '<div class="form-group">';
            if ($currentUser->getUserType() == USER_SUPERVISOR) {
                $returnStr .= $this->displayInterviewerSelect(0, true);
            } else {
                $returnStr .= $this->displaySupervisorSelect();
            }
            $returnStr .= '</div>';
            $returnStr .= '<button type="submit" class="btn btn-default">' . Language::labelSMSButtonAssign() . '</button>';
            $returnStr .= '</div></form></div></div></nav>';
        } else {
            if ($refpage == 'sysadmin.sms.sample') {
                $returnStr .= $this->displayWarning(Language::labelSMSWarningNoSample());
            } else {
                if (dbConfig::defaultPanel() == PANEL_HOUSEHOLD) {
                    $returnStr .= $this->displayWarning(Language::labelSMSWarningNoUnassignedHouseholds());
                } else {
                    $returnStr .= $this->displayWarning(Language::labelSMSWarningNoUnassignedRespondents());
                }
            }
        }
        return $returnStr;
    }
Пример #21
0
 ------------------------------------------------------------------------
 Copyright (C) 2014 Bart Orriens, Albert Weerman

 This library/program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

 This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

 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);
require_once "constants.php";
require_once "functions.php";
require_once "dbConfig.php";
$loaded = dbConfig::load();
require_once "config.php";
// start session if installed
if ($loaded == 3) {
    session_set_cookie_params(0, getSessionPath());
    // set cookie path
    session_start();
}
if (isset($_POST[POST_PARAM_FULLRESET]) && is_Numeric($_POST[POST_PARAM_FULLRESET]) || isset($_GET[POST_PARAM_FULLRESET]) && is_Numeric($_GET[POST_PARAM_FULLRESET])) {
    //reset session!
    endSession();
    $param = '';
    if (isset($_GET[POST_PARAM_SE]) && is_Numeric($_GET[POST_PARAM_SE])) {
        if ($_GET[POST_PARAM_SE] > 1) {
            $param = '?' . POST_PARAM_SE . '=' . $_GET[POST_PARAM_SE];
        }
Пример #22
0
<?php

//incudes
include "includes/functions.php";
include "classes/config.php";
//connect to db
$db = new dbConfig();
$db->getDbParams();
//check new record
$record = $_GET['record'];
if ($record == 'yes') {
    //get player data
    $name = '\'' . substr(str_replace('\'', '', $_GET['name']), 0, 15) . '\'';
    $score = $_GET['score'];
    //use functions to insert new recordds and select top-10
    $result_insert = getInsert($db, $name, $score);
    $result_select = getSelect($db);
    // html
    echo "<table id=\"scoreTable\" >\n";
    while ($row = mysql_fetch_array($result_select, MYSQL_ASSOC)) {
        echo "\t<tr id='{$row['name']}'>\n";
        foreach ($row as $key => $value) {
            echo "\t\t<td>{$value}</td>\n";
        }
        echo "\t</tr>\n";
    }
    echo "</table>\n";
} else {
    if ($record == 'start') {
        //show highscores at new game
        //select top-10
Пример #23
0
 function db_connect(&$db_result, $object, $db_name = "")
 {
     //dev/live
     global $flag;
     global $g_db_info;
     $dbConfig = new dbConfig();
     $db_host = $dbConfig::DB_HOST;
     if ($db_name == "") {
         $db_name = $dbConfig::DB_DATABASE_01;
     }
     $db_con_array = $dbConfig->getDBconnection();
     if (array_key_exists($db_name, $db_con_array)) {
         $db_user = $db_con_array[$db_name]['username'];
         $db_password = $db_con_array[$db_name]['password'];
     }
     $db_result = mysqli_connect($db_host, $db_user, $db_password, $db_name);
     if (!$db_result) {
         die('Could not connect: ' . mysqli_connect_error());
         //mail to admin@pbmarketing.ca
         $to = "*****@*****.**";
         $subject = "The form in " . $_SERVER['SERVER_NAME'] . " Is Broken";
         $message = "\n\t\t\t<html>\n\t\t\t<head>\n\t\t\t<title>" . $subject . "</title>\n\t\t\t</head>\n\t\t\t<body>\n\t\t\t<p>The registration form has lost the database connection. Please check and resolve the issue.</p>\n\t\t\t<p>Regards,<br>PB marketing Support</p>\n\t\t\t</body>\n\t\t\t</html>\n\t\t\t";
         // Always set content-type when sending HTML email
         $headers = "MIME-Version: 1.0" . "\r\n";
         $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
         // More headers
         $headers .= 'From: <*****@*****.**>' . "\r\n";
         $headers .= 'Cc: admin@pbmarketing.ca' . "\r\n";
         mail($to, $subject, $message, $headers);
     }
     if (is_array($object)) {
         // array of object
         $count = 0;
         $table_name = array();
         $table = array();
         foreach ($object as $obj_key => $obj_val) {
             if (is_array($g_db_info) && !array_key_exists($obj_key, $g_db_info) || !$g_db_info) {
                 $table_name[$count] = $obj_key;
                 if ($flag == "live") {
                     $table[$count] = $obj_key;
                 } elseif ($flag == "dev") {
                     $table[$count] = $obj_key . "_debug";
                 }
                 $count++;
             }
         }
         //end of foreach
         $n = count($table);
         for ($i = 0; $i < $n; $i++) {
             $sql = "SHOW COLUMNS FROM " . $db_name . "." . $table[$i];
             $result = mysqli_query($db_result, $sql);
             $num = mysqli_num_rows($result);
             $field_name = array();
             $t = 0;
             while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
                 $field_name[$t] = $row['Field'];
                 $t++;
             }
             $g_db_info[$table_name[$i]] = array('no' => $num, 'name' => $field_name, 'table' => $table[$i]);
         }
         //end of for loop
     } else {
         // object - not array
         $table_name = $object;
         if ($flag == "live") {
             $table = $object;
         } elseif ($flag == "dev") {
             $table = $object . "_debug";
         }
         $sql = "SHOW COLUMNS FROM " . $db_name . "." . $table;
         $result = mysqli_query($db_result, $sql);
         $num = mysqli_num_rows($result);
         $field_name = array();
         $t = 0;
         while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
             $field_name[$t] = $row['Field'];
             $t++;
         }
         $g_db_info[$table_name] = array('no' => $num, 'name' => $field_name, 'table' => $table);
     }
     return true;
 }
Пример #24
0
 function showEditRes($primkey, $type = 1)
 {
     if ($type == 1) {
         $respondent = new Respondent($primkey);
         $respondent->setFirstName(loadvar('firstname'));
         $respondent->setLastName(loadvar('lastname'));
     } else {
         $respondent = new Household($primkey);
         $respondent->setName(loadvar('name'));
         $respondent->setAddress1(loadvar('address1'));
         $respondent->setAddress2(loadvar('address2'));
         $respondent->setZip(loadvar('zip'));
         $respondent->setCity(loadvar('city'));
     }
     if (dbConfig::defaultPanel() == PANEL_RESPONDENT) {
         //only save for respondent panels
         $respondent->setAddress1(loadvar('address1'));
         $respondent->setAddress2(loadvar('address2'));
         $respondent->setZip(loadvar('zip'));
         $respondent->setCity(loadvar('city'));
     }
     $respondent->setTelephone1(loadvar('telephone1'));
     //$respondent->setTelephone2(loadvar('telephone2'));
     $respondent->setEmail(loadvar('email'));
     //log???
     $errorMessage = $respondent->saveChanges();
     $display = new Display();
     $messageEditError = $display->displaySuccess(Language::messageRespondentChanged($respondent));
     //'<div class="alert alert-info">Changes saved.</div>';
     if (sizeof($errorMessage) > 0) {
         $messageEditError = $display->displayError(implode('<br/>', $errorMessage));
     }
     $displayInterviewer = new DisplayInterviewer();
     return $displayInterviewer->showInfo($respondent, $messageEditError);
 }