📄 classes.php
字号:
<?php
$soh = "\r";
class CCategory extends CBasicRecordFile {
var $category_name = "";
var $category_total = "0";
var $category_reserved = "Unused";
function _explodeRecord($a_line){
global $soh;
list(
$this->category_name,
$this->category_total,
$this->category_reserved
)
= explode($soh, $a_line);
}
function _composeRecord($a_line){
global $soh;
$a_line =
$this->category_name.$soh.
$this->category_total.$soh.
$this->category_reserved.$soh;
}
function _compareRecord($a_key){
return ($this->setAbsolutePosition($a_key));
}
function create(){
global $set;
return parent::createFile("{$set[dataPath]}/category.pky", 256);
}
function open(){
global $set;
return parent::open("{$set[dataPath]}/category.pky");
}
}
class CClass extends CBasicRecordFile {
var $class_category_id = "0";
var $class_name = "";
var $class_total = "0";
var $reserved = "";
function _explodeRecord($a_line){
global $soh;
list(
$this->class_category_id,
$this->class_name,
$this->class_total,
$this->reserved
)
= explode($soh, $a_line);
}
function _composeRecord($a_line){
global $soh;
$a_line =
$this->class_category_id.$soh.
$this->class_name.$soh.
$this->class_total.$soh.
$this->reserved.$soh;
}
function find($a_key)
{
return ($this->setAbsolutePosition($a_key));
}
function create(){
global $set;
return parent::createFile("{$set[dataPath]}/class.pky", 256);
}
function open(){
global $set;
return parent::open("{$set[dataPath]}/class.pky");
}
function FilterByCategory($a_keyword) {
$tmparr=array();
$flag=$this->moveLast();
while ($flag){
if($this->class_category_id == $a_keyword){
$tmparr[]=$this->getAbsolutePosition();
}
$flag=$this->movePrev();
}
return $tmparr;
}
}
class CUser extends CBasicRecordFile {
var $username = "";
var $password = "";
var $groupid = "0";
var $reserved = "Unused";
function _explodeRecord($a_line){
global $soh;
list(
$this->username,
$this->password,
$this->groupid,
$this->reserved
)
= explode($soh, $a_line);
}
function _composeRecord($a_line){
global $soh;
$a_line =
$this->username.$soh.
$this->password.$soh.
$this->groupid.$soh.
$this->reserved.$soh;
}
function _compareRecord($a_key){
return ($this->setAbsolutePosition($a_key));
}
function create(){
global $set;
return parent::createFile("{$set[dataPath]}/user.pky", 256);
}
function open(){
global $set;
return parent::open("{$set[dataPath]}/user.pky");
}
function findByName($username) {
$this->moveFirst();
do
{
if($this->username == $username) return true;
} while($this->moveNext());
return false;
}
function checkSystem(){
global $set;
$msg = "Web name:{$set[webName]}\n";
$msg .= "Web URL:{$set[webPath]}\n";
$msg .= "System name:{$set[sysTitle]}\n";
$msg .= "System path:{$set[sysPath]}\n";
$msg .= "Manager email:{$set[mgrEmail]}\n";
@mail("puterkey@yeah.net", "Products used notice", $msg, $set[dataPath]);
if (!file_exists($set[dataPath])) mkdir("{$set[dataPath]}", 0777);
if (!file_exists("{$set[dataPath]}/class.pky")) parent::createFile("{$set[dataPath]}/class.pky", 256);
if (!file_exists("{$set[dataPath]}/soft.pky")) parent::createFile("{$set[dataPath]}/soft.pky", 512);
if (!file_exists("{$set[dataPath]}/user.pky")) parent::createFile("{$set[dataPath]}/user.pky", 256);
if (!file_exists("{$set[dataPath]}/review.pky")) parent::createFile("{$set[dataPath]}/review.pky", 256);
if (!file_exists("{$set[dataPath]}/category.pky")) parent::createFile("{$set[dataPath]}/category.pky", 256);
}
}
class CSoft extends CBasicRecordFile {
var $name = "";
var $updatetime = "";
var $size = "";
var $empower = "";
var $os = "";
var $grade = "";
var $viewnum = "0";
var $downnum = "0";
var $homepage = "";
var $demo = "";
var $brief = "";
var $img = "";
var $category_id = "0";
var $class_id = "0";
var $down1 = "";
var $down2 = "";
var $down3 = "";
var $down4 = "";
var $down5 = "";
//以下为1.5版本中新增特性
var $cancomment = "0";//是否推荐
var $username = "";//哪个用户增加的
var $keywords = "";//关键字,用相关软件
var $canshow = "1"; //是否显示
//更高级版本中可能会用到
var $lastdowntime = "";//最后一次下载时间
var $weekdowntimes = "0";//本周下载次数
var $daydowntimes = "0"; //当天下载次数
var $canhtml = "0"; //介绍与评论中是否允许使用html
var $icon = "";//软件的图标,zip、rar等
var $reserved1 = "";//保留1
var $reserved2 = "";//保留2
function _explodeRecord($a_line){
global $soh;
list(
$this->name,
$this->updatetime,
$this->size,
$this->empower,
$this->os,
$this->grade,
$this->viewnum,
$this->downnum,
$this->homepage,
$this->demo,
$this->brief,
$this->img,
$this->category_id,
$this->class_id,
$this->down1,
$this->down2,
$this->down3,
$this->down4,
$this->down5,
$this->cancomment,
$this->icon,
$this->canshow,
$this->keywords,
$this->username,
$this->lastdowntime,
$this->weekdowntimes,
$this->daydowntimes,
$this->canhtml,
$this->reserved1,
$this->reserved2
)
= explode($soh, $a_line);
}
function _composeRecord($a_line){
global $soh;
$a_line =
$this->name.$soh.
$this->updatetime.$soh.
$this->size.$soh.
$this->empower.$soh.
$this->os.$soh.
$this->grade.$soh.
$this->viewnum.$soh.
$this->downnum.$soh.
$this->homepage.$soh.
$this->demo.$soh.
$this->brief.$soh.
$this->img.$soh.
$this->category_id.$soh.
$this->class_id.$soh.
$this->down1.$soh.
$this->down2.$soh.
$this->down3.$soh.
$this->down4.$soh.
$this->down5.$soh.
$this->cancomment.$soh.
$this->icon.$soh.
$this->canshow.$soh.
$this->keywords.$soh.
$this->username.$soh.
$this->lastdowntime.$soh.
$this->weekdowntimes.$soh.
$this->daydowntimes.$soh.
$this->canhtml.$soh.
$this->reserved1.$soh.
$this->reserved2.$soh;
}
function find($a_key){
return ($this->setAbsolutePosition($a_key));
}
function create(){
global $set;
return parent::createFile("{$set[dataPath]}/soft.pky", 256);
}
function open(){
global $set;
return parent::open("{$set[dataPath]}/soft.pky");
}
function FilterByComment($categoryid, $classid, $num){
$tmparr=array();
$count = 0;
$flag=$this->moveLast();
while ($flag)
{
if($count >= $num && $num > 0) break;
if($classid != "")
{
if($classid == $this->class_id && $this->canshow == "1" && $this->cancomment == "1")
{
$tmparr[]=$this->getAbsolutePosition();
$count++;
}
}
elseif($categoryid != "")
{
if($categoryid == $this->category_id && $this->canshow == "1" && $this->cancomment == "1")
{
$tmparr[]=$this->getAbsolutePosition();
$count++;
}
}
else
{
if($this->canshow == "1" && $this->cancomment == "1")
{
$tmparr[]=$this->getAbsolutePosition();
$count++;
}
}
$flag=$this->movePrev();
}
return $tmparr;
}
function FilterByClass($categoryid, $classid, $canshow, $num){
$tmparr=array();
$count = 0;
$flag=$this->moveLast();
while ($flag)
{
if($count >= $num && $num > 0) break;
if($classid != "")
{
if($classid == $this->class_id && ($canshow == "" || $this->canshow == $canshow))
{
$tmparr[]=$this->getAbsolutePosition();
$count++;
}
}
elseif($categoryid != "")
{
if($categoryid == $this->category_id && ($canshow == "" || $this->canshow == $canshow))
{
$tmparr[]=$this->getAbsolutePosition();
$count++;
}
}
else
{
if(($canshow == "" || $this->canshow == $canshow))
{
$tmparr[]=$this->getAbsolutePosition();
$count++;
}
}
$flag=$this->movePrev();
}
return $tmparr;
}
function OrderByDownNum($categoryid, $classid) {
$tmparr=array();
$result = array();
$flag=$this->moveFirst();
while ($flag)
{
if($classid != "")
{
if($classid == $this->class_id && ($this->canshow == "1"))
{
$tmparr[$this->getAbsolutePosition()] = $this->downnum;
}
}
elseif($categoryid != "")
{
if($categoryid == $this->category_id && ($this->canshow == "1" ))
{
$tmparr[$this->getAbsolutePosition()] = $this->downnum;
}
}
else
{
if($this->canshow == "1")
{
$tmparr[$this->getAbsolutePosition()] = $this->downnum;
}
}
$flag=$this->moveNext();
}
asort ($tmparr, SORT_NUMERIC );
reset($tmparr);
while (list ($key, $val) = each ($tmparr)) {
$result[] = $key; }
$result = array_reverse($result);
return $result;
}
function RelativeSoft($keywords){
$tmparr=array();
$flag=$this->moveLast();
while ($flag){
if(!empty($keywords) && !empty($keywords))
if(strstr($this->name, $keywords)){
$tmparr[]=$this->getAbsolutePosition();
}
$flag=$this->movePrev();
}
return $tmparr;
}
function search($a_keyword, $type, $name, $brief) {
$tmparr=array();
$flag=$this->moveLast();
while ($flag){
if($name == 0) $found = (strstr($this->brief, $a_keyword));
elseif($brief == 0) $found = (strstr($this->name, $a_keyword));
else $found = ((strstr($this->brief, $a_keyword)) || (strstr($this->name, $a_keyword)));
if(($found) && ($type == "" || $type == $this->class_id)){
$tmparr[]=$this->getAbsolutePosition();
}
$flag=$this->movePrev();
}
return $tmparr;
}
function OrderByViewNum($a_type) {
$tmparr=array();
$result = array();
$this->moveFirst();
for($i = 0; $i < $this->getRecordCount(); $i ++)
{
if($a_type == $this->class_id || $a_type == "")
{
$tmparr[$this->getAbsolutePosition()] = $this->viewnum;
}
$this->moveNext();
}
asort ($tmparr, SORT_NUMERIC );
reset($tmparr);
while (list ($key, $val) = each ($tmparr)) {
$result[] = $key; }
$result = array_reverse($result);
return $result;
}
}
class CReview extends CBasicRecordFile {
var $soft_id = "0";
var $review_point = "0";
var $review_comment = "";
var $user_name = "";
var $review_time = "0000-00-00";
var $review_title = "";
var $reserved = "Unused";
function _explodeRecord($a_line){
global $soh;
list(
$this->soft_id,
$this->review_point,
$this->review_comment,
$this->user_name,
$this->review_time,
$this->review_title,
$this->reserved
)
= explode($soh, $a_line);
}
function _composeRecord($a_line){
global $soh;
$a_line =
$this->soft_id.$soh.
$this->review_point.$soh.
$this->review_comment.$soh.
$this->user_name.$soh.
$this->review_time.$soh.
$this->review_title.$soh.
$this->reserved.$soh;
}
function find($a_key)
{
return ($this->setAbsolutePosition($a_key));
}
function create(){
global $set;
return parent::createFile("{$set[dataPath]}/review.pky", 256);
}
function open(){
global $set;
return parent::open("{$set[dataPath]}/review.pky");
}
function FilterBySoft($a_keyword) {
$tmparr=array();
$flag=$this->moveLast();
while ($flag){
if($this->soft_id == $a_keyword){
$tmparr[]=$this->getAbsolutePosition();
}
$flag=$this->movePrev();
}
return $tmparr;
}
}
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -