function getCrmModel() { $config = array('hostname' => "pdb10.runhosting.com", 'username' => "998905_myblog", 'password' => "1234", 'database' => "998905_myblog"); $db = new OBJ_mysql($config); $customers = $db->query("SELECT * FROM crm_company WHERE deleted != 1")->fetchAll(); $deals = $db->query("SELECT * FROM crm_deals WHERE deleted != 1")->fetchAll(); $tasks = $db->query("SELECT * FROM crm_tasks WHERE deleted != 1")->fetchAll(); $people = $db->query("SELECT * FROM crm_people WHERE deleted != 1")->fetchAll(); foreach ($customers as $customer) { $pPeople = new Plinq($people); $pTasks = new Plinq($tasks); $pDeals = new Plinq($deals); $customer->people = $pPeople->Where(function ($k, $v) use($customer) { return $v->company_id == $customer->company_id; })->ToArray(); $customer->deals = $pDeals->Where(function ($k, $v) use($customer) { return $v->deal_company == $customer->company_id; })->ToArray(); $customer->tasks = $pTasks->Where(function ($k, $v) use($customer) { return $v->task_company == $customer->company_id; })->ToArray(); } return $customers; }
<?php if (isset($_POST['username']) && isset($_POST['password'])) { $username = $_POST['username']; $password = $_POST['password']; include_once '../assets/php/Database.php'; $config = array('hostname' => "pdb10.runhosting.com", 'username' => "998905_myblog", 'password' => "1234", 'database' => "998905_myblog"); $db = new OBJ_mysql($config); $q = "SELECT * FROM users WHERE username = '******' AND password = '******'"; $query = $db->query($q); $result = $query->fetchAll(); if (count($result) == 1) { if (isset($_SESSION['ted'])) { session_unset(); session_destroy(); } include_once '../assets/php/session.php'; //print_r ($result); $_SESSION['ted'] = $result['username']; $_SESSION['ted']['AUTH'] = "true"; header("Location: dashboard.php"); } else { echo "Invalid username or password. Please click <a href='../index.html'>here</a> to try again."; } } else { echo "You have reached this page in error. Please leave."; }
/* * Copyright (C) 2012 Jonathan Tavares <*****@*****.**> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ include "bin/OBJ_mysql.php"; //database configuration $config = array('hostname' => 'localhost', 'username' => 'root', 'password' => '', 'database' => 'test'); //creating a new MySQL Connection $db = new OBJ_mysql($config); $query = $db->query("show tables"); var_dump($query); $query = $db->query("SELECT * FROM client LIMIT 10 "); $array = $query->fetchAll(); $array2 = $query->fetchColumn('telefone'); $array3 = $query->fetchArrayPair('id_client', 'usern'); var_dump($array); var_dump($array2); var_dump($array3);
// check if no other conferences with the same access_code exists $Result = $db->query("SELECT * FROM participants WHERE conference_id = ? AND passcode = ?", array($conference_id, $passcode)); $Parts = $Result->fetchALL(); if (sizeof($Parts) > 0) { return true; } else { return false; } } $action_types = array('authorize', 'create_conference', 'delete_conference', 'add_participant', 'edit_participant', 'remove_participant', 'get_participants', 'get_numbers', 'get_access_code', 'start_conference', 'get_conference_info', 'get_conference', 'save_ms_url', 'mute_participant', 'unmute_participant', 'disconnect_participant', 'redial_participant'); if (isset($_REQUEST['action'])) { $action = $_REQUEST['action']; if (!in_array($action, $action_types)) { terminate("Unknown action type specified"); } $db = new OBJ_mysql($config); if (isset($_REQUEST['params'])) { $_REQUEST['params'] = stripslashes($_REQUEST['params']); } if ($action != 'authorize') { if (!isset($_SESSION['manager_id'])) { terminate("Unauthorized"); } } if ($action != 'get_numbers') { if (!isset($_REQUEST['params'])) { terminate("Params not specified"); } else { $data = json_decode($_REQUEST['params'], true); } }