-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathorganization.php
executable file
·252 lines (193 loc) · 8.42 KB
/
organization.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
<?php
session_start();
require_once('includes/connect.php');
include('includes/header.php');
include('comment.php');
include('includes/navigation.php');
// Check if HTTPS is used, otherwise default to HTTP
$protocol = ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";
// Get the server name (e.g., www.example.com)
$serverName = $_SERVER['SERVER_NAME'];
// Get the port number
$port = $_SERVER['SERVER_PORT'];
// If the port is not standard, include it in the URL
if (($protocol === "https://" && $port != 443) || ($protocol === "http://" && $port != 80)) {
$serverName .= ":" . $port;
}
// Get the web root path (if your application is in a subdirectory e.g., /myapp)
$webRoot = dirname($_SERVER['PHP_SELF']);
// Construct the base URL
$baseUrl = $protocol . $serverName . $webRoot;
$sql = "SELECT * FROM organization WHERE slug=? AND status='published'";
$result = $db->prepare($sql);
$result->execute(array($_GET['url']));
$post = $result->fetch(PDO::FETCH_ASSOC);
$usersql = "SELECT * FROM users WHERE id=?";
$userresult = $db->prepare($usersql);
$userresult->execute(array($post['uid']));
$user = $userresult->fetch(PDO::FETCH_ASSOC);
if($_SESSION['lang'] === 'en'){
$titel = $post['entitle'];
$web_content = $post['encontent'];
}else if($_SESSION['lang'] === 'bo'){
$titel = $post['tbtitle'];
$web_content = $post['tbcontent'];
}else{
$titel = $post['entitle'];
$web_content = $post['encontent'];
}
$map = $post['map'];
?>
<!-- Page Content -->
<div class="container">
<div class="row">
<!-- Post Content Column -->
<div class="col-lg-8">
<a href="javascript:history.back()"> <span style="font-size: 22px;position: relative;top: 2px;"><i class='fa fa-angle-left'></i></span> <?php echo htmlspecialchars(translate('go-back'), ENT_QUOTES, 'UTF-8'); ?></a>
<!-- Title -->
<h4 style="margin-bottom: 20px; line-height: 35px; " class="mt-4"><?php echo $titel; ?></h4>
<!-- Author -->
<!-- Preview Image -->
<?php if(isset($post['pic']) & !empty($post['pic'])){ ?>
<img style="width: 100%;object-fit: cover;" class="img-fluid rounded" src="<?php echo $post['pic']; ?>" alt="" onerror="this.onerror=null; this.src='vendor/img/noimage.jpg';">
<?php }else{ ?>
<img class="img-fluid rounded" src="http://placehold.it/900x300" alt="">
<?php } ?>
<hr>
<!-- Post Content -->
<?php
if($_SESSION['lang'] === 'en'){
?>
<!-- <div style="background: #eceae8;border-radius: 5px;padding: 4px;">
<button style="color: #f7fdff;background-color: #676b6a;" type="button" onclick="readText()" class="btn play-word">
<i class="fa fa-play-circle"></i>
</button>
<button style="color: #f75555;background-color: #686b6a;" type="button" onclick="stopText()" class="btn stop-word">
<i class="fa fa-stop-circle"></i>
</button>
<span style="color: #797777;font-size: 14px;font-family: Monlam;">Text to Read in English</span>
<script>
var currentSpeech = null;
function readText() {
if (window.speechSynthesis.speaking || window.speechSynthesis.paused) {
return; // Already speaking or paused, so do nothing.
}
var textElement = document.getElementById('textToRead');
var text = textElement.textContent || textElement.innerText;
var speech = new SpeechSynthesisUtterance(text);
speech.lang = 'en-US'; // Set language to English
currentSpeech = speech; // Keep a reference to the current speech
window.speechSynthesis.speak(speech);
}
function stopText() {
if (window.speechSynthesis.speaking || window.speechSynthesis.paused) {
window.speechSynthesis.cancel(); // This will stop the speech
currentSpeech = null;
}
}
speechSynthesis.onvoiceschanged = function () {
// Voices are loaded, you can now set a specific voice if needed.
};
</script>
</div> -->
<audio style="width: 100%;" controls>
<?php
$ensound = $post['sound'];
$ensound = str_ireplace("GP", "EP", $ensound);
?>
<source src="<?php echo $ensound; ?>" type="audio/mp3">
</audio>
<?php
}else if($_SESSION['lang'] === 'bo'){
?>
<audio style="width: 100%;" controls>
<source src="<?php echo $post['sound']; ?>" type="audio/mp3">
Your browser does not support the audio element.
</audio>
<?php
}
?>
<div id="textToRead" style="line-height: 30px; padding: 0px 0px 100px 0px; text-align: justify; font-family: 'Monlam', Arial, sans-serif; font-size: 15px;" class="content">
<?php echo $web_content; ?>
</div>
<div>
<hr>
<!-- <h5 style="padding-bottom: 30px;" >རྟགས་རིས་ཁ་བྱང་། (QR)</h5> -->
<!-- <script>
let msg; // Define outside to make it reusable
function populateVoiceList() {
var voices = window.speechSynthesis.getVoices();
var voiceSelect = document.getElementById('voiceSelection');
voices.forEach((voice, index) => {
var option = document.createElement('option');
option.textContent = voice.name + ' (' + voice.lang + ')';
// Optionally, try to infer gender from the voice name
if (voice.name.toLowerCase().includes('female') || voice.name.toLowerCase().includes('woman')) {
option.textContent += ' - Female';
} else if (voice.name.toLowerCase().includes('male') || voice.name.toLowerCase().includes('man')) {
option.textContent += ' - Male';
}
option.setAttribute('value', index);
voiceSelect.appendChild(option);
});
}
function speakText() {
// Stop current speech if any
window.speechSynthesis.cancel();
// Get the selected voice
var selectedVoiceIndex = document.getElementById('voiceSelection').value;
var voices = window.speechSynthesis.getVoices();
// Get the text from the div
var text = document.getElementById("textToRead").innerText;
// Create a new speech synthesis utterance with the selected voice
msg = new SpeechSynthesisUtterance(text);
msg.voice = voices[selectedVoiceIndex];
// Speak the text
window.speechSynthesis.speak(msg);
}
// Populate voice list when voices are loaded
window.speechSynthesis.onvoiceschanged = populateVoiceList;
function stopText() {
// Stop the speech synthesis
window.speechSynthesis.cancel();
}
function reReadText() {
// Stop the current speech and start over
speakText();
}
</script> -->
</div>
<?php
require_once 'vendor/phpqrcode/qrlib.php';
if(isset($post['slug'])){
$text =$baseUrl.'/organization.php?url='.$post['slug'].'';
$qtex = str_replace(" ", "",$text);
// Start output buffering
ob_start();
// Generate the QR code and output it directly to the buffer
QRcode::png($text, null, QR_ECLEVEL_L, 3, 2);
// Capture the buffered output into a variable
$imageString = ob_get_contents();
// Clean (erase) the output buffer and turn off output buffering
ob_end_clean();
// Encode the image in base64 format
$imageData = base64_encode($imageString);
// Generate the HTML code for the image
?>
<div style="text-align: center;">
<?php
//echo '<img src="data:image/png;base64,' . $imageData . '" />';
?>
</div>
<?php
}
?>
<div style="padding-bottom: 200px;">
</div>
</div>
<?php include('includes/sidebar-tensum.php'); ?>
</div>
<!-- /.row -->
</div>
<!-- /.container -->
<?php include('includes/footer.php'); ?>