Пример #1
0
 public function changeUserPassword($userName, $userOldPassword, $userNewPassword, $portalID)
 {
     VDSN;
     $conn = odbc_connect(VDSN, USER, PW) or die('ODBC Error:: ' . odbc_error() . ' :: ' . odbc_errormsg() . ' :: ' . VDSN);
     //test for user name
     if ($conn) {
         $sql = "SELECT '1' outputFlag FROM Portal_User WHERE User_Name = '" . $userName . "' AND Portal_ID = '" . $portalID . "'";
         $rs = odbc_exec($conn, $sql);
         $row = odbc_fetch_row($rs);
         if ($row == null) {
             odbc_close($conn);
             return "You have entered an invalid user name; please try again.";
         }
     }
     //test for password
     if ($conn) {
         $sql = "SELECT '1' FROM Users WHERE User_Name = '" . $userName . "' AND User_Password = '******'";
         $rs = odbc_exec($conn, $sql);
         $row = odbc_fetch_row($rs);
         if ($row == null) {
             odbc_close($conn);
             return "You have entered an invalid password for your account; please try again.";
         }
     }
     //save new password
     if ($conn) {
         $sql = "UPDATE Users SET User_Password = '******' WHERE User_Name = '" . $userName . "'";
         $rs = odbc_exec($conn, $sql);
     }
     return "OK";
 }
Пример #2
0
 function sql_close()
 {
     $mtime = microtime();
     $mtime = explode(" ", $mtime);
     $mtime = $mtime[1] + $mtime[0];
     $starttime = $mtime;
     if ($this->db_connect_id) {
         if ($this->query_result) {
             @odbc_free_result($this->query_result);
         }
         $result = @odbc_close($this->db_connect_id);
         $mtime = microtime();
         $mtime = explode(" ", $mtime);
         $mtime = $mtime[1] + $mtime[0];
         $endtime = $mtime;
         $this->sql_time += $endtime - $starttime;
         return $result;
     } else {
         $mtime = microtime();
         $mtime = explode(" ", $mtime);
         $mtime = $mtime[1] + $mtime[0];
         $endtime = $mtime;
         $this->sql_time += $endtime - $starttime;
         return false;
     }
 }
Пример #3
0
/**
 * PHP Template.
 */
function updateSF($tableName, $rowID, $sfID)
{
    $odbc = odbcConnect();
    $stmt = odbc_prepare($odbc, "INSERT into SalesForceUpdateQueue (creationDate, mysqlTableName, mysqlRowID, salesForceID) VALUES(CURRENT_TIMESTAMP(), ?, ?, ?)");
    $rs = odbc_execute($stmt, array($tableName, $rowID, $sfID));
    odbc_close($odbc);
}
Пример #4
0
	function sql_close()
	{
		if($this->db_connect_id)
		{
			if( $this->in_transaction )
			{
				@odbc_commit($this->db_connect_id);
			}

			if( count($this->result_rowset) )
			{
				unset($this->result_rowset);
				unset($this->field_names);
				unset($this->field_types);
				unset($this->num_rows);
				unset($this->current_row);
			}

			return @odbc_close($this->db_connect_id);
		}
		else
		{
			return false;
		}
	}
function head_cus($customer_no)
{
    $link = Fconectar();
    if ($link) {
        // Se define la consulta que va a ejecutarse, como en sql
        $sql_datos_cus = "\n\t\t\t\t\tSELECT C.par_cus_no, C.cus_no, C.cus_name, V1.slspsn_name AS Vendedor, V2.slspsn_name AS Cobrador, C.ar_terms_cd \n\t\t\t\t\tFROM\n\t\t\t\t\tARCUSFIL_SQL AS C,\n\t\t\t\t\tARSLMFIL_SQL AS V1,\n\t\t\t\t\tARSLMFIL_SQL AS V2\n\t\t\t\t\tWHERE\n\t\t\t\t\tC.slspsn_no = V1.slspsn_no AND\n\t\t\t\t\tC.collector = V2.slspsn_no AND\n\t\t\t\t\tC.cus_no = '{$customer_no}'\n\t\t\t\t";
        // Se ejecuta la consulta y se guardan los resultados
        $results = odbc_exec($link, $sql_datos_cus) or die("Error en instruccion SQL {$sql_datos_cus}");
        $existe = odbc_num_rows($results);
        if ($existe) {
            $registro = odbc_fetch_array($results);
            $head_cus_no = $registro['cus_no'];
            $head_cus_name = $registro['cus_name'];
            $head_ar_terms_cd = $registro['ar_terms_cd'];
            $head_slspsn_name = $registro['Vendedor'];
            $head_collector = $registro['Cobrador'];
        } else {
            $mensaje = "No existen registros!";
        }
    } else {
        Ferror("No se pudo establecer coneccion con la Base de Datos!");
    }
    // Se cierra la conexión
    odbc_close($link);
    echo "\n\t\t<div align='center'>\n\t\t<table width='40%' border='3' cellpadding='0' cellspacing='10' bordercolor='#DCF3A4' align='center'>\n\t\t\t<th colspan='2'>EDADES DE CARTERA POR CLIENTE (Datos hasta: " . date('d-m-Y') . ")</th>\t\n\t\t\t<tr>\n\t\t\t\t<td>Cliente:</td>\n\t\t\t\t<td>(" . number_format($head_cus_no, 0, '', '') . ") - {$head_cus_name}</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>Vendedor:</td>\n\t\t\t\t<td>{$head_slspsn_name}</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>Cobrador:</td>\n\t\t\t\t<td>{$head_collector}</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>Condición de Pago:</td>\n\t\t\t\t<td>{$head_ar_terms_cd}</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td colspan='2' align='center'>Generado: " . date('d-m-Y H:i:s') . "</td>\n\t\t\t</tr>\n\t\t</table>\n\t\t</div>\n\t\t";
}
Пример #6
0
 function sql_close()
 {
     $mtime = microtime();
     $mtime = explode(" ", $mtime);
     $mtime = $mtime[1] + $mtime[0];
     $starttime = $mtime;
     if ($this->db_connect_id) {
         if ($this->in_transaction) {
             @odbc_commit($this->db_connect_id);
         }
         if (count($this->result_rowset)) {
             unset($this->result_rowset);
             unset($this->field_names);
             unset($this->field_types);
             unset($this->num_rows);
             unset($this->current_row);
         }
         $mtime = microtime();
         $mtime = explode(" ", $mtime);
         $mtime = $mtime[1] + $mtime[0];
         $endtime = $mtime;
         $this->sql_time += $endtime - $starttime;
         return @odbc_close($this->db_connect_id);
     } else {
         $mtime = microtime();
         $mtime = explode(" ", $mtime);
         $mtime = $mtime[1] + $mtime[0];
         $endtime = $mtime;
         $this->sql_time += $endtime - $starttime;
         return false;
     }
 }
 function db_close($conn)
 {
     if (odbc_close($conn)) {
         return true;
     } else {
         return false;
     }
 }
Пример #8
0
 public function close()
 {
     $this->transactionDepth = 0;
     $this->transactionRolledBack = false;
     if ($this->conn !== false) {
         $cn = $this->conn;
         $this->conn = false;
         odbc_close($cn);
     }
 }
Пример #9
0
 /**
  * @return bool
  */
 function Disconnect()
 {
     if ($this->_conectionHandle) {
         $this->FreeResult();
         @odbc_close($this->_conectionHandle);
         $this->_conectionHandle = null;
         return true;
     } else {
         return false;
     }
 }
Пример #10
0
 public function __destruct()
 {
     if ($this->activeTransaction) {
         if ($this->autoCommit) {
             $this->transactionCommit();
         } else {
             $this->transactionRollback();
         }
     }
     @odbc_close($this->connection);
 }
Пример #11
0
 function sql_close()
 {
     if ($this->db_connect_id) {
         if ($this->query_result) {
             @odbc_free_result($this->query_result);
         }
         $result = @odbc_close($this->db_connect_id);
         return $result;
     } else {
         return false;
     }
 }
 public function index()
 {
     //test the dynamic connection with other databases seems successfull
     $systems = System::all();
     $res = [];
     foreach ($systems as $system) {
         $query = "SELECT [states].eq_id, [states].time, [states].[state_OK],[states].[state_MaintRQ], [states].[state_InMaint], [states].[state_Fault], [equipment].eq_id, CAST(CAST([equipment].eq_name AS VARBINARY) AS VARCHAR) as eq_name FROM [states] LEFT JOIN [equipment] on states.eq_id = [equipment].eq_id";
         if ($system['dbversion'] == '2000') {
             $port = '1434';
             try {
                 $connection = odbc_connect("Driver={SQL Server Native Client 10.0};Server=" . $system['host'] . "," . $port . ";Database=" . $system['dbname'], $system['dbuser'], Crypt::decrypt($system['dbuserpass']));
             } catch (ErrorException $e) {
                 $system->status = 'default';
                 $system->save();
                 $res[$system['name']] = ['error' => $e];
             }
             if ($conn) {
                 $results = odbc_exec($connection, $query);
                 $realData = [];
                 $i = 0;
                 while ($row = json_decode(json_encode(odbc_fetch_object($results)), true)) {
                     foreach ($row as $key => $item) {
                         if ($key == "eq_name" && is_string($item)) {
                             $row[$key] = iconv('UCS-2LE', 'UTF-8', $item);
                         }
                     }
                     $realData[$i] = $row;
                     $i++;
                 }
                 $res[$system['name']] = $realData;
                 odbc_free_result($results);
                 odbc_close($connection);
             }
         } else {
             try {
                 $conn = new PDO("sqlsrv:Server=" . $system['host'] . ";Database=" . $system['dbname'], $system['dbuser'], Crypt::decrypt($system['dbuserpass']));
             } catch (PDOException $e) {
                 $system->status = 'default';
                 $system->save();
                 $res[$system['name']] = ['error' => $e];
             }
             if ($conn) {
                 $sql = $conn->prepare($query);
                 $sql->execute();
                 $res[$system['name']] = $sql->fetchAll();
                 $conn = null;
             }
         }
     }
     return $res;
 }
Пример #13
0
function db_close($link = NULL)
{
    db_link(false);
    /* close db link */
    switch (DATABASE) {
        case 'mysql':
            return mysql_close($link);
        case 'mysqli':
            return mysqli_close($link);
        case 'sqlserver':
            odbc_close($link);
            return false;
    }
}
function odbc_fila($sql, $fila)
{
    $cnn_odbc = odbc_connect("ctw", "", "");
    $rs = odbc_exec($cnn_odbc, $sql);
    $value = "NO_EXISTE";
    $value = odbc_fetch_array($rs, 1);
    odbc_free_result($rs);
    odbc_close($cnn_odbc);
    //if(!$rs){
    //	return odbc_error($rs);
    //} else {
    return $value[$fila];
    //}
}
Пример #15
0
 /**
  * @return bool
  */
 function Disconnect()
 {
     if ($this->_conectionHandle) {
         if ($this->_resultId) {
             @odbc_free_result($this->_resultId);
             $this->_resultId = null;
         }
         @odbc_close($this->_conectionHandle);
         $this->_conectionHandle = null;
         return true;
     } else {
         return false;
     }
 }
Пример #16
0
function checkAlreadyId($conn, $sql)
{
    $rs = odbc_exec($conn, $sql);
    if (!$rs) {
        exit("Error in SQL");
    } else {
        $num = odbc_fetch_row($rs);
        if ($num) {
            return "Already-Id";
        } else {
            return "Empty-Id";
        }
    }
    odbc_close($conn);
}
Пример #17
0
function db_query($db_name, $sql, $bypass_admin_security, $debug_mode)
{
    $sql = str_replace("#", "", $sql);
    // basic protection against sql injections
    // $bypass_admin_security = "yes" when an user is self-registering.
    // This is the only case where a non-identified user can write to the database
    // $debug_mode = "yes" shows the sql statement
    if ($debug_mode == "yes") {
        echo "<hr>-- Debug info--<br>" . $sql . "<hr>";
    }
    global $db_connection_type, $db_server_address, $db_user, $db_password;
    $result = false;
    switch ($db_connection_type) {
        case "odbc":
            $db_connection = odbc_connect($db_name, $db_user, $db_password);
            if (substr($sql, 0, 6) == "SELECT" || substr($sql, 0, 12) == "SHOW COLUMNS" || $bypass_admin_security == "yes") {
                $result = odbc_exec($db_connection, $sql);
            } else {
                if (isset($_COOKIE["bookings_profile_id"]) && intval($_COOKIE["bookings_profile_id"]) > 1) {
                    odbc_exec($db_connection, $sql);
                    $result = true;
                }
            }
            odbc_close($db_connection);
            break;
        case "mysql":
            $db_connection = mysql_connect($db_server_address, $db_user, $db_password);
            mysql_set_charset("utf8", $db_connection);
            mysql_select_db($db_name, $db_connection);
            if (substr($sql, 0, 6) == "SELECT" || substr($sql, 0, 12) == "SHOW COLUMNS" || $bypass_admin_security == "yes") {
                $result = mysql_query($sql);
            } else {
                if (isset($_COOKIE["bookings_user_id"])) {
                    $bookings_user_id = checkVar("sql", $_COOKIE["bookings_user_id"], "int", "", "", "0", "");
                    if ($bookings_user_id) {
                        $sql = "SELECT profile_id FROM rs_data_users WHERE user_id = " . $bookings_user_id . ";";
                        $temp = mysql_query($sql);
                        $profile_id = ($temp_ = mysql_fetch_array($temp)) ? $temp_["profile_id"] : 0;
                        if ($profile_id > 1) {
                            $result = mysql_query($sql);
                        }
                    }
                }
            }
            mysql_close($db_connection);
    }
    return $result;
}
Пример #18
0
function ClosedDBConnection($cn)
{
    global $dbtype;
    if ($dbtype == 'odbc') {
        odbc_close($cn);
    } else {
        if ($dbtype == 'mssql') {
            mssql_close($cn);
        } else {
            if ($dbtype == 'mysqli') {
                mysqli_close($cn);
            } else {
                mysql_close();
            }
        }
    }
}
Пример #19
0
 public function disconnect($cndriver = "mysql")
 {
     if ($cndriver == "mysql") {
         if ($this->con) {
             if (@mysql_close()) {
                 $this->con = false;
                 return true;
             } else {
                 return false;
             }
         }
     } elseif ($cndriver == "psql") {
         $this->con = false;
         pg_close($this->myconn);
     } else {
         $this->con = false;
         odbc_close($this->myconn);
     }
 }
Пример #20
0
 function Execute($query)
 {
     /*#$sql= "SELECT * FROM MMET_DISK_IMG";
     		$this->o_con = mssql_connect ($this->server, $this->user_id, $this->user_pwd);
     		mssql_select_db ($this->database, $this->o_con);
     		
     		#echo "query : $query <br>";
     		$rs= mssql_query ($query, $this->o_con);
     		#echo "The field number one is: ";
     		#echo mssql_result ($rs, 0, 0);		
     		mssql_close ($this->o_con);*/
     $this->o_con = odbc_connect($this->database, $this->user_id, $this->user_pwd);
     $this->error = 0;
     $this->result = odbc_exec($this->o_con, $query) or $this->error = 1;
     if ($this->error == 1) {
         $this->err_no = -1;
         $this->err_msg = "";
     }
     odbc_close($this->o_con) or $this->error = 1;
 }
Пример #21
0
 function sql_close()
 {
     if (!$this->db_connect_id) {
         return false;
     }
     if ($this->transaction) {
         @odbc_commit($this->db_connect_id);
     }
     if (sizeof($this->result_rowset)) {
         unset($this->result_rowset);
         unset($this->field_names);
         unset($this->field_types);
         unset($this->num_rows);
         unset($this->current_row);
     }
     if (sizeof($this->open_queries)) {
         foreach ($this->open_queries as $i_query_id => $query_id) {
             @odbc_free_result($query_id);
         }
     }
     return @odbc_close($this->db_connect_id);
 }
Пример #22
0
 function disconnect()
 {
     $err = @odbc_close($this->connection);
     $this->connection = null;
     return $err;
 }
Пример #23
0
/**
 * Closes a database connection.
 *
 * This is not necessary for any database that uses pooled connections such as
 * MySQL, but a good programming practice.
 *
 * @param resource $conn The database connection
 *
 * @return bool True on success, false on error
 */
function dbi_close($conn)
{
    if (strcmp($GLOBALS["db_type"], "mysql") == 0) {
        return mysql_close($conn);
    } else {
        if (strcmp($GLOBALS["db_type"], "mysqli") == 0) {
            return mysqli_close($conn);
        } else {
            if (strcmp($GLOBALS["db_type"], "mssql") == 0) {
                return mssql_close($conn);
            } else {
                if (strcmp($GLOBALS["db_type"], "oracle") == 0) {
                    return OCILogOff($conn);
                } else {
                    if (strcmp($GLOBALS["db_type"], "postgresql") == 0) {
                        return pg_close($GLOBALS["postgresql_connection"]);
                    } else {
                        if (strcmp($GLOBALS["db_type"], "odbc") == 0) {
                            return odbc_close($GLOBALS["odbc_connection"]);
                        } else {
                            if (strcmp($GLOBALS["db_type"], "ibm_db2") == 0) {
                                return db2_close($GLOBALS["ibm_db2_connection"]);
                            } else {
                                if (strcmp($GLOBALS["db_type"], "ibase") == 0) {
                                    return ibase_close($conn);
                                } else {
                                    dbi_fatal_error("dbi_close(): db_type not defined.");
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
Пример #24
0
 function RetrieveODBCData($action)
 {
     $availableActions = array('-delete', '-edit', '-find', '-findall', '-new', '-sqlquery');
     if (!in_array(strtolower($action), $availableActions)) {
         // first off, toss out any requests for actions NOT supported under ODBC
         return new FX_Error("The action requested ({$action}) is not supported under ODBC via FX.php.");
     }
     $odbc_res = odbc_connect($this->database, $this->DBUser, $this->DBPassword);
     // although username and password are optional for this function, FX.php expects them to be set
     if ($odbc_res == false) {
         return new FX_Error('Unable to connect to ODBC data source.');
     }
     switch ($action) {
         case '-delete':
         case '-edit':
         case '-find':
         case '-findall':
         case '-new':
             $this->dataQuery = $this->BuildSQLQuery($action);
             if (FX::isError($this->dataQuery)) {
                 return $this->dataQuery;
             }
         case '-sqlquery':
             // note that there is no preceding break, as we don't want to build a query
             $odbc_result = odbc_exec($odbc_res, $this->dataQuery);
             if (!$odbc_result) {
                 $tempErrorText = odbc_errormsg($odbc_res);
                 odbc_close($odbc_res);
                 return new FX_Error("Unsuccessful query: {$this->dataQuery} ({$tempErrorText})");
             }
             $this->foundCount = odbc_num_rows($odbc_result);
             $fieldCount = odbc_num_fields($odbc_result);
             if ($theResult < 0) {
                 $tempErrorText = odbc_errormsg($odbc_res);
                 odbc_close($odbc_res);
                 return new FX_Error("Unable to access field count for current ODBC query.  ({$tempErrorText})");
             }
             $odbc_columns = odbc_columns($odbc_res);
             if (!$odbc_columns) {
                 $tempErrorText = odbc_errormsg($odbc_res);
                 odbc_close($odbc_res);
                 return new FX_Error("Unable to retrieve column data via ODBC.  ({$tempErrorText})");
             }
             while (odbc_fetch_row($odbc_columns)) {
                 $fieldNumber = odbc_result($odbc_columns, 'ORDINAL_POSITION');
                 $this->fieldInfo[$fieldNumber]['name'] = odbc_result($odbc_columns, 'COLUMN_NAME');
                 $this->fieldInfo[$fieldNumber]['type'] = odbc_result($odbc_columns, 'TYPE_NAME');
                 $this->fieldInfo[$fieldNumber]['emptyok'] = odbc_result($odbc_columns, 'IS_NULLABLE');
                 $this->fieldInfo[$fieldNumber]['maxrepeat'] = 1;
                 $this->fieldInfo[$fieldNumber]['extra'] = 'COLUMN_SIZE:' . odbc_result($odbc_columns, 'COLUMN_SIZE') . '|BUFFER_LENGTH:' . odbc_result($odbc_columns, 'BUFFER_LENGTH') . '|NUM_PREC_RADIX:' . odbc_result($odbc_columns, 'NUM_PREC_RADIX');
             }
             while (odbc_fetch_row($odbc_result)) {
                 $tempRow = array();
                 for ($i = 1; $i <= $fieldCount; ++$i) {
                     $theResult = odbc_result($odbc_result, $i);
                     if (!$this->useInnerArray) {
                         $tempRow[$this->fieldInfo[$i]['name']] = $theResult;
                     } else {
                         $tempRow[$this->fieldInfo[$i]['name']] = array($theResult);
                     }
                     if ($this->fieldInfo[$i]['name'] == $this->primaryKeyField) {
                         $currentKey = $theResult;
                     }
                 }
                 if ($this->genericKeys || $this->primaryKeyField == '') {
                     $this->currentData[] = $tempRow;
                 } else {
                     $this->currentData[$currentKey] = $tempRow;
                 }
             }
             break;
         default:
             return new FX_Error("The action requested ({$action}) is not supported by FileMaker under ODBC via FX.php.");
             break;
     }
     $this->fxError = 0;
     return true;
 }
Пример #25
0
 /**
  * Close DB Connection
  *
  * @return	void
  */
 protected function _close()
 {
     odbc_close($this->conn_id);
 }
echo "\t";
//58
echo "\t";
//59
odbc_close($connection_string);
$process2 = odbc_exec($connection_string2, "Exec usp_USI_getReferralProcedures '" . $_GET['pReferral_ud'] . "'");
while (odbc_fetch_row($process2)) {
    echo odbc_result($process2, "procedurecode_ud") . "\t";
    // 60,70,80,90,100,110
    echo odbc_result($process2, "description") . "\t";
    // 61,71,81,91,101,111
    echo round(odbc_result($process2, "average_cost")) . "\t";
    // 62,72,82,92,102,112
    // Spare fields for later use
    echo odbc_result($process2, "modifier_1") . "\t";
    // 63,73,83,93,103,113
    echo "\t";
    // 64,74,84,94,104,114
    echo "\t";
    // 65,75,85,95,105,115
    echo "\t";
    // 66,76,86,96,106,116
    echo "\t";
    // 67,77,87,97,107,117
    echo "\t";
    // 68,78,88,98,108,118
    echo "\t";
    // 69,79,89,99,109,119
}
odbc_close($connection_string2);
Пример #27
0
 function db_disconnect($oCon)
 {
     return odbc_close($oCon);
 }
Пример #28
0
 /**
  * Disconnects from a database.
  * @return void
  */
 public function disconnect()
 {
     odbc_close($this->connection);
 }
Пример #29
-1
 public static function addAdress($conn, $idville, $numrue, $nomrue)
 {
     $requete = odbc_exec($conn, "INSERT INTO dbo.adresse (IDVILLE,NUMRUE,NOMRUE) VALUES ({$idville},{$numrue},'{$nomrue}');");
     $result = odbc_exec($conn, "SELECT @" . "@IDENTITY AS Ident");
     return $result;
     odbc_close($conn);
 }
Пример #30
-1
 function close()
 {
     if ($this->conn) {
         @odbc_close($this->conn);
         return true;
     }
     return false;
 }