Example #1
0
function getLevelOneMenu($text)
{
    switch (strtolower($text)) {
        case 1:
            $response = "1. Request Loan" . PHP_EOL;
            $response .= "2. Pay Loan";
            break;
        case 2:
            $response = "Your balance is Ksh. 235. Thanks for using MShwari";
            sendOutput($response, 2);
            break;
        default:
            $response = "We could not understand your response";
            break;
    }
    return $response;
}
    case 'update':
        $elementArray = $queryObj->parameters->data->folderArray;
        $applicationId = $queryObj->parameters->data->applicationId;
        // get all of the users applications
        $allowedApplicationArray = $user->getApplicationsByPermission(0);
        if (in_array($applicationId, $allowedApplicationArray)) {
            $sql = "DELETE FROM gui_treegde WHERE fkey_gui_id = \$1";
            $v = array($applicationId);
            $t = array("s");
            $res = db_prep_query($sql, $v, $t);
            $rowArray = array();
            for ($i = 0; $i < count($elementArray); $i++) {
                $currentElement = $elementArray[$i];
                $sql = "INSERT INTO gui_treegde (fkey_gui_id, lft, rgt, " . "my_layer_title, wms_id) VALUES (\$1, \$2, \$3, \$4, \$5)";
                $v = array($applicationId, $currentElement->left, $currentElement->right, $currentElement->name, $currentElement->wms);
                $t = array("s", "i", "i", "s", "s");
                $res = db_prep_query($sql, $v, $t);
                $rowArray[] = $v;
            }
            $data = array("sql" => $sql, "data" => $rowArray);
            $resultObj["data"] = $data;
            $resultObj["success"] = "Elements have been updated in the database.";
        }
        break;
        // Invalid command
    // Invalid command
    default:
        $resultObj["error"] = "no action specified...";
}
sendOutput($resultObj);
    // This is the first request. Note how we start the response with CON
    $response = "Please enter Staff ID";
    sendOutput($response, 1);
} else {
    //receive what Edwin has sent in as text
    $id = $input['text'];
    $leo = array('name' => 'Leo', 'staff_id' => 1234);
    $macharia = array('name' => 'Macharia', 'staff_id' => 12345);
    $kevin = array('name' => 'Kevin', 'staff_id' => 231);
    $staff = array('1234' => $leo, '12345' => $macharia, '231' => $kevin);
    if (!empty($staff[$id])) {
        $message = "ID is valid and it belongs to " . $staff[$id]['name'];
    } else {
        $message = "No Staff with that id";
    }
    sendOutput($message, 2);
}
//verify if the id belongs to one of the staff members
function getInput()
{
    $input = array();
    $input['sessionId'] = $_REQUEST["sessionId"];
    $input['serviceCode'] = $_REQUEST["serviceCode"];
    $input['phoneNumber'] = $_REQUEST["phoneNumber"];
    $input['text'] = $_REQUEST["text"];
    return $input;
}
function sendOutput($message, $type = 2)
{
    //Type 1 is a continuation, type 2 output is an end
    if ($type == 1) {
        sendOutput($obj);
        break;
    case 'getWfsConfData':
        $obj->wfsConf = getWfsConfData($obj->wfs);
        sendOutput($obj);
        break;
    case 'getAssignedGuis':
        $obj->assignedGuis = getAssignedGuis($obj);
        sendOutput($obj);
        break;
    case 'deleteSelectedConfs':
        deleteWfsConf($obj);
        sendOutput($obj);
        break;
    default:
        sendOutput("no action specified...");
}
/*
 * Get all services (ids and titles) where the current user is owner
 * 
 * @return mixed[] services the ids and titles of the services
 */
function getServices()
{
    global $con;
    $services = array();
    $services['id'] = array();
    $services['title'] = array();
    $adm = new administration();
    $serviceList = $adm->getWfsByOwner(Mapbender::session()->get("mb_user_id"));
    if (count($serviceList) == 0) {
Example #5
0
function getMenu4($text)
{
    switch ($text) {
        case 1:
            $response = "Hard work Pays";
            sendOutput($response, 2);
            break;
        case 2:
            $response = "Go for what your instinct tells you";
            sendOutput($response, 2);
            break;
    }
}
Example #6
0
require_once 'connect.php';
//Dog
//get users phone
$phone = $_REQUEST['from'];
createUser($phone);
//get users message
$message = $_REQUEST['message'];
$result = checkForMessage($message, $phone);
saveMessage($message, $phone);
//check if the users message is dog
if (trim(strtolower($message)) == 'dog') {
    $reply = "A dog is a domestic animal";
} else {
    $reply = "We don't know what animal that is";
}
sendOutput($reply, $phone);
exit;
function createUser($phone)
{
    //check if the phone number exists
    $query = mysql_query("SELECT phone FROM users WHERE phone='{$phone}'");
    if (mysql_num_rows($query) > 0) {
        //do nothing
    } else {
        //create the user
        $query = mysql_query("INSERT INTO users (phone) VALUES ('{$phone}')");
    }
    return $query;
}
function saveMessage($message, $phone)
{
Example #7
0
function getLevelThreeMenu($input)
{
    switch ($input) {
        case 1:
        case 2:
            $response = "Request received we'll get back to you. Thankyou for ur cooperation.";
            sendOutput($input, 2);
            break;
        default:
            getLevelTwoMenu();
            break;
    }
}
Example #8
0
$lat = floatval(mosGetParam($_GET, "lat", 0));
$long = floatval(mosGetParam($_GET, "long", 0));
$cityid = intval(mosGetParam($_GET, "cityid", 0));
if ($cityid > 0) {
    $query = "SELECT id, 0 as dist\r\n\t\t\tFROM #__city\r\n\t\t\tWHERE id=" . dbQuote($cityid) . "\r\n\t\t\tLIMIT 1";
    $rdDb->setQuery($query);
    $o = $_cache['query']->call("rdDb->loadObjectList", "", "", $query);
} else {
    $query = "SELECT cityid, (ABS(`long`-{$long})+ABS(`lat`-{$lat})) as dist\r\n\t\t\tFROM #__city_ll\r\n\t\t\tORDER BY dist ASC\r\n\t\t\tLIMIT 1";
    $rdDb->setQuery($query);
    $o = $_cache['query']->call("rdDb->loadObjectList", "", "", $query);
}
$o = reset($o);
if ($o->cityid && $o->dist < 1) {
    $city = heGeo::getCity($o->cityid, 1);
    echo "<p>Ваш город ";
    echo "<strong>";
    echo $city->params['small_name_imen'];
    echo "</strong>?";
    echo "</p>";
    echo "<div id=\"mn_city_popup_buttons\">";
    echo "<a href=\"#\" class=\"btn btn_color yes\" data-cityid=\"{$o->cityid}\">Да</a>";
    echo "<a href=\"http://cp.mnogonado.net/c/?c=cityPopupChoose&d={$city->params['main_site']}\" class=\"btn btn_color go\">Перейти</a>";
    echo "<a href=\"#\" class=\"no cancel\" data-cityid=\"{$o->cityid}\">Нет</a>";
    //	echo "<a href=\"#\" class=\"cancel\">Нет</a>";
    echo "</div>";
} else {
    mosRedirect("/", 404);
}
sendOutput();
Example #9
0
 /**
  * Check file attributes before uplaoding the file
  *
  * @param file $file - the file
  *
  * @set $this->_file_
  *
  * @use $this->checkFileSize()
  * @use $this->checkFileExtention()
  * @use $this->checkFileType()
  * @use $this->sendOutput()
  * @use $this->prepareUpload()
  *
  */
 private function checkFile($file = null)
 {
     if ($file == null) {
         sendOutput('File not sent');
     }
     $this->_file_ = $file;
     $errors = array();
     array_push($errors, $this->checkFileSize());
     array_push($errors, $this->checkFileExtention());
     array_push($errors, $this->checkFileType());
     if (in_array(0, $errors)) {
         $this->sendOutput('File triggered errors.');
     } else {
         $this->prepareUpload();
     }
 }
Example #10
0
function getdominantcolor()
{
    global $conn;
    $image = varRequest('image', '');
    if ($image == "") {
        sendOutput(getError('No image sent'));
    }
    $idSetProcess = 20;
    $x_processId = rand_str(12);
    $image_url = urlencode($image);
    $command = "http://localhost/eutv-tools/process/service/lib/ExtractImageDominantColor.php?image={$image_url}";
    $sSqlWrk = "INSERT INTO process ( `processId`, `idSetProcess`, `idProcessStatus`, `start`, `end`, `OSProcessId`, `command`) VALUES" . "('" . $x_processId . "', " . $idSetProcess . ", 1, NULL, NULL, NULL, '{$command}');";
    $rswrk = $conn->Execute($sSqlWrk);
    $idProcess = $conn->Insert_ID();
    $sSqlWrk = "UPDATE process SET command = '{$command}&pid={$idProcess}' WHERE idProcessNum = '{$idProcess}'";
    $conn->Execute($sSqlWrk);
    sendOutput(getProcessStarted($idProcess));
}
Example #11
0
function getMenu2($message, $phoneNumber)
{
    createStaff($message, $phoneNumber);
    sendOutput($response, 1);
}
Example #12
0
 public function index()
 {
     $result = $this->getLevel($text);
     $level = $result['level'];
     $message = $result['latest_message'];
     switch (strtolower($level)) {
         case 0:
             $response = $this->getHomeMenu();
             break;
         case 1:
             $response = $this->getLevelOneMenu($message);
             break;
         case 2:
             $response = $this->getLevelOneMenu($message);
             break;
         default:
             $response = $this->getHomeMenu();
             break;
     }
     sendOutput($response, 1);
     exit;
     $exploded_text = explode('*', $text);
     print_r($exploded_text);
     //LEVEL 1
     $input = getInput();
     if ($input['text'] == "") {
         //this is the first request
         $this->getHomeMenu();
         $this->sendOutput($response, 1);
     } else {
         switch (strtolower($input['text'])) {
             case 1:
                 //English Version
                 //check if user already exits
                 $tel_no = $this->UserTable->get_user_telephone_no($phonenumber);
                 if ($tel_no == '1') {
                     $this->getLevelOneMenuEnglish();
                 }
                 //if no user detected proceed to registration process
                 if ($tel_no < 1 && $tel_no == '0') {
                     $this->registration();
                 }
                 if ($tel_no == '1') {
                     $this->getLevelOneMenuEnglish();
                 }
                 break;
             case 2:
                 //Kiswahili Version
                 $tel_no = $this->UserTable->get_user_telephone_no($phonenumber);
                 if ($tel_no == '1') {
                     $this->getLevelOneMenuKiswahili();
                 }
                 if ($tel_no < 1 && $tel_no == '0') {
                     $this->registrationKiswahili();
                 }
                 if ($tel_no == '1') {
                     $this->getLevelOneMenuKiswahili();
                 }
                 break;
             default:
                 $response = "Please try again later/Tafadhali jaribu badaaye ";
                 break;
         }
     }
 }
Example #13
0
function stopThisProcess($stop_message) {
//Graceful Stop

global $log_result;
global $log_result_file;
global $pid;
global $phpcron_off;
global $phpcron_psinfo_file;
global $daemon_mode;
/* Only do this if this process is running as a daemon.
Don't want to log start/stops if only running once */
sendOutput($stop_message."\r\n", true);

if($daemon_mode) {

  $stop_time= date("m/d/Y").":".date("h:i:s:A");

  if ($log_result) {
  $stop_message="
***********************************************************
PHPCRON (DAEMON) $pid Stopped $stop_time

Final Output Message:
".strip_tags($stop_message)."
***********************************************************
";

  appendToFile("$stop_message", $log_result_file);
  }

  deleteFile($phpcron_off);

}

deleteFile($phpcron_psinfo_file);
deleteFile("$TEMP_DIR/".basename($phpcron_psinfo_file));



exit;

}
Example #14
0
function verifyPatient($text, $patient, $input)
{
    /*if(!empty($text)){
    
            $message= "Mr/Ms".$patient[$text]['name'];
            //if patient exist
            if($message==$patient[$text]['name']){
                // proceed
                $response = "those are you exams details".$message;
                    sendOutput($response,2);
    
    
            }
            /* else{
                 $response = gethealservicemenu($message);
             }
    
        }else{
            $response =  "You are a not yet reigisted at Nairobi hospital please contact  the registration office";
        }/
    
        //$response .= "2. Exit";
        sendOutput($response,2);*/
    if ($input['text'] == "") {
        // This is the first request. Note how we start the response with CON
        $response = "Enter your  ID please!!!";
        sendOutput($response, 1);
    } else {
        //receive what Edwin has sent in as text
        $text = $input['text'];
        $patient1 = array('name' => 'JAMES', 'staff_id' => 1234);
        $patient2 = array('name' => 'LEWIS', 'staff_id' => 12345);
        $patient3 = array('name' => 'CHARLES', 'staff_id' => 231);
        $patient = array('1234' => $patient1, '12345' => $patient2, '231' => $patient3);
        if (!empty($patient[$text])) {
            $message = "ID is valid and it belongs to " . $patient[$text]['name'];
        } else {
            $message = "No patient with that id";
        }
    }
    //verify if the id belongs to one of the staff members
    /*function getInput(){
        $input = array();
        $input['sessionId']   = $_REQUEST["sessionId"];
        $input['serviceCode'] = $_REQUEST["serviceCode"];
        $input['phoneNumber'] = $_REQUEST["phoneNumber"];
        $input['text']        = $_REQUEST["text"];
    
        return $input;
    
    }*/
}
Example #15
0
function getLevelFiveMenu()
{
    $response = "Thank you for using our system!";
    //$text.
    sendOutput($response, 2);
    return $response;
}
Example #16
0
function checkPhpVersion ($version_required, $warning_string="/", $quit=false) {


$version_installed=phpversion();
/*Break Up $version_required string by decimal point*/
$version_required=explode(".", $version_required);

if (!ereg( "[[$version_required[0]-9]\.[$version_required[1]-9]\.[$version_required[2]-9].*", $version_installed )){

 if ($warning_string !="/") {
    sendOutput($warning_string);
  }
  if ($quit) {
  
  exit;
  }

  return false;
exit;
} else {

return true;
}



}