-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from Deric-W/dev
Dev
- Loading branch information
Showing
5 changed files
with
208 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
session_start | ||
session_abort | ||
session_write_close(session_commit) | ||
session_create_id | ||
session_destroy | ||
session_get_cookie_params | ||
session_id | ||
session_name | ||
session_regenerate_id | ||
session_reset | ||
session_save_path | ||
session_set_cookie_params | ||
session_set_save_handler | ||
session_status | ||
session_gc | ||
session_encode | ||
session_decode | ||
$_SESSION |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/usr/bin/python3 | ||
|
||
"""PyHP cache handler (files with modification time)""" | ||
|
||
import marshal | ||
import os.path | ||
from os import makedirs | ||
|
||
class handler: | ||
def __init__(self, cache_path, file_path): | ||
self.cache_path = os.path.join(cache_path, file_path.strip(os.path.sep) + ".cache") # use full path to allow indentical named files in different directories with cache_path as root | ||
self.file_path = file_path | ||
|
||
def is_outdated(self): # return True if cache is not created or needs refresh | ||
if not os.path.isfile(self.cache_path) or os.path.getmtime(self.cache_path) < os.path.getmtime(self.file_path): | ||
return True | ||
else: | ||
return False | ||
|
||
def load(self): | ||
with open(self.cache_path, "rb") as cache: | ||
cache_content = marshal.load(cache) | ||
if len(cache_content) != 2: | ||
raise ValueError("corrupted cache at " + self.cache_path) | ||
else: | ||
return cache_content[0], cache_content[1] # file_content, code_at_begin | ||
|
||
def save(self, file_content, code_at_begin): | ||
if not os.path.isdir(os.path.dirname(self.cache_path)): # directories not already created | ||
os.makedirs(os.path.dirname(self.cache_path), exist_ok=True) | ||
with open(self.cache_path, "wb") as cache: | ||
marshal.dump([file_content, code_at_begin], cache) | ||
|
||
def close(self): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Configuration for the PyHP Interpreter (https://github.com/Deric-W/PyHP-Interpreter) | ||
# This file uses the INI syntax | ||
|
||
[parser] | ||
opening_tag = \<\?pyhp[\n \t] # regex | ||
closing_tag = [\n \t]\?\> # regex | ||
|
||
[caching] | ||
allow_caching = True | ||
auto_caching = False # ignore -c arg | ||
cache_path = /var/cache/pyhp # path to use | ||
handler = files_mtime | ||
handler_path = /lib/pyhp/cache_handlers # directory containing the handler |
Oops, something went wrong.