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


PHP F3::fixSlashes方法代码示例

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


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

示例1: captcha

 /**
 		Generate CAPTCHA image
 			@param $_dimx integer
 			@param $_dimy integer
 			@param $_len integer
 			@param $_ttfs string
 			@public
 	**/
 public static function captcha($_dimx, $_dimy, $_len, $_ttfs = 'cube')
 {
     $_base = self::rgb(F3::$global['BGCOLOR']);
     $_trans = F3::$global['FGTRANS'];
     // Specify Captcha seed
     if (!strlen(session_id())) {
         session_start();
     }
     $_SESSION['captcha'] = substr(md5(uniqid()), 0, $_len);
     F3::$global['SESSION'] =& $_SESSION;
     // Font size
     $_size = min($_dimx / $_len, 0.6 * $_dimy);
     // Load TrueType font file
     $_fonts = explode('|', $_ttfs);
     $_file = F3::$global['FONTS'] . F3::fixSlashes($_fonts[mt_rand(0, count($_fonts) - 1)]) . '.ttf';
     F3::$global['PROFILE']['FILES']['fonts'][basename($_file)] = filesize($_file);
     $_maxdeg = 15;
     // Compute bounding box metrics
     $_bbox = imagettfbbox($_size, $_angle, $_file, $_SESSION['captcha']);
     $_wimage = 0.9 * (max($_bbox[2], $_bbox[4]) - max($_bbox[0], $_bbox[6]));
     $_himage = max($_bbox[1], $_bbox[3]) - max($_bbox[5], $_bbox[7]);
     // Create blank image
     $_captcha = imagecreatetruecolor($_dimx, $_dimy);
     list($_r, $_g, $_b) = $_base;
     $_bg = imagecolorallocate($_captcha, $_r, $_g, $_b);
     imagefill($_captcha, 0, 0, $_bg);
     $_width = 0;
     // Insert each Captcha character
     for ($_i = 0; $_i < $_len; $_i++) {
         // Random angle
         $_angle = $_maxdeg - mt_rand(0, $_maxdeg * 2);
         // Get CAPTCHA character from session cookie
         $_char = $_SESSION['captcha'][$_i];
         $_fg = imagecolorallocatealpha($_captcha, mt_rand(0, 255 - $_trans), mt_rand(0, 255 - $_trans), mt_rand(0, 255 - $_trans), $_trans);
         imagettftext($_captcha, $_size, $_angle, ($_dimx - $_wimage) / 2 + $_i * $_wimage / $_len, ($_dimy - $_himage) / 2 + 0.9 * $_himage, $_fg, $_file, $_char);
         imagecolordeallocate($_captcha, $_fg);
     }
     // Make the background transparent
     imagecolortransparent($_captcha, $_bg);
     // Send output as PNG image
     if (PHP_SAPI != 'cli' && !headers_sent()) {
         header(F3::HTTP_Content . ': image/png');
     }
     imagepng($_captcha, NULL, self::PNG_Compress, PNG_NO_FILTER);
     // Free resources
     imagedestroy($_captcha);
 }
开发者ID:seyyah,项目名称:f3kulmysql,代码行数:55,代码来源:expansion.php

示例2: write

 /**
 		Write specified text to log file
 			@param $_text string
 			@public
 	**/
 public function write($_text)
 {
     if (!self::ready()) {
         // Lock attempt failed
         trigger_error(self::TEXT_LogLock);
         return;
     }
     $_path = F3::$global['LOGS'];
     clearstatcache();
     if (filesize($_path . $this->filename) > F3::bytes(self::LOG_Size)) {
         // Perform log rotation sequence
         if (file_exists($_path . $this->filename . '.1')) {
             copy($_path . $this->filename . '.1', $_path . $this->filename . '.2');
         }
         copy($_path . $this->filename, $_path . $this->filename . '.1');
         ftruncate($this->handle, 0);
     }
     // Prepend text with timestamp, source IP, file name and
     // line number for tracking origin
     $_trace = debug_backtrace(FALSE);
     fwrite($this->handle, date('r') . ' [' . $_SERVER['REMOTE_ADDR'] . '] ' . F3::fixSlashes($_trace[0]['file']) . ':' . $_trace[0]['line'] . ' ' . preg_replace('/\\s+/', ' ', $_text) . "\n");
     flock($this->handle, LOCK_UN);
 }
开发者ID:seyyah,项目名称:f3kayOLD,代码行数:28,代码来源:log.php


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