예제 #1
0
 function SQLWhere($SearchFor, $strSearchOption, $SearchFor2, $etype, $isSuggest)
 {
     $hasDigits = false;
     for ($i = 0; $i < strlen($SearchFor); $i++) {
         if (is_numeric($SearchFor[$i])) {
             $hasDigits = true;
             break;
         }
     }
     if (!$hasDigits) {
         for ($i = 0; $i < strlen($SearchFor2); $i++) {
             if (is_numeric($SearchFor2[$i])) {
                 $hasDigits = true;
                 break;
             }
         }
     }
     if (!$hasDigits) {
         return "";
     }
     //$SearchFor = $this->prepare_datetime_for_search($SearchFor);
     if ($SearchFor == "") {
         return "";
     }
     //$SearchFor2 = $this->prepare_datetime_for_search($SearchFor2);
     $SearchFor = prepare_for_db($this->field, $SearchFor, "time");
     $SearchFor2 = prepare_for_db($this->field, $SearchFor2, "time");
     return parent::SQLWhere($SearchFor, $strSearchOption, $SearchFor2, $etype, $isSuggest);
 }
 //	processibng Customer Type - end
 //	insert masterkey value if exists and if not specified
 if (@$_SESSION[$sessionPrefix . "_mastertable"] == "dbo.LU_Customer Type") {
     if (postvalue("masterkey1")) {
         $_SESSION[$sessionPrefix . "_masterkey1"] = postvalue("masterkey1");
     }
     if ($avalues["Customer Type"] == "") {
         $avalues["Customer Type"] = prepare_for_db("Customer Type", $_SESSION[$sessionPrefix . "_masterkey1"]);
     }
 }
 if (@$_SESSION[$sessionPrefix . "_mastertable"] == "dbo.LU_Locations") {
     if (postvalue("masterkey1")) {
         $_SESSION[$sessionPrefix . "_masterkey1"] = postvalue("masterkey1");
     }
     if ($avalues["Location"] == "") {
         $avalues["Location"] = prepare_for_db("Location", $_SESSION[$sessionPrefix . "_masterkey1"]);
     }
 }
 $failed_inline_add = false;
 //	add filenames to values
 foreach ($afilename_values as $akey => $value) {
     $avalues[$akey] = $value;
 }
 //	before Add event
 $retval = true;
 if ($eventObj->exists("BeforeAdd")) {
     $retval = $eventObj->BeforeAdd($avalues, $usermessage, (bool) $inlineadd);
 }
 if ($retval && $pageObject->isCaptchaOk) {
     $_SESSION[$strTableName . "_count_captcha"] = $_SESSION[$strTableName . "_count_captcha"] + 1;
     if (DoInsertRecord($strOriginalTableName, $avalues, $blobfields, $id, $pageObject)) {
예제 #3
0
 //	processing inserts - end
 //	insert masterkey value if exists and if not specified
 if (@$_SESSION[$sessionPrefix . "_mastertable"] == "app.groups") {
     if (postvalue("masterkey1")) {
         $_SESSION[$sessionPrefix . "_masterkey1"] = postvalue("masterkey1");
     }
     if ($avalues["group_id"] == "") {
         $avalues["group_id"] = prepare_for_db("group_id", $_SESSION[$sessionPrefix . "_masterkey1"]);
     }
 }
 if (@$_SESSION[$sessionPrefix . "_mastertable"] == "app.modules") {
     if (postvalue("masterkey1")) {
         $_SESSION[$sessionPrefix . "_masterkey1"] = postvalue("masterkey1");
     }
     if ($avalues["module_id"] == "") {
         $avalues["module_id"] = prepare_for_db("module_id", $_SESSION[$sessionPrefix . "_masterkey1"]);
     }
 }
 $failed_inline_add = false;
 //	add filenames to values
 foreach ($afilename_values as $akey => $value) {
     $avalues[$akey] = $value;
 }
 //	before Add event
 $retval = true;
 if ($eventObj->exists("BeforeAdd")) {
     $retval = $eventObj->BeforeAdd($avalues, $usermessage, (bool) $inlineadd, $pageObject);
 }
 if ($retval && $pageObject->isCaptchaOk) {
     //add or set updated lat-lng values for all map fileds with 'UpdateLatLng' ticked
     setUpdatedLatLng($avalues, $pageObject->cipherer->pSet);
 }
 //	processing updated - end
 //	processing created - start
 $inlineAddOption = true;
 if ($inlineAddOption) {
     $control_created = $pageObject->getControl("created", $id);
     $control_created->readWebValue($avalues, $blobfields, "", false, $afilename_values);
 }
 //	processing created - end
 //	insert masterkey value if exists and if not specified
 if (@$_SESSION[$sessionPrefix . "_mastertable"] == "pad.pad_reklame_kelas_jalan") {
     if (postvalue("masterkey1")) {
         $_SESSION[$sessionPrefix . "_masterkey1"] = postvalue("masterkey1");
     }
     if ($avalues["jalan_kelas_id"] == "") {
         $avalues["jalan_kelas_id"] = prepare_for_db("jalan_kelas_id", $_SESSION[$sessionPrefix . "_masterkey1"]);
     }
 }
 $failed_inline_add = false;
 //	add filenames to values
 foreach ($afilename_values as $akey => $value) {
     $avalues[$akey] = $value;
 }
 //	before Add event
 $retval = true;
 if ($eventObj->exists("BeforeAdd")) {
     $retval = $eventObj->BeforeAdd($avalues, $usermessage, (bool) $inlineadd, $pageObject);
 }
 if ($retval && $pageObject->isCaptchaOk) {
     //add or set updated lat-lng values for all map fileds with 'UpdateLatLng' ticked
     setUpdatedLatLng($avalues, $pageObject->cipherer->pSet);
     }
     if ($value !== false) {
         if (0 && "Location" == "Password" && $url_page == "admin_users_") {
             $value = md5($value);
         }
         $evalues["Location"] = $value;
     }
 }
 //	processing Location - end
 //	processing Customer Type - begin
 $condition = 1;
 if ($condition) {
     $value = postvalue("value_Customer_Type_" . $id);
     $type = postvalue("type_Customer_Type_" . $id);
     if (FieldSubmitted("Customer Type_" . $id)) {
         $value = prepare_for_db("Customer Type", $value, $type);
     } else {
         $value = false;
     }
     if ($value !== false) {
         if (0 && "Customer Type" == "Password" && $url_page == "admin_users_") {
             $value = md5($value);
         }
         $evalues["Customer Type"] = $value;
     }
 }
 //	processing Customer Type - end
 foreach ($efilename_values as $ekey => $value) {
     $evalues[$ekey] = $value;
 }
 if ($pageObject->lockingObj) {
     }
     if (!($value === false)) {
         if (0 && "Bill Amount" == "Password" && $url_page == "admin_users_") {
             $value = md5($value);
         }
         $avalues["Bill Amount"] = $value;
     }
 }
 //	processibng Bill Amount - end
 //	processing Due Date - start
 $inlineAddOption = true;
 if ($inlineAddOption) {
     $value = postvalue("value_Due_Date_" . $id);
     $type = postvalue("type_Due_Date_" . $id);
     if (FieldSubmitted("Due Date_" . $id)) {
         $value = prepare_for_db("Due Date", $value, $type);
     } else {
         $value = false;
     }
     if (!($value === false)) {
         if (0 && "Due Date" == "Password" && $url_page == "admin_users_") {
             $value = md5($value);
         }
         $avalues["Due Date"] = $value;
     }
 }
 //	processibng Due Date - end
 $failed_inline_add = false;
 //	add filenames to values
 foreach ($afilename_values as $akey => $value) {
     $avalues[$akey] = $value;
예제 #7
0
파일: Control.php 프로젝트: kcallow/MatchMe
 /**
  * Get the WHERE clause conditions string for the search or suggest SQL query
  * @param String SearchFor
  * @param String strSearchOption
  * @param String SearchFor2
  * @param String etype
  * @param Boolean isSuggest
  */
 function SQLWhere($SearchFor, $strSearchOption, $SearchFor2, $etype, $isSuggest)
 {
     $baseResult = $this->baseSQLWhere($strSearchOption);
     if ($baseResult === false) {
         return "";
     }
     if ($baseResult != "") {
         return $baseResult;
     }
     if (!strlen($SearchFor)) {
         return "";
     }
     $value1 = $this->pageObject->cipherer->MakeDBValue($this->field, $SearchFor, $etype, true);
     $value2 = false;
     $cleanvalue2 = false;
     if ($strSearchOption == "Between") {
         $cleanvalue2 = prepare_for_db($this->field, $SearchFor2, $etype);
         $value2 = make_db_value($this->field, $SearchFor2, $etype);
     }
     if ($strSearchOption != "Contains" && $strSearchOption != "Starts with" && ($value1 === "null" || $value2 === "null") && !$this->pageObject->cipherer->isFieldPHPEncrypted($this->field)) {
         return "";
     }
     if (($strSearchOption == "Contains" || $strSearchOption == "Starts with") && !$this->isStringValidForLike($SearchFor)) {
         return "";
     }
     $searchIsCaseInsensitive = $this->pageObject->pSetEdit->getNCSearch();
     if (IsCharType($this->type) && !$this->btexttype) {
         $gstrField = $this->getFieldSQLDecrypt();
         if (!$this->pageObject->cipherer->isFieldPHPEncrypted($this->field) && $searchIsCaseInsensitive) {
             $value1 = $this->connection->upper($value1);
             $value2 = $this->connection->upper($value2);
             $gstrField = $this->connection->upper($gstrField);
         }
     } elseif ($strSearchOption == "Contains" || $strSearchOption == "Starts with") {
         $gstrField = $this->connection->field2char($this->getFieldSQLDecrypt(), $this->type);
     } elseif ($this->pageObject->pSetEdit->getViewFormat($this->field) == FORMAT_TIME) {
         $gstrField = $this->connection->field2time($this->getFieldSQLDecrypt(), $this->type);
     } else {
         $gstrField = $this->getFieldSQLDecrypt();
     }
     if ($strSearchOption == "Contains") {
         if ($this->pageObject->cipherer->isFieldPHPEncrypted($this->field)) {
             return $gstrField . "=" . $this->pageObject->cipherer->MakeDBValue($this->field, $SearchFor);
         }
         $SearchFor = $this->connection->escapeLIKEpattern($SearchFor);
         if (IsCharType($this->type) && !$this->btexttype && $searchIsCaseInsensitive) {
             return $gstrField . " " . $this->like . " " . $this->connection->upper($this->connection->prepareString("%" . $SearchFor . "%"));
         }
         return $gstrField . " " . $this->like . " " . $this->connection->prepareString("%" . $SearchFor . "%");
     }
     if ($strSearchOption == "Equals") {
         return $gstrField . "=" . $value1;
     }
     if ($strSearchOption == "Starts with") {
         $SearchFor = $this->connection->escapeLIKEpattern($SearchFor);
         if (IsCharType($this->type) && !$this->btexttype && $searchIsCaseInsensitive) {
             return $gstrField . " " . $this->like . " " . $this->connection->upper($this->connection->prepareString($SearchFor . "%"));
         }
         return $gstrField . " " . $this->like . " " . $this->connection->prepareString($SearchFor . "%");
     }
     if ($strSearchOption == "More than") {
         return $gstrField . ">" . $value1;
     }
     if ($strSearchOption == "Less than") {
         return $gstrField . "<" . $value1;
     }
     if ($strSearchOption == "Equal or more than") {
         return $gstrField . ">=" . $value1;
     }
     if ($strSearchOption == "Equal or less than") {
         return $gstrField . "<=" . $value1;
     }
     if ($strSearchOption == "Between") {
         $ret = $gstrField . ">=" . $value1 . " and ";
         if (IsDateFieldType($this->type)) {
             $timeArr = db2time($cleanvalue2);
             // for dates without time, add one day
             if ($timeArr[3] == 0 && $timeArr[4] == 0 && $timeArr[5] == 0) {
                 $timeArr = adddays($timeArr, 1);
                 $value2 = $timeArr[0] . "-" . $timeArr[1] . "-" . $timeArr[2];
                 $value2 = add_db_quotes($this->field, $value2, $this->pageObject->tName);
                 $ret .= $gstrField . "<" . $value2;
             } else {
                 $ret .= $gstrField . "<=" . $value2;
             }
         } else {
             $ret .= $gstrField . "<=" . $value2;
         }
         return $ret;
     }
     return "";
 }
    if ($pageObject->captchaExists()) {
        $pageObject->doCaptchaCode();
    }
}
// insert new record if we have to
if (@$_POST["a"] == "added") {
    $afilename_values = array();
    $avalues = array();
    $blobfields = array();
    //	processing Type - start
    $inlineAddOption = true;
    if ($inlineAddOption) {
        $value = postvalue("value_Type_" . $id);
        $type = postvalue("type_Type_" . $id);
        if (FieldSubmitted("Type_" . $id)) {
            $value = prepare_for_db("Type", $value, $type);
        } else {
            $value = false;
        }
        if (!($value === false)) {
            if (0 && "Type" == "Password" && $url_page == "admin_users_") {
                $value = md5($value);
            }
            $avalues["Type"] = $value;
        }
    }
    //	processibng Type - end
    $failed_inline_add = false;
    //	add filenames to values
    foreach ($afilename_values as $akey => $value) {
        $avalues[$akey] = $value;
     }
     if ($value !== false) {
         if (0 && "IsSync" == "Password" && $url_page == "admin_users_") {
             $value = md5($value);
         }
         $evalues["IsSync"] = $value;
     }
 }
 //	processing IsSync - end
 //	processing Currunt Readings - begin
 $condition = 1;
 if ($condition) {
     $value = postvalue("value_Currunt_Readings_" . $id);
     $type = postvalue("type_Currunt_Readings_" . $id);
     if (FieldSubmitted("Currunt Readings_" . $id)) {
         $value = prepare_for_db("Currunt Readings", $value, $type);
     } else {
         $value = false;
     }
     if ($value !== false) {
         if (0 && "Currunt Readings" == "Password" && $url_page == "admin_users_") {
             $value = md5($value);
         }
         $evalues["Currunt Readings"] = $value;
     }
 }
 //	processing Currunt Readings - end
 foreach ($efilename_values as $ekey => $value) {
     $evalues[$ekey] = $value;
 }
 if ($pageObject->lockingObj) {
예제 #10
0
 /**
  * @param String field
  * @param Mixed value
  * @param String controltype (optional)
  * @param Boolean phpEncryptionOnly (optional)
  */
 public function MakeDBValue($field, $value, $controltype = "", $phpEncryptionOnly = false)
 {
     $ret = prepare_for_db($field, $value, $controltype, "", $this->strTableName);
     if ($ret === false) {
         return $ret;
     }
     $ret = add_db_quotes($field, $this->EncryptField($field, $ret), $this->strTableName);
     if ($phpEncryptionOnly) {
         return $ret;
     }
     return $this->EncryptValueByDB($field, $ret);
 }
 /**
  * Get the date slider's where
  * @return string
  */
 static function getDateSliderWhere($fName, $pSet, $cipherer, $table, $SearchFor, $SearchFor2, $strSearchOption, $fullFieldName)
 {
     $firstDelimPos = strpos($SearchFor, "-");
     $lastDelimPos = strrpos($SearchFor, "-");
     if ($firstDelimPos === FALSE || $firstDelimPos == $lastDelimPos) {
         return "";
     }
     $stepType = $pSet->getFilterStepType($fName);
     $timeValueEnvolved = false;
     if ($stepType == FSST_SECONDS || $stepType == FSST_MINUTES || $stepType == FSST_HOURS) {
         $timeValueEnvolved = true;
     }
     $value1 = $cipherer->MakeDBValue($fName, $SearchFor, "", true);
     switch ($strSearchOption) {
         case "slider":
             $firstDelimPos = strpos($SearchFor2, "-");
             $lastDelimPos = strrpos($SearchFor2, "-");
             if ($firstDelimPos === FALSE || $firstDelimPos == $lastDelimPos) {
                 return "";
             }
             $cleanvalue2 = prepare_for_db($fName, $SearchFor2, "");
             $timeArr = db2time($cleanvalue2);
             if (!$timeValueEnvolved) {
                 // for dates without time, add one day
                 $timeArr = adddays($timeArr, 1);
                 $value2 = $timeArr[0] . "-" . $timeArr[1] . "-" . $timeArr[2];
             } else {
                 if ($stepType == FSST_SECONDS) {
                     $timeArr = addSeconds($timeArr, 1);
                 } else {
                     $timeArr = addMinutes($timeArr, 1);
                 }
                 $dateString = $timeArr[0] . "-" . $timeArr[1] . "-" . $timeArr[2];
                 $hours = $timeArr[3] < 10 ? '0' . $timeArr[3] : $timeArr[3];
                 $minutes = $timeArr[4] < 10 ? '0' . $timeArr[4] : $timeArr[4];
                 $seconds = $timeArr[5] < 10 ? '0' . $timeArr[5] : $timeArr[5];
                 $timeString = $hours . ":" . $minutes . ":" . $seconds;
                 $value2 = $dateString . " " . $timeString;
             }
             $value2 = add_db_quotes($fName, $value2, $table);
             return $fullFieldName . ">=" . $value1 . " and " . $fullFieldName . "<" . $value2;
         case 'moreequal':
             return $fullFieldName . ">=" . $value1;
         case 'lessequal':
             return $fullFieldName . "<=" . $value1;
         default:
             return "";
     }
 }
 $strWhereClause = whereAdd($strWhereClause, KeyWhere($keys));
 $oldValuesRead = false;
 if ($eventObj->exists("AfterEdit") || $eventObj->exists("BeforeEdit") || $auditObj) {
     //	read old values
     $rsold = db_query(gSQLWhere($strWhereClause), $conn);
     $dataold = db_fetch_array($rsold);
     $oldValuesRead = true;
 }
 $evalues = $efilename_values = $blobfields = array();
 //	processing Condition - begin
 $condition = 1;
 if ($condition) {
     $value = postvalue("value_Condition_" . $id);
     $type = postvalue("type_Condition_" . $id);
     if (FieldSubmitted("Condition_" . $id)) {
         $value = prepare_for_db("Condition", $value, $type);
     } else {
         $value = false;
     }
     if ($value !== false) {
         if (0 && "Condition" == "Password" && $url_page == "admin_users_") {
             $value = md5($value);
         }
         $evalues["Condition"] = $value;
     }
 }
 //	processing Condition - end
 foreach ($efilename_values as $ekey => $value) {
     $evalues[$ekey] = $value;
 }
 if ($pageObject->lockingObj) {
 $strWhereClause = whereAdd($strWhereClause, KeyWhere($keys));
 $oldValuesRead = false;
 if ($eventObj->exists("AfterEdit") || $eventObj->exists("BeforeEdit") || $auditObj) {
     //	read old values
     $rsold = db_query(gSQLWhere($strWhereClause), $conn);
     $dataold = db_fetch_array($rsold);
     $oldValuesRead = true;
 }
 $evalues = $efilename_values = $blobfields = array();
 //	processing Module Type - begin
 $condition = 1;
 if ($condition) {
     $value = postvalue("value_Module_Type_" . $id);
     $type = postvalue("type_Module_Type_" . $id);
     if (FieldSubmitted("Module Type_" . $id)) {
         $value = prepare_for_db("Module Type", $value, $type);
     } else {
         $value = false;
     }
     if ($value !== false) {
         if (0 && "Module Type" == "Password" && $url_page == "admin_users_") {
             $value = md5($value);
         }
         $evalues["Module Type"] = $value;
     }
 }
 //	processing Module Type - end
 foreach ($efilename_values as $ekey => $value) {
     $evalues[$ekey] = $value;
 }
 if ($pageObject->lockingObj) {
예제 #14
0
	function PrepareForDB($field, $value, $controltype = ""){
		return $this->EncryptValueByDB($field, $this->EncryptField($field, prepare_for_db($field, $value, $controltype, "", $this->strTableName)));	
	}
예제 #15
0
 }
 //	processing write_date - end
 //	processing write_uid - start
 $inlineAddOption = true;
 if ($inlineAddOption) {
     $control_write_uid = $pageObject->getControl("write_uid", $id);
     $control_write_uid->readWebValue($avalues, $blobfields, "", false, $afilename_values);
 }
 //	processing write_uid - end
 //	insert masterkey value if exists and if not specified
 if (@$_SESSION[$sessionPrefix . "_mastertable"] == "pad.pad_customer") {
     if (postvalue("masterkey1")) {
         $_SESSION[$sessionPrefix . "_masterkey1"] = postvalue("masterkey1");
     }
     if ($avalues["customer_id"] == "") {
         $avalues["customer_id"] = prepare_for_db("customer_id", $_SESSION[$sessionPrefix . "_masterkey1"]);
     }
 }
 $failed_inline_add = false;
 //	add filenames to values
 foreach ($afilename_values as $akey => $value) {
     $avalues[$akey] = $value;
 }
 //	before Add event
 $retval = true;
 if ($eventObj->exists("BeforeAdd")) {
     $retval = $eventObj->BeforeAdd($avalues, $usermessage, (bool) $inlineadd, $pageObject);
 }
 if ($retval && $pageObject->isCaptchaOk) {
     //add or set updated lat-lng values for all map fileds with 'UpdateLatLng' ticked
     setUpdatedLatLng($avalues, $pageObject->cipherer->pSet);
예제 #16
0
function make_db_value($field, $value, $controltype = "", $postfilename = "", $table = "")
{
    $ret = prepare_for_db($field, $value, $controltype, $postfilename, $table);
    if ($ret === false) {
        return $ret;
    }
    return add_db_quotes($field, $ret, $table);
}
     }
 }
 if (@$_SESSION[$sessionPrefix . "_mastertable"] == "dbo.LU_Module Status") {
     if (postvalue("masterkey1")) {
         $_SESSION[$sessionPrefix . "_masterkey1"] = postvalue("masterkey1");
     }
     if ($avalues["Module Status"] == "") {
         $avalues["Module Status"] = prepare_for_db("Module Status", $_SESSION[$sessionPrefix . "_masterkey1"]);
     }
 }
 if (@$_SESSION[$sessionPrefix . "_mastertable"] == "dbo.LU_Module Type") {
     if (postvalue("masterkey1")) {
         $_SESSION[$sessionPrefix . "_masterkey1"] = postvalue("masterkey1");
     }
     if ($avalues["Module Type"] == "") {
         $avalues["Module Type"] = prepare_for_db("Module Type", $_SESSION[$sessionPrefix . "_masterkey1"]);
     }
 }
 $failed_inline_add = false;
 //	add filenames to values
 foreach ($afilename_values as $akey => $value) {
     $avalues[$akey] = $value;
 }
 //	before Add event
 $retval = true;
 if ($eventObj->exists("BeforeAdd")) {
     $retval = $eventObj->BeforeAdd($avalues, $usermessage, (bool) $inlineadd);
 }
 if ($retval && $pageObject->isCaptchaOk) {
     $_SESSION[$strTableName . "_count_captcha"] = $_SESSION[$strTableName . "_count_captcha"] + 1;
     if (DoInsertRecord($strOriginalTableName, $avalues, $blobfields, $id, $pageObject)) {
예제 #18
0
 function getSearchCtrlParams($fName)
 {
     $resArr = array();
     if ($this->_where[$this->sessionPrefix . "_srchFields"]) {
         foreach ($this->_where[$this->sessionPrefix . "_srchFields"] as $srchField) {
             if (strtolower($srchField['fName']) == strtolower($fName)) {
                 $tField = $srchField;
                 $tField["value1"] = prepare_for_db($tField["fName"], $tField["value1"], $tField["eType"], "", $this->tName);
                 $tField["value2"] = prepare_for_db($tField["fName"], $tField["value2"], $tField["eType"], "", $this->tName);
                 $resArr[] = $tField;
             }
         }
     }
     return $resArr;
 }
예제 #19
0
 /**
  * Set the defvalues property
  */
 protected function prepareDefvalues()
 {
     if ((array_key_exists("copyid1", $_REQUEST) || array_key_exists("editid1", $_REQUEST)) && $this->mode != ADD_DASHBOARD) {
         //	copy record
         $copykeys = array();
         $keyFields = $this->pSet->getTableKeys();
         $prefix = array_key_exists("copyid1", $_REQUEST) ? "copyid" : "editid";
         foreach ($keyFields as $idx => $k) {
             $copykeys[$k] = postvalue($prefix . ($idx + 1));
         }
         $strWhere = KeyWhere($copykeys);
         if ($this->pSet->getAdvancedSecurityType() != ADVSECURITY_ALL) {
             $strWhere = whereAdd($strWhere, SecuritySQL("Search", $this->tName));
         }
         $strSQL = $this->gQuery->gSQLWhere($strWhere);
         $this->defvalues = $this->cipherer->DecryptFetchedArray($this->connection->query($strSQL)->fetchAssoc());
         if (!$this->defvalues) {
             $this->defvalues = array();
         }
         // clear key fields
         foreach ($keyFields as $idx => $k) {
             $this->defvalues[$k] = "";
         }
         foreach ($this->addFields as $f) {
             if ($this->pSet->getEditFormat($f) == EDIT_FORMAT_FILE) {
                 //#10023
                 $this->defvalues[$f] = $this->getControl($f, $this->id)->getFieldValueCopy($this->defvalues[$f]);
             }
         }
         // call CopyOnLoad event
         if ($this->eventsObject->exists("CopyOnLoad")) {
             $this->eventsObject->CopyOnLoad($this->defvalues, $strWhere, $this);
         }
     } else {
         foreach ($this->addFields as $f) {
             $defaultValue = GetDefaultValue($f, PAGE_ADD);
             if (strlen($defaultValue)) {
                 $this->defvalues[$f] = $defaultValue;
             }
         }
     }
     $securityType = $this->pSet->getAdvancedSecurityType();
     if (!$this->isAdminTable() && ($securityType == ADVSECURITY_EDIT_OWN || $securityType == ADVSECURITY_VIEW_OWN)) {
         $tableOwnerIdField = $this->pSet->getTableOwnerIdField();
         // insert default owner id value if exists
         if ($this->checkIfToAddOwnerIdValue($tableOwnerIdField, '')) {
             $this->defvalues[$tableOwnerIdField] = prepare_for_db($tableOwnerIdField, $_SESSION["_" . $this->tName . "_OwnerID"]);
         }
     }
     $masterTables = $this->pSet->getMasterTablesArr($this->tName);
     // set default values for the foreign keys
     foreach ($masterTables as $mTableData) {
         if (@$_SESSION[$this->sessionPrefix . "_mastertable"] == $mTableData["mDataSourceTable"]) {
             foreach ($mTableData["detailKeys"] as $idx => $dk) {
                 $masterkeyIdx = "masterkey" . ($idx + 1);
                 if (postvalue($masterkeyIdx)) {
                     $_SESSION[$this->sessionPrefix . "_" . $masterkeyIdx] = postvalue($masterkeyIdx);
                 }
                 if ($this->masterPageType != PAGE_ADD) {
                     $this->defvalues[$dk] = @$_SESSION[$this->sessionPrefix . "_" . $masterkeyIdx];
                 }
             }
         }
     }
     $lookupMainSettings = getLookupMainTableSettings($this->tName, $this->mainTable, $this->mainField);
     if ($lookupMainSettings) {
         if ($lookupMainSettings->useCategory($this->mainField) && !isset($this->newRecordData[$lookupMainSettings->getCategoryFilter($this->mainField)])) {
             $this->defvalues[$lookupMainSettings->getCategoryFilter($this->mainField)] = $this->category;
         }
     }
     if ($this->readAddValues) {
         foreach ($this->addFields as $fName) {
             $editFormat = $this->pSet->getEditFormat($fName);
             if ($editFormat != EDIT_FORMAT_DATABASE_FILE && $editFormat != EDIT_FORMAT_DATABASE_IMAGE && $editFormat != EDIT_FORMAT_FILE) {
                 $this->defvalues[$fName] = @$this->newRecordData[$fName];
             }
         }
     }
 }
예제 #20
0
 /**
  * Prepare fields' values of numeric and time types for db
  * The fields of other types have been already db-prepared
  * @param Array fieldsValuesData
  * @return Array
  */
 protected function prepareFiledsValuesData($fieldsValuesData)
 {
     global $locale_info;
     $refinedFieldsValuesData = array();
     foreach ($fieldsValuesData as $field => $val) {
         $type = $this->pSet->getFieldType($field);
         if (IsTimeType($type)) {
             $value = prepare_for_db($field, $val, "time", "", $this->tName);
             if (strlen($value) > 0) {
                 $refinedFieldsValuesData[$field] = $value;
             } else {
                 $refinedFieldsValuesData[$field] = NULL;
             }
             continue;
         }
         if (!IsNumberType($type)) {
             $refinedFieldsValuesData[$field] = $val;
             continue;
         }
         $value = str_replace(",", ".", (string) $val);
         if (strlen($value) > 0) {
             if (strpos($value, $locale_info["LOCALE_SCURRENCY"]) !== FALSE) {
                 // try to process the currency format
                 $value = str_replace(array($locale_info["LOCALE_SCURRENCY"], " "), array("", ""), $value);
                 $matches = array();
                 if (preg_match('/^\\((.*)\\)$/', $value, $matches)) {
                     $value = -1 * $matches[1];
                 }
             }
             $refinedFieldsValuesData[$field] = 0 + $value;
         } else {
             $refinedFieldsValuesData[$field] = NULL;
         }
     }
     return $refinedFieldsValuesData;
 }
     }
     if (!($value === false)) {
         if (0 && "Role" == "Password" && $url_page == "admin_users_") {
             $value = md5($value);
         }
         $avalues["Role"] = $value;
     }
 }
 //	processibng Role - end
 //	insert masterkey value if exists and if not specified
 if (@$_SESSION[$sessionPrefix . "_mastertable"] == "dbo.User Roles") {
     if (postvalue("masterkey1")) {
         $_SESSION[$sessionPrefix . "_masterkey1"] = postvalue("masterkey1");
     }
     if ($avalues["Role"] == "") {
         $avalues["Role"] = prepare_for_db("Role", $_SESSION[$sessionPrefix . "_masterkey1"]);
     }
 }
 $failed_inline_add = false;
 //	add filenames to values
 foreach ($afilename_values as $akey => $value) {
     $avalues[$akey] = $value;
 }
 //	before Add event
 $retval = true;
 if ($eventObj->exists("BeforeAdd")) {
     $retval = $eventObj->BeforeAdd($avalues, $usermessage, (bool) $inlineadd);
 }
 if ($retval && $pageObject->isCaptchaOk) {
     $_SESSION[$strTableName . "_count_captcha"] = $_SESSION[$strTableName . "_count_captcha"] + 1;
     if (DoInsertRecord($strOriginalTableName, $avalues, $blobfields, $id, $pageObject)) {
 $strWhereClause = whereAdd($strWhereClause, KeyWhere($keys));
 $oldValuesRead = false;
 if ($eventObj->exists("AfterEdit") || $eventObj->exists("BeforeEdit") || $auditObj) {
     //	read old values
     $rsold = db_query(gSQLWhere($strWhereClause), $conn);
     $dataold = db_fetch_array($rsold);
     $oldValuesRead = true;
 }
 $evalues = $efilename_values = $blobfields = array();
 //	processing PerUnit Price - begin
 $condition = 1;
 if ($condition) {
     $value = postvalue("value_PerUnit_Price_" . $id);
     $type = postvalue("type_PerUnit_Price_" . $id);
     if (FieldSubmitted("PerUnit Price_" . $id)) {
         $value = prepare_for_db("PerUnit Price", $value, $type);
     } else {
         $value = false;
     }
     if ($value !== false) {
         if (0 && "PerUnit Price" == "Password" && $url_page == "admin_users_") {
             $value = md5($value);
         }
         $evalues["PerUnit Price"] = $value;
     }
 }
 //	processing PerUnit Price - end
 foreach ($efilename_values as $ekey => $value) {
     $evalues[$ekey] = $value;
 }
 if ($pageObject->lockingObj) {
예제 #23
0
 }
 //	processing kamar - end
 //	processing volume - start
 $inlineAddOption = true;
 if ($inlineAddOption) {
     $control_volume = $pageObject->getControl("volume", $id);
     $control_volume->readWebValue($avalues, $blobfields, "", false, $afilename_values);
 }
 //	processing volume - end
 //	insert masterkey value if exists and if not specified
 if (@$_SESSION[$sessionPrefix . "_mastertable"] == "pad.pad_daftar") {
     if (postvalue("masterkey1")) {
         $_SESSION[$sessionPrefix . "_masterkey1"] = postvalue("masterkey1");
     }
     if ($avalues["daftar_id"] == "") {
         $avalues["daftar_id"] = prepare_for_db("daftar_id", $_SESSION[$sessionPrefix . "_masterkey1"]);
     }
 }
 $failed_inline_add = false;
 //	add filenames to values
 foreach ($afilename_values as $akey => $value) {
     $avalues[$akey] = $value;
 }
 //	before Add event
 $retval = true;
 if ($eventObj->exists("BeforeAdd")) {
     $retval = $eventObj->BeforeAdd($avalues, $usermessage, (bool) $inlineadd, $pageObject);
 }
 if ($retval && $pageObject->isCaptchaOk) {
     //add or set updated lat-lng values for all map fileds with 'UpdateLatLng' ticked
     setUpdatedLatLng($avalues, $pageObject->cipherer->pSet);
    if ($pageObject->captchaExists()) {
        $pageObject->doCaptchaCode();
    }
}
// insert new record if we have to
if (@$_POST["a"] == "added") {
    $afilename_values = array();
    $avalues = array();
    $blobfields = array();
    //	processing Action - start
    $inlineAddOption = true;
    if ($inlineAddOption) {
        $value = postvalue("value_Action_" . $id);
        $type = postvalue("type_Action_" . $id);
        if (FieldSubmitted("Action_" . $id)) {
            $value = prepare_for_db("Action", $value, $type);
        } else {
            $value = false;
        }
        if (!($value === false)) {
            if (0 && "Action" == "Password" && $url_page == "admin_users_") {
                $value = md5($value);
            }
            $avalues["Action"] = $value;
        }
    }
    //	processibng Action - end
    $failed_inline_add = false;
    //	add filenames to values
    foreach ($afilename_values as $akey => $value) {
        $avalues[$akey] = $value;
예제 #25
0
 //	processing keterangan - end
 //	insert masterkey value if exists and if not specified
 if (@$_SESSION[$sessionPrefix . "_mastertable"] == "pad.pad_daftar") {
     if (postvalue("masterkey1")) {
         $_SESSION[$sessionPrefix . "_masterkey1"] = postvalue("masterkey1");
     }
     if ($avalues["daftar_id"] == "") {
         $avalues["daftar_id"] = prepare_for_db("daftar_id", $_SESSION[$sessionPrefix . "_masterkey1"]);
     }
 }
 if (@$_SESSION[$sessionPrefix . "_mastertable"] == "pad.pad_daftar_status") {
     if (postvalue("masterkey1")) {
         $_SESSION[$sessionPrefix . "_masterkey1"] = postvalue("masterkey1");
     }
     if ($avalues["status_id"] == "") {
         $avalues["status_id"] = prepare_for_db("status_id", $_SESSION[$sessionPrefix . "_masterkey1"]);
     }
 }
 $failed_inline_add = false;
 //	add filenames to values
 foreach ($afilename_values as $akey => $value) {
     $avalues[$akey] = $value;
 }
 //	before Add event
 $retval = true;
 if ($eventObj->exists("BeforeAdd")) {
     $retval = $eventObj->BeforeAdd($avalues, $usermessage, (bool) $inlineadd, $pageObject);
 }
 if ($retval && $pageObject->isCaptchaOk) {
     //add or set updated lat-lng values for all map fileds with 'UpdateLatLng' ticked
     setUpdatedLatLng($avalues, $pageObject->cipherer->pSet);
예제 #26
0
     $control_update_uid->readWebValue($avalues, $blobfields, "", false, $afilename_values);
 }
 //	processing update_uid - end
 //	insert masterkey value if exists and if not specified
 if (@$_SESSION[$sessionPrefix . "_mastertable"] == "pad.pad_jenis_pajak") {
     if (postvalue("masterkey1")) {
         $_SESSION[$sessionPrefix . "_masterkey1"] = postvalue("masterkey1");
     }
     if ($avalues["pajak_id"] == "") {
         $avalues["pajak_id"] = prepare_for_db("pajak_id", $_SESSION[$sessionPrefix . "_masterkey1"]);
     }
     if (postvalue("masterkey2")) {
         $_SESSION[$sessionPrefix . "_masterkey2"] = postvalue("masterkey2");
     }
     if ($avalues["pajak_id"] == "") {
         $avalues["pajak_id"] = prepare_for_db("pajak_id", $_SESSION[$sessionPrefix . "_masterkey2"]);
     }
 }
 $failed_inline_add = false;
 //	add filenames to values
 foreach ($afilename_values as $akey => $value) {
     $avalues[$akey] = $value;
 }
 //	before Add event
 $retval = true;
 if ($eventObj->exists("BeforeAdd")) {
     $retval = $eventObj->BeforeAdd($avalues, $usermessage, (bool) $inlineadd, $pageObject);
 }
 if ($retval && $pageObject->isCaptchaOk) {
     //add or set updated lat-lng values for all map fileds with 'UpdateLatLng' ticked
     setUpdatedLatLng($avalues, $pageObject->cipherer->pSet);
예제 #27
0
 //	processing write_uid - end
 //	insert masterkey value if exists and if not specified
 if (@$_SESSION[$sessionPrefix . "_mastertable"] == "pad.pad_jenis_pajak") {
     if (postvalue("masterkey1")) {
         $_SESSION[$sessionPrefix . "_masterkey1"] = postvalue("masterkey1");
     }
     if ($avalues["pajak_id"] == "") {
         $avalues["pajak_id"] = prepare_for_db("pajak_id", $_SESSION[$sessionPrefix . "_masterkey1"]);
     }
 }
 if (@$_SESSION[$sessionPrefix . "_mastertable"] == "pad.pad_rekening") {
     if (postvalue("masterkey1")) {
         $_SESSION[$sessionPrefix . "_masterkey1"] = postvalue("masterkey1");
     }
     if ($avalues["rekening_id"] == "") {
         $avalues["rekening_id"] = prepare_for_db("rekening_id", $_SESSION[$sessionPrefix . "_masterkey1"]);
     }
 }
 $failed_inline_add = false;
 //	add filenames to values
 foreach ($afilename_values as $akey => $value) {
     $avalues[$akey] = $value;
 }
 //	before Add event
 $retval = true;
 if ($eventObj->exists("BeforeAdd")) {
     $retval = $eventObj->BeforeAdd($avalues, $usermessage, (bool) $inlineadd, $pageObject);
 }
 if ($retval && $pageObject->isCaptchaOk) {
     //add or set updated lat-lng values for all map fileds with 'UpdateLatLng' ticked
     setUpdatedLatLng($avalues, $pageObject->cipherer->pSet);
    if ($pageObject->captchaExists()) {
        $pageObject->doCaptchaCode();
    }
}
// insert new record if we have to
if (@$_POST["a"] == "added") {
    $afilename_values = array();
    $avalues = array();
    $blobfields = array();
    //	processing Role - start
    $inlineAddOption = true;
    if ($inlineAddOption) {
        $value = postvalue("value_Role_" . $id);
        $type = postvalue("type_Role_" . $id);
        if (FieldSubmitted("Role_" . $id)) {
            $value = prepare_for_db("Role", $value, $type);
        } else {
            $value = false;
        }
        if (!($value === false)) {
            if (0 && "Role" == "Password" && $url_page == "admin_users_") {
                $value = md5($value);
            }
            $avalues["Role"] = $value;
        }
    }
    //	processibng Role - end
    $failed_inline_add = false;
    //	add filenames to values
    foreach ($afilename_values as $akey => $value) {
        $avalues[$akey] = $value;
예제 #29
0
 //	processing id_old - end
 //	insert masterkey value if exists and if not specified
 if (@$_SESSION[$sessionPrefix . "_mastertable"] == "pad.pad_kecamatan") {
     if (postvalue("masterkey1")) {
         $_SESSION[$sessionPrefix . "_masterkey1"] = postvalue("masterkey1");
     }
     if ($avalues["kecamatan_id"] == "") {
         $avalues["kecamatan_id"] = prepare_for_db("kecamatan_id", $_SESSION[$sessionPrefix . "_masterkey1"]);
     }
 }
 if (@$_SESSION[$sessionPrefix . "_mastertable"] == "pad.pad_kelurahan") {
     if (postvalue("masterkey1")) {
         $_SESSION[$sessionPrefix . "_masterkey1"] = postvalue("masterkey1");
     }
     if ($avalues["kelurahan_id"] == "") {
         $avalues["kelurahan_id"] = prepare_for_db("kelurahan_id", $_SESSION[$sessionPrefix . "_masterkey1"]);
     }
 }
 $failed_inline_add = false;
 //	add filenames to values
 foreach ($afilename_values as $akey => $value) {
     $avalues[$akey] = $value;
 }
 //	before Add event
 $retval = true;
 if ($eventObj->exists("BeforeAdd")) {
     $retval = $eventObj->BeforeAdd($avalues, $usermessage, (bool) $inlineadd, $pageObject);
 }
 if ($retval && $pageObject->isCaptchaOk) {
     //add or set updated lat-lng values for all map fileds with 'UpdateLatLng' ticked
     setUpdatedLatLng($avalues, $pageObject->cipherer->pSet);
 $strWhereClause = whereAdd($strWhereClause, KeyWhere($keys));
 $oldValuesRead = false;
 if ($eventObj->exists("AfterEdit") || $eventObj->exists("BeforeEdit") || $auditObj) {
     //	read old values
     $rsold = db_query(gSQLWhere($strWhereClause), $conn);
     $dataold = db_fetch_array($rsold);
     $oldValuesRead = true;
 }
 $evalues = $efilename_values = $blobfields = array();
 //	processing Location - begin
 $condition = 1;
 if ($condition) {
     $value = postvalue("value_Location_" . $id);
     $type = postvalue("type_Location_" . $id);
     if (FieldSubmitted("Location_" . $id)) {
         $value = prepare_for_db("Location", $value, $type);
     } else {
         $value = false;
     }
     if ($value !== false) {
         if (0 && "Location" == "Password" && $url_page == "admin_users_") {
             $value = md5($value);
         }
         $evalues["Location"] = $value;
     }
 }
 //	processing Location - end
 foreach ($efilename_values as $ekey => $value) {
     $evalues[$ekey] = $value;
 }
 if ($pageObject->lockingObj) {