Replaced all mysql_close by close_connection, except for the directory /install

This commit is contained in:
Dmitriy Simushev 2011-11-09 14:16:37 +00:00
parent 6698601d19
commit 1cd6926f4f
35 changed files with 89 additions and 89 deletions

View File

@ -32,7 +32,7 @@ if($referer && isset($_SESSION['threadid'])) {
$msg = getstring2_("chat.client.visited.page", array($referer), $thread['locale']);
post_message_($thread['threadid'], $kind_for_agent,$msg,$link);
}
mysql_close($link);
close_connection($link);
}
$image = verifyparam(isset($_GET['image']) ? "image" : "i", "/^\w+$/", "webim");

View File

@ -110,7 +110,7 @@ if( !isset($_GET['token']) || !isset($_GET['thread']) ) {
$link = connect();
if(!check_connections_from_remote($remoteHost, $link)) {
mysql_close($link);
close_connection($link);
die("number of connections from your IP is exceeded, try again later");
}
$thread = create_thread($groupid,$visitor['name'], $remoteHost, $referrer,$current_locale,$visitor['id'], $userbrowser,$state_loading,$link);
@ -137,7 +137,7 @@ if( !isset($_GET['token']) || !isset($_GET['thread']) ) {
$postedid = post_message_($thread['threadid'],$kind_user,$firstmessage,$link,$visitor['name']);
commit_thread( $thread['threadid'], array('shownmessageid' => $postedid), $link);
}
mysql_close($link);
close_connection($link);
}
$threadid = $thread['threadid'];
$token = $thread['ltoken'];

View File

@ -51,7 +51,7 @@ if ($settings['enabletracking'] == '1') {
$operator = operator_by_id_($invited, $link);
}
mysql_close($link);
close_connection($link);
}
start_xml_output();

View File

@ -46,7 +46,7 @@ function store_message($name, $email, $info, $message,$groupid,$referrer) {
post_message_($thread['threadid'],$kind_for_agent,getstring2('chat.visitor.info',array($info)),$link);
}
post_message_($thread['threadid'],$kind_user,$message,$link,$name);
mysql_close($link);
close_connection($link);
}
$groupid = "";
@ -118,7 +118,7 @@ if (isset($group) && !empty($group['vcemail'])) {
if($inbox_mail) {
$link = connect();
webim_mail($inbox_mail, $email, $subject, $body, $link);
mysql_close($link);
close_connection($link);
}
setup_logo();

View File

@ -83,7 +83,7 @@ function post_message($threadid, $kind, $message, $from = null, $agentid = null)
{
$link = connect();
$id = post_message_($threadid, $kind, $message, $link, $from, null, $agentid);
mysql_close($link);
close_connection($link);
return $id;
}
@ -158,7 +158,7 @@ function get_messages($threadid, $meth, $isuser, &$lastid)
}
}
mysql_close($link);
close_connection($link);
return $messages;
}
@ -328,7 +328,7 @@ function setup_survey($name, $email, $groupid, $info, $referrer)
if ($settings['enablegroups'] == '1' && $settings["surveyaskgroup"] == "1") {
$link = connect();
$allgroups = get_groups($link, false);
mysql_close($link);
close_connection($link);
$val = "";
foreach ($allgroups as $k) {
$groupname = $k['vclocalname'];
@ -414,7 +414,7 @@ function load_canned_messages($locale, $groupid)
}
$result = $result2;
}
mysql_close($link);
close_connection($link);
return $result;
}
@ -452,7 +452,7 @@ function setup_chatview_for_operator($thread, $operator)
$visitor = track_get_visitor_by_threadid($thread['threadid'], $link);
$page['trackedParams'] = array("visitor" => "" . $visitor['visitorid']);
$page['trackedParamsLink'] = add_params($webimroot . "/operator/tracked.php", $page['trackedParams']);
mysql_close($link);
close_connection($link);
}
$predefinedres = "";
$canned_messages = load_canned_messages($thread['locale'], $thread['groupid']);
@ -494,7 +494,7 @@ function ping_thread($thread, $isuser, $istyping)
if ($thread['istate'] == $state_loading && $isuser) {
$params['istate'] = $state_queue;
commit_thread($thread['threadid'], $params, $link);
mysql_close($link);
close_connection($link);
return;
}
@ -510,13 +510,13 @@ function ping_thread($thread, $isuser, $istyping)
$params['istate'] = $state_waiting;
$params['nextagent'] = 0;
commit_thread($thread['threadid'], $params, $link);
mysql_close($link);
close_connection($link);
return;
}
}
update_thread_access($thread['threadid'], $params, $link);
mysql_close($link);
close_connection($link);
}
function commit_thread($threadid, $params, $link)
@ -542,7 +542,7 @@ function rename_user($thread, $newname)
post_message_($thread['threadid'], $kind_events,
getstring2_("chat.status.user.changedname", array($thread['userName'], $newname), $thread['locale']), $link);
}
mysql_close($link);
close_connection($link);
}
function close_thread($thread, $isuser)
@ -558,7 +558,7 @@ function close_thread($thread, $isuser)
$message = $isuser ? getstring2_("chat.status.user.left", array($thread['userName']), $thread['locale'])
: getstring2_("chat.status.operator.left", array($thread['agentName']), $thread['locale']);
post_message_($thread['threadid'], $kind_events, $message, $link);
mysql_close($link);
close_connection($link);
}
function thread_by_id_($id, $link)
@ -580,7 +580,7 @@ function thread_by_id($id)
{
$link = connect();
$thread = thread_by_id_($id, $link);
mysql_close($link);
close_connection($link);
return $thread;
}
@ -615,7 +615,7 @@ function do_take_thread($threadid, $operatorId, $operatorName)
"nextagent" => 0,
"agentId" => $operatorId,
"agentName" => "'" . mysql_real_escape_string($operatorName, $link) . "'"), $link);
mysql_close($link);
close_connection($link);
}
function reopen_thread($threadid)
@ -636,7 +636,7 @@ function reopen_thread($threadid)
}
post_message_($thread['threadid'], $kind_events, getstring_("chat.status.user.reopenedthread", $thread['locale']), $link);
mysql_close($link);
close_connection($link);
return $thread;
}

View File

@ -687,7 +687,7 @@ function loadsettings()
if (!$settingsloaded) {
$link = connect();
loadsettings_($link);
mysql_close($link);
close_connection($link);
}
}

View File

@ -84,7 +84,7 @@ function get_groups_list()
if ($settings['enablegroups'] == '1') {
$link = connect();
$allgroups = get_all_groups($link);
mysql_close($link);
close_connection($link);
$result[] = array('groupid' => '', 'vclocalname' => getlocal("page.gen_button.default_group"));
foreach ($allgroups as $g) {
$result[] = $g;

View File

@ -25,7 +25,7 @@ function group_by_id($id)
$link = connect();
$group = select_one_row(
"select * from ${mysqlprefix}chatgroup where groupid = $id", $link);
mysql_close($link);
close_connection($link);
return $group;
}

View File

@ -39,7 +39,7 @@ function operator_by_login($login)
$link = connect();
$operator = select_one_row(
"select * from ${mysqlprefix}chatoperator where vclogin = '" . mysql_real_escape_string($login) . "'", $link);
mysql_close($link);
close_connection($link);
return $operator;
}
@ -49,7 +49,7 @@ function operator_by_email($mail)
$link = connect();
$operator = select_one_row(
"select * from ${mysqlprefix}chatoperator where vcemail = '" . mysql_real_escape_string($mail) . "'", $link);
mysql_close($link);
close_connection($link);
return $operator;
}
@ -64,7 +64,7 @@ function operator_by_id($id)
{
$link = connect();
$operator = operator_by_id_($id, $link);
mysql_close($link);
close_connection($link);
return $operator;
}
@ -76,7 +76,7 @@ function operator_get_all()
$query = "select operatorid, vclogin, vclocalename, vccommonname, istatus, (unix_timestamp(CURRENT_TIMESTAMP)-unix_timestamp(dtmlastvisited)) as time " .
"from ${mysqlprefix}chatoperator order by vclogin";
$operators = select_multi_assoc($query, $link);
mysql_close($link);
close_connection($link);
return $operators;
}
@ -115,7 +115,7 @@ function update_operator($operatorid, $login, $email, $password, $localename, $c
$operatorid);
perform_query($query, $link);
mysql_close($link);
close_connection($link);
// update the session password
if (isset($password))
{
@ -133,7 +133,7 @@ function update_operator_avatar($operatorid, $avatar)
mysql_real_escape_string($avatar), $operatorid);
perform_query($query, $link);
mysql_close($link);
close_connection($link);
}
function create_operator_($login, $email, $password, $localename, $commonname, $avatar, $link)
@ -158,7 +158,7 @@ function create_operator($login, $email, $password, $localename, $commonname, $a
{
$link = connect();
$newop = create_operator_($login, $email, $password, $localename, $commonname, $avatar, $link);
mysql_close($link);
close_connection($link);
return $newop;
}
@ -167,7 +167,7 @@ function notify_operator_alive($operatorid, $istatus)
global $mysqlprefix;
$link = connect();
perform_query("update ${mysqlprefix}chatoperator set istatus = $istatus, dtmlastvisited = CURRENT_TIMESTAMP where operatorid = $operatorid", $link);
mysql_close($link);
close_connection($link);
}
function has_online_operators($groupid = "")
@ -183,7 +183,7 @@ function has_online_operators($groupid = "")
$query .= " where istatus = 0";
}
$row = select_one_row($query, $link);
mysql_close($link);
close_connection($link);
return $row['time'] < $settings['online_timeout'] && $row['total'] > 0;
}
@ -310,7 +310,7 @@ function setup_redirect_links($threadid, $token)
"${mysqlprefix}chatoperator", array(), "order by vclogin $limit"), $link);
$groups = array_slice($groups, $p['start'], $p['end'] - $p['start']);
mysql_close($link);
close_connection($link);
$agent_list = "";
$params = array('thread' => $threadid, 'token' => $token);
@ -418,7 +418,7 @@ function get_operator_groupids($operatorid)
$link = connect();
$query = "select groupid from ${mysqlprefix}chatgroupoperator where operatorid = $operatorid";
$result = select_multi_assoc($query, $link);
mysql_close($link);
close_connection($link);
return $result;
}

View File

@ -31,7 +31,7 @@ function update_settings()
perform_query($query, $link);
}
mysql_close($link);
close_connection($link);
}
function setup_settings_tabs($active)

View File

@ -66,7 +66,7 @@ $body = getstring2("mail.user.history.body", array($thread['userName'],$history)
$link = connect();
webim_mail($email, $webim_mailbox, $subject, $body, $link);
mysql_close($link);
close_connection($link);
setup_logo();
expand("styles", getchatstyle(), "mailsent.tpl");

View File

@ -52,7 +52,7 @@ if (isset($_POST['address'])) {
$link = connect();
$existing_ban = ban_for_addr_($address, $link);
mysql_close($link);
close_connection($link);
if ((!$banId && $existing_ban) ||
($banId && $existing_ban && $banId != $existing_ban['banid'])) {
@ -77,7 +77,7 @@ if (isset($_POST['address'])) {
mysql_real_escape_string($comment, $link));
perform_query($query, $link);
}
mysql_close($link);
close_connection($link);
if (!$threadid) {
header("Location: $webimroot/operator/blocked.php");
@ -97,7 +97,7 @@ if (isset($_POST['address'])) {
$banId = verifyparam('id', "/^\d{1,9}$/");
$link = connect();
$ban = select_one_row("select banid,(unix_timestamp(dtmtill)-unix_timestamp(CURRENT_TIMESTAMP)) as days,address,comment from ${mysqlprefix}chatban where banid = $banId", $link);
mysql_close($link);
close_connection($link);
if ($ban) {
$page['banId'] = topage($ban['banid']);

View File

@ -55,7 +55,7 @@ while ($ban = mysql_fetch_array($result, MYSQL_ASSOC)) {
}
mysql_free_result($result);
mysql_close($link);
close_connection($link);
setup_pagination($blockedList);

View File

@ -61,7 +61,7 @@ function load_canned_messages($locale, $groupid)
$result = select_multi_assoc($query, $link);
}
}
mysql_close($link);
close_connection($link);
return $result;
}
@ -94,7 +94,7 @@ if ($settings['enablegroups'] == '1') {
$link = connect();
$allgroups = get_all_groups($link);
mysql_close($link);
close_connection($link);
$page['groups'] = array();
$page['groups'][] = array('groupid' => '', 'vclocalname' => getlocal("page.gen_button.default_group"));
foreach ($allgroups as $g) {
@ -114,7 +114,7 @@ if (isset($_GET['act']) && $_GET['act'] == 'delete') {
if (count($errors) == 0) {
$link = connect();
perform_query("delete from ${mysqlprefix}chatresponses where id = $key", $link);
mysql_close($link);
close_connection($link);
header("Location: $webimroot/operator/canned.php?lang=$lang&group=$groupid");
exit;
}

View File

@ -28,7 +28,7 @@ function load_message($key)
global $mysqlprefix;
$link = connect();
$result = select_one_row("select vcvalue from ${mysqlprefix}chatresponses where id = $key", $link);
mysql_close($link);
close_connection($link);
return $result ? $result['vcvalue'] : null;
}
@ -38,7 +38,7 @@ function save_message($key, $message)
$link = connect();
perform_query("update ${mysqlprefix}chatresponses set vcvalue = '" . mysql_real_escape_string($message, $link) . "' " .
"where id = $key", $link);
mysql_close($link);
close_connection($link);
}
function add_message($locale, $groupid, $message)
@ -48,7 +48,7 @@ function add_message($locale, $groupid, $message)
perform_query("insert into ${mysqlprefix}chatresponses (locale,groupid,vcvalue) values ('$locale'," .
($groupid ? "$groupid, " : "null, ") .
"'" . mysql_real_escape_string($message, $link) . "')", $link);
mysql_close($link);
close_connection($link);
}
$operator = check_login();

View File

@ -35,7 +35,7 @@ function group_by_name($name)
$link = connect();
$group = select_one_row(
"select * from ${mysqlprefix}chatgroup where vclocalname = '" . mysql_real_escape_string($name) . "'", $link);
mysql_close($link);
close_connection($link);
return $group;
}
@ -55,7 +55,7 @@ function create_group($name, $descr, $commonname, $commondescr, $email)
$id = mysql_insert_id($link);
$newdep = select_one_row("select * from ${mysqlprefix}chatgroup where groupid = $id", $link);
mysql_close($link);
close_connection($link);
return $newdep;
}
@ -73,7 +73,7 @@ function update_group($groupid, $name, $descr, $commonname, $commondescr, $email
$groupid);
perform_query($query, $link);
mysql_close($link);
close_connection($link);
}

View File

@ -31,7 +31,7 @@ function get_group_members($groupid)
$link = connect();
$query = "select operatorid from ${mysqlprefix}chatgroupoperator where groupid = $groupid";
$result = select_multi_assoc($query, $link);
mysql_close($link);
close_connection($link);
return $result;
}
@ -43,7 +43,7 @@ function update_group_members($groupid, $newvalue)
foreach ($newvalue as $opid) {
perform_query("insert into ${mysqlprefix}chatgroupoperator (groupid, operatorid) values ($groupid,$opid)", $link);
}
mysql_close($link);
close_connection($link);
}
function get_operators()
@ -53,7 +53,7 @@ function get_operators()
$query = "select * from ${mysqlprefix}chatoperator order by vclogin";
$result = select_multi_assoc($query, $link);
mysql_close($link);
close_connection($link);
return $result;
}

View File

@ -41,7 +41,7 @@ if (isset($_GET['act']) && $_GET['act'] == 'del') {
perform_query("delete from ${mysqlprefix}chatgroup where groupid = $groupid", $link);
perform_query("delete from ${mysqlprefix}chatgroupoperator where groupid = $groupid", $link);
perform_query("update ${mysqlprefix}chatthread set groupid = 0 where groupid = $groupid", $link);
mysql_close($link);
close_connection($link);
header("Location: $webimroot/operator/groups.php");
exit;
}
@ -63,7 +63,7 @@ function is_away($group)
$page = array();
$link = connect();
$page['groups'] = get_groups($link, true);
mysql_close($link);
close_connection($link);
$page['canmodify'] = is_capable($can_administrate, $operator);
prepare_menu($operator);

View File

@ -60,7 +60,7 @@ if ($query !== false) {
"order by created DESC",
"DISTINCT ${mysqlprefix}chatthread.dtmcreated", $link);
mysql_close($link);
close_connection($link);
$page['formq'] = topage($query);
} else {

View File

@ -28,7 +28,7 @@ force_password($operator);
$link = connect();
loadsettings_($link);
$isonline = is_operator_online($operator['operatorid'], $link);
mysql_close($link);
close_connection($link);
$page = array(
'version' => $version,

View File

@ -33,7 +33,7 @@ $errors = array();
$link = connect();
$invitation = invitation_state($visitorid, $link);
mysql_close($link);
close_connection($link);
start_xml_output();
echo '<invitation>';

View File

@ -33,7 +33,7 @@ $link = connect();
if (!invitation_invite($visitorid, $operator['operatorid'], $link)) {
die("Invitation failed!");
}
mysql_close($link);
close_connection($link);
$page = array();
$page['visitor'] = $visitorid;

View File

@ -54,7 +54,7 @@ if (isset($_GET['act']) && $_GET['act'] == 'del') {
$link = connect();
perform_query("delete from ${mysqlprefix}chatgroupoperator where operatorid = $operatorid", $link);
perform_query("delete from ${mysqlprefix}chatoperator where operatorid = $operatorid", $link);
mysql_close($link);
close_connection($link);
header("Location: $webimroot/operator/operators.php");
exit;

View File

@ -33,7 +33,7 @@ function update_operator_groups($operatorid, $newvalue)
foreach ($newvalue as $groupid) {
perform_query("insert into ${mysqlprefix}chatgroupoperator (groupid, operatorid) values ($groupid,$operatorid)", $link);
}
mysql_close($link);
close_connection($link);
}
@ -41,7 +41,7 @@ $opId = verifyparam("op", "/^\d{1,9}$/");
$page = array('opid' => $opId);
$link = connect();
$page['groups'] = get_all_groups($link);
mysql_close($link);
close_connection($link);
$errors = array();
$canmodify = ($opId == $operator['operatorid'] && is_capable($can_modifyprofile, $operator))

View File

@ -32,7 +32,7 @@ function update_operator_permissions($operatorid, $newvalue)
$query = "update ${mysqlprefix}chatoperator set iperm = $newvalue where operatorid = $operatorid";
perform_query($query, $link);
mysql_close($link);
close_connection($link);
}
$opId = verifyparam("op", "/^\d{1,9}$/");

View File

@ -51,7 +51,7 @@ if (isset($_GET['nextGroup'])) {
post_message_($thread['threadid'], $kind_events,
getstring2_("chat.status.operator.redirect",
array(get_operator_name($operator)), $thread['locale']), $link);
mysql_close($link);
close_connection($link);
} else {
$errors[] = getlocal("chat.redirect.cannot");
}
@ -77,7 +77,7 @@ if (isset($_GET['nextGroup'])) {
post_message_($thread['threadid'], $kind_events,
getstring2_("chat.status.operator.redirect",
array(get_operator_name($operator)), $thread['locale']), $link);
mysql_close($link);
close_connection($link);
} else {
$errors[] = getlocal("chat.redirect.cannot");
}

View File

@ -55,7 +55,7 @@ if (count($errors) == 0 && isset($_POST['password'])) {
$link = connect();
$query = "update ${mysqlprefix}chatoperator set vcpassword = '" . md5($password) . "', vcrestoretoken = '' where operatorid = " . $opId;
perform_query($query, $link);
mysql_close($link);
close_connection($link);
start_html_output();
require('../view/resetpwd.php');

View File

@ -50,7 +50,7 @@ if (isset($_POST['loginoremail'])) {
$href = get_app_location(true, false) . "/operator/resetpwd.php?id=" . $torestore['operatorid'] . "&token=$token";
webim_mail($email, $email, getstring("restore.mailsubj"), getstring2("restore.mailtext", array(get_operator_name($torestore), $href)), $link);
mysql_close($link);
close_connection($link);
$page['isdone'] = true;
require('../view/restore.php');

View File

@ -82,7 +82,7 @@ $page['reportByAgent'] = select_multi_assoc("select vclocalename as name, COUNT(
$page['showresults'] = count($errors) == 0;
mysql_close($link);
close_connection($link);
prepare_menu($operator);
start_html_output();

View File

@ -40,7 +40,7 @@ function thread_info($id)
"vclocalname as groupName " .
"from ${mysqlprefix}chatthread left join ${mysqlprefix}chatgroup on ${mysqlprefix}chatthread.groupid = ${mysqlprefix}chatgroup.groupid " .
"where threadid = " . $id, $link);
mysql_close($link);
close_connection($link);
return $thread;
}

View File

@ -53,7 +53,7 @@ else {
die("Wrong visitor!");
}
}
mysql_close($link);
close_connection($link);
$path = track_retrieve_path($visitor);

View File

@ -142,7 +142,7 @@ function print_pending_threads($groupids, $since)
$revision = $row['lrevision'];
}
mysql_close($link);
close_connection($link);
echo "<threads revision=\"$revision\" time=\"" . time() . "000\">";
foreach ($output as $thr) {
@ -246,7 +246,7 @@ function print_visitors()
$output[] = $visitor;
}
mysql_close($link);
close_connection($link);
echo "<visitors>";
foreach ($output as $thr) {
@ -265,7 +265,7 @@ loadsettings_($link);
if (!isset($_SESSION["${mysqlprefix}operatorgroups"])) {
$_SESSION["${mysqlprefix}operatorgroups"] = get_operator_groupslist($operator['operatorid'], $link);
}
mysql_close($link);
close_connection($link);
$groupids = $_SESSION["${mysqlprefix}operatorgroups"];
start_xml_output();

View File

@ -58,7 +58,7 @@ function threads_by_userid($userid)
}
mysql_free_result($result);
mysql_close($link);
close_connection($link);
return $foundThreads;
}

View File

@ -33,7 +33,7 @@ notify_operator_alive($operator['operatorid'], $status);
$link = connect();
loadsettings_($link);
$_SESSION["${mysqlprefix}operatorgroups"] = get_operator_groupslist($operator['operatorid'], $link);
mysql_close($link);
close_connection($link);
$page = array();
$page['havemenu'] = isset($_GET['nomenu']) ? "0" : "1";

View File

@ -82,7 +82,7 @@ if( $act == "refresh" ) {
if($isuser && $thread["shownmessageid"] == 0) {
commit_thread( $thread['threadid'], array('shownmessageid' => $postedid), $link);
}
mysql_close($link);
close_connection($link);
print_thread_messages($thread, $token, $lastid, $isuser, $outformat, $isuser ? null : $operator['operatorid']);
exit;