function show_branch() { switch (@$_GET['message']) { case "branchjustadded": $message_html = template_get("message", array('message' => "Город успешно добавлен")); break; default: $message_html = template_get("nomessage"); } $branch_id = $_GET['branch']; $branch = db_easy("SELECT * FROM `phpbb_branches` WHERE `id`={$branch_id}"); $pointsRES = db_query("SELECT * FROM `phpbb_points` WHERE `branch_id`={$branch_id}"); if (db_count($pointsRES) > 0) { while ($point = db_fetch($pointsRES)) { $points_html .= "<div style='padding-bottom:5px;'><a href='/manager.php?action=show_point&point={$point['id']}'>{$point['name']}</a></div>"; } } else { $points_html = "-"; } if (check_rights('add_branch')) { $edit_branch_html = "<a href='/manager.php?action=edit_branch&branch={$branch_id}' style='font-size:8pt;'>Редактировать</a>"; } $html .= template_get("branches/show_branch", array('name' => $branch['name'], 'editbranch' => $edit_branch_html, 'message' => $message_html, 'points' => $points_html)); return $html; }
function display_trial_balance() { global $table_style, $path_to_root; start_table($table_style); $tableheader = "<tr>\n <td rowspan=2 class='tableheader'>" . tr("Account") . "</td>\n <td rowspan=2 class='tableheader'>" . tr("Account Name") . "</td>\n\t\t<td colspan=2 class='tableheader'>" . tr("Brought Forward") . "</td>\n\t\t<td colspan=2 class='tableheader'>" . tr("This Period") . "</td>\n\t\t<td colspan=2 class='tableheader'>" . tr("Balance") . "</td>\n\t\t</tr><tr>\n\t\t<td class='tableheader'>" . tr("Debit") . "</td>\n <td class='tableheader'>" . tr("Credit") . "</td>\n\t\t<td class='tableheader'>" . tr("Debit") . "</td>\n\t\t<td class='tableheader'>" . tr("Credit") . "</td>\n <td class='tableheader'>" . tr("Debit") . "</td>\n <td class='tableheader'>" . tr("Credit") . "</td>\n </tr>"; echo $tableheader; $k = 0; $accounts = get_gl_accounts(); while ($account = db_fetch($accounts)) { if (is_account_balancesheet($account["account_code"])) { $begin = null; } else { $begin = begin_fiscalyear(); if ($_POST['TransFromDate'] < $begin) { $begin = $_POST['TransFromDate']; } $begin = add_days($begin, -1); } $prev_balance = get_balance($account["account_code"], $begin, $_POST['TransFromDate'], false, false); $curr_balance = get_balance($account["account_code"], $_POST['TransFromDate'], $_POST['TransToDate']); if (check_value("NoZero") && !$prev_balance && !$curr_balance) { continue; } alt_table_row_color($k); $url = "<a href='{$path_to_root}/gl/inquiry/gl_account_inquiry.php?" . SID . "TransFromDate=" . $_POST["TransFromDate"] . "&TransToDate=" . $_POST["TransToDate"] . "&account=" . $account["account_code"] . "'>" . $account["account_code"] . "</a>"; label_cell($url); label_cell($account["account_name"]); display_debit_or_credit_cells($prev_balance); display_debit_or_credit_cells($curr_balance); display_debit_or_credit_cells($prev_balance + $curr_balance); end_row(); } end_table(1); }
function getQueue($type = false) { if (!$type) { $type = $this->name; } loader_import('cms.Workspace.Notice.' . $this->types[$type]); $res = db_fetch('select * from sitellite_msg_queue where type = ?', $type); if (!$res) { $this->error = db_error(); return false; } elseif (is_object($res)) { $res = array($res); } foreach ($res as $k => $v) { $qid = $res[$k]->id; $struct = $res[$k]->struct; $res[$k] = unserialize($struct); if (!$res[$k]) { $this->error = 'unserialize() failed: ' . $struct; return false; } $res[$k]->qid = $qid; } return $res; }
function EntryAddForm() { parent::MailForm(); $this->parseSettings('inc/app/timetracker/forms/entry/add/settings.php'); $res = db_fetch('select username, firstname, lastname from sitellite_user order by lastname asc'); if (!$res) { $res = array(); } elseif (is_object($res)) { $res = array($res); } $users = array(); foreach ($res as $row) { if (!empty($row->lastname)) { $users[$row->username] = $row->lastname; if (!empty($row->firstname)) { $users[$row->username] .= ', ' . $row->firstname; } $users[$row->username] .= ' (' . $row->username . ')'; } else { $users[$row->username] = $row->username; } } $this->widgets['users']->setValues($users); $this->widgets['users']->setDefault(session_username()); $this->widgets['users']->addRule('not empty', 'You must select at least one user.'); $this->widgets['started']->setDefault(date('Y-m-d H:i:s')); $this->widgets['ended']->setDefault(date('Y-m-d H:i:s')); global $cgi; $this->widgets['proj_name']->setValue(db_shift('select name from timetracker_project where id = ?', $cgi->project)); $this->widgets['submit_button']->buttons[1]->extra = 'onclick="history.go (-1); return false"'; }
function search_facets_extras_values_by_name($name, $viewer_id = 0, $more = array()) { $enc_name = AddSlashes($name); $sql = "SELECT e.value, COUNT(d.dot_id) AS count_dots, COUNT(DISTINCT(d.sheet_id)) AS count_sheets"; $sql .= " FROM DotsSearch d, DotsSearchExtras e WHERE 1"; $sql .= " AND d.dot_id=e.dot_id"; $sql .= " AND e.name='{$enc_name}'"; if ($more['user_id']) { $enc_user = AddSlashes($more['user_id']); $sql .= " AND d.user_id='{$enc_user}'"; } # See those perms? That makes caching hard unless # we only facet on public things... if ($perms = _search_facets_perms($viewer_id, $more)) { $sql .= " AND {$perms}"; } $sql .= " GROUP BY e.value"; $rsp = db_fetch($sql, $more); # We sort in memory because ORDER-ing by 'count_sheets' in MySQL # will always cause a filesort (because we're already grouping on # another column) function cmp($a, $b) { if ($a['count_sheets'] == $b['count_sheets']) { return 0; } return $a['count_sheets'] > $b['count_sheets'] ? -1 : 1; } usort($rsp['rows'], 'cmp'); # _search_facets_paginate($rsp, $more); return $rsp; }
function get_comment() { /*Получаем данные от пользователя*/ if (isset($_POST['id'])) { if (!preg_match("/^comment\\-[0-9]{1,2}\\-[0-9]{4}\\-[0-9]{1,2}\\-[0-9]{1,2}\$/", $_POST['id'])) { return "Ошибка в формате входных данных (td)."; } else { $id = $_POST['id']; } } else { return "Не определены входные данные (id)"; } /*Обрабатываем полученные данные*/ $temp = explode('-', $id); $year = (int) $temp[2]; $month = (int) $temp[3]; $day = (int) $temp[4]; //Запрос к базе $q = db_query("SELECT * FROM `phpbb_timetable_comments` WHERE `year`={$year} AND `month`={$month} AND `day`={$day}"); if (db_count($q) == 0) { return 1; } else { $result = db_fetch($q); return $result['comment1'] . "\n" . $result['comment2'] . "\n" . $result['comment3']; } }
function page_index() { $q = db_query("SELECT * FROM `intr_message`"); $message_html = ""; if (get_user_group() == "writer") { $add_message_html = "<a href='" . uri_make_v1(array("UriScript" => "intranet.php", "add_message" => "yes")) . "' style='padding:0 0 0 10px;'><img src='/_content/img/add-icon.png'/></a>"; } else { $add_message_html = ""; } while ($message = db_fetch($q)) { $message_html .= "<a href='" . uri_make_v1(array("UriScript" => "intranet.php", "page" => "message", "message" => $message['id'])) . "'>" . trim($message['title']) . "</a>"; if (check_group("writer") || $user['name'] == get_user()) { //$message_html.="<br/><a href='".uri_make_v1(array("UriScript"=>'intranet.php', 'edit_message'=>'yes', 'message'=>$message['id']))."' style='font-size:8pt;'>Редактировать</a>"; //$message_html.="<a href='".uri_make_v1(array("UriScript"=>'intranet.php', 'delete_message'=>'yes', 'message'=>$message['id']))."' style='padding-left:10px;font-size:8pt;' onClick=\"if(!confirm('Удалить?')) return false;\">Удалить</a>"; //$message_html.="<br/><br/>"; /*$comments_html.="<a href='".uri_make_v1(array("UriScript"=>'intranet.php', 'page'=>'message', 'message'=>$message['id'], 'edit_comment'=>'yes', 'comment'=>$comment['id']))."' style='font-size:8pt;'>Редактировать</a>"; $comments_html.="<a href='".uri_make_v1(array("UriScript"=>'intranet.php', 'page'=>'message', 'message'=>$message['id'], 'delete_comment'=>'yes', 'comment'=>$comment['id']))."' style='padding-left:10px;font-size:8pt;' onClick=\"if(!confirm('Удалить?')) return false;\">Удалить</a>"; */ $message_html .= "<a href='" . uri_make_v1(array("UriScript" => "intranet.php", "edit_message" => "yes", "message" => $message['id'])) . "' style='padding:0 0 0 10px;'><img src='/_content/img/edit-icon.png'/></a>"; $message_html .= "<a href='" . uri_make_v1(array("UriScript" => "intranet.php", "delete_message" => "yes", "message" => $message['id'])) . "' style='padding:0 0 0 10px;' onClick=\"if(!confirm('Удалить?')) return false;\"><img src='/_content/img/remove-icon.png'/></a>" . "<br/>"; } } $contacts_html = ""; $q = db_query("SELECT * FROM `users`"); while ($user = db_fetch($q)) { $contacts_html .= "<a href='" . uri_make_v1(array("UriScript" => "intranet.php", "page" => "contact", "name" => $user['name'])) . "'>" . $user['name_rus'] . "</a>" . "<br/>"; } $html .= template_get('intranet/intranet', array("add_message" => $add_message_html, "message" => $message_html, "contacts" => $contacts_html)); //Подключаем подвал $html .= template_get('footer'); return $html; }
function sheets_lookup_by_fingerprint($fingerprint, $user_id = 0) { $cache_key = "sheets_lookup_fingerprint_{$fingerprint}"; $cache = cache_get($cache_key); if ($cache['ok']) { return $cache['data']; } # $enc_fingerprint = AddSlashes($fingerprint); $sql = "SELECT * FROM SheetsLookup WHERE fingerprint='{$enc_fingerprint}'"; if ($user_id) { $enc_id = AddSlashes($user_id); $sql .= " AND user_id='{$enc_id}'"; } $rsp = db_fetch($sql); $sheets = array(); foreach ($rsp['rows'] as $row) { $more = array('sheet_user_id' => $row['user_id']); if ($sheet = sheets_get_sheet($row['sheet_id'], $user_id, $more)) { $sheets[] = $sheet; } } cache_set($cache_key, $sheets); return $sheets; }
function render($id, $title) { global $path_to_root; include_once $path_to_root . "/includes/ui.inc"; $today = date2sql(Today()); $sql = "SELECT bank_act, bank_account_name, SUM(amount) balance FROM " . TB_PREF . "bank_trans bt" . " INNER JOIN " . TB_PREF . "bank_accounts ba ON bt.bank_act = ba.id" . " WHERE trans_date < '{$today}'" . " AND inactive <> 1"; if ($this->data_filter != '') { $sql .= ' AND ' . $this->data_filter; } $sql .= " GROUP BY bank_act, bank_account_name" . " ORDER BY bank_account_name"; $result = db_query($sql); br(); $th = array(_("Account"), _("Balance")); start_table(TABLESTYLE, "width=98%"); table_header($th); $k = 0; //row colour counter while ($myrow = db_fetch($result)) { alt_table_row_color($k); label_cell($myrow["bank_account_name"]); amount_cell($myrow['balance']); end_row(); } end_table(1); }
function player_load_option(&$user, $option_id = null) { $options = null; if (!empty($option_id)) { if (is_array($option_id)) { foreach ($option_id as $key => $option) { if (isset($user['player_options'][$option])) { $options[$option] = $user['player_options'][$option]; unset($option_id[$key]); } } } else { if (isset($user['player_options'][$option_id])) { $options = $user['player_options'][$option_id]; $option_id = 0; } } } if (isset($user['id']) && is_numeric($user['id']) && (!isset($option_id) || !empty($option_id))) { !is_array($option_id) or array_walk($option_id, function (&$value) { $value = "'{$value}'"; }); $query = doquery($q = "SELECT * FROM {{player_options}} WHERE `player_id` = {$user['id']}" . ($option_id ? " AND option_id " . (is_array($option_id) ? 'IN (' . implode(',', $option_id) . ')' : "= '{$option_id}'") : '')); while ($row = db_fetch($query)) { $user['player_options'][$row['option_id']] = $row['value']; $options[$row['option_id']] = $row['value']; } is_array($option_id) || !$option_id or $options = isset($options[$option_id]) ? $options[$option_id] : null; } return empty($options) ? null : $options; }
function list_stat_by_dates() { //Определяем переменные $stat_html = ""; $users = array(); $stats = array(); $userStats = array(); //Запрос к базе $usersRES = db_query("SELECT *\r\n\t\t\t\t\t\t\t\tFROM `phpbb_users`\r\n\t\t\t\t\t\t\t\tWHERE (`user_type`=0 OR `user_type`=3) AND `username`!='root' AND `user_email`!='*****@*****.**' AND `user_id`!=95 AND `user_id`!=5871\r\n\t\t\t\t\t\t\t\tORDER BY `username` ASC"); //Цикл while ($userWHILE = db_fetch($usersRES)) { $users[$userWHILE['user_id']]['name'] = $userWHILE['username']; } //Запрос к базе $statsRES = db_query("SELECT * FROM `phpbb_stat` ORDER BY `date` DESC"); //Цикл while ($statWHILE = db_fetch($statsRES)) { if ($statWHILE['user_id'] != 5871) { $date_stats[date("d/m/Y", strtotime($statWHILE['date']))][] = array('uri' => $statWHILE['uri'], 'time' => date("H:i", strtotime($statWHILE['date'])), 'user_id' => $statWHILE['user_id']); } } //Цикл foreach ($date_stats as $date => $stat) { $stat_html .= "<a href='manager.php?action=show_stat&date={$date}'>" . $date . "</a>: " . count($stat) . "<br/>"; } //Возвращаем значение функции return $html .= template_get("stat/list_stat", array('userStats' => $stat_html)); }
function OneCatValue($table, $value1, $value2, $ident, $param) { $query = "SELECT " . $value1 . "," . $value2 . " FROM " . $table . " WHERE " . $ident . " = " . $param; $result = db_query($query); $row = db_fetch($result); return $row[$value1] . " " . $row[$value2]; }
function menu_top($manual_items=""){ //Подключаем глобальную переменную global $DocumentId; db_connect(); $html_items=" <a href='/engine.php?table=documents'>Документ покупки</a><span class='divider'></span> <a href='/engine.php?table=computers'>Сборки компьютеров</a><span class='divider'></span> <a href='/statistics.php'>Статистика</a><span class='divider'></span> <a href='/engine.php?table=documents&document=$DocumentId&action=list_contragents'>Контрагенты</a><span class='divider'></span> <a href='/engine.php?table=documents&document=$DocumentId&action=list_positions'>Позиции</a><span class='divider'></span> <br/> "; //Запрашиваем из таблицы БД 'menus' все пункты меню, принадлежащие размещению 'top' $items_query=db_query("SELECT `href`, `text`, `label` FROM `menu_items` WHERE `area`='top' ORDER BY `order` ASC"); $number_item=1; //Ручное добавление пунктов $html_items.=$manual_items; //Пункты меню найдены if(db_count($items_query)>0){ //Перебираем пункты меню while($item=db_fetch($items_query)){ $html_items.="<a href='{$item['href']}' class='".get_class_depend_on_uri("!=", 'table_name', $item['label'])."'>{$item['text']}</a>"; $html_items.="<span class='divider'></span>"; if($number_item % 7 == 0) $html_items.="<br/>"; $number_item++; } //Такие пункты меню не найдены } return template_get('menus/menu_top', array('html_items'=>$html_items, 'login'=>$_SESSION['user'])); }
function page_message() { $message_id = $_GET['message']; $message = db_easy("SELECT * FROM `intr_message` WHERE `id`={$message_id}"); $q_comm = db_query("SELECT * FROM `intr_comments` WHERE `message_id`={$message_id} ORDER BY `date` DESC"); $user = db_easy("SELECT * FROM `users` WHERE `id`=" . $message['user_id']); $edit_del_comment_html = ""; if (check_group("writer") || $user['name'] == get_user()) { $edit_del_message_html .= "<br/><a href='" . uri_make_v1(array("UriScript" => 'intranet.php', 'page' => 'message', 'message' => $message_id, 'edit_message' => 'yes', 'message' => $message['id'])) . "' style='font-size:8pt;'>Редактировать</a>"; $edit_del_message_html .= "<a href='" . uri_make_v1(array("UriScript" => 'intranet.php', 'page' => 'message', 'message' => $message_id, 'delete_message' => 'yes', 'message' => $message['id'])) . "' style='padding-left:10px;font-size:8pt;' onClick=\"if(!confirm('Удалить?')) return false;\">Удалить</a>"; } $comments_html = ""; while ($comment = db_fetch($q_comm)) { $user = db_easy("SELECT * FROM `users` WHERE `id`={$comment['user_id']}"); $comments_html .= "<div style='margin:15px 0 0 0;padding:0 0 0 10px;border-left:2px solid #AAA;'>"; $comments_html .= "<span style='font-size:8pt;font-style:italic;'><b>" . $user['name_rus'] . ",</b> " . date("d.m.Y H:i", strtotime($comment['date'])) . "</span><br/>" . $comment['text'] . "</div>"; if (check_group("writer") || $user['name'] == get_user()) { $comments_html .= "<a href='" . uri_make_v1(array("UriScript" => 'intranet.php', 'page' => 'message', 'message' => $message_id, 'edit_comment' => 'yes', 'comment' => $comment['id'])) . "' style='font-size:8pt;'>Редактировать</a>"; $comments_html .= "<a href='" . uri_make_v1(array("UriScript" => 'intranet.php', 'page' => 'message', 'message' => $message_id, 'delete_comment' => 'yes', 'comment' => $comment['id'])) . "' style='padding-left:10px;font-size:8pt;' onClick=\"if(!confirm('Удалить?')) return false;\">Удалить</a>"; } } $html .= template_get('message/message', array("user" => $user['name_rus'], "date" => date("d.m.Y", strtotime($message['date'])), "title" => $message['title'], "edit_del_message" => $edit_del_message_html, "text" => $message['text'], "uri_back" => uri_make_v1(array("UriScript" => "intranet.php")), "uri_comment" => uri_make_v1(array("UriScript" => "intranet.php", "page" => "message", "message" => $message_id, "add_comment" => "yes")), "comments" => $comments_html)); //Подключаем подвал $html .= template_get('footer'); return $html; }
function flickr_push_subscriptions_get_by_user_and_topic(&$user, $topic_id, $topic_args = null) { if ($topic_args) { $topic_args = json_encode($topic_args); } $cache_key = "flickr_push_subscriptions_user_{$user['id']}_{$topic_id}"; if ($topic_args) { $cache_key .= "#" . md5($topic_args); } $cache = cache_get($cache_key); if ($cache['ok']) { $row = $cache['data']; } else { $enc_id = AddSlashes($user['id']); $enc_topic = AddSlashes($topic_id); $enc_args = $topic_args ? AddSlashes($topic_args) : ""; $sql = "SELECT * FROM FlickrPushSubscriptions WHERE user_id='{$enc_id}' AND topic_id='{$enc_topic}' AND topic_args='{$enc_args}'"; $rsp = db_fetch($sql); $row = db_single($rsp); if ($row) { cache_set($cache_key, $row, "cache locally"); } } return $row; }
public static function login($name, $email, $user) { if (!$name || !$user) { throw new Exception('Wypełnij wszystkie pola.'); } $user = new ChatUser(array('name' => $name, 'gravatar' => $user)); include_once "../db_connect.php"; include_once "../include/ust.php"; $Querys = 'SELECT * FROM ' . $pre . 'user WHERE user_id=' . $_SESSION['user_id'] . ''; $results = db_query($Querys) or die(db_error()); while ($rows = db_fetch($results)) { $ile_pkt = $rows['user_money']; if ($rows['user_vip'] >= time()) { $czy_vp = 1; } $user_chat = $rows['user_chat']; } if ($user_chat == 1) { throw new Exception('Masz zablokowany dostęp do czatu.'); } if ($czy_vp != 1) { if ($ile_pkt > $ust['chatp']) { $up = "UPDATE " . $pre . "user SET user_money=user_money-" . $ust['chatp'] . " WHERE user_id='" . db_real_escape_string($_SESSION['user_id']) . "'"; db_query($up); } else { throw new Exception('Masz zamało punktów by dołączyć do czatu.'); } } // The save method returns a MySQLi object if ($user->save()->affected_rows != 1) { throw new Exception('Nick jest zajęty.'); } $_SESSION['user'] = array('name' => $name, 'gravatar' => $user); return array('status' => 1, 'name' => $name, 'gravatar' => $user); }
function check_rights($right_name = "") { //Define global variables global $user; //Check rights if (isset($GLOBALS['super_rights_users'][$user->data['username']])) { //For users with super rights return true; } else { //If if ($right_name !== "") { $rightRES = db_query("SELECT * FROM `phpbb_rights` WHERE `name`='{$right_name}'"); if (db_count($rightRES) == 1) { $right_id = db_fetch($rightRES)['id']; } else { show("Ошибка в функции check_right_name(). Права с именем '{$right_name}' не существует или имеется несколько прав с таким именем.<br/>"); show('Debug backtrace:'); show(debug_backtrace()); exit; } if (db_easy_count("SELECT * FROM `phpbb_rights_users` WHERE `user_id`={$user->data['user_id']} AND `right_id`={$right_id}") > 0) { return true; } else { return false; } } } }
function explainTbl($tbl) { $e = db_fetch('explain `' . $tbl . '`;'); $f = array(); foreach ($e as $v) { $o = $d = null; $p = 'string'; if (strstr($v['Type'], 'int')) { $p = 'int'; $d = (int) substr($v['Type'], strpos($v['Type'], '(') + 1); } else { if (substr($v['Type'], 0, 4) == 'enum') { $p = 'enum'; $o = explode("','", trim(substr($v['Type'], 4), "'()")); } else { if (strstr($v['Type'], 'text')) { $p = 'text'; } else { if (strstr($v['Type'], 'float') || strstr($v['Type'], 'double')) { $p = 'float'; } } } } $t = array('type' => $p, 'null' => 'YES' === $v['Null'], 'options' => $o, 'value' => $d); $f[strtolower($v['Field'])] = $t; } return $f; }
function display_wo_issue_details($issue_no) { $result = get_work_order_issue_details($issue_no); if (db_num_rows($result) == 0) { display_note(_("There are no items for this issue.")); } else { start_table(TABLESTYLE); $th = array(_("Component"), _("Quantity"), _("Units")); table_header($th); $j = 1; $k = 0; //row colour counter $total_cost = 0; while ($myrow = db_fetch($result)) { alt_table_row_color($k); label_cell($myrow["stock_id"] . " - " . $myrow["description"]); qty_cell($myrow["qty_issued"], false, get_qty_dec($myrow["stock_id"])); label_cell($myrow["units"]); end_row(); $j++; if ($j == 12) { $j = 1; table_header($th); } //end of page full new headings if } //end of while end_table(); } }
function show_results() { global $path_to_root; /*Now get the transactions */ div_start('trans_tbl'); start_table(TABLESTYLE); $netAmounts = check_value('NetAmounts'); if ($netAmounts) { $net = _("Net"); } else { $net = _("Gross"); } $th = array(_("Type"), _("Description"), _("Tax") . "<br>" . _("Amount"), $net . "<br>" . _("Outputs") . "/" . _("Inputs")); table_header($th); $k = 0; $total = 0; $bdate = date2sql($_POST['TransFromDate']); $edate = date2sql($_POST['TransToDate']); $taxes = get_tax_cash_summary($_POST['TransFromDate'], $_POST['TransToDate']); while ($tx = db_fetch($taxes)) { $payable = $tx['payable']; $collectible = $tx['collectible']; $net = $collectible + $payable; $total += $net; alt_table_row_color($k); label_cell($tx['name'] . " " . $tx['rate'] . "%"); label_cell(_("Charged on sales") . " (" . _("Output Tax") . "):"); amount_cell($payable); if ($netAmounts) { amount_cell($tx['net_output']); } else { amount_cell($tx['gross_output']); } end_row(); alt_table_row_color($k); label_cell($tx['name'] . " " . $tx['rate'] . "%"); label_cell(_("Paid on purchases") . " (" . _("Input Tax") . "):"); amount_cell($collectible); if ($netAmounts) { amount_cell($tx['net_input']); } else { amount_cell($tx['gross_input']); } end_row(); alt_table_row_color($k); label_cell("<b>" . $tx['name'] . " " . $tx['rate'] . "%</b>"); label_cell("<b>" . _("Net payable or collectible") . ":</b>"); amount_cell($net, true); label_cell(""); end_row(); } alt_table_row_color($k); label_cell(""); label_cell("<b>" . _("Total payable or refund") . ":</b>"); amount_cell($total, true); label_cell(""); end_row(); end_table(2); div_end(); }
function flickr_places_get_by_woeid($woeid, $more = array()) { if (!isset($more['force'])) { if (isset($GLOBALS['flickr_places_cache'][$woeid])) { return $GLOBALS['flickr_places_cache'][$woeid]; } # filter by date too? $enc_woeid = AddSlashes($woeid); $sql = "SELECT * FROM Places WHERE woeid='{$enc_woeid}'"; if ($row = db_single(db_fetch($sql))) { $place = json_decode($row['flickr_data'], "as hash"); $GLOBALS['flickr_places_cache'][$woeid] = $place; return $place; } } $rsp = _flickr_places_getinfo($woeid); if (!$rsp['ok']) { return null; } $place = $rsp['rsp']['place']; $insert = array('woeid' => AddSlashes($woeid), 'flickr_data' => AddSlashes(json_encode($place)), 'date_created' => time()); $rsp = db_insert('Places', $insert); $GLOBALS['flickr_places_cache'][$woeid] = $place; return $place; }
function versioncontrol_menu() { //Получаем глобальные переменные global $project_id; //Определяем переменные $html = ""; //Запрос к базе $q = db_query("SELECT * FROM `projects` ORDER BY `sort` ASC"); //Определяем переменные $phpself = substr($_SERVER['PHP_SELF'], 1); //Цикл while ($projectWHILE = db_fetch($q)) { //IF if ($projectWHILE['id'] == $project_id) { $class = "no_underlined"; $size = trim(explode("/", exec("du -h --summarize /backups/full/projects/{$project_id}/"))[0]); $size = str_replace("G", "Гб", str_replace("K", "Кб", str_replace("M", "Мб", $size))); $size = "<span style='font-size:10pt;font-style:italic;'>({$size})</span>"; //ElSE } else { $class = "underlined"; $size = ""; } //Определяем переменные if (preg_match("/^show\\_/", $_GET['action'])) { $action = $_GET['action']; } else { $action = 'show_version'; } $html .= "<a href='/versions.php?action={$action}&project=" . $projectWHILE['id'] . "' class='{$class}'>" . $projectWHILE['name'] . $size . "</a><span class='divider'></span>"; } $html .= "<a href='/versions.php?action=add_project' class='{$class}'><img src='/_content/img/add-icon.png' /></a><span class='divider'></span>"; //Возвращаем значение функции return template_get('versioncontrol/menu_top', array('items' => "<br/>Проекты:<span class='divider'></span>{$html}", 'project_id' => $project_id)); }
function flt_get_fleets($condition, $phalanx = false) { $fleet_db_list = array(); if (!$condition) { $missile_query = $condition = 1; } elseif (is_array($condition)) { $missile_query = "\n (fleet_start_galaxy = {$condition['galaxy']} AND fleet_start_system = {$condition['system']} AND fleet_start_planet = {$condition['planet']} AND fleet_start_type = {$condition['planet_type']})\n OR\n (fleet_end_galaxy = {$condition['galaxy']} AND fleet_end_system = {$condition['system']} AND fleet_end_planet = {$condition['planet']} AND fleet_end_type = {$condition['planet_type']})"; $condition = "\n (fleet_start_galaxy = {$condition['galaxy']} AND fleet_start_system = {$condition['system']} AND fleet_start_planet = {$condition['planet']} AND fleet_start_type = {$condition['planet_type']}" . ($phalanx ? '' : ' AND fleet_mess = 1') . ")\n OR\n (fleet_end_galaxy = {$condition['galaxy']} AND fleet_end_system = {$condition['system']} AND fleet_end_planet = {$condition['planet']} AND fleet_end_type = {$condition['planet_type']}" . ($phalanx ? '' : ' AND fleet_mess = 0') . ")"; } else { $missile_query = "`fleet_owner` = '{$condition}' OR `fleet_target_owner` = '{$condition}'"; $condition = $missile_query; } $sql_fleets = doquery("SELECT DISTINCT * FROM {{fleets}} WHERE {$condition};"); while ($fleet = db_fetch($sql_fleets)) { $fleet_db_list[] = $fleet; } // Missile attack $sql_fleets = doquery("SELECT * FROM `{{iraks}}` WHERE {$missile_query};"); while ($irak = db_fetch($sql_fleets)) { if ($irak['fleet_end_time'] >= SN_TIME_NOW) { $irak['fleet_start_type'] = PT_PLANET; $planet_start = db_planet_by_vector($irak, 'fleet_start_', false, 'name'); $irak['fleet_id'] = -$irak['id']; $irak['fleet_mission'] = MT_MISSILE; $irak['fleet_array'] = UNIT_DEF_MISSILE_INTERPLANET . ",{$irak['fleet_amount']};"; $irak['fleet_start_name'] = $planet_start['name']; } $fleet_db_list[] = $irak; } return $fleet_db_list; }
/** * eco_get_build_data.php * * 1.0 - copyright (c) 2010 by Gorlum for http://supernova.ws * @version 1.0 */ function eco_get_lab_max_effective_level(&$user, $lab_require) { if (!$user['user_as_ally'] && !isset($user['laboratories_active'])) { $user['laboratories_active'] = array(); $query = db_unit_list_laboratories($user['id']); while ($row = db_fetch($query)) { if (!eco_unit_busy($user, $row, UNIT_TECHNOLOGIES)) { $row += array(STRUC_LABORATORY => $level_lab = mrc_get_level($user, $row, STRUC_LABORATORY), STRUC_LABORATORY_NANO => $level_lab_nano = mrc_get_level($user, $row, STRUC_LABORATORY_NANO), 'laboratory_effective_level' => $level_lab * pow(2, $level_lab_nano)); $user['laboratories_active'][$row['id']] = $row; } } uasort($user['laboratories_active'], 'eco_lab_sort_effectivness'); } if (!isset($user['research_effective_level'][$lab_require])) { if ($user['user_as_ally']) { $lab_level = doquery("SELECT ally_members AS effective_level FROM {{alliance}} WHERE id = {$user['user_as_ally']} LIMIT 1", true); } else { $tech_intergalactic = mrc_get_level($user, false, TECH_RESEARCH) + 1; $lab_level['effective_level'] = 0; foreach ($user['laboratories_active'] as $data) { if ($tech_intergalactic <= 0) { break; } if ($data[STRUC_LABORATORY] >= $lab_require) { $lab_level['effective_level'] += $data['laboratory_effective_level']; $tech_intergalactic--; } } } $user['research_effective_level'][$lab_require] = $lab_level['effective_level'] ? $lab_level['effective_level'] : 1; } return $user['research_effective_level'][$lab_require]; }
function create_user($email, $username, $password, $password_confirm, $firstname, $lastname) { if (!ereg(".+@.+\\..+", $email)) { return "Invalid email address"; } if (empty($username)) { return "Empty username"; } if (empty($password) || empty($password_confirm)) { return "Empty password"; } if (strcmp($password, $password_confirm)) { return "Passwords don't match"; } if (empty($firstname)) { return "Empty first name"; } if (empty($lastname)) { return "Empty last name"; } if (db_fetch("select email from sitellite_user where email = ?", $email)) { return "Email address is already in system"; } if (db_fetch("select username from sitellite_user where username = ?", $username)) { return "Username is already in system"; } // All the data checks out, let's insert this mofo if (!db_execute("insert into sitellite_user (email, password, firstname, lastname, username, role, team, expires, lang) values (?, ?, ?, ?, ?, ?, ?, ?, ?)", $email, crypt($password), $firstname, $lastname, $username, '', '', 0, 'en')) { return "User creation failed"; } return ''; // Everything is peachy! *gulp* }
/** * function get_conversation_to_display() * This function gets the conversation from the db to display/return to the user * @link http://blog.program-o.com/?p=1223 * @param array $convoArr - the conversation array * @return array $orderedRows - a list of conversation line **/ function get_conversation_to_display($convoArr) { global $dbConn, $dbn, $bot_name, $unknown_user; $user_id = $convoArr['conversation']['user_id']; $bot_id = $convoArr['conversation']['bot_id']; $user_name = $convoArr['conversation']['user_name']; $user_name = !empty($user_name) ? $user_name : $unknown_user; $convoArr['conversation']['bot_name'] = $bot_name; if (empty($bot_name)) { $sql = "select `bot_name` from `bots` where `bot_id` = {$bot_id} limit 1;"; $row = db_fetch($sql, null, __FILE__, __FUNCTION__, __LINE__); $bot_name = $row['bot_name']; } if ($convoArr['conversation']['conversation_lines'] != 0) { $limit = " LIMIT " . $convoArr['conversation']['conversation_lines']; } else { $limit = ""; } $sql = "SELECT * FROM `{$dbn}`.`conversation_log`\n WHERE\n `user_id` = '" . $convoArr['conversation']['user_id'] . "'\n AND `bot_id` = '" . $convoArr['conversation']['bot_id'] . "'\n AND `convo_id` = '" . $convoArr['conversation']['convo_id'] . "'\n ORDER BY id DESC {$limit} "; runDebug(__FILE__, __FUNCTION__, __LINE__, "get_conversation SQL: {$sql}", 3); $result = db_fetchAll($sql, null, __FILE__, __FUNCTION__, __LINE__); if (count($result) > 0) { foreach ($result as $row) { $allrows[] = $row; } $orderedRows = array_reverse($allrows, false); } else { $orderedRows = array('id' => NULL, 'input' => "", 'response' => "", 'user_id' => $convoArr['conversation']['user_id'], 'bot_id' => $convoArr['conversation']['bot_id'], 'timestamp' => ""); } runDebug(__FILE__, __FUNCTION__, __LINE__, "Found '" . count($result) . "' lines of conversation", 2); return $orderedRows; }
/** * Function showChatFrame * * * @return mixed|string */ function showChatFrame() { global $template, $bot_name, $bot_id, $dbConn; $qs = '?bot_id=' . $bot_id; $sql = "select `format` from `bots` where `bot_id` = {$bot_id} limit 1;"; $row = db_fetch($sql, null, __FILE__, __FUNCTION__, __LINE__); $format = strtolower($row['format']); switch ($format) { case "html": $url = '../gui/plain/'; break; case "json": $url = '../gui/jquery/'; break; case "xml": $url = '../gui/xml/'; break; default: $url = '../gui/plain/'; } $url .= $qs; $out = $template->getSection('ChatDemo'); $out = str_replace('[pageSource]', $url, $out); $out = str_replace('[format]', strtoupper($format), $out); return $out; }
function print_list_of_journal_entries() { global $path_to_root; include_once $path_to_root . "reporting/includes/pdf_report.inc"; $from = $_REQUEST['PARAM_0']; $to = $_REQUEST['PARAM_1']; $systype = $_REQUEST['PARAM_2']; $comments = $_REQUEST['PARAM_3']; $dec = user_price_dec(); $cols = array(0, 100, 240, 300, 400, 460, 520, 580); $headers = array(tr('Type/Account'), tr('Account Name'), tr('Date/Dim.'), tr('Person/Item/Memo'), tr('Debit'), tr('Credit')); $aligns = array('left', 'left', 'left', 'left', 'right', 'right'); $params = array(0 => $comments, 1 => array('text' => tr('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => tr('Type'), 'from' => systypes::name($systype), 'to' => '')); $rep = new FrontReport(tr('List of Journal Entries'), "JournalEntries.pdf", user_pagesize()); $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); $rep->Header(); if ($systype == -1) { $systype = null; } $trans = get_gl_transactions($from, $to, -1, null, 0, $systype); $typeno = 0; while ($myrow = db_fetch($trans)) { if ($typeno != $myrow['type_no']) { if ($typeno != 0) { $rep->Line($rep->row + 4); $rep->NewLine(); } $typeno = $myrow['type_no']; $TransName = systypes::name($myrow['type']); $rep->TextCol(0, 2, $TransName . " # " . $myrow['type_no']); $rep->TextCol(2, 3, sql2date($myrow['tran_date'])); $coms = payment_person_types::person_name($myrow["person_type_id"], $myrow["person_id"]); $memo = get_comments_string($myrow['type'], $myrow['type_no']); if ($memo != '') { $coms .= $coms != "" ? "/" : "" . $memo; } $rep->TextCol(3, 6, $coms); $rep->NewLine(2); } $rep->TextCol(0, 1, $myrow['account']); $rep->TextCol(1, 2, $myrow['account_name']); $dim_str = get_dimension_string($myrow['dimension_id']); $dim_str2 = get_dimension_string($myrow['dimension2_id']); if ($dim_str2 != "") { $dim_str .= "/" . $dim_str2; } $rep->TextCol(2, 3, $dim_str); $rep->TextCol(3, 4, $myrow['memo_']); if ($myrow['amount'] > 0.0) { $rep->TextCol(4, 5, number_format2(abs($myrow['amount']), $dec)); } else { $rep->TextCol(5, 6, number_format2(abs($myrow['amount']), $dec)); } $rep->NewLine(1, 2); } $rep->Line($rep->row + 4); $rep->End(); }
function render($id, $title) { global $path_to_root, $systypes_array; include_once $path_to_root . "/includes/ui.inc"; $start_date = add_days(Today(), -$this->days_past); $end_date = add_days(Today(), $this->days_future); $result = get_bank_trans_for_bank_account($this->bank_act, $start_date, $end_date); start_table(TABLESTYLE, 'width=98%'); $th = array(_("#"), _("Date"), _("Receipt"), _("Payment"), _("Balance"), _("Person/Item"), _("Memo"), ""); table_header($th); $bfw = get_balance_before_for_bank_account($this->bank_act, $start_date); $credit = $debit = 0; start_row("class='inquirybg' style='font-weight:bold'"); label_cell(_("Opening Balance") . " - " . $start_date, "colspan=4"); display_debit_or_credit_cells($bfw); label_cell(""); label_cell("", "colspan=2"); end_row(); $running_total = $bfw; if ($bfw > 0) { $debit += $bfw; } else { $credit += $bfw; } $j = 1; $k = 0; //row colour counter while ($myrow = db_fetch($result)) { alt_table_row_color($k); $running_total += $myrow["amount"]; label_cell(get_trans_view_str($myrow["type"], $myrow["trans_no"])); $trandate = sql2date($myrow["trans_date"]); label_cell($trandate); display_debit_or_credit_cells($myrow["amount"]); amount_cell($running_total); label_cell(payment_person_name($myrow["person_type_id"], $myrow["person_id"])); label_cell(get_comments_string($myrow["type"], $myrow["trans_no"])); label_cell(get_gl_view_str($myrow["type"], $myrow["trans_no"])); end_row(); if ($myrow["amount"] > 0) { $debit += $myrow["amount"]; } else { $credit += $myrow["amount"]; } if ($j == 12) { $j = 1; table_header($th); } $j++; } //end of while loop start_row("class='inquirybg' style='font-weight:bold'"); label_cell(_("Ending Balance") . " - " . $end_date, "colspan=4"); amount_cell($debit + $credit); label_cell(""); label_cell("", "colspan=2"); end_row(); end_table(2); }
function print_purchases_cost() { global $path_to_root; $from = $_POST['PARAM_0']; $to = $_POST['PARAM_1']; $destination = $_POST['PARAM_2']; $orientation = $_POST['PARAM_3']; if ($destination) { include_once $path_to_root . "/reporting/includes/excel_report.inc"; } else { include_once $path_to_root . "/reporting/includes/pdf_report.inc"; } $dec = user_price_dec(); if ($category == ALL_NUMERIC) { $category = 0; } if ($category == 0) { $cat = _('All'); } else { $cat = get_category_name($category); } $cols = array(0, 20, 55, 85, 125, 200, 230, 260, 290, 325, 350, 375, 425, 475); //14 headers + 1 lagi dapat for cols //todo: format date paid to 2 digits representation only i.e. 12/12/12 $headers = array(_('CV#'), _('Date Paid'), _('OR #'), _('Supplier'), _('Title of Book'), _('Quantity'), _('Unit Cost'), _('Amount'), _('With Tax'), _('Net'), _('PO #'), _('Stock Supplied'), _('Stock Amount'), _('Total Amount')); //todo: Date Paid, OR(official receipt number) Amount, w/tax, net, Stock supplied, stock amount and total amount // Possible tables to read on: grn_batch and grn_items $aligns = array('left', 'left', 'left', 'left', 'left', 'left', 'left', 'left', 'left', 'left', 'left', 'left', 'left', 'left'); $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Category'), 'from' => $cat, 'to' => '')); $rep = new FrontReport(_('Summary of Purchases at Cost Report'), "SummaryPurchasesCostReport", user_pagesize(), 8, 'L'); $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); $rep->NewPage(); $res = getTransactions($from, $to); $total = $grandtotal = 0.0; $total1 = $grandtotal1 = 0.0; $total2 = $grandtotal2 = 0.0; $catt = ''; while ($trans = db_fetch($res)) { $rep->NewLine(); $rep->fontSize -= 2; $rep->TextCol(3, 4, $trans['supp_name']); $rep->TextCol(4, 5, $trans['description']); $rep->AmountCol(5, 6, $trans['quantity_ordered']); $rep->AmountCol(6, 7, $trans['unit_price']); $rep->AmountCol(10, 11, $trans['order_no']); } $rep->NewLine(2, 3); $rep->TextCol(0, 4, _('Total')); $rep->AmountCol(4, 5, $total, $dec); $rep->Line($rep->row - 2); $rep->NewLine(); $rep->NewLine(2, 1); $rep->TextCol(0, 4, _('Grand Total')); $rep->AmountCol(4, 5, $grandtotal, $dec); $rep->Line($rep->row - 4); $rep->NewLine(); $rep->End(); }