/** * Class constructor of diskspace. Gets reference for database connection. * Builds self::taxclasses from database values. * * @param db Reference to database handler * * @author Former03 GmbH :: Florian Lippert <*****@*****.**> */ function __construct($db) { $this->db = $db; $default_taxclass_result = $this->db->query_first('SELECT `classid` FROM `' . TABLE_BILLING_TAXCLASSES . '` WHERE `default` = \'1\' LIMIT 0,1'); $this->default_taxclass = $default_taxclass_result['classid']; $last_taxclass_validfrom = 0; $taxclasses_result = $this->db->query('SELECT `taxclass`, `taxrate`, `valid_from` FROM `' . TABLE_BILLING_TAXRATES . '` ORDER BY `valid_from` ASC'); while ($taxclasses_row = $this->db->fetch_array($taxclasses_result)) { if (!isset($this->taxclasses[$taxclasses_row['taxclass']]) || !is_array($this->taxclasses[$taxclasses_row['taxclass']])) { $this->taxclasses[$taxclasses_row['taxclass']] = array(); } $this->taxclasses[$taxclasses_row['taxclass']][$taxclasses_row['valid_from']] = $taxclasses_row; if (isset($this->taxclasses[$taxclasses_row['taxclass']][$last_taxclass_validfrom]) && is_array($this->taxclasses[$taxclasses_row['taxclass']][$last_taxclass_validfrom]) && $taxclasses_row['valid_from'] != 0) { $this->taxclasses[$taxclasses_row['taxclass']][$last_taxclass_validfrom]['valid_to'] = $taxclasses_row['valid_from']; } $last_taxclass_validfrom = $taxclasses_row['valid_from']; } }
/** * This is the main invoice collector. It collects all items for a userid and also * can fix the invoice and imports all cancelled invoices which should be reinvoiced. * For every service category it fires up the collector, fetches data and pushes the * rows through the taxcontroller to apply taxes before they finally get stored in * self::invoices. * * @param int UserId to handle * @param bool Fix invoice * @return bool true if everything went okay, false if something went wrong * * @author Former03 GmbH :: Florian Lippert <*****@*****.**> */ function collect($userId, $fixInvoice = false) { $this->userId = $userId; $this->user = $this->db->query_first('SELECT * FROM `' . getModeDetails($this->mode, 'TABLE_PANEL_USERS', 'table') . '` WHERE `' . getModeDetails($this->mode, 'TABLE_PANEL_USERS', 'key') . '` = \'' . $this->userId . '\' '); if ($this->userId == 0 || !is_array($this->user) || empty($this->user) || $this->user[getModeDetails($this->mode, 'TABLE_PANEL_USERS', 'key')] != $this->userId) { return false; } $taxController = new taxController(&$this->db); if ($this->user['calc_tax'] === '1') { $taxController->calc_tax = true; } else { $taxController->calc_tax = false; } $cancelledInvoices_result = $this->db->query('SELECT * FROM `' . getModeDetails($this->mode, 'TABLE_BILLING_INVOICES', 'table') . '` WHERE `' . getModeDetails($this->mode, 'TABLE_BILLING_INVOICES', 'key') . '` = \'' . $this->userId . '\' AND ( `state` = \'' . CONST_BILLING_INVOICESTATE_CANCELLED_REINVOICE_WITHOUT_CREDIT_NOTE . '\' OR `state` = \'' . CONST_BILLING_INVOICESTATE_CANCELLED_REINVOICE_WITH_CREDIT_NOTE . '\' ) '); while ($cancelledInvoices_row = $this->db->fetch_array($cancelledInvoices_result)) { $this->importXml($cancelledInvoices_row['xml']); $this->cancelledInvoices[$cancelledInvoices_row['id']] = $cancelledInvoices_row; } if ($fixInvoice === true && !empty($this->cancelledInvoices)) { $this->db->query('UPDATE `' . getModeDetails($this->mode, 'TABLE_BILLING_INVOICES', 'table') . '` SET `state` = \'' . CONST_BILLING_INVOICESTATE_CANCELLED_REINVOICED . '\', `state_change` = \'' . time() . '\' WHERE `' . getModeDetails($this->mode, 'TABLE_BILLING_INVOICES', 'key') . '` = \'' . $this->userId . '\' AND ( `state` = \'' . CONST_BILLING_INVOICESTATE_CANCELLED_REINVOICE_WITHOUT_CREDIT_NOTE . '\' OR `state` = \'' . CONST_BILLING_INVOICESTATE_CANCELLED_REINVOICE_WITH_CREDIT_NOTE . '\' ) AND `id` IN ( ' . implode(', ', array_keys($this->cancelledInvoices)) . ' ) '); } foreach ($this->service_categories as $service_category => $service_category_details) { if (!class_exists($service_category_details['category_classname'])) { require_once './' . makeCorrectFile($service_category_details['category_classfile']); } if (class_exists($service_category_details['category_classname'])) { $subject = 0; $mode = $this->mode; $include_setup_fee = false; $include_interval_fee = false; if ($this->mode === 1 && intval($service_category_details['category_mode']) === 1) { if (isset($this->admin2customers[$this->userId])) { $subject = $this->admin2customers[$this->userId]; $mode = 0; // We have to set mode to customer because we are feeding an array of customer ids, so serviceCategory should also work in customer mode if (in_array($service_category_details['id'], $this->adminmode_include_once)) { $include_setup_fee = true; } if (in_array($service_category_details['id'], $this->adminmode_include_period)) { $include_interval_fee = true; } } } else { $subject = $this->userId; $include_setup_fee = true; $include_interval_fee = true; } if ($subject != 0) { $currentServiceCategory = new $service_category_details['category_classname'](&$this->db, $mode, $service_category_details['category_name']); $currentServiceCategory->fetchData($subject); $this->invoice = array_merge($this->invoice, $taxController->applyTaxRate($currentServiceCategory->collect($fixInvoice, $include_setup_fee, $include_interval_fee))); unset($currentServiceCategory); } } } return true; }
/** * Read client data from database. */ private function _readData() { if (isset($this->cid) && $this->cid != -1) { $_client = $this->db->query_first('SELECT * FROM `' . TABLE_FROXLOR_CLIENTS . '` WHERE `id` = "' . $this->cid . '"'); foreach ($_client as $field => $value) { $this->Set($field, $value, true, true); } // after we have details about the client, // we need its settings too $this->_readSettings(); } }
/** * Mail notifications. */ public function sendMail($customerid = -1, $template_subject = null, $default_subject = null, $template_body = null, $default_body = null) { global $mail; // Some checks are to be made here in the future if ($customerid != -1) { // Get e-mail message for customer $usr = $this->db->query_first('SELECT `name`, `firstname`, `email` FROM `' . TABLE_PANEL_CUSTOMERS . '` WHERE `customerid` = "' . (int) $customerid . '"'); $replace_arr = array('FIRSTNAME' => $usr['firstname'], 'NAME' => $usr['name'], 'SUBJECT' => $this->Get('subject', true)); } else { $replace_arr = array('SUBJECT' => $this->Get('subject', true)); } $result = $this->db->query_first('SELECT `value` FROM `' . TABLE_PANEL_TEMPLATES . '` WHERE `adminid`=\'' . (int) $this->userinfo['adminid'] . '\' AND `language`=\'' . $this->db->escape($this->userinfo['def_language']) . '\' AND `templategroup`=\'mails\' AND `varname`=\'' . $template_subject . '\''); $mail_subject = html_entity_decode(replace_variables($result['value'] != '' ? $result['value'] : $default_subject, $replace_arr)); $result = $this->db->query_first('SELECT `value` FROM `' . TABLE_PANEL_TEMPLATES . '` WHERE `adminid`=\'' . (int) $this->userinfo['adminid'] . '\' AND `language`=\'' . $this->db->escape($this->userinfo['def_language']) . '\' AND `templategroup`=\'mails\' AND `varname`=\'' . $template_body . '\''); $mail_body = html_entity_decode(replace_variables($result['value'] != '' ? $result['value'] : $default_body, $replace_arr)); if ($customerid != -1) { $mail->From = $this->settings['ticket']['noreply_email']; $mail->FromName = $this->settings['ticket']['noreply_name']; $mail->Subject = $mail_subject; $mail->Body = $mail_body; $mail->AddAddress($usr['email'], $usr['firstname'] . ' ' . $usr['name']); if (!$mail->Send()) { standard_error(array('errorsendingmail', $usr['email'])); } $mail->ClearAddresses(); } else { $admin = $this->db->query_first('SELECT `email` FROM `' . TABLE_PANEL_ADMINS . "` WHERE `adminid`='" . (int) $this->userinfo['adminid'] . "'"); $mail->From = $this->settings['ticket']['noreply_email']; $mail->FromName = $this->settings['ticket']['noreply_name']; $mail->Subject = $mail_subject; $mail->Body = $mail_body; $mail->AddAddress($admin['email'], $admin['firstname'] . ' ' . $admin['name']); if (!$mail->Send()) { standard_error(array('errorsendingmail', $admin['email'])); } $mail->ClearAddresses(); } }
if (!isset($sql_root[$result['dbserver']]) || !is_array($sql_root[$result['dbserver']])) { $result['dbserver'] = 0; } if (isset($_POST['send']) && $_POST['send'] == 'send') { // Only change Password if it is set, do nothing if it is empty! -- PH 2004-11-29 $password = validate($_POST['mysql_password'], 'password'); $external_access_val = isset($_POST['mysql_allow_external_access']) ? '1' : '0'; if (!checkNitradoServiceLimit($userinfo['customerid'], 'mysql', 'allow_external_access')) { $external_access_val = '0'; } // External access checkbox $db_root = new db($sql_root[$result['dbserver']]['host'], $sql_root[$result['dbserver']]['user'], $sql_root[$result['dbserver']]['password'], ''); if ($external_access_val == '1') { $db_root->query('GRANT ALL PRIVILEGES ON `' . $db_root->escape($result['databasename']) . '`.* TO \'' . $db_root->escape($result['databasename']) . '\'@\'%\'', false, true); $db_root->query('GRANT USAGE ON *.* TO \'' . $db_root->escape($result['databasename']) . '\'@\'%\' IDENTIFIED BY \'password\'', false, true); $current_password = $db_root->query_first('SELECT password FROM mysql.user WHERE user = \'' . $db_root->escape($result['databasename']) . '\' AND Host = \'localhost\'', false, true); $db_root->query('SET PASSWORD FOR `' . $db_root->escape($result['databasename']) . '`@`%` = \'' . $current_password['password'] . '\'', false, true); } else { $db_root->query('REVOKE ALL PRIVILEGES ON * . * FROM `' . $db_root->escape($result['databasename']) . '`@`%`', false, true); $db_root->query('REVOKE ALL PRIVILEGES ON `' . str_replace('_', '\\_', $db_root->escape($result['databasename'])) . '` . * FROM `' . $db_root->escape($result['databasename']) . '`@`%`', false, true); $db_root->query('DELETE FROM `mysql`.`user` WHERE `User` = "' . $db_root->escape($result['databasename']) . '" AND `Host` = "%"', false, true); } $db_root->query('FLUSH PRIVILEGES'); $db_root->close(); if ($password != '') { // validate password $password = validatePassword($password); $access_result = $db->query_first('SELECT `allow_external_access` FROM `' . TABLE_PANEL_DATABASES . '` WHERE `customerid`="' . (int) $userinfo['customerid'] . '" AND `id`="' . (int) $id . '"'); // Begin root-session $db_root = new db($sql_root[$result['dbserver']]['host'], $sql_root[$result['dbserver']]['user'], $sql_root[$result['dbserver']]['password'], ''); foreach (array_map('trim', explode(',', $settings['system']['mysql_access_host'])) as $mysql_access_host) {
public function right() { $object_id = intval($this->input['object_id']) ? intval($this->input['object_id']) : 0; if (empty($object_id)) { return false; } $db = array('host' => '192.168.60.18', 'user' => 'forapp', 'pass' => 'Hoge@mysql', 'database' => 'm2o_mediaserver', 'charset' => 'utf8', 'pconnect' => '0'); include_once ROOT_PATH . 'lib/db/db_mysql.class.php'; $g_db = new db(); $g_db->connect($db['host'], $db['user'], $db['pass'], $db['database'], $db['charset'], $db['pconnect'], $db['dbprefix']); $sql = "select * from " . DB_PREFIX . "right_temp where obj_id=" . $object_id; $f = $g_db->query_first($sql); $right_info = json_decode($f['content'], 1); hg_pre($right_info); }
public function show() { $progressPath = CACHE_DIR . 'progress.txt'; $totalPath = CACHE_DIR . 'total.txt'; if (file_exists($progressPath)) { $progress = file_get_contents($progressPath); } else { file_put_contents($progressPath, 0); $sql = 'SELECT COUNT(*) AS total FROM ' . DB_PREFIX . 'member'; $total = $this->db->query_first($sql); $total = $total['total']; file_put_contents($totalPath, $total); $progress = 0; } $newlegth = $progress + LENGTH; $sql = 'SELECT * FROM ' . DB_PREFIX . 'member where id >' . $progress . ' AND id <= ' . $newlegth . ' order by id asc '; $query = $this->db->query($sql); $arr = array(); $ids = array(); while ($row = $this->db->fetch_array($query)) { $ids[] = $row['id']; $arr[$row['id']] = array('id' => $row['id'], 'uc_id' => $row['uc_id'], 'member_name' => $row['member_name'], 'nick_name' => $row['nick_name'], 'password' => $row['password'], 'email' => $row['email'], 'appid' => $row['appid'], 'appname' => $row['appname'], 'salt' => $row['salt'], 'mobile' => $row['mobile'], 'avatar' => $row['filename'] ? serialize(array('host' => $row['host'], 'dir' => $row['dir'], 'filepath' => $row['filepath'], 'filename' => $row['filename'])) : '', 'create_time' => $row['create_time'], 'update_time' => $row['update_time'], 'ip' => $row['ip']); } if (!empty($ids)) { $sql = 'SELECT * FROM ' . DB_PREFIX . 'member_bound WHERE member_id IN (' . implode(',', $ids) . ')'; $query = $this->db->query($sql); $bound = array(); while ($row = $this->db->fetch_array($query)) { $arr[$row['member_id']]['avatar_url'] = $row['avatar_url']; $arr[$row['member_id']]['platform_id'] = $row['platform_id']; $arr[$row['member_id']]['nick_name'] = $row['plat_member_name']; $platform_id[] = $row['platform_id']; } } if ($platform_id && $this->settings['App_share']) { $platform_id_str = implode(',', $platform_id); //$access_plat_token_str .= ',d4cf3e1c11842fc401dac4785fc7cb74,4161492c9e237fc3a6a33b6420fdbb73'; $this->curl->setSubmitType('post'); $this->curl->initPostData(); $this->curl->addRequestData('a', 'get_user_by_id'); $this->curl->addRequestData('id', $platform_id_str); $ret = $this->curl->request('get_user.php'); $ret = $ret[0]; } if (!empty($arr)) { foreach ($arr as $key => $val) { if (!empty($ret[$val['platform_id']])) { $arr[$key]['type'] = $this->plat_maps[$ret[$val['platform_id']]['plat_type']]['type']; $arr[$key]['type_name'] = $this->plat_maps[$ret[$val['platform_id']]['plat_type']]['type_name']; $arr[$key]['platform_id'] = $ret[$val['platform_id']]['uid']; } else { $arr[$key]['type'] = 'm2o'; $arr[$key]['type_name'] = 'M2O'; } } $source_db = array('host' => 'localhost', 'user' => 'root', 'pass' => 'hogesoft', 'database' => 'jn_members', 'charset' => 'utf8', 'pconncet' => '0', 'dbprefix' => 'm2o_'); $sourceDB = new db(); $sourceDB->connect($source_db['host'], $source_db['user'], $source_db['pass'], $source_db['database'], $source_db['charset'], $source_db['pconnect'], $source_db['dbprefix']); foreach ($arr as $key => $val) { $sql = 'INSERT INTO ' . DB_PREFIX . 'member ( guid, member_name, password, salt, type, type_name, avatar, email, status, appid, appname, mobile, create_time, update_time, ip) VALUES( "' . guid() . '", "' . $val['member_name'] . '", "' . $val['password'] . '", "' . $val['salt'] . '", "' . $val['type'] . '", "' . $val['type_name'] . '", "' . addslashes($val['avatar']) . '", "' . $val['email'] . '", "1", "' . $val['appid'] . '", "' . $val['appname'] . '", "' . $val['mobile'] . '", "' . $val['create_time'] . '", "' . $val['update_time'] . '", "' . $val['ip'] . '" )'; $sourceDB->query_first($sql); $iid = $sourceDB->insert_id(); if (!$iid) { break; } $val['platform_id'] = !empty($val['platform_id']) ? $val['platform_id'] : (empty($val['uc_id']) ? $iid : $val['uc_id']); $sql = 'INSERT INTO ' . DB_PREFIX . 'member_bind ( member_id, platform_id, nick_name, type, type_name, avatar_url, bind_time, inuc, is_primary ) VALUES( ' . $iid . ', "' . $val['platform_id'] . '", "' . $val['nick_name'] . '", "' . $val['type'] . '", "' . $val['type_name'] . '", "' . $val['avatar_url'] . '", "' . TIMENOW . '", "' . $val['uc_id'] . '", 1 )'; $sourceDB->query($sql); $sql = 'INSERT INTO ' . DB_PREFIX . 'member_count ( u_id ) VALUES( ' . $iid . ' )'; $sourceDB->query($sql); } file_put_contents($progressPath, $progress + LENGTH); $total = file_get_contents($totalPath); if (intval($progress + LENGTH) < intval($total)) { $percent = round(intval($progress + LENGTH) / intval($total) * 100, 2) . "%"; echo $message = '正在更新数据...' . $percent; $this->redirect('export2members.php'); } echo "数据更新完成"; exit; } else { echo "已经导入完成,请勿导入重复数据"; } exit; }
if ($db->link_id == 0) { fclose($debugHandler); unlink($lockfile); $cronlog->logAction(CRON_ACTION, LOG_ERR, 'Database-connection crashed during traffic-cronjob, could not reconnect!'); die('SysCP can\'t connect to mysqlserver. Exiting...'); } fwrite($debugHandler, 'Database-connection re-established' . "\n"); unset($sql); unset($db->password); $cronlog->logAction(CRON_ACTION, LOG_WARNING, 'Database-connection crashed during traffic-cronjob, reconnected!'); } /* * FTP-Traffic */ fwrite($debugHandler, 'ftp traffic for ' . $row['loginname'] . ' started...' . "\n"); $ftptraffic = $db->query_first('SELECT SUM(`up_bytes`) AS `up_bytes_sum`, SUM(`down_bytes`) AS `down_bytes_sum` FROM `' . TABLE_FTP_USERS . "` WHERE `customerid`='" . (int) $row['customerid'] . "'"); if (!is_array($ftptraffic)) { $ftptraffic = array('up_bytes_sum' => 0, 'down_bytes_sum' => 0); } $db->query('UPDATE `' . TABLE_FTP_USERS . "` SET `up_bytes`='0', `down_bytes`='0' WHERE `customerid`='" . (int) $row['customerid'] . "'"); /* * Mail-Traffic */ $mailtraffic = 0; /* * Total Traffic */ fwrite($debugHandler, 'total traffic for ' . $row['loginname'] . ' started' . "\n"); $current_traffic = array(); $current_traffic['http'] = floatval($httptraffic); $current_traffic['ftp_up'] = floatval($ftptraffic['up_bytes_sum'] / 1024);
/** * <b>****************************************** Mandant ***********************************************</b><br /> * Mandant.<br /> * */ define('INITIALIZE_MADNANT', true); if ($_SESSION['mandant']) { $mandant = $_SESSION['mandant']['mandant_id']; } if ($_GET['mandant']) { $mandant = $_GET['mandant']; } if ($mandant == "") { $mandant = 2; } $mandant = $db->query_first("SELECT * FROM rhs_mandant WHERE mandant_id={$mandant}"); if (!$mandant) { $mandant = $db->query_first("SELECT * FROM rhs_mandant WHERE mandant_id=2"); } /** * <b>****************************************** Header ***********************************************</b><br /> * Class for GZip Output.<br /> * */ require $manu_additional_patch . "./lib/class.headers.php"; $i = 0; $result = $db->query("SELECT * FROM rhs_download_data ORDER BY create_date DESC LIMIT 6"); while ($row = $db->fetch_array($result)) { $row['dl_counter_man'] = $i + 1; $overall_download_data[$i] = $row; $i++;
//添加时间 $begin_time = $_REQUEST['begin_time'] ? strtotime($_REQUEST['begin_time'] . ' 00:00:00') : strtotime(date('Y-m-d', time())); $end_time = $_REQUEST['end_time'] ? strtotime($_REQUEST['end_time'] . ' 23:59:59') : strtotime(date('Y-m-d', time()) . ' 23:59:59'); $db_sql = str_replace('$begin_time', ' ' . $begin_time . ' ', $db_sql); $db_sql = str_replace('$end_time', ' ' . $end_time . ' ', $db_sql); $tt1 = substr($db_sql, 6, strlen($db_sql)); $total_sql = substr($db_sql, 0, 6); $total_sql .= ' SQL_CALC_FOUND_ROWS '; $db_sql = $total_sql . $tt1; $db_sql = stripslashes($db_sql); //添加limit限制。默认每页显示30条记录 $str = strstr($db_sql, 'limit'); if (!$str) { $db_sql .= ' limit ' . $pp . ' , ' . 30; $qid = $DB->query($db_sql); $total = $DB->query_first('select found_rows() as total'); //此句要用在query之后 $perpage = 30; } else { $tmp = explode(',', $str); $perpage = intval(trim($tmp[1])); $qid = $DB->query($db_sql); $total = $DB->query_first('select found_rows() as total'); if ($total['total'] > $perpage) { $total['total'] = $perpage; } } $total = $total['total']; //计算分页 $page_link = array('totalpages' => $total, 'curpage' => intval($pp), 'perpage' => $perpage, 'pagelink' => '?sql=' . urlencode($_REQUEST['sql']) . '&server=' . $db_choice); $p_links = hg_build_pagelinks($page_link);
$row['region'] = $staaten[$ort['adm0']] . " / " . $laender[$ort['adm0']][$ort['adm1']] . " / " . $ort['ort']; } else { $row['region'] = $row['land'] . " / " . $row['ort']; } $einsatz[$i] = $row; $smarty->assign("einsatz", $einsatz); $i++; } $smarty->display("database_einsatz.tpl.php"); $db = new db($sqlhost, $sqluser, $sqlpassword, $sqldb, $phpversion); break; case "dl": $i = 0; $result = $db->query("SELECT * FROM rhs_download_cat ORDER BY catorder ASC"); while ($row = $db->fetch_array($result)) { $rowdata = $db->query_first("SELECT count(id) as anzahl FROM rhs_download_data WHERE catid = " . $row['id']); $row['anzahl'] = $rowdata['anzahl']; $linkref[$i] = $row; $smarty->assign("linkref", $linkref); $i++; $optionhtml .= makeoption($row['id'], $row['catname'], $_GET['ref']); } $smarty->assign("optionhtml", $optionhtml); $smarty->display("database_dl_cat.tpl.php"); break; case "dldetail": $i = 0; $result = $db->query("SELECT * FROM rhs_download_data WHERE catid = " . $_GET['ref'] . " ORDER BY dlname ASC"); while ($row = $db->fetch_array($result)) { $linkref[$i] = $row; $smarty->assign("linkref", $linkref);
/** * Mail notifications */ public function sendMail($customerid = -1, $template_subject = null, $default_subject = null, $template_body = null, $default_body = null) { global $mail; // Some checks are to be made here in the future if ($customerid != -1) { // Get e-mail message for customer $usr = $this->db->query_first('SELECT `name`, `firstname`, `company`, `email` FROM `' . TABLE_PANEL_CUSTOMERS . '` WHERE `customerid` = "' . (int) $customerid . '"'); $replace_arr = array('FIRSTNAME' => $usr['firstname'], 'NAME' => $usr['name'], 'COMPANY' => $usr['company'], 'SALUTATION' => getCorrectUserSalutation($usr), 'SUBJECT' => $this->Get('subject', true)); } else { $replace_arr = array('SUBJECT' => $this->Get('subject', true)); } $result = $this->db->query_first('SELECT `value` FROM `' . TABLE_PANEL_TEMPLATES . '` WHERE `adminid`=\'' . (int) $this->userinfo['adminid'] . '\' AND `language`=\'' . $this->db->escape($this->userinfo['def_language']) . '\' AND `templategroup`=\'mails\' AND `varname`=\'' . $template_subject . '\''); $mail_subject = html_entity_decode(replace_variables($result['value'] != '' ? $result['value'] : $default_subject, $replace_arr)); $result = $this->db->query_first('SELECT `value` FROM `' . TABLE_PANEL_TEMPLATES . '` WHERE `adminid`=\'' . (int) $this->userinfo['adminid'] . '\' AND `language`=\'' . $this->db->escape($this->userinfo['def_language']) . '\' AND `templategroup`=\'mails\' AND `varname`=\'' . $template_body . '\''); $mail_body = html_entity_decode(replace_variables($result['value'] != '' ? $result['value'] : $default_body, $replace_arr)); if ($customerid != -1) { $_mailerror = false; try { $mail->SetFrom($this->settings['ticket']['noreply_email'], $this->settings['ticket']['noreply_name']); $mail->Subject = $mail_subject; $mail->AltBody = $mail_body; $mail->MsgHTML(str_replace("\n", "<br />", $mail_body)); $mail->AddAddress($usr['email'], $usr['firstname'] . ' ' . $usr['name']); $mail->Send(); } catch (phpmailerException $e) { $mailerr_msg = $e->errorMessage(); $_mailerror = true; } catch (Exception $e) { $mailerr_msg = $e->getMessage(); $_mailerror = true; } if ($_mailerror) { $rstlog = FroxlorLogger::getInstanceOf(array('loginname' => 'ticket_class'), $this->db, $this->settings); $rstlog->logAction(ADM_ACTION, LOG_ERR, "Error sending mail: " . $mailerr_msg); standard_error('errorsendingmail', $usr['email']); } $mail->ClearAddresses(); } else { $admin = $this->db->query_first("SELECT `name`, `email` FROM `" . TABLE_PANEL_ADMINS . "` WHERE `adminid`='" . (int) $this->userinfo['adminid'] . "'"); $_mailerror = false; try { $mail->SetFrom($this->settings['ticket']['noreply_email'], $this->settings['ticket']['noreply_name']); $mail->Subject = $mail_subject; $mail->AltBody = $mail_body; $mail->MsgHTML(str_replace("\n", "<br />", $mail_body)); $mail->AddAddress($admin['email'], $admin['name']); $mail->Send(); } catch (phpmailerException $e) { $mailerr_msg = $e->errorMessage(); $_mailerror = true; } catch (Exception $e) { $mailerr_msg = $e->getMessage(); $_mailerror = true; } if ($_mailerror) { $rstlog = FroxlorLogger::getInstanceOf(array('loginname' => 'ticket_class'), $this->db, $this->settings); $rstlog->logAction(ADM_ACTION, LOG_ERR, "Error sending mail: " . $mailerr_msg); standard_error('errorsendingmail', $admin['email']); } $mail->ClearAddresses(); } }
$paging = new paging($userinfo, $db, TABLE_PANEL_DATABASES, $fields, $settings['panel']['paging'], $settings['panel']['natsorting']); $result = $db->query("SELECT * FROM `" . TABLE_PANEL_DATABASES . "` WHERE `customerid`='" . (int) $userinfo['customerid'] . "' " . $paging->getSqlWhere(true) . " " . $paging->getSqlOrderBy() . " " . $paging->getSqlLimit()); $paging->setEntries($db->num_rows($result)); $sortcode = $paging->getHtmlSortCode($lng); $arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s); $searchcode = $paging->getHtmlSearchCode($lng); $pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s); $i = 0; $count = 0; $mysqls = ''; // Begin root-session $db_root = new db($sql_root[0]['host'], $sql_root[0]['user'], $sql_root[0]['password'], ''); while ($row = $db->fetch_array($result)) { if ($paging->checkDisplay($i)) { $row = htmlentities_array($row); $mbdata = $db_root->query_first("SELECT SUM( data_length + index_length) / 1024 / 1024 'MB' FROM information_schema.TABLES WHERE table_schema = '" . $db_root->escape($row['databasename']) . "' GROUP BY table_schema ;"); $row['size'] = number_format($mbdata['MB'], 3, '.', ''); eval("\$mysqls.=\"" . getTemplate("mysql/mysqls_database") . "\";"); $count++; } $i++; } $db_root->close(); // End root-session $mysqls_count = $db->num_rows($result); eval("echo \"" . getTemplate("mysql/mysqls") . "\";"); } elseif ($action == 'delete' && $id != 0) { $result = $db->query_first('SELECT `id`, `databasename`, `description`, `dbserver` FROM `' . TABLE_PANEL_DATABASES . '` WHERE `customerid`="' . (int) $userinfo['customerid'] . '" AND `id`="' . (int) $id . '"'); if (isset($result['databasename']) && $result['databasename'] != '') { if (!isset($sql_root[$result['dbserver']]) || !is_array($sql_root[$result['dbserver']])) { $result['dbserver'] = 0;
public function show() { $progressPath = CACHE_DIR . 'progress.txt'; $totalPath = CACHE_DIR . 'total.txt'; $is_next = true; if (file_exists($progressPath) && file_exists($totalPath)) { $progress = file_get_contents($progressPath); $total = file_get_contents($totalPath); } else { file_put_contents($progressPath, 0); $sql = 'SELECT max(member_id) as max,min(member_id) as min FROM ' . DB_PREFIX . 'member'; $max_min = $this->db->query_first($sql); file_put_contents($totalPath, $max_min['max']); file_put_contents($progressPath, $max_min['min']); $progress = $max_min['min'] - 1; $total = $max_min['max']; } $newlegth = intval($progress + LENGTH); if ($newlegth > intval($total)) { $newlegth = $total; $is_next = false; } $sql = 'SELECT * FROM ' . DB_PREFIX . 'member where ( member_id >' . $progress . ') AND ( member_id <= ' . $newlegth . ') order by member_id asc '; $query = $this->db->query($sql); $member = array(); $member_id = array(); while ($row = $this->db->fetch_array($query)) { $member[$row['member_id']] = $row; $member_id[] = $row['member_id']; } if ($member_id) { $sql = 'SELECT * FROM ' . DB_PREFIX . 'member_bind where member_id IN (' . implode(',', $member_id) . ') order by member_id asc '; $query = $this->db->query($sql); $member_bind = array(); while ($row = $this->db->fetch_array($query)) { $member_bind[$row['member_id']][] = $row; } } if (!empty($member)) { $source_db = array('host' => 'localhost', 'user' => 'root', 'pass' => 'hogesoft', 'database' => 'jn_members2', 'charset' => 'utf8', 'pconncet' => '0', 'dbprefix' => 'm2o_'); $_sourceDB = new db(); $_sourceDB->connect($source_db['host'], $source_db['user'], $source_db['pass'], $source_db['database'], $source_db['charset'], $source_db['pconnect'], $source_db['dbprefix']); foreach ($member as $key => $val) { $insertData = $val; if (!$val['guid']) { $insertData['guid'] = guid(); } $sql = 'SELECT count(*) as total FROM ' . DB_PREFIX . 'member where member_name = \'' . $insertData['member_name'] . '\' AND type = \'' . $insertData['type'] . '\''; $isInsert = $_sourceDB->query_first($sql); if ($isInsert['total'] > 0) { file_put_contents(CACHE_DIR . 'error_member.txt', var_export($insertData, 1), FILE_APPEND); continue; } unset($insertData['member_id']); $cmd = $replace ? 'REPLACE INTO ' : 'INSERT INTO '; $sql = $cmd . DB_PREFIX . 'member SET ' . $this->setField($insertData); $_sourceDB->query($sql); $iid = $_sourceDB->insert_id(); if (!$iid) { break; } $sql = 'INSERT INTO ' . DB_PREFIX . 'member_count ( u_id ) VALUES( ' . $iid . ' )'; $_sourceDB->query($sql); if ($_member_bind = $member_bind[$val['member_id']]) { foreach ($_member_bind as $k => $v) { $inuc = 0; $v['member_id'] = $iid; if ($v['type'] == 'm2o' && $v['inuc'] == 0) { $v['platform_id'] = $iid; } if ($v['type'] == 'uc') { $inuc = $v['platform_id']; } else { if ($v['inuc'] != 0) { $inuc = $v['inuc']; } } $sql = 'SELECT count(*) as total FROM ' . DB_PREFIX . 'member_bind where member_id = ' . $v['member_id'] . ' AND platform_id = \'' . $v['platform_id'] . '\' AND type = \'' . $v['type'] . '\''; $isInsertBind = $_sourceDB->query_first($sql); if ($isInsertBind['total'] > 0) { file_put_contents(CACHE_DIR . 'error_memberbind.txt', var_export($v, 1), FILE_APPEND); continue; } $cmd = $replace ? 'REPLACE INTO ' : 'INSERT INTO '; $sql = $cmd . DB_PREFIX . 'member_bind SET ' . $this->setField($v); $_sourceDB->query($sql); if ($inuc) { $sql = 'UPDATE ' . DB_PREFIX . 'member_bind SET inuc =\'' . $inuc . '\' WHERE member_id = ' . $iid; $_sourceDB->query($sql); } } } } $_sourceDB->close(); file_put_contents($progressPath, $newlegth); if ($is_next) { $percent = round(intval($newlegth) / intval($total) * 100, 2) . "%"; echo $message = '系统正在合并数据,别打扰唉...' . $percent; $this->redirect('membersDataMerge.php'); } echo "数据合并完成"; exit; } else { echo "已经合并完成,请勿重复合并数据"; } exit; }