コード例 #1
1
ファイル: MultiChoiceControl.php プロジェクト: jjanekk/forms
 /**
  * Sets selected items (by keys).
  * @param  array
  * @return self
  */
 public function setValue($values)
 {
     if (is_scalar($values) || $values === NULL) {
         $values = (array) $values;
     } elseif (!is_array($values)) {
         throw new Nette\InvalidArgumentException(sprintf("Value must be array or NULL, %s given in field '%s'.", gettype($values), $this->name));
     }
     $flip = [];
     foreach ($values as $value) {
         if (!is_scalar($value) && !method_exists($value, '__toString')) {
             throw new Nette\InvalidArgumentException(sprintf("Values must be scalar, %s given in field '%s'.", gettype($value), $this->name));
         }
         $flip[(string) $value] = TRUE;
     }
     $values = array_keys($flip);
     if ($this->checkAllowedValues && ($diff = array_diff($values, array_keys($this->items)))) {
         $set = Nette\Utils\Strings::truncate(implode(', ', array_map(function ($s) {
             return var_export($s, TRUE);
         }, array_keys($this->items))), 70, '...');
         $vals = (count($diff) > 1 ? 's' : '') . " '" . implode("', '", $diff) . "'";
         throw new Nette\InvalidArgumentException("Value{$vals} are out of allowed set [{$set}] in field '{$this->name}'.");
     }
     $this->value = $values;
     return $this;
 }
コード例 #2
1
 /**
  * s2Member's PayPal Auto-Return/PDT handler (inner processing routine).
  *
  * @package s2Member\PayPal
  * @since 110720
  *
  * @param array $vars Required. An array of defined variables passed by {@link s2Member\PayPal\c_ws_plugin__s2member_paypal_return_in::paypal_return()}.
  * @return array|bool The original ``$paypal`` array passed in (extracted) from ``$vars``, or false when conditions do NOT apply.
  */
 public static function cp($vars = array())
 {
     extract($vars);
     foreach (array_keys(get_defined_vars()) as $__v) {
         $__refs[$__v] =& ${$__v};
     }
     do_action("ws_plugin__s2member_during_paypal_return_before_no_return_data", get_defined_vars());
     unset($__refs, $__v);
     $paypal["s2member_log"][] = "No Return-Data. Customer MUST wait for Email Confirmation.";
     $paypal["s2member_log"][] = "Note. This can sometimes happen when/if you are offering an Initial/Trial Period. There are times when a Payment Gateway will NOT supply s2Member with any data immediately after checkout. When/if this happens, s2Member must process the transaction via IPN only (i.e. behind-the-scene), and the Customer must wait for Email Confirmation in these cases.";
     $paypal["s2member_log"][] = var_export($_REQUEST, true);
     foreach (array_keys(get_defined_vars()) as $__v) {
         $__refs[$__v] =& ${$__v};
     }
     do_action("ws_plugin__s2member_during_paypal_return_during_no_return_data", get_defined_vars());
     unset($__refs, $__v);
     if ($custom_success_redirection) {
         $paypal["s2member_log"][] = "Redirecting Customer to a custom URL: " . $custom_success_redirection . ".";
         wp_redirect($custom_success_redirection);
     } else {
         $paypal["s2member_log"][] = "Redirecting Customer to the Home Page (after asking Customer to check their email).";
         echo c_ws_plugin__s2member_return_templates::return_template($paypal["subscr_gateway"], _x('<strong>Thank you! (you MUST check your email before proceeding).</strong><br /><br />* Note: It can take <em>(up to 15 minutes)</em> for Email Confirmation with important details. If you don\'t receive email confirmation in the next 15 minutes, please contact Support.', "s2member-front", "s2member") . ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_sandbox"] || c_ws_plugin__s2member_utils_conds::pro_is_installed() && !empty($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["pro_" . $paypal["subscr_gateway"] . "_sandbox"]) ? '<br /><br />' . _x('<strong>** Sandbox Mode **</strong> You may NOT receive this Email in Sandbox Mode. Sandbox addresses are usually bogus (for testing).', "s2member-front", "s2member") : ''), _x("Back To Home Page", "s2member-front", "s2member"), home_url("/"));
     }
     foreach (array_keys(get_defined_vars()) as $__v) {
         $__refs[$__v] =& ${$__v};
     }
     do_action("ws_plugin__s2member_during_paypal_return_after_no_return_data", get_defined_vars());
     unset($__refs, $__v);
     return apply_filters("c_ws_plugin__s2member_paypal_return_in_no_tx_data", $paypal, get_defined_vars());
 }
コード例 #3
1
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $realCacheDir = $this->getContainer()->getParameter('kernel.cache_dir');
     $oldCacheDir = $realCacheDir . '_old';
     $filesystem = $this->getContainer()->get('filesystem');
     if (!is_writable($realCacheDir)) {
         throw new \RuntimeException(sprintf('Unable to write in the "%s" directory', $realCacheDir));
     }
     if ($filesystem->exists($oldCacheDir)) {
         $filesystem->remove($oldCacheDir);
     }
     $kernel = $this->getContainer()->get('kernel');
     $output->writeln(sprintf('Clearing the cache for the <info>%s</info> environment with debug <info>%s</info>', $kernel->getEnvironment(), var_export($kernel->isDebug(), true)));
     $this->getContainer()->get('cache_clearer')->clear($realCacheDir);
     if ($input->getOption('no-warmup')) {
         $filesystem->rename($realCacheDir, $oldCacheDir);
     } else {
         // the warmup cache dir name must have the same length than the real one
         // to avoid the many problems in serialized resources files
         $warmupDir = substr($realCacheDir, 0, -1) . '_';
         if ($filesystem->exists($warmupDir)) {
             $filesystem->remove($warmupDir);
         }
         $this->warmup($warmupDir, $realCacheDir, !$input->getOption('no-optional-warmers'));
         $filesystem->rename($realCacheDir, $oldCacheDir);
         if (defined('PHP_WINDOWS_VERSION_BUILD')) {
             sleep(1);
             // workaround for windows php rename bug
         }
         $filesystem->rename($warmupDir, $realCacheDir);
     }
     $filesystem->remove($oldCacheDir);
 }
コード例 #4
0
ファイル: upgrades.php プロジェクト: homebru/bandb
function move_to_yaml()
{
    $sql = SQL::current();
    if (!($attrs = $sql->select("post_attributes", "*", array("name" => array("unclean_tags", "clean_tags"))))) {
        return;
    }
    function parseTags($tags, $clean)
    {
        $tags = explode(",", preg_replace("/\\{\\{([^\\}]+)\\}\\}/", "\\1", $tags));
        $clean = explode(",", preg_replace("/\\{\\{([^\\}]+)\\}\\}/", "\\1", $clean));
        return array_combine($tags, $clean);
    }
    $tags = array();
    foreach ($attrs->fetchAll() as $attr) {
        if ($attr["name"] == "unclean_tags") {
            $tags[$attr["post_id"]]["unclean"] = $attr["value"];
        } else {
            $tags[$attr["post_id"]]["clean"] = $attr["value"];
        }
    }
    if (empty($tags)) {
        return;
    }
    foreach ($tags as $post_id => $tags) {
        $yaml = YAML::dump(parseTags($tags["unclean"], $tags["clean"]));
        echo _f("Relocating tags for post #%d...", array($post_id), "tags");
        echo test($insert = $sql->replace("post_attributes", array("name" => "tags", "value" => $yaml, "post_id" => $post_id)), _f("Backup written to %s.", array("./_tags.bak.txt")));
        if (!$insert) {
            return file_put_contents("./_tags.bak.txt", var_export($tags, true));
        }
    }
    echo __("Removing old post attributes...", "tags") . test($sql->delete("post_attributes", array("name" => array("unclean_tags", "clean_tags"))));
}
コード例 #5
0
ファイル: migrate-mypg.php プロジェクト: TamirAl/hubzilla
function run_sql($file, $db, &$err, &$n)
{
    $sql = file_get_contents($file);
    $sql = explode(';', $sql);
    $err = 0;
    $n = 0;
    $c = count($sql);
    if (!$c) {
        echo "Unknown error.\n";
        exit;
    }
    foreach ($sql as $stmt) {
        if ($stmt == '' || $stmt == "\n" || $stmt == "\n\n") {
            $c--;
            continue;
        }
        $r = $db->exec($stmt);
        if ($r === false) {
            echo "\nError executing {$stmt}: " . var_export($db->errorInfo(), true) . "\n";
            $err++;
        } else {
            $n++;
        }
        if ($n % 5 == 0) {
            echo "Executing: {$file}, {$n}/{$c}";
        }
    }
    echo "\n";
}
コード例 #6
0
ファイル: Gateway.php プロジェクト: medz/thinksns-4
 /**
  * 向所有客户端(或者client_id_array指定的客户端)广播消息
  * @param string $message         向客户端发送的消息(可以是二进制数据)
  * @param array  $client_id_array 客户端id数组
  */
 public static function sendToAll($message, $client_id_array = null)
 {
     $gateway_data = GatewayProtocol::$empty;
     $gateway_data['cmd'] = GatewayProtocol::CMD_SEND_TO_ALL;
     $gateway_data['body'] = $message;
     if ($client_id_array) {
         $params = array_merge(array('N*'), $client_id_array);
         $gateway_data['ext_data'] = call_user_func_array('pack', $params);
     } elseif (empty($client_id_array) && is_array($client_id_array)) {
         return;
     }
     // 如果有businessWorker实例,说明运行在workerman环境中,通过businessWorker中的长连接发送数据
     if (self::$businessWorker) {
         foreach (self::$businessWorker->gatewayConnections as $gateway_connection) {
             $gateway_connection->send($gateway_data);
         }
     } else {
         $all_addresses = Store::instance('gateway')->get('GLOBAL_GATEWAY_ADDRESS');
         if (!is_array($all_addresses)) {
             throw new \Exception('bad gateway addresses ' . var_export($all_addresses, true));
         }
         foreach ($all_addresses as $address) {
             self::sendToGateway($address, $gateway_data);
         }
     }
 }
コード例 #7
0
 /**
  * Aktualisiert die gespeicherten Benutzereinstellungen .
  * @global mixed[] $REX Redaxo Variable
  * @global i18n $I18N Objekt mir Übersetzungen fürs Backend
  * @param boolean $showSuccessMsg True, wenn Meldung bei erfolgreichem
  * Speichern angezeigt werden soll.
  */
 public static function updateSettingsFile($showSuccessMsg = true)
 {
     global $REX, $I18N;
     $settingsFile = self::getSettingsFile();
     $msg = self::checkDirForFile($settingsFile);
     if ($msg != '') {
         if ($REX['REDAXO']) {
             echo rex_warning($msg);
         }
     } else {
         if (!file_exists($settingsFile)) {
             self::createDynFile($settingsFile);
         }
         $content = "<?php\n\n";
         foreach ((array) $REX['ADDON']['hr4you_sync']['settings'] as $key => $value) {
             $content .= "\$REX['ADDON']['hr4you_sync']['settings']['{$key}'] = " . var_export($value, true) . ";\n";
         }
         if (rex_put_file_contents($settingsFile, $content)) {
             if ($REX['REDAXO'] && $showSuccessMsg) {
                 echo rex_info($I18N->msg('d2u_stellenmarkt_hr4you_sync_config_ok'));
             }
         } else {
             if ($REX['REDAXO']) {
                 echo rex_warning($I18N->msg('d2u_stellenmarkt_hr4you_sync_config_error'));
             }
         }
     }
 }
コード例 #8
0
ファイル: bug67397.php プロジェクト: badlamer/hhvm
function ut_main()
{
    $ret = var_export(ut_loc_get_display_name(str_repeat('*', 256), 'en_us'), true);
    $ret .= "\n";
    $ret .= var_export(intl_get_error_message(), true);
    return $ret;
}
コード例 #9
0
ファイル: stat_category.php プロジェクト: dalinhuang/yy
function stat_write_static_cache($cache_file_path, $config_arr)
{
    $content = "<?php\r\n";
    $content .= "\$data = " . var_export($config_arr, true) . ";\r\n";
    $content .= "?>";
    file_put_contents($cache_file_path, $content, LOCK_EX);
}
コード例 #10
0
ファイル: Array.php プロジェクト: gauravstomar/Pepool
 /**
  * Defined by Zend_Config_Writer
  *
  * @param  string      $filename
  * @param  Zend_Config $config
  * @throws Zend_Config_Exception When filename was not set
  * @throws Zend_Config_Exception When filename is not writable
  * @return void
  */
 public function write($filename = null, Zend_Config $config = null)
 {
     if ($filename !== null) {
         $this->setFilename($filename);
     }
     if ($config !== null) {
         $this->setConfig($config);
     }
     if ($this->_filename === null) {
         require_once 'Zend/Config/Exception.php';
         throw new Zend_Config_Exception('No filename was set');
     }
     if ($this->_config === null) {
         require_once 'Zend/Config/Exception.php';
         throw new Zend_Config_Exception('No config was set');
     }
     $data = $this->_config->toArray();
     $sectionName = $this->_config->getSectionName();
     if (is_string($sectionName)) {
         $data = array($sectionName => $data);
     }
     $arrayString = "<?php\n" . "return " . var_export($data, true) . ";\n";
     $result = @file_put_contents($this->_filename, $arrayString);
     if ($result === false) {
         require_once 'Zend/Config/Exception.php';
         throw new Zend_Config_Exception('Could not write to file "' . $this->_filename . '"');
     }
 }
コード例 #11
0
 public function updateUserAction($yacPrefix, $key)
 {
     $yac = new Yac($yacPrefix);
     $ret = $yac->get($key);
     // Q: Does ttl expired key flushed or not?
     $user = new User();
     $user->name = $ret['param']['name'];
     $user->department = $ret['param']['department'];
     $success = $user->save();
     if ($success) {
         unset($user);
         // echo "Thanks for registering!\r\n";
     } else {
         echo "Sorry, {$yacPrefix}:::::::{$key} \r\n";
         foreach ($user->getMessages() as $message) {
             echo $message->getMessage(), "\r\n";
         }
     }
     if (!$ret) {
         var_export(array($key, $ret));
         echo "\r\n";
     }
     $yac->delete($key);
     return true;
     // $arr = unserialize($ret);
     // return array("heihei"=>$ret,"ret2"=>$ret2);
 }
コード例 #12
0
function sw_combine_debug()
{
    if (ProjectConfiguration::getActive()->isDebug()) {
        $response = sfContext::getInstance()->getResponse();
        echo "<!-- DEBUG MODE - \nCombined files : \n" . var_export($response->getCombinedAssets(), 1) . "\n -->\n";
    }
}
コード例 #13
0
ファイル: parseTest.php プロジェクト: kylekatarnls/sbp
 public function testParse()
 {
     $content = explode("\n", Sbp::testContent("<?\n__FILE . __DIR", __FILE__), 2);
     $content = $content[1];
     $this->assertSame(trim($content), var_export(__FILE__, true) . ' . ' . var_export(__DIR__, true) . ';', "__FILE . __DIR should be __FILE__ . __DIR__");
     $this->assertParse("ANameSpace\\BClass:CNameSpace\\DClass\n\t- \$var = 'a'", "class ANameSpace\\BClass extends CNameSpace\\DClass {\n\tprivate \$var = 'a';\n}");
 }
コード例 #14
0
ファイル: DB.php プロジェクト: admpub/MicroPHP
 public static function &getInstance($config, $force_new_conn = false)
 {
     $default['dbdriver'] = 'mysql';
     $default['hostname'] = '127.0.0.1';
     $default['port'] = '3306';
     $default['username'] = '******';
     $default['password'] = '';
     $default['database'] = 'test';
     $default['dbprefix'] = '';
     $default['pconnect'] = TRUE;
     $default['db_debug'] = TRUE;
     $default['char_set'] = 'utf8';
     $default['dbcollat'] = 'utf8_general_ci';
     $default['swap_pre'] = '';
     $default['autoinit'] = TRUE;
     $default['stricton'] = FALSE;
     $config = array_merge($default, $config);
     $class = 'CI_DB_' . $config['dbdriver'] . '_driver';
     if (!class_exists($class, false)) {
         return null;
     }
     $config0 = $config;
     asort($config0);
     $hash = md5(sha1(var_export($config0, TRUE)));
     if ($force_new_conn || !isset(self::$conns[$hash])) {
         self::$conns[$hash] = new $class($config);
     }
     if ($config['dbdriver'] == 'pdo' && stripos($config['hostname'], 'mysql') !== FALSE) {
         //pdo下面dns设置mysql字符会失效,这里hack一下
         self::$conns[$hash]->simple_query('set names ' . $config['char_set']);
     }
     return self::$conns[$hash];
 }
コード例 #15
0
 function save($key, $data)
 {
     if (!isset($this->data[$key]) || $this->data[$key] !== $data) {
         $this->data[$key] = $data;
         file_put_contents($this->filename, '<?php return ' . var_export($this->data, true) . ';', LOCK_EX);
     }
 }
コード例 #16
0
ファイル: compiler.url.php プロジェクト: nvdnkpr/Enlight
 /**
  * @param $args
  * @param $compiler
  * @return string
  */
 public function compile($args, $compiler)
 {
     // check and get attributes
     $_attr = $this->getAttributes($compiler, $args);
     // default 'false' for all option flags not set
     foreach ($_attr as $index => $param) {
         if ($param === false) {
             unset($_attr[$index]);
         } elseif ($param === true) {
             $_attr[$index] = "'1'";
         }
     }
     $params = array();
     foreach ($_attr as $index => $param) {
         if (!preg_match('/^([\'"]?)[a-zA-Z0-9]+(\\1)$/', $param, $match) || !empty($_attr['appendSession'])) {
             $params = '';
             foreach ($_attr as $index => $param) {
                 $params .= var_export($index, true) . ' => ' . $param . ', ';
             }
             return '<?php echo Enlight_Application::Instance()->Front()->Router()->assemble(array(' . $params . ')); ?>';
         }
         $params[$index] = substr($param, 1, -1);
     }
     $url = Enlight_Application::Instance()->Front()->Router()->assemble($params);
     return '<?php echo ' . var_export($url, true) . ';?>';
 }
コード例 #17
0
 public function run()
 {
     if (!version_compare($this->from_version, '7.0', '>') || !version_compare($this->from_version, '7.6', '<')) {
         // only need to run this upgrading for greater than 7.0 and less than 7.7
         return;
     }
     $customModules = $this->getCustomModules();
     if (empty($customModules)) {
         // No MB modules - nothing to do
         return;
     }
     foreach ($customModules as $module) {
         $path = 'modules/' . $module . '/clients/base/menus/header/header.php';
         $this->foundPattern = false;
         $viewdefs = null;
         include $path;
         if (!empty($viewdefs)) {
             $module = key($viewdefs);
             $array = $viewdefs[$module]['base']['menu']['header'];
             $this->fixIcons($array);
             if ($this->foundPattern) {
                 sugar_file_put_contents($path, "<?php\n\n/* This file was generated by the 7_FixIconNameChanges upgrader */\n\$viewdefs['{$module}']['base']['menu']['header'] =  " . var_export($array, true) . ";\n");
             }
         }
         $viewdefs = null;
     }
 }
コード例 #18
0
 /**
  * {@inheritDoc}
  */
 public function check($value, $schema = null, JsonPointer $path = null, $i = null)
 {
     // Verify minItems
     if (isset($schema->minItems) && count($value) < $schema->minItems) {
         $this->addError($path, "There must be a minimum of " . $schema->minItems . " items in the array", 'minItems', array('minItems' => $schema->minItems));
     }
     // Verify maxItems
     if (isset($schema->maxItems) && count($value) > $schema->maxItems) {
         $this->addError($path, "There must be a maximum of " . $schema->maxItems . " items in the array", 'maxItems', array('maxItems' => $schema->maxItems));
     }
     // Verify uniqueItems
     if (isset($schema->uniqueItems) && $schema->uniqueItems) {
         $unique = $value;
         if (is_array($value) && count($value)) {
             $unique = array_map(function ($e) {
                 return var_export($e, true);
             }, $value);
         }
         if (count(array_unique($unique)) != count($value)) {
             $this->addError($path, "There are no duplicates allowed in the array", 'uniqueItems');
         }
     }
     // Verify items
     if (isset($schema->items)) {
         $this->validateItems($value, $schema, $path, $i);
     }
 }
コード例 #19
0
function saveDetectPortToCache()
{
    foreach (glob(ST_ROOT . '/Config/Cache/*detect_port.cache.php') as $php_file) {
        unlink($php_file);
    }
    file_put_contents(ST_ROOT . '/Config/Cache/' . time() . '.detect_port.cache.php', "<?php\n\\Statistics\\Config::\$ProviderPort=" . var_export(\Statistics\Config::$ProviderPort, true) . ';');
}
コード例 #20
0
ファイル: object.php プロジェクト: mdb-webdev/livehelperchat
 /**
  * Serialize the data for storing.
  *
  * Serializes the given $data to a executable PHP code representation 
  * string. This works with objects implementing {@link ezcBaseExportable},
  * arrays and scalar values (int, bool, float, string). The return value is
  * executable PHP code to be stored to disk. The data can be unserialized 
  * using the {@link fetchData()} method.
  * 
  * @param mixed $data
  * @return string
  *
  * @throws ezcCacheInvalidDataException
  *         if the $data can not be serialized (e.g. an object that does not
  *         implement ezcBaseExportable, a resource, ...).
  */
 protected function prepareData($data)
 {
     if (is_object($data) && !$data instanceof ezcBaseExportable || is_resource($data)) {
         throw new ezcCacheInvalidDataException(gettype($data), array('simple', 'array', 'ezcBaseExportable'));
     }
     return "<?php\nreturn " . var_export($data, true) . ";\n?>\n";
 }
コード例 #21
0
ファイル: Scaffold.php プロジェクト: stecj/sime
 protected function _build_belongs($number = 0)
 {
     // Initial tabs
     $tabs = str_repeat(TT, $number);
     $prefix = 'o';
     // Export array
     $belongs = array();
     foreach ($this->_foreigns as $db_column => $foreign) {
         $alias = $this->_camelize($foreign['table']);
         $belongs[$prefix . $alias] = array('model' => $alias, 'foreign_key' => $db_column);
     }
     ob_start();
     var_export($belongs);
     $html = ob_get_clean();
     // Add return
     $html = 'protected $_belongs_to = ' . $html;
     // 'array (' to 'array('
     $html = preg_replace('/array \\(/', 'array(', $html);
     // Remove EOL from subarray start
     $html = preg_replace('/=> \\n  /', '=> ', $html);
     // Replace ' ' with \t
     $html = preg_replace('/  /', TT, $html);
     // Add initial tabs
     $html = preg_replace('/^(.*)$/m', $tabs . '$1', $html);
     return $html . ';';
     //echo '<pre>'.$html;
     //die();
 }
コード例 #22
0
ファイル: Nonce.php プロジェクト: marcioyonamine/php-openid
 function _mkCheckTest($case)
 {
     list($nonce_str, $skew, $now, $expected) = $case;
     $test = new Tests_Auth_OpenID_Nonce_TimestampCase($nonce_str, $skew, $now, $expected);
     $test->setName('CheckTimestamp ' . var_export($nonce_str, true));
     $this->addTest($test);
 }
コード例 #23
0
ファイル: Aggregator.php プロジェクト: hukumonline/yii
 /**
  * Returns a list of entities with metadata
  */
 public function getSources()
 {
     $sourcesDef = $this->aConfig->getArray('sources');
     try {
         $sources = SimpleSAML_Metadata_MetaDataStorageSource::parseSources($sourcesDef);
     } catch (Exception $e) {
         throw new Exception('Invalid aggregator source configuration for aggregator ' . var_export($id, TRUE) . ': ' . $e->getMessage());
     }
     #echo $exclude; exit;
     /* Find list of all available entities. */
     $entities = array();
     #echo '<pre>'; print_r($this->sets); exit;
     foreach ($sources as $source) {
         foreach ($this->sets as $set) {
             foreach ($source->getMetadataSet($set) as $entityId => $metadata) {
                 if (isset($metadata['tags']) && count(array_intersect($this->excludeTags, $metadata['tags'])) > 0) {
                     SimpleSAML_Logger::debug('Excluding entity ID [' . $entityId . '] becuase it is tagged with one of [' . var_export($this->excludeTags, TRUE) . ']');
                     continue;
                 } else {
                     #echo('<pre>'); print_r($metadata); exit;
                 }
                 if (!array_key_exists($entityId, $entities)) {
                     $entities[$entityId] = array();
                 }
                 if (array_key_exists($set, $entities[$entityId])) {
                     /* Entity already has metadata for the given set. */
                     continue;
                 }
                 $entities[$entityId][$set] = $metadata;
             }
         }
     }
     return $entities;
 }
コード例 #24
0
ファイル: PDO.php プロジェクト: uedcw/webstory
 public function prepare($statement, $driver_options = array())
 {
     if (isset($this->dsn) and stristr($this->dsn, 'anjuke_db') and preg_match('/\\sajk_propertys\\s/i', $statement)) {
         if (stristr($statement, 'select CITYID') or stristr($statement, 'insert') or stristr($statement, 'update ')) {
         } else {
             $dir = '/home/www/logs/propsql';
             if (!is_dir($dir)) {
                 mkdir($dir, 0755, true);
             }
             $content = '-=-=-=-=-=-=-=-=-=-=' . PHP_EOL;
             $content .= 'DSN: ' . $this->dsn . PHP_EOL;
             $content .= 'URI: ' . $_SERVER['REQUEST_URI'] . PHP_EOL;
             $content .= 'JOB: ' . var_export($_SERVER['argv'], true) . PHP_EOL;
             $content .= 'SQL: ' . $statement . PHP_EOL;
             file_put_contents($dir . '/' . date('Ymd'), $content, FILE_APPEND);
         }
     }
     //add by jackie for record SQL
     APF::get_instance()->pf_benchmark("sql", array($this->i => $statement));
     $stmt = parent::prepare($statement, $driver_options);
     if ($stmt instanceof PDOStatement) {
         $stmt->setFetchMode($this->default_fetch_mode);
     }
     //add by hexin for record SQL execute time
     $stmt->set_i($this->i);
     $this->i++;
     $stmt->_sql = $statement;
     return $stmt;
 }
コード例 #25
0
ファイル: AkTestApplication.php プロジェクト: joeymetal/v1
 function assertHeader($header, $content = null)
 {
     if (is_array($this->_cacheHeaders)) {
         foreach ($this->_cacheHeaders as $ch) {
             $parts = split(': ', $ch);
             if ($parts[0] == $header) {
                 if ($content != null) {
                     $this->assertEqual($content, $parts[1], '1 Header content does not match: ' . $parts[1] . '!=' . $content . ':' . var_export($this->_cacheHeaders, true) . "\n" . var_export($this->Dispatcher->Request->_format, true));
                     return;
                 } else {
                     $this->assertTrue(true);
                     return;
                 }
             }
         }
     }
     if ($this->Dispatcher) {
         $value = $this->Dispatcher->Response->getHeader($header);
         $this->assertTrue($value != false, 'Header "' . $header . '" not found');
         if ($content != null) {
             $this->assertEqual($value, $content, '2 Header content does not match: ' . $content . '!=' . $value . ':' . var_export($this->Dispatcher->Response->_headers, true) . ':' . var_export($this->Dispatcher->Response->_headers_sent, true) . "\n" . var_export($this->Dispatcher->Request->_format, true));
         }
     } else {
         $this->assertTrue(false, 'Header "' . $header . '" not found');
     }
 }
コード例 #26
0
ファイル: FileUploadsFilter.php プロジェクト: keyeMyria/CRM
 /**
  * Returns true if the file is safe to upload.
  *
  * Will use fileinfo if available for determining mime type of the uploaded file.
  * @param array $file
  */
 public function checkFilename($filename)
 {
     if (preg_match(self::EXT_BLACKLIST, $filename, $match)) {
         AuxLib::debugLog('Throwing exception for array: ' . var_export($_FILES, 1));
         throw new CHttpException(403, Yii::t('app', 'Forbidden file type: {ext}', array('{ext}' => $match['ext'])));
     }
 }
コード例 #27
0
 public function actionIndex($email, $spam_id, $key)
 {
     /** @var User $user */
     $user = User::model()->findByAttributes(array('email' => $email));
     /** @var Spam $spam */
     $spam = Spam::model()->findByPk($spam_id);
     if (!$user || !$spam || $key != $spam->getUnsubscribeHash($user)) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     $unsubscribed = false;
     $spam_type_id = $spam->type_enum;
     foreach ($user->userUnsubscribes as $unsubscribe) {
         if ($unsubscribe->spam_type_id == $spam_type_id) {
             $unsubscribed = true;
         }
     }
     if (!$unsubscribed) {
         $userUnsubscribe = new UserUnsubscribe();
         $userUnsubscribe->spam_type_id = $spam_type_id;
         $userUnsubscribe->user_id = $user->id;
         if ($userUnsubscribe->save()) {
             $unsubscribed = true;
         } else {
             throw new CException('unsubscribe error:' . var_export($userUnsubscribe->errors, true));
         }
     }
     $this->render('/user/unsubscribe', array('user' => $user, 'spam' => $spam, 'unsubscribed' => $unsubscribed));
 }
コード例 #28
0
 public function execute(AgaviXmlConfigDomDocument $document)
 {
     $document->setDefaultNamespace(self::XML_NAMESPACE, 'bus');
     $transports = [];
     $subscriptions = [];
     foreach ($document->getConfigurationElements() as $configuration_node) {
         if ($event_bus_element = $configuration_node->getChild('event_bus')) {
             if ($transports_node = $event_bus_element->getChild('transports')) {
                 $transports = array_merge($transports, $this->parseTransports($transports_node));
             }
         }
     }
     $channels = [];
     foreach ($document->getConfigurationElements() as $configuration_node) {
         if ($event_bus_element = $configuration_node->getChild('event_bus')) {
             foreach ($event_bus_element->get('channels') as $channel_element) {
                 $channel_data = $this->parseChannel($channel_element, $transports);
                 if (isset($channels[$channel_data['name']])) {
                     $channels[$channel_data['name']]['subscriptions'] = array_merge($channels[$channel_data['name']]['subscriptions'], $channel_data['subscriptions']);
                 } else {
                     $channels[$channel_data['name']] = $channel_data;
                 }
             }
         }
     }
     $config_data = ['channels' => $channels, 'transports' => $transports];
     $config_code = sprintf('return %s;', var_export($config_data, true));
     return $this->generate($config_code, $document->documentURI);
 }
コード例 #29
0
 public function assert_equal_array($expected, $actual, $debug = null)
 {
     if ($expected !== $actual) {
         throw new Kohana_Unit_Test_Exception(sprintf("Expected (%s) %s but received (%s) %s\n Diff: %s", gettype($expected), var_export($expected, true), gettype($actual), var_export($actual, true), test::diff(var_export($expected, true), var_export($actual, true))), $debug);
     }
     return $this;
 }
コード例 #30
-6
 function procesar()
 {
     toba::logger_ws()->debug('Servicio Llamado: ' . $this->info['basica']['item']);
     toba::logger_ws()->set_checkpoint();
     set_error_handler('toba_logger_ws::manejador_errores_recuperables', E_ALL);
     $this->validar_componente();
     //-- Pide los datos para construir el componente, WSF no soporta entregar objetos creados
     $clave = array();
     $clave['proyecto'] = $this->info['objetos'][0]['objeto_proyecto'];
     $clave['componente'] = $this->info['objetos'][0]['objeto'];
     list($tipo, $clase, $datos) = toba_constructor::get_runtime_clase_y_datos($clave, $this->info['objetos'][0]['clase'], false);
     agregar_dir_include_path(toba_dir() . '/php/3ros/wsf');
     $opciones_extension = toba_servicio_web::_get_opciones($this->info['basica']['item'], $clase);
     $wsdl = strpos($_SERVER['REQUEST_URI'], "?wsdl") !== false;
     $sufijo = 'op__';
     $metodos = array();
     $reflexion = new ReflectionClass($clase);
     foreach ($reflexion->getMethods() as $metodo) {
         if (strpos($metodo->name, $sufijo) === 0) {
             $servicio = substr($metodo->name, strlen($sufijo));
             $prefijo = $wsdl ? '' : '_';
             $metodos[$servicio] = $prefijo . $metodo->name;
         }
     }
     $opciones = array();
     $opciones['serviceName'] = $this->info['basica']['item'];
     $opciones['classes'][$clase]['operations'] = $metodos;
     $opciones = array_merge($opciones, $opciones_extension);
     $this->log->debug("Opciones del servidor: " . var_export($opciones, true), 'toba');
     $opciones['classes'][$clase]['args'] = array($datos);
     toba::logger_ws()->set_checkpoint();
     $service = new WSService($opciones);
     $service->reply();
     $this->log->debug("Fin de servicio web", 'toba');
 }