ノブログ製作委員会

プロフィール(更新できたよ)

最終更新:

匿名ユーザー

- view
だれでも歓迎! 編集
<?php

//=============================
//基本設定
//=============================
$my_url = $_SERVER{'PHP_SELF'};

//ファイル読み込み
require_once("./init.php");

//=============================
//基本設計
//=============================

//セッションスタート
session_start();

$h = new html();
$prof = new profile();

//サーバ側から
if($_SERVER['REQUEST_METHOD'] == "GET"){
$_POST['mode'] = &$_GET['mode'];
}

$h->header_html(THEMETITLE);

switch($_POST['mode']):
case 'write':
//更新処理
$prof->update();
break;
default:
//一覧表示
$prof->write_html();
break;
endswitch;

$h->footer_html();
exit;

//=============================
//プロフィール
//=============================
class profile {

var $id;
var $name;
var $year;
var $mon;
var $day;
var $job;
var $sex;
var $syumi;
var $hitokoto;
var $syokai;
var $pic;

//================================================//
//□コンストラクタ
//================================================//
function __construct() {

$this->id = $_SESSION["session_id"];
$this->name = $_POST['name']; //名前の取得
$this->year = $_POST['year']; //年の取得
$this->mon = $_POST['mon']; //月の取得
$this->day = $_POST['day']; //日の更新
$this->job = $_POST['job']; //職業の取得
$this->sex = $_POST['sex']; //性別の取得
$this->syumi = $_POST['syumi']; //趣味の取得
$this->hitokoto = $_POST['hitokoto']; //一言の更新
$this->syokai = $_POST['syokai']; //自己紹介の取得
$this->pic = $_POST['pic']; //画像

}

//================================================//
//□投稿画面
//================================================//
function write_html($error ="") {
global $pro;

$pro_name = $pro['name'];
$pro_hobby = $pro['hobby'];
$pro_text = $pro['text'];
$pro_com = $pro['com'];

//================================================//
//□ユーザのプロフィール呼び出し
//================================================//
//MySQLへの接続
$conn = SQL_init::connect();

//一致する行取得
$insert ="SELECT * FROM {$pro['colum']} "
."where {$pro['id']} = '$this->id'";

//sql実行
$sql = mysql_query($insert,$conn);

//配列として受け取る
$lines = mysql_fetch_array($sql,MYSQL_ASSOC);

//閉じる
mysql_close($conn);

//================================================//
//□いろんな処理
//================================================//
//職業欄生成
$jobs = $this->job_form($lines);

//年の設定
$years = $this->year_form($lines);

//月の設定
$mons = $this->mon_form($lines);

//月の設定
$days = $this->day_form($lines);

//性別の設定
$sexs = $this->sex_form($lines);

//================================================//
//□HTML
//================================================//

echo<<<HTML
<table border="0" class="header2" bgcolor="#ffffff">
<!--ここからメイン-->
<tr>
<!--メニューバー-->
<td valign="top" width="140px">
<br>
<div class="u-menu2">
<!--ブログの編集メニュー-->
<div class="gra-box2">
<img src="./image/doa.gif" alt="ブログ編集">ブログ編集
</div>
<table border="0">
<tr>
<td>
<img src="./image/pen.gif" alt="ブログを書く">
<a href="kari.htm">ブログを書く</a>
<div class="hr2"></div>
</td>
</tr>
<tr>
<td>
<img src="./image/book.gif" alt="過去のブログ">
<a href="b-hensyu.html">過去のブログ</a>
<div class="hr2"></div>
</td>
</tr>
<tr>
<td>
<img src="./image/book.gif" alt="プロフィール">
<a href="profile.html">プロフィール</a>
<div class="hr2"></div>
</td>
</tr>
</table>
</div>
<!--設定メニュー-->
<div class="u-menu1">
<div class="gra-box1">
<img src="./image/doa.gif" alt="設定">設定
</div>
<table border="0">
<tr>
<td>
<img src="./image/pen.gif" alt="ブログの設定">
<a href="b-set.html">ブログの設定</a>
<div class="hr2"></div>
</td>
</tr>
<tr>
<td>
<img src="./image/book.gif" alt="デザイン">
<a href="kari.htm">デザイン</a>
<div class="hr2"></div>
</td>
</tr>
</table>
</div>
<!--その他メニュー-->
<div class="u-menu3">
<div class="gra-box3">
<img src="./image/doa.gif" alt="設定">その他
</div>
<table border="0">
<tr>
<td>
<img src="./image/pen.gif" alt="">
<a href="gazou.php">画像アップロード</a>
<div class="hr2"></div>
</td>
</tr>
<tr>
<td>
<img src="./image/book.gif" alt="ユーザー設定">
<a href="u-set.html">ユーザー設定</a>
<div class="hr2"></div>
</td>
</tr>
<tr>
<td>
<img src="./image/book.gif" alt="ブログの削除">
<a href="delete.html">ブログの削除</a>
<div class="hr2"></div>
</td>
</tr>
</table>
</div>
</td>
<!--ここから右のページ-->
<td valign="top" width="610px" colspan="2">
<!--パン屑プログラム-->
<div class="waku2">
管理ツールトップ
<div class="hr1"></div>
<!--ここまではテンプレ(パン屑プログラムも)-->
<!--エラー表示-->
<h3>{$error}</h3>
<BR>
<BR>
<!--プロフィール編集項目-->
<form action="$my_url" method="POST">
<input type=hidden name="mode" value="write">
<table border="0" class="orange">
<tr>
<td colspan="2">
<h2>プロフィール編集</h2>
</td>
</tr>
<tr>
<th>
名前
</th>
<td>
<input type="text" name="name" size="40" value = "{$lines[$pro_name]}">

</td>
</tr>
<tr>
<th>
生年月日
</th>
<td>
$years


$mons


$days

</td>
</tr>
<tr>
<th>
職業
</th>
<td>
$jobs
</td>
</tr>
<tr>
<th>
性別
</th>
<td>

$sexs

</td>
</tr>
<tr>
<th>
趣味
</th>
<td>
<textarea rows="2" cols="35" name="syumi" value = "{$lines[$pro_hobby]}">{$lines[$pro_hobby]}</textarea>
</td>
</tr>
<tr>
<th>
一言
</th>
<td>
<textarea rows="2" cols="35" name="hitokoto" value = "{$lines[$pro_com]}">{$lines[$pro_com]}</textarea>
</td>
</tr>
<tr>
<th>
自己紹介
</th>
<td>
<textarea rows="12" cols="35" name="syokai" value = "{$lines[$pro_text]}">{$lines[$pro_text]}</textarea>
</td>
</tr>
<tr>
<th>
公開する画像
</th>
<td>
<a href="gazou.php" name="pic">参照</a>  ※こちらからどうぞ
</td>
</tr>
</table>
<br>
<input value="更新" type="submit" name="submit">
</form>
</div>
</td>
</tr>
</table>
</div>
</div>
</body>
</html>
HTML;
}

//================================================//
//□エラー処理
//================================================//

function error_check()
{
//文字数チェック
if(strlen($this->name) > 40)
{
//エラー表示
$error .="名前を20文字以内にしてください。<br/>";
}
//名前が未入力の場合
else if($this->name == "")
{
//エラー表示
$error .="名前が入力されていません。<br/>";
}

//正しくない生年月日が選択された場合
if(!(checkdate($this->mon,$this->day,$this->year)))
{
//エラー表示
$error .="生年月日が正しくありません。<br/>";
}

if($error != "") {
$this->write_html($error);
exit();
}
}

//================================================//
//□職業テーブルから職業の取得
//================================================//

function job_form($olines)
{
global $job,$pro; //グローバルとして読み込む

$pro_job = $pro['job'];
$job_no = $job['no'];
$job_name = $job['name'];
$flg = 0; //でたかどうか

$select = array();

//Mysqlへ接続
$conn = sql_init::connect();

//sql文
$insert ="SELECT * FROM {$job['colum']} ";

//sql実行
$sql = mysql_query($insert,$conn);

$job=0;
while($lines = mysql_fetch_array($sql,MYSQL_ASSOC))
{
if($job == $olines[$pro_job]-1)
{
$flg= 1;
array_push($select,"<option value=\"$lines[$job_no]\" selected=\"selected\">$lines[$job_name]</option>\n");

}else{
//上から順に
array_push($select,"<option value=\"$lines[$job_no]\">$lines[$job_name]</option>\n");
}
$job++;
}
if($flg ==0){
$selected ="selected=\"selected\"";
}
//先頭にいれる
array_unshift($select,"<select name=\"job\">\n<option value=\"0\" $selected\>公開しない</option>\n");

array_push($select,"</select>\n");

//sql接続切る
mysql_close($conn);
//配列を返す
return implode($select,"\n");
}

//================================================//
//□年の処理
//================================================//
function year_form($lines)
{
global $pro;
$pro_year = $pro['year'];

//配列を初期化
$select = array("<select name=\"year\">\n");
//現在年数取得
$nowyear = date("Y", time());

$flg=0; //でたかどうか

//年数のカウントアップ 今から90年前まで表示
for($year = $nowyear -90;$year < $nowyear; $year++)
{
//前に保存したデータがなければ初期値は22歳
if(($year == $nowyear - 22) && $flg ==0)
{
array_push($select,"<option value=\"$year\" selected=\"selected\">$year</option>\n");
}

//選択された値を表示
elseif($year == $lines[$pro_year])
{
$flg= 1;
array_push($select,"<option value=\"$lines[$pro_year]\" selected=\"selected\">$lines[$pro_year]</option>\n");
}else{
//上から順に
array_push($select,"<option value=\"$year\">$year</option>\n");
}
}

//閉じタグ挿入
array_push($select,"</select>");
//配列を文字列にして返す
return implode($select,"\n");
}

//================================================//
//□月の処理
//================================================//
function mon_form($lines)
{
global $pro;
$flg = 0; //でたかどうか
$pro_mon = $pro['mon'];

$select = array("<select name=\"mon\">\n");

for($mon = 1; $mon < 13; $mon++)
{
if(($mon == 1) && $flg ==0)
{
array_push($select,"<option value=\"1\" selected>1</option>\n");
}
elseif($mon == $lines[$pro_mon])
{
$flg= 1;
array_push($select,"<option value=\"$lines[$pro_mon]\" selected=\"selected\">$lines[$pro_mon]</option>\n");
} else {
//上から順に
array_push($select,"<option value=\"$mon\">$mon</option>\n");
}
}
array_push($select,"</select>");
return implode($select,"\n");
}


//================================================//
//□日の処理
//================================================//
function day_form($lines)
{
global $pro;
$flg=0; //でたかどうか
$pro_day = $pro['day'];

$select = array("<select name=\"day\">\n");

for($day = 1; $day < 32; $day++)
{
if(($day == 1) && $flg ==0)
{
array_push($select,"<option value=\"1\" selected>1</option>\n");
}
elseif($day == $lines[$pro_day])
{
$flg= 1;
array_push($select,"<option value=\"$lines[$pro_day]\" selected=\"selected\">$lines[$pro_day]</option>\n");
} else {
//上から順に
array_push($select,"<option value=\"$day\">$day</option>\n");
}
}
array_push($select,"</select>");
return implode($select,"\n");
}

//================================================//
//□性別の処理
//================================================//
function sex_form($lines){
global $pro,$sexs;

$flg=0; //でたかどうか
$pro_sex = $pro['sex'];


//初期化
$select = array("");
//格納処理
foreach($sexs as $key => $value) {
//初期値決定
if($lines[$pro_sex] == $key){
$flg = 1;
//一致したやつにチェック
$checked="checked";
}else{
//なかった
$checked="";
}
//格納
array_push($select,"<input type=\"radio\" name=\"sex\" value=\"$key\" $checked>$value");
}
if($flg==0){
$checked="checked";
}else{
$checked="";
}

//最後は閉じる
array_push($select,"<input type=\"radio\" value=\"0\" name=\"sex\" $checked>公開しない");

//配列返す
return implode($select,"\n");
}

//================================================//
//□更新処理
//================================================//
function update()
{
global $pro,$myurl;

//error_checkに飛ばす
$this->error_check();

//MySQLへの接続
$conn = SQL_init::connect();

//データベースの更新
$sql ="update {$pro['colum']} set "
."{$pro['name']} = '$this->name', "
."{$pro['year']} = '$this->year', "
."{$pro['mon']} = '$this->mon', "
."{$pro['day']} = '$this->day', "
."{$pro['job']} = '$this->job', "
."{$pro['sex']} = '$this->sex', "
."{$pro['hobby']} = '$this->syumi', "
."{$pro['com']} = '$this->hitokoto', "
."{$pro['text']} = '$this->syokai', "
."{$pro['pic']} = '$this->pic' "
."where {$pro['id']} = '$this->id'";

//クエリ送信
$aa = mysql_query($sql, $conn);

if($aa)
{
echo"<h3>更新しました。</h3><br>";
echo"<h3>しばらくお待ちください。</h3>";
/* exit();
*/ } else {
die("更新できませんでした。");
}

//sql接続切る
mysql_close($conn);

//管理トップに戻す。
html::back_html($myurl);
}
//================================================//
}
?>

list($width, $height) = getimagesize(UPLOAD_DIR.$file);

//簡単なサムネイル表示を行うために縦横のサイズの計算をする。
$ratio = MAX_SIZE / max($width, $height);
$width = (int)($width * $ratio);
$height = (int)($height * $ratio);

タグ:

+ タグ編集
  • タグ:

このサイトはreCAPTCHAによって保護されており、Googleの プライバシーポリシー利用規約 が適用されます。

目安箱バナー