-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.php
98 lines (76 loc) · 2.7 KB
/
index.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
<?php
include 'TagCloudGenerator.inc.php';
$tagCloudGenerator= new TagCloudGenerator();
if (isset($_POST['theWords'])){
$gematria = array ('A' => 1, 'B' => 2, 'C' => 3, 'D' => 4, 'E' => 5, 'F' => 6, 'G' => 7, 'H' => 8, 'I' => 9, 'J' => 1, 'K' => 2, 'L' => 3, 'M' => 4, 'N' => 5, 'O' => 6, 'P' => 7, 'Q' => 8, 'R' => 9, 'S' => 1, 'T' => 2, 'U' => 3, 'V' => 4, 'W' => 5, 'X' => 6, 'Y' => 7, 'Z' => 8,);
$theWords = $_POST['theWords'];
if (is_numeric($theWords)) {
$result = word_cloud(query_numeric(db_connection(),$theWords));
$result['value'] = $theWords;
} else {
$originalEntry = $theWords;
$theValue = value_from_word($theWords);
$result = word_cloud(query_numeric(db_connection(),$theValue));
$result['value'] = $theValue;
}
} else {
$result = Array ('value' => 0);
}
$output = '';
$output = $output . 'Value: ' . $result['value'] . '<br/>' . output_for_words($result) . '<br/>' . output_for_phrases($result);
require 'render.php';
function output_for_phrases($result){
global $tagCloudGenerator;
$output = '';
if (isset($result['phrases'])){
foreach($result['phrases'] as $phrase){
$output = $tagCloudGenerator->generateTagCloudFromString($phrase,'');
}
}
return $output;
}
function output_for_words($result){
global $tagCloudGenerator;
if (isset($result['words'])){
$output = $tagCloudGenerator->generateTagCloudFromText(implode(' ',$result['words']));
} else {
$output = '';
}
return $output;
}
function db_connection(){
require("eqcalc-settings.php");
$connection=mysql_connect($host,$user,$password) or die("could not connect to server");
$dbconn=mysql_select_db($database,$connection) or die("could not connect to database");
return $connection;
}
function query_numeric($connection,$theWords){
return mysql_query("SELECT * FROM qaballah WHERE thevalue = ".$theWords." ORDER BY thetext",$connection);
}
function word_cloud($matches){
$words=Array(); $phrases=Array();
while ($row1=mysql_fetch_array($matches))
{
extract($row1);
if (strpos($thetext," ")) {
$phrases[count($phrases)] = $thetext;
} else {
$words[count($words)] = $thetext;
}
}
require_once("TagCloudGenerator.inc.php");
$tagCloudGenerator= new TagCloudGenerator();
$result['words'] = $words;
$result['phrases'] = $phrases;
return $result;
}
function value_from_word($theWords){
global $gematria;
$theWords = strtoupper(preg_replace('/[^a-zA-Z]+/', '', $theWords));
$theNumber = 0;
for ($i=0; $i < strlen($theWords); $i++) {
$theNumber = $theNumber + $gematria[substr($theWords,$i,1)];
}
return $theNumber;
}
?>