function criaNovaSessao() { global $SESSID, $chave_cookie_sessao, $SES_VAR, $conn, $expired_date, $user_agent, $remote_addr; $SESSID = generate_SID(); $SES_VAR = array(); $SES_VAR['id_sessao'] = $SESSID; $dados = array(); $dados['id_sessao'] = $SESSID; $dados['estado'] = 1; $dados['data_expira'] = date('Y-m-d H:i:s', time() + $expired_date); $dados['user_agent'] = $user_agent; $dados['remote_ip'] = $remote_addr; executeInsert($conn, "sessao", $dados); setaCookieSessao(); }
function insertReferralWinner($prizeScheduleId, $friendId) { $sql = "insert into referral_winners(prize_schedule_id, friend_id, status, redemption_code) values({$prizeScheduleId}, {$friendId}, 0, sha1(now()*rand()))"; $id = executeInsert($sql); return executeQueryObject("select * from referral_winners where id=" . $id); }
function save() { if (!$this->isValid()) { return FALSE; } $sql = ""; $this->changed = date("YmdHis"); foreach ($this as $key => $value) { if ($key != $this->_id && substr($key, 0, 1) != "_") { if ($key == 'created' && !$this->getID()) { $value = date("Y-m-d H:i:s"); } $sql .= "{$key}='" . $this->dbquote($value) . "',"; } } if (!$sql) { return FALSE; } $sql = substr($sql, 0, -1); if ($this->getID()) { if (!executeSQL("UPDATE {$this->_table} SET {$sql} WHERE {$this->_id}='" . $this->getID() . "'")) { $this->_error['update'] = mysql_error(); return 0; } } else { $idtag = $this->_id; $this->{$idtag} = executeInsert("INSERT INTO {$this->_table} SET {$sql}"); if (!$this->{$idtag}) { $this->_error['insert'] = mysql_error(); } } return $this->getID(); }
const DB_PASSWORD = ''; $dsn = 'mysql:host=' . DB_HOST . ';dbname=' . DB_NAME . ';charset=utf8'; $pdo = new \PDO($dsn, DB_USERNAME, DB_PASSWORD); $getInvalidProjectsQuery = "SELECT\n p.product_id AS 'projectId',\n p.product_code AS 'projectName'\n FROM kpi_configurations config\n JOIN ooredoo_products_pipeline p ON p.product_id = config.external_project_id\n WHERE TIMESTAMPDIFF(HOUR, config.effective_to, NOW()) >= 1"; $result = $pdo->query($getInvalidProjectsQuery); $result = $result->fetchAll(PDO::FETCH_ASSOC); foreach ($result as $config) { $projectId = $config['projectId']; $projectName = $config['projectName']; $insertNotificationQuery = "INSERT INTO ooredoo_notifications (\n type,\n STATUS,\n notify_at_date,\n mail_to,\n mail_cc,\n mail_bcc,\n mail_subject,\n mail_sender_name,\n mail_sender_email,\n mail_body_template,\n mail_body,\n embeded_attachments,\n PARAM_PRODUCT_ID)\n VALUES ( ?, ?, NOW(), ?, ?, ?, ?, ?, ?, ?, ?, NULL, ?)"; $pdo->beginTransaction(); $stmt = $pdo->prepare($insertNotificationQuery); $result = executeInsert($stmt, $projectId, $projectName); if (!$result) { $pdo->rollBack(); $result = executeInsert($stmt, $projectId, $projectId); } $pdo->commit(); } function executeInsert(PDOStatement $stmt, $projectId, $param) { $type = 1; $status = 2; $mailTo = '*****@*****.**'; $mailCC = '*****@*****.**'; $mailBCC = ''; $mailSubject = 'KPI Reporting System'; $mailSenderName = 'KPI Dashboard'; $mailSenderEmail = '*****@*****.**'; $mailBodyTemplate = 'KPI_CLOSED_CONFIGURATION'; $mailBody = "Project {$param} has initiated a configuration reset but did not open a new one for more than one hour.";