require_once defines php define TITLE_LENGTH 20 function makeTitle con

 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
<?
require_once("defines.php");
define(TITLE_LENGTH,20);
function makeTitle($contents)
{
if ($contents == '') return '[new]';
$pos = strpos($contents,"\n");
$pos2 = strpos($contents,"\r");
if ($pos2 && $pos2 < $pos)
$pos = $pos2;
if (!$pos) $pos = TITLE_LENGTH;
return substr($contents,0,min($pos,TITLE_LENGTH));
}
function makeNewId($user)
{
// ids need to be globally unique... yikes!
return SERVER_ID_PREFIX . $user . getmicrotime();
}
// from php manual
function getmicrotime()
{
$mtime = microtime();
$mtime = explode(" ",$mtime);
$mtime = $mtime[1] + $mtime[0];
return ($mtime);
}
function log_error($message)
{
$fp = fopen("/home/groups/h/ha/handynotes/htdocs/log","a");
//$fp = fopen("d:/matias/handynotes/server/log.log","a");
if (!$fp) return;
//
$date = getdate();
fwrite($fp,"$date[year]-$date[month]-$date[day] $date[hours]:$date[minutes]: ERROR: $message\n");
}
function log_info($message)
{
// $fp = fopen("/home/groups/handynotes/htdocs/log","a");
//$fp = fopen("d:/matias/handynotes/server/log.log","a");
// if (!$fp) return;
// $date = getdate();
// fwrite($fp,"$date[year]-$date[month]-$date[day] $date[hours]:$date[minutes]: INFO: $message\n");
}
function random_password()
{
srand((double) microtime() * 1000000);
for ($i=0;$i<8;$i++)
{
$pass .= chr(rand(97,122));
}
return $pass;
}
?>