Пример #1
0
  function getValue()
  {
    $value = $this->base->getValue();

    $locale_value = $this->_getLocale();

    $toolkit =& Limb :: toolkit();
    $locale =& $toolkit->getLocale($locale_value);

    if(isset($this->parameters[2]) && $this->parameters[2]->getValue())
      $fract_digits = $this->parameters[2]->getValue();
    else
      $fract_digits = $locale->fract_digits;

    if(isset($this->parameters[3]) && $this->parameters[3]->getValue())
      $decimal_symbol = $this->parameters[3]->getValue();
    else
      $decimal_symbol = $locale->decimal_symbol;

    if(isset($this->parameters[4]) && $this->parameters[4]->getValue())
      $thousand_separator = $this->parameters[4]->getValue();
    else
      $thousand_separator = $locale->thousand_separator;

    if ($this->isConstant())
      return number_format($value, $fract_digits, $decimal_symbol, $thousand_separator);
    else
      RaiseError('compiler', 'UNRESOLVED_BINDING');
  }
Пример #2
0
  function getValue()
  {
    include_once(LIMB_DIR . '/core/http/Ip.class.php');

    if ($this->isConstant())
      return Ip :: decode($this->base->getValue());
    else
      RaiseError('compiler', 'UNRESOLVED_BINDING');
  }
Пример #3
0
 public function ApplyIdentityToConnectionOptions(&$connectionOptions)
 {
     if ($this->GetCurrentUser() == $this->guestUserName) {
         if ($this->allowGuestAccess) {
             $connectionOptions['username'] = $this->guestServerLogin;
             $connectionOptions['password'] = $this->guestServerPassword;
         } else {
             RaiseError(GetCaptions()->GetMessageString('GuestAccessDenied'));
         }
     } else {
         $connectionOptions['username'] = $this->GetCurrentUser();
         $connectionOptions['password'] = $_COOKIE[UserIdentityCookieStorage::passwordCookie];
     }
 }
Пример #4
0
  function getValue()
  {
    require_once(LIMB_DIR . '/core/i18n/Strings.class.php');

    $locale_value = $this->_getLocale();

    if(isset($this->parameters[0]) && $this->parameters[0]->getValue())
      $file = $this->parameters[0]->getValue();
    else
      $file = 'common';

    $value = $this->base->getValue();

    if ($this->isConstant())
      return  Strings :: get($value, $file, $locale_value);
    else
      RaiseError('compiler', 'UNRESOLVED_BINDING');
  }
Пример #5
0
 public function RenderRecordCardView(RecordCardView $recordCardView)
 {
     $Grid = $recordCardView->GetGrid();
     $linkBuilder = null;
     $primaryKeyMap = array();
     $Grid->GetDataset()->Open();
     $Row = array();
     if ($Grid->GetDataset()->Next()) {
         $linkBuilder = $Grid->CreateLinkBuilder();
         $linkBuilder->AddParameter(OPERATION_PARAMNAME, OPERATION_PRINT_ONE);
         $keyValues = $Grid->GetDataset()->GetPrimaryKeyValues();
         for ($i = 0; $i < count($keyValues); $i++) {
             $linkBuilder->AddParameter("pk{$i}", $keyValues[$i]);
         }
         $primaryKeyMap = $Grid->GetDataset()->GetPrimaryKeyValuesMap();
         $rowValues = $Grid->GetDataset()->GetFieldValues();
         foreach ($Grid->GetSingleRecordViewColumns() as $Column) {
             $columnName = $Grid->GetDataset()->IsLookupField($Column->GetName()) ? $Grid->GetDataset()->IsLookupFieldNameByDisplayFieldName($Column->GetName()) : $Column->GetName();
             $columnRenderResult = '';
             $customRenderColumnHandled = false;
             $Grid->OnCustomRenderColumn->Fire(array($columnName, $Column->GetData(), $rowValues, &$columnRenderResult, &$customRenderColumnHandled));
             $columnRenderResult = $customRenderColumnHandled ? $columnRenderResult : $this->Render($Column);
             $Row[] = $columnRenderResult;
         }
     } else {
         RaiseError('Cannot retrieve single record. Check the primary key fields.');
     }
     $customParams = array();
     $this->DisplayTemplate($Grid->GetPage()->GetCustomTemplate(PagePart::VerticalGrid, PageMode::ModalView, 'view/record_card_view.tpl', $customParams), array('Grid' => $Grid, 'Columns' => $Grid->GetSingleRecordViewColumns()), array_merge($customParams, array('PrintOneRecord' => $Grid->GetPage()->GetPrinterFriendlyAvailable(), 'PrintRecordLink' => $linkBuilder->GetLink(), 'Title' => $Grid->GetPage()->GetShortCaption(), 'PrimaryKeyMap' => $primaryKeyMap, 'ColumnCount' => count($Grid->GetSingleRecordViewColumns()), 'Row' => $Row)));
 }
Пример #6
0
 public function GetViewSingleRowViewData(Renderer $renderer)
 {
     $detailViewData = array();
     $this->GetDataset()->Open();
     $linkBuilder = null;
     if ($this->GetDataset()->Next()) {
         $linkBuilder = $this->CreateLinkBuilder();
         $linkBuilder->AddParameter(OPERATION_PARAMNAME, OPERATION_PRINT_ONE);
         $keyValues = $this->GetDataset()->GetPrimaryKeyValues();
         for ($i = 0; $i < count($keyValues); $i++) {
             $linkBuilder->AddParameter("pk{$i}", $keyValues[$i]);
         }
         $primaryKeyMap = $this->GetDataset()->GetPrimaryKeyValuesMap();
         foreach ($this->details as $detail) {
             $detailViewData[] = array('Link' => $detail->GetSeparateViewLink(), 'Caption' => $detail->GetCaption());
         }
         return array('Details' => $detailViewData, 'CancelUrl' => $this->GetReturnUrl(), 'PrintOneRecord' => $this->GetPage()->GetPrinterFriendlyAvailable(), 'PrintRecordLink' => $linkBuilder->GetLink(), 'Title' => $this->GetPage()->GetShortCaption(), 'PrimaryKeyMap' => $primaryKeyMap, 'Row' => $this->GetViewSingleRowColumnViewData($renderer));
     } else {
         RaiseError('Cannot retrieve single record. Check the primary key fields.');
         return null;
     }
 }
Пример #7
0
		public function LoadTemplate($templatename)
		{
			$templ = @file("{$this->Smarty->template_dir}/{$templatename}");
			if (count($templ) > 0)
			{
				$this->Subject = array_shift($templ);
				$this->Body = $this->Smarty->fetch("string:".implode("", $templ));
			}
			else
				RaiseError(_("Cannot read template {$templatename}"));
		}
Пример #8
0
 public function GetFieldValueAsSQL($fieldInfo, $value)
 {
     if ($fieldInfo->FieldType == ftNumber) {
         $result = str_replace(',', '.', $value);
         if (!is_numeric($result)) {
             RaiseError('Field "' . $fieldInfo->Name . '" must be a number.');
         }
         return $this->EscapeString($result);
     } elseif ($fieldInfo->FieldType == ftDateTime) {
         if (!is_string($value) && get_class($value) == 'SMDateTime') {
             return $this->GetDateTimeFieldValueAsSQL($fieldInfo, $value);
         } else {
             return $this->GetDateTimeFieldValueAsSQL($fieldInfo, SMDateTime::Parse($value, ''));
         }
     } elseif ($fieldInfo->FieldType == ftDate) {
         if (!is_string($value) && get_class($value) == 'SMDateTime') {
             return $this->GetDateFieldValueAsSQL($fieldInfo, $value);
         } else {
             return $this->GetDateFieldValueAsSQL($fieldInfo, SMDateTime::Parse($value, ''));
         }
     } elseif ($fieldInfo->FieldType == ftTime) {
         if (!is_string($value) && get_class($value) == 'SMDateTime') {
             return $this->GetTimeFieldValueAsSQL($fieldInfo, $value);
         } else {
             return $this->GetTimeFieldValueAsSQL($fieldInfo, SMDateTime::Parse($value, ''));
         }
     } elseif ($fieldInfo->FieldType == ftBlob) {
         if (is_array($value)) {
             return '\'' . mysql_escape_string(file_get_contents($value[0])) . '\'';
         } else {
             return '\'' . mysql_escape_string($value) . '\'';
         }
     } else {
         return '\'' . $this->EscapeString($value) . '\'';
     }
 }
Пример #9
0
 public function GetFieldValueAsSQL($fieldInfo, $value)
 {
     if ($fieldInfo->FieldType == ftBoolean) {
         if (!is_numeric($value) || !($value == 0 || $value == 1)) {
             RaiseError("The only valid values for the column {$fieldInfo->Name} are 0 and 1.");
         }
         return $this->EscapeString($value);
     } else {
         return parent::GetFieldValueAsSQL($fieldInfo, $value);
     }
 }
Пример #10
0
 public function Post()
 {
     $this->DoBeforePost();
     if ($this->editMode) {
         if (count($this->editFieldValues) > 0 || count($this->editFieldSetToDefault) > 0) {
             $updateCommand = $this->CreateUpdateCommand();
             $primaryKeyValues = $this->GetOldPrimaryKeyValuesMap();
             foreach ($primaryKeyValues as $keyFieldName => $value) {
                 $updateCommand->SetKeyFieldValue($keyFieldName, $value);
             }
             foreach ($this->editFieldValues as $fieldName => $value) {
                 if (in_array($fieldName, $this->editFieldSetToDefault)) {
                     $updateCommand->SetParameterValue($fieldName, null, true);
                 } else {
                     $updateCommand->SetParameterValue($fieldName, $value);
                 }
             }
             foreach ($this->GetFields() as $field) {
                 if ($field->GetReadOnly()) {
                     $updateCommand->SetParameterValue($field->GetNameInDataset(), $field->GetDefaultValue());
                 }
             }
             if (DebugUtils::GetDebugLevel() >= 1) {
                 echo $updateCommand->GetSQL() . '<br>';
             }
             $updateCommand->Execute($this->GetConnection());
         }
         $this->editMode = false;
     } elseif ($this->insertMode) {
         $hasValuesForAutoIncrement = false;
         $insertCommand = $this->CreateInsertCommand() or RaiseError('Could not create InsertCommand');
         $this->Connect();
         foreach ($this->masterFieldValue as $fieldName => $value) {
             $insertCommand->SetParameterValue($fieldName, $value);
         }
         foreach ($this->insertFieldValues as $fieldName => $value) {
             if (in_array($fieldName, $this->insertFieldSetToDefault)) {
                 if (!$this->GetFieldByName($fieldName)->GetIsAutoincrement()) {
                     $insertCommand->SetParameterValue($fieldName, null, true);
                 }
             } else {
                 if ($this->GetFieldByName($fieldName)->GetIsAutoincrement()) {
                     $hasValuesForAutoIncrement = true;
                 }
                 $insertCommand->SetParameterValue($fieldName, $value);
             }
         }
         foreach ($this->GetFields() as $field) {
             if ($field->GetReadOnly()) {
                 $insertCommand->SetParameterValue($field->GetNameInDataset(), $field->GetDefaultValue());
             }
         }
         foreach ($this->defaultFieldValues as $fieldName => $value) {
             $insertCommand->SetParameterValue($fieldName, $value);
         }
         $insertCommand->SetAutoincrementInsertion($hasValuesForAutoIncrement);
         if (DebugUtils::GetDebugLevel() == 1) {
             echo $insertCommand->GetSQL() . '<br>';
         }
         $insertCommand->Execute($this->GetConnection());
         $this->UpdatePrimaryKeyAfterInserting();
         $this->insertMode = false;
         $this->insertedMode = true;
     }
 }
Пример #11
0
 /**
  * Raises an error, passing it on to the framework level error mechanisms
  * @param string (optional) SQL statement
  * @return void
  * @access private
  */
 function RaiseError($sql = NULL)
 {
     $errno = mysql_errno($this->getConnectionId());
     $id = 'DB_ERROR';
     $info = array('driver' => 'MySQL');
     if ($errno != 0) {
         $info['errorno'] = $errno;
         $info['error'] = mysql_error($this->getConnectionId());
         $id .= '_MESSAGE';
     }
     if (!is_null($sql)) {
         $info['sql'] = $sql;
         $id .= '_SQL';
     }
     RaiseError('db', $id, $info);
 }
Пример #12
0
<?php

try {
    $db_ConnectionString = DB_CONNECTIONSTRING;
    //READ CONNECTIONSTRING FROM CONFIG
    if (strlen(trim($db_ConnectionString)) == 0) {
        throw new Exception(" Connection String not found", 101);
    } else {
        $arrConnectionString = explode(":", $db_ConnectionString);
        if (!is_array($arrConnectionString)) {
            throw new Exception("Invald Connection String ", 102);
        } else {
            if (count($arrConnectionString) != 5) {
                throw new Exception("Invald Connection String ", 102);
            }
        }
    }
    //CREATE DKMANAGER OBJECT
    $objDataHelper = new DataHelper($db_ConnectionString);
    if (!is_object($objDataHelper)) {
        throw new Exception("DataHelper Object did not instantiate", 104);
    }
} catch (Exception $e) {
    RaiseError($_SERVER["PHP_SELF"], $e->getCode(), $e->getMessage());
}
Пример #13
0
 /**
  * Raises an error, passing it on to the framework level error mechanisms
  * @param string (optional) SQL statement
  * @return void
  * @access private
  */
 function RaiseError($error = NULL, $sql = NULL)
 {
     if (empty($error)) {
         $error =& $this->getConnectionId();
     }
     $id = 'DB_ERROR';
     $info = array('driver' => 'mdb2');
     if (MDB2::isError($error)) {
         $errno = $error->getCode();
         if ($errno != -1) {
             $info['errorno'] = $errno;
             $info['error'] = $error->getMessage();
             $id .= '_MESSAGE';
         }
     }
     if (!is_null($sql)) {
         $info['sql'] = $sql;
         $id .= '_SQL';
     }
     RaiseError('db', $id, $info);
 }
Пример #14
0
function Do_Work()
{
    global $settings;
    global $need_reload;
    global $px_Setops;
    global $res_str;
    pluginload();
    $vDir = './farmville-logs';
    if (!file_exists($vDir)) {
        mkdir($vDir);
    }
    $time_limit = 7 * 24 * 60 * 60;
    // number of seconds to 'keep' the log DAYSxHOURSxMINSxSECS
    if ($df = opendir($vDir)) {
        while (false !== ($file = readdir($df))) {
            if ($file != "." && $file != "..") {
                $file1 = $vDir . '/' . $file;
                $last_modified = filemtime($file1);
                if (time() - $last_modified > $time_limit) {
                    unlink($file1);
                }
            }
        }
        closedir($df);
    }
    while (file_exists('notrun_parser.txt') || file_exists('notrun_parser_' . $_SESSION['userId'] . '.txt')) {
        AddLog2("Bot Paused. Next check in 30 seconds.");
        sleep(30);
    }
    parse_neighbors();
    parse_user();
    AddLog2("Beginning Bot Cycle");
    Hook('before_work');
    // Init
    $res = DoInit('full');
    if ($res != 'OK') {
        RaiseError(2);
    } else {
        $res_str = '';
        //for main logs
    }
    Hook('before_load_settings');
    // load settings
    if (!function_exists('LoadSavedSettings')) {
        die("\n\nSettings plugin installed incorrectly no LoadSavedSettings found!\n\n");
    }
    $px_Setopts = LoadSavedSettings();
    $enable_lonlyanimals = $px_Setopts['lonlyanimals'];
    Hook('after_load_settings');
    if ($enable_lonlyanimals) {
        AddLog2("check lonlyanimal");
        Do_Check_Lonlyanimals();
    }
    Hook('flybiplane');
    Hook('before_harvest');
    Hook('harvest');
    Hook('after_harvest');
    Hook('before_harvest_buildings');
    Hook('harvest_buildings');
    Hook('after_harvest_buildings');
    //after building harvest
    Hook('before_harvest_animals');
    //get product from livestock
    Hook('harvest_animals');
    Hook('after_harvest_animals');
    Hook('before_transform_animals');
    Hook('transform_animals');
    Hook('after_transform_animals');
    Hook('before_harvest_trees');
    Hook('harvest_trees');
    Hook('after_harvest_trees');
    Hook('before_hoe');
    Hook('hoe');
    Hook('after_hoe');
    Hook('before_before_planting');
    Hook('before_planting');
    Hook('planting');
    Hook('after_planting');
    Hook('after_work');
    Parser_Check_Images();
    AddLog2("Peak Memory Usaged: " . round(memory_get_peak_usage(true) / 1024 / 1024, 2) . "MB");
    AddLog2("Finished Bot Cycle");
}
Пример #15
0
function RaiseCannotRetrieveSingleRecordError()
{
    RaiseError('Cannot retrieve single record. Check the primary key fields.');
}
Пример #16
0
ini_set('memory_limit', '128M');
/* Used to determine output to display */
define('DW_TESTS_OUTPUT_HTML', 1);
define('DW_TESTS_OUTPUT_XML', 2);
if (isset($_GET['output']) && $_GET['output'] == 'xml') {
    define('DW_TESTS_OUTPUT', DW_TESTS_OUTPUT_XML);
} else {
    define('DW_TESTS_OUTPUT', DW_TESTS_OUTPUT_HTML);
}
require_once 'lib/testmanager.php';
TestManager::setup('tests.ini');
if (!defined('SIMPLE_TEST')) {
    define('SIMPLE_TEST', ConfigManager::getOptionAsPath('tests', 'simpletest', 'library_path'));
}
if (!@(include_once SIMPLE_TEST . 'reporter.php')) {
    RaiseError('runtime', 'LIBRARY_REQUIRED', array('library' => 'Simple Test', 'path' => SIMPLE_TEST));
}
function &DW_TESTS_GetReporter()
{
    static $Reporter = NULL;
    if (!$Reporter) {
        switch (DW_TESTS_OUTPUT) {
            case DW_TESTS_OUTPUT_XML:
                require_once SIMPLE_TEST . 'xml.php';
                $Reporter = new XmlReporter();
                break;
            case DW_TESTS_OUTPUT_HTML:
            default:
                $Reporter = new HTMLReporter('utf-8');
                break;
        }