当前位置: 首页>>代码示例>>PHP>>正文


PHP Storage::write方法代码示例

本文整理汇总了PHP中Storage::write方法的典型用法代码示例。如果您正苦于以下问题:PHP Storage::write方法的具体用法?PHP Storage::write怎么用?PHP Storage::write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Storage的用法示例。


在下文中一共展示了Storage::write方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: indexAction


//.........这里部分代码省略.........
                         $rgb = imagecolorat($font, $sx, $sy);
                         $opacity = $rgb >> 24;
                         if ($opacity < 127) {
                             $left = $sx - $m['start'] + $x;
                             $py = $sy + $y;
                             if ($py > $this->_height) {
                                 break;
                             }
                             for ($px = min($left, $this->_width - 1); $px > $left - 12 && $px >= 0; $px -= 1) {
                                 $color = imagecolorat($img, $px, $py) & 0xff;
                                 if ($color + $opacity < 190) {
                                     if ($shift > $left - $px) {
                                         $shift = $left - $px;
                                     }
                                     break;
                                 }
                             }
                             break;
                         }
                     }
                 }
                 if ($shift == 10000) {
                     $shift = mt_rand(4, 6);
                 }
             }
             imagecopy($img, $font, $x - $shift, $y, $m['start'], 1, $m['end'] - $m['start'], $fFileHeight);
             $x += $m['end'] - $m['start'] - $shift;
         }
     } while ($x >= $this->_width - 10);
     $center = $x / 2;
     $img2 = imagecreatetruecolor($this->_width, $this->_height);
     $foreground = imagecolorallocate($img2, $this->_foregroundColor[0], $this->_foregroundColor[1], $this->_foregroundColor[2]);
     $background = imagecolorallocate($img2, $this->_backgroundColor[0], $this->_backgroundColor[1], $this->_backgroundColor[2]);
     imagefilledrectangle($img2, 0, 0, $this->_width - 1, $this->_height - 1, $background);
     imagestring($img2, 2, $this->_width - 2, $this->_height - 2, 0, $background);
     // periods
     $rand1 = mt_rand(750000, 1200000) / 10000000;
     $rand2 = mt_rand(750000, 1200000) / 10000000;
     $rand3 = mt_rand(750000, 1200000) / 10000000;
     $rand4 = mt_rand(750000, 1200000) / 10000000;
     // phases
     $rand5 = mt_rand(0, 31415926) / 10000000;
     $rand6 = mt_rand(0, 31415926) / 10000000;
     $rand7 = mt_rand(0, 31415926) / 10000000;
     $rand8 = mt_rand(0, 31415926) / 10000000;
     // amplitudes
     $rand9 = mt_rand(330, 420) / 110;
     $rand10 = mt_rand(330, 450) / 110;
     // wave distortion
     for ($x = 0; $x < $this->_width; $x++) {
         for ($y = 0; $y < $this->_height; $y++) {
             $sx = $x + (sin($x * $rand1 + $rand5) + sin($y * $rand3 + $rand6)) * $rand9 - $this->_width / 2 + $center + 1;
             $sy = $y + (sin($x * $rand2 + $rand7) + sin($y * $rand4 + $rand8)) * $rand10;
             if ($sx < 0 || $sy < 0 || $sx >= $this->_width - 1 || $sy >= $this->_height - 1) {
                 continue;
             } else {
                 $color = imagecolorat($img, $sx, $sy) & 0xff;
                 $color_x = imagecolorat($img, $sx + 1, $sy) & 0xff;
                 $color_y = imagecolorat($img, $sx, $sy + 1) & 0xff;
                 $color_xy = imagecolorat($img, $sx + 1, $sy + 1) & 0xff;
             }
             if ($color == 255 && $color_x == 255 && $color_y == 255 && $color_xy == 255) {
                 continue;
             } else {
                 if ($color == 0 && $color_x == 0 && $color_y == 0 && $color_xy == 0) {
                     $newred = $this->_foregroundColor[0];
                     $newgreen = $this->_foregroundColor[1];
                     $newblue = $this->_foregroundColor[2];
                 } else {
                     $frsx = $sx - floor($sx);
                     $frsy = $sy - floor($sy);
                     $frsx1 = 1 - $frsx;
                     $frsy1 = 1 - $frsy;
                     $newcolor = $color * $frsx1 * $frsy1 + $color_x * $frsx * $frsy1 + $color_y * $frsx1 * $frsy + $color_xy * $frsx * $frsy;
                     if ($newcolor > 255) {
                         $newcolor = 255;
                     }
                     $newcolor = $newcolor / 255;
                     $newcolor0 = 1 - $newcolor;
                     $newred = $newcolor0 * $this->_foregroundColor[0] + $newcolor * 255;
                     $newgreen = $newcolor0 * $this->_foregroundColor[1] + $newcolor * 255;
                     $newblue = $newcolor0 * $this->_foregroundColor[2] + $newcolor * 255;
                 }
             }
             imagesetpixel($img2, $x, $y, imagecolorallocate($img2, $newred, $newgreen, $newblue));
         }
     }
     imagedestroy($img);
     $action = preg_replace('/[^a-z-]+/', '', \Request::getParam('action'));
     $action = 'protection-code' . ($action ? '-' . $action : '');
     \Storage::write($action, $keyString);
     \Request::addHeader('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
     \Request::addHeader('Cache-Control: no-store, no-cache, must-revalidate');
     \Request::addHeader('Cache-Control: post-check=0, pre-check=0');
     \Request::addHeader('Pragma: no-cache');
     \Request::addHeader('Content-Type: image/jpeg');
     \Request::sendHeaders();
     imagejpeg($img2, null, $this->_jpegQuality);
     exit;
 }
开发者ID:nsedenkov,项目名称:phpsu,代码行数:101,代码来源:mainController.php

示例2: processAction

 /**
  * processAction
  *
  * Member registration process
  *
  * @return null
  */
 public function processAction()
 {
     // set json context
     \View::setOutputContext('json');
     \View::lockOutputContext();
     // validate form
     $registerForm = \App::getInstance('\\modules\\user\\RegisterForm');
     $registerForm->validate();
     // invalid form data
     if (!$registerForm->isValid()) {
         throw new \MemberErrorException(array('title' => \View::$language->register_error, 'description' => \View::$language->register_proc_err_descr, 'form_messages' => $registerForm->getMessages()));
     }
     // create a new user
     $userData = $registerForm->getData();
     // set new user defaults
     $userData->group_id = 0;
     // TODO get default user group ID
     $userData->password = $userData->password;
     // TODO need hash password algorythm
     $userData->time_zone = '+00:00';
     // TODO get default user time zone
     $userData->status = 0;
     // TODO get default new registered user status
     $userData->activation_hash = 'xxx';
     // TODO need algorythm for generation of activation hash
     $userData->avatar = 'no-avatar.png';
     // TODO get default user avatar
     $UserModel = \App::getInstance('common\\UserModel');
     $UserModel->createUser($userData);
     // TODO send email notification of account activation
     \App::dump($userData);
     // redirect to complete page
     \Storage::write('__register_complete', true);
     throw new \MemberSuccessException(array('redirection' => '/user/register/complete'));
 }
开发者ID:esterio,项目名称:phpsu,代码行数:42,代码来源:registerController.php

示例3: processAction

 /**
  * processAction
  *
  * Member registration process
  *
  * @return null
  */
 public function processAction()
 {
     // set json context
     \View::setOutputContext('json');
     \View::lockOutputContext();
     // validate form
     $registerForm = new forms\RegisterForm();
     $registerForm->validate();
     if (!$registerForm->isValid()) {
         throw new \MemberErrorException(array('title' => \View::$language->register_error, 'description' => \View::$language->register_proc_err_descr, 'form_messages' => $registerForm->getMessages()));
     }
     $userData = $registerForm->getData();
     // set new user defaults
     $hCnf = \App::getConfig('hosts');
     $mCnf = \App::getConfig('member-defaults');
     $pass = \common\CryptHelper::generateHash($userData->password);
     $userData->group_id = $mCnf->group_id;
     $userData->cookie = \common\HashHelper::getUniqueKey();
     $userData->password = $pass;
     $userData->time_zone = $mCnf->time_zone;
     $userData->status = $mCnf->status;
     $userData->activation_hash = \common\HashHelper::getUniqueKey();
     $userData->avatar = '//' . $hCnf->st . $mCnf->avatar;
     // create a new user
     $UserModel = \App::getInstance('common\\UserModel');
     $UserModel->createUser($userData);
     // TODO send email notification of account activation
     \App::dump($userData);
     // redirect to complete page
     \Storage::write('__register_complete', true);
     throw new \MemberSuccessException(array('redirection' => '/user/register/complete'));
 }
开发者ID:nsedenkov,项目名称:phpsu,代码行数:39,代码来源:registerController.php

示例4: write

 public function write($data)
 {
     //write $data and timestamp
     $now = time();
     //convert to json
     $foo = array('timestamp' => $now, 'data' => $data);
     Storage::write($this->options['cacheDir'] . md5($this->options['cacheId']), json_encode($foo));
 }
开发者ID:MusicalAPP,项目名称:php-lastfm,代码行数:8,代码来源:Flatcache.php

示例5: testWhatYouWriteIsReadBack

 public function testWhatYouWriteIsReadBack()
 {
     $data = array('this' => 'is', 'a' => 'sample');
     Storage::write($data);
     $read = Storage::read();
     $this->assertEquals($read, $data);
     // Actual, Expected <-- alphabetic order
 }
开发者ID:aercolino,项目名称:tech-test,代码行数:8,代码来源:storageTest.php

示例6: write

 public static function write($data = array(), $type = 'access')
 {
     if (!isset($data['servername']) || !isset($data['remoteip']) || !isset($data['bundle'])) {
         $data['bundle'] = 'SYSEXC';
     }
     if (isset($data['url']) && ($p = parse_url($data['url']))) {
         $data += $p;
     }
     $data += array('servername' => '', 'remoteip' => '', 'ssid' => '', 'uid' => 0, 'datetime' => time(), 'exectime' => 0, 'method' => 'GET', 'referer' => '', 'agent' => '', 'scheme' => 'http', 'query' => '', 'path' => '/', 'host' => '', 'port' => 80);
     $entry = array(':version' => static::$version, ':servername' => $data['servername'], ':remoteip' => $data['remoteip'], ':bundle' => strtoupper($data['bundle']), ':ssid' => $data['ssid'], ':uid' => (int) $data['uid'], ':datetime' => substr($data['datetime'], 0, 10), ':exectime' => (int) $data['exectime'], ':method' => strtoupper($data['method']), ':referer' => $data['referer'], ':agent' => $data['agent'], ':scheme' => strtolower($data['scheme']), ':query' => $data['query'], ':path' => strtolower($data['path']), ':host' => strtolower($data['host']), ':port' => (int) $data['port']);
     Storage::write($type, $entry);
 }
开发者ID:royalwang,项目名称:Pyramid,代码行数:12,代码来源:Watchdog.php

示例7: __construct

 /**
  * __construct
  *
  * User sign in form class constructor.
  * Definition of validation rules
  *
  * @return null
  */
 public function __construct()
 {
     parent::__construct();
     \View::addLanguageItem('SignInForm');
     $this->_rules = array('login' => array(array('negation', 'IsString', \View::$language->sign_in_form_data_invalid), array('filter', 'ToString'), array('filter', 'Trim'), array('assertion', 'IsEmpty', \View::$language->sign_in_form_login_is_empty)), 'password' => array(array('negation', 'IsString', \View::$language->sign_in_form_data_invalid), array('filter', 'ToString'), array('filter', 'Trim'), array('assertion', 'IsEmpty', \View::$language->sign_in_form_password_is_empty)));
     // increment sign in tries number
     if (\Storage::isExists('sign-in-tries')) {
         $signInTries = \Storage::read('sign-in-tries') + 1;
     } else {
         $signInTries = 1;
     }
     \Storage::write('sign-in-tries', $signInTries);
     // protection code appendix
     if ($signInTries >= 3) {
         // TODO maybe get number of tries from config?
         $this->_rules['protection_code'] = array(array('negation', 'IsString', \View::$language->sign_in_form_data_invalid), array('filter', 'ToString'), array('filter', 'Trim'), array('assertion', 'IsEmpty', \View::$language->sign_in_form_protection_code_is_empty));
     }
 }
开发者ID:nsedenkov,项目名称:phpsu,代码行数:26,代码来源:SignInForm.php

示例8: setLanguage

 /**
  * setLanguage
  *
  * Loading language environment
  *
  * @param  string $name Name of language
  * @return null
  */
 public static function setLanguage($name)
 {
     if ($name != self::$_currentLang) {
         $langDir = APPLICATION . 'languages/' . $name;
         self::$language = array();
         foreach (self::$_langItems as $langFile) {
             $langPath = $langDir . '/' . $langFile . '.php';
             self::$language = array_merge(self::$language, require $langPath);
         }
         self::$_currentLang = $name;
         Storage::write(self::$_langStorageKey, $name);
         self::$language = (object) self::$language;
     }
 }
开发者ID:nsedenkov,项目名称:phpsu,代码行数:22,代码来源:View.php

示例9: minifyJS

 /**
  * Minify JS.
  * 
  * @param string|array $source_filename
  * @param string $target_filename
  * @return bool
  */
 public static function minifyJS($source_filename, $target_filename)
 {
     $minifier = new \MatthiasMullie\Minify\JS();
     if (is_array($source_filename)) {
         foreach ($source_filename as $filename) {
             $minifier->add($filename);
         }
     } else {
         $minifier->add($source_filename);
     }
     $content = $minifier->execute($target_filename);
     Storage::write($target_filename, $content);
     return strlen($content) ? true : false;
 }
开发者ID:rhymix,项目名称:rhymix,代码行数:21,代码来源:formatter.php

示例10: MMCache

$mmcache = new MMCache();
//$mmcache->delete("key");
//$mmcache->set("key","问少尉",600);
echo $mmcache->get("key");
return;
$imgurl = 'http://localhost:86/temporary/test.jpg';
$request = new HttpRequest(false, false);
$img_data = $request->get($imgurl);
$img = new Image();
$img->setData($img_data);
//$img->resize(300); // 等比缩放到200宽
$img->annotate("翁少尉1", 0.5, GRAVITY_SOUTHEAST, array("name" => FONT_MicroHei, "size" => 100, "color" => "red"));
$new_data = $img->exec();
// 执行处理并返回处理后的二进制数据
$ftype = "jpg";
$stor = new Storage();
$picurlm = $stor->write(FILE_DIR_TEMP, "_400." . $ftype, $new_data);
return;
$stor = new Storage();
$picurl = $stor->upload(FILE_DIR_TEMP, $destination, $filename);
return;
$uptypes = array('image/jpg', 'image/jpeg', 'image/png', 'image/pjpeg', 'image/gif', 'image/bmp', 'image/x-png');
//上传文件大小限制, 单位BYTE
//$destination_folder="../../../uploads/temporary/".date("Y-m-d")."/"; //上传文件路径
//sea存储方案
$destination_folder = '/' . date("Y-m") . "/a/";
//上传文件路径
$watermark = 0;
//是否附加水印(1为加水印,其他为不加水印);
$watertype = 0;
//水印类型(1为文字,2为图片)
开发者ID:xuyintao,项目名称:thindev,代码行数:31,代码来源:test.php

示例11: base64ToImage

 /**
  * 处理base64编码的图片上传
  * @param $base64Data
  * @return mixed
  */
 private function base64ToImage($base64Data)
 {
     $img = base64_decode($base64Data);
     $this->fileName = time() . rand(1, 10000) . ".png";
     $this->fullName = $this->getFolder() . '/' . $this->fileName;
     if (!Storage::write($this->fullName, $img)) {
         $this->stateInfo = $this->getStateInfo("IO");
         return;
     } else {
         $this->url = Storage::getUrl($this->fullName);
     }
     $this->oriName = "";
     $this->fileSize = strlen($img);
     $this->fileType = ".png";
 }
开发者ID:lunnlew,项目名称:Norma_Code,代码行数:20,代码来源:Uploader.php

示例12: effect

 public function effect()
 {
     $res = array();
     $project = new Project();
     $project->setValue($this->ProjectId);
     if ($project->Url != $this->Url) {
         //生产二维码
         $project->Url = $this->Url;
         $destination_folder = date("Y") . "/";
         //上传文件路径
         $filenamenew = uniqid(date("Ymd"), true) . '.png';
         $destination = $destination_folder . $filenamenew;
         $stor = new Storage();
         if (!empty($project->QrCode)) {
             $stor->delete(FILE_DOMAIN, $project->QrCode);
         }
         $project->QrCode = $destination;
         $url = urlencode($project->Url);
         $qrcode = URL_WEBSITE . '/basic/handles/qrcode.php?Url=' . $url;
         $f = new Fetchurl();
         $imageData = $f->fetch($qrcode);
         $stor->write(FILE_DOMAIN, $project->QrCode, $imageData);
     }
     $project->Pv = $this->Pv;
     $project->Uv = $this->Uv;
     $project->Fans = $this->Fans;
     $project->Summary = $this->Summary;
     $project->Laud = $this->Laud;
     //print_r($project);
     $result = $project->update();
     if ($result > 0) {
         $res['Success'] = true;
         $res['Message'] = "更新成功";
         //发送部门老大emailt通知
     } else {
         $res['Success'] = false;
         $res['Message'] = "没有更新任何数据";
     }
     echo json_encode($res);
     exit;
 }
开发者ID:xuyintao,项目名称:thindev,代码行数:41,代码来源:project.php

示例13: foreach

<?php

require_once CONFIG::get('ABSPATH') . '/src/models/person.php';
require_once CONFIG::get('ABSPATH') . '/src/models/storage.php';
try {
    $people = $_POST['people'];
    foreach ($people as $key => $value) {
        $people[$key] = new Person($value);
        // this cleans up posted data
    }
    Storage::write($people);
    $_SESSION['info'] = 'People saved.';
    redirect_to('/people/list');
} catch (Exception $e) {
    $_SESSION['page_error'] = $e->getMessage();
    $_SESSION['page_post'] = $_POST;
    $_SESSION['errors'] = $errors;
    redirect_to('/people/list');
}
开发者ID:aercolino,项目名称:tech-test,代码行数:19,代码来源:a_save.php


注:本文中的Storage::write方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。