]>
src.bluestatic.org Git - bugdar.git/blob - docs/phrasetools.php
1 <!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 <html xmlns
="http://www.w3.org/1999/xhtml" xml
:lang
="en" lang
="en">
5 <meta http
-equiv
="content-type" content
="text/html; charset=iso-8859-1" />
6 <title
>Phrase Tools
</title
>
12 // phrase tools for managing DB phrase system
16 require_once('./global.php');
18 define('SELECTED', ' selected="selected"');
19 define('CHECKED', ' checked="checked"');
21 sanitize(array('varname' => STR
, 'phrasetext' => STR
, 'matchmethod' => STR
, 'do' => STR
));
22 $use['varname'] = (bool)$_REQUEST['use']['varname'];
23 $use['phrasetext'] = (bool)$_REQUEST['use']['phrasetext'];
24 $use['and'] = iff($vars['matchmethod'] == 'and', true, false);
25 $use['or'] = iff($use['and'], false, true);
26 $use['matcher'] = iff($use['and'], 'AND', 'OR');
28 $select['or'] = iff($use['or'], SELECTED
);
29 $select['and'] = iff($use['and'] , SELECTED
);
30 $select['search'] = iff($vars['do'] == 'search', SELECTED
);
31 $select['insert'] = iff($vars['do'] == 'insert', SELECTED
);
32 $select['delete'] = iff($vars['do'] == 'delete', SELECTED
);
34 error_reporting(E_ALL
& ~E_NOTICE
);
36 echo "<h2>Input</h2>\n<pre>\n";
38 echo "\n</pre>\n\n<hr />\n\n";
40 // ###################################################################
45 <form action="phrasetools.php" method="post" name="newphrase">
46 <div><strong>Varname:</strong> <input type="text" name="varname" value="$vars[varname]" size="35" /> <input type="checkbox" name="use[varname]" value="1" checked="checked" /></div>
47 <div><strong>Phrase text:</strong> <input type="checkbox" name="use[phrasetext]" value="1" /></div>
48 <div><textarea name="phrasetext" rows="7" cols="75">$vars[phrasetext]</textarea></div>
50 <strong>Action:</strong>
51 <select name="do"><option value="search"$select[search]>Search</option><option value="insert"$select[insert]>Insert</option><option value="delete"$select[delete]>Delete</option></select>
54 <strong>Match Method:</strong>
55 <select name="matchmethod"><option value="or"$select[or]>* OR *</option><option value="and"$select[and]>+ AND +</option></select>
56 <input type="submit" name="submit" value=" Continue " />
57 <input type="reset" name="reset" value=" Reset " />
64 echo "\n\n<hr />\n\n";
67 // ###################################################################
69 if ($_REQUEST['do'] == 'kill')
71 $DB_sql->query("DELETE FROM " . TABLE_PREFIX
. "phrase WHERE varname = '" . addslasheslike($vars['varname']) . "'");
72 header("Location: phrasetools.php");
75 // ###################################################################
77 if ($_REQUEST['do'] == 'delete')
79 $phrase = $DB_sql->query_first("SELECT * FROM " . TABLE_PREFIX
. "phrase WHERE varname = '" . addslasheslike($vars['varname']) . "'");
82 echo 'Not a valid phrase!';
86 echo "<h2>Delete</h2>\n\n<pre><a href=\"phrasetools.php?do=kill&varname=$phrase[varname]\">Found: <strong>$phrase[varname]</strong> ===> $phrase[phrasetext]</a></pre>";
89 // ###################################################################
91 if ($_POST['do'] == 'insert')
93 $vars['varname'] = str_replace(' ', '_', $vars['varname']);
95 INSERT INTO " . TABLE_PREFIX
. "phrase
98 ('" . addslasheslike($vars['varname']) . "', '" . addslasheslike($vars['phrasetext']) . "'
101 header("Location: phrasetools.php?do=edit&varname=$vars[varname]");
104 // ###################################################################
106 if ($_POST['do'] == 'update')
109 UPDATE " . TABLE_PREFIX
. "phrase
110 SET varname = '" . addslasheslike($vars['varname']) . "',
111 phrasetext = '" . addslasheslike($vars['phrasetext']) . "'
112 WHERE varname = '" . addslasheslike($vars['varname']) . "'"
114 header("Location: phrasetools.php?do=edit&varname=$vars[varname]");
117 // ###################################################################
119 if ($_REQUEST['do'] == 'edit')
121 $phrase = $DB_sql->query_first("SELECT * FROM " . TABLE_PREFIX
. "phrase WHERE varname = '" . addslasheslike($vars['varname']) . "'");
124 echo 'Not a valid phrase!';
131 <form action="phrasetools.php" method="post" name="editphrase">
132 <input type="hidden" name="do" value="update" />
133 <div><strong>Varname:</strong> <input type="text" name="varname" value="$phrase[varname]" size="35" /></div>
134 <div><strong>Phrase text:</strong></div>
135 <div><textarea name="phrasetext" rows="7" cols="75">$phrase[phrasetext]</textarea></div>
137 <input type="submit" name="submit" value=" Continue " />
138 <input type="reset" name="reset" value=" Reset " />
144 // ###################################################################
146 if ($_REQUEST['do'] == 'search')
148 if ($use['varname'] AND !$use['phrasetext'])
150 $where = "varname LIKE '%$vars[varname]%'";
152 else if (!$use['varname'] AND $use['phrasetext'])
154 $where = "phrasetext LIKE '%$vars[phrasetext]%'";
158 $where = "varname LIKE '%$vars[varname]%' $use[matcher] phrasetext LIKE '%$vars[phrasetext]%'";
161 $phrases = $DB_sql->query("SELECT * FROM " . TABLE_PREFIX
. "phrase WHERE $where");
162 $numrows = $DB_sql->num_rows($phrases);
166 echo 'No results found!';
172 while ($phrase = $DB_sql->fetch_array($phrases))
174 echo "<pre
><div
>\$bugsys
->language
['<strong><a href=\"phrasetools.php?do=edit&varname=$phrase[varname]\">$phrase[varname]</a></strong>'] =======> " . htmlspecialcharslike($phrase['phrasetext']) . "</div
></pre
>";
179 $phrase = $DB_sql->fetch_array($phrases);
180 header("Location
: phrasetools
.php
?do=edit
&varname
=$phrase[varname
]");