示例#1
0
function gcm($var)
{
    if (is_object($var)) {
        $var = get_class($var);
    }
    echo '<pre>';
    prn(get_class_methods($var));
    echo '</pre>';
}
示例#2
0
 function update_post_meta_ing($post_id, $key, $value)
 {
     $data['id_post'] = $post_id;
     $dta['name'] = $key;
     $data['kol'] = $value;
     global $wpdb;
     $wpdb->insert('ingredients', $data);
     prn($post_id);
     prn($key);
     prn($value);
 }
function main($access_key, $secret_key, $canonical_uri)
{
    //パラメータ
    $service = 's3';
    $region = 'ap-northeast-1';
    //	$canonical_uri         = 'URL指定' ;
    //	$access_key            = 'アクセスキー';
    //	$secret_key            = '秘密鍵';
    $method = 'GET';
    $host = "{$service}-{$region}.amazonaws.com";
    $canonical_querystring = '';
    $signed_headers = 'host;x-amz-content-sha256;x-amz-date';
    $endpoint = "http://{$host}{$canonical_uri}";
    $payload = '';
    $algorithm = 'AWS4-HMAC-SHA256';
    //現在時刻の取得
    $t = time();
    $amzdate = gmdate('Ymd\\THis\\Z', $t);
    $datestamp = gmdate('Ymd', $t);
    //payload作成
    $payload_hash = hash('sha256', $payload);
    //ヘッダ作成
    $canonical_headers = "host:{$host}\n";
    $canonical_headers .= "x-amz-content-sha256:{$payload_hash}\n";
    $canonical_headers .= "x-amz-date:{$amzdate}\n";
    //リクエスト生成
    $canonical_request = "{$method}\n";
    $canonical_request .= "{$canonical_uri}\n";
    $canonical_request .= "{$canonical_querystring}\n";
    $canonical_request .= "{$canonical_headers}\n";
    $canonical_request .= "{$signed_headers}\n";
    $canonical_request .= "{$payload_hash}";
    $credential_scope = "{$datestamp}/{$region}/{$service}/aws4_request";
    $string_to_sign = "{$algorithm}\n";
    $string_to_sign .= "{$amzdate}\n";
    $string_to_sign .= "{$credential_scope}\n";
    $string_to_sign .= hash('sha256', $canonical_request);
    $signing_key = getSignature($secret_key, $datestamp, $region, $service);
    $signature = hash_hmac('sha256', $string_to_sign, $signing_key);
    $authorization_header = "{$algorithm} Credential={$access_key}/{$credential_scope}, SignedHeaders={$signed_headers}, Signature={$signature}";
    $headers = array("x-amz-content-sha256: {$payload_hash}", "Authorization: {$authorization_header}", "x-amz-date: {$amzdate}");
    $request_url = rtrim("{$endpoint}?{$canonical_querystring}", "?");
    $context = array("http" => array("method" => $method, "header" => implode("\r\n", $headers)));
    $ret = file_get_contents($request_url, false, stream_context_create($context));
    prn("payload_hash", $payload_hash);
    prn("canonical_headers", $canonical_headers);
    prn("string_to_sign", $string_to_sign);
    prn("canonical_request", $canonical_request);
    prn("Request", print_r($context, 1));
    prn("Response-header", print_r($http_response_header, 1));
    prn("Response-body", $ret);
}
示例#4
0
function set_status_function()
{
    $option_name = 'status_kons';
    $newvalue = $_POST['status'];
    $autoload = 'no';
    prn('123');
    if (get_option($option_name) != $newvalue) {
        update_option($option_name, $newvalue, $autoload);
    } else {
        $deprecated = ' ';
        add_option($option_name, $newvalue, $deprecated, $autoload);
    }
    die;
}
 private function getPDFMarkupFromString($template, $variables = [], $params = [])
 {
     $pdf = $this->getViewModel($template, $variables, $params);
     $twigRenderer = $this->service->get('zfctwigviewtwigrenderer');
     $this->service->get('twigenvironment')->getLoader()->addLoader(new \Twig_Loader_String());
     $pdfRenderer = $this->service->get('ViewPDFRenderer');
     try {
         $pdfRenderer->getEngine()->keep_table_proportions = true;
         $html = $pdfRenderer->setRenderer($twigRenderer)->getRenderer()->render($pdf);
         $pdfRenderer->getEngine()->WriteHTML($html);
         $markup = $pdfRenderer->getEngine()->Output('', 'S');
     } catch (\Exception $e) {
         prn($e);
     }
     return $markup;
     exit;
 }
 public function checkAuth()
 {
     if (isset($this->_session->main_user_id) && $this->_session->main_user_id) {
         try {
             $this->_mainUser = $this->getGateway('MainUser')->get($this->_session->main_user_id);
         } catch (\Exception $e) {
             $this->_session->main_user_id = 0;
             return false;
         }
         $company = $this->getGateway('MainCompany')->get($this->_mainUser->company_id);
         /*
                     $configDB = $this->getGateway('MainConfig')
                         ->findOne(['company_id' => $company->_id]);
         
                     if ( !$configDB) {
                         if (($defaultCompanyConfig
                                 = @include 'config/autoload/company.php') === false
                         ) {
                             throw new \Exception('Company default config does not exist');
                         }
         
                         $dataModel             = $this->getGateway('MainConfig')
                             ->model();
                         $dataModel->company_id = $company->_id;
                         $dataModel->config     = $defaultCompanyConfig;
                         $this->getGateway('MainConfig')->save($dataModel);
         
                         $companyConfig = $defaultCompanyConfig;
                     } else {
                         $companyConfig = $configDB->config();
                     }
         */
         // $company->_id : 533ec57a83971eba5c19bbb8
         $companyConfig['bsb_flysystem']['adapters']['pydio']['options'] = $this->getGateway('MainFS')->findOne(['company_id' => $company->_id, 'isdefault' => 'true', 'status_id' => Status::NORMAL])->toArray();
         $dbs = $this->getGateway('MainDb')->findOne(['company_id' => $company->_id, 'isdefault' => 'true', 'status_id' => Status::NORMAL]);
         $serviceManager = $this->getServiceLocator();
         $config = $this->getServiceLocator()->get('Config');
         $config = ArrayUtils::merge($config, $companyConfig);
         $connection = $this->getServiceLocator()->get('wepo_company')->getDriver()->getConnection();
         $connection->setConnectionParameters($companyConfig['mongozend_db']['adapters']['wepo_company']);
         $allowOverride = $serviceManager->getAllowOverride();
         $serviceManager->setAllowOverride(true);
         $serviceManager->setService('Config', $config);
         $serviceManager->setAllowOverride($allowOverride);
         $user = $this->getGateway('User')->findOne(['main_id' => $this->_mainUser->_id]);
         $dbs = $this->getGateway('MainDb')->find(['company_id' => $company->_id, 'isdefault' => 'true', 'status_id' => Status::NORMAL]);
         prn($dbs);
         exit;
         if ($dbs->count() > 0) {
             $db = $dbs->current();
             $connection = $this->getServiceLocator()->get('wepo_company')->getDriver()->getConnection();
             $connection->setConnectionParameters($db->toArray());
             $user = $this->getGateway('User')->findOne(['main_id' => $this->_mainUser->_id]);
             if ($user == null) {
                 $this->cleanUsers();
                 throw new \Exception('User does not exist');
             }
             $this->_user = $user;
             if (strlen($this->_user->theme)) {
                 if (is_array($config) && isset($config['view_manager'])) {
                     $config = $config['view_manager'];
                     if (is_array($config) && isset($config['template_path_stack'])) {
                         $config['template_path_stack']['wepo'] = __DIR__ . '/../../../../../../module/Wepo/themes/' . $this->_user->theme;
                         $config['template_path_stack']['partial'] = __DIR__ . '/../../../../../../module/Wepo/themes/' . $this->_user->theme . '/wepo';
                     }
                     $zZfcTwigLoaderTemplatePathStack = $this->getServiceLocator()->get('ZfcTwigLoaderTemplatePathStack');
                     $zZfcTwigLoaderTemplatePathStack->setPaths($config['template_path_stack']);
                 }
             }
         } else {
             $this->cleanUsers();
             throw new \Exception('Could not connect to db');
         }
     }
 }
 /**
  * @param array $exceptProtocolUids
  *
  * @return array
  * @throws \Exception
  */
 public function fetchAll($exceptProtocolUids = [])
 {
     $this->findRootFolder();
     $exceptProtocolUids = $this->prepareExceptUids($exceptProtocolUids);
     $uids = $this->transport->getUniqueId();
     prn('root folder', $this->rootFolder->getGlobalName());
     prn('uids before', count($uids));
     $uids = array_diff($uids, $exceptProtocolUids);
     $this->lastSyncSuccessful = true;
     $settingID = $this->setting['id'];
     //        $uids = ['3AB4A466-FC5E-11E3-89A8-00215AD99F24'];
     $resUids = [];
     $count = 0;
     prn('total count', count($uids));
     foreach ($uids as $uid) {
         //            prn( 'outside' );
         $storeMail = $this->storage->find(['protocol_ids.' . $settingID => $this->getFullUid($uid)])->current();
         $rawMail = null;
         if (!isset($storeMail) || !$storeMail->is_converted) {
             prn('new mail');
             $storeMail = $this->getModelServiceVerify()->get($this->storeModel);
             //                prn( 'inside', $storeMail );
             $storeMail->protocol_ids = [$settingID => $this->getFullUid($uid)];
             //                prn( $storeMail );
             try {
                 $rawMail = $this->transport->getMessage($this->transport->getNumberByUniqueId($uid));
             } catch (\Exception $ex) {
                 $storeMail->error = ['sync_error' => $ex->getMessage()];
                 $this->lastSyncSuccessful = false;
             }
             $sameMail = $this->storage->find(['message_id' => $rawMail->message_id])->current();
             if (isset($sameMail)) {
                 $storeMail = $sameMail;
                 $protocolIds = $storeMail->protocol_ids;
                 $protocolIds[$settingID] = $this->getFullUid($uid);
                 $storeMail->protocol_ids = $protocolIds;
             }
         }
         if (!$storeMail->is_converted && isset($rawMail)) {
             $convertedMail = [];
             $content = $rawMail->getContent();
             $headers = $rawMail->getHeaders()->toString();
             if (mb_check_encoding($content, 'UTF-8')) {
                 $storeMail->raw_content = $content;
             }
             if (mb_check_encoding($headers, 'UTF-8')) {
                 $storeMail->raw_headers = $headers;
             }
             try {
                 $convertedMail = $this->convertor->convertMailToInternalFormat($rawMail);
                 prn(count($convertedMail['text']));
                 $convertedMail['link'] = [];
                 $storeMail->is_converted = false;
             } catch (\Exception $ex) {
                 $error = $storeMail->error;
                 $error['convert_error'] = $ex->getMessage();
                 $storeMail->error = $error;
             }
             $storeMail->converted_mail = $convertedMail;
             $storeMail->message_id = $rawMail->message_id;
             $size = $this->checkVariableSize($storeMail);
             if ($size > 16777216) {
                 $storeMail->raw_content = 'too big, size = ' . $size . ' bytes';
             }
             prn('size', $size);
             //                prn($storeMail);
         } else {
             $convertedMail = $storeMail->converted_mail;
             $convertedMail['link'] = [];
             $storeMail->converted_mail = $convertedMail;
         }
         $storeMail->raw_content = iconv("utf-8", "utf-8//ignore", $storeMail->raw_content);
         $cm = $storeMail->converted_mail;
         $cm['text'] = iconv("utf-8", "utf-8//ignore", $cm['text']);
         $storeMail->converted_mail = $cm;
         prn(++$count, 'here', $storeMail->message_id);
         $this->storage->save($storeMail);
         $resUids[] = $this->getFullUid($uid);
     }
     return $resUids;
 }
示例#8
0
文件: reph.php 项目: scriptor/reph
function run($port = 10000, $opts = array())
{
    global $argv;
    $addr = "127.0.0.1";
    $sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
    $__condtmpvar4 = Null;
    if (isset($opts["file"])) {
        $__condtmpvar4 = $opts["file"];
    } else {
        $__condtmpvar4 = NULL;
    }
    $file = $__condtmpvar4;
    $repl_vars = get_repl_vars($file);
    if ($file) {
        compile_file($file);
    } else {
        NULL;
    }
    \NamespaceNode::$repling = TRUE;
    socket_set_option($sock, SOL_SOCKET, SO_REUSEADDR, 1);
    socket_bind($sock, $addr, $port);
    socket_listen($sock, 5);
    prn("Initializing Reph server on ", $addr, ":", $port);
    accept_loop($sock, $repl_vars);
    return socket_close($sock);
}
示例#9
0
    ++$cnts[$nw];
    $ws[] = array($nw, $i);
    ++$kk;
    $jj = $ws[$kk][1];
    ++$i;
}
while ($cnts[$ws[$k][0]] > 1) {
    --$cnts[$ws[$k][0]];
    ++$k;
    $j = $ws[$k][1];
}
if ($jj - $j + 1 < $curlen) {
    $bestk = $k;
    $bestkk = $kk;
    $curlen = $jj - $j + 1;
}
prn();
function prn()
{
    global $ws, $bestk, $bestkk, $wlst;
    $frist = TRUE;
    for ($jjj = $ws[$bestk][1]; $jjj <= $ws[$bestkk][1]; ++$jjj) {
        if ($frist) {
            $frist = FALSE;
        } else {
            print ' ';
        }
        print $wlst[$jjj * 2];
    }
    print "\n";
}
 /**
  * {@inheritdoc}
  */
 public function write($path, $contents, Config $config)
 {
     $location = $this->applyPathPrefix($path);
     prn($path, $contents, $config, $location, dirname($location));
     $this->client->setMethod('POST');
     $this->client->setUri($this->api_url);
     $this->client->setParameterPOST(array_merge($this->auth_param, ['filename' => $path]));
     file_put_contents('tmp', $contents);
     $this->client->setFileUpload('tmp', 'form');
     $response = $this->client->send();
     if ($response->getStatusCode() != 200) {
         throw new \Exception(json_decode($response->getBody())->message);
     }
     prn($response->getContent());
     return json_decode($response->getContent())->data->{$filename};
     $location = $this->applyPathPrefix($path);
     $this->client->request('PUT', $location, $contents);
     $result = compact('path', 'contents');
     if ($config->get('visibility')) {
         throw new LogicException(__CLASS__ . ' does not support visibility settings.');
     }
     return $result;
 }
示例#11
0
 /**
  * Get a read-stream for a file
  *
  * @param $path
  * @return array|bool
  */
 public function readStream($path)
 {
     $headers = ['User-Agent' => 'testing/1.0', 'Accept' => 'application/json', 'X-Foo' => ['Bar', 'Baz'], 'custom' => 'cust'];
     $stream = \GuzzleHttp\Stream\Stream::factory('contents...');
     $client = new \GuzzleHttp\Client(['headers' => $headers]);
     $resource = fopen('a.gif', 'r');
     $request = $client->put($this->api_url . 'upload', ['body' => $resource]);
     prn($client, $request);
     echo $request->getBody();
     exit;
     $location = $this->applyPathPrefix($path);
     $this->client->setMethod('PUT');
     $this->client->setUri($this->api_url . 'upload');
     $this->client->setParameterPost(array_merge($this->auth_param, ['location' => $location]));
     //        $this->client
     //            //->setHeaders(['path: /usr/local....'])
     //            ->setFileUpload('todo.txt','r')
     //            ->setRawData(fopen('todo.txt','r'));
     $fp = fopen('todo.txt', "r");
     $curl = $this->client->getAdapter();
     $curl->setCurlOption(CURLOPT_PUT, 1)->setCurlOption(CURLOPT_RETURNTRANSFER, 1)->setCurlOption(CURLOPT_INFILE, $fp)->setCurlOption(CURLOPT_INFILESIZE, filesize('todo.txt'));
     //  prn($curl->setOutputStream($fp));
     $response = $this->client->send();
     prn($response->getContent(), json_decode($response->getContent()));
     exit;
 }
示例#12
0
<?php

$post = $wp_query->post;
prn($post);
 public function processModel($model)
 {
     $logicConfig = $this->getSubject()->getlogicConfigVerify();
     $debugInfo = ['Observer config' => $this->getRootConfig(), 'Model' => $model, 'Config' => $logicConfig];
     prn('Called with key "' . $logicConfig->key . '"', $debugInfo);
 }