function connect_db($db_host, $db_user, $db_pass, $db_name) { if ($connection = mysql_pconnect($db_host, $db_user, $db_pass)) { if (!mysql_select_db($db_name, $connection)) { error_alert("数据库错误", $db_name, "没有找到数据库名"); } } else { error_alert("数据库错误", $db_host, "不能连接"); } return $connection; }
/** * 连接数据库 * */ function Database() { //建立数据链接 if (!($this->ResID = mssql_connect(DB_HOST, DB_USER, DB_PASS))) { $this->error_alert('数据库错误', DB_HOST, '不能连接数据库主机'); } else { //选择数据库 if (!mssql_select_db(DB_NAME, $this->ResID)) { error_alert('数据库错误', DB_NAME, '没有找到数据库'); } } }
/** * 连接数据库 * */ function __construct() { //建立数据链接 if (!($this->ResID = mysql_connect(DB_HOST, DB_USER, DB_PASS))) { $this->error_alert('数据库错误', DB_HOST, '不能连接数据库主机'); } else { //选择数据库 if (!mysql_select_db(DB_NAME, $this->ResID)) { error_alert('数据库错误', DB_NAME, '没有找到数据库'); } } //判断MySQL的版本信息 !version_compare($this->version(), '4.1', '<') or die('MySQL数据库版本低于4.1,请升级你的MySQL数据库!'); //指定数据库编码,避免字符出错。 mysql_query('SET NAMES "' . DB_LANG . '"'); }
function resolve_user_emails($ulist) { global $lang; // return an array of emails from a list of usernames and email addresses. // with 'key_required' sibling array preserving the intent of internal/external sharing. $emails_key_required = array(); for ($n = 0; $n < count($ulist); $n++) { $uname = $ulist[$n]; $email = sql_value("select email value from user where username='******'", ''); if ($email == '') { # Not a recognised user, if @ sign present, assume e-mail address specified if (strpos($uname, "@") === false) { error_alert($lang["couldnotmatchallusernames"] . ": " . escape_check($uname)); die; } $emails_key_required['unames'][$n] = $uname; $emails_key_required['emails'][$n] = $uname; $emails_key_required['key_required'][$n] = true; } else { # Add e-mail address from user account $emails_key_required['unames'][$n] = $uname; $emails_key_required['emails'][$n] = $email; $emails_key_required['key_required'][$n] = false; } } return $emails_key_required; }
} # Fetch resource data. $resource = get_resource_data($ref); # Allow alternative configuration settings for this resource type. resource_type_config_override($resource["resource_type"]); # If upload template, check if the user has upload permission. if ($ref < 0 && !(checkperm("c") || checkperm("d"))) { $error = $lang['error-permissiondenied']; error_alert($error); exit; } # Check edit permission. if (!get_edit_access($ref, $resource["archive"], false, $resource)) { # The user is not allowed to edit this resource or the resource doesn't exist. $error = $lang['error-permissiondenied']; error_alert($error); exit; } if (getval("regen", "") != "") { sql_query("update resource set preview_attempts=0 WHERE ref='" . $ref . "'"); create_previews($ref, false, $resource["file_extension"]); } if (getval("regenexif", "") != "") { extract_exif_comment($ref); } # Establish if this is a metadata template resource, so we can switch off certain unnecessary features $is_template = isset($metadata_template_resource_type) && $resource["resource_type"] == $metadata_template_resource_type; hook("editbeforeheader"); # ----------------------------------- # PERFORM SAVE # -----------------------------------
switch ($error) { case 0: case 2: //normal break; case -1: prompt_multilogin(); exit; case 3: error_alert("本帐号已停机或正在戒网"); case 5: error_alert("登录过于频繁"); case 1: error_alert("对不起,系统忙碌,请稍候再尝试登录"); default: error_alert("登录错误,错误号:" . $error); } $data = array(); $num = bbs_getcurrentuinfo($data); if ($data["userid"] != "guest") { $wwwparameters = bbs_getwwwparameters(); setcookie("WWWPARAMS", $wwwparameters, 0, "/"); $currentuser_num = bbs_getcurrentuser($currentuser); if (!($currentuser["userlevel"] & BBS_PERM_LOGINOK)) { $mainurl = "bbsnew.php"; } $mbids = bbs_bm_get_manageable_bids(); if ($mbids) { setcookie("MANAGEBIDS", $mbids, 0, "/"); } header("Set-KBSRC: " . $data["userid"]);
<div class="BasicsBox"> <p><a onClick="return CentralSpaceLoad(this,true);" href="<?php echo $baseurl_short; ?> pages/team/team_resource.php">< <?php echo $lang["back"]; ?> </a></p> <h1><?php echo $lang['uploadviaemail']; ?> </h1> <?php if ($userinfo['email'] == "") { error_alert($lang['pleasesetupemailaddress']); } $message = str_replace("[fromaddress]", $userinfo['email'], $lang['uploadviaemail-intro']); $message = str_replace("[toaddress]", $checkmail_email, $message); $subjectfield = sql_value("select title value from resource_type_field where ref='{$checkmail_subject_field}'", ""); $bodyfield = sql_value("select title value from resource_type_field where ref='{$checkmail_body_field}'", ""); $message = str_replace("[subjectfield]", lang_or_i18n_get_translated($subjectfield, "fieldtitle-"), $message); $message = str_replace("[bodyfield]", lang_or_i18n_get_translated($bodyfield, "fieldtitle-"), $message); $access = $checkmail_default_access; $access = $lang["access{$access}"]; $archive = $checkmail_default_archive; $archive = $lang["status{$archive}"]; $message = str_replace("[access]", $access, $message); $message = str_replace("[archive]", $archive, $message); $message = str_replace("[confirmation]", $lang['checkmail_confirmation_message'], $message); ?>
$query_edit = mysql_query($sql_edit); if (!$query_edit) die ('UPDATE failed: '.mysql_error()); */ $i++; } } //CREATE-Button if (isset($_POST['create_ugroup'])) { //Check if Usergroup already exists $sql_checkexist = "SELECT ugroup_id FROM ugroup WHERE ugroup_name = '{$_POST['ugroup_name']}'"; $query_checkexist = mysql_query($sql_checkexist); if (!$query_checkexist) { die('SELECT failed: ' . mysql_error()); } if ($ausgabe = mysql_fetch_array($query_checkexist)) { error_alert('Usergroup already exists.\\nPlease choose different name for Usergroup.'); goto START_OVER; } //Create new Usergroup if (!isset($_POST['ugroup_new'])) { $_POST['ugroup_new'] = 0; } if (!isset($_POST['ugroup_report'])) { $_POST['ugroup_report'] = 0; } if (!isset($_POST['ugroup_admin'])) { $_POST['ugroup_admin'] = 0; } $ugroup_created = time(); $sql_insert = "INSERT INTO ugroup (ugroup_name, ugroup_new, ugroup_report, ugroup_admin, ugroup_created) VALUES ('{$_POST['ugroup_name']}', '{$_POST['ugroup_new']}', '{$_POST['ugroup_report']}', '{$_POST['ugroup_admin']}', '{$ugroup_created}')"; $query_insert = mysql_query($sql_insert);
} umask($old_mask); // put the filepaths together $dest = sprintf("%s/%d.%s", $dir, $lastSubmitID, $extension); $tmp = $_FILES['uploaded-file']['tmp_name']; // move the file and if successful, open the judge status page if (move_uploaded_file($tmp, $dest) && chmod($dest, 0775)) { // prepare and execute a query for the tester $query = <<<SQL INSERT INTO submits(timestamp, site, username, problem, language, status) VALUES (CURRENT_TIMESTAMP(), :site, :username, :problem, :language, :status) SQL; $stmt = $dbc->prepare($query); $stmt->execute(array(':site' => WEBSITE, ':username' => $_COOKIE['username'], ':problem' => $_POST['problem'], ':language' => "." . $extension, ':status' => "IQ")); // success, go to status page echo get_js("window.location='judge.php';"); } else { // the file upload has been unsuccessful echo error_alert(0); } } else { echo error_alert(1); } } else { echo error_alert(2); } } else { echo error_alert(3); } // go back to the submit page echo get_js("history.go(-1);");
resource_type_config_override($resource["resource_type"]); # If upload template, check if the user has upload permission. if ($ref<0 && !(checkperm("c") || checkperm("d"))) { $error=$lang['error-permissiondenied']; error_alert($error); exit(); } # Check edit permission. if (!get_edit_access($ref,$resource["archive"],false,$resource)) { # The user is not allowed to edit this resource or the resource doesn't exist. $error=$lang['error-permissiondenied']; error_alert($error,!$modal); exit(); } if (getval("regen","")!="") { sql_query("update resource set preview_attempts=0 WHERE ref='" . $ref . "'"); create_previews($ref,false,$resource["file_extension"]); } if (getval("regenexif","")!="") { extract_exif_comment($ref); } # Establish if this is a metadata template resource, so we can switch off certain unnecessary features