public function init($deal_id) { $query = 'SELECT * FROM deal WHERE id = ' . (int) $deal_id; $array = array(); $array = $this->db->select($query); try { if ($array !== FALSE) { $row = $array[0]; $this->id = (int) $row['id']; $this->customer_id = (int) $row['customer_id']; $this->article_id = (int) $row['article_id']; $this->payment_id = (int) $row['payment_id']; $this->shipment_id = (int) $row['shipment_id']; $this->amount = (int) $row['amount']; $this->total_price = (double) $row['total_price']; $this->platform_name = $this->db->res($row['platform_name']); $this->commented = (int) $row['platform_name']; $this->status = (int) $row['status']; $this->extras = $this->db->res($row['extras']); } else { throw new CustomException(); } } catch (CustomException $e) { UtilFunctions::p($e->errorMessage('No deals are found.')); } }
public function init($contact_id = 0, $customer_id = 0) { $query = ''; if ($contact_id > 0) { $query = 'SELECT * FROM contact WHERE id = ' . (int) $contact_id; } else { if ($customer_id > 0) { $query = 'SELECT * FROM contact WHERE customer_id = ' . (int) $customer_id; } } $array = array(); $array = $this->db->select($query); try { if ($array !== FALSE) { $row = $array[0]; $this->id = (int) $row['id']; $this->customer_id = $row['customer_id']; $this->country = $row['country']; $this->zip_code = (int) $row['zip_code']; $this->city = $row['city']; $this->street = $row['street']; $this->street_number = (int) $row['street_number']; $this->street_number_extra = $row['street_number_extra']; $this->room_number = (int) $row['room_number']; $this->phone = $row['phone']; } else { throw new CustomException(); } } catch (CustomException $e) { UtilFunctions::p($e->errorMessage('No contacts are found.')); } }
/** * Atualiza registro */ public function index() { if (isset($_POST['formSubmit']) && $_POST['formSubmit'] == true) { $dados = $this->input->post(NULL, TRUE); # Tratamento de alguns campos $dados['data_update'] = date('Y-m-d H:i:s'); $this->validacao($dados); if ($this->form_validation->run() == true) { unset($dados['formSubmit']); $ret = $this->social_model->update($dados, array('id' => 1)); if ($ret == true) { redirect(UtilFunctions::formataLink($this->area) . '?ret=update'); } else { $this->form_validation->set_message('', 'Dados inválidos.'); } } else { # Necessário para que haja o retorno de campos como data_insert e imagem # Funde o $_POST, com o que tem no BD $dados = $this->db->get_where('social', array('id' => 1))->result_array(); $dados = $dados[0]; $dados = array_merge($_POST, $dados); } } else { $dados = $this->db->get_where('social', array('id' => 1))->result_array(); $dados = $dados[0]; } // echo '<pre>';print_r($curso);echo '</pre>'; $this->load->view('topo'); $this->load->view(strtolower($this->area) . '/index', array('dados' => $dados)); $this->load->view('rodape'); }
public static function autoLogin($rememberme = true) { if (isset($_SESSION["userId"])) { $userId = $_SESSION["userId"]; $user = GameUsers::getGameUserById($userId); if (!empty($user)) { UtilFunctions::storeSessionUser($user, $rememberme); return $user; } } if (isset($_COOKIE["auth"]) && false) { $cookie = $_COOKIE["auth"]; $arr = explode('&', $cookie); $userName = substr($arr[0], 4); $hash = substr($arr[1], 5); $user = GameUsers::getGameUserByUserName($userName); if (!empty($user)) { if ($hash == md5($user->getPassword())) { $user->setLastLoginDate(time()); $user->setLoginCount($user->getLoginCount() + 1); $user->updateToDatabase(DBUtils::getConnection()); Queue::checkUserFriends($user->userId); UtilFunctions::storeSessionUser($user, $rememberme); return $user; } else { UtilFunctions::forgetMe(); } } } return false; }
public function init($article_id) { $query = 'SELECT * FROM article WHERE id = ' . (int) $article_id; $array = array(); $array = $this->db->select($query); try { if ($array !== FALSE) { $row = $array[0]; $this->id = (int) $row['id']; $this->name = $row['name']; $this->price = $row['price']; $this->extras = $row['extras']; } else { throw new CustomException(); } } catch (CustomException $e) { UtilFunctions::p($e->errorMessage('No articles are found.')); } }
public function init($payment_id) { $query = 'SELECT * FROM payment WHERE id = ' . (int) $payment_id; $array = array(); $array = $this->db->select($query); try { if ($array !== FALSE) { $row = $array[0]; $this->id = (int) $row['id']; $this->date = $row['date']; $this->paid_amount = $row['paid_amount']; $this->bank_name = (int) $row['bank_name']; $this->extras = $row['extras']; } else { throw new CustomException(); } } catch (CustomException $e) { UtilFunctions::p($e->errorMessage('No payments are found.')); } }
public function init($shipment_id) { $query = 'SELECT * FROM shipment WHERE id = ' . (int) $shipment_id; $array = array(); $array = $this->db->select($query); try { if ($array !== FALSE) { $row = $array[0]; $this->id = (int) $row['id']; $this->customer_id = (int) $row['customer_id']; $this->number = $row['number']; $this->date = (int) $row['date']; $this->transport_charge = (double) $row['transport_charge']; $this->extras = (double) $row['extras']; } else { throw new CustomException(); } } catch (CustomException $e) { UtilFunctions::p($e->errorMessage('No shipments are found.')); } }
public function init($customer_id) { $query = 'SELECT * FROM customer WHERE id = ' . (int) $customer_id; $array = array(); $array = $this->db->select($query); try { if ($array !== FALSE) { $row = $array[0]; $this->id = (int) $row['id']; $this->last_name = $row['last_name']; $this->first_name = $row['first_name']; $this->middle_name = (int) $row['middle_name']; $this->nick_name = $row['nick_name']; $this->email = $row['email']; $this->extras = $row['extras']; } else { throw new CustomException(); } } catch (CustomException $e) { UtilFunctions::p($e->errorMessage('No customers are found.')); } }
public function init($page_id) { $query = 'SELECT * FROM page WHERE id = ' . (int) $page_id; $array = array(); $array = $this->db->select($query); try { if ($array !== FALSE) { $row = $array[0]; $this->id = (int) $row['id']; $this->slug = $row['slug']; $this->name = $row['name']; $this->place = (int) $row['place']; $this->glyphicon = $row['glyphicon']; $this->class_name = $row['class_name']; $this->active = $row['active']; } else { // TODO throw new CustomException(); } } catch (CustomException $e) { UtilFunctions::p($e->errorMessage('No pages are found.')); } }
/** * Deleta registro */ public function delete() { $id = UtilFunctions::trataDados($_POST['idDelete'], 11); $this->galeria_model->delete(array('id' => $id)); redirect('empreendimento/cria?#passo-4'); }
public static function getUserDailyBonus($userId) { $result = array(); if (!empty($userId)) { try { $SQL = "SELECT * FROM " . TBL_GAME_USER_LOGIN_LOG . " WHERE userId=" . DBUtils::mysql_escape($userId, 1) . " GROUP BY date ORDER BY date DESC LIMIT 0,7"; $dailies = GameUserLoginLog::findBySql(DBUtils::getConnection(), $SQL); $dailyBonusConstants = BonusUtils::getDailyBonusConstants(); $good = 1; if (!empty($dailies) && sizeof($dailies) > 1) { for ($i = 1; $i < sizeof($dailies); $i++) { $current = $dailies[$i]; $prev = $dailies[$i - 1]; if (!empty($current) && !empty($prev)) { $diffs = UtilFunctions::dateDiff(intval($prev->time), intval($current->time)); if ($diffs['year'] > 0 || $diffs['month'] > 0 || $diffs['month'] > 0 || $diffs['day'] > 1) { break; } else { $currentD = date("d", $current->time); $prevD = date("d", $prev->time); if ($diffs['day'] == 1 && $diffs["hour"] <= 0 && $diffs["minute"] <= 0 && $diffs["second"] <= 0) { $good++; } else { if ($currentD != $prevD) { $good++; } else { break; } } } } else { break; } } } for ($i = 0; $i < 7; $i++) { $dailybonus = new stdClass(); if (!empty($dailyBonusConstants) && sizeof($dailyBonusConstants) > $i) { $tmp = $dailyBonusConstants[$i]; if (!empty($tmp)) { $dailybonus = $tmp; } } else { $dailybonus->order = $i + 1; $dailybonus->coin = ($i + 1) * 100; } if ($i < $good) { $dailybonus->active = true; } else { $dailybonus->active = false; } array_push($result, $dailybonus); } } catch (Exception $exc) { error_log($exc->getTraceAsString()); } } return $result; }
/** * Deleta registro */ public function delete() { $id = UtilFunctions::trataDados($_POST['idDelete'], 11); $this->usuario_model->delete(array('id' => $id)); redirect('/' . UtilFunctions::formataLink($this->area), 'refresh'); }
echo date('s'); ?> #passo-3'">Passo anterior</button> <button type="submit" class="btn btn-primary" onclick="submitar4('nao')">Salvar e sair</button> <button type="submit" class="btn btn-success" onclick="submitar4('sim')">Salvar e prosseguir</button> </div> <?php echo form_close(); ?> </div> </div> </div> <?php UtilFunctions::modalDelete('galeria'); ?> <style type="text/css"> </style> <script src="<?php echo base_url(); ?> application/assets/js/jquery-1.9.1.min.js"></script> <script> function submitar4(prossegue){ $("#prossegue4").val(prossegue); $("#formGaleria").submit(); } </script>
/** * Upload CSV */ public function upload() { $erro = ""; if (isset($_POST['formSubmit']) && $_POST['formSubmit'] == true) { if ($_FILES['csv']['name'] == "") { $erro = "O campo <strong>%s</strong> não pode ficar vazio."; } if ($erro == "") { UtilFunctions::do_upload($_FILES, '', 'csv', 'cliente', $this->uploaddir); $filename = $this->uploaddir . 'cliente.csv'; $handle = fopen("{$filename}", "r"); $dt = date('Y-m-d H:i:s'); while (($data = fgetcsv($handle, 1000, ";")) !== FALSE) { $this->db->query("INSERT INTO cliente VALUES ('','{$data['0']}','{$data['1']}','{$data['2']}','{$data['3']}','{$data['4']}','{$data['5']}','{$data['6']}','{$data['7']}','{$data['8']}','{$data['9']}','{$data['10']}','{$data['11']}','{$data['12']}','{$data['13']}','{$data['14']}','{$data['15']}','{$data['16']}','{$data['17']}','{$data['18']}','{$data['19']}',null,'{$dt}')"); } fclose($handle); redirect(UtilFunctions::formataLink($this->area) . '?ret=upload', 'refresh'); } } $this->load->view('topo'); $this->load->view(strtolower($this->area) . '/upload', array('erro' => $erro)); $this->load->view('rodape'); }
/** * Atualiza a template do empreendimento */ public function atualiza() { $id = $this->uri->segment(3); $this->empreendimento_model->geraLayout($id); redirect(UtilFunctions::formataLink($this->area) . '?ret=atualiza'); }
public function index() { if (defined("SERVER_PROD")) { if (!SERVER_PROD) { $this->user = GameUsers::getGameUserById(2); LanguageUtils::setLocale($this->user->language); if (!empty($this->user) && $this->user->active == 0) { $this->redirect("banned"); exit(1); } return; } } $facebook = new Facebook(array('appId' => FB_APP_ID, 'secret' => FB_APP_SECRET, 'cookie' => true)); $login_req = true; $this->user = UtilFunctions::autoLogin(); if (!empty($this->user)) { $facebook->setAccessToken($this->user->getOauthToken()); try { $fbUser = $facebook->api("/me"); if (!empty($fbUser) && !empty($fbUser['id'])) { $login_req = false; } } catch (Exception $exc) { $this->log->logError($exc->getTraceAsString()); } } else { $login_req = true; if (isset($_GET['error']) || isset($_GET['error_reason']) || isset($_GET['error_description'])) { if ($_GET['error_description']) { $this->addError($_GET['error_description']); } if (isset($_GET['error_reason'])) { $this->addError(isset($_GET['error_reason'])); } echo "<p> Error : " . $_GET['error_reason'] . "</p>"; echo "<p> Please Refresh Page ! </p>"; exit(1); } else { $facebook = new Facebook(array('appId' => FB_APP_ID, 'secret' => FB_APP_SECRET, 'cookie' => true)); try { $fbUser = $facebook->api("/me"); } catch (Exception $exc) { $this->log->logError($exc->getTraceAsString()); } if (!empty($fbUser) && !empty($fbUser['id'])) { $this->user = GameUsers::getGameUserByFBId($fbUser['id']); if (!empty($this->user)) { $this->user->setOauthToken($facebook->getAccessToken()); $this->user->setLastLoginDate(time()); $this->user->setLoginCount($this->user->getLoginCount() + 1); $this->user->updateToDatabase(DBUtils::getConnection()); Queue::checkUserFriends($this->user->userId); UtilFunctions::storeSessionUser($this->user); $login_req = false; } else { $result = GameUsers::createGameUser($fbUser, $facebook->getAccessToken()); if ($result->success) { $this->user = $result->result; if (!empty($result)) { $userId = $this->user->getUserId(); if (!empty($userId)) { Queue::checkUserFriends($this->user->userId); UtilFunctions::storeSessionUser($this->user); $login_req = false; $this->newUser = "******"; } } else { $this->addError(LANG_FACEBOOK_USER_CREATE_ERROR_UNKNOWN_ERROR); } } else { if (!empty($result->result)) { foreach ($result->result as $value) { $this->addError($value); } } else { $this->addError(LANG_FACEBOOK_USER_CREATE_ERROR_UNKNOWN_ERROR); } } unset($result); } } if (!$login_req && !empty($this->user)) { GameUserLoginLog::insertLog($this->user->userId); } } } if (!$login_req) { if (!empty($this->user) && $this->user->active == 0) { $this->redirect("banned"); exit(1); } } if ($login_req) { UtilFunctions::forgetMe(); $params = array('scope' => FB_SCOPE, 'redirect_uri' => FB_CALLBACK_URL); $login_url = $facebook->getLoginUrl($params); if (isset($_SERVER['QUERY_STRING'])) { if (strpos($login_url, "?")) { $login_url . "&" . $_SERVER['QUERY_STRING']; } else { $login_url . "?" . $_SERVER['QUERY_STRING']; } } ?> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head></head> <body><script>top.location.href='<?php echo $login_url; ?> ';</script></body> </html> <?php exit(1); } else { $this->dailyBonus = BonusUtils::getDailyBonusPrice($this->user); if (isset($_GET['request_ids']) && !empty($_GET['request_ids'])) { $this->fbRequests = FacebookRequestUtils::getFacebookGiftRequest($this->user, $_GET['request_ids']); } LanguageUtils::setLocale($this->user->language); } }
<?php } ?> }); </script> </head> <body> <?php if (!empty($_SESSION['idCamp'])) { ?> <div class="alert alert-info"> <button type="button" class="close" data-dismiss="alert">×</button> Para atualizar a template da campanha, <a href="<?php echo site_url(UtilFunctions::formataLink($this->area) . '/atualiza/' . $_SESSION['idCamp']); ?> ">clique aqui</a>. </div> <?php } ?> <div id="tabs"> <ul> <li><a href="#passo-1">Campanha</a></li> <li><a href="#passo-2">Scripts</a></li> <li><a href="#passo-3">Empreendimentos</a></li> <li><a href="#passo-4">Vídeo YouTube</a></li> </ul> <div id="passo-1">
/** * Função de validação personalizada para o campo de email * @param $email * @return bool */ public function email_check($email) { if (UtilFunctions::validaEmail($email) == false) { $this->form_validation->set_message('email_check', 'O <strong>%s</strong> não é válido.'); return false; } else { return true; } }
echo '</div>'; echo '<div style="float: left;">'; include_once "_tableEmailVariavel.php"; echo '</div> <div style="clear: both"></div> '; ?> <input type="hidden" name="prossegue7" id="prossegue7" value="nao"> <div class="form-actions"> <a href="<?php echo site_url(UtilFunctions::formataLink($this->area)); ?> " class="btn">Voltar</a> <button type="button" class="btn btn-danger" onclick="window.location='<?php echo base_url() . UtilFunctions::formataLink($this->area); ?> /cria?&c=<?php echo date('s'); ?> #passo-5'">Passo anterior</button> <button type="submit" class="btn btn-primary" onclick="submitar7('nao')">Salvar e sair</button> <button type="submit" class="btn btn-success" onclick="submitar7('sim')">Salvar e prosseguir</button> </div> <?php echo form_fieldset_close(); echo form_close(); ?> </div> </div>
public function imagem() { if (isset($_POST['formSubmit']) && $_POST['formSubmit'] == true) { $pastaUpload = '../assets'; if ($_FILES['leonardo']['name'] != "") { UtilFunctions::do_upload($_FILES, '', 'leonardo', 'leonardo', $pastaUpload); # Copia $origem = $pastaUpload . "/leonardo" . '.' . pathinfo($_FILES['leonardo']['name'], PATHINFO_EXTENSION); $destino = $pastaUpload . "/leonardo" . '.jpg'; copy($origem, $destino); } if ($_FILES['whatsapp']['name'] != "") { UtilFunctions::do_upload($_FILES, '', 'whatsapp', 'whatsapp', $pastaUpload); # Copia $origem = $pastaUpload . "/whatsapp" . '.' . pathinfo($_FILES['whatsapp']['name'], PATHINFO_EXTENSION); $destino = $pastaUpload . "/whatsapp" . '.jpg'; copy($origem, $destino); } redirect(UtilFunctions::formataLink($this->area) . '/imagem?ret=update'); } // echo '<pre>';print_r($curso);echo '</pre>'; $this->load->view('topo'); $this->load->view(strtolower($this->area) . '/imagem', array()); $this->load->view('rodape'); }
/** * Deleta registro */ public function delete() { $id = UtilFunctions::trataDados($_POST['idDelete'], 11); $this->construtora_model->delete(array('id' => $id)); redirect('/' . UtilFunctions::formataLink($this->area)); }
echo site_url(UtilFunctions::formataLink($this->area) . '/update/' . $res->id); ?> "> <i class="icon-edit icon-white"></i> </a> <a class="btn btn-danger btn-modal-delete" id="lnkDelete_<?php echo $res->id; ?> "> <i class="icon-trash icon-white"></i> </a> </td> </tr> <?php } ?> </tbody> </table> </div> </div><!--/span--> </div><!--/row--> <!-- end: Content --> </div><!--/#content.span10--> </div><!--/fluid-row--> <?php UtilFunctions::modalDelete();
public static function getAllProducts() { $SQL = "SELECT products.*," . "lang.language AS langCode,lang.text AS langText," . "price.currency AS priceCurrency,price.amount AS priceAmount " . "FROM game_fb_products AS products,game_fb_product_language AS lang,game_fb_product_prices AS price " . "WHERE products.active=1 AND products.Id=lang.fbProductId AND products.Id=price.fbProductId"; $query = mysql_query($SQL, DBUtils::getManualConnection()); if (!empty($query)) { $list = array(); $ids = array(); $i = 0; while ($db_field = mysql_fetch_assoc($query)) { $item = GameFbProducts::createFromSQLWithLanguagePrice($db_field); if (!empty($item)) { $itemId = $item->getId(); if (!empty($itemId)) { if (isset($ids[$itemId]) && isset($list[$ids[$itemId]])) { $oldItem = $list[$ids[$itemId]]; $oldItem->languages = UtilFunctions::array_unique_merge(array($oldItem->languages, $item->languages)); $oldItem->prices = UtilFunctions::array_unique_merge(array($oldItem->prices, $item->prices)); } else { array_push($list, $item); $ids[$itemId] = $i; $i++; } } } } unset($ids); return $list; } return array(); }
<div class="control-group"> <label class="control-label" for="date01">Cor de fundo</label> <div class="controls"> <input type='text' id="fundo" name="fundo" /> </div> </div> <input type="hidden" name="prossegue" id="prossegue" value="nao"> <input type="hidden" name="passo" id="passo" value="1"> <div class="form-actions"> <a href="<?php echo site_url(UtilFunctions::formataLink($this->area)); ?> " class="btn">Voltar</a> <button type="submit" class="btn btn-primary" onclick="submitar('nao')">Salvar e sair</button> <button type="submit" class="btn btn-success" onclick="submitar('sim')">Salvar e prosseguir</button> </div> <?php echo form_fieldset_close(); echo form_close(); ?> </div> </div> </div>
public function redirect($controller, $action = '') { if (UtilFunctions::startsWith($controller, "http") || UtilFunctions::startsWith($controller, "www")) { header('Location: ' . $controller); } else { header('Location: ' . HOSTNAME . $controller . ($action != "" ? "/" . $action : "")); } die; }
if (isset($_GET['gameId'])) { $gameId = $_GET['gameId']; } } $quantity = 1; if (isset($_POST['quantity'])) { $quantity = $_POST['quantity']; } else { if (isset($_GET['quantity'])) { $quantity = $_GET['quantity']; } } if ($quantity < 1) { $quantity = 1; } if (!UtilFunctions::checkUserSession($userId)) { $result->result = "401 : auth error"; header("HTTP/1.1 401 Unauthorized"); echo json_encode($result); exit(1); } $log = KLogger::instance(KLOGGER_PATH . "apis/", KLogger::DEBUG); $error = false; if (!empty($userId)) { $user = GameUsers::getGameUserById($userId); if (empty($user)) { $error = false; $log->logError(LanguageUtils::getText("LANG_API_USER_EMPTY")); $result->result = LanguageUtils::getText("LANG_API_USER_EMPTY"); } else { $error = true;
$user->updateToDatabase(DBUtils::getConnection()); Queue::checkUserFriends($user->userId); UtilFunctions::storeSessionUser($user); $error = false; } else { //new user $facebook = new Facebook(array('appId' => FB_APP_ID, 'secret' => FB_APP_SECRET, 'cookie' => true)); $facebook->setAccessToken($fbToken); $fbUser = $facebook->api("/me"); $res = GameUsers::createGameUser($fbUser, $fbToken); if ($res->success) { $user = $res->result; $userId = $user->getUserId(); if (!empty($userId)) { Queue::checkUserFriends($userId); UtilFunctions::storeSessionUser($user); $newUser = "******"; $error = false; } } else { $result->result = LanguageUtils::getText("LANG_FACEBOOK_USER_CREATE_ERROR_UNKNOWN_ERROR"); } } } else { $result->result = "fbUserId or fbToken empty"; } if (!$error && !empty($user)) { $result->success = true; $result->result = new stdClass(); $result->result->user = $user; $result->result->dailyBonus = BonusUtils::getDailyBonusPrice($user);