function getEquip() { $db = new Database(); $link = $db->connect(); $result = $db->select($link, 'equip_type'); return $result; }
function main() { $program_start_time = microtime(true); $arguments = validate_arguments($_GET, array('platform' => 'int', 'metric' => 'int', 'testGroup' => 'int?', 'startTime' => 'int?', 'endTime' => 'int?')); $platform_id = $arguments['platform']; $metric_id = $arguments['metric']; $start_time = $arguments['startTime']; $end_time = $arguments['endTime']; if (!!$start_time != !!$end_time) { exit_with_error('InvalidTimeRange', array('startTime' => $start_time, 'endTime' => $end_time)); } $db = new Database(); if (!$db->connect()) { exit_with_error('DatabaseConnectionFailure'); } $fetcher = new MeasurementSetFetcher($db); if (!$fetcher->fetch_config_list($platform_id, $metric_id)) { exit_with_error('ConfigurationNotFound', array('platform' => $platform_id, 'metric' => $metric_id)); } $cluster_count = 0; while (!$fetcher->at_end()) { $content = $fetcher->fetch_next_cluster(); $cluster_count++; if ($fetcher->at_end()) { $cache_filename = "measurement-set-{$platform_id}-{$metric_id}.json"; $content['clusterCount'] = $cluster_count; $content['elapsedTime'] = (microtime(true) - $program_start_time) * 1000; } else { $cache_filename = "measurement-set-{$platform_id}-{$metric_id}-{$content['endTime']}.json"; } $json = success_json($content); generate_data_file($cache_filename, $json); } echo $json; }
public function __construct() { $this->db = new Database(); $this->gm = new GroupMeService('birthday'); $this->db->connect(); $this->process(); }
/** * Initialise a database connection. * @param $type * @param $hostname * @param $database * @param $username * @param $password * @return bool * @throws \Exception */ protected function initDatabase($type, $hostname, $database, $username, $password) { $className = "DBtrack\\Databases\\{$type}"; if (!class_exists($className)) { throw new \Exception('Unsupported database type: ' . $type); } $this->dbms = new $className($hostname, $database, $username, $password); return $this->dbms->connect(); }
/** * Site constructor * * Given all the settings values from the config file, the function sets * the values to all its settings preferences, on construct. * * It also starts the benchmarking process, prepares the emoticon variables * (using the emoticons.cfg), and then starts the Smarty service. * * @return void * @param string $configfile location of config settings .ini file */ function Site($configfile) { $this->startBenchmark(); $this->config = $this->fetchConfig($configfile); $this->db = new Database($this->config['database']['hostname'], $this->config['database']['username'], $this->config['database']['password'], $this->config['database']['name'], $this->config['database']['prefix']); $dbc = $this->db->connect(); if ($dbc !== TRUE) { $this->displayError('$site->Site', $dbc); } $this->name = $this->config['website']['name']; $this->title = $this->config['website']['title']; $this->slogan = $this->config['website']['slogan']; $this->url = $this->config['website']['url']; $this->path = $this->config['website']['path']; $this->theme = $this->config['website']['theme']; $this->webmaster = $this->config['webmaster']['name']; $this->email = $this->config['webmaster']['email']; $this->ad_pass = $this->config['admin']['password']; $this->prepareEmoticons(); $this->smarty = new Smarty(); // smarty directories $this->smarty->template_dir = 'templates/' . $this->theme; $this->smarty->compile_dir = 'templates_c'; $this->smarty->config_dir = 'configs'; $this->smarty->cache_dir = 'cache'; // custom modifiers & functions /* my plugins: * modifier.linkalize.php * modifier.autop.php * modifier.hebdate.php * modifier.n0tags.php * function.mymailto.php */ }
public static function rpc_post_install(Context $ctx) { $data = $ctx->post; if (empty($data['dbtype'])) { throw new RuntimeException(t('Вы не выбрали тип БД.')); } $config = $ctx->config; // Выносим секцию main в самое начало. $config['main'] = array(); if ($config->isok()) { throw new ForbiddenException(t('Инсталляция невозможна: конфигурационный файл уже есть.')); } $dsn = self::getDSN($data['dbtype'], $data['db'][$data['dbtype']]); if (!empty($data['db']['prefix'])) { $dsn['prefix'] = $data['db']['prefix']; } $config->set('modules/db', $dsn); foreach (array('modules/mail/server', 'modules/mail/from', 'main/debug/errors') as $key) { if (!empty($data[$key])) { $config->set($key, $data[$key]); } } $config->set('modules/files/storage', 'files'); $config->set('modules/files/ftp', 'ftp'); $config->set('main/tmpdir', 'tmp'); $config->set('main/debug/allow', array('127.0.0.1', $_SERVER['REMOTE_ADDR'])); // Создаём маршрут для главной страницы. $config['routes']['localhost/'] = array('title' => 'Molinos CMS', 'theme' => 'example', 'call' => 'BaseRoute::serve'); // Проверим соединение с БД. $pdo = Database::connect($config->get('modules/db')); // Подключились, можно сохранять конфиг. $config->save(); $ctx->redirect('admin/system/reload?destination=admin/system/settings'); }
function __construct() { if (!is_a($this->mysqli, "MySQLi")) { $this->mysqli = Database::connect(); } $this->initialize(); }
public function allusers($title, $body) { // To send HTML mail, the Content-type header must be set $header = 'MIME-Version: 1.0' . "\r\n"; $header .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; // Additional headers $header .= 'From: register@domain.com' . "\r\n"; $header .= 'Reply-To: register@domain.com' . "\r\n"; $header .= 'X-Mailer: PHP/' . phpversion(); $message = "<html>"; $message .= "<body>"; $message .= $body; $message .= "</body>"; $message .= "</html>"; //echo $message; $db = new Database(); $db->connect(); $query = "select `email` from `user` where `accountstatusid`>1"; $db->query($query); $tmp = $db->getresult(); foreach ($tmp as $value) { //echo "mail(".$value['email'].")<br>"; mail($value['email'], $title, $message, $header); } //mail('*****@*****.**',$title,$message,$header); }
private function count_members() { $query = "SELECT COUNT(*) AS num_of_members FROM members WHERE individual_headhunter = 'Y'"; $mysql = Database::connect(); $result = $mysql->query($query); return $result[0]['num_of_members']; }
function __construct($_id = "", $_seed_id = "") { if (!is_a($this->mysqli, "MySQLi")) { $this->mysqli = Database::connect(); } $this->initializeWith($_id, $_seed_id); }
function main($path) { if (count($path) > 1) { exit_with_error('InvalidRequest'); } $db = new Database(); if (!$db->connect()) { exit_with_error('DatabaseConnectionFailure'); } $task_id = array_get($_GET, 'task'); $query = array(); if ($task_id) { $triggerable = find_triggerable_for_task($db, $task_id); if (!$triggerable) { exit_with_error('TriggerableNotFoundForTask', array('task' => $task_id)); } $query['id'] = $triggerable['id']; } $id_to_triggerable = array(); foreach ($db->select_rows('build_triggerables', 'triggerable', $query) as $row) { $id = $row['triggerable_id']; $repositories = array(); $id_to_triggerable[$id] = array('id' => $id, 'name' => $row['triggerable_name'], 'acceptedRepositories' => &$repositories); } foreach ($db->select_rows('triggerable_repositories', 'trigrepo', array()) as $row) { $triggerable = array_get($id_to_triggerable, $row['trigrepo_triggerable']); if ($triggerable) { array_push($triggerable['acceptedRepositories'], $row['trigrepo_repository']); } } exit_with_success(array('triggerables' => array_values($id_to_triggerable))); }
function main($post_data) { set_exit_detail('failureStored', false); $db = new Database(); if (!$db->connect()) { exit_with_error('DatabaseConnectionFailure'); } // Convert all floating points to strings to avoid parsing them in PHP. // FIXME: Do this conversion in the submission scripts themselves. $parsed_json = json_decode(preg_replace('/(?<=[\\s,\\[])(\\d+(\\.\\d+)?)(\\s*[,\\]])/', '"$1"$3', $post_data), true); if (!$parsed_json) { exit_with_error('FailedToParseJSON'); } set_exit_detail('processedRuns', 0); foreach ($parsed_json as $i => $report) { $processor = new ReportProcessor($db); $processor->process($report); set_exit_detail('processedRuns', $i + 1); } $generator = new ManifestGenerator($db); if (!$generator->generate()) { exit_with_error('FailedToGenerateManifest'); } else { if (!$generator->store()) { exit_with_error('FailedToStoreManifest'); } } exit_with_success(); }
protected function validateDatabase($e) { if (!extension_loaded('pdo')) { $e->add($this->getDBErrorMsg()); } else { // attempt to connect to the database if (defined('DB_SERVER')) { $db = DB::connect(array('host' => DB_SERVER, 'user' => DB_USERNAME, 'password' => DB_PASSWORD, 'database' => DB_DATABASE)); $DB_SERVER = DB_SERVER; $DB_DATABASE = DB_DATABASE; } else { $db = DB::connect(array('host' => $_POST['DB_SERVER'], 'user' => $_POST['DB_USERNAME'], 'password' => $_POST['DB_PASSWORD'], 'database' => $_POST['DB_DATABASE'])); $DB_SERVER = $_POST['DB_SERVER']; $DB_DATABASE = $_POST['DB_DATABASE']; } if ($DB_SERVER && $DB_DATABASE) { if (!$db) { $e->add(t('Unable to connect to database.')); } else { $num = $db->GetCol("show tables"); if (count($num) > 0) { $e->add(t('There are already %s tables in this database. concrete5 must be installed in an empty database.', count($num))); } } } } return $e; }
public static function update_comment() { $sql_query = "UPDATE `comments` SET `comment` = 'This is a Test Mannnnn hehheeh' WHERE `id` = '2'"; $pdo = Database::connect(); $pdo->query($sql_query); Database::disconnect(); }
/** * @param $job_id * @return bool|mysqli_result */ public function check_complete($job_id) { //makes a request for verification Field work performed //db_connect() method extends from class Database $query = mysqli_query(Database::connect(), "SELECT job_done FROM family_job WHERE id='" . $job_id . "'") or die(mysqli_error(Database::connect())); return $query; }
function ajax($f3, $params) { Misc::debug_function_start(__CLASS__, __FUNCTION__, "(This is called when someone hits 'search')"); Database::connect(); $this->url_query = Misc::get_url_query($params, 3); if (!$this->url_query) { return false; } // SUBMISSION A PRIME if ($this->get_prime_data()) { $submit = array('str_search_field' => Misc::debrace($this->url_query), 'searchvalue' => $this->url_query, 'str_status_msg' => htmlspecialchars('Click "Clear" to start new search'), 'str_suppliers_head' => htmlspecialchars($this->str_suppliers_head), 'str_suppliers' => $this->str_suppliers, 'str_prime_definition' => $this->str_prime_definition, 'str_prime_examples' => $this->str_prime_examples, 'str_linked_items' => $this->str_linked_items, 'str_collective_items' => $this->str_collective_items, 'str_related_items' => $this->str_related_items); if (DEBUG) { $f3->get('FP')->log(__CLASS__ . "->" . __FUNCTION__ . " SUBMISSION A PRIME, CACHE=" . $f3->get('CACHE')); } $this->render_page("submit.htm", "text/xml", $submit); return; } // SUBMISSION A BP if ($this->get_bp_data()) { $submit = array('str_search_field' => Misc::debrace($this->url_query), 'searchvalue' => $this->url_query, 'str_status_msg' => htmlspecialchars('Click "Clear" to start new search'), 'str_suppliers_head' => htmlspecialchars($this->str_suppliers_head), 'str_suppliers' => $this->str_suppliers, 'str_prime_definition' => '', 'str_prime_examples' => '', 'str_linked_items' => '', 'str_collective_items' => '', 'str_related_items' => ''); if (DEBUG) { $f3->get('FP')->log(__CLASS__ . "->" . __FUNCTION__ . "SUBMISSION A BP, CACHE=" . $f3->get('CACHE')); } $this->render_page("submit.htm", "text/xml", $submit); return; } // SUBMISSION NOT A PRIME NOR BP $submit = array('str_search_field' => '', 'searchvalue' => $this->url_query, 'str_status_msg' => htmlspecialchars('Sorry, input not recognized. Spelling? To solve enter Keyword only.'), 'str_suppliers_head' => '', 'str_suppliers' => '', 'str_prime_definition' => '', 'str_prime_examples' => '', 'str_linked_items' => '', 'str_collective_items' => '', 'str_related_items' => ''); if (DEBUG) { $f3->get('FP')->log(__CLASS__ . "->" . __FUNCTION__ . "SUBMISSION NOT A PRIME NOR BP, CACHE=" . $f3->get('CACHE')); } $this->render_page("submit.htm", "text/xml", $submit); return; }
public function init($xml_location) { $this->xml_file = file_get_contents(dirname(__FILE__) . '/kina.xml', FILE_USE_INCLUDE_PATH); //$xml_file = file_get_contents('http://nowetwarze.goingapp.pl/kina.xml', FALSE, stream_context_create( array( 'http' => array( 'user_agent' => 'php' )))); $db_connect = new Database(); $db_connect->connect(); }
function buscar($b) { include 'crud/class/mysql_crud.php'; $db = new Database(); $db->connect(); $db->select('proveedor', 'idproveedor, razonsocial, numerodoc', NULL, ' UPPER(numerodoc) LIKE "%' . strtoupper($b) . '%"', NULL, '1'); // Table name, Column Names, WHERE conditions, ORDER BY conditions $res = $db->getResult(); $contar = $db->numRows(); if ($contar == 0) { echo "No se han encontrado resultados para '<b>" . $b . "</b>'."; } else { foreach ($res as $key => $value) { //$name = $value['numerodoc'].'|'.$value['razonsocial'].'|'.$value['idproveedor']; //array_push($data, $name); $id = $value['idproveedor']; $razonsocial = $value['razonsocial']; $numerodoc = $value['numerodoc']; $data = array('idproveedor' => $id, 'razonsocial' => $razonsocial, 'numerodoc' => $numerodoc); //echo $data['razonsocial']; } echo json_encode($data); exit; } }
function editEquip($value, $id) { $db = new Database(); $link = $db->connect(); $result = $db->update($link, 'equip_type', array('name' => $value), 'type_id=' . $id); return $result; }
function ajax($f3, $params) { Misc::debug_function_start(__CLASS__, __FUNCTION__, "(This is called when something is entered in the search box and returns suggestions)"); Database::connect(); $this->url_query = Misc::get_url_query($params); if (DEBUG) { $f3->get('FP')->log(__CLASS__ . "->" . __FUNCTION__ . "() \$this->url_query = {$this->url_query}"); } if ($this->url_query) { if (!$this->get_prime_vars($this->url_query)) { return false; } $this->prime_bp_matches(); $function = $this->get_function_name(); if (!method_exists($this, $function)) { Misc::$no_suggestions = FUNCTION_MISSING; $this->setResponse(__LINE__); if (DEBUG) { $f3->get('FP')->log(__CLASS__ . "->" . __FUNCTION__ . "() Method \$this->{$function}() does not exist"); } return Misc::quit_suggest(__LINE__); } $this->{$function}(); } if (!Misc::$suggestions) { Misc::$no_suggestions = NO_RESULTS_AT_ALL; $this->setResponse(__LINE__); if (DEBUG) { $f3->get('FP')->log(__CLASS__ . "->" . __FUNCTION__ . "() \$this->{$function}() no results"); } return Misc::quit_suggest(__LINE__); } Misc::render_ajax_suggestions(); }
function addNewEquip($value) { $db = new Database(); $link = $db->connect(); $result = $db->update($link, 'equip_type', array('name' => 2)); return $result; }
function main($post_data) { $db = new Database(); if (!$db->connect()) { exit_with_error('DatabaseConnectionFailure'); } $report = json_decode($post_data, true); verify_slave($db, $report); $commits = array_get($report, 'commits', array()); foreach ($commits as $commit_info) { if (!array_key_exists('repository', $commit_info)) { exit_with_error('MissingRepositoryName', array('commit' => $commit_info)); } if (!array_key_exists('revision', $commit_info)) { exit_with_error('MissingRevision', array('commit' => $commit_info)); } require_format('Revision', $commit_info['revision'], '/^[A-Za-z0-9 \\.]+$/'); if (array_key_exists('author', $commit_info) && !is_array($commit_info['author'])) { exit_with_error('InvalidAuthorFormat', array('commit' => $commit_info)); } } $db->begin_transaction(); foreach ($commits as $commit_info) { $repository_id = $db->select_or_insert_row('repositories', 'repository', array('name' => $commit_info['repository'])); if (!$repository_id) { $db->rollback_transaction(); exit_with_error('FailedToInsertRepository', array('commit' => $commit_info)); } $author = array_get($commit_info, 'author'); $committer_id = NULL; if ($author) { $account = array_get($author, 'account'); $committer_query = array('repository' => $repository_id, 'account' => $account); $committer_data = $committer_query; $name = array_get($author, 'name'); if ($name) { $committer_data['name'] = $name; } $committer_id = $db->update_or_insert_row('committers', 'committer', $committer_query, $committer_data); if (!$committer_id) { $db->rollback_transaction(); exit_with_error('FailedToInsertCommitter', array('committer' => $committer_data)); } } $parent_revision = array_get($commit_info, 'parent'); $parent_id = NULL; if ($parent_revision) { $parent_commit = $db->select_first_row('commits', 'commit', array('repository' => $repository_id, 'revision' => $parent_revision)); if (!$parent_commit) { $db->rollback_transaction(); exit_with_error('FailedToFindParentCommit', array('commit' => $commit_info)); } $parent_id = $parent_commit['commit_id']; } $data = array('repository' => $repository_id, 'revision' => $commit_info['revision'], 'parent' => $parent_id, 'order' => array_get($commit_info, 'order'), 'time' => array_get($commit_info, 'time'), 'committer' => $committer_id, 'message' => array_get($commit_info, 'message'), 'reported' => true); $db->update_or_insert_row('commits', 'commit', array('repository' => $repository_id, 'revision' => $data['revision']), $data); } $db->commit_transaction(); exit_with_success(); }
function main($id, $path, $post_data) { if (!$id && (count($path) < 1 || count($path) > 2)) { exit_with_error('InvalidRequest'); } $db = new Database(); if (!$db->connect()) { exit_with_error('DatabaseConnectionFailure'); } $report = $post_data ? json_decode($post_data, true) : array(); $updates = array_get($report, 'buildRequestUpdates'); if ($updates) { verify_slave($db, $report); update_builds($db, $updates); } $requests_fetcher = new BuildRequestsFetcher($db); if ($id) { $requests_fetcher->fetch_request($id); } else { $triggerable_query = array('name' => array_get($path, 0)); $triggerable = $db->select_first_row('build_triggerables', 'triggerable', $triggerable_query); if (!$triggerable) { exit_with_error('TriggerableNotFound', $triggerable_query); } $requests_fetcher->fetch_incomplete_requests_for_triggerable($triggerable['triggerable_id']); } exit_with_success(array('buildRequests' => $requests_fetcher->results_with_resolved_ids(), 'rootSets' => $requests_fetcher->root_sets(), 'roots' => $requests_fetcher->roots(), 'updates' => $updates)); }
public function __construct($host = NULL) { if (is_null($host)) { $this->Host = $this->Setting('master_host'); } else { $this->Host = $host; } $this->MythProto = new MythProto($this); if (isset($_ENV['MYTHCONFDIR'])) { $this->ConfigFiles[] = $_ENV['MYTHCONFDIR']; } // look for config files $found = FALSE; foreach ($this->ConfigFiles as $ConfigFile) { // Php does not appear to honor ~, so we fake it. $ConfigFile = str_replace('~', $_ENV['HOME'], $ConfigFile); $this->ConfigFile = realpath($ConfigFile); if ($this->ConfigFile) { $found = TRUE; break; } } if (!$found) { die("Cannot find a valid config file.\n"); } $this->LoadConfig(); $this->DB = Database::connect($this->Config['DBName'], $this->Config['DBUserName'], $this->Config['DBPassword'], $this->Config['DBHostName'], null, 'mysql'); // Unset the password to protect the mysql server unset($this->Config['DBPassword']); }
function getNewsArticle($article_id) { $db = Database::connect(); $query = 'SELECT * FROM `news` ' . $db->prepare('WHERE `id` = ?i LIMIT 1;', $article_id); $articles = Database::get_data($query, $db); return $articles[0]; }
/** * Creates the configuration file. * @return true|string Returns true when successful. * Warning: Connection failed! * Warning: Creation failed! * Warning: Could not create file! */ public static function create($host, $user, $password, $name = 'lychee', $prefix = '') { // Open a new connection to the MySQL server $connection = Database::connect($host, $user, $password); // Check if the connection was successful if ($connection === false) { return 'Warning: Connection failed!'; } // Check if user can create the database before saving the configuration if (Database::createDatabase($connection, $name) === false) { return 'Warning: Creation failed!'; } // Escape data $host = mysqli_real_escape_string($connection, $host); $user = mysqli_real_escape_string($connection, $user); $password = mysqli_real_escape_string($connection, $password); $name = mysqli_real_escape_string($connection, $name); $prefix = mysqli_real_escape_string($connection, $prefix); // Save config.php $config = "<?php\n\n// Database configuration\n\$dbHost = '{$host}'; // Host of the database\n\$dbUser = '******'; // Username of the database\n\$dbPassword = '******'; // Password of the database\n\$dbName = '{$name}'; // Database name\n\$dbTablePrefix = '{$prefix}'; // Table prefix\n\n?>"; // Save file if (@file_put_contents(LYCHEE_CONFIG_FILE, $config) === false) { return 'Warning: Could not create file!'; } return true; }
public function loginAction() { $user = $_POST['email']; $pass = $_POST['password']; $base = new Database(); $con = $base->connect(); $sql = "select * from admin where (email= \"" . $user . "\" or username= \"" . $user . "\" ) and password= \"" . $pass . "\""; //print $sql; $query = $con->query($sql); $found = false; $userid = null; while ($r = $query->fetch_array()) { $found = true; $userid = $r['id']; } if ($found == true) { session_start(); // print $userid; $_SESSION['admin_id'] = $userid; // setcookie('userid',$userid); // print $_SESSION['userid']; print "Cargando ... {$user}"; print "<script>window.location='./';</script>"; } else { print "<script>window.location='./';</script>"; } }
function __construct() { if (!isset($_SESSION)) { session_start(); } $database = new Database(); $this->dbh = $database->connect(); }
private function mark_all_referrals_viewed() { $mysqli = Database::connect(); $query = "UPDATE referrals SET response_counted = TRUE\n WHERE response_counted = FALSE AND \n view_counted = FALSE AND \n (referrals.employed_on IS NULL OR referrals.employed_on = '0000-00-00 00:00:00') AND \n (referrals.work_commence_on IS NULL OR referrals.work_commence_on = '0000-00-00 00:00:00') AND \n (referrals.referee_acknowledged_on IS NOT NULL AND referrals.referee_acknowledged_on <> '0000-00-00 00:00:00') AND \n (referrals.referee_rejected_on IS NULL OR referrals.referee_rejected_on = '0000-00-00 00:00:00') AND \n (referrals.replacement_authorized_on IS NULL OR referrals.replacement_authorized_on = '0000-00-00 00:00:00') AND \n (referrals.employer_agreed_terms_on IS NULL OR referrals.employer_agreed_terms_on = '0000-00-00 00:00:00') AND \n member = '" . $this->member->id() . "'"; $mysqli->execute($query); $query = "UPDATE referrals SET view_counted = TRUE \n WHERE view_counted = FALSE AND \n (referrals.employed_on IS NULL OR referrals.employed_on = '0000-00-00 00:00:00') AND \n (referrals.work_commence_on IS NULL OR referrals.work_commence_on = '0000-00-00 00:00:00') AND \n (referrals.referee_acknowledged_on IS NOT NULL AND referrals.referee_acknowledged_on <> '0000-00-00 00:00:00') AND \n (referrals.referee_rejected_on IS NULL OR referrals.referee_rejected_on = '0000-00-00 00:00:00') AND \n (referrals.replacement_authorized_on IS NULL OR referrals.replacement_authorized_on = '0000-00-00 00:00:00') AND \n (referrals.employer_agreed_terms_on IS NOT NULL AND referrals.employer_agreed_terms_on <> '0000-00-00 00:00:00') AND \n member = '" . $this->member->id() . "'"; $mysqli->execute($query); }
function connect() { $db = new Database(); if (!$db->connect()) { exit_with_error('DatabaseConnectionError'); } return $db; }