File: ct_file.inc

package info (click to toggle)
phplib 2%3A7.2d-3.1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 1,612 kB
  • ctags: 198
  • sloc: php: 6,095; pascal: 186; perl: 95; makefile: 78; sh: 6
file content (78 lines) | stat: -rw-r--r-- 1,546 bytes parent folder | download
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
<?php

##
## Copyright (c) 1999-2000 Oliver Teuber <oliver@teuber.com>
##
## PHPLIB Data Storage Container using Files
##
## Code inspired by ct_dbm.inc 

class CT_File {
    ##
    ## Define these parameters by overwriting or by
    ## deriving your own class from it (recommened)
    ##

    var $file_path = "";  ## Path where to store the session files
                          ## writable by the web server UID

    ## end of configuration
    
    function ac_start() {
        # Not needed in this instance
    }

    function ac_get_lock() {
        # Not needed in this instance
    }

    function ac_release_lock() {
        # Not needed in this instance
    }

    function ac_newid($str, $name) {
        return $str;
    }

    function ac_store($id, $name, $str) {

        $f=fopen($this->file_path . "$id$name",'w+');
        if($f<0)
        {
            return false;
        }
        fputs($f,urlencode($str));
        fclose($f);

        return true;
    }

    function ac_delete($id, $name) {
        unlink($this->file_path."$id$name");
    }

    function ac_gc($gc_time, $name) {
    }

    function ac_halt($s) {
        echo "<b>$s</b>";
        exit;
    }

    function ac_get_value($id, $name) {
        if(file_exists($this->file_path."$id$name"))
        {

            $f=fopen($this->file_path."$id$name",'r');
            if($f<0)
                return '';

            $s=fgets($f,10240);
            fclose($f);
            return urldecode($s);
        }
        else
            return '';
    }
}
?>