function create_content($name, $params) { my_mysql_connect(); $ret = call_user_func('create_' . $name, $params); my_mysql_disconnect(); return $ret; }
function load_old_config() { $file = INCPATH . '../../system/conf_main.php'; if (file_exists($file)) { $C = new stdClass(); $C->INCPATH = realpath(INCPATH . '../../system/') . '/'; include $file; $conn = my_mysql_connect($C->DB_HOST, $C->DB_USER, $C->DB_PASS); if ($conn) { $dbs = my_mysql_select_db($C->DB_NAME, $conn); if ($dbs) { $tmp = my_mysql_query('SELECT * FROM `settings` ', $conn); while ($obj = my_mysql_fetch_object($tmp)) { $C->{$obj->word} = stripslashes($obj->value); } } } return $C; } $file = INCPATH . '../../include/conf_main.php'; if (file_exists($file)) { $C = new stdClass(); $src = file_get_contents($file); $pattern = '/(define(\\s)*\\((\\s)*\'([a-z0-9\\-\\_]+)\'\\,(\\s)*)(\')([^\\\']*)(\')((\\s)*\\))/isu'; preg_match_all($pattern, $src, $matches, PREG_SET_ORDER); foreach ($matches as $dfmatches) { $key = trim($dfmatches[4]); $val = trim($dfmatches[7]); if (empty($key)) { continue; } $C->{$key} = $val; } $C->VERSION = 'unofficial'; return $C; } return new stdClass(); }
if (isset($_POST['submit'])) { //Copy $_POST data, sanitizing it to prevent SQL injection attacks. $q = safe_inputs($_POST); //Check various conditions to make sure input is valid. if (!preg_match('/^[a-zA-Z0-9._-]+@[a-zA-Z0-9-]+\\.[a-zA-Z.]{2,5}$/', $q['Email'])) { echo "Invalid E-mail entered. E-mail must be in the format \"name@server.com\"<br />"; } else { if ($q['Phone'] != '' && !preg_match('/^\\d{3}\\-\\d{3}\\-\\d{4}$/', $q['Phone'])) { echo "Invalid phone number entered. Phone number must be in the format \"XXX-XXX-XXXX\"<br />"; } else { if ($q['Phone2'] != '' && !preg_match('/^\\d{3}\\-\\d{3}\\-\\d{4}$/', $q['Phone2'])) { echo "Invalid phone number 2 entered. Phone number 2 must be in the format \"XXX-XXX-XXXX\"<br />"; } else { //Force zip code to a number $zip_num = (int) $q[Zip]; my_mysql_connect(); //Pick the correct query type if ($_POST['query_type'] == 'insert') { //Name can't be blank on insertion if ($_POST['Name'] == '') { echo "Invalid Name entered. Name cannot be blank. <br />"; } else { if (count(my_trusted_mysql_query("SELECT Email FROM COMPANY WHERE Email = '{$q['Email']}'")) > 0) { echo "The company with the e-mail " . $q['Email'] . " already exists in the database. " . "To edit this company's information, please select update instead of insert.<br /><br />"; $_POST['Fill'] = 'true'; } else { //Perform the insertion $company_query = "INSERT INTO COMPANY (Email, Name, Address, City, State, Zip) \r\n VALUES ('{$q['Email']}', '{$q['Name']}', '{$q['Address']}', '{$q['City']}', '{$q['State']}', {$zip_num})"; my_trusted_mysql_query($company_query); if ($q['Phone'] != '') { $company_phone_query = "INSERT INTO COMPANY_PHONE (Number, Email)\r\n VALUES ('{$q['Phone']}', '{$q['Email']}')";
function utils_init() { assert_setup(); logger_setup(false); my_mysql_connect(); }
if (false !== ($tmp = mysql_create_db($link, $link, $link))) { printf("[002] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); } if ($link = my_mysql_connect($host, $user, $passwd, $db, $port, $socket)) { printf("[003] Can connect to the server using host=%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s\n", $host, $user . 'unknown_really', $db, $port, $socket); } if (!mysql_query("CREATE DATABASE mysqlcreatedb", $link)) { die(sprintf("[004] Cannot create database, aborting test, [%d] %s\n", mysql_errno($link), mysql_error($link))); } if (!mysql_query("DROP DATABASE mysqlcreatedb", $link)) { printf("[005] [%d] %s\n", mysql_errno($link), mysql_error($link)); } if (true !== ($tmp = mysql_create_db("mysqlcreatedb", $link))) { printf("[006] Expecting boolean/true, got %s/%s, [%d] %s\n", gettype($tmp), $tmp, mysql_errno($link), mysql_error($link)); } if (false !== ($tmp = mysql_create_db("mysqlcreatedb", $link))) { printf("[007] Expecting boolean/false, got %s/%s, [%d] %s\n", gettype($tmp), $tmp, mysql_errno($link), mysql_error($link)); } if (!mysql_query("DROP DATABASE mysqlcreatedb", $link)) { printf("[008] [%d] %s\n", mysql_errno($link), mysql_error($link)); } print "done!"; error_reporting(0); require_once 'connect.inc'; if (!($link = my_mysql_connect($host, $user, $passwd, $db, $port, $socket))) { printf("[c001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); } if (!mysql_query("DROP DATABASE IF EXISTS mysqlcreatedb", $link)) { printf("[c002] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } mysql_close($link);
$PAGE_TITLE = 'Installation - Step 3'; $s =& $_SESSION['INSTALL_DATA']; $texts = array('is_apache' => 'Apache HTTP Server required', 'apache_mod_rewrite' => 'Apache: mod_rewrite module required', 'mysql_version_5' => 'MySQL: version 5.0 or higher required', 'php_version_51' => 'PHP: version 5.1 or higher required', 'php_curl_or_urlfopen' => 'PHP: cURL is needed, or else "allow_url_fopen" directive should be On', 'php_short_open_tag_on' => 'PHP: "short_open_tag" directive should be On', 'php_gd' => 'PHP: gd extension required'); $check = array('is_apache' => FALSE, 'apache_mod_rewrite' => FALSE, 'mysql_version_5' => FALSE, 'php_version_51' => FALSE, 'php_curl_or_urlfopen' => FALSE, 'php_short_open_tag_on' => FALSE, 'php_gd' => FALSE); if (function_exists('apache_get_version')) { $check['is_apache'] = TRUE; } elseif (isset($_SERVER['SERVER_SIGNATURE']) && preg_match('/Apache/i', $_SERVER['SERVER_SIGNATURE'])) { $check['is_apache'] = TRUE; } elseif (isset($_SERVER['SERVER_SOFTWARE']) && preg_match('/Apache/i', $_SERVER['SERVER_SOFTWARE'])) { $check['is_apache'] = TRUE; } $tmp = floatval(substr(phpversion(), 0, 3)); if ($tmp >= 5.1) { $check['php_version_51'] = TRUE; } $tmp = my_mysql_connect($s['MYSQL_HOST'], $s['MYSQL_USER'], $s['MYSQL_PASS']); if ($tmp) { $tmp = my_mysql_get_server_info($tmp); $tmp = str_replace('.', '', substr($tmp, 0, 5)); $tmp = intval($tmp); if ($tmp >= 500) { $check['mysql_version_5'] = TRUE; } } if (function_exists('gd_info')) { $check['php_gd'] = TRUE; } if (function_exists('curl_init')) { $check['php_curl_or_urlfopen'] = TRUE; } else { $tmp = intval(ini_get('allow_url_fopen'));
/** * fn: safe_inputs * brief: takes in an array and returns an array containing the * mysql_real_escape_string() version of each element. * param: $inputs -- array of inputs from $_POST probably */ function safe_inputs($inputs) { $q = array(); my_mysql_connect(); foreach ($inputs as $key => $value) { if (is_array($value)) { $q[mysql_real_escape_string($key)] = $value; } else { $q[mysql_real_escape_string($key)] = mysql_real_escape_string($value); } } my_mysql_close(); return $q; }
<?php $title = "赞助我们 | "; include "../config.php"; include "../header.php"; $link = my_mysql_connect(); $donates = my_mysql_query($link, "select name,money,datetime,url,remark from hc_donate where status = 1 and datetime > '2015-01-01 00:00:00' order by datetime"); $donate_total = 0; ?> <section class="s-content"> <div class="container"> <div class="s-slider-nav left"> <ul> <li><a href="/about/index.php">关于我们</a></li> <li class="active"><a href="/about/donate.php">赞助我们</a></li> <li><a href="/about/qun.php">QQ群</a></li> <li><a href="/about/links.php">友情链接</a></li> <li><a href="/about/contact.php">联系我们</a></li> </ul> <a href="http://weibo.com/highcharts" target="_blank"><img src="http://static.hcharts.cn//images/weibo_210x60.png" alt="highcharts中文网官方微博" data-bd-imgshare-binded="1"></a> </div> <div class="s-box s-main left"> <h1>赞助我们 <div class="s-share bdsharebuttonbox bdshare-button-style0-24" data-bd-bind="1428301316404"><a href="#" class="bds_more" data-cmd="more"></a><a href="#" class="bds_tsina" data-cmd="tsina" title="分享到新浪微博"></a><a href="#" class="bds_weixin" data-cmd="weixin" title="分享到微信"></a><a href="#" class="bds_qzone" data-cmd="qzone" title="分享到QQ空间"></a><a href="#" class="bds_sqq" data-cmd="sqq" title="分享到QQ好友"></a><a href="#" class="bds_youdao" data-cmd="youdao" title="分享到有道云笔记"></a></div></h1> <p>中文网由个人开发和维护着,为了减轻服务器等额外成本,让我可以将更多的精力花在网站开发和网站内容更新上,需要大家的帮助和支持。</p> <p>如果您认为本网站做的不错,对您的工作带来方便,不妨小额赞助我一下,让我有动力继续完善和更新网站内容。</p> <h3>赞助方法</h3> <p>通过支付宝付款或微信转账形式给中文网赞助</p> <p class="donate-method">支付宝付款:</p> <div class="donate-cont">
function database_drop_tables_with_prefix($prefix) { if (empty($prefix)) { return FALSE; } global $s; $conn = my_mysql_connect($s['MYSQL_HOST'], $s['MYSQL_USER'], $s['MYSQL_PASS']); $dbs = my_mysql_select_db($s['MYSQL_DBNAME'], $conn); if (!$conn || !$dbs) { return FALSE; } $tmp = my_mysql_query('SHOW TABLES FROM ' . $s['MYSQL_DBNAME'], $conn); while ($tbl = my_mysql_fetch_row($tmp)) { $tbl = $tbl[0]; if (substr($tbl, 0, strlen($prefix)) == $prefix) { my_mysql_query("DROP TABLE IF EXISTS `" . $tbl . "`;", $conn); } } }
<?php require_once 'connect.inc'; if ($host == 'localhost') { $host = '127.0.0.1'; } if ($link = my_mysql_connect($host, $user, $passwd, $db, null, $socket)) { var_dump($link); } else { printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, null, $socket); }