function tSpew() { $conn = dbConn(); $sql = "SELECT * FROM user"; echo $sql . "<br><br>"; //if (!$link = mysql_connect('mysql_host', 'mysql_user', 'mysql_password')) { if (!($link = $conn)) { echo 'Could not connect to mysql'; exit; } if (!mysql_select_db('androidsoundappproject:soundwave', $link)) { echo 'Could not select database'; exit; } //$sql = 'SELECT foo FROM bar WHERE id = 42'; $result = mysql_query($sql, $link); if (!$result) { echo "DB Error, could not query the database\n"; echo 'MySQL Error: ' . mysql_error(); exit; } while ($row = mysql_fetch_assoc($result)) { echo $row['foo']; } mysql_free_result($result); }
<?php // 라이브러리 함수 파일 인크루드 include "lib.php"; if (!eregi("member_modify.php", $HTTP_REFERER)) { Error("제대로 된 접근을 하여 주시기 바랍니다"); } // DB 연결 if (!$connect) { $connect = dbConn(); } // 회원 정보를 얻어옴 $member = member_info(); $group_no = $member[group_no]; // 멤버 정보 삭제 @mysql_query("delete from {$member_table} where no='{$member['no']}'") or error(mysql_error()); // 쪽지 테이블에서 멤버 정보 삭제 @mysql_query("delete from {$get_memo_table} where member_no='{$member['no']}'") or error(mysql_error()); @mysql_query("delete from {$send_memo_table} where member_no='{$member['no']}'") or error(mysql_error()); // 각종 게시판에서 현재 탈퇴한 멤버의 모든 정보를 삭제 (부하 문제로 인해서 주석 처리) /* $result=mysql_query("select name from $admin_table"); while($data=mysql_fetch_array($result)) { // 게시판 테이블에서 삭제 @mysql_query("update $t_board"."_$data[name] set ismember='0', password=password('".time()."') where ismember='$member[no]'") or error(mysql_error()); // 코멘트 테이블에서 삭제 @mysql_query("update $t_comment"."_$data[name] set ismember='0', password=password('".time()."') where ismember='$member[no]'") or error(mysql_error()); } */ // 그룹테이블에서 회원수 -1 @mysql_query("update {$group_table} set member_num=member_num-1 where no = '{$group_no}'") or error(mysql_error());
<? $_zb_url = "/bbs/"; $_zb_path = "/home/hosting_users/academysoft/www/bbs/"; include $_zb_path."outlogin.php"; // DB 연결 if(!$connect) $connect=dbConn(); // 멤버 정보 구해오기 $member=member_info(); if(!$member[no]) Error("로그인 하신 후 다시 하십시오","window.close"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=euc-kr" /> <title>강의 시리얼 등록</title> <link href="css/global.css" rel="stylesheet" type="text/css" /> </head> <script> function check_submit() { if(!write.p_class_id.value) {alert("수강반ID를 입력하여 주십시요.");write.user_id.focus(); return false;} return true; } </script> <body leftmargin="0" topmargin="0"> <form name=write method=post action=serial_reg_01_ok.php enctype=multipart/form-data onsubmit="return check_submit();">
function message_distro_delete($user_id_target, $msg_id) { /* * Delete message from table MESSAGE_DISTRO * * URL: /server?action=message_distro_delete&user_id=<user_id_target>&msg_id=<msg_id> */ $dbh = dbConn(); $sql = 'DELETE FROM MESSAGE_DISTRO WHERE USER_ID_TARGET = ' . $user_id_target . ' AND MSG_ID = ' . $msg_id; //echo "sql: " . $sql; $qry = $dbh->prepare($sql); $qry->execute(); dbClose($dbh); // build response array $response = array('USER_ID_TARGET' => $user_id_target, 'MSG_ID = ' . $msg_id); return $response; //return(sendResponse($response)); }
ensureLogin(true); ?> <span id="top"></span> <div> <h1>Λίστα Ασθενών</h1> </div> <?php include 'menu.php'; ?> <div class="mainContent"> <?php if ($_SESSION['LoggedRole'] == "client") { echo "Αυτή η σελίδα είναι διαθέσιμη μόνο για γιατρούς."; die; } $conn = dbConn(); $sql = "SET CHARSET 'utf8'"; $result = $conn->query($sql); $sql = "SELECT clientID FROM clients WHERE doctorID=" . $_SESSION['userID']; $result = $conn->query($sql); echo '<span class="info">'; if ($result->num_rows > 0) { while ($row = $result->fetch_assoc()) { $sqlDoc = "SELECT * FROM users WHERE id=" . $row["clientID"]; $resultDoc = $conn->query($sqlDoc); if ($resultDoc->num_rows > 0) { $rowDoc = $resultDoc->fetch_assoc(); $name = $rowDoc["name"]; $surname = $rowDoc["surname"]; echo "<div>{$name} {$surname} [<a href='clientinfo.php?client=" . $row["clientID"] . "&exercise=1'>Ασκήσεις</a>] [<a href='clientinfo.php?client=" . $row["clientID"] . "&nutrition=1'>Διατροφή</a>]</div>"; } else {
function tableSpew() { $dbh = dbConn(); $sql = "SELECT * FROM USER"; echo $sql . "<br><br>"; //if (!$link = mysql_connect('mysql_host', 'mysql_user', 'mysql_password')) { if (!($link = $dbh)) { echo 'Could not connect to mysql'; exit; } try { // Show existing guestbook entries. //echo "<div>"; //foreach($conn->query($sql) as $row) { //echo $row['USER_ID'] . " | " . $row['FRST_NME'] . " | " . $row['LAST_NME'] . " | " . $row['EMAIL_ADDR'] . "<br>"; //$array = $sql->fetchAll(PDO::FETCH_ASSOC); //var_dum($array); //return($array); $sth = $dbh->prepare($sql); $sth->execute(); /* Fetch all of the remaining rows in the result set */ //print("Fetch all of the remaining rows in the result set: <br><br>"); //$results = $sth->fetchAll(); $results = $sth->fetchAll(PDO::FETCH_ASSOC); //print_r($result); $rowcount = $sth->rowCount(); $colcount = $sth->columnCount(); echo "rowcount: " . $rowcount . "<br>"; echo "colcount: " . $colcount . "<br><br>"; foreach ($results as $row) { print_r($row); } /*if ($results) { echo "<table>\n"; echo " <tr>\n"; echo " <th>Record #</th>\n"; //foreach(sqlsrv_field_metadata($rs) as $fieldMetadata) { //foreach(PDOStatement::getColumnMeta($rs) as $fieldMetadata) { // echo " <th>" . $fieldMetadata["Name"] . "</th>\n"; /*for ($i = 0; $i < $sth->columnCount(); $i++) { $col = $sth->getColumnMeta($i); $columns[] = $col['name']; echo " <th>" . $col['name'] . "</th>\n"; } echo " </tr>\n"; //do { while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { //$results = PDO::FETCH_ASSOC($rs, PDO::FETCH_NUM); //if ($results) { if ($row) { echo " <tr>\n"; echo " <td class=\"cell\">" . ++$i . "</td>\n"; foreach ($row as $v) { if (gettype($v) == "object") { echo " <td>" . $v->format("m/d/Y H:i:s") . "</td>\n"; } elseif (is_null($v)) { echo " <td class=\"cellNull\"><div class=\"cellNull\">NULL</div></td>\n"; } elseif ($v == "") { echo " <td class=\"cellEmpty\"><div class=\"cellEmpty\"> </div></td>\n"; } else { echo " <td class=\"cell\">" . $v . "</td>\n"; } } echo " </tr>\n"; } } //while ($results); echo "</table>\n"; //sqlsrv_free_stmt($rs);*/ //} //} //echo "</div>"; } catch (PDOException $ex) { echo "An error occurred."; } dbClose($dbh); }
function FileUpload($resourceType, $currentFolder, $sCommand) { dbConn(); $email = getEmailFCK(); $thumb_widthpx = 160; if (!isset($_FILES)) { global $_FILES; } $sErrorNumber = '0'; $sFileName = ''; if (isset($_FILES['NewFile']) && !is_null($_FILES['NewFile']['tmp_name']) && $email != "") { global $Config; $oFile = $_FILES['NewFile']; // Map the virtual path to the local server path. //$sServerDir = ServerMapFolder( $resourceType, $currentFolder, $sCommand ) ; $s = GetRootPath() . $Config['UserTempPath'] . $currentFolder . "/"; $s = str_replace("\\", "/", $s); $sServerDir = $s; $f = fopen("log2.txt", "a"); fwrite($f, "\r\n s = {$s} \r\n"); // Get the uploaded file name. $sFileName = $oFile['name']; $sFileName = SanitizeFileName($sFileName); $sOriginalFileName = $sFileName; // Get the extension. $sExtension = substr($sFileName, strrpos($sFileName, '.') + 1); $sExtension = strtolower($sExtension); if (isset($Config['SecureImageUploads'])) { if (($isImageValid = IsImageValid($oFile['tmp_name'], $sExtension)) === false) { $sErrorNumber = '202'; } } if (isset($Config['HtmlExtensions'])) { if (!IsHtmlExtension($sExtension, $Config['HtmlExtensions']) && ($detectHtml = DetectHtml($oFile['tmp_name'])) === true) { $sErrorNumber = '202'; } } // Check if it is an allowed extension. if (!$sErrorNumber && IsAllowedExt($sExtension, $resourceType)) { $iCounter = 0; while (true) { $sFilePath = $sServerDir . "/" . $sFileName; //fwrite($f, "\r\n sFilePath = $sFilePath \r\n"); //fwrite($f, "\nsServerDir = $sServerDir\n"); if (is_file($sFilePath)) { $iCounter++; $sFileName = RemoveExtension($sOriginalFileName) . '(' . $iCounter . ').' . $sExtension; $sErrorNumber = '201'; } else { move_uploaded_file($oFile['tmp_name'], $sFilePath); if (is_file($sFilePath)) { $ftype = $_FILES['NewFile']['type']; $file_size = $_FILES['NewFile']['size']; $originalpic = file_get_contents($sFilePath); list($width, $height) = getimagesize($sFilePath); if ($width > $thumb_widthpx) { $count = 1; $p = str_replace($sFileName, "", $sFilePath, $count); //fwrite($f, "\r\nfpath: $sFilePath\r\n"); $thumbpic = getThumbImage($p, $thumb_widthpx, $sFileName); } else { $thumbpic = $originalpic; unlink($sFilePath); } $album_id = getAlbumId($email); $table = 'user_imgs'; $fields = array('id', 'user_email', 'large_image', 'thumb_image', 'file_type', 'stat', 'file_name', 'file_size', 'album_id', 'admin_perm', 'view_count', 'rating'); $values = array(null, $email, $originalpic, $thumbpic, $ftype, 1, $sFileName, $file_size, $album_id, 1, 0, 0); $rs = insertData($table, $fields, $values); if (is_string($rs) || $rs == false) { //$sErrorNumber = '202' ; //file_put_contents("$sFileName", $thumbpic); } else { //fwrite($f, "is inserted = true"); } if (isset($Config['ChmodOnUpload']) && !$Config['ChmodOnUpload']) { break; } $permissions = 0777; if (isset($Config['ChmodOnUpload']) && $Config['ChmodOnUpload']) { $permissions = $Config['ChmodOnUpload']; } $oldumask = umask(0); chmod($sFilePath, $permissions); umask($oldumask); } break; } } if (file_exists($sFilePath)) { //previous checks failed, try once again if (isset($isImageValid) && $isImageValid === -1 && IsImageValid($sFilePath, $sExtension) === false) { @unlink($sFilePath); $sErrorNumber = '202'; } else { if (isset($detectHtml) && $detectHtml === -1 && DetectHtml($sFilePath) === true) { @unlink($sFilePath); $sErrorNumber = '202'; } } } } else { $sErrorNumber = '202'; } } else { $sErrorNumber = '202'; } $sFileUrl = CombinePaths(GetResourceTypePath($resourceType, $sCommand), $currentFolder); $sFileUrl = CombinePaths($sFileUrl, $sFileName); SendUploadResults($sErrorNumber, $sFileUrl, $sFileName); exit; }
function create_user() { $dbh = dbConn(); // test variables //$frst_nme = "frst004"; //$last_nme = "last004"; //$email_addr = "*****@*****.**"; //$user_pw = "password004"; $disp_nme = $_POST['disp_nme']; $email_addr = $_POST['email_addr']; $user_pw = $_POST['user_pw']; $user_type = "basic"; // date creation $date = date_create(); $tz = $date->getTimezone(); $timestamp = date_format($date, 'Y-m-d H:i:s'); $timezone = $tz->getName(); // load date variables $date_effective = $timestamp; $date_modified = $timestamp; $date_expired = '9999-12-31T23:59:59'; // sql statement //$sql = "INSERT INTO USER (FRST_NME, LAST_NME, EMAIL_ADDR, USER_PW, USER_TYPE, DATE_EFFECTIVE, DATE_MODIFIED, DATE_EXPIRED) // VALUES (:FRST_NME, :LAST_NME, :EMAIL_ADDR, :USER_PW, :USER_TYPE, :DATE_EFFECTIVE, :DATE_MODIFIED, :DATE_EXPIRED)"; $sql = "INSERT INTO USER (FRST_NME, EMAIL_ADDR, USER_PW, USER_TYPE, DATE_EFFECTIVE, DATE_MODIFIED, DATE_EXPIRED) \n VALUES (:FRST_NME, :EMAIL_ADDR, :USER_PW, :USER_TYPE, :DATE_EFFECTIVE, :DATE_MODIFIED, :DATE_EXPIRED)"; $q = $dbh->prepare($sql); $new_user = array(':FRST_NME' => $disp_nme, ':EMAIL_ADDR' => $email_addr, ':USER_PW' => $user_pw, ':USER_TYPE' => $user_type, ':DATE_EFFECTIVE' => $date_effective, ':DATE_MODIFIED' => $date_modified, ':DATE_EXPIRED' => $date_expired); $q->execute($new_user); dbClose($dbh); //$foo = $new_user; //$foo = array("chad","*****@*****.**"); return $new_user; }
function func_reg_ing($bookid, $examid, $userid, $examlgubun, $examsgubun, $elapsedtime) { // 권한 검사 $connect=dbConn(); $member=member_info(); call_pear_init(); require_once("DB.php"); // DB 접속 $db =& DB::connect(call_pear_db_dsn()); if (PEAR::isError($db)) { die($db->getMessage()); } //****************************** // CLASS_ID 찾기 $sql = "SELECT TB_REG1.CLASS_ID " ." FROM TB_CLASS, TB_REG1 " ." WHERE TB_REG1.USER_ID = '$userid' " ." AND BOOK_ID = '$bookid' " ." AND TB_REG1.CLASS_ID = TB_CLASS.CLASS_ID"; $res = $db->query($sql); if (PEAR::isError($db)) { die($db->getMessage()); } while ($res->fetchInto($row)) { $class_id = $row[0]; } //****************************** // TB_EXAM.SEQ 찾기 $sql = "SELECT SEQ " ." FROM TB_EXAM " ." WHERE BOOK_ID = '$bookid' " ." AND EXAM_ID = '$examid' "; $res = $db->query($sql); if (PEAR::isError($db)) { die($db->getMessage()); } while ($res->fetchInto($row)) { $exam_seq = $row[0]; } //****************************** // TB_EXAM_SCH.SEQ 찾기 $sql = "SELECT SEQ " ." FROM TB_EXAM_SCH " ." WHERE CLASS_ID = '$class_id' " ." AND EXAM_SEQ = '$exam_seq' "; $res = $db->query($sql); if (PEAR::isError($db)) { die($db->getMessage()); } while ($res->fetchInto($row)) { $exam_sch_seq = $row[0]; } // select 문제번호를 불러온다. $sql = "SELECT SEQ " ." FROM TB_EXAM_REC " ." WHERE USER_ID = '$userid' " ." AND EXAM_SCH_SEQ = '$exam_sch_seq' "; echo $sql; $res = $db->query($sql); if (PEAR::isError($db)) { die($db->getMessage()); } while ($res->fetchInto($row)) { $r_seq = $row[0]; } // TB_EXAM_REC RECORD UPDATE $sth = $db->prepare("UPDATE TB_EXAM_REC SET ELAPSED_TIME = ? WHERE SEQ = ?"); $data = array($elapsedtime, $r_seq); $db->execute($sth, $data ); echo "update complete : "; echo $elapsedtime; } // end function func_reg_ing
function func_state_request($bookid, $examid, $userid, $examlgubun, $examsgubun) { echo $elapsedtime; // 권한 검사 $connect=dbConn(); $member=member_info(); call_pear_init(); require_once("DB.php"); // DB 접속 $db =& DB::connect(call_pear_db_dsn()); if (PEAR::isError($db)) { die($db->getMessage()); } //****************************** // CLASS_ID 찾기 $sql = "SELECT TB_REG1.CLASS_ID " ." FROM TB_CLASS, TB_REG1 " ." WHERE TB_REG1.USER_ID = '$userid' " ." AND BOOK_ID = '$bookid' " ." AND TB_REG1.CLASS_ID = TB_CLASS.CLASS_ID"; $res = $db->query($sql); if (PEAR::isError($db)) { die($db->getMessage()); } while ($res->fetchInto($row)) { $class_id = $row[0]; } //****************************** // TB_EXAM.SEQ 찾기 $sql = "SELECT SEQ " ." FROM TB_EXAM " ." WHERE BOOK_ID = '$bookid' " ." AND EXAM_ID = '$examid' "; $res = $db->query($sql); if (PEAR::isError($db)) { die($db->getMessage()); } while ($res->fetchInto($row)) { $exam_seq = $row[0]; } //****************************** // TB_EXAM_SCH.SEQ 찾기 $sql = "SELECT SEQ " ." FROM TB_EXAM_SCH " ." WHERE CLASS_ID = '$class_id' " ." AND EXAM_SEQ = '$exam_seq' "; $res = $db->query($sql); if (PEAR::isError($db)) { die($db->getMessage()); } while ($res->fetchInto($row)) { $exam_sch_seq = $row[0]; } $sql = "SELECT r.EXAM_START, r.EXAM_END, r.CUR_QST_SEQ, r.ELAPSED_TIME, r.RETAKE_CNT, r.SKIP_NO " ." FROM TB_EXAM_SCH s, TB_EXAM e, TB_EXAM_REC r " ." WHERE e.EXAM_ID = '$examid' " ." AND r.USER_ID = '$userid' " ." AND e.BOOK_ID = '$bookid' " ." AND r.EXAM_SCH_SEQ = '$exam_sch_seq' "; $res =& $db->query($sql); if (PEAR::isError($db)) { die($db->getMessage()); } while ($res->fetchInto($row)) { $r_examstart = $row[0]; $r_examend = $row[1]; $r_curqstseq = $row[2]; $r_elapsedtime = $row[3]; $r_retakecnt = $row[4]; $r_skipno = $row[5]; } $arr = array($r_examstart, $r_examend, $r_curqstseq, $r_elapsedtime, $r_retakecnt, $r_skipno); $rtn = implode(",", $arr); echo $rtn; }
function func_reg_Skip($bookid, $examid, $userid, $p_examlgubun, $p_examsgubun, $skipno, $elapsedtime) { // 권한 검사 $connect=dbConn(); $member=member_info(); call_pear_init(); require_once("DB.php"); // DB 접속 $db =& DB::connect(call_pear_db_dsn()); if (PEAR::isError($db)) { die($db->getMessage()); } //****************************** // CLASS_ID 찾기 $sql = "SELECT TB_REG1.CLASS_ID " ." FROM TB_CLASS, TB_REG1 " ." WHERE TB_REG1.USER_ID = '$userid' " ." AND BOOK_ID = '$bookid' " ." AND TB_REG1.CLASS_ID = TB_CLASS.CLASS_ID"; $res = $db->query($sql); if (PEAR::isError($db)) { die($db->getMessage()); } while ($res->fetchInto($row)) { $class_id = $row[0]; } //****************************** // TB_EXAM.SEQ 찾기 $sql = "SELECT SEQ " ." FROM TB_EXAM " ." WHERE BOOK_ID = '$bookid' " ." AND EXAM_ID = '$examid' "; $res = $db->query($sql); if (PEAR::isError($db)) { die($db->getMessage()); } while ($res->fetchInto($row)) { $exam_seq = $row[0]; } //****************************** // TB_EXAM_SCH.SEQ 찾기 $sql = "SELECT SEQ " ." FROM TB_EXAM_SCH " ." WHERE CLASS_ID = '$class_id' " ." AND EXAM_SEQ = '$exam_seq' "; $res = $db->query($sql); if (PEAR::isError($db)) { die($db->getMessage()); } while ($res->fetchInto($row)) { $exam_sch_seq = $row[0]; } //****************************** $sql = "SELECT SEQ, SKIP_NO " ." FROM TB_EXAM_REC " ." WHERE EXAM_SCH_SEQ = '$exam_sch_seq' " ." AND USER_ID = '$userid' "; $res = $db->query($sql); if (PEAR::isError($db)) { die($db->getMessage()); } while ($res->fetchInto($row)) { $r_seq = $row[0]; } //****************************** $res = $db->query($sql); if (PEAR::isError($db)) { die($db->getMessage()); } while ($res->fetchInto($row)) { $r_skipno = $row[1]; } $r_skipno = $skipno."@".$r_skipno; // 문제번호 추가 // 수정 $sth = $db->prepare("UPDATE TB_EXAM_REC SET SKIP_NO = ?, UPDATE_ILSI = now(), ELAPSED_TIME = ? WHERE SEQ = ?"); $data = array($r_skipno, $elapsedtime, $r_seq); $db->execute($sth, $data ); }