Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

php version compatibility

  • Loading branch information...
commit 255a97d72dab5bcb122117770d55f3f7cf2c25c5 1 parent 9aa87be
Bernd Orttenburger authored
Showing with 52 additions and 62 deletions.
  1. +52 −62 web/classes/phphooks.config.php
View
114 web/classes/phphooks.config.php
@@ -1,24 +1,14 @@
<?php
-/**
- * @author eric.wzy@gmail.com
- * @version 1.0
- * @package config
- *
- * @license http://www.gnu.org/copyleft/lesser.html LGPL
+/**
+ * @author eric.wzy@gmail.com
+ * @version 1.0
+ * @package config
+ *
+ * @license http://www.gnu.org/copyleft/lesser.html LGPL
*/
class config {
- #config function interfase:
- #-config
- #-setFile
- #-getError
- #-getLastError
- #-delete
- #-insert
- #-update
- #-openFile
- #-closeFile
- #
+
private $IsFile;
private $FileNew;
private $Error;
@@ -26,8 +16,8 @@ class config {
private $ArrayVars;
public $prefix;
- /**
- * initialization constructor. Called when class is created.
+ /**
+ * initialization constructor. Called when class is created.
*/
function config() {
$this->IsFile = '';
@@ -35,77 +25,77 @@ function config() {
$this->LastError = null;
$this->ArrayVars = array ();
$this->prefix = null;
- } #end function
+ }
- /**
- * @param string $file. check the file is exists, or create a new one.
+ /**
+ * @param string $file. check the file is exists, or create a new one.
*/
function setFile($file) {
$this->IsFile = $file;
- } #end function
+ }
- /**
- * @return $this->Error
+ /**
+ * @return $this->Error
*/
function getError() {
return $this->Error;
- } #end function
+ }
- /**
- * @return $this->LastError
+ /**
+ * @return $this->LastError
*/
function getLastError() {
return $this->LastError;
- } #end function
+ }
- /**
- *
- * @param $var. delete item.
+ /**
+ *
+ * @param $var. delete item.
*/
function delete($var) {
if (isset ( $this->prefix ))
$var = $this->prefix . $var;
unset($this->ArrayVars[$var]);
return true;
- } #end function
+ }
- /**
- * add item.
- *
- * @param sting $var
- * @param sting $value
+ /**
+ * add item.
+ *
+ * @param sting $var
+ * @param sting $value
*/
function insert($var, $value) {
if (isset ( $this->prefix ))
$var = $this->prefix . $var;
$this->ArrayVars[$var] = $value;
return true;
- } #end function
+ }
- /**
- * update item.
- *
- * @param sting $var
- * @param sting $value
+ /**
+ * update item.
+ *
+ * @param sting $var
+ * @param sting $value
*/
function update($var, $value) {
if (isset ( $this->prefix ))
$var = $this->prefix . $var;
- if (array_key_exists($var,$this->ArrayVars))$this->ArrayVars[$var]= $value;
+ if (array_key_exists($var,$this->ArrayVars))$this->ArrayVars[$var]= $value;
return true;
- } #end function
+ }
- /**
- * openfile
+ /**
+ * openfile
*/
function openFile() {
- #get contents of a file into a string
+ #get contents of a file into a string
if (file_exists ( $this->IsFile )) {
$handle = fopen ( $this->IsFile, "r" );
@@ -121,38 +111,38 @@ function openFile() {
$exp = explode ( "=", $c [$s1] );
$exp = array_map ( trim, $exp );
$c1 [$exp [0]] = $exp [1];
- } #end if
+ } //end if
$s1 ++;
- } #end while
+ } //end while
$this->ArrayVars = $c1;
}
return true;
- } #end function
+ }
/**
* closefile
- */
+ */
function closeFile() {
- #prepare string
+ //prepare string
$string = null;
- #add init php file
+ //add init php file
$string = $string . "<?php\n";
- #add comments
+ //add comments
foreach ($this->ArrayVars as $field=>$value) {
if (is_string($value)) $value ='"'.$value.'"';
$string = $string."$".$field." = ".$value.";\n";
- }
+ }
$string = $string . "?>\n";
if (! $handle = fopen ( $this->IsFile, 'w' )) {
return false;
- } #end if
- // Write $somecontent to our opened file.
+ } //end if
+ // Write $somecontent to our opened file.
if (fwrite ( $handle, $string ) === FALSE) {
return false;
- } #end if
+ } //end if
fclose ( $handle );
return true;
- } #end function
-} #end class
+ }
+} //end class
?>
Please sign in to comment.
Something went wrong with that request. Please try again.