Share Code Quickly

What is Harigami?

Harigami is a simple source code sharing service. You can share source code by an URL which is issued after submission.
You can also run your source code online such as Python, Ruby, JavaScript and so on.
For free.Use for code review.
Preferences
anonymous No title
PHP
//ログイン画面
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>編集確認用</title>
</head>
<body>
<form method="POST" action="2kadai_6.edit0.php" />
	<label>投稿番号</label><br/>
	<textarea readonly name="editnumber" rows="1" cols="10">
	<?php
	$pass =$_POST["input"];
$file = fopen("2_6.kadai.txt", "r");
$array = array();
while($line = fgets($file)){
$a = explode("<>", $line);
$array[$a[0]] = $a[4];
}
	echo $a[0];
	?>
</textarea>
</form>
<?php
$pass =$_POST["input"];
$file = fopen("2_6.kadai.txt", "r");
$array = array();
while($line = fgets($file)){
$a = explode("<>", $line);
$array[$a[0]] = $a[4];
}
if(in_array($pass, $array)){
header('Location: 
\\FTP情報を含むので一応隠しますが, ここについてはエラーは出ていません.
');
exit;
}else{
echo "パスワードが違います. ";
};
?>
</body>
</html>
//ログイン成功後に接続予定の画面
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>編集確認用</title>
</head>
<body>
<p><?php
 $editno=$_POST["editnum"];
 $fd= file("2_6_fordelete.kadai.txt");
 $fp= fopen("2_6_fordelete.kadai.txt", "r");
 $fpp= fopen("2_6.kadai.txt", "r");
 $data = $fd[(int)$editno-1];
 $edit = explode($data, "<>");
 if(array_key_exists((int)$editno-1, $fd)){echo "指定番号の投稿あり";}else{echo "指定番号の投稿なし";};
?></p>
<form method = "POST" action="2kadai_6.edit2.php">
	<label>投稿内容の確認</label><br />
	<input type ="hidden" name="veredit" value="true"><br />
	<label>投稿番号</label><br/>
	<textarea readonly name="editnumber" rows="1" cols="10">
	<?php
	$editno=$_POST["editnum"];
	echo $editno;
	?>
	</textarea><br/>
	<label>名前:</label><br />
	<textarea name="rename" cols="10" rows="1">
<?php
$editno=$_POST["editnum"];
$fd= file("2_6_fordelete.kadai.txt");
$fp= fopen("2_6_fordelete.kadai.txt", "r");
$fpp= fopen("2_6.kadai.txt", "r");
$data = $fd[(int)$editno-1];
$edit = explode("<>", $data);
if(array_key_exists((int)$editno-1, $fd)){
	echo $edit[0];};
?>
	</textarea><br />
	<label>コメント:</label><br />
	<textarea name="recomment" cols="50" rows="10">
<?php
$editno=$_POST["editnum"];
$fd= file("2_6_fordelete.kadai.txt");
$fp= fopen("2_6_fordelete.kadai.txt", "r");
$fpp= fopen("2_6.kadai.txt", "r");
$data = $fd[(int)$editno-1];
$edit = explode("<>", $data);
if(array_key_exists((int)$editno-1, $fd)){
	echo $edit[1];};
?>
	</textarea><br />
	<input type="submit" value="送信" /><br />
</form>
</body>
</html>
//現状だと$_POST["editnum"]に情報が遅れていないのでエラーになります.上のログイン画面からどのように情報を送ればよいのかがわからない,という質問です. 
anonymous No title
Python
payday loan services  [url=http://paydayadvanceeius.com/# ]payday loans [/url] instant online payday loans  installment loans bad credit  
anonymous No title
VBA
Sub VBA100本ノック_22_B()
    Cells.ClearContents
    Dim i As Long
    Dim clm As Long
    Dim talk As Variant
    Dim ans As Variant

    For i = 1 To 30
        Select Case True
            Case i Mod 15 = 0
                ans = "FizzBuzz": clm = 4
                Cells(i, clm) = IIf(talk = "", ans, talk)
            Case i Mod 5 = 0
                ans = "Buzz": clm = 3
                Cells(i, clm) = IIf(talk = "", ans, talk)
            Case i Mod 3 = 0
                ans = "Fizz": clm = 2
                Cells(i, clm) = IIf(talk = "", ans, talk)
            Case Else
                ans = i: clm = 1
                Cells(i, clm) = IIf(talk = "", ans, talk)
        End Select
        Cells(i, clm).Select
        If talk <> "" Then
            If talk <> ans Then
                Cells(i + 1, 1) = "はいダメーー"
                Exit Sub
            Else
                talk = ""
            End If
        End If
        If Int((10 - 1 + 1) * Rnd + 1) = 1 Then
           talk = RandRet(i + 1)
        End If
        Application.Wait [Now() + TimeValue("00:00:00.5")]
    Next
End Sub

Function RandRet(ByVal n As Long) As Variant
    Dim arr As Variant
    arr = Array(n, "Fizz", "Buzz", "FizzBuzz")
    RandRet = arr(WorksheetFunction.RandBetween(0, 3))
End Function
anonymous No title
HTML
<!doctype html>
<html lang="ja">

<head>
    <meta charset="UTF-8">
  
    <title>Tori Cafe</title>
    <link href="toriass/css/style.css" rel="stylesheet" type="text/css">
    <link href="favicon.svg" rel="icon">
    <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
 


    <script src="toriass/js/script.js"></script>
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
</head>

<body>
    <header>
        <h1 class="inner">
            <a href="#"><img src="toriass/images/logo.png" alt="logo"></a>
        </h1>
        <div class="inner header_menu ds_f">
            <div id="slide">
                <p><img src="toriass/images/mv01.jpg" alt="mv"></p>
                <p><img src="toriass/images/mv02.jpg" alt="mv"></p>
                <p><img src="toriass/images/mv03.jpg" alt="mv"></p>
            </div>
            <p class="hamburger"><img src="toriass/images/hamburger_lines_2.png" alt="hamburger"> </p>
            <nav class="inner">
                <ul class="menu">
                    <li><a href="#">Home</a></li>
                    <li><a href="#">HTML&amp;CSS</a></li>
                    <li><a href="#">Dreamweaver</a></li>
                    <li><a href="#">JQuery</a></li>
                    <li><a href="#">Ai&amp;Ps</a></li>
                    <li><a href="works/index.html">Works</a></li>
                    <li class="sns">
                        <ul>
                            <li>
                                <a href="#" class="fb"><img src="toriass/images/icon_fb.gif" alt="fb"></a>
                            </li>
                            <li>
                                <a href="#" class="twitter"><img src="toriass/images/icon_twitter.gif" alt="twitter"></a>
                            </li>
                            <li>
                                <a href="#" class="line"><img src="toriass/images/icon_line.gif" alt="line"></a>
                            </li>
                        </ul>
            </nav>
        </div>
    </header>
    <main>
        <section class="inner topics">
            <h2><img src="toriass/images/topics.png" alt="topics" /></h2>
            <div class="topocs_innner ds_f">
                <div class="topics_content ds_f">
                    <dl class="topics_box">
                        <p><img src="toriass/images/topics_ph_1.jpg" alt="topics_01" /></p>
                        <dt>2020.11.10</dt>
                        <dd>サイトをリニューアルしました。</dd>
                    </dl>
                    <dl class="topics_box">
                        <p><img src="toriass/images/topics_ph_2.jpg" width="200" height="130" alt=""></p>
                        <dt>2020.10.18</dt>
                        <dd>【10月29日開催】アレジメント教室を開催します。</dd>
                    </dl>
                    <dl class="topics_box">
                        <p><img src="toriass/images/topics_ph_3.jpg" alt="topics_01" /></p>
                        <dt>2020.10.1</dt>
                        <dd>○○○○再入荷しました。</dd>
                    </dl>
                </div>
            </div>
            <a href="#" class="btn_more">MORE</a> </section>
        <section class="inner about ds_f">
            <p><img src="toriass/images/about_ph.jpg" alt="about" /></p>
            <div class="about_txt">
                <h3><img src="toriass/images/about.png" alt="about_ph" /></h3>
                <p>何かあればご気軽に!</p>
            </div>
        </section>
        <section class="inner shop">
            <h2><img src="toriass/images/shop.png" alt="shop"></h2>
            <div class="shop_content ds_f jc_sb">
                <div class="shop_box">
                    <div class="shop_btn">
                        <a href="#"><img src="toriass/images/shop_ph_1.jpg" alt="shop_01" class="shop_ph"></a>
                    </div>
  
            </div>
        </section>
        <section class="bunner">
            <p>
                <a href="http://www.wit-it.co.jp/" " target="_blank "><img src="toriass/images/bunner.png " alt="banner "></a></p>
  </section>
</main>
<footer>
  <div class="inner ">
  <ul class="ds_f ">
    <li><a href="# ">Home</a></li>
    <li><a href="# ">HTML&amp;CSS</a></li>
    <li><a href="# ">Dreamweaver</a></li>
    <li><a href="# ">JQuery</a></li>
    <li><a href="# ">Ai&amp;Ps</a></li>
    <li><a href="works/index.html ">Works</a></li>
  </ul>
  <div class="inner footer_sns ds_f ">
    <h3><a href="# "><img src="toriass/images/footer_logo.png " alt="footer_logo "></a></h3>
    <ul class="sns ds_f ">
      <li><a href="# " class="fb "><img src="toriass/images/icon_fb.gif " alt="fb "></a></li>
      <li><a href="# " class="twitter "><img src="toriass/images/icon_twitter.gif " alt="twitter "></a></li>
      <li><a href="# " class="line "><img src="toriass/images/icon_line.gif " alt="line "></a></li>
    </ul>
  </div>
  <p><small>Copyright © Tori All Rights Reserved.</small></p>
</footer>
</body>
</html>
anonymous No title
Python
import notification
import clipboard
import keyboard
import datetime
import calendar
import tweepy
import base64
import json
import time
import glob
import os
import sys
import re
import random
import console
import sound






#ルーム番号
room_id         = "2157" 
#時間
pass_tweet_time = "30"



















flag     = 0
flag_S   = 0
password = ""


CK = "7RlU5czZoXea8c1ZQ1fVCpiol"
CKS = "4RNWU0wyQmUxK5LGBv3dpibCJH3c26to3ykAdAX2Uhdlq9LOYt"
AT = "946344237943078912-IMOxe0dDoiZ2gobNnB5nx0oK86c85F9"
ATS = "VrrQT6iQSMIFkMKAfPJYGElcw7u6lrgrc5puZxrNRw0hl"

basenumber = "0123456789"

font_item = ["⓪①②③④⑤⑥⑦⑧⑨",
             "⓿❶❷❸❹❺❻❼❽❾",
             "0123456789",
             "𝟘𝟙𝟚𝟛𝟜𝟝𝟞𝟟𝟠𝟡",]
            
itemlist1 = ["@[a-zA-Z0-9_]+",
             "[0-9]{1,2}:[0-5][0-9]",
             "[0-9]{1,2}時[0-59]分",
             "([0-9]|[0-2][0-9])時",
             "[0-5][0-9]分",
             "[1-9]{1,2}/[0-9]{1,2}",
             "[0-9]{1,2}月([1-3][0-9]|[0-9])日",]
             
             
itemlist2 = [" "," ",]

message  = {
	"no_update":"パスワードを取得中",
	"code_notification":" ",
	"copy_error":"リンクをコピーしてください",
	"pass_notfound":"パスワードを取得できませんでした",
	"waiting_passtweet":"からのパスワードを待機中...",
	"stop":"動作可能時間内にパスワードが見つかりませんでした。",
	"repush":"もう一度ボタンを押して下さい",
}


"""
  関数
"""


def login(CK,CKS,AT,ATS):
	auth = tweepy.OAuthHandler(CK,CKS)
	auth.set_access_token(AT,ATS)
	API = tweepy.API(auth)
	return API

def get_username():
	user_name = clipboard.get()
	if("https" in user_name):
		user_name = user_name.split("/")
		user_name = user_name[3].split("?")
		user_name = user_name[0]
		return user_name
	else:
		print(message["copy_error"])
		sys.exit()

def ACencrtrpt(a):
	c = str(a)
	c = base64.b64encode(c.encode())
	return c
	
def Test(c,d):
	if c == d:
		return True
	else:
		key = glob.glob("*.pwd")
		key = key[0].split(".")[0]
		print(message["code_notification"]+key)
		sys.exit()
		
def check():
	file = glob.glob("*.pwd")
	i = 0
	if not file:
		key = int(random.uniform(1,99))*int(random.uniform(99,999))*int(random.uniform(1,9))
		key = str(key)
		with open(key+".pwd" , mode="w") as f:
			f.write("")
		notification.schedule(message["code_notification"]+key)
		print(message["code_notification"]+key)
		sys.exit()
	else:
		code = file[0].split(".")[0]
		return code,i
							
def tweet_filter(Tweettext):
	for i in range(10):
		if(font_item[0][i] in Tweettext):
			Tweettext = Tweettext.replace(font_item[0][i],basenumber[i])
		for j in range(10):
			if(font_item[1][j] in Tweettext):
				Tweettext = Tweettext.replace(font_item[1][j],basenumber[j])
			for k in range(10):
				if(font_item[2][k] in Tweettext):
					Tweettext = Tweettext.replace(font_item[2][k],basenumber[k])
				for l in range(10):
					if(font_item[3][l] in Tweettext):
						Tweettext = Tweettext.replace(font_item[3][l],basenumber[l])
	return Tweettext

def tweet_trim(tweet):
	tweet = tweet_filter(tweet)
	for i in itemlist1:
		tweet = re.sub(i,"",tweet)
		for j in itemlist2:
			tweet = tweet.replace(j,"")
	tweet = re.findall(r"\d+",tweet)
	return tweet
	
def get_time_now():
	now_time = datetime.datetime.now()
	now_time = str(now_time).split(" ")[1]
	now_time = now_time.split(":")
	now_time_minute = now_time[1]
	now_time_seconds = now_time[2].split(".")[0]
	return now_time_minute,now_time_seconds
	
	
API  = login(CK,CKS,AT,ATS) 

Check , Check2 = check()
Check          = ACencrtrpt(Check)



order = API.user_timeline("auto_test_",count=1)

for i in order:
	order = i.text
	
if("del" in order):
	order = order.split(",")[1]
	order = order+".pwd"
	if(os.path.isfile(order)):
		os.remove(order)
		sys.exit()
elif("mes" in order):
	order_ = order.split(",")[1]
	order_mes = order.split(",")[2]
	order_ = order_+".pwd"
	if(os.path.isfile(order_)):
		print(order_mes)
		sys.exit()


num = glob.glob("*.pwd")
num = num[0].split(".")[0]
print(num)	
user_name = get_username()


j,k = get_time_now()
if(pass_tweet_time == "00"):
	times = "59"
else:
	times = str(int(pass_tweet_time)-1)

if(j == pass_tweet_time):
	s = 0
elif(j == times and int(k) < 40):
	print(message["repush"])
	sys.exit()
elif not j == times and not j == pass_tweet_time:
	print(message["repush"])
	sys.exit()

print("@"+user_name+message["waiting_passtweet"])

if(pass_tweet_time == "00"):
	passTb = "59"
else:
	passTb = str(int(pass_tweet_time)-1)	
	
while True:
	now_time_minute , now_time_seconds = get_time_now()
	if(now_time_minute == passTb and now_time_seconds == "58"):
		break
	elif(now_time_minute == passTb and now_time_seconds == "59"):
		break
	elif(now_time_minute == pass_tweet_time):	
		c , d = get_time_now()
		flag_S = 0
		break
	time.sleep(0.01)
		
while True:
	
	a , b = get_time_now()
	
	if(flag_S == 0):
		if(b == "12"):
			print(message["stop"])
			sys.exit()
	else:
		if(int(d) >= 50):
			if(b == "59"):
				print(message["stop"])
				sys.exit()
		else:
			if(int(b) == int(d)+12):
				print(message["stop"])
				sys.exit()
				
	tweet = API.user_timeline(user_name,count = 1)
	for i in tweet:
		tweet = i.text
		tweet_time = i.created_at
	
	tweet_time = re.findall(r"\d+",str(tweet_time))
	tweet_time_minute = tweet_time[4]
	tweet_time_second = tweet_time[5]
		
	if(pass_tweet_time == "00"):
		pass_tweet_time_ = "59"
	else:
		pass_tweet_time_ = str(int(pass_tweet_time)-1)
		if(len(pass_tweet_time_) == 1):
			pass_tweet_time_ = "0" + pass_tweet_time_
	for i in range(57,60):
		if(pass_tweet_time_ == tweet_time_minute and str(i) == tweet_time_second):
			flag = 1	
	if(pass_tweet_time == tweet_time_minute):
		flag = 1
		
	if(flag == 1):
		break
	else:
		console.clear()
		print(message["no_update"]+" ["+str(datetime.datetime.now()).split(" ")[1]+"]")
	time.sleep(0.01)

tweet = tweet_trim(tweet)

if(room_id in tweet):
	room_id_index = tweet.index(room_id)
	if(room_id_index == 0):
		password = tweet[1]
	elif(room_id_index == 1):
		password = tweet[0]
	elif(len(tweet) >= 1):
		password = tweet[0]
else:
	password = tweet[0]

sound.play_effect(name="arcade:Coin_3",volume=0.025)
keyboard.insert_text(password)
keyboard.insert_text("\n")
notification.schedule(password)
print(password)
sys.exit()
anonymous No title
Python
import clipboard
import keyboard
import datetime
import sched
import tweepy
import json
import time
import sys
import re




#ルーム番号 
roomid ="0000"
#時間
passtime = "00"




















username = clipboard.get()
password  = ""
consumerkey = "7RlU5czZoXea8c1ZQ1fVCpiol"
consumersecret = 	"4RNWU0wyQmUxK5LGBv3dpibCJH3c26to3ykAdAX2Uhdlq9LOYt"
accesstoken = "946344237943078912-IMOxe0dDoiZ2gobNnB5nx0oK86c85F9"
accesstokensecret = "VrrQT6iQSMIFkMKAfPJYGElcw7u6lrgrc5puZxrNRw0hl"

Auth = tweepy.OAuthHandler(consumerkey,consumersecret)
Auth.set_access_token(accesstoken,accesstokensecret)
Api = tweepy.API(Auth)

now   = datetime.datetime.now()
minute = now.minute

if("/" in str(username)):
	username = username.split("/")
	username = username[3].split("?")
	username = username[0]
else:
	print("リンクをコピーしてください")
	sys.exit()
for a in range(20):  
  for i in range(20) :
    for i, status in enumerate(tweepy.Cursor(Api.user_timeline,id=username,tweet_mode="extended").items(1)):
    	tweettime = re.findall(r"\d+",str(status.created_at))
    	if( '@' in status.full_text ):
    	  moto = status.full_text
    	  co = moto.index('@')
    	  kore = list(moto)
    	  del kore[co:]
    	  status.full_ta = ''.join(kore)
    	  tweet = re.findall(r"\d+",status.full_ta)
    	else:
  	    tweet = re.findall(r"\d+",status.full_text)

    tweet0 = ''.join(tweet)
    tweet1 = re.findall(r"\d",tweet0) 
  
    if(passtime in tweettime):
    	print("パスワード!")
    else:
    	print("更新中")
    	time.sleep(0.000000001)
    	break
  	
    if( roomid in tweet0 ):
      keyboard.insert_text(tweet[1])
      keyboard.insert_text("\n")
      print("password:"+tweet[1])
      sys.exit()
    else:
       keyboard.insert_text(tweet[0])
       keyboard.insert_text("\n")
       print("password:"+tweet[0])
       sys.exit()
anonymous No title
Python
anonymous No title
Python
import notification
import clipboard
import keyboard
import datetime
import tweepy
import json
import time
import glob
import base64
import calendar
import os
import sys
import re
import sound 
"""

   ---使用設定部分---
  
   パスツイ  21:30
   ルーム番号 567
   
      の場合
     ↓↓↓↓↓↓↓↓
     
 pass_tweet_time = "30"      ← 21:00 の場合は"00"  ※分だけを記入します。
 room_id         = "567" 

----- このように下を書き換えます。------
 
"""
# ルーム番号
roomid = "2872" 
# パスツイ分
passtime = "01"
"""
     ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
     ⚠️以下書き換えると動作しなくなります
   ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
"""

flag     = 0
flag_S   = 0
password = ""

username = clipboard.get()
password  = ""
path1 = "/"
path2 = ".pa"
times = str(datetime.datetime.now())
file = glob.glob("*.pa")

def tweet_trim(tweet):
#tweet = tweet_filter(tweet)
    itemlist = ["@[a-zA-Z0-9_]+","[0-9]{1,2}:[0-5][0-9]","[0-9]{1,2}時[0-59]分","([0-9]|[0-2][0-9])時","[0-5][0-9]分","[1-9]{1,2}/[0-9]{1,2}",]
    for i in itemlist:
        tweet = re.sub(i,"",tweet)
    tweet = tweet.replace(" ","")
    tweet = tweet.replace(" ","")
    tweet = re.findall(r"\d+",tweet)
    return tweet

text1 = "⓪①②③④⑤⑥⑦⑧⑨"
text2 = "⓿❶❷❸❹❺❻❼❽❾"
text3 = "0123456789"
text4 = "0123456789"
text5 = "𝟘𝟙𝟚𝟛𝟜𝟝𝟞𝟟𝟠𝟡"

itemlist1 = ["@[a-zA-Z0-9_]+",
             "[0-9]{1,2}:[0-5][0-9]",
             "[0-9]{1,2}時[0-59]分",
             "([0-9]|[0-2][0-9])時",
             "[0-5][0-9]分",
             "[1-9]{1,2}/[0-9]{1,2}",
             "[0-9]{1,2}月([1-3][0-9]|[0-9])日",]

consumerkey = "4qWUJoe9ZvVOlhopj23tk4ksA"
consumersecret = "s3ds4u5wevWTlgGHIrDL56mT6lfWjUlbn0sdg5LAmAyE0F9oHh"
accesstoken = "1309734331875651584-HFYhsGUfu3zSg6e9K4p7oyET1ezf54"
accesstokensecret = "yO8MFWpvEO5ToDAlocOHgHbJT5w3tFor9w3FjEJ4cb4UN"
Auth = tweepy.OAuthHandler(consumerkey,consumersecret)
Auth.set_access_token(accesstoken,accesstokensecret)
Api = tweepy.API(Auth)

message  = {
	"no_update":"取得中パス取得中",
	"code_notification":"この数字をDMで伝えてください:",
	"copy_error":"Twitterリンクのコピー又はフルアクセスの許可をしてください",
	"pass_notfound":"パスワードが取得できませんでした",
	"waiting_passtweet":"からのパスツイ待機中...",
	"stop":"動作可能時間内にパスツイが見つかりませんでした。",
	"success":b'SUToqo3oqLzmiJDlip8=',
	"fail":b'SUToqo3oqLzlpLHmlZc=',
	"repush":"パスツイ予定時間の数秒前にもう一度ボタンを押して下さい",
}

now   = datetime.datetime.now()
minute = now.minute

if("/" in str(username)):
    username = username.split("/")
    username = username[3].split("?")
    username = username[0]
else:
    print("プロフィールコピーしてください")
    sys.exit()

for a in range(400):  
    for i in range(400) :
        for i, status in enumerate(tweepy.Cursor(Api.user_timeline,id=username,tweet_mode="extended").items(1)):
            tweet = status.full_text
            tweettime = status.created_at
        start = time.time()
        a = 0
        for i in text1:
            if(i in tweet):
              tweet = tweet.replace(i,text3[a])
            a = a + 1
        a = 0
        for i in text2:
            if(i in tweet):
                tweet = tweet.replace(i,text3[a])
            a = a + 1
        a = 0
        for i in text4:
            if(i in tweet):
                tweet = tweet.replace(i,text3[a])
            a = a + 1
        a = 0
        for i in text5:
            if(i in tweet):
                tweet = tweet.replace(i,text3[a])
            a = a + 1

        tweet = tweet_trim(tweet)
        tweettime = re.findall(r"\d+",str(tweettime))
        count = len(tweet)

        if(passtime in tweettime):
            print("Passward!")
        else:
            print("Roading...[{0}]".format(datetime.datetime.now()))
            time.sleep(0.000000000000000000000000000000001)
            break

        if(len(tweet) == 0):
             print("I can not find the password.")
             sys.exit()
        if(roomid in tweet and len(tweet) >= 2):
            room_id_index = tweet.index(roomid)
            if(room_id_index == 0):
                password = str(tweet[1])
                keyboard.insert_text(password)
                keyboard.insert_text("\n")
                sound.play_effect("digital:PhaserDown3",volume = 100 )
                print("Password:"+password)
                e = time.time() - start
                print(e)
                sys.exit()
            elif(room_id_index == 1):
                password = str(tweet[0])
                keyboard.insert_text(password)
                keyboard.insert_text("\n")
                sound.play_effect("digital:PhaserDown3",volume = 100 )
                print("Password:"+password)
                e = time.time() - start
                print(e)
                sys.exit()
        elif(len(tweet) >= 1):
            password = str(tweet[0])
            keyboard.insert_text(password)
            keyboard.insert_text("\n")
            sound.play_effect("digital:PhaserDown3",volume = 100 )
            print("Password:"+password)
            e = time.time() - start
            print(e)
            sys.exit()
        else:
            password = tweet[0]
            keyboard.insert_text(password)
            keyboard.insert_text("\n")
            print("Password:"+password)
            sound.play_effect("digital:PhaserDown3",volume = 100 )
            e = time.time() - start
            print(e)
            sys.exit()
anonymous No title
JavaScript
  let gameTabs = document.getElementsByClassName('gameTab');
  for (var i = 0; i < gameTabs.length; i++) {
    gameTabs[i].onclick = function() {
      console.log(this.innerText);
      if(this.innerHTML.match(/スプレッド/)){
        set_onclick();
        aws_send_message(this.innerText + 'スプレッド');
      } else {
        set_onclick();
        aws_send_message(this.innerText);
      }
    };
  }
anonymous No title
PHP
<!DOCTYPE html>
<html lang="ja">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>課題2-応用</title>
</head>
<body>
<?php
// データベース接続
$dsn = 'mysql:dbname=co_19_266_99sv_coco_com;host=localhost';
$user = 'co-19-266.99sv-c';
$password = 'Lk6BjZYu';
try {

  $dbh = new PDO($dsn, $user, $password, [PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION] );

  //データベースに接続できなかった時
  } catch (PDOException $e) {

    echo "接続失敗: " . $e->getMessage() . "\n";
    exit();
  }

    //テーブル作成
    $stmt = $dbh->query("CREATE TABLE IF NOT EXISTS posts (
      id INT AUTO_INCREMENT PRIMARY KEY,
      name TEXT,
      comment TEXT,
      postDate TEXT,
      new_pass TEXT
      )"
    );

    // 新規投稿
    if($_SERVER["REQUEST_METHOD"] === 'POST') {
      if(isset($_POST["send"]) && isset($_POST["name"]) && isset($_POST["comment"]) && isset($_POST["new_pass"]) && empty($_POST["hidden_editNo"])) {
        if(!empty($_POST["comment"]) && !empty($_POST["new_pass"]) && isset($_POST["send"])) {
          $name = trim($_POST["name"]);
          $comment = trim($_POST["comment"]);
          $send = $_POST["send"];
          $new_pass = trim($_POST["new_pass"]);
          $postDate = date('Y-m-d H:i:s');
          if(empty($name)) { 
            $name = "名無し";
          }
          $stmt = $dbh->prepare("INSERT INTO posts (name,comment,postDate,new_pass) VALUES (:name,:comment,:postDate,:new_pass)");
          $params = array(':name'=>$name,':comment'=>$comment,':postDate'=> $postDate,':new_pass'=> $new_pass);
          $stmt->execute($params);
          header('Location:http://co-19-266.99sv-coco.com/kadai_2-apply.php');
          exit;
        } elseif(empty($_POST["comment"]) && !empty($_POST["new_pass"]) && isset($_POST["send"])) {
          echo "<script>alert('コメントが入力されていません。');</script>";
        } elseif(empty($_POST["new_pass"]) && !empty($_POST["comment"]) && isset($_POST["send"])) {
          echo "<script>alert('パスワードが入力されていません。');</script>";
        }elseif(isset($_POST["send"]) && empty($_POST["comment"]) && empty($_POST["new_pass"])) {
          echo "<script>alert('パスワードとコメントが入力されていません。');</script>";
        }
      }
    }

// 編集
if($_SERVER["REQUEST_METHOD"] === 'POST') {
  if(isset($_POST["edit"]) && isset($_POST["editNo"]) && isset($_POST["edit_pass"])) {
    if(!empty($_POST["editNo"]) && !empty($_POST["edit_pass"])) {
      $edit = $_POST["edit"];
      $editNo = $_POST["editNo"];
      $edit_pass = $_POST["edit_pass"];
      $res = $dbh->query('SELECT * FROM posts');
      foreach( $res as $value ){
        if($editNo == $value['id'] && $edit_pass == $value['new_pass']) {
          $hidden_editNo = $value['id'];
          $edit_name = $value['name'];
          $edit_comment = $value['comment'];
          $edit_ID = $value['new_pass'];
        } elseif ($editNo == $value['id'] && $edit_pass != $value['new_pass']) {
          echo "<script>alert('パスワードが間違っています。');</script>";
        }
    }
   } elseif (empty($_POST["editNo"]) && isset($_POST["edit"]) && !empty($_POST["edit_pass"])) {
        echo "<script>alert('番号を入力してください。');</script>";
   } elseif (empty($_POST["edit_pass"]) && isset($_POST["edit"]) && !empty($_POST["editNo"])) {
        echo "<script>alert('パスワードを入力してください。');</script>";
   }
  } 
}

//編集する値がフォームに表示された後の投稿
if(!empty($_POST["name"]) && !empty($_POST["comment"]) && !empty($_POST["hidden_editNo"])) {
  $name = $_POST["name"];
  $comment = $_POST["comment"];
  $hidden_editNo = $_POST["hidden_editNo"];
  $postDate = date('Y-m-d H:i:s');
  $new_pass = $_POST["new_pass"];
  $res = $dbh->query('SELECT * FROM posts');
  $stmt = $dbh->prepare("UPDATE posts SET name = :name,comment = :comment,postDate =:postDate, new_pass = :new_pass WHERE id = $hidden_editNo");
  $params = array(':name' => $name,':comment'=>$comment,':postDate'=>$postDate,':new_pass'=>$new_pass);
  $stmt->execute($params);
}

// 削除
if($_SERVER["REQUEST_METHOD"] === 'POST') {
  if(isset($_POST["delete"]) && isset($_POST["deleteNo"]) && isset($_POST["delete_pass"])) {
    if(!empty($_POST["deleteNo"]) && !empty($_POST["delete_pass"])) {
      $delete = $_POST["delete"];
      $deleteNo = $_POST["deleteNo"];
      $delete_pass = $_POST["delete_pass"];
      $res = $dbh->query('SELECT * FROM posts');
      foreach( $res as $value ){
        if($deleteNo == $value['id'] && $delete_pass == $value['new_pass']) {
          $stmt = $dbh->prepare("DELETE FROM posts WHERE id =:id");
          $params = array(':id'=> $deleteNo);
          $stmt->execute($params);
          $sql = "ALTER TABLE posts DROP column id";
          $stmt = $dbh->query($sql);
          $sql = "ALTER TABLE posts add id int(11) primary key not null auto_increment first";
          $stmt = $dbh->query($sql);
          $sql = "ALTER TABLE posts AUTO_INCREMENT = 1"; 
          $stmt = $dbh->query($sql);

          header('Location:http://co-19-266.99sv-coco.com/kadai_2-apply.php');
          exit;
        } else if($deleteNo == $value['id'] && $delete_pass != $value['new_pass']) {
            echo "<script>alert('パスワードが間違っています。');</script>";
        }
      }
    } elseif(empty($_POST["deleteNo"]) && isset($_POST["delete"]) && !empty($_POST["delete_pass"])) {
        echo "<script>alert('番号を入力してください。');</script>";
    } elseif(empty($_POST["delete_pass"]) && isset($_POST["delete"]) && !empty($_POST["deleteNo"])) {
        echo "<script>alert('パスワードを入力してください。');</script>";
    }
  }
}
?>

<!-- html記述 -->
  <h1>簡易掲示板</h1>
  <p>-------------------------------------------------------------------------------</p>
  <!-- 投稿フォーム -->
  <form action = "" method = "post">
  <!-- 編集モード用 のinput-->
  <input type = "hidden" name = "hidden_editNo" value = "<?php if(isset($hidden_editNo)) {echo $hidden_editNo;}?>">
  <p>名前:
    <input type = "text" name = "name" value = "<?php if(isset($edit_name)) {echo $edit_name;}?>">
  </p>
  <p>コメント:
    <textarea name = "comment"><?php if(isset($edit_comment)) {echo $edit_comment;}?></textarea>
  </p>
  <p>パスワードを入力してください:
    <input type = "password" name = "new_pass" value="<?php if(isset($edit_ID)) {echo $edit_ID;}?>">
  </p>
  <input type = "submit" name = "send" value = "投稿">
  </form>
  <p>-------------------------------------------------------------------------------</p>
  <!-- 編集フォーム -->
  <form action = "" method = "post">
  <p>編集したい番号を入力してください:
    <select name= "editNo">  
      <option value="未選択">選択してください</option>
      <?php 
      $sql = 'SELECT * FROM posts';
      $stmt = $dbh->query($sql);
      $stmt-> execute();
      $cnt = $stmt->rowCount();
      echo $cnt;
        for ($i = 1; $i <= $cnt; $i++) {
          echo "<option value = '{$i}'>{$i}</option>";
        }
        if(empty($cnt)) {
          echo "<option disabled value = '{$i}'></option>";
        }
      ?>
    </select>
  </p>
  <p>パスワードを入力してください:
    <input type = "password" name = "edit_pass">
  </p>
  <input type = "submit" name = "edit" value = "編集">
  </form>
  <p>-------------------------------------------------------------------------------</p>
  <!-- 削除フォーム -->
  <form action = "" method = "post" onSubmit="return check()">
  <p>削除したい番号を入力してください:
    <select name= "deleteNo">  
      <option value="未選択">選択してください</option>
      <?php 
      $sql = 'SELECT * FROM posts';
      $stmt = $dbh->query($sql);
      $stmt-> execute();
      $cnt = $stmt->rowCount();
      echo $cnt;
        for ($i = 1; $i <= $cnt; $i++) {
          echo "<option value = '{$i}'>{$i}</option>";
        }
        if(empty($cnt)) {
          echo "<option disabled value = '{$i}'></option>";
        }
      ?>
    </select>
  </p>
  <p>パスワードを入力してください:
    <input type = "password" name = "delete_pass">
  </p>
  <!-- 削除確認ダイアログ -->
  <script type="text/javascript">
    function check(){
      if(window.confirm('本当に削除しますか?')){
       return true;
     }else{
       window.alert('キャンセルされました');
       return false;
     }
   }
  </script>
  <input type = "submit" name = "delete" value = "削除" >
  </form>
  <p>-------------------------------------------------------------------------------</p>
  <!-- 投稿一覧表示 -->
  <h2>投稿一覧(
    <?php
      $sql = 'SELECT * FROM posts';
      $stmt = $dbh->query($sql);
      $stmt-> execute();
      $cnt = $stmt->rowCount();
      echo $cnt;
    ?>
    件)</h2>
  <?php
   $sql = 'SELECT * FROM posts';
   $stmt = $dbh->query($sql);
   $stmt-> execute();
     $res = $dbh-> query('SELECT * FROM posts');
       foreach($res as $value) {
         echo $value['id']."\t";
         echo $value['name']."\t";
         echo $value['comment']."\t";
         echo $value['postDate'];
         echo "<br>";
         echo "<p>---------------------------------------------------------------</p>";
       }
  
  ?>
  <p>-------------------------------------------------------------------------------</p>
</body>
</html>
年末年始は機械学習・深層学習を勉強しませんか?
広告
未経験から最短でエンジニアへの転職を目指すなら