function InsertVk($k, $uk) { $con = GetMyConnection(); $query = sprintf("insert into url_query(queried_key,user_key) values('%s','%s')", mysql_real_escape_string($k), mysql_real_escape_string($uk)); $result = mysql_query($query, $con); CleanUpDB(); }
function formToDB($table, $exceptions = '', $sql_type = 'insert', $sql_condition = NULL, $passedVals = NULL) { CleanUpDB(); GetMyConnection('operators'); // define some vars $fields = ''; $values = ''; // format input fields into sql // deal with passed values... if ($passedVals == NULL) { // insert the _POST values... $passedVals = $_POST; } //foreach ($_POST as $field => $value) { foreach ($passedVals as $field => $value) { if (!preg_match("/{$field}, /", $exceptions)) { $value = mysql_real_escape_string($value, GetMyConnection()); if ($sql_type == 'insert') { $fields .= "{$field}, "; $values .= "'{$value}', "; } else { $fields .= "{$field} = '{$value}', "; } } } // remove trailing ", " from $fields and $values $fields = preg_replace('/, $/', '', $fields); $values = preg_replace('/, $/', '', $values); // create sql statement if ($sql_type == 'insert') { $sql = "INSERT INTO {$table} ({$fields}) VALUES ({$values})"; //die($sql); } elseif ($sql_type == 'update') { if (!isset($sql_condition)) { echo 'ERROR: You must enter a sql condition!'; exit; } $sql = "UPDATE {$table} SET {$fields} WHERE {$sql_condition}"; } else { echo 'ERROR: Invalid input for argument $sql_type: must be "insert" or "update"'; exit; } // execute sql // $result = mysql_query($sql, GetMyConnection('operators')); //die ($sql); if (mysql_query($sql, GetMyConnection('operators'))) { $rct = mysql_result(mysql_query('SELECT LAST_INSERT_ID()'), 0); //if($rct){ //global $g_link; //die($rct); return $rct; } else { die(mysql_error() . 'SQL : ' . $sql); //return false; } }
// Default FM session time. We use it if we can't find close DB(or connection) record define('FM_MAX_DURATION_SESSION', 12 * 60 * 60); // Max FM session time. We close session with default time if we can't find close DB (session) record and session time is more that FM_MAX_DURATION_SESSION define('FM_RELOGIN_TIMEOUT', 1); // If 2 actions from the same client are xx sec close to each other we save them in one session (like relogin as ... action) define('FM_TYPE_OTHER', 'Other'); define('FM_TYPE_REGEXP', '/^([a-zA-Z_ ]+) /'); define('FM_CONN_PAID_REGEXP', '/(^Go )|(^Go_iPad)|(\\[fmwebdirect\\]S)/'); // Start here $LOG->message("session started"); $ckStart = new CheckStart($CONFIG['VAR_DIR'] . 'sessions.lock'); if (!$ckStart->canStart()) { // Check if script already running. Doesn't allow customer to send multiple restart requests printLogAndDie("Script is already running."); } CleanUpDB(); // Cleanup DB $user_session = array(); $script_session = array(); $opened_connections = array(); $session_to_close = array(); $last_used_app = array(); $lastProcessedDate = ''; $sth = $DB->dbh->prepare("SELECT * FROM FmAccessLog WHERE SessionId=? ORDER BY LogDate, LogTime, LogSec, Id LIMIT 100000"); # Limit request to prevent Allowed memory size ... exhausted error $sth->execute(array(0)); if ($sth->errorInfo()[1]) { printLogAndDie("DB error: " . $sth->errorInfo()[2]); } while ($rec = $sth->fetch(PDO::FETCH_ASSOC)) { $lastProcessedDate = $rec['LogDate'] . ' ' . $rec['LogTime'];