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


PHP kFile::safeFilePutContents方法代码示例

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


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

示例1: get

 /**
  * @param string $type
  * @return KalturaTypeReflector
  */
 static function get($type)
 {
     if (!self::$_enabled) {
         return new KalturaTypeReflector($type);
     }
     if (!array_key_exists($type, self::$_loadedTypeReflectors)) {
         $cachedDir = KAutoloader::buildPath(kConf::get("cache_root_path"), "api_v3", "typeReflector");
         if (!is_dir($cachedDir)) {
             mkdir($cachedDir);
             chmod($cachedDir, 0755);
         }
         $cachedFilePath = $cachedDir . DIRECTORY_SEPARATOR . $type . ".cache";
         $typeReflector = null;
         if (file_exists($cachedFilePath)) {
             $cachedData = file_get_contents($cachedFilePath);
             $typeReflector = unserialize($cachedData);
         }
         if (!$typeReflector) {
             $typeReflector = new KalturaTypeReflector($type);
             $cachedData = serialize($typeReflector);
             $bytesWritten = kFile::safeFilePutContents($cachedFilePath, $cachedData);
             if (!$bytesWritten) {
                 $folderPermission = substr(decoct(fileperms(dirname($cachedFilePath))), 2);
                 error_log("Kaltura type reflector could not be saved to path [{$cachedFilePath}] type [{$type}] folder permisisons [{$folderPermission}]");
             }
         }
         self::$_loadedTypeReflectors[$type] = $typeReflector;
     }
     return self::$_loadedTypeReflectors[$type];
 }
开发者ID:DBezemer,项目名称:server,代码行数:34,代码来源:KalturaTypeReflectorCacher.php

示例2: write

 public function write()
 {
     $amfSerializer = new FLV_Util_AMFSerialize();
     $metadata_data = array();
     // theses will be used as placeholders for dynamic data
     $metadata_data["canSeekToEnd"] = true;
     $metadata_data["duration"] = (int) ($this->duration / 1000);
     $metadata_data["timeOffset"] = 0;
     $metadata_data["bytesOffset"] = 0;
     // because of akamai seek limitation we want to limit metadata size to 16kb
     // 15K / 2 (times & positions arrays ) / 8 (bytes each) ~ 850
     // we will skip keyframes in order to use at most 850 of them
     $kf_cnt = count($this->keyframeTimes);
     // if there are more than 1 keyframe per second and file size < 100MB its probably and edit flavor and we should maintain all KF
     // we serve the file from our server and not the cdn anyway because the cdn cant clip the file
     $lastKF = $lastKFPos = 0;
     if ($kf_cnt) {
         $lastKF = $this->keyframeTimes[$kf_cnt - 1] / 1000;
         $lastKFPos = $this->keyframeBytes[$kf_cnt - 1] / (1000 * 1000);
     }
     if ($kf_cnt > $lastKF && ($lastKFPos < 100 && !$this instanceof FlvMetadataAudio)) {
         $new_kf_step = 1;
     } else {
         $new_kf_step = max(1, $kf_cnt / 850);
     }
     $new_kf = array();
     $new_fp = array();
     $i = 0;
     $new_kf_pos = 0;
     while ($i < $kf_cnt) {
         $new_kf[] = $this->keyframeTimes[$i];
         $new_fp[] = $this->keyframeBytes[$i];
         $new_kf_pos += $new_kf_step;
         $i = floor($new_kf_pos);
     }
     $metadata_data["times"] = $new_kf;
     $metadata_data["filepositions"] = $new_fp;
     $data = $amfSerializer->serialize('onMetaData') . $amfSerializer->serialize($metadata_data);
     $data_len = strlen($data);
     $metatagSize = myFlvHandler::TAG_WRAPPER_SIZE + $data_len;
     for ($i = 0; $i < count($new_kf); ++$i) {
         $metadata_data["filepositions"][$i] += $metatagSize;
     }
     $res = $amfSerializer->serialize('onMetaData') . $amfSerializer->serialize($metadata_data);
     $meta_tag = myFlvHandler::createMetadataTag($data);
     kFile::safeFilePutContents($this->info_file_name, $meta_tag);
     // sync - OK
     $meta_tag = null;
     $amfSerializer = null;
 }
开发者ID:DBezemer,项目名称:server,代码行数:50,代码来源:myFlvHandler.class.php

示例3: fromObject

 public final function fromObject($srcObj, KalturaDetachedResponseProfile $responseProfile = null)
 {
     if (!is_object($srcObj)) {
         KalturaLog::err("expected an object, got " . print_r($srcObj, true));
         return;
     }
     $thisClass = get_class($this);
     $srcObjClass = get_class($srcObj);
     $fromObjectClass = "Map_{$thisClass}_{$srcObjClass}";
     if (!class_exists($fromObjectClass)) {
         $cacheFileName = kConf::get("cache_root_path") . "/api_v3/fromObject/{$fromObjectClass}.php";
         if (!file_exists($cacheFileName)) {
             $cacheDir = dirname($cacheFileName);
             if (!is_dir($cacheDir)) {
                 mkdir($cacheDir);
                 chmod($cacheDir, 0755);
             }
             $fromObjectClassCode = $this->generateFromObjectClass($srcObj, $fromObjectClass);
             if (!$fromObjectClassCode) {
                 return;
             }
             kFile::safeFilePutContents($cacheFileName, $fromObjectClassCode);
         }
         require_once $cacheFileName;
     }
     $fromObjectClass::fromObject($this, $srcObj, $responseProfile);
     $this->doFromObject($srcObj, $responseProfile);
     if ($srcObj instanceof IRelatedObject) {
         KalturaResponseProfileCacher::onPersistentObjectLoaded($srcObj);
         if ($responseProfile && $responseProfile->relatedProfiles) {
             // trigger validation
             $responseProfile->validateNestedObjects();
             $this->relatedObjects = KalturaResponseProfileCacher::start($srcObj, $responseProfile);
             if (!$this->relatedObjects) {
                 $this->loadRelatedObjects($responseProfile);
                 KalturaResponseProfileCacher::stop($srcObj, $this);
             }
         }
     }
 }
开发者ID:panigh,项目名称:server,代码行数:40,代码来源:KalturaObject.php

示例4: fromObject

 public final function fromObject($srcObj, KalturaDetachedResponseProfile $responseProfile = null)
 {
     if (!is_object($srcObj)) {
         KalturaLog::err("expected an object, got " . print_r($srcObj, true));
         return;
     }
     if ($srcObj instanceof IRelatedObject && $responseProfile && $responseProfile->relatedProfiles) {
         if (KalturaResponseProfileCacher::start($this, $srcObj, $responseProfile)) {
             return;
         }
     }
     $thisClass = get_class($this);
     $srcObjClass = get_class($srcObj);
     $fromObjectClass = "Map_{$thisClass}_{$srcObjClass}";
     if (!class_exists($fromObjectClass)) {
         $cacheFileName = kConf::get("cache_root_path") . "/api_v3/fromObject/{$fromObjectClass}.php";
         $max_include_retries = 10;
         $fromObjectClassCode = null;
         while (!@(include_once $cacheFileName) and $max_include_retries--) {
             if (!$fromObjectClassCode) {
                 $fromObjectClassCode = $this->generateFromObjectClass($srcObj, $fromObjectClass);
                 if (!$fromObjectClassCode) {
                     return;
                 }
             }
             $cacheDir = dirname($cacheFileName);
             if (!is_dir($cacheDir)) {
                 mkdir($cacheDir);
                 chmod($cacheDir, 0775);
             }
             kFile::safeFilePutContents($cacheFileName, $fromObjectClassCode, 0644);
         }
         if (!class_exists($fromObjectClass)) {
             throw new Exception("Could not include cached code file - {$cacheFileName}");
         }
     }
     $fromObjectClass::fromObject($this, $srcObj, $responseProfile);
     $this->doFromObject($srcObj, $responseProfile);
     if ($srcObj instanceof IRelatedObject) {
         KalturaResponseProfileCacher::onPersistentObjectLoaded($srcObj);
         if ($responseProfile && $responseProfile->relatedProfiles) {
             $responseProfile->validateNestedObjects();
             $this->loadRelatedObjects($responseProfile);
             KalturaResponseProfileCacher::stop($srcObj, $this);
         }
     }
 }
开发者ID:wzur,项目名称:server,代码行数:47,代码来源:KalturaObject.php

示例5: cacheMap

 static function cacheMap($servicePath, $cacheFilePath)
 {
     if (!is_dir($servicePath)) {
         throw new Exception('Invalid directory [' . $servicePath . ']');
     }
     $servicePath = realpath($servicePath);
     $serviceMap = array();
     $classMap = KAutoloader::getClassMap();
     $checkedClasses = array();
     //Retrieve all service classes from the classMap.
     $serviceClasses = array();
     foreach ($classMap as $class => $classFilePath) {
         $classFilePath = realpath($classFilePath);
         if (strpos($classFilePath, $servicePath) === 0) {
             $reflectionClass = new ReflectionClass($class);
             if ($reflectionClass->isSubclassOf('KalturaBaseService')) {
                 $serviceDoccomment = new KalturaDocCommentParser($reflectionClass->getDocComment());
                 $serviceClasses[$serviceDoccomment->serviceName] = $class;
             }
         }
     }
     //Retrieve all plugin service classes.
     $pluginInstances = KalturaPluginManager::getPluginInstances('IKalturaServices');
     foreach ($pluginInstances as $pluginName => $pluginInstance) {
         $pluginServices = $pluginInstance->getServicesMap();
         foreach ($pluginServices as $serviceName => $serviceClass) {
             $serviceName = strtolower($serviceName);
             $serviceId = "{$pluginName}_{$serviceName}";
             $serviceClasses[$serviceId] = $serviceClass;
         }
     }
     //Add core & plugin services to the services map
     $aliasActions = array();
     foreach ($serviceClasses as $serviceId => $serviceClass) {
         $serviceReflectionClass = KalturaServiceReflector::constructFromClassName($serviceClass);
         $serviceMapEntry = new KalturaServiceActionItem();
         $serviceMapEntry->serviceId = $serviceId;
         $serviceMapEntry->serviceClass = $serviceClass;
         $serviceMapEntry->serviceInfo = $serviceReflectionClass->getServiceInfo();
         $actionMap = array();
         $nativeActions = $serviceReflectionClass->getActions();
         foreach ($nativeActions as $actionId => $actionName) {
             $actionMap[strtolower($actionId)] = array("serviceClass" => $serviceClass, "actionMethodName" => $actionName, "serviceId" => $serviceId, "actionName" => $actionId);
         }
         $serviceMapEntry->actionMap = $actionMap;
         $serviceMap[strtolower($serviceId)] = $serviceMapEntry;
         foreach ($serviceReflectionClass->getAliasActions() as $alias => $methodName) {
             $aliasActions[$alias] = "{$serviceId}.{$methodName}";
         }
     }
     // add aliases
     foreach ($aliasActions as $aliasAction => $sourceAction) {
         list($aliasService, $aliasAction) = explode('.', $aliasAction);
         list($sourceService, $sourceAction) = explode('.', $sourceAction);
         $aliasService = strtolower($aliasService);
         $sourceService = strtolower($sourceService);
         $extServiceClass = $serviceClasses[$sourceService];
         $serviceMap[$aliasService]->actionMap[strtolower($aliasAction)] = array("serviceClass" => $extServiceClass, "actionMethodName" => $sourceAction, "serviceId" => $sourceService, "actionName" => $aliasAction);
     }
     // filter out services that have no actions
     $serviceMap = array_filter($serviceMap, array('KalturaServicesMap', 'filterEmptyServices'));
     if (!is_dir(dirname($cacheFilePath))) {
         mkdir(dirname($cacheFilePath));
         chmod(dirname($cacheFilePath), 0755);
     }
     kFile::safeFilePutContents($cacheFilePath, serialize($serviceMap), 0644);
 }
开发者ID:EfncoPlugins,项目名称:Media-Management-based-on-Kaltura,代码行数:67,代码来源:KalturaServicesMap.php

示例6: fromObject

 public final function fromObject($srcObj, KalturaDetachedResponseProfile $responseProfile = null)
 {
     $thisClass = get_class($this);
     $srcObjClass = get_class($srcObj);
     $fromObjectClass = "Map_{$thisClass}_{$srcObjClass}";
     if (!class_exists($fromObjectClass)) {
         $cacheFileName = kConf::get("cache_root_path") . "/api_v3/fromObject/{$fromObjectClass}.php";
         if (!file_exists($cacheFileName)) {
             $cacheDir = dirname($cacheFileName);
             if (!is_dir($cacheDir)) {
                 mkdir($cacheDir);
                 chmod($cacheDir, 0755);
             }
             $fromObjectClassCode = $this->generateFromObjectClass($srcObj, $fromObjectClass);
             if (!$fromObjectClassCode) {
                 return;
             }
             kFile::safeFilePutContents($cacheFileName, $fromObjectClassCode);
         }
         require_once $cacheFileName;
     }
     $fromObjectClass::fromObject($this, $srcObj, $responseProfile);
     $this->doFromObject($srcObj, $responseProfile);
     if ($responseProfile) {
         $this->loadRelatedObjects($responseProfile);
     }
 }
开发者ID:AdiTal,项目名称:server,代码行数:27,代码来源:KalturaObject.php


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