docs(10_Wiki): 위키 구조 정리 — 언어 튜토리얼 카테고리 폴더 제거 + 신규 자산 동기화

Topic_CSS/Topic_HTML/Topic_JavaScript/Topic_Prompt/Topic_Comfyui 등 기존 카테고리 폴더를 정리하고,
Topic_Graphic/Dev 등 신규 산출물과 Topics 내부 세션/메모리 기록을 동기화.
This commit is contained in:
Antigravity Agent
2026-07-05 00:10:59 +09:00
parent a397bc4720
commit 1cfd3bbb56
1495 changed files with 68534 additions and 27 deletions
+75
View File
@@ -0,0 +1,75 @@
---
id: php-ajax-poll
title: "PHP AJAX Poll"
category: "Programming_Language"
status: "draft"
verification_status: "conceptual"
canonical_id: ""
aliases: ["PHP AJAX 투표"]
duplicate_of: ""
source_trust_level: "B"
confidence_score: 0.87
created_at: 2026-07-04
updated_at: 2026-07-04
review_reason: ""
merge_history: []
tags: ["php", "programming", "w3schools", "ajax", "file-handling"]
raw_sources: ["https://www.w3schools.com/php/php_ajax_poll.asp"]
applied_in: []
github_commit: ""
---
# [[PHP AJAX Poll]]
## 🎯 한 줄 통찰 (One-line insight)
This poll persists its vote counts in a PLAIN TEXT FILE (`poll_result.txt`, format `"0||0"`), not a database — and the source explicitly warns to grant the WEB SERVER write access to that file, but NOT everyone, framing file permissions as the specific security concern for this simpler persistence approach. [S1]
## 🧠 핵심 개념 (Core concepts)
- **`onclick` event** — triggers on radio button selection (vs. `onkeyup`/`onchange` in earlier chapters). [S1]
- **Same AJAX skeleton** — `XMLHttpRequest` + `onreadystatechange`, now sending a `vote` parameter instead of a search string. [S1]
- **File-based vote storage** — `poll_result.txt` stores counts as `"yesCount||noCount"`, parsed via `explode("||", $content[0])`. [S1]
- **Read-modify-write cycle** — `file()` reads current counts, increments the relevant one, then `fopen()`+`fputs()`+`fclose()` overwrites the file with updated counts. [S1]
- **Graphical percentage bars** — computed inline with `round($yes/($no+$yes),2)` and rendered as a proportionally-sized `<img>` width. [S1]
- **File permission warning** — only the web server (PHP process) should have write access to `poll_result.txt`, not all users. [S1]
## 📖 세부 내용 (Details)
- Read-modify-write vote logic: `$vote = $_REQUEST['vote']; $content = file($filename); $array = explode("||", $content[0]); $yes = $array[0]; $no = $array[1]; if ($vote == 0) { $yes = $yes + 1; } if ($vote == 1) { $no = $no + 1; } $insertvote = $yes."||".$no; $fp = fopen($filename,"w"); fputs($fp,$insertvote); fclose($fp);`. [S1]
- Percentage bar rendering: `<img src="poll.gif" width='<?php echo(100*round($yes/($no+$yes),2)); ?>' height='20'> <?php echo(100*round($yes/($no+$yes),2)); ?>%`. [S1]
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
- **파일 쓰기 권한 경고**: poll_result.txt에 대한 쓰기 권한은 웹 서버(PHP)에만 부여해야 하며 모든 사용자에게 열어주면 안 된다는 점이 명시적으로 경고됨. [S1]
## 🛠️ 적용 사례 (Applied in summary)
현재 발견된 실제 적용 사례가 없습니다 — 텍스트 파일로 투표수를 저장하고 그래픽 막대로 비율을 표시하는 것이 파일 기반 데이터 영속화의 대표 실전 사례다. [S1]
## 💻 코드 패턴 (Code patterns)
Read-modify-write vote counting in a text file (PHP):
```php
$vote = $_REQUEST['vote'];
$content = file("poll_result.txt");
$array = explode("||", $content[0]);
$yes = $array[0]; $no = $array[1];
if ($vote == 0) { $yes = $yes + 1; }
if ($vote == 1) { $no = $no + 1; }
$fp = fopen("poll_result.txt", "w");
fputs($fp, $yes."||".$no);
fclose($fp);
```
## ✅ 검증 상태 및 신뢰도
- **상태:** draft
- **검증 단계:** conceptual
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
- **신뢰 점수:** 0.87
- **중복 검사 결과:** 신규 생성 (New discovery)
## 🔗 지식 그래프 (Knowledge Graph)
- **상위/루트:** [[PHP Tutorial]]
- **관련 개념:** [[PHP AJAX Live Search]], [[PHP Files Write]], [[PHP File Create]]
- **참조 맥락:** AJAX 섹션이자 PHP 튜토리얼 전체의 마지막 챕터 — 파일 기반 데이터 저장을 실전 활용으로 마무리.
## 📚 출처 (Sources)
- [S1] W3Schools — PHP - AJAX Poll — https://www.w3schools.com/php/php_ajax_poll.asp
## 📝 변경 이력 (Change history)
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP - AJAX Poll" page (Astra wiki-curation, P-Reinforce v3.1 format).