/
base.php
executable file
·89 lines (87 loc) · 3.68 KB
/
base.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
<?php
/**
* c-datcom_cibp's tables incmpatible: utf8_general_ci, utf8_unicode_ci
* http://dev.mysql.com/doc/refman/5.5/en/charset-unicode-sets.html
* For any Unicode character set, operations performed using the _general_ci collation are faster than those for the _unicode_ci collation.
* For example, comparisons for the utf8_general_ci collation are faster, but slightly less correct, than comparisons for utf8_unicode_ci.
* The reason for this is that utf8_unicode_ci supports mappings such as expansions; that is, when one character compares as equal to combinations of other characters.
* For example, in German and some other languages “ß” is equal to “ss”. utf8_unicode_ci also supports contractions and ignorable characters.
* utf8_general_ci is a legacy collation that does not support expansions, contractions, or ignorable characters. It can make only one-to-one comparisons between characters.
*
* In summary, unicode_ci adheres more strictly to the official Unicode collation algorithms because it respects the rules for expanding characters and the like.
* general_ci is faster, because it looks at every character in isolation.
*
*/
class PamsBase
{
var $url, $divid;
function __construct() {
$this->url = $_SERVER['PHP_SELF'];
}
function get_payment_type() {
$sql = "SELECT distinct payment_type FROM employers order by payment_type";
$result = mysql_query($sql) or die(mysql_error());
echo "\t<option value=''> --------------- </option>\n";
while ($res = mysql_fetch_row($result)) {
echo "\t<option value=\"" . $res[0] . "\">$res[0]</option>\n";
}
mysql_free_result($result);
}
function get_total_rows($sql) {
$res = mysql_query($sql);
return mysql_num_rows($res);
}
function escape($str) {
$order = array("\r\n", "\n", "\r");
$replace = '<br />';
$newstr = str_replace($order, $replace, $str);
if (preg_match("/\'/", $newstr)) $newstr = preg_replace("/\'/", "\\'", $newstr);
if (preg_match("/\"/", $newstr)) $newstr = preg_replace("/\"/", """, $newstr);
return $newstr;
}
function get_date($date) {
return preg_match("/YYYY-MM-DD/i", $date) ? '' : $date;
}
function str_replace_once($search, $replace, $subject)
{
if(($pos = strpos($subject, $search)) !== false) {
$ret = substr($subject, 0, $pos).$replace.substr($subject, $pos + strlen($search));
} else {
$ret = $subject;
}
return($ret);
}
function web_full($subject) {
if (! preg_match("/^http/", $subject)) {
$subject = 'https://'.$subject;
}
return $subject;
}
function web_abbr($subject) {
$pos = strripos($subject, '.');
$h1 = strtolower(substr($subject, 0, $pos));
$f1 = strtolower(substr($subject, $pos+1)); //csv,xls etc
$ret = '';
switch($f1) {
case 'csv':
$ret = '<img src="images/page_excel.png" width="16" height="16" border="0" alt="download csv file ' . $subject .'" />';
break;
case 'xls';
$ret = '<img src="images/page_excel.png" width="16" height="16" border="0" alt="download xls file ' . $subject .'" />';
break;
default:
$ret = '<img src="images/page_excel.png" width="16" height="16" border="0" alt="download file ' . $subject .'" />';
break;
}
return ((strlen($h1)>FILE_LEN) ? substr($h1, 0, FILE_LEN-1).'…'.$f1 : $subject ).' '.$ret;
}
function email_abbr($subject) {
if(! $subject) return '';
return (strlen($subject)>15) ? substr($subject, 0, 14).'…' : $subject;
}
function cutstr($str, $length, $ellipsis='') {
$cut=(array)explode("\n\n",wordwrap($str,$length,"\n\n"));
return $cut[0].((strlen($cut[1])<strlen($str))?$ellipsis:'...');
}
}
?>