本文整理汇总了PHP中Db::disconnect方法的典型用法代码示例。如果您正苦于以下问题:PHP Db::disconnect方法的具体用法?PHP Db::disconnect怎么用?PHP Db::disconnect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Db
的用法示例。
在下文中一共展示了Db::disconnect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: makeActions
function makeActions()
{
global $site;
global $parametersMod;
require_once BASE_DIR . MODULE_DIR . 'administrator/email_queue/module.php';
if (isset($_REQUEST['cm_group']) && isset($_REQUEST['cm_name'])) {
$menuModule = Db::getMenuModModule(null, $_REQUEST['cm_group'], $_REQUEST['cm_name']);
if ($menuModule) {
eval(' $new_module = new \\Modules\\standard\\content_management\\Widgets\\' . $menuModule['g_name'] . '\\' . $menuModule['m_name'] . '\\Module(); ');
$new_module->makeActions();
}
}
if (isset($_POST['id'])) {
$road = $site->getZone($site->currentZone)->getRoadToElement($_POST['id']);
$urlVars = array();
foreach ($road as $key => $value) {
$urlVars[] = $value->getUrl();
}
echo 'window.location.href = \'' . $site->generateUrl(null, $site->currentZone, $urlVars) . '\';';
}
if (isset($_POST['action']) && $_POST['action'] == 'sitemap_list') {
$list = $this->getSitemapInList();
echo $list;
}
\Db::disconnect();
exit;
}
示例2: setup
public function setup()
{
global $baseParams;
$db = new Db($baseParams['__YKVAL_DB_DSN__'], 'root', 'lab', $baseParams['__YKVAL_DB_OPTIONS__']);
$db->connect();
# $db->truncateTable('queue');
$db->disconnect();
}
示例3: __construct
function __construct()
{
session_name(SESSION_NAME);
session_start();
if (sizeof($_POST) > 0 || sizeof($_GET) > 0) {
//CSRF atack check
if ((!isset($_REQUEST['security_token']) || $this->securityToken() != $_REQUEST['security_token']) && (!isset($_REQUEST['action']) || $_REQUEST['action'] != "login" || isset($_REQUEST['module_id']))) {
global $cms;
echo '
<script type="text/javascript">document.location=\'admin.php\'</script>
';
/* trigger_error("Possible CSRF atack.\n Referer:".(isset($_SERVER['HTTP_REFERER'])?"No":$_SERVER["http_referer"])."\n Destination:".$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]);*/
\Db::disconnect();
exit;
}
}
}
示例4: makeActions
function makeActions()
{
if (isset($_REQUEST['action'])) {
switch ($_REQUEST['action']) {
case 'getSystemInfo':
$module = new Module();
$systemInfo = $module->getSystemInfo();
if (isset($_REQUEST['afterLogin'])) {
// request after login.
if ($systemInfo == '') {
$_SESSION['modules']['administrator']['system']['show_system_message'] = false;
//don't display system alert at the top.
return;
} else {
$md5 = \DbSystem::getSystemVariable('last_system_message_shown');
if ($systemInfo && (!$md5 || $md5 != md5($systemInfo))) {
//we have a new message
$newMessage = false;
foreach (json_decode($systemInfo) as $infoKey => $infoValue) {
if ($infoValue->type != 'status') {
$newMessage = true;
}
}
$_SESSION['modules']['administrator']['system']['show_system_message'] = $newMessage;
//display system alert
} else {
//this message was already seen.
$_SESSION['modules']['administrator']['system']['show_system_message'] = false;
//don't display system alert at the top.
return;
}
}
} else {
//administrator/system tab.
\DbSystem::setSystemVariable('last_system_message_shown', md5($systemInfo));
$_SESSION['modules']['administrator']['system']['show_system_message'] = false;
//don't display system alert at the top.
}
echo $systemInfo;
break;
}
}
\Db::disconnect();
exit;
}
示例5: makeRedirect
private function makeRedirect()
{
$curEl = $this->getCurrentElement();
if ($curEl) {
//if page exist.
switch ($curEl->getType()) {
case 'subpage':
case 'redirect':
$currentUrl = $this->getCurrentUrl();
if (isset($_SESSION['frontend']['redirects'][$currentUrl])) {
unset($_SESSION['frontend']['redirects']);
return;
//infinite redirect loop. Stop redirecting;
} else {
if (!isset($_GET['cms_action']) || $_GET['cms_action'] != 'manage_content') {
$_SESSION['frontend']['redirects'][$currentUrl] = 1;
//to detect infinite loop
header('HTTP/1.1 301 Moved Permanently');
header('Location: ' . $curEl->getLink());
\Db::disconnect();
exit;
}
}
break;
}
}
unset($_SESSION['frontend']['redirects']);
}
示例6: makeActions
public static function makeActions($zoneName)
{
global $site;
global $parametersMod;
global $log;
$newsletterZone = $site->getZoneByModule('community', 'newsletter');
if (!$newsletterZone) {
return;
}
if (isset($_REQUEST['action'])) {
switch ($_REQUEST['action']) {
case 'subscribe':
if (isset($_REQUEST['email']) && Db::subscribed($_REQUEST['email'], $site->currentLanguage['id'])) {
$status = 'subscribed';
$url = $site->generateUrl(null, $zoneName, array("subscribed"));
} elseif (!preg_match('#^[a-z0-9.!\\#$%&\'*+-/=?^_`{|}~]+@([0-9.]+|([^\\s]+\\.+[a-z]{2,6}))$#si', $_REQUEST['email'])) {
$status = 'incorrect_email';
$url = $site->generateUrl(null, $zoneName, array("incorrect_email"));
} else {
$site->requireTemplate('community/newsletter/template.php');
if ($_REQUEST['email'] && !Db::registeredAndNotActivated($_REQUEST['email'], $site->currentLanguage['id'])) {
Db::subscribe($_REQUEST['email'], $site->currentLanguage['id']);
}
$subscriber = Db::getSubscriberByEmail($_REQUEST['email'], $site->currentLanguage['id']);
$emailQueue = new \Modules\administrator\email_queue\Module();
$link = $site->generateUrl(null, $newsletterZone->getName(), array(), array("action" => "conf", "id" => $subscriber['id'], "code" => $subscriber['verification_code']));
$emailHtml = Template::subscribeConfirmation($link);
$emailQueue->addEmail($parametersMod->getValue('standard', 'configuration', 'main_parameters', 'email'), $parametersMod->getValue('standard', 'configuration', 'main_parameters', 'name'), $_REQUEST['email'], '', $parametersMod->getValue('community', 'newsletter', 'subscription_translations', 'subject_confirmation'), $emailHtml, true, true, null);
$emailQueue->send();
$status = 'email_confirmation';
$url = $site->generateUrl(null, $zoneName, array("email_confirmation"));
}
echo '
{
"status":"' . $status . '",
"url":"' . $url . '"
}';
$log->log('community/newsletter', 'Start subscribtion', $_REQUEST['email']);
\Db::disconnect();
exit;
break;
case 'unsubscribe':
//unsubscribe through website
if ($parametersMod->getValue('community', 'newsletter', 'options', 'show_unsubscribe_button')) {
//if unsubscribe through webpage is allowed
Db::unsubscribe($_REQUEST['email'], $site->currentLanguage['id']);
echo '
{
"status":"email_confirmation",
"url":"' . $site->generateUrl(null, $zoneName, array("unsubscribed")) . '"
}';
$log->log('community/newsletter', 'Unsubscribe (website form)', $_REQUEST['email']);
\Db::disconnect();
exit;
}
break;
case 'cancel':
//unsubscribe through e-mail link
if (isset($_REQUEST['id']) && isset($_REQUEST['code'])) {
$record = DB::getSubscriber($_REQUEST['id']);
$log->log('community/newsletter', 'Unsubscribe (e-mail link)', $record['email']);
Db::unsubscribe($_REQUEST['email'], $site->currentLanguage['id'], $_REQUEST['id'], $_REQUEST['code']);
header('location: ' . $site->generateUrl(null, $newsletterZone->getName(), array("unsubscribed"), array()));
\Db::disconnect();
exit;
}
break;
case 'conf':
if (isset($_GET['id']) && isset($_GET['code'])) {
if (Db::confirm($_GET['id'], $_GET['code'], $site->currentLanguage['id'])) {
header('location: ' . $site->generateUrl(null, $newsletterZone->getName(), array("subscribed"), array()));
$record = DB::getSubscriber($_GET['id']);
$log->log('community/newsletter', 'Confirm subscribtion', $record['email']);
} else {
header('location: ' . $site->generateUrl(null, $newsletterZone->getName(), array("error_confirmation"), array()));
$log->log('community/newsletter', 'Incorrect confirmation link', $_GET['id'] . ' ' . $_GET['code']);
}
}
break;
case 'get_link':
if (isset($_REQUEST['page'])) {
switch ($_REQUEST['page']) {
case 'error_confirmation':
echo $site->generateUrl(null, $zoneName, array("error_confirmation"));
break;
case 'email_confirmation':
echo $site->generateUrl(null, $zoneName, array("email_confirmation"));
break;
case 'subscribed':
echo $site->generateUrl(null, $zoneName, array("subscribed"));
break;
case 'incorrect_email':
echo $site->generateUrl(null, $zoneName, array("incorrect_email"));
break;
case 'unsubscribed':
echo $site->generateUrl(null, $zoneName, array("unsubscribed"));
break;
}
}
\Db::disconnect();
//.........这里部分代码省略.........
示例7: switch
switch ($_REQUEST['action']) {
case 'delete':
$db->deleteNote($activeNoteId);
$newId = $db->getMaxId();
setcookie("ACTIVE_NOTE_ID", $newId);
$activeNoteId = $newId;
break;
case 'update':
$db->updateNote($_COOKIE['ACTIVE_NOTE_ID'], $_REQUEST['content']);
break;
case 'new':
$db->createNote("New note.");
$newId = $db->getMaxId();
setcookie("ACTIVE_NOTE_ID", $newId);
$activeNoteId = $newId;
break;
case 'navigate':
setcookie("ACTIVE_NOTE_ID", $_REQUEST['id']);
$activeNoteId = $_REQUEST['id'];
break;
}
}
// create Smarty template
$template = new Smarty();
// pass the variables to the corresponding template and display it
$template->assign("ACTIVE_NOTE_ID", $activeNoteId);
$template->assign("notes", $db->getNotes());
$template->display('index.tpl');
//disconnect
$db->disconnect();
示例8: __destruct
public function __destruct()
{
Db::disconnect();
}
示例9: ajax_action
function ajax_action()
{
global $parametersMod;
global $cms;
if (isset($_POST['action'])) {
switch ($_POST['action']) {
case 'new_row_number':
$sql = "update `" . DB_PREF . $this->current_area->db_table . "` set `" . mysql_real_escape_string($this->current_area->sort_field) . "` = '" . mysql_real_escape_string($_POST['new_row_number']) . "'\n\t\t\t\twhere `" . $this->current_area->db_key . "` = '" . mysql_real_escape_string($_POST['key_id']) . "'";
$rs = mysql_query($sql);
if (!$rs) {
trigger_error($sql . " " . mysql_error());
}
\Db::disconnect();
exit;
break;
case 'row_number_increase':
$sql_current = "select `" . $this->current_area->db_key . "`, `" . mysql_real_escape_string($this->current_area->sort_field) . "` from `" . DB_PREF . $this->current_area->db_table . "` where `" . $this->current_area->db_key . "` = '" . mysql_real_escape_string($_POST['key_id']) . "'";
$rs_current = mysql_query($sql_current);
if ($rs_current) {
if ($lock_current = mysql_fetch_assoc($rs_current)) {
//current record (need to be moved up)
/*searching upper record*/
if ($this->level > 0) {
$sql_add = " and " . $this->current_area->get_db_reference() . " = '" . mysql_real_escape_string($this->up_area->get_parent_id()) . "' ";
} else {
$sql_add = '';
}
$sql_upper = "select `" . $this->current_area->db_key . "`, `" . mysql_real_escape_string($this->current_area->sort_field) . "`\n\t\t\t\t\t\tfrom `" . DB_PREF . $this->current_area->db_table . "` \n\t\t\t\t\t\twhere `" . mysql_real_escape_string($this->current_area->sort_field) . "` >= '" . mysql_real_escape_string($lock_current[$this->current_area->sort_field]) . "' \n\t\t\t\t\t\tand `" . $this->current_area->db_key . "` <> '" . mysql_real_escape_string($lock_current[$this->current_area->db_key]) . "' " . $sql_add . "\n\t\t\t\t\t\torder by `" . mysql_real_escape_string($this->current_area->sort_field) . "` asc limit 1";
$rs_upper = mysql_query($sql_upper);
if ($rs_upper) {
if ($lock_upper = mysql_fetch_assoc($rs_upper)) {
//upper record (need to be moved down)
if ($lock_upper[$this->current_area->sort_field] == $lock_current[$this->current_area->sort_field]) {
$sql_update = "update `" . DB_PREF . $this->current_area->db_table . "`\n\t\t\t\t\t\t\t\t\tset `" . mysql_real_escape_string($this->current_area->sort_field) . "` = `" . mysql_real_escape_string($this->current_area->sort_field) . "` - 1 \n\t\t\t\t\t\t\t\t\twhere `" . mysql_real_escape_string($this->current_area->sort_field) . "` <= " . mysql_real_escape_string($lock_upper[$this->current_area->sort_field]) . " and `" . $this->current_area->db_key . "` <> '" . mysql_real_escape_string($lock_current[$this->current_area->db_key]) . "' " . $sql_add . " ";
$rs_update = mysql_query($sql_update);
if (!$rs_update) {
trigger_error($sql . " " . mysql_error());
}
} else {
$sql_update = "update `" . DB_PREF . $this->current_area->db_table . "`\n\t\t\t\t\t\t\t\t\tset `" . mysql_real_escape_string($this->current_area->sort_field) . "` = " . mysql_real_escape_string($lock_current[$this->current_area->sort_field]) . "\n\t\t\t\t\t\t\t\t\twhere `" . $this->current_area->db_key . "` = '" . mysql_real_escape_string($lock_upper[$this->current_area->db_key]) . "' " . $sql_add . " limit 1";
$rs_update = mysql_query($sql_update);
if (!$rs_update) {
trigger_error($sql_update . " " . mysql_error());
}
$sql_update = "update `" . DB_PREF . $this->current_area->db_table . "`\n\t\t\t\t\t\t\t\t\tset `" . mysql_real_escape_string($this->current_area->sort_field) . "` = " . mysql_real_escape_string($lock_upper[$this->current_area->sort_field]) . " \n\t\t\t\t\t\t\t\t\twhere `" . $this->current_area->db_key . "` = '" . mysql_real_escape_string($lock_current[$this->current_area->db_key]) . "' " . $sql_add . " limit 1";
$rs_update = mysql_query($sql_update);
if (!$rs_update) {
trigger_error($sql . " " . mysql_error());
}
}
}
}
} else {
trigger_error($sql . " Element does not exist");
}
}
echo "\n window.location = window.location;\t\t\t\t\t \n ";
\Db::disconnect();
exit;
break;
case 'row_number_decrease':
$sql_current = "select `" . $this->current_area->db_key . "`, `" . mysql_real_escape_string($this->current_area->sort_field) . "`\n \t\t\t\tfrom `" . DB_PREF . $this->current_area->db_table . "` \n \t\t\t\twhere `" . $this->current_area->db_key . "` = '" . mysql_real_escape_string($_POST['key_id']) . "'";
$rs_current = mysql_query($sql_current);
if ($rs_current) {
if ($lock_current = mysql_fetch_assoc($rs_current)) {
//current record (need to be moved down)
/*searching under record*/
if ($this->level > 0) {
$sql_add = " and " . $this->current_area->get_db_reference() . " = '" . mysql_real_escape_string($this->up_area->get_parent_id()) . "' ";
} else {
$sql_add = '';
}
$sql_under = "select `" . $this->current_area->db_key . "`, `" . mysql_real_escape_string($this->current_area->sort_field) . "`\n \t\t\t\t\t\tfrom `" . DB_PREF . $this->current_area->db_table . "` \n \t\t\t\t\t\twhere `" . mysql_real_escape_string($this->current_area->sort_field) . "` <= '" . mysql_real_escape_string($lock_current[$this->current_area->sort_field]) . "' " . $sql_add . "\n \t\t\t\t\t\tand `" . $this->current_area->db_key . "` <> '" . mysql_real_escape_string($lock_current[$this->current_area->db_key]) . "'\n \t\t\t\t\t\torder by `" . mysql_real_escape_string($this->current_area->sort_field) . "` desc limit 1";
$rs_under = mysql_query($sql_under);
if ($rs_under) {
if ($lock_under = mysql_fetch_assoc($rs_under)) {
//under record (need to be moved up)
if ($lock_under[$this->current_area->sort_field] == $lock_current[$this->current_area->sort_field]) {
$sql_update = "update `" . DB_PREF . $this->current_area->db_table . "`\n \t\t\t\t\t\t\t\t\tset `" . mysql_real_escape_string($this->current_area->sort_field) . "` = `" . mysql_real_escape_string($this->current_area->sort_field) . "` + 1\n \t\t\t\t\t\t\t\t\twhere `" . mysql_real_escape_string($this->current_area->sort_field) . "` >= " . mysql_real_escape_string($lock_under[$this->current_area->sort_field]) . " and `" . $this->current_area->db_key . "` <> '" . mysql_real_escape_string($lock_current[$this->current_area->db_key]) . "' " . $sql_add . "";
$rs_update = mysql_query($sql_update);
if (!$rs_update) {
trigger_error($sql_update . " " . mysql_error());
}
} else {
$sql_update = "update `" . DB_PREF . $this->current_area->db_table . "`\n \t\t\t\t\t\t\t\t\tset `" . mysql_real_escape_string($this->current_area->sort_field) . "` = " . $lock_current[$this->current_area->sort_field] . " \n \t\t\t\t\t\t\t\t\twhere `" . $this->current_area->db_key . "` = '" . mysql_real_escape_string($lock_under[$this->current_area->db_key]) . "' " . $sql_add . " limit 1";
$rs_update = mysql_query($sql_update);
if (!$rs_update) {
trigger_error($sql_update . " " . mysql_error());
}
$sql_update = "update `" . DB_PREF . $this->current_area->db_table . "`\n \t\t\t\t\t\t\t\t\tset `" . mysql_real_escape_string($this->current_area->sort_field) . "` = " . $lock_under[$this->current_area->sort_field] . " \n \t\t\t\t\t\t\t\t\twhere `" . $this->current_area->db_key . "` = '" . mysql_real_escape_string($lock_current[$this->current_area->db_key]) . "' " . $sql_add . " limit 1";
$rs_update = mysql_query($sql_update);
if (!$rs_update) {
trigger_error($sql_update . " " . mysql_error());
}
}
}
}
} else {
trigger_error($sql . " Element does not exist");
}
//.........这里部分代码省略.........
示例10: test_setAttribute_withArgs
/**
* test_setAttribute_withArgs()
*
* setAttribute()のテスト(引数指定時)
*/
public function test_setAttribute_withArgs()
{
$params = ["driver" => $GLOBALS['DB_DRIVER'], "user" => $GLOBALS['DB_USER'], "pass" => $GLOBALS['DB_PASSWORD'], "dbname" => $GLOBALS['DB_DBNAME'], "host" => $GLOBALS['DB_HOST'], "persistent" => false];
$instance = new Db();
$instance->connect($params);
$before_val = $instance->getAttribute('FETCH_MODE');
$tmp_result = $instance->setAttribute(\PDO::ATTR_DEFAULT_FETCH_MODE, \PDO::FETCH_OBJ);
$after_val = $instance->getAttribute('FETCH_MODE');
$this->assertTrue($tmp_result);
$this->assertNotEquals($before_val, $after_val);
$this->assertNotEquals(\PDO::FETCH_OBJ, $after_val);
$instance->disconnect();
unset($instance);
}
示例11: manage
function manage()
{
global $cms;
$answer = '';
if (isset($_REQUEST['type']) == 'ajax' && $_REQUEST['action'] == 'install') {
if ($_REQUEST['action'] == 'install') {
$errors = ModulesInstallation::getErrors($_REQUEST['module_group'], $_REQUEST['module']);
if ($errors) {
$tmp_answer = '';
foreach ($errors as $key => $error) {
if ($tmp_answer != '') {
$tmp_answer .= "\\n\\n";
}
$tmp_answer .= addslashes(str_replace("\n", "", str_replace("\r", "", $error)));
}
$answer .= 'alert(\'' . $tmp_answer . '\')';
} else {
ModulesInstallation::install($_REQUEST['module_group'], $_REQUEST['module']);
$answer .= '
window.location = \'' . $cms->generateUrl() . '\';
';
}
}
echo $answer;
\Db::disconnect();
exit;
} else {
//$this->standard_module->before_content = $this->find_new_modules(); widgets installation disabled
return $this->standard_module->manage();
}
}
示例12: testDisconnectClearsPdo
public function testDisconnectClearsPdo()
{
$this->db->disconnect();
$this->assertEmpty($this->db->getPdo());
}
示例13: getSitemap
/**
* Generates sitemap XML
* @param int $nr Number of sitemap. Big sites are split into several sitemaps. Begining from 0.
* @return string Sitemap XML
*/
function getSitemap($zone, $languageId, $nr)
{
global $parametersMod;
global $site;
if (!isset($this->mappedZones[$zone]) || $site->getZone($zone) == false) {
header('HTTP/1.0 404 Not Found');
\Db::disconnect();
exit;
}
header('Content-type: application/xml; charset="' . CHARSET . '"', true);
$answer = '';
$answer .= '<' . '?xml version="1.0" encoding="' . CHARSET . '"?' . '>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
';
if ($this->mappedZones[$zone] == -1) {
//unlimited depth
$pages = $this->getPages($site->getZone($zone), $languageId);
} else {
$pages = $this->getPages($site->getZone($zone), $languageId, $this->mappedZones[$zone]);
}
//var_dump($pages);
for ($i = $nr * SITEMAP_MAX_LENGTH; $i < ($nr + 1) * SITEMAP_MAX_LENGTH; $i++) {
if (isset($pages[$i])) {
$answer .= '
<url>
<loc>' . $pages[$i]->getLink() . '</loc>
';
if ($pages[$i]->getLastModified()) {
$answer .= '<lastmod>' . substr($pages[$i]->getLastModified(), 0, 10) . '</lastmod>
';
}
if ($frequency = $pages[$i]->getModifyFrequency()) {
$tmp_freq = '';
if ($frequency < 60 * 30) {
//30 min
$tmp_freq = 'always';
} elseif ($frequency < 60 * 60) {
//1 hour
$tmp_freq = 'hourly';
} elseif ($frequency < 60 * 60 * 24) {
//1 day
$tmp_freq = 'daily';
} elseif ($frequency < 60 * 60 * 24 * 7) {
//1 week
$tmp_freq = 'weekly';
} elseif ($frequency < 60 * 60 * 24 * 30) {
//1 month
$tmp_freq = 'monthly';
} elseif ($frequency < 60 * 60 * 24 * 360 * 2) {
//2 years
$tmp_freq = 'yearly';
} else {
$tmp_freq = 'never';
}
$answer .= '<changefreq>' . $tmp_freq . '</changefreq>
';
}
if ($tmpPriority = $pages[$i]->getPriority()) {
$answer .= '<priority>' . $tmpPriority . '</priority>
';
}
$answer .= '
</url>
';
}
}
$answer .= '
</urlset>';
return $answer;
}
示例14: Cms
$site = new \Frontend\Site();
/*to generate links to site and get other data about frontend*/
$site->init();
$cms = new Cms();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>ImpressPages CMS</title>
<link rel="SHORTCUT ICON" href="favicon.ico" />
</head>
<frameset rows="64px,*" framespacing="0" border="0">
<frame name="header" noresize="noresize" frameborder=0 scrolling="no" src="<?php
echo $cms->generateActionurl('tep_modules');
?>
">
<frame id="frameContent" name="content" frameborder=0 src="<?php
echo $cms->generateActionurl('first_module');
?>
">
<noframes>
<body>Your browser don't support frames!</body>
</noframes>
</frameset>
</html>
<?php
\Db::disconnect();
} else {
trigger_error('Database access');
}
示例15: ajaxAction
function ajaxAction()
{
global $parametersMod;
global $cms;
if (isset($_POST['action'])) {
switch ($_POST['action']) {
case 'new_row_number':
if (method_exists($this->currentArea, 'beforeSort')) {
$this->currentArea->beforeSort();
}
$sql = "update `" . mysql_real_escape_string(DB_PREF . $this->currentArea->dbTable) . "` set `" . mysql_real_escape_string($this->currentArea->sortField) . "` = '" . mysql_real_escape_string($_POST['new_row_number']) . "'\n\t\t\t\twhere `" . mysql_real_escape_string($this->currentArea->dbPrimaryKey) . "` = '" . mysql_real_escape_string($_POST['key_id']) . "'";
$rs = mysql_query($sql);
if (!$rs) {
trigger_error($sql . " " . mysql_error());
}
if (method_exists($this->currentArea, 'afterSort')) {
$this->currentArea->afterSort();
}
\Db::disconnect();
exit;
break;
case 'row_number_increase':
if (method_exists($this->currentArea, 'beforeSort')) {
$this->currentArea->beforeSort();
}
$sql_current = "select `" . mysql_real_escape_string($this->currentArea->dbPrimaryKey) . "`, `" . mysql_real_escape_string($this->currentArea->sortField) . "` from `" . mysql_real_escape_string(DB_PREF . $this->currentArea->dbTable) . "` where `" . mysql_real_escape_string($this->currentArea->dbPrimaryKey) . "` = '" . mysql_real_escape_string($_POST['key_id']) . "'";
$rs_current = mysql_query($sql_current);
if ($rs_current) {
if ($lock_current = mysql_fetch_assoc($rs_current)) {
//current record (need to be moved up)
/*searching upper record*/
if ($this->level > 0) {
$sql_add = " and `" . mysql_real_escape_string($this->currentArea->dbReference) . "` = '" . mysql_real_escape_string($this->upArea->parentId) . "' ";
} else {
$sql_add = '';
}
$sql_upper = "select `" . mysql_real_escape_string($this->currentArea->dbPrimaryKey) . "`, `" . mysql_real_escape_string($this->currentArea->sortField) . "`\n from `" . mysql_real_escape_string(DB_PREF . $this->currentArea->dbTable) . "`\n where `" . mysql_real_escape_string($this->currentArea->sortField) . "` >= '" . mysql_real_escape_string($lock_current[$this->currentArea->sortField]) . "'\n and `" . mysql_real_escape_string($this->currentArea->dbPrimaryKey) . "` <> '" . mysql_real_escape_string($lock_current[$this->currentArea->dbPrimaryKey]) . "' " . $sql_add . "\n order by `" . $this->currentArea->sortField . "` asc limit 1";
$rs_upper = mysql_query($sql_upper);
if ($rs_upper) {
if ($lock_upper = mysql_fetch_assoc($rs_upper)) {
//upper record (need to be moved down)
if ($lock_upper[$this->currentArea->sortField] == $lock_current[$this->currentArea->sortField]) {
$sql_update = "update `" . mysql_real_escape_string(DB_PREF . $this->currentArea->dbTable) . "`\n set `" . mysql_real_escape_string($this->currentArea->sortField) . "` = `" . mysql_real_escape_string($this->currentArea->sortField) . "` - 1\n where `" . mysql_real_escape_string($this->currentArea->sortField) . "` <= " . mysql_real_escape_string($lock_upper[$this->currentArea->sortField]) . " and `" . mysql_real_escape_string($this->currentArea->dbPrimaryKey) . "` <> '" . mysql_real_escape_string($lock_current[$this->currentArea->dbPrimaryKey]) . "' " . $sql_add . " ";
$rs_update = mysql_query($sql_update);
if (!$rs_update) {
trigger_error($sql . " " . mysql_error());
}
} else {
$sql_update = "update `" . mysql_real_escape_string(DB_PREF . $this->currentArea->dbTable) . "`\n set `" . mysql_real_escape_string($this->currentArea->sortField) . "` = " . (int) $lock_current[$this->currentArea->sortField] . "\n where `" . mysql_real_escape_string($this->currentArea->dbPrimaryKey) . "` = '" . mysql_real_escape_string($lock_upper[$this->currentArea->dbPrimaryKey]) . "' " . $sql_add . " limit 1";
$rs_update = mysql_query($sql_update);
if (!$rs_update) {
trigger_error($sql_update . " " . mysql_error());
}
$sql_update = "update `" . mysql_real_escape_string(DB_PREF . $this->currentArea->dbTable) . "`\n\t\t\t\t\t\t\t\t\tset `" . mysql_real_escape_string($this->currentArea->sortField) . "` = " . (int) $lock_upper[$this->currentArea->sortField] . "\n\t\t\t\t\t\t\t\t\twhere `" . mysql_real_escape_string($this->currentArea->dbPrimaryKey) . "` = '" . mysql_real_escape_string($lock_current[$this->currentArea->dbPrimaryKey]) . "' " . $sql_add . " limit 1";
$rs_update = mysql_query($sql_update);
if (!$rs_update) {
trigger_error($sql . " " . mysql_error());
}
}
}
}
} else {
trigger_error($sql . " Element does not exist");
}
}
echo "\n window.location = window.location;\t\t\t\t\t \n ";
if (method_exists($this->currentArea, 'afterSort')) {
$this->currentArea->afterSort();
}
\Db::disconnect();
exit;
break;
case 'row_number_decrease':
if (method_exists($this->currentArea, 'beforeSort')) {
$this->currentArea->beforeSort();
}
$sql_current = "select `" . mysql_real_escape_string($this->currentArea->dbPrimaryKey) . "`, `" . mysql_real_escape_string($this->currentArea->sortField) . "`\n from `" . mysql_real_escape_string(DB_PREF . $this->currentArea->dbTable) . "`\n where `" . mysql_real_escape_string($this->currentArea->dbPrimaryKey) . "` = '" . mysql_real_escape_string($_POST['key_id']) . "'";
$rs_current = mysql_query($sql_current);
if ($rs_current) {
if ($lock_current = mysql_fetch_assoc($rs_current)) {
//current record (need to be moved down)
/*searching under record*/
if ($this->level > 0) {
$sql_add = " and `" . mysql_real_escape_string($this->currentArea->dbReference) . "` = '" . mysql_real_escape_string($this->upArea->parentId) . "' ";
} else {
$sql_add = '';
}
$sql_under = "select `" . mysql_real_escape_string($this->currentArea->dbPrimaryKey) . "`, `" . mysql_real_escape_string($this->currentArea->sortField) . "`\n from `" . mysql_real_escape_string(DB_PREF . $this->currentArea->dbTable) . "`\n where `" . mysql_real_escape_string($this->currentArea->sortField) . "` <= '" . mysql_real_escape_string($lock_current[$this->currentArea->sortField]) . "' " . $sql_add . "\n and `" . mysql_real_escape_string($this->currentArea->dbPrimaryKey) . "` <> '" . mysql_real_escape_string($lock_current[$this->currentArea->dbPrimaryKey]) . "'\n order by `" . mysql_real_escape_string($this->currentArea->sortField) . "` desc limit 1";
$rs_under = mysql_query($sql_under);
if ($rs_under) {
if ($lock_under = mysql_fetch_assoc($rs_under)) {
//under record (need to be moved up)
if ($lock_under[$this->currentArea->sortField] == $lock_current[$this->currentArea->sortField]) {
$sql_update = "update `" . mysql_real_escape_string(DB_PREF . $this->currentArea->dbTable) . "`\n set `" . mysql_real_escape_string($this->currentArea->sortField) . "` = `" . mysql_real_escape_string($this->currentArea->sortField) . "` + 1\n where `" . mysql_real_escape_string($this->currentArea->sortField) . "` >= " . mysql_real_escape_string($lock_under[$this->currentArea->sortField]) . "\n and `" . mysql_real_escape_string($this->currentArea->dbPrimaryKey) . "` <> '" . mysql_real_escape_string($lock_current[$this->currentArea->dbPrimaryKey]) . "' " . $sql_add . "";
$rs_update = mysql_query($sql_update);
if (!$rs_update) {
trigger_error($sql_update . " " . mysql_error());
}
} else {
$sql_update = "update `" . mysql_real_escape_string(DB_PREF . $this->currentArea->dbTable) . "`\n set `" . mysql_real_escape_string($this->currentArea->sortField) . "` = " . (int) $lock_current[$this->currentArea->sortField] . "\n where `" . mysql_real_escape_string($this->currentArea->dbPrimaryKey) . "` = '" . mysql_real_escape_string($lock_under[$this->currentArea->dbPrimaryKey]) . "' " . $sql_add . " limit 1";
//.........这里部分代码省略.........