本文整理汇总了PHP中ipFile函数的典型用法代码示例。如果您正苦于以下问题:PHP ipFile函数的具体用法?PHP ipFile怎么用?PHP ipFile使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ipFile函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ipCronExecute
public static function ipCronExecute($info)
{
if ($info['firstTimeThisDay'] || $info['test']) {
self::cleanDirRecursive(ipFile('file/tmp/'));
self::cleanDirRecursive(ipFile('file/secure/tmp/'));
}
}
示例2: downloadTheme
public function downloadTheme($name, $url, $signature)
{
$model = Model::instance();
//download theme
$net = new \Ip\Internal\NetHelper();
$themeTempFilename = $net->downloadFile($url, ipFile('file/secure/tmp/'), $name . '.zip');
if (!$themeTempFilename) {
throw new \Ip\Exception('Theme file download failed.');
}
$archivePath = ipFile('file/secure/tmp/' . $themeTempFilename);
//check signature
$fileMd5 = md5_file($archivePath);
$rsa = new \Crypt_RSA();
$rsa->loadKey($this->publicKey);
$rsa->setSignatureMode(CRYPT_RSA_SIGNATURE_PKCS1);
$verified = $rsa->verify($fileMd5, base64_decode($signature));
if (!$verified) {
throw new \Ip\Exception('Theme signature verification failed.');
}
//extract
$helper = Helper::instance();
$secureTmpDir = ipFile('file/secure/tmp/');
$tmpExtractedDir = \Ip\Internal\File\Functions::genUnoccupiedName($name, $secureTmpDir);
\Ip\Internal\Helper\Zip::extract($secureTmpDir . $themeTempFilename, $secureTmpDir . $tmpExtractedDir);
unlink($archivePath);
//install
$extractedDir = $helper->getFirstDir($secureTmpDir . $tmpExtractedDir);
$installDir = $model->getThemeInstallDir();
$newThemeDir = \Ip\Internal\File\Functions::genUnoccupiedName($name, $installDir);
rename($secureTmpDir . $tmpExtractedDir . '/' . $extractedDir, $installDir . $newThemeDir);
}
示例3: __construct
/**
* @param array|string $data
* @param null $defaultImage
*/
public function __construct($data, $defaultImage = null)
{
if (is_string($data)) {
$data = $this->parseStr($data);
}
if (!empty($data['imageOrig']) && file_exists(ipFile('file/repository/' . $data['imageOrig']))) {
$this->imageOrig = $data['imageOrig'];
if (isset($data['x1']) && isset($data['y1']) && isset($data['x2']) && isset($data['y2'])) {
$this->x1 = $data['x1'];
$this->y1 = $data['y1'];
$this->x2 = $data['x2'];
$this->y2 = $data['y2'];
if (empty($data['requiredWidth'])) {
$data['requiredWidth'] = $this->x2 - $this->x1;
}
if (empty($data['requiredHeight'])) {
$data['requiredHeight'] = $this->y2 - $this->y1;
}
$this->requiredWidth = $data['requiredWidth'];
$this->requiredHeight = $data['requiredHeight'];
$transform = array('type' => 'crop', 'x1' => $this->getX1(), 'y1' => $this->getY1(), 'x2' => $this->getX2(), 'y2' => $this->getY2(), 'width' => $this->getRequiredWidth(), 'height' => $this->getRequiredHeight());
$this->image = ipFileUrl(ipReflection($this->getImageOrig(), $transform, null));
}
} else {
$this->image = $defaultImage;
}
if (!empty($data['id'])) {
$this->id = $data['id'];
} else {
$this->id = mt_rand(2, 2147483647);
//1 used for inline logo
}
}
示例4: concatenate
protected static function concatenate($urls, $ext)
{
$key = md5(json_encode($urls));
$path = 'file/concatenate/' . $key . '.' . $ext;
if (!is_file(ipFile($path))) {
$concatenated = '';
foreach ($urls as $url) {
$urlContent = self::fetchContent($url);
if ($urlContent === false) {
//break if at least one of the assets can't be downloaded
return false;
}
if ($ext == 'css') {
$urlContent = self::replaceUrls($url, $urlContent);
$concatenated .= "\n" . '/*' . $url . "*/\n" . $urlContent;
}
if ($ext == 'js') {
$urlContent .= ';';
$concatenated .= "\n" . '//' . $url . "\n" . $urlContent;
}
}
if (!is_dir(ipFile('file/concatenate'))) {
mkdir(ipFile('file/concatenate'));
}
file_put_contents(ipFile($path), $concatenated);
}
return ipFileUrl($path);
}
示例5: downloadPlugin
public function downloadPlugin($name, $url, $signature)
{
if (is_dir(ipFile("Plugin/{$name}/"))) {
Service::deactivatePlugin($name);
Helper::removeDir(ipFile("Plugin/{$name}/"));
}
//download plugin
$net = new \Ip\Internal\NetHelper();
$pluginTempFilename = $net->downloadFile($url, ipFile('file/secure/tmp/'), $name . '.zip');
if (!$pluginTempFilename) {
throw new \Ip\Exception('Plugin file download failed.');
}
$archivePath = ipFile('file/secure/tmp/' . $pluginTempFilename);
//check signature
$fileMd5 = md5_file($archivePath);
$rsa = new \Crypt_RSA();
$rsa->loadKey($this->publicKey);
$rsa->setSignatureMode(CRYPT_RSA_SIGNATURE_PKCS1);
$verified = $rsa->verify($fileMd5, base64_decode($signature));
if (!$verified) {
throw new \Ip\Exception('Plugin signature verification failed.');
}
//extract
$secureTmpDir = ipFile('file/secure/tmp/');
$tmpExtractedDir = \Ip\Internal\File\Functions::genUnoccupiedName($name, $secureTmpDir);
\Ip\Internal\Helper\Zip::extract($secureTmpDir . $pluginTempFilename, $secureTmpDir . $tmpExtractedDir);
unlink($archivePath);
//install
$extractedDir = $this->getFirstDir($secureTmpDir . $tmpExtractedDir);
$installDir = Model::pluginInstallDir();
$newPluginDir = \Ip\Internal\File\Functions::genUnoccupiedName($name, $installDir);
rename($secureTmpDir . $tmpExtractedDir . '/' . $extractedDir, $installDir . $newPluginDir);
Service::activatePlugin($name);
}
示例6: ipRouteAction_150
/**
* @param $info
* @return array|null
* @throws \Ip\Exception
*/
public static function ipRouteAction_150($info)
{
$requestFile = ipFile('') . $info['relativeUri'];
$fileDir = ipFile('file/');
if (ipRequest()->getRelativePath() != $info['relativeUri']) {
return null;
//language specific url.
}
if (mb_strpos($requestFile, $fileDir) !== 0) {
return null;
}
$reflection = mb_substr($requestFile, mb_strlen($fileDir));
$reflection = urldecode($reflection);
$reflectionModel = ReflectionModel::instance();
$reflectionRecord = $reflectionModel->getReflectionByReflection($reflection);
if ($reflectionRecord) {
$reflectionModel->createReflection($reflectionRecord['original'], $reflectionRecord['reflection'], json_decode($reflectionRecord['options'], true));
if (is_file(ipFile('file/' . $reflection))) {
//supply file route
$result['page'] = null;
$result['plugin'] = 'Repository';
$result['controller'] = 'PublicController';
$result['action'] = 'download';
return $result;
}
}
}
示例7: execute
/**
* Execute response and return html response
*
* @return \Ip\Response
*/
public function execute()
{
ipContent()->setBlockContent('main', $this->content);
$layout = $this->getLayout();
if ($layout[0] == '/' || $layout[1] == ':') {
// Check if absolute path: '/' for unix, 'C:' for windows
$viewFile = $layout;
if (!is_file($viewFile)) {
$viewFile = ipThemeFile('main.php');
}
} elseif (strpos($layout, '/') !== false) {
//impresspages path. Eg. Ip/Internal/xxx.php
$viewFile = $layout;
if (!is_file(ipFile($viewFile))) {
$viewFile = ipThemeFile('main.php');
}
} else {
//layout file. Like main.php
$viewFile = ipThemeFile($layout);
if (!is_file($viewFile)) {
$viewFile = ipThemeFile('main.php');
}
}
$content = ipView($viewFile, $this->getLayoutVariables())->render();
$response = new \Ip\Response($content, $this->getHeaders(), $this->getStatusCode());
return $response;
}
示例8: index
public function index()
{
ipAddJs('Ip/Internal/Core/assets/js/jquery-ui/jquery-ui.js');
ipAddCss('Ip/Internal/Core/assets/js/jquery-ui/jquery-ui.css');
ipAddJs('Ip/Internal/Core/assets/js/easyXDM/easyXDM.min.js');
ipAddJs('Ip/Internal/Design/assets/options.js');
ipAddJs('Ip/Internal/Design/assets/market.js');
ipAddJs('Ip/Internal/Design/assets/design.js');
ipAddJs('Ip/Internal/Design/assets/pluginInstall.js');
ipAddJs('Ip/Internal/System/assets/market.js');
$model = Model::instance();
$themes = $model->getAvailableThemes();
$model = Model::instance();
$theme = $model->getTheme(ipConfig()->theme());
$options = $theme->getOptionsAsArray();
$themePlugins = $model->getThemePlugins();
$installedPlugins = \Ip\Internal\Plugins\Service::getActivePluginNames();
$notInstalledPlugins = array();
//filter plugins that are already installed
foreach ($themePlugins as $plugin) {
if (!empty($plugin['name']) && (!in_array($plugin['name'], $installedPlugins) || !is_dir(ipFile('Plugin/' . $plugin['name'])))) {
$notInstalledPlugins[] = $plugin;
}
}
if (isset($_SESSION['module']['design']['pluginNote'])) {
$pluginNote = $_SESSION['module']['design']['pluginNote'];
unset($_SESSION['module']['design']['pluginNote']);
} else {
$pluginNote = '';
}
$data = array('pluginNote' => $pluginNote, 'theme' => $model->getTheme(ipConfig()->theme()), 'plugins' => $notInstalledPlugins, 'availableThemes' => $themes, 'marketUrl' => $model->getMarketUrl(), 'showConfiguration' => !empty($options), 'contentManagementUrl' => ipConfig()->baseUrl() . '?aa=Content.index', 'contentManagementText' => __('Manage content', 'Ip-admin', false));
$contentView = ipView('view/layout.php', $data);
ipResponse()->setLayoutVariable('removeAdminContentWrapper', true);
return $contentView->render();
}
示例9: ipFile
public static function ipFile($path)
{
$path = str_replace('Plugin/', 'install/Plugin/', $path);
if (self::$installationDir) {
return self::$installationDir . $path;
} else {
return ipFile($path);
}
}
示例10: __construct
/**
* @param array|string $data
* @param string $defaultLogo
*/
public function __construct($data, $defaultLogo = null)
{
if (is_string($data)) {
$data = $this->parseStr($data);
}
if (!isset($data['type'])) {
if ($defaultLogo) {
$data['type'] = self::TYPE_IMAGE;
} else {
$data['type'] = self::TYPE_TEXT;
}
}
switch ($data['type']) {
case self::TYPE_TEXT:
$this->type = self::TYPE_TEXT;
break;
case self::TYPE_IMAGE:
$this->type = self::TYPE_IMAGE;
break;
default:
$this->type = self::TYPE_TEXT;
break;
}
if (!empty($data['imageOrig']) && file_exists(ipFile('file/repository/' . $data['imageOrig']))) {
$this->imageOrig = $data['imageOrig'];
if (isset($data['x1']) && isset($data['y1']) && isset($data['x2']) && isset($data['y2'])) {
$this->x1 = $data['x1'];
$this->y1 = $data['y1'];
$this->x2 = $data['x2'];
$this->y2 = $data['y2'];
if (empty($data['requiredWidth'])) {
$data['requiredWidth'] = $this->x2 - $this->x1;
}
if (empty($data['requiredHeight'])) {
$data['requiredHeight'] = $this->y2 - $this->y1;
}
$this->requiredWidth = $data['requiredWidth'];
$this->requiredHeight = $data['requiredHeight'];
$transform = array('type' => 'crop', 'x1' => $this->getX1(), 'y1' => $this->getY1(), 'x2' => $this->getX2(), 'y2' => $this->getY2(), 'width' => $this->getRequiredWidth(), 'height' => $this->getRequiredHeight(), 'quality' => 100);
$requestedName = \Ip\Internal\Text\Specialchars::url(ipGetOptionLang('Config.websiteTitle'));
$this->image = ipReflection($this->getImageOrig(), $transform, $requestedName);
}
} else {
$this->image = $defaultLogo;
}
if (!empty($data['text'])) {
$this->setText($data['text']);
} else {
$this->setText(ipGetOptionLang('Config.websiteTitle'));
}
if (isset($data['color'])) {
$this->setColor($data['color']);
}
if (isset($data['font'])) {
$this->setFont($data['font']);
}
}
示例11: pluginIcon
protected function pluginIcon($pluginName)
{
if (file_exists(ipFile('Plugin/' . $pluginName . '/assets/icon.svg'))) {
return ipFileUrl('Plugin/' . $pluginName . '/assets/icon.svg');
}
if (file_exists(ipFile('Plugin/' . $pluginName . '/assets/icon.png'))) {
return ipFileUrl('Plugin/' . $pluginName . '/assets/icon.png');
}
}
示例12: setupTestDatabase
public static function setupTestDatabase($database, $tablePrefix)
{
Model::setInstallationDir(ipFile(''));
Model::createDatabaseStructure($database, $tablePrefix);
Model::importData($tablePrefix);
OptionHelper::import(__DIR__ . '/options.json');
Model::insertAdmin('test', 'test@example.com', 'test');
ipSetOptionLang('Config.websiteTitle', 'TestSite', 'en');
ipSetOptionLang('Config.websiteEmail', 'test@example.com', 'en');
}
示例13: getTheme
public function getTheme($name = null, $dir = null, $url = null)
{
if ($name == null) {
$name = ipConfig()->theme();
}
if ($dir == null) {
$dir = ipFile('Theme/');
}
$model = Model::instance();
$theme = $model->getTheme($name, $dir, $url);
return $theme;
}
示例14: extractArchive
private function extractArchive($archivePath, $extractedPath)
{
$fs = new Helper\FileSystem();
$fs->createWritableDir($extractedPath);
$fs->clean($extractedPath);
require_once ipFile('Ip/Internal/PclZip.php');
$zip = new \PclZip($archivePath);
$status = $zip->extract(PCLZIP_OPT_PATH, $extractedPath, PCLZIP_OPT_REMOVE_PATH, 'ImpressPages');
if (!$status) {
throw new UpdateException("Archive extraction failed");
}
}
示例15: availablePermissions
/**
* Get list of all available permissions on the system
*/
public static function availablePermissions()
{
$permissions = array('Super admin', 'Content', 'Pages', 'Design', 'Plugins', 'Config', 'Config advanced', 'Languages', 'System', 'Administrators', 'Log', 'Email', 'Repository', 'Repository upload');
$plugins = \Ip\Internal\Plugins\Model::getActivePluginNames();
foreach ($plugins as $plugin) {
if (is_file(ipFile('Plugin/' . $plugin . '/AdminController.php'))) {
array_push($permissions, $plugin);
}
}
$permissions = ipFilter('ipAvailablePermissions', $permissions);
return $permissions;
}