Ejemplo n.º 1
0
 public function __construct()
 {
     $this->conex = mysql_connect(Fishbones::getConfig()->dbHost, Fishbones::getConfig()->dbUser, Fishbones::getConfig()->dbPass);
     if (!$this->conex) {
         $error = "database connection error 1";
         $this->error = $error;
         Fishbones::getLog()->writeDatabaseError($error);
         Fishbones::getPump()->outXml($this->makeErrorXml($error));
     }
     $selected = mysql_select_db(Fishbones::getConfig()->dbDatabase, $this->conex);
     if (!$selected) {
         $error = "database selection error 2";
         $this->error = $error;
         Fishbones::getLog()->writeDatabaseError($error);
         Fishbones::getPump()->outXml($this->makeErrorXml($error));
     }
 }
Ejemplo n.º 2
0
 /**
  * keep log file
  * append it to a more permanet one
  * @return boolean true on sucess, false on error
  */
 public function keepLog()
 {
     if (!Fishbones::getConfig()->debugLog) {
         return true;
     }
     $file = fopen(Fishbones::getConfig()->currentPathToStart . Fishbones::getConfig()->currentPathToFishbones . 'logs/' . $this->keepfilename, 'at');
     $logCurrentSize = filesize(Fishbones::getConfig()->currentPathToStart . Fishbones::getConfig()->currentPathToFishbones . 'logs/' . $this->keepfilename);
     if ($logCurrentSize > $this->keepMaxSize) {
         ftruncate($file, 0);
     }
     $logtext = file_get_contents(Fishbones::getConfig()->currentPathToStart . Fishbones::getConfig()->currentPathToFishbones . 'logs/' . $this->filename);
     fwrite($file, "=====================================================================\n");
     fwrite($file, $logtext);
     fwrite($file, "=====================================================================\n");
     fclose($file);
 }
<?php

// fishbones sample webservice:
//
// simple database transaction
// point this to start.php
$pathToStart = '../../start.php';
include $pathToStart;
/////////////////////////////////////////////////////////////////
// log debuging data
Fishbones::getLog()->writeDebug('var1: ' . $_POST['var1']);
Fishbones::getLog()->writeDebug('var2: ' . $_POST['var2']);
//////////////////////////////////////////////////////////////////
// config var
$development = Fishbones::getConfig()->mode == Config::MODE_DEVELOPMENT;
if ($development) {
    Fishbones::getLog()->writeDebug('development: ' . $development);
}
///////////////////////////////////////////////////////////////////////
session_start();
// all post data is escaped for mysql
// see config.php
$itemId = $_POST['wi'];
$groupId = $_POST['si'];
$userId = $_SESSION['userId'];
///////////////////////////////////////////////////////////////////////////
// data validation
if (!ctype_digit($itemId)) {
    Fishbones::getPump()->outXmlErrorString("Invalid data");
}
if (!ctype_digit($groupId)) {
Ejemplo n.º 4
0
<?php

// fishbones starting point
// this var is required
// put Fish folder in a non internet accesable folder for security , and modify the path var below accordingly
$pathToFishbones = 'fishbones/';
// config should come first
include $pathToFishbones . 'Config.php';
// second the core classes
include $pathToFishbones . 'core/Log.php';
include $pathToFishbones . 'core/DB.php';
include $pathToFishbones . 'core/Pump.php';
include $pathToFishbones . 'core/CleanVars.php';
// the Fish class
include $pathToFishbones . 'core/Fishbones.php';
/////////////////////////////////////////////////////////////////////////////////
Fishbones::getConfig()->currentPathToStart = $pathToStart;
Fishbones::getConfig()->currentPathToFishbones = $pathToFishbones;
/////////////////////////////////////////////////////////////////////////////////
if (Fishbones::getConfig()->autoEscapeHttpRequestVars) {
    Fishbones::getCleanVars()->cleanHttpRequestVars();
}
/////////////////////////////////////////////////////////////////////////////////