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


PHP Jaws_Utils::mkdir方法代码示例

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


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

示例1: Install

 /**
  * Install the gadget
  *
  * @access  public
  * @param   string  $input_schema       Schema file path
  * @param   array   $input_variables    Schema variables
  * @return  mixed   True on success or Jaws_Error on failure
  */
 function Install($input_schema = '', $input_variables = array())
 {
     if (!Jaws_Utils::is_writable(JAWS_DATA)) {
         return new Jaws_Error(_t('GLOBAL_ERROR_FAILED_DIRECTORY_UNWRITABLE', JAWS_DATA));
     }
     $new_dir = JAWS_DATA . 'phoo' . DIRECTORY_SEPARATOR;
     if (!Jaws_Utils::mkdir($new_dir)) {
         return new Jaws_Error(_t('GLOBAL_ERROR_FAILED_CREATING_DIR', $new_dir));
     }
     $result = $this->installSchema('schema.xml');
     if (Jaws_Error::IsError($result)) {
         return $result;
     }
     $result = $this->installSchema('insert.xml', null, 'schema.xml', true);
     if (Jaws_Error::IsError($result)) {
         return $result;
     }
     if (!empty($input_schema)) {
         $result = $this->installSchema($input_schema, $input_variables, 'schema.xml', true);
         if (Jaws_Error::IsError($result)) {
             return $result;
         }
     }
     // Install listener for update comment
     $this->gadget->event->insert('UpdateComment');
     return true;
 }
开发者ID:Dulciane,项目名称:jaws,代码行数:35,代码来源:Installer.php

示例2: Get

 /**
  *
  */
 function Get($email, $name)
 {
     $ap_dir = JAWS_DATA . 'cache' . DIRECTORY_SEPARATOR . 'addressprotector';
     if (file_exists($ap_dir . DIRECTORY_SEPARATOR . md5($email . $name))) {
         $contents = file_get_contents($ap_dir . DIRECTORY_SEPARATOR . md5($email . $name));
         $contents = '<a href="http://address-protector.com/' . $contents . '">' . $name . '</a>';
         return $contents;
     }
     Jaws_Utils::mkdir($ap_dir);
     if (!is_dir($ap_dir) || !Jaws_Utils::is_writable($ap_dir) || !(bool) ini_get('allow_url_fopen')) {
         $contents = str_replace(array('@', '.'), array('(at)', 'dot'), $email);
         return $contents;
     }
     $url = "http://address-protector.com/?mode=textencrypt&name=<name>&email=<email>";
     $url = str_replace('<name>', urlencode($name), $url);
     $url = str_replace('<email>', $email, $url);
     $contents = $this->getURL($url);
     if (empty($contents)) {
         $contents = str_replace(array('@', '.'), array('(at)', 'dot'), $email);
     }
     if (substr($contents, -1, 1) == "\n") {
         $contents = substr($contents, 0, -1);
     }
     file_put_contents($ap_dir . DIRECTORY_SEPARATOR . md5($email . $name), $contents);
     $contents = '<a href="http://address-protector.com/' . $contents . '">' . $name . '</a>';
     return $contents;
 }
开发者ID:Dulciane,项目名称:jaws,代码行数:30,代码来源:AddressProtector.php

示例3: Install

 /**
  * Installs the plugin
  *
  * @access  public
  * @return  mixed   True on success and Jaws_Error on failure
  */
 function Install()
 {
     $new_dir = JAWS_DATA . 'AlbumCover' . DIRECTORY_SEPARATOR;
     if (!Jaws_Utils::mkdir($new_dir)) {
         return new Jaws_Error(_t('GLOBAL_ERROR_FAILED_CREATING_DIR', $new_dir), $this->_Name);
     }
     // Registry key
     $GLOBALS['app']->Registry->insert('devtag', 'MY DEV TAG', false, 'AlbumCover');
     return true;
 }
开发者ID:Dulciane,项目名称:jaws,代码行数:16,代码来源:Plugin.php

示例4: Install

 /**
  * Installs the gadget
  *
  * @access  public
  * @return  mixed   True on successful installation, Jaws_Error otherwise
  */
 function Install()
 {
     $result = $this->installSchema('schema.xml');
     if (Jaws_Error::IsError($result)) {
         return $result;
     }
     $new_dir = JAWS_DATA . 'directory';
     if (!Jaws_Utils::mkdir($new_dir)) {
         return new Jaws_Error(_t('GLOBAL_ERROR_FAILED_CREATING_DIR', $new_dir));
     }
     return true;
 }
开发者ID:juniortux,项目名称:jaws,代码行数:18,代码来源:Installer.php

示例5: MakeDir

 /**
  * Creates a directory
  *
  * @access  public
  * @param   string  $path       Where to create it
  * @param   string  $dir_name   Which name
  * @return  bool    Returns true if the directory was created, if not, returns false
  */
 function MakeDir($path, $dir_name)
 {
     $path = trim($path, '/');
     $path = str_replace('..', '', $path);
     $fModel = $this->gadget->model->load('Files');
     $dir = $fModel->GetFileBrowserRootDir() . $path . '/' . $dir_name;
     require_once PEAR_PATH . 'File/Util.php';
     $realpath = File_Util::realpath($dir);
     $blackList = explode(',', $this->gadget->registry->fetch('black_list'));
     $blackList = array_map('strtolower', $blackList);
     if (!File_Util::pathInRoot($realpath, $fModel->GetFileBrowserRootDir()) || in_array(strtolower(basename($realpath)), $blackList) || !Jaws_Utils::mkdir($realpath)) {
         $GLOBALS['app']->Session->PushLastResponse(_t('FILEBROWSER_ERROR_CANT_CREATE_DIRECTORY', $realpath), RESPONSE_ERROR);
         return false;
     }
     return true;
 }
开发者ID:juniortux,项目名称:jaws,代码行数:24,代码来源:Directory.php

示例6: Upgrade

 /**
  * Upgrades the gadget
  *
  * @access  public
  * @param   string  $old    Current version (in registry)
  * @param   string  $new    New version (in the $gadgetInfo file)
  * @return  mixed   True on Success or Jaws_Error on Failure
  */
 function Upgrade($old, $new)
 {
     if (!Jaws_Utils::is_writable(JAWS_DATA)) {
         return new Jaws_Error(_t('GLOBAL_ERROR_FAILED_DIRECTORY_UNWRITABLE', JAWS_DATA));
     }
     $new_dir = JAWS_DATA . 'languages' . DIRECTORY_SEPARATOR;
     if (!Jaws_Utils::mkdir($new_dir)) {
         return new Jaws_Error(_t('GLOBAL_ERROR_FAILED_CREATING_DIR', $new_dir));
     }
     // Registry keys
     $this->gadget->registry->delete('use_data_lang');
     $this->gadget->registry->insert('update_default_lang', 'false');
     // ACL keys
     $this->gadget->acl->insert('ModifyLanguageProperties');
     return true;
 }
开发者ID:Dulciane,项目名称:jaws,代码行数:24,代码来源:Installer.php

示例7: FullCopy

 /**
  * Recursive copy
  *
  * Copies a file to another location or a complete directory
  *
  * @access  public
  * @param   string  $source  File source
  * @param   string  $dest    Destination path
  * @return  bool    Returns TRUE on success, FALSE on failure
  */
 function FullCopy($source, $dest)
 {
     // Simple copy for a file
     if (is_file($source)) {
         return copy($source, $dest);
     }
     // Make destination directory
     Jaws_Utils::mkdir($dest);
     // Loop through the folder
     $dir = @dir($source);
     while (false !== ($entry = $dir->read())) {
         // Skip pointers
         if ($entry == '.' || $entry == '..') {
             continue;
         }
         // Deep copy directories
         if ($dest !== $source . '/' . $entry) {
             Jaws_FileManagement::FullCopy($source . '/' . $entry, $dest . '/' . $entry);
         }
     }
     // Clean up
     $dir->close();
     return true;
 }
开发者ID:juniortux,项目名称:jaws,代码行数:34,代码来源:FileManagement.php

示例8: AlexaSiteRank

/**
 * Generates Alexa Rank Html display Fragment
 * 
 * @access  public
 * @return  string   html fragment
 */
function AlexaSiteRank()
{
    $cache_dir = JAWS_DATA . 'launcher' . DIRECTORY_SEPARATOR;
    if (!Jaws_Utils::mkdir($cache_dir)) {
        return new Jaws_Error(_t('GLOBAL_ERROR_FAILED_CREATING_DIR', $cache_dir), __FUNCTION__);
    }
    $url = $GLOBALS['app']->GetSiteURL('/');
    $file = $cache_dir . 'alexarank_' . md5($url);
    $timedif = time() - (file_exists($file) ? @filemtime($file) : 0);
    $objAlexaRank = new AlexaRank();
    if ($timedif < 43200) {
        // a half day
        //cache file is fresh
        $ranks = $objAlexaRank->loadFile($file);
    } else {
        $ranks = $objAlexaRank->getRank($url);
        $objAlexaRank->saveFile($file, $ranks);
    }
    unset($objAlexaRank);
    $result = '';
    foreach ($ranks as $key => $rank) {
        $result .= "<div><label>{$key}:</label> <span>{$rank}</span></div>";
    }
    return "<div class=\"gadget launcher alexarank\">{$result}</div>";
}
开发者ID:Dulciane,项目名称:jaws,代码行数:31,代码来源:AlexaSiteRank.php

示例9: UpdateAddress

 /**
  * Insert New AddressBook Data to DB
  *
  * @access  public
  * @returns array of Address Books or Jaws_Error on error
  */
 function UpdateAddress($id, $data)
 {
     $data['public'] = (bool) $data['public'];
     $data['updatetime'] = time();
     $targetDir = JAWS_DATA . 'addressbook' . DIRECTORY_SEPARATOR;
     if (array_key_exists('image', $data)) {
         // get address information
         $adr = $this->GetAddressInfo((int) $id);
         if (Jaws_Error::IsError($adr) || empty($adr)) {
             return false;
         }
         if (!empty($adr['image'])) {
             Jaws_Utils::Delete($targetDir . 'image' . DIRECTORY_SEPARATOR . $adr['image']);
         }
         if (!empty($data['image'])) {
             $fileinfo = pathinfo($data['image']);
             if (isset($fileinfo['extension']) && !empty($fileinfo['extension'])) {
                 if (!in_array($fileinfo['extension'], array('gif', 'jpg', 'jpeg', 'png'))) {
                     return false;
                 } else {
                     if (!is_dir($targetDir)) {
                         Jaws_Utils::mkdir($targetDir);
                     }
                     $targetDir = $targetDir . 'image' . DIRECTORY_SEPARATOR;
                     if (!is_dir($targetDir)) {
                         Jaws_Utils::mkdir($targetDir);
                     }
                     $new_image = $adr['id'] . '.' . $fileinfo['extension'];
                     rename(Jaws_Utils::upload_tmp_dir() . '/' . $data['image'], $targetDir . $new_image);
                     $data['image'] = $new_image;
                 }
             }
         }
     }
     $adrTable = Jaws_ORM::getInstance()->table('address_book');
     return $adrTable->update($data)->where('id', (int) $id)->exec();
 }
开发者ID:Dulciane,项目名称:jaws,代码行数:43,代码来源:AddressBook.php

示例10: UpdateFile

 /**
  * Updates file
  *
  * @access  public
  * @return  array   Response array
  */
 function UpdateFile()
 {
     try {
         // Validate data
         $data = jaws()->request->fetch(array('id', 'title', 'description', 'parent', 'url', 'filename', 'filetype', 'filesize'));
         if (empty($data['title'])) {
             throw new Exception(_t('DIRECTORY_ERROR_INCOMPLETE_DATA'));
         }
         $data['title'] = Jaws_XSS::defilter($data['title']);
         $data['description'] = Jaws_XSS::defilter($data['description']);
         $model = $this->gadget->model->load('Files');
         // Validate file
         $id = (int) $data['id'];
         $file = $model->GetFile($id);
         if (Jaws_Error::IsError($file)) {
             throw new Exception($file->getMessage());
         }
         // Validate user
         $user = (int) $GLOBALS['app']->Session->GetAttribute('user');
         if ($file['user'] != $user) {
             throw new Exception(_t('DIRECTORY_ERROR_FILE_UPDATE'));
         }
         // Upload file
         if ($file['user'] != $file['owner']) {
             // is shortcut
             unset($data['parent'], $data['url'], $data['filename']);
             unset($data['filetype'], $data['filesize']);
         } else {
             $path = $GLOBALS['app']->getDataURL('directory/' . $user);
             if (!is_dir($path)) {
                 if (!Jaws_Utils::mkdir($path, 2)) {
                     throw new Exception('DIRECTORY_ERROR_FILE_UPLOAD');
                 }
             }
             $res = Jaws_Utils::UploadFiles($_FILES, $path);
             if (Jaws_Error::IsError($res)) {
                 throw new Exception($res->getMessage());
             } else {
                 if ($res !== false) {
                     $data['filename'] = $res['file'][0]['host_filename'];
                     $data['filetype'] = $res['file'][0]['host_filetype'];
                     $data['filesize'] = $res['file'][0]['host_filesize'];
                 } else {
                     if ($data['filename'] === ':nochange:') {
                         unset($data['filename']);
                     } else {
                         if (empty($data['filename'])) {
                             throw new Exception(_t('DIRECTORY_ERROR_FILE_UPLOAD'));
                         } else {
                             $filename = Jaws_Utils::upload_tmp_dir() . '/' . $data['filename'];
                             if (file_exists($filename)) {
                                 $target = $path . '/' . $data['filename'];
                                 $res = Jaws_Utils::rename($filename, $target, false);
                                 if ($res === false) {
                                     throw new Exception(_t('DIRECTORY_ERROR_FILE_UPLOAD'));
                                 }
                                 $data['filename'] = basename($res);
                             } else {
                                 throw new Exception(_t('DIRECTORY_ERROR_FILE_UPLOAD'));
                             }
                         }
                     }
                 }
             }
         }
         // Update file in database
         $data['updatetime'] = time();
         $model = $this->gadget->model->load('Files');
         $res = $model->Update($id, $data);
         if (Jaws_Error::IsError($res)) {
             throw new Exception(_t('DIRECTORY_ERROR_FILE_UPDATE'));
         }
         // Update shortcuts
         if ($file['shared']) {
             $shortcut = array();
             $shortcut['url'] = $data['url'];
             $shortcut['filename'] = $data['filename'];
             $shortcut['filetype'] = $data['filetype'];
             $shortcut['filesize'] = $data['filesize'];
             $shortcut['updatetime'] = $data['updatetime'];
             $model->UpdateShortcuts($id, $shortcut);
         }
     } catch (Exception $e) {
         return $GLOBALS['app']->Session->GetResponse($e->getMessage(), RESPONSE_ERROR);
     }
     return $GLOBALS['app']->Session->GetResponse(_t('DIRECTORY_NOTICE_FILE_UPDATED'), RESPONSE_NOTICE);
 }
开发者ID:juniortux,项目名称:jaws,代码行数:93,代码来源:Files.php

示例11: ExtractFiles

 /**
  * Extract archive Files
  *
  * @access  public
  * @param   array   $files        $_FILES array
  * @param   string  $dest         Destination directory(include end directory separator)
  * @param   bool    $extractToDir Create separate directory for extracted files
  * @param   bool    $overwrite    Overwrite directory if exist
  * @param   int     $max_size     Max size of file
  * @return  bool    Returns TRUE on success or FALSE on failure
  */
 static function ExtractFiles($files, $dest, $extractToDir = true, $overwrite = true, $max_size = null)
 {
     if (empty($files) || !is_array($files)) {
         return new Jaws_Error(_t('GLOBAL_ERROR_UPLOAD'), __FUNCTION__);
     }
     if (isset($files['name'])) {
         $files = array($files);
     }
     require_once PEAR_PATH . 'File/Archive.php';
     foreach ($files as $key => $file) {
         if (isset($file['error']) && !empty($file['error']) || !isset($file['name'])) {
             return new Jaws_Error(_t('GLOBAL_ERROR_UPLOAD_' . $file['error']), __FUNCTION__);
         }
         if (empty($file['tmp_name'])) {
             continue;
         }
         $ext = strrchr($file['name'], '.');
         $filename = substr($file['name'], 0, -strlen($ext));
         if (false !== stristr($filename, '.tar')) {
             $filename = substr($filename, 0, strrpos($filename, '.'));
             switch ($ext) {
                 case '.gz':
                     $ext = '.tgz';
                     break;
                 case '.bz2':
                 case '.bzip2':
                     $ext = '.tbz';
                     break;
                 default:
                     $ext = '.tar' . $ext;
             }
         }
         $ext = strtolower(substr($ext, 1));
         if (!File_Archive::isKnownExtension($ext)) {
             return new Jaws_Error(_t('GLOBAL_ERROR_UPLOAD_INVALID_FORMAT', $file['name']), __FUNCTION__);
         }
         if ($extractToDir) {
             $dest = $dest . $filename;
         }
         if ($extractToDir && !Jaws_Utils::mkdir($dest)) {
             return new Jaws_Error(_t('GLOBAL_ERROR_FAILED_CREATING_DIR', $dest), __FUNCTION__);
         }
         if (!Jaws_Utils::is_writable($dest)) {
             return new Jaws_Error(_t('GLOBAL_ERROR_FAILED_DIRECTORY_UNWRITABLE', $dest), __FUNCTION__);
         }
         $archive = File_Archive::readArchive($ext, $file['tmp_name']);
         if (PEAR::isError($archive)) {
             return new Jaws_Error($archive->getMessage(), __FUNCTION__);
         }
         $writer = File_Archive::_convertToWriter($dest);
         $result = $archive->extract($writer);
         if (PEAR::isError($result)) {
             return new Jaws_Error($result->getMessage(), __FUNCTION__);
         }
         //@unlink($file['tmp_name']);
     }
     return true;
 }
开发者ID:Dulciane,项目名称:jaws,代码行数:69,代码来源:Utils.php

示例12: SyncSitemapData

 /**
  * Sync sitemap data files
  *
  * @access  public
  * @param   string  $gadget  Gadget name
  * @return  mixed   Array of Tag info or Jaws_Error on failure
  */
 function SyncSitemapData($gadget)
 {
     $objGadget = Jaws_Gadget::getInstance($gadget);
     if (Jaws_Error::IsError($objGadget)) {
         return '';
     }
     $objHook = $objGadget->hook->load('Sitemap');
     if (Jaws_Error::IsError($objHook)) {
         return '';
     }
     $result[$gadget] = array();
     $gResult = $objHook->Execute(1);
     if (Jaws_Error::IsError($gResult) || empty($gResult)) {
         return '';
     }
     // Check gadget directory in sitemap
     $gadget_dir = JAWS_DATA . 'sitemap/' . strtolower($gadget);
     if (!Jaws_Utils::mkdir($gadget_dir, 1)) {
         return new Jaws_Error(_t('GLOBAL_ERROR_FAILED_CREATING_DIR', $gadget_dir));
     }
     $cache_file = $gadget_dir . '/sitemap.bin';
     if (!Jaws_Utils::file_put_contents($cache_file, serialize($gResult))) {
         return false;
     }
     return true;
 }
开发者ID:juniortux,项目名称:jaws,代码行数:33,代码来源:Sitemap.php

示例13: SendMessage


//.........这里部分代码省略.........
                 $data['insert_time'] = time();
                 $senderMessageId = $mTable->insert($data)->exec();
             }
         } else {
             // update message
             $mTable->update($data)->where('id', $messageData['id'])->exec();
             $senderMessageId = $messageData['id'];
         }
         // Insert message for every recipient
         if (!empty($recipient_users) && count($recipient_users) > 0) {
             $table = $table->table('pm_messages');
             $from = $is_notification ? 0 : $user;
             $data['folder'] = $messageData['folder'];
             foreach ($recipient_users as $recipient_user) {
                 $data['insert_time'] = time();
                 $data['from'] = $from;
                 $data['to'] = $recipient_user;
                 $data['read'] = false;
                 $messageId = $table->insert($data)->exec();
                 if (Jaws_Error::IsError($messageId)) {
                     //Rollback Transaction
                     $table->rollback();
                     return false;
                 }
                 $messageIds[] = $messageId;
                 // send notification on new private message
                 if (!$is_notification) {
                     $params = array();
                     $params['key'] = crc32('PrivateMessage' . $senderMessageId);
                     $params['title'] = _t('PRIVATEMESSAGE_NEW_MESSAGE_NOTIFICATION_TITLE');
                     $params['summary'] = _t('PRIVATEMESSAGE_NEW_MESSAGE_NOTIFICATION');
                     $params['description'] = _t('PRIVATEMESSAGE_NEW_MESSAGE_NOTIFICATION_DESC', $data['subject']);
                     $params['user'] = (int) $recipient_user;
                     $this->gadget->event->shout('Notify', $params);
                 }
             }
         }
     }
     // Insert attachments info
     if (!empty($messageData['attachments']) && count($messageData['attachments']) > 0) {
         $maData = array();
         $pm_dir = JAWS_DATA . 'pm' . DIRECTORY_SEPARATOR . 'attachments' . DIRECTORY_SEPARATOR;
         foreach ($messageData['attachments'] as $attachment) {
             // check new attachments file -- we must copy tmp files to correct location
             if (is_array($attachment)) {
                 $src_filepath = Jaws_Utils::upload_tmp_dir() . '/' . $attachment['filename'];
                 $dest_filepath = $pm_dir . $attachment['filename'];
                 if (!file_exists($src_filepath)) {
                     continue;
                 }
                 if (!file_exists($pm_dir)) {
                     if (!Jaws_Utils::mkdir($pm_dir)) {
                         return new Jaws_Error(_t('GLOBAL_ERROR_FAILED_CREATING_DIR', JAWS_DATA));
                     }
                 }
                 $cres = Jaws_Utils::rename($src_filepath, $dest_filepath);
                 Jaws_Utils::delete($src_filepath);
                 if ($cres) {
                     $aData = array('title' => $attachment['title'], 'filename' => $attachment['filename'], 'filesize' => $attachment['filesize'], 'filetype' => $attachment['filetype']);
                     $table = $table->table('pm_attachments');
                     $attachmentId = $table->insert($aData)->exec();
                     if (Jaws_Error::IsError($attachmentId)) {
                         //Rollback Transaction
                         $table->rollback();
                         return false;
                     }
                     // Add sender message Id to pm_message_attachment table
                     $maData[] = array('message' => $senderMessageId, 'attachment' => $attachmentId);
                     // Add recipient message Id to pm_message_attachment table
                     foreach ($messageIds as $messageId) {
                         $maData[] = array('message' => $messageId, 'attachment' => $attachmentId);
                     }
                 }
             } else {
                 // Add sender message Id to pm_message_attachment table
                 $maData[] = array('message' => $senderMessageId, 'attachment' => $attachment);
                 // Add recipient message Id to pm_message_attachment table
                 foreach ($messageIds as $messageId) {
                     $maData[] = array('message' => $messageId, 'attachment' => $attachment);
                 }
             }
         }
         if (!empty($maData) && count($maData) > 0) {
             $table = $table->table('pm_message_attachment');
             $res = $table->insertAll(array('message', 'attachment'), $maData)->exec();
             if (Jaws_Error::IsError($res)) {
                 //Rollback Transaction
                 $table->rollback();
                 return false;
             }
         } else {
             //Rollback Transaction
             $table->rollback();
             return false;
         }
     }
     //Commit Transaction
     $mTable->commit();
     return $senderMessageId;
 }
开发者ID:uda,项目名称:jaws,代码行数:101,代码来源:Message.php

示例14: GooglePageRank

/**
 * Generates Google Rank Html display Fragment
 * 
 * @access  public
 * @return  string   html fragment
 */
function GooglePageRank()
{
    $cache_dir = JAWS_DATA . 'launcher' . DIRECTORY_SEPARATOR;
    if (!Jaws_Utils::mkdir($cache_dir)) {
        return new Jaws_Error(_t('GLOBAL_ERROR_FAILED_CREATING_DIR', $cache_dir), __FUNCTION__);
    }
    $url = $GLOBALS['app']->GetSiteURL('/');
    $file = $cache_dir . 'rank_' . md5($url);
    $timedif = time() - (file_exists($file) ? @filemtime($file) : 0);
    $gRank = new PageRank();
    if ($timedif < 604800) {
        // a week
        //cache file is fresh
        $rank = $gRank->loadFile($file);
    } else {
        $rank = $gRank->GetRank($url);
        $gRank->saveFile($file, $rank);
    }
    unset($gRank);
    $theme = $GLOBALS['app']->GetTheme();
    if (is_dir($theme['path'] . 'PageRank')) {
        $pg_images = $theme['url'] . 'PageRank/';
    } else {
        $pg_images = $GLOBALS['app']->getSiteURL('/gadgets/Launcher/Resources/images/PageRank/', true);
    }
    return "<img src='{$pg_images}pr{$rank}.gif' alt='{$rank}' />";
}
开发者ID:Dulciane,项目名称:jaws,代码行数:33,代码来源:GooglePageRank.php

示例15: UpdateFile

 /**
  * Updates file
  *
  * @access  public
  * @return  array   Response array
  */
 function UpdateFile()
 {
     try {
         // Validate data
         $data = jaws()->request->fetch(array('id', 'title', 'description', 'parent', 'hidden', 'user_filename', 'host_filename', 'filetype', 'filesize'));
         if (empty($data['title'])) {
             throw new Exception(_t('DIRECTORY_ERROR_INCOMPLETE_DATA'));
         }
         $data['title'] = Jaws_XSS::defilter($data['title']);
         $data['description'] = Jaws_XSS::defilter($data['description']);
         $model = $this->gadget->model->loadAdmin('Files');
         // Validate file
         $id = (int) $data['id'];
         $file = $model->GetFile($id);
         if (Jaws_Error::IsError($file)) {
             throw new Exception($file->getMessage());
         }
         // Upload file
         $path = $GLOBALS['app']->getDataURL('directory');
         if (!is_dir($path)) {
             if (!Jaws_Utils::mkdir($path, 2)) {
                 throw new Exception('DIRECTORY_ERROR_FILE_UPLOAD');
             }
         }
         $res = Jaws_Utils::UploadFiles($_FILES, $path, '', null);
         if (Jaws_Error::IsError($res)) {
             throw new Exception($res->getMessage());
         } else {
             if ($res !== false) {
                 $data['host_filename'] = $res['file'][0]['host_filename'];
                 $data['user_filename'] = $res['file'][0]['user_filename'];
                 $data['filetype'] = $res['file'][0]['host_filetype'];
                 $data['filesize'] = $res['file'][0]['host_filesize'];
             } else {
                 if ($data['host_filename'] === ':nochange:') {
                     unset($data['host_filename']);
                 } else {
                     if (empty($data['host_filename'])) {
                         throw new Exception(_t('DIRECTORY_ERROR_FILE_UPLOAD'));
                     } else {
                         $filename = Jaws_Utils::upload_tmp_dir() . '/' . $data['host_filename'];
                         if (file_exists($filename)) {
                             $target = $path . '/' . $data['host_filename'];
                             $res = Jaws_Utils::rename($filename, $target, false);
                             if ($res === false) {
                                 throw new Exception(_t('DIRECTORY_ERROR_FILE_UPLOAD'));
                             }
                             $data['host_filename'] = basename($res);
                         } else {
                             throw new Exception(_t('DIRECTORY_ERROR_FILE_UPLOAD'));
                         }
                     }
                 }
             }
         }
         // Update file in database
         unset($data['user']);
         $data['updatetime'] = time();
         $data['hidden'] = $data['hidden'] ? true : false;
         $model = $this->gadget->model->loadAdmin('Files');
         $res = $model->Update($id, $data);
         if (Jaws_Error::IsError($res)) {
             throw new Exception(_t('DIRECTORY_ERROR_FILE_UPDATE'));
         }
         // Update Tags
         if (Jaws_Gadget::IsGadgetInstalled('Tags')) {
             $tags = jaws()->request->fetch('tags');
             $tModel = Jaws_Gadget::getInstance('Tags')->model->loadAdmin('Tags');
             $tModel->UpdateReferenceTags('Directory', 'file', $id, !$data['hidden'], time(), $tags);
         }
     } catch (Exception $e) {
         return $GLOBALS['app']->Session->GetResponse($e->getMessage(), RESPONSE_ERROR);
     }
     return $GLOBALS['app']->Session->GetResponse(_t('DIRECTORY_NOTICE_FILE_UPDATED'), RESPONSE_NOTICE);
 }
开发者ID:Dulciane,项目名称:jaws,代码行数:81,代码来源:Files.php


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