本文整理汇总了PHP中db_link函数的典型用法代码示例。如果您正苦于以下问题:PHP db_link函数的具体用法?PHP db_link怎么用?PHP db_link使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了db_link函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: bannerlist_insert
function bannerlist_insert()
{
global $Translation;
// mm: can member insert record?
$arrPerm = getTablePermissions('bannerlist');
if (!$arrPerm[1]) {
return false;
}
$data['imgurl'] = makeSafe($_REQUEST['imgurl']);
if ($data['imgurl'] == empty_lookup_value) {
$data['imgurl'] = '';
}
$data['linkurl'] = makeSafe($_REQUEST['linkurl']);
if ($data['linkurl'] == empty_lookup_value) {
$data['linkurl'] = '';
}
$data['listdisp'] = makeSafe($_REQUEST['listdisp']);
if ($data['listdisp'] == empty_lookup_value) {
$data['listdisp'] = '';
}
$data['dldisp'] = makeSafe($_REQUEST['dldisp']);
if ($data['dldisp'] == empty_lookup_value) {
$data['dldisp'] = '';
}
$data['authdisp'] = makeSafe($_REQUEST['authdisp']);
if ($data['authdisp'] == empty_lookup_value) {
$data['authdisp'] = '';
}
// hook: bannerlist_before_insert
if (function_exists('bannerlist_before_insert')) {
$args = array();
if (!bannerlist_before_insert($data, getMemberInfo(), $args)) {
return false;
}
}
$o = array('silentErrors' => true);
sql('insert into `bannerlist` set `imgurl`=' . ($data['imgurl'] !== '' && $data['imgurl'] !== NULL ? "'{$data['imgurl']}'" : 'NULL') . ', `linkurl`=' . ($data['linkurl'] !== '' && $data['linkurl'] !== NULL ? "'{$data['linkurl']}'" : 'NULL') . ', `listdisp`=' . ($data['listdisp'] !== '' && $data['listdisp'] !== NULL ? "'{$data['listdisp']}'" : 'NULL') . ', `dldisp`=' . ($data['dldisp'] !== '' && $data['dldisp'] !== NULL ? "'{$data['dldisp']}'" : 'NULL') . ', `authdisp`=' . ($data['authdisp'] !== '' && $data['authdisp'] !== NULL ? "'{$data['authdisp']}'" : 'NULL'), $o);
if ($o['error'] != '') {
echo $o['error'];
echo "<a href=\"bannerlist_view.php?addNew_x=1\">{$Translation['< back']}</a>";
exit;
}
$recID = db_insert_id(db_link());
// hook: bannerlist_after_insert
if (function_exists('bannerlist_after_insert')) {
$res = sql("select * from `bannerlist` where `bannerid`='" . makeSafe($recID, false) . "' limit 1", $eo);
if ($row = db_fetch_assoc($res)) {
$data = array_map('makeSafe', $row);
}
$data['selectedID'] = makeSafe($recID, false);
$args = array();
if (!bannerlist_after_insert($data, getMemberInfo(), $args)) {
return get_magic_quotes_gpc() ? stripslashes($recID) : $recID;
}
}
// mm: save ownership data
sql("insert ignore into membership_userrecords set tableName='bannerlist', pkValue='{$recID}', memberID='" . getLoggedMemberID() . "', dateAdded='" . time() . "', dateUpdated='" . time() . "', groupID='" . getLoggedGroupID() . "'", $eo);
return get_magic_quotes_gpc() ? stripslashes($recID) : $recID;
}
示例2: shippers_insert
function shippers_insert()
{
global $Translation;
if ($_GET['insert_x'] != '') {
$_POST = $_GET;
}
// mm: can member insert record?
$arrPerm = getTablePermissions('shippers');
if (!$arrPerm[1]) {
return false;
}
$data['CompanyName'] = makeSafe($_POST['CompanyName']);
if ($data['CompanyName'] == empty_lookup_value) {
$data['CompanyName'] = '';
}
$data['Phone'] = makeSafe($_POST['Phone']);
if ($data['Phone'] == empty_lookup_value) {
$data['Phone'] = '';
}
if ($data['CompanyName'] == '') {
echo StyleSheet() . "\n\n<div class=\"alert alert-danger\">" . $Translation['error:'] . " 'Company Name': " . $Translation['field not null'] . '<br><br>';
echo '<a href="" onclick="history.go(-1); return false;">' . $Translation['< back'] . '</a></div>';
exit;
}
// hook: shippers_before_insert
if (function_exists('shippers_before_insert')) {
$args = array();
if (!shippers_before_insert($data, getMemberInfo(), $args)) {
return false;
}
}
$o = array('silentErrors' => true);
sql('insert into `shippers` set `CompanyName`=' . ($data['CompanyName'] !== '' && $data['CompanyName'] !== NULL ? "'{$data['CompanyName']}'" : 'NULL') . ', `Phone`=' . ($data['Phone'] !== '' && $data['Phone'] !== NULL ? "'{$data['Phone']}'" : 'NULL'), $o);
if ($o['error'] != '') {
echo $o['error'];
echo "<a href=\"shippers_view.php?addNew_x=1\">{$Translation['< back']}</a>";
exit;
}
$recID = db_insert_id(db_link());
// hook: shippers_after_insert
if (function_exists('shippers_after_insert')) {
$res = sql("select * from `shippers` where `ShipperID`='" . makeSafe($recID) . "' limit 1", $eo);
if ($row = db_fetch_assoc($res)) {
$data = array_map('makeSafe', $row);
}
$data['selectedID'] = makeSafe($recID);
$args = array();
if (!shippers_after_insert($data, getMemberInfo(), $args)) {
return get_magic_quotes_gpc() ? stripslashes($recID) : $recID;
}
}
// mm: save ownership data
sql("insert into membership_userrecords set tableName='shippers', pkValue='{$recID}', memberID='" . getLoggedMemberID() . "', dateAdded='" . time() . "', dateUpdated='" . time() . "', groupID='" . getLoggedGroupID() . "'", $eo);
return get_magic_quotes_gpc() ? stripslashes($recID) : $recID;
}
示例3: db_error
function db_error($link = NULL, $mysqli_connect = false)
{
if (!$link) {
$link = db_link();
}
switch (DATABASE) {
case 'mysql':
return mysql_error($link);
case 'mysqli':
if ($mysqli_connect) {
return mysqli_connect_error();
}
return mysqli_error($link);
}
}
示例4: residence_and_rental_history_insert
function residence_and_rental_history_insert()
{
global $Translation;
if ($_GET['insert_x'] != '') {
$_POST = $_GET;
}
// mm: can member insert record?
$arrPerm = getTablePermissions('residence_and_rental_history');
if (!$arrPerm[1]) {
return false;
}
$data['tenant'] = makeSafe($_POST['tenant']);
if ($data['tenant'] == empty_lookup_value) {
$data['tenant'] = '';
}
$data['address'] = makeSafe($_POST['address']);
if ($data['address'] == empty_lookup_value) {
$data['address'] = '';
}
$data['landlord_or_manager_name'] = makeSafe($_POST['landlord_or_manager_name']);
if ($data['landlord_or_manager_name'] == empty_lookup_value) {
$data['landlord_or_manager_name'] = '';
}
$data['landlord_or_manager_phone'] = makeSafe($_POST['landlord_or_manager_phone']);
if ($data['landlord_or_manager_phone'] == empty_lookup_value) {
$data['landlord_or_manager_phone'] = '';
}
$data['monthly_rent'] = makeSafe($_POST['monthly_rent']);
if ($data['monthly_rent'] == empty_lookup_value) {
$data['monthly_rent'] = '';
}
$data['duration_of_residency_from'] = intval($_POST['duration_of_residency_fromYear']) . '-' . intval($_POST['duration_of_residency_fromMonth']) . '-' . intval($_POST['duration_of_residency_fromDay']);
$data['duration_of_residency_from'] = parseMySQLDate($data['duration_of_residency_from'], '');
$data['to'] = intval($_POST['toYear']) . '-' . intval($_POST['toMonth']) . '-' . intval($_POST['toDay']);
$data['to'] = parseMySQLDate($data['to'], '');
$data['reason_for_leaving'] = makeSafe($_POST['reason_for_leaving']);
if ($data['reason_for_leaving'] == empty_lookup_value) {
$data['reason_for_leaving'] = '';
}
$data['notes'] = makeSafe($_POST['notes']);
if ($data['notes'] == empty_lookup_value) {
$data['notes'] = '';
}
// hook: residence_and_rental_history_before_insert
if (function_exists('residence_and_rental_history_before_insert')) {
$args = array();
if (!residence_and_rental_history_before_insert($data, getMemberInfo(), $args)) {
return false;
}
}
$o = array('silentErrors' => true);
sql('insert into `residence_and_rental_history` set `tenant`=' . ($data['tenant'] !== '' && $data['tenant'] !== NULL ? "'{$data['tenant']}'" : 'NULL') . ', `address`=' . ($data['address'] !== '' && $data['address'] !== NULL ? "'{$data['address']}'" : 'NULL') . ', `landlord_or_manager_name`=' . ($data['landlord_or_manager_name'] !== '' && $data['landlord_or_manager_name'] !== NULL ? "'{$data['landlord_or_manager_name']}'" : 'NULL') . ', `landlord_or_manager_phone`=' . ($data['landlord_or_manager_phone'] !== '' && $data['landlord_or_manager_phone'] !== NULL ? "'{$data['landlord_or_manager_phone']}'" : 'NULL') . ', `monthly_rent`=' . ($data['monthly_rent'] !== '' && $data['monthly_rent'] !== NULL ? "'{$data['monthly_rent']}'" : 'NULL') . ', `duration_of_residency_from`=' . ($data['duration_of_residency_from'] !== '' && $data['duration_of_residency_from'] !== NULL ? "'{$data['duration_of_residency_from']}'" : 'NULL') . ', `to`=' . ($data['to'] !== '' && $data['to'] !== NULL ? "'{$data['to']}'" : 'NULL') . ', `reason_for_leaving`=' . ($data['reason_for_leaving'] !== '' && $data['reason_for_leaving'] !== NULL ? "'{$data['reason_for_leaving']}'" : 'NULL') . ', `notes`=' . ($data['notes'] !== '' && $data['notes'] !== NULL ? "'{$data['notes']}'" : 'NULL'), $o);
if ($o['error'] != '') {
echo $o['error'];
echo "<a href=\"residence_and_rental_history_view.php?addNew_x=1\">{$Translation['< back']}</a>";
exit;
}
$recID = db_insert_id(db_link());
// hook: residence_and_rental_history_after_insert
if (function_exists('residence_and_rental_history_after_insert')) {
$res = sql("select * from `residence_and_rental_history` where `id`='" . makeSafe($recID) . "' limit 1", $eo);
if ($row = db_fetch_assoc($res)) {
$data = array_map('makeSafe', $row);
}
$data['selectedID'] = makeSafe($recID);
$args = array();
if (!residence_and_rental_history_after_insert($data, getMemberInfo(), $args)) {
return get_magic_quotes_gpc() ? stripslashes($recID) : $recID;
}
}
// mm: save ownership data
sql("insert into membership_userrecords set tableName='residence_and_rental_history', pkValue='{$recID}', memberID='" . getLoggedMemberID() . "', dateAdded='" . time() . "', dateUpdated='" . time() . "', groupID='" . getLoggedGroupID() . "'", $eo);
return get_magic_quotes_gpc() ? stripslashes($recID) : $recID;
}
示例5: setupTable
function setupTable($tableName, $createSQL = '', $silent = true, $arrAlter = '')
{
global $Translation;
ob_start();
echo '<div style="padding: 5px; border-bottom:solid 1px silver; font-family: verdana, arial; font-size: 10px;">';
// is there a table rename query?
if (is_array($arrAlter)) {
$matches = array();
if (preg_match("/ALTER TABLE `(.*)` RENAME `{$tableName}`/", $arrAlter[0], $matches)) {
$oldTableName = $matches[1];
}
}
if ($res = @db_query("select count(1) from `{$tableName}`")) {
// table already exists
if ($row = @db_fetch_array($res)) {
echo str_replace("<TableName>", $tableName, str_replace("<NumRecords>", $row[0], $Translation["table exists"]));
if (is_array($arrAlter)) {
echo '<br>';
foreach ($arrAlter as $alter) {
if ($alter != '') {
echo "{$alter} ... ";
if (!@db_query($alter)) {
echo '<span class="label label-danger">' . $Translation['failed'] . '</span>';
echo '<div class="text-danger">' . $Translation['mysql said'] . ' ' . db_error(db_link()) . '</div>';
} else {
echo '<span class="label label-success">' . $Translation['ok'] . '</span>';
}
}
}
} else {
echo $Translation["table uptodate"];
}
} else {
echo str_replace("<TableName>", $tableName, $Translation["couldnt count"]);
}
} else {
// given tableName doesn't exist
if ($oldTableName != '') {
// if we have a table rename query
if ($ro = @db_query("select count(1) from `{$oldTableName}`")) {
// if old table exists, rename it.
$renameQuery = array_shift($arrAlter);
// get and remove rename query
echo "{$renameQuery} ... ";
if (!@db_query($renameQuery)) {
echo '<span class="label label-danger">' . $Translation['failed'] . '</span>';
echo '<div class="text-danger">' . $Translation['mysql said'] . ' ' . db_error(db_link()) . '</div>';
} else {
echo '<span class="label label-success">' . $Translation['ok'] . '</span>';
}
if (is_array($arrAlter)) {
setupTable($tableName, $createSQL, false, $arrAlter);
}
// execute Alter queries on renamed table ...
} else {
// if old tableName doesn't exist (nor the new one since we're here), then just create the table.
setupTable($tableName, $createSQL, false);
// no Alter queries passed ...
}
} else {
// tableName doesn't exist and no rename, so just create the table
echo str_replace("<TableName>", $tableName, $Translation["creating table"]);
if (!@db_query($createSQL)) {
echo '<span class="label label-danger">' . $Translation['failed'] . '</span>';
echo '<div class="text-danger">' . $Translation['mysql said'] . db_error(db_link()) . '</div>';
} else {
echo '<span class="label label-success">' . $Translation['ok'] . '</span>';
}
}
}
echo "</div>";
$out = ob_get_contents();
ob_end_clean();
if (!$silent) {
echo $out;
}
}
示例6: products_insert
function products_insert()
{
global $Translation;
if ($_GET['insert_x'] != '') {
$_POST = $_GET;
}
// mm: can member insert record?
$arrPerm = getTablePermissions('products');
if (!$arrPerm[1]) {
return false;
}
$data['ProductName'] = makeSafe($_POST['ProductName']);
if ($data['ProductName'] == empty_lookup_value) {
$data['ProductName'] = '';
}
$data['SupplierID'] = makeSafe($_POST['SupplierID']);
if ($data['SupplierID'] == empty_lookup_value) {
$data['SupplierID'] = '';
}
$data['CategoryID'] = makeSafe($_POST['CategoryID']);
if ($data['CategoryID'] == empty_lookup_value) {
$data['CategoryID'] = '';
}
$data['QuantityPerUnit'] = makeSafe($_POST['QuantityPerUnit']);
if ($data['QuantityPerUnit'] == empty_lookup_value) {
$data['QuantityPerUnit'] = '';
}
$data['UnitPrice'] = makeSafe($_POST['UnitPrice']);
if ($data['UnitPrice'] == empty_lookup_value) {
$data['UnitPrice'] = '';
}
$data['UnitsInStock'] = makeSafe($_POST['UnitsInStock']);
if ($data['UnitsInStock'] == empty_lookup_value) {
$data['UnitsInStock'] = '';
}
$data['UnitsOnOrder'] = makeSafe($_POST['UnitsOnOrder']);
if ($data['UnitsOnOrder'] == empty_lookup_value) {
$data['UnitsOnOrder'] = '';
}
$data['ReorderLevel'] = makeSafe($_POST['ReorderLevel']);
if ($data['ReorderLevel'] == empty_lookup_value) {
$data['ReorderLevel'] = '';
}
$data['Discontinued'] = makeSafe($_POST['Discontinued']);
if ($data['Discontinued'] == empty_lookup_value) {
$data['Discontinued'] = '';
}
if ($data['UnitPrice'] == '') {
$data['UnitPrice'] = "0";
}
if ($data['UnitsInStock'] == '') {
$data['UnitsInStock'] = "0";
}
if ($data['UnitsOnOrder'] == '') {
$data['UnitsOnOrder'] = "0";
}
if ($data['ReorderLevel'] == '') {
$data['ReorderLevel'] = "0";
}
// hook: products_before_insert
if (function_exists('products_before_insert')) {
$args = array();
if (!products_before_insert($data, getMemberInfo(), $args)) {
return false;
}
}
$o = array('silentErrors' => true);
sql('insert into `products` set `ProductName`=' . ($data['ProductName'] !== '' && $data['ProductName'] !== NULL ? "'{$data['ProductName']}'" : 'NULL') . ', `SupplierID`=' . ($data['SupplierID'] !== '' && $data['SupplierID'] !== NULL ? "'{$data['SupplierID']}'" : 'NULL') . ', `CategoryID`=' . ($data['CategoryID'] !== '' && $data['CategoryID'] !== NULL ? "'{$data['CategoryID']}'" : 'NULL') . ', `QuantityPerUnit`=' . ($data['QuantityPerUnit'] !== '' && $data['QuantityPerUnit'] !== NULL ? "'{$data['QuantityPerUnit']}'" : 'NULL') . ', `UnitPrice`=' . ($data['UnitPrice'] !== '' && $data['UnitPrice'] !== NULL ? "'{$data['UnitPrice']}'" : 'NULL') . ', `UnitsInStock`=' . ($data['UnitsInStock'] !== '' && $data['UnitsInStock'] !== NULL ? "'{$data['UnitsInStock']}'" : 'NULL') . ', `UnitsOnOrder`=' . ($data['UnitsOnOrder'] !== '' && $data['UnitsOnOrder'] !== NULL ? "'{$data['UnitsOnOrder']}'" : 'NULL') . ', `ReorderLevel`=' . ($data['ReorderLevel'] !== '' && $data['ReorderLevel'] !== NULL ? "'{$data['ReorderLevel']}'" : 'NULL') . ', `Discontinued`=' . ($data['Discontinued'] !== '' && $data['Discontinued'] !== NULL ? "'{$data['Discontinued']}'" : 'NULL'), $o);
if ($o['error'] != '') {
echo $o['error'];
echo "<a href=\"products_view.php?addNew_x=1\">{$Translation['< back']}</a>";
exit;
}
$recID = db_insert_id(db_link());
// hook: products_after_insert
if (function_exists('products_after_insert')) {
$res = sql("select * from `products` where `ProductID`='" . makeSafe($recID) . "' limit 1", $eo);
if ($row = db_fetch_assoc($res)) {
$data = array_map('makeSafe', $row);
}
$data['selectedID'] = makeSafe($recID);
$args = array();
if (!products_after_insert($data, getMemberInfo(), $args)) {
return get_magic_quotes_gpc() ? stripslashes($recID) : $recID;
}
}
// mm: save ownership data
sql("insert into membership_userrecords set tableName='products', pkValue='{$recID}', memberID='" . getLoggedMemberID() . "', dateAdded='" . time() . "', dateUpdated='" . time() . "', groupID='" . getLoggedGroupID() . "'", $eo);
return get_magic_quotes_gpc() ? stripslashes($recID) : $recID;
}
示例7: method_insertpin
function method_insertpin($params, $error)
{
if (!isset($_SESSION['username'])) {
die("Not logged in");
}
if (!check_permission($_SESSION['member_id'], "AMEND_PINS")) {
$error->SetError(JsonRpcError_PermissionDenied, "Permission Denied (AMEND_PINS)");
return $error;
}
$err = "";
$link = db_link();
if (strlen($params[1]) <= 1) {
$d = "";
} else {
$exp_date = new DateTime($params[1]);
$d = date_format($exp_date, 'd/m/Y H:i:s');
}
$ret = $link->sp_pin_insert($params[0], $d, $params[2], $params[3], $err);
$link->close();
if (strlen($err) > 0) {
$ret = $err;
} else {
if (!$ret) {
$ret = "Failed to insert";
} else {
$ret = "";
}
}
return $ret;
}
示例8: login
function login()
{
$result = array();
if (!isset($_POST["username"]) || !isset($_POST["password"])) {
$result['access_granted'] = false;
$result['error'] = 'Missing username/password';
} else {
$username = $_POST["username"];
$password = $_POST["password"];
/* Replace anything that isn't a-Z, 0-9 with an underscore (mostly after spaces...) */
$username = preg_replace('/[^a-zA-Z0-9]/', '_', $username);
$oInstDB = db_link();
if ($oInstDB->sp_wiki_login($username, $email, $name, $ret)) {
if ($ret == 1) {
/* check password */
$krb5 = krb_auth();
if ($krb5->check_password($username, $password)) {
$result['access_granted'] = true;
$result['name'] = $name;
$result['email'] = $email;
} else {
$result['access_granted'] = false;
$result['error'] = "Incorrect password / password check failed for [{$username}]";
}
} else {
$result['access_granted'] = false;
$result['error'] = 'Unknown username / no Wiki permission';
}
} else {
$result['access_granted'] = false;
$result['error'] = 'DB check failed';
}
}
return $result;
}
示例9: checkPermissionVal
$shippers_view = checkPermissionVal('shippers_view');
$shippers_edit = checkPermissionVal('shippers_edit');
$shippers_delete = checkPermissionVal('shippers_delete');
###############################
// new group or old?
if ($_POST['groupID'] == '') {
// new group
// make sure group name is unique
if (sqlValue("select count(1) from membership_groups where name='{$name}'")) {
echo "<div class=\"alert alert-danger\">Error: Group name already exists. You must choose a unique group name.</div>";
include "{$currDir}/incFooter.php";
}
// add group
sql("insert into membership_groups set name='{$name}', description='{$description}', allowSignup='{$allowSignup}', needsApproval='{$needsApproval}'", $eo);
// get new groupID
$groupID = db_insert_id(db_link());
} else {
// old group
// validate groupID
$groupID = intval($_POST['groupID']);
if ($groupID == $anonGroupID) {
$name = $adminConfig['anonymousGroup'];
$allowSignup = 0;
$needsApproval = 0;
}
// make sure group name is unique
if (sqlValue("select count(1) from membership_groups where name='{$name}' and groupID!='{$groupID}'")) {
echo "<div class=\"alert alert-danger\">Error: Group name already exists. You must choose a unique group name.</div>";
include "{$currDir}/incFooter.php";
}
// update group
示例10: sql
function sql($statment, &$o)
{
static $connected = false, $db_link;
// $connect would be set to true on successful connection
if (!$connected) {
/****** Connect to MySQL ******/
if (!($db_link = @db_connect(config('dbServer'), config('dbUsername'), config('dbPassword')))) {
echo "<div class=\"alert alert-danger\">Couldn't connect to MySQL at '" . config('dbServer') . "'. You might need to re-configure this application. You can do so by manually editing the config.php file, or by deleting it to run the setup wizard.</div>";
exit;
}
/****** Select DB ********/
if (!db_select_db(config('dbDatabase'), $db_link)) {
echo "<div class=\"alert alert-danger\">Couldn't connect to the database '" . config('dbDatabase') . "'.</div>";
exit;
}
$connected = true;
}
if (!($result = @db_query($statment))) {
echo "An error occured while attempting to execute:<br><pre>" . htmlspecialchars($statment) . "</pre><br>MySQL said:<br><pre>" . db_error(db_link()) . "</pre>";
exit;
}
return $result;
}
示例11: implode
}
$valList = implode("','", $arrCSVData[$j]);
if ($valList != '' && strlen($valList) > count($arrCSVData[$j]) * 3) {
$insert .= "('" . $valList . "'),";
}
}
// update record if pk matches
if ($_POST['csvUpdateIfPKExists']) {
$insert = "replace `{$tn}` ({$fieldList}) values " . substr($insert, 0, -1);
} else {
$insert = "insert ignore into `{$tn}` ({$fieldList}) values " . substr($insert, 0, -1);
}
// execute batch
echo 'Importing batch ' . (($i - 1) / $batch + 1) . ' of ' . $numBatches . ': ';
if (!@db_query($insert)) {
echo 'ERROR: ' . db_error(db_link()) . "\n";
} else {
echo "Ok\n";
}
if (!($i % ($batch * 5))) {
flush();
}
}
echo "</textarea>";
} else {
/* no more records in csv file */
$numRows = 0;
}
if ($numRows < MAXROWS) {
/* reached end of data */
// remove uploaded csv file
示例12: employees_insert
function employees_insert()
{
global $Translation;
if ($_GET['insert_x'] != '') {
$_POST = $_GET;
}
// mm: can member insert record?
$arrPerm = getTablePermissions('employees');
if (!$arrPerm[1]) {
return false;
}
$data['TitleOfCourtesy'] = makeSafe($_POST['TitleOfCourtesy']);
if ($data['TitleOfCourtesy'] == empty_lookup_value) {
$data['TitleOfCourtesy'] = '';
}
$data['LastName'] = makeSafe($_POST['LastName']);
if ($data['LastName'] == empty_lookup_value) {
$data['LastName'] = '';
}
$data['FirstName'] = makeSafe($_POST['FirstName']);
if ($data['FirstName'] == empty_lookup_value) {
$data['FirstName'] = '';
}
$data['Title'] = makeSafe($_POST['Title']);
if ($data['Title'] == empty_lookup_value) {
$data['Title'] = '';
}
$data['BirthDate'] = intval($_POST['BirthDateYear']) . '-' . intval($_POST['BirthDateMonth']) . '-' . intval($_POST['BirthDateDay']);
$data['BirthDate'] = parseMySQLDate($data['BirthDate'], '');
$data['HireDate'] = intval($_POST['HireDateYear']) . '-' . intval($_POST['HireDateMonth']) . '-' . intval($_POST['HireDateDay']);
$data['HireDate'] = parseMySQLDate($data['HireDate'], '1');
$data['Address'] = br2nl(makeSafe($_POST['Address']));
$data['City'] = makeSafe($_POST['City']);
if ($data['City'] == empty_lookup_value) {
$data['City'] = '';
}
$data['Region'] = makeSafe($_POST['Region']);
if ($data['Region'] == empty_lookup_value) {
$data['Region'] = '';
}
$data['PostalCode'] = makeSafe($_POST['PostalCode']);
if ($data['PostalCode'] == empty_lookup_value) {
$data['PostalCode'] = '';
}
$data['Country'] = makeSafe($_POST['Country']);
if ($data['Country'] == empty_lookup_value) {
$data['Country'] = '';
}
$data['HomePhone'] = makeSafe($_POST['HomePhone']);
if ($data['HomePhone'] == empty_lookup_value) {
$data['HomePhone'] = '';
}
$data['Extension'] = makeSafe($_POST['Extension']);
if ($data['Extension'] == empty_lookup_value) {
$data['Extension'] = '';
}
$data['Notes'] = makeSafe($_POST['Notes']);
if ($data['Notes'] == empty_lookup_value) {
$data['Notes'] = '';
}
$data['ReportsTo'] = makeSafe($_POST['ReportsTo']);
if ($data['ReportsTo'] == empty_lookup_value) {
$data['ReportsTo'] = '';
}
$data['Photo'] = PrepareUploadedFile('Photo', 153600, 'jpg|jpeg|gif|png', false, '');
if ($data['Photo']) {
createThumbnail($data['Photo'], getThumbnailSpecs('employees', 'Photo', 'tv'));
}
/* for empty upload fields, when saving a copy of an existing record, copy the original upload field */
if ($_REQUEST['SelectedID']) {
$res = sql("select * from employees where EmployeeID='" . makeSafe($_REQUEST['SelectedID']) . "'");
if ($row = db_fetch_assoc($res)) {
if (!$data['Photo']) {
$data['Photo'] = makeSafe($row['Photo']);
}
}
}
// hook: employees_before_insert
if (function_exists('employees_before_insert')) {
$args = array();
if (!employees_before_insert($data, getMemberInfo(), $args)) {
return false;
}
}
$o = array('silentErrors' => true);
sql('insert into `employees` set `TitleOfCourtesy`=' . ($data['TitleOfCourtesy'] !== '' && $data['TitleOfCourtesy'] !== NULL ? "'{$data['TitleOfCourtesy']}'" : 'NULL') . ', ' . ($data['Photo'] != '' ? "`Photo`='{$data['Photo']}'" : '`Photo`=NULL') . ', `LastName`=' . ($data['LastName'] !== '' && $data['LastName'] !== NULL ? "'{$data['LastName']}'" : 'NULL') . ', `FirstName`=' . ($data['FirstName'] !== '' && $data['FirstName'] !== NULL ? "'{$data['FirstName']}'" : 'NULL') . ', `Title`=' . ($data['Title'] !== '' && $data['Title'] !== NULL ? "'{$data['Title']}'" : 'NULL') . ', `BirthDate`=' . ($data['BirthDate'] !== '' && $data['BirthDate'] !== NULL ? "'{$data['BirthDate']}'" : 'NULL') . ', `HireDate`=' . ($data['HireDate'] !== '' && $data['HireDate'] !== NULL ? "'{$data['HireDate']}'" : 'NULL') . ', `Address`=' . ($data['Address'] !== '' && $data['Address'] !== NULL ? "'{$data['Address']}'" : 'NULL') . ', `City`=' . ($data['City'] !== '' && $data['City'] !== NULL ? "'{$data['City']}'" : 'NULL') . ', `Region`=' . ($data['Region'] !== '' && $data['Region'] !== NULL ? "'{$data['Region']}'" : 'NULL') . ', `PostalCode`=' . ($data['PostalCode'] !== '' && $data['PostalCode'] !== NULL ? "'{$data['PostalCode']}'" : 'NULL') . ', `Country`=' . ($data['Country'] !== '' && $data['Country'] !== NULL ? "'{$data['Country']}'" : 'NULL') . ', `HomePhone`=' . ($data['HomePhone'] !== '' && $data['HomePhone'] !== NULL ? "'{$data['HomePhone']}'" : 'NULL') . ', `Extension`=' . ($data['Extension'] !== '' && $data['Extension'] !== NULL ? "'{$data['Extension']}'" : 'NULL') . ', `Notes`=' . ($data['Notes'] !== '' && $data['Notes'] !== NULL ? "'{$data['Notes']}'" : 'NULL') . ', `ReportsTo`=' . ($data['ReportsTo'] !== '' && $data['ReportsTo'] !== NULL ? "'{$data['ReportsTo']}'" : 'NULL'), $o);
if ($o['error'] != '') {
echo $o['error'];
echo "<a href=\"employees_view.php?addNew_x=1\">{$Translation['< back']}</a>";
exit;
}
$recID = db_insert_id(db_link());
// hook: employees_after_insert
if (function_exists('employees_after_insert')) {
$res = sql("select * from `employees` where `EmployeeID`='" . makeSafe($recID) . "' limit 1", $eo);
if ($row = db_fetch_assoc($res)) {
$data = array_map('makeSafe', $row);
}
$data['selectedID'] = makeSafe($recID);
$args = array();
//.........这里部分代码省略.........
示例13: substr
if ($valList != '' && strlen($valList) > count($arrCSVData[$j]) * 3) {
$insert .= "('" . $valList . "'),";
}
}
// update record if pk matches
if ($_POST['csvUpdateIfPKExists']) {
$insert = "replace `{$tn}` ({$fieldList}) values " . substr($insert, 0, -1);
} else {
$insert = "insert ignore into `{$tn}` ({$fieldList}) values " . substr($insert, 0, -1);
}
// execute batch
$originalValues = array('<BATCH>', '<BATCHNUM>');
$replaceValues = array(($i - 1) / $batch + 1, $numBatches);
echo str_replace($originalValues, $replaceValues, $Translation['importing batch']);
if (!@db_query($insert)) {
echo "{$Translation['error']}: " . db_error(db_link()) . "\n";
} else {
echo $Translation['ok'] . "\n";
}
if (!($i % ($batch * 5))) {
flush();
}
}
echo "</textarea>";
} else {
/* no more records in csv file */
$numRows = 0;
}
if ($numRows < MAXROWS) {
/* reached end of data */
// remove uploaded csv file
示例14: properties_insert
function properties_insert()
{
global $Translation;
if ($_GET['insert_x'] != '') {
$_POST = $_GET;
}
// mm: can member insert record?
$arrPerm = getTablePermissions('properties');
if (!$arrPerm[1]) {
return false;
}
$data['property_name'] = makeSafe($_POST['property_name']);
if ($data['property_name'] == empty_lookup_value) {
$data['property_name'] = '';
}
$data['type'] = makeSafe($_POST['type']);
if ($data['type'] == empty_lookup_value) {
$data['type'] = '';
}
$data['number_of_units'] = makeSafe($_POST['number_of_units']);
if ($data['number_of_units'] == empty_lookup_value) {
$data['number_of_units'] = '';
}
$data['owner'] = makeSafe($_POST['owner']);
if ($data['owner'] == empty_lookup_value) {
$data['owner'] = '';
}
$data['operating_account'] = makeSafe($_POST['operating_account']);
if ($data['operating_account'] == empty_lookup_value) {
$data['operating_account'] = '';
}
$data['property_reserve'] = makeSafe($_POST['property_reserve']);
if ($data['property_reserve'] == empty_lookup_value) {
$data['property_reserve'] = '';
}
$data['lease_term'] = makeSafe($_POST['lease_term']);
if ($data['lease_term'] == empty_lookup_value) {
$data['lease_term'] = '';
}
$data['country'] = makeSafe($_POST['country']);
if ($data['country'] == empty_lookup_value) {
$data['country'] = '';
}
$data['street'] = makeSafe($_POST['street']);
if ($data['street'] == empty_lookup_value) {
$data['street'] = '';
}
$data['City'] = makeSafe($_POST['City']);
if ($data['City'] == empty_lookup_value) {
$data['City'] = '';
}
$data['State'] = makeSafe($_POST['State']);
if ($data['State'] == empty_lookup_value) {
$data['State'] = '';
}
$data['ZIP'] = makeSafe($_POST['ZIP']);
if ($data['ZIP'] == empty_lookup_value) {
$data['ZIP'] = '';
}
$data['photo'] = PrepareUploadedFile('photo', 1024000, 'jpg|jpeg|gif|png', false, '');
if ($data['photo']) {
createThumbnail($data['photo'], getThumbnailSpecs('properties', 'photo', 'tv'));
}
if ($data['photo']) {
createThumbnail($data['photo'], getThumbnailSpecs('properties', 'photo', 'dv'));
}
if ($data['property_name'] == '') {
echo StyleSheet() . "\n\n<div class=\"alert alert-danger\">" . $Translation['error:'] . " 'Property Name': " . $Translation['field not null'] . '<br><br>';
echo '<a href="" onclick="history.go(-1); return false;">' . $Translation['< back'] . '</a></div>';
exit;
}
if ($data['type'] == '') {
echo StyleSheet() . "\n\n<div class=\"alert alert-danger\">" . $Translation['error:'] . " 'Type': " . $Translation['field not null'] . '<br><br>';
echo '<a href="" onclick="history.go(-1); return false;">' . $Translation['< back'] . '</a></div>';
exit;
}
// hook: properties_before_insert
if (function_exists('properties_before_insert')) {
$args = array();
if (!properties_before_insert($data, getMemberInfo(), $args)) {
return false;
}
}
$o = array('silentErrors' => true);
sql('insert into `properties` set `property_name`=' . ($data['property_name'] !== '' && $data['property_name'] !== NULL ? "'{$data['property_name']}'" : 'NULL') . ', `type`=' . ($data['type'] !== '' && $data['type'] !== NULL ? "'{$data['type']}'" : 'NULL') . ', `number_of_units`=' . ($data['number_of_units'] !== '' && $data['number_of_units'] !== NULL ? "'{$data['number_of_units']}'" : 'NULL') . ', ' . ($data['photo'] != '' ? "`photo`='{$data['photo']}'" : ($_POST['photo_remove'] != 1 ? '`photo`=`photo`' : '`photo`=NULL')) . ', `owner`=' . ($data['owner'] !== '' && $data['owner'] !== NULL ? "'{$data['owner']}'" : 'NULL') . ', `country`=' . ($data['country'] !== '' && $data['country'] !== NULL ? "'{$data['country']}'" : 'NULL') . ', `street`=' . ($data['street'] !== '' && $data['street'] !== NULL ? "'{$data['street']}'" : 'NULL') . ', `City`=' . ($data['City'] !== '' && $data['City'] !== NULL ? "'{$data['City']}'" : 'NULL') . ', `State`=' . ($data['State'] !== '' && $data['State'] !== NULL ? "'{$data['State']}'" : 'NULL') . ', `ZIP`=' . ($data['ZIP'] !== '' && $data['ZIP'] !== NULL ? "'{$data['ZIP']}'" : 'NULL'), $o);
if ($o['error'] != '') {
echo $o['error'];
echo "<a href=\"properties_view.php?addNew_x=1\">{$Translation['< back']}</a>";
exit;
}
$recID = db_insert_id(db_link());
// hook: properties_after_insert
if (function_exists('properties_after_insert')) {
$res = sql("select * from `properties` where `id`='" . makeSafe($recID) . "' limit 1", $eo);
if ($row = db_fetch_assoc($res)) {
$data = array_map('makeSafe', $row);
}
$data['selectedID'] = makeSafe($recID);
$args = array();
if (!properties_after_insert($data, getMemberInfo(), $args)) {
//.........这里部分代码省略.........
示例15: ob_start
<?php
ob_start();
?>
<center>
<?php
$currDir = dirname(__FILE__);
include "{$currDir}/defaultLang.php";
include "{$currDir}/language.php";
include "{$currDir}/lib.php";
$memberID = db_escape(strtolower($_GET['memberID']), db_link());
if ($memberID != '') {
$res = sql("select memberID from membership_users where lcase(memberID)='{$memberID}'", $eo);
if ($row = db_fetch_row($res)) {
echo "<b>" . str_replace("<MemberID>", $memberID, $Translation['user already exists']) . "</b><!-- NOT AVAILABLE -->";
} else {
echo "<b>" . str_replace("<MemberID>", $memberID, $Translation['user available']) . "</b><!-- AVAILABLE -->";
}
} else {
echo $Translation['empty user'];
}
?>
<br><br><input type="button" value="Close" onClick="window.close();">
</center>