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


PHP io_deleteFromFile函数代码示例

本文整理汇总了PHP中io_deleteFromFile函数的典型用法代码示例。如果您正苦于以下问题:PHP io_deleteFromFile函数的具体用法?PHP io_deleteFromFile怎么用?PHP io_deleteFromFile使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: subscription_set

/**
 * Set subscription information
 *
 * Allows to set subscription informations for permanent storage in meta files.
 * Subscriptions consist of a target object, a subscribing user, a subscribe
 * style and optional data.
 * A subscription may be deleted by specifying an empty subscribe style.
 * Only one subscription per target and user is allowed.
 * The function returns false on error, otherwise true. Note that no error is
 * returned if a subscription should be deleted but the user is not subscribed
 * and the subscription meta file exists.
 *
 * @param string $user      The subscriber or unsubscriber
 * @param string $page      The target object (page or namespace), specified by
 *                          id; Namespaces are identified by a trailing colon.
 * @param string $style     The subscribe style; DokuWiki currently implements
 *                          “every”, “digest”, and “list”.
 * @param string $data      An optional data blob
 * @param bool   $overwrite Whether an existing subscription may be overwritten
 *
 * @author Adrian Lang <lang@cosmocode.de>
 */
function subscription_set($user, $page, $style, $data = null, $overwrite = false)
{
    global $lang;
    if (is_null($style)) {
        // Delete subscription.
        $file = subscription_filename($page);
        if (!@file_exists($file)) {
            msg(sprintf($lang['subscr_not_subscribed'], $user, prettyprint_id($page)), -1);
            return false;
        }
        // io_deleteFromFile does not return false if no line matched.
        return io_deleteFromFile($file, subscription_regex(array('user' => $user)), true);
    }
    // Delete subscription if one exists and $overwrite is true. If $overwrite
    // is false, fail.
    $subs = subscription_find($page, array('user' => $user));
    if (count($subs) > 0 && array_pop(array_keys($subs)) === $page) {
        if (!$overwrite) {
            msg(sprintf($lang['subscr_already_subscribed'], $user, prettyprint_id($page)), -1);
            return false;
        }
        // Fail if deletion failed, else continue.
        if (!subscription_set($user, $page, null)) {
            return false;
        }
    }
    $file = subscription_filename($page);
    $content = auth_nameencode($user) . ' ' . $style;
    if (!is_null($data)) {
        $content .= ' ' . $data;
    }
    return io_saveFile($file, $content . "\n", true);
}
开发者ID:JeromeS,项目名称:dokuwiki,代码行数:55,代码来源:subscription.php

示例2: test_delete

 function test_delete()
 {
     $file = TMP_DIR . '/test.txt';
     $contents = "The\nDelete\nDelete01\nDelete02\nDelete\nDeleteX\nTest\n";
     io_saveFile($file, $contents);
     $this->assertTrue(io_deleteFromFile($file, "Delete\n"));
     $this->assertEquals("The\nDelete01\nDelete02\nDeleteX\nTest\n", io_readFile($file));
     $this->assertTrue(io_deleteFromFile($file, "#Delete\\d+\n#", true));
     $this->assertEquals("The\nDeleteX\nTest\n", io_readFile($file));
 }
开发者ID:richmahn,项目名称:Door43,代码行数:10,代码来源:io_deletefromfile.test.php

示例3: deleteUsers

 /**
  *  Remove one or more users from the list of registered users
  *
  *  @author  Christopher Smith <chris@jalakai.co.uk>
  *  @param   array  $users   array of users to be deleted
  *  @return  int             the number of users deleted
  */
 function deleteUsers($users)
 {
     global $config_cascade;
     if (!is_array($users) || empty($users)) {
         return 0;
     }
     if ($this->users === null) {
         $this->_loadUserData();
     }
     $deleted = array();
     foreach ($users as $user) {
         if (isset($this->users[$user])) {
             $deleted[] = preg_quote($user, '/');
         }
     }
     if (empty($deleted)) {
         return 0;
     }
     $pattern = '/^(' . join('|', $deleted) . '):/';
     if (io_deleteFromFile($config_cascade['plainauth.users']['default'], $pattern, true)) {
         foreach ($deleted as $user) {
             unset($this->users[$user]);
         }
         return count($deleted);
     }
     // problem deleting, reload the user list and count the difference
     $count = count($this->users);
     $this->_loadUserData();
     $count -= count($this->users);
     return $count;
 }
开发者ID:projectesIF,项目名称:Ateneu,代码行数:38,代码来源:plain.class.php

示例4: remove

 /**
  * Removes a subscription for the given page or namespace
  *
  * This removes all subscriptions matching the given criteria on the given page or
  * namespace. It will *not* modify any subscriptions that may exist in higher
  * namespaces.
  *
  * @param string         $id   The target object’s (namespace or page) id
  * @param string|array   $user
  * @param string|array   $style
  * @param string|array   $data
  * @return bool
  */
 public function remove($id, $user = null, $style = null, $data = null)
 {
     if (!$this->isenabled()) {
         return false;
     }
     $file = $this->file($id);
     if (!file_exists($file)) {
         return true;
     }
     $re = $this->buildregex($user, $style, $data);
     return io_deleteFromFile($file, $re, true);
 }
开发者ID:omusico,项目名称:isle-web-framework,代码行数:25,代码来源:subscription.php

示例5: act_subscriptionns

/**
 * Handle namespace 'subscribe', 'unsubscribe'
 *
 */
function act_subscriptionns($act)
{
    global $ID;
    global $INFO;
    global $lang;
    if (!getNS($ID)) {
        $file = metaFN(getNS($ID), '.mlist');
        $ns = "root";
    } else {
        $file = metaFN(getNS($ID), '/.mlist');
        $ns = getNS($ID);
    }
    // reuse strings used to display the status of the subscribe action
    $act_msg = rtrim($act, 'ns');
    if ($act == 'subscribens' && !$INFO['subscribedns']) {
        if ($INFO['userinfo']['mail']) {
            if (io_saveFile($file, $_SERVER['REMOTE_USER'] . "\n", true)) {
                $INFO['subscribedns'] = true;
                msg(sprintf($lang[$act_msg . '_success'], $INFO['userinfo']['name'], $ns), 1);
            } else {
                msg(sprintf($lang[$act_msg . '_error'], $INFO['userinfo']['name'], $ns), 1);
            }
        } else {
            msg($lang['subscribe_noaddress']);
        }
    } elseif ($act == 'unsubscribens' && $INFO['subscribedns']) {
        if (io_deleteFromFile($file, $_SERVER['REMOTE_USER'] . "\n")) {
            $INFO['subscribedns'] = false;
            msg(sprintf($lang[$act_msg . '_success'], $INFO['userinfo']['name'], $ns), 1);
        } else {
            msg(sprintf($lang[$act_msg . '_error'], $INFO['userinfo']['name'], $ns), 1);
        }
    }
    return 'show';
}
开发者ID:halfbyte,项目名称:rugtool,代码行数:39,代码来源:actions.php

示例6: _acl_del

 /**
  * remove acl-entry from conf/acl.auth.php
  *
  * @author  Frank Schubert <frank@schokilade.de>
  */
 function _acl_del($acl_scope, $acl_user)
 {
     global $config_cascade;
     $acl_user = auth_nameencode($acl_user, true);
     $acl_pattern = '^' . preg_quote($acl_scope, '/') . '[ \\t]+' . $acl_user . '[ \\t]+[0-8].*$';
     return io_deleteFromFile($config_cascade['acl']['default'], "/{$acl_pattern}/", true);
 }
开发者ID:janzoner,项目名称:dokuwiki,代码行数:12,代码来源:admin.php

示例7: deleteUsers

 /**
  * Remove one or more users from the list of registered users
  *
  * @author  Christopher Smith <chris@jalakai.co.uk>
  * @param   array  $users   array of users to be deleted
  * @return  int             the number of users deleted
  */
 public function deleteUsers($users)
 {
     global $config_cascade;
     if (!is_array($users) || empty($users)) {
         return 0;
     }
     if ($this->users === null) {
         $this->_loadUserData();
     }
     $deleted = array();
     foreach ($users as $user) {
         // don't delete protected users
         if (!empty($this->users[$user]['protected'])) {
             msg(sprintf($this->getLang('protected'), hsc($user)), -1);
             continue;
         }
         if (isset($this->users[$user])) {
             $deleted[] = preg_quote($user, '/');
         }
     }
     if (empty($deleted)) {
         return 0;
     }
     $pattern = '/^(' . join('|', $deleted) . '):/';
     if (!io_deleteFromFile($config_cascade['plainauth.users']['default'], $pattern, true)) {
         msg($this->getLang('writefail'), -1);
         return 0;
     }
     // reload the user list and count the difference
     $count = count($this->users);
     $this->_loadUserData();
     $count -= count($this->users);
     return $count;
 }
开发者ID:janzoner,项目名称:dokuwiki,代码行数:41,代码来源:auth.php


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