// common.php (有)福地アイティ工房 IT Works
// Copyright 2003, itworks@itworks.co.jp
// **** 06/01/03
$mk0=substr($mk,0,8); $MyTwaFile="../tmp/twa".$mk0;
$ctime=Date("ymdHis"); $theDay=Date("m")."/".Date("d")." ".Date("H").":".Date("i");
$userid=0; $usertyp=0; $vndrno=0; $storeno=0;
function My_Connect() { // *データベース接続
$MyDb = mysql_Connect("mysql527.phy.lolipop.jp","LA11981944","12Qc12G1");
if (!$MyDb):
echo "D01,** DataBase ConnectionError
";
mysql_Close($MyDb); exit;
endif;
return $MyDb;
}
function My_Exec($MyDb,$MySql) { // * データベースSQL文の実行
$MyResult = mysql_db_query("LA11981944-vxww9u",$MySql);
if (!$MyResult):
echo "D02,** DataBase Errer. SQL is not executed
";
echo $MySql."
"; mysql_Close($MyDb); exit;
endif;
return $MyResult;
}
function My_Close($MyDb) { mysql_Close($MyDb); } // * データベースの切断
function MyGetTwa(&$mk) { global $myday; $twadate=Date("ymd");
$MyDb=My_Connect(); $a1=" where key1=1 and key2=1 ";
$MySql="lock table myctl write"; $result=My_Exec($MyDb,$MySql);
$MySql="update myctl set ctl1=ctl1+1 $a1 "; $result=My_Exec($MyDb,$MySql);
$MySql="select * from myctl $a1"; $result=My_Exec($MyDb,$MySql);
$twano=0; $myday=0;
while($ar=mysql_fetch_array($result)):
$twano=$ar[0]; $myday=$ar[1];
if($twano > 900000):
$MySql="update myctl set ctl1=1 $a1 "; $result2=My_Exec($MyDb,$MySql);
$twano=1;
endif;
endwhile;
$MySql="unlock table"; $result=My_Exec($MyDb,$MySql);
My_Close($MyDb);
$a1= sprintf("%06d",$twano); $mk=$a1.Date("dsi");
$mk0=substr($mk,0,8); $MyTwaFile = "../tmp/twa".$mk0;
return $MyTwaFile;
}
function MyLogOut() {
global $userid,$pw,$applkey,$bumon,$vndrno,$storeno,$MyTwaFile,$REMOTE_ADDR;
$a0=$REMOTE_ADDR;
$MyFp=fopen("../log/access.log","a"); flock($MyFp,1);
$a1="LogIn,".Date("ymdHis").",".$a0.",".$userid.",".$pw.",".$applkey;
$a2=$a1.",".$bumon.",".$vndrno.",".$storeno.",".$MyTwaFile."\n";
$i=fwrite($MyFp,$a2,strlen($a2)); flock($MyFp,3); fclose($MyFp);
}
function MySubX01() {
Global $mp0,$mp,$mk,$MyTwaFile,$ctime,$MyRAddr;
Global $userid,$usertyp,$vndrno,$storeno,$dBunrui,$cBunrui,$sBunrui,$ustoreno,$myday,$mk0;
$ustoren0=0; $myday=0; $usertyp=0; $userid=0;$storeno=0; $dBunrui=0; $cBunrui=0; $sBunrui=0;
if(is_file($MyTwaFile)):
$MyFp = fopen($MyTwaFile, "r");
flock($MyFp,1); $MyData = fread($MyFp, filesize($MyTwaFile));
$MyAr=explode(",",$MyData); $MyMp=$MyAr[2]; $mk0=$MyAr[3];
// if($mk==$mk0): **** 03/11/11 修正
$userid=$MyAr[4]; $usertyp2=$MyAr[5]; $vndrno=$MyAr[6]; $storeno=1 * $MyAr[7];
$dBunrui=$MyAr[8]; $cBunrui=$MyAr[9]; $sBunrui=$MyAr[10]; $myday=$MyAr[11];
$MyRAddr=$MyAr[12]; $a1=sprintf("%05d",$usertyp2);
$usertyp=1 * substr($a1,1,1); $ustoreno=1 * substr($a1,2,3);
// endif; **** 03/11/11 修正
flock($MyFp,3); fclose($MyFp);
endif;
}
function MySubX02(){
Global $mp0,$mp,$mk,$MyTwaFile,$ctime,$MyRAddr;
Global $userid,$usertyp,$vndrno,$storeno,$dBunrui,$cBunrui,$sBunrui,$ustoreno,$myday;
$MyFp = fopen($MyTwaFile,"w");
if ($MyFp):
flock($MyFp,2);
$usertyp2=$usertyp * 1000 + $ustoreno;
$a1=sprintf("%03d,%02d,%012d,%04d,%02d",$mp0,$mp,$mk,$userid,$usertyp2);
$a2=sprintf("%06d,%04d,%02d,%02d,%03d",$vndrno,$storeno,$dBunrui,$cBunrui,$sBunrui);
$a3=sprintf("%08d",$myday);
$MyData = $ctime.",".$a1.",".$a2.",".$a3.",".$MyRAddr;
fwrite($MyFp, $MyData, strlen($MyData));
endif;
flock($MyFp,3); fclose($MyFp);
}
function InitProc($mp,$mk){
header("location: index.html");
}
?>