Text Database Custom Function Set 0.2 Test Edition

xiaoxiao2021-03-06  58

/ **************************************************

^^^^^^^^ Text database custom function set 0.2 test version ^^^^^^^^^^^

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

This function set is suitable for storing data in a text format, with a single record to separate the text structure database of the library.

Contact method: xbrid@163.com

Technical support: http://phplink.126.com

Copyright: PHP Beginner Alliance, unable to delete copyright information

Program: Xbrid

Modification Date: 2003.04.30

*********************************************************** /

/ *

Instructions:

Note: In the text database, if you use the keyword, this keyword is best to be unique, otherwise it will only operate the first record when you delete modifications.

TEXT_APPEND ($ filename, $ linecon) → data add functions, return 1 is success, 0 is unsuccessful

TEXT_LOCATE ($ FileName, $ Keyword, $ CUTWORD, $ colnum) → Data Find Function, Returns this record if it is found, otherwise returns 0

TEXT_DELETE ($ FileName, $ Keyword, $ Cutword, $ colnum) → Data Delete function, if you have this record, delete it and return 1, otherwise return 0

TEXT_MODIFY ($ FileName, $ Keyword, $ Cutword, $ colnum, $ modify) → Data modification function, if there is this record and modify successfully returns 1, otherwise return 0

TEXT_INSERT ($ FileName, $ Keyword, $ Cutword, $ colnum, $ insert) → Data insert function, inserted in front of keyword records

TEXT_INSERTB ($ FileName, $ Keyword, $ Cutword, $ colnum, $ insert) → Data insert function, inserted before keyword record

TEXT_SORT ($ FileName, $ Cutword, $ Colnum, $ Mode) → Data Sort Function, the file coverage generated after the file is sorted

TEXT_SELECT ($ FileName, $ Keyword, $ Cutword, $ colnum) → Multi-record lookup functions, return multiple records with keywords

TEXT_FIND ($ FileName, $ Keyword, $ Cutword, $ colnum) → Fuzzy query function, return all records with keywords in the field

$ filename → file name

$ Linecon → To add content

$ Keyword → Find or delete the keywords used in operation, this keyword is unique.

$ cutword → separator

$ colnum → Keyword (field) is located, column is ranked from 0

$ modify → To modify the content

The modified or appended content is in line with the format applicable to this function library.

* /

// Database add function

Function TEXT_APPEND ($ FileName, $ LineCon)

{

$ fp = fopen ($ filename, "a");

FLOCK ($ FP, 2);

$ file = fwrite ($ FP, $ LINECON);

Fclose ($ fp);

Return $ FILE;

}

// Text Database Find Function → Result is to return the first record

Function TEXT_LOCATE ($ FileName, $ Keyword, $ Cutword, $ colnum)

{

$ fileList = file ($ filename);

$ listNum = count ($ fileList); for ($ I = 0; $ i <$ listnum; $ i ) {

$ list = evLode ($ Cutword, $ fileList [$ I]);

IF ($ keyword == $ list [$ colnum]) {

RETURN $ LIST;

}

}

Return 0;

}

// Text Database Delete Record Function

Function TEXT_DELETE ($ FileName, $ Keyword, $ Cutword, $ colnum)

{

$ fileList = file ($ filename);

$ listnum = count ($ fileList);

$ fp = fopen ($ filename, "w");

FLOCK ($ FP, 2);

$ yesno = 1;

For ($ I = 0; $ i <$ listnum; $ i ) {

$ list = evLode ($ Cutword, $ fileList [$ I]);

IF ($ keyword == $ list [$ colnum] and $ yesno == 1) {

$ yesno = 0;

$ RETURNKEY = 1;

CONTINUE;

}

FPUTS ($ FP, $ FILELIST [$ I]);

}

Fclose ($ fp);

IF (Empty ($ RETURNKEY)) $ RETURNKEY = 0;

Return $ RETURNKEY;

}

// Text Database Modify Record Function

Function TEXT_MODIFY ($ Filename, $ Keyword, $ Cutword, $ Colnum, $ modify

{

$ fileList = file ($ filename);

$ listnum = count ($ fileList);

$ fp = fopen ($ filename, "w");

FLOCK ($ FP, 2);

$ yesno = 1;

For ($ I = 0; $ i <$ listnum; $ i ) {

$ list = evLode ($ Cutword, $ fileList [$ I]);

IF ($ keyword == $ list [$ colnum] and $ yesno == 1) {

FPUTS ($ FP, $ Modify);

$ yesno = 0;

$ RETURNKEY = 1;

CONTINUE;

}

FPUTS ($ FP, $ FILELIST [$ I]);

}

Fclose ($ fp);

IF (Empty ($ RETURNKEY)) $ RETURNKEY = 0;

Return $ RETURNKEY;

}

// Text Database Insert Record Function → Insert in front of the keyword record

Function TEXT_INSERT ($ Filename, $ Keyword, $ Cutword, $ colnum, $ insert)

{

$ fileList = file ($ filename);

$ listnum = count ($ fileList);

$ fp = fopen ($ filename, "w");

FLOCK ($ FP, 2);

For ($ I = 0; $ i <$ listnum; $ i ) {

$ list = evLode ($ Cutword, $ fileList [$ I]);

IF ($ keyword == $ list [$ colnum]) {

FPUTS ($ FP, $ INSERT);

}

FPUTS ($ FP, $ FILELIST [$ I]);

}

Fclose ($ fp);

}

// Text Database Insert Record Function → Insert inserted back with keyword record

Function TEXT_INSERTB ($ FileName, $ Keyword, $ Cutword, $ colnum, $ insert) {

$ fileList = file ($ filename);

$ listnum = count ($ fileList);

$ fp = fopen ($ filename, "w");

FLOCK ($ FP, 2);

For ($ I = 0; $ i <$ listnum; $ i ) {

FPUTS ($ FP, $ FILELIST [$ I]);

$ list = evLode ($ Cutword, $ fileList [$ I]);

IF ($ keyword == $ list [$ colnum]) {

FPUTS ($ FP, $ INSERT);

$ RETURNKEY = 1;

}

}

Fclose ($ fp);

IF (Empty ($ RETURNKEY)) $ RETURNKEY = 0;

Return $ RETURNKEY;

}

// Text Database Sort

Function TEXT_SORT ($ FileName, $ Cutword, $ Colnum, $ MODE

{

$ list = file ($ filename);

For ($ I = 0; $ i

$ LIST1 = EXPLODE ($ CUTWORD, $ LIST [$ I]);

$ LIST2 [($ LIST [$ I])] = $ list1 [$ colnum];

}

IF ($ mode == "a") {

@asort ($ lis);

@RESET ($ LIST2);

}

IF ($ mode == "d") {

@arsort ($ list2);

@RESET ($ LIST2);

}

For ($ all = 0; $ all <= count ($ list2); $ all ) {

$ newlist [] = key ($ list2);

IF (! ($ list2))).

}

$ fp = fopen ($ filename, "w");

FLOCK ($ FP, 2);

$ listnum = count ($ newlist);

For ($ I = 0; $ i <$ listnum; $ i ) {

FPUTS ($ FP, $ NEWLIST [$ I]);

}

Fclose ($ fp);

}

// Text Database Multiple Record Find Functions → Returns all the same data as keywords

Function TEXT_SELECT ($ FileName, $ Keyword, $ Cutword, $ colnum)

{

$ fileList = file ($ filename);

$ listnum = count ($ fileList);

For ($ I = 0; $ i <$ listnum; $ i ) {

$ list = evLode ($ Cutword, $ fileList [$ I]);

IF ($ keyword == $ list [$ colnum]) {

$ newlist [] = $ fileList [$ I];

}

}

IF (Empty ($ newlist)) Return 0;

Else Return $ newlist;

}

// Text Database Find Find Functions → Returns all data containing keywords

Function TEXT_FIND ($ FileName, $ Keyword, $ Cutword, $ colnum)

{

$ fileList = file ($ filename);

$ listnum = count ($ fileList);

For ($ I = 0; $ i <$ listnum; $ i ) {

$ list = evdode ($ cutword, $ filelist [$ I]); if (EREGI ($ Keyword, $ LIST [$ colnum])) {

$ newlist [] = $ fileList [$ I];

}

}

IF (Empty ($ newlist)) Return 0;

Else Return $ newlist;

}

/ / Customized array sort

Function Array_sort ($ list, $ cutword, $ colnum, $ mode)

{

For ($ I = 0; $ i

$ LIST1 = EXPLODE ($ CUTWORD, $ LIST [$ I]);

$ list2 [$ list [$ I]] = $ list1 [$ colnum];

}

IF ($ mode == "a") {

@asort ($ lis);

@RESET ($ LIST2);

}

IF ($ mode == "d") {

@arsort ($ list2);

@RESET ($ LIST2);

}

For ($ all = 0; $ all

$ newlist [] = key ($ list2);

IF (! ($ list2))).

}

Return $ newlist;

}

/ **************************************************

^^^^^^^^ Text database custom function set 0.2 test version ^^^^^^^^^^^

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

This function set is suitable for storing data in a text format, with a single record to separate the text structure database of the library.

Contact method: xbrid@163.com

Technical support: http://phplink.126.com

Copyright: PHP Beginner Alliance, unable to delete copyright information

Program: Xbrid

Writing Date: 2003.04.30

*********************************************************** /

/ *

Instructions:

TEXT_APPEND ($ FileName, $ Linecon) → Data Additional Function

$ filename is the file name, $ linecon is the content to be added, this content is the same as the file's separation format

Function return value: 1 is successful, 0 is unsuccessful.

TEXT_LOCATE ($ FileName, $ KEYWORD, $ CUTWORD, $ colnum) → Data Find Function

$ filename is the file name, $ keyword is a search keyword, $ cutword is a separator, $ colnum is the column where the keyword is located, the start number of the segment is 0

Function Return Value: There is this record returns an array of this record (data separated by separator), otherwise returns 0

Note: The returned data value is a field value, which records the first record of the results in the database.

TEXT_DELETE ($ FileName, $ Keyword, $ Cutword, $ colnum) → Data Delete function, the keyword is unique, otherwise all the same records as keywords will be removed

$ filename For the file name, $ keyword is deleted keyword, $ cutword is separator, $ colnum is the column where the keyword is located, the start number of the segment is 0

Function return value: There is this record delete and returns 1, otherwise returns 0

TEXT_MODIFY ($ FileName, $ Keyword, $ Cutword, $ colnum, $ modify) → Data modification function $ filename is the file name, $ keyword is a modified keyword, $ cutword is a separator, $ colnum is the list of keywords, The start number of the column is 0

$ modify is the same after the modification, the format should be the same as the file separation format.

Function return value: There is this record modified and returned 1, otherwise returns 0

This function does not change this record

TEXT_INSERT ($ FileName, $ Keyword, $ Cutword, $ colnum, $ insert) → Data insert function, insertion position in front of the keyword

$ filename is the file name, $ keyword is keyword, $ cutword is separator, $ colnum is the column where the keyword is located, the start number of the segment is 0

$ INSERT is the content to be inserted, its format is the same as the file separation format

Function Return Value: There is a keyword record, inserted and returned 1, otherwise no file is modified and returned 0

TEXT_INSERTB ($ FileName, $ Keyword, $ Cutword, $ colnum, $ insert) → Data insert function, insertion position after keyword

$ filename is the file name, $ keyword is a modified keyword, $ cutword is a separator, $ colnum is the column where the keyword is located, the start number of the column is 0

$ INSERT is the content to be inserted, its format is the same as the file separation format

Function Return Value: There is a keyword record, insert and return 1, otherwise it is not modified and returned to 0

TEXT_SORT ($ Filename, $ Cutword, $ Colnum, $ Mode) → Data Sort Function

$ filename is the file name, $ cutword is a separator, $ colnum is the column where the keyword is located, the start number of the column is 0, and the Mode is arranged, and A is descending order.

Function Return Value: This function has no return value. After sorting this file is reordered file override, you should pay attention to this point when using this function.

TEXT_SELECT ($ FileName, $ Keyword, $ Cutword, $ colnum) → Multiple data find functions

$ filename is the file name, $ keyword is a search keyword, $ cutword is a separator, $ colnum is the column where the keyword is located, the start number of the segment is 0

Function Return Value: If there is a keyword record, return all the same record data as the keyword, otherwise returns 0

Note: Returns the recorded data, which is the same as the database's format, and needs to be re-separated.

TEXT_FIND ($ FileName, $ Keyword, $ Cutword, $ colnum) → Data fuzzy query function

$ filename is the file name, $ keyword is a search keyword, $ cutword is a separator, $ colnum is the column where the keyword is located, the start number of the segment is 0

Function Return Value: Returns all recorded data containing this keyword in the Find field, otherwise returns 0

Note: Returns the recorded data, is a plurality of data, which is the same as the format of the database, and needs to be separated.

Array_sort ($ list, $ cutword, $ colnum, $ mode) → "array" sort function

$ list is a group name, $ cutword is a separator, $ colnum is the column where the keyword is located, and the start number of the column is 0, and the $ mode is arranged, A is ascended as ascending D as descending order

Function Return Value: The return value is the array of sorts, the format is the same as before the sort, and the content is displayed, and the resilience is required. * /

?>

转载请注明原文地址:https://www.9cbs.com/read-111740.html

New Post(0)