Returns Status Information of Mail Box.
@access		public
@param		string		$folder			Folder in Mail Box
@return		array
973385
public function getStatusInfo( $folder = NULL )
	{
		$address	= $this->connection->getAddress( $folder );
		$info		= imap_status( $this->connection->getStream(), $address, SA_ALL );
		if( !$info )
			throw new Exception( "imap_status() failed: ". imap_lasterror() );
		return array(
			"messages"	=> $info->messages,
			"recent"	=> $info->recent,
			"unseen"	=> $info->unseen,
		);
	}
1275061
public function folder_exists($folder, $subscription = false)
    {
        if ($folder == 'INBOX') {
            return true;
        }

        $key = $subscription ? 'subscribed' : 'existing';

        if (is_array($this->icache[$key]) && in_array($folder, $this->icache[$key])) {
            return true;
        }

        if (!$this->check_connection()) {
            return false;
        }

        if ($subscription) {
            // It's possible we already called LIST command, check LIST data
            if (!empty($this->conn->data['LIST']) && !empty($this->conn->data['LIST'][$folder])
                && in_array_nocase('\\Subscribed', $this->conn->data['LIST'][$folder])
            ) {
                $a_folders = array($folder);
            }
            else {
                $a_folders = $this->conn->listSubscribed('', $folder);
            }
        }
        else {
            // It's possible we already called LIST command, check LIST data
            if (!empty($this->conn->data['LIST']) && isset($this->conn->data['LIST'][$folder])) {
                $a_folders = array($folder);
            }
            else {
                $a_folders = $this->conn->listMailboxes('', $folder);
            }
        }

        if (is_array($a_folders) && in_array($folder, $a_folders)) {
            $this->icache[$key][] = $folder;
            return true;
        }

        return false;
    }
129111
public function getList($sort = null)
    {
        //Get the states list
        $states = $this->getStates();
        
        //Sorting
        $validSorts = [
            'iso_3166_2',
            'name',
            'country_code',
        ];
        
        if (! is_null($sort) && in_array($sort, $validSorts)) {
            uasort($states, function ($a, $b) use ($sort) {
                if (!isset($a[$sort]) && !isset($b[$sort])) {
                    return 0;
                } elseif (!isset($a[$sort])) {
                    return -1;
                } elseif (!isset($b[$sort])) {
                    return 1;
                } else {
                    return strcasecmp($a[$sort], $b[$sort]);
                }
            });
        }
        
        //Return the states
        return $states;
    }
1273822
public function check(array $folders)
    {
        foreach($folders as $folder => $permission)
        {
            if(!($this->getPermission($folder) >= $permission))
            {
                $this->addFileAndSetErrors($folder, $permission, false);
            }
            else {
                $this->addFile($folder, $permission, true);
            }
        }

        return $this->results;
    }
880090
public function getCurrentReleasePath($folder = null)
    {
        if ($folder) {
            $folder = '/'.$folder;
        }

        return $this->getPathToRelease($this->getCurrentRelease().$folder);
    }
1301329
static function countContentObjectByEmail( $email, $status = false )
    {
        $statusString = "";
        if ( $status !== false )
        {
            $statusString = " AND status = $status";
        }
        $sql = "SELECT COUNT(*) as row_count FROM " .
               "( SELECT DISTINCT contentobject_id, language_id ".
               " FROM ezcomment " .
               " WHERE email='$email'" .
               "$statusString" .
               ") as contentobject";
        $db = eZDB::instance();
        $result = $db->arrayQuery( $sql );
        return $result[0]['row_count'];
    }
1174628
public function getFolders($separator = null, $type = 0)
    {
        if(preg_match( '/^{.+}/', $this->mailbox, $matches)){
            $mailbox = $matches[0];
        }else{
            $mailbox = $this->mailbox;
        };

        $folders = imap_list($this->imap, $mailbox, "*");

        if ($type == 2) {
            return $folders;
        };
        if ($type == 1) {
            return str_replace($mailbox, "", $folders);
        };
        if ($type == 0) {
            $arrayRaw = str_replace($mailbox, "", $folders);
            if (!isset($separator)) {
                $separator = '.';
            };
            $arrayNew = [];
            foreach ($arrayRaw as $string) {
                $array = explode($separator, $string);
                $count = count($array);
                $count = $count-1;
                $cache = false;
                for($i=$count; $i>=0; $i--){
                    if($i == $count){
                        $cache = [$array[$i]=>[]];
                    }else{
                        $cache = [$array[$i] => $cache];
                    };
                };
                $arrayNew = array_merge_recursive($arrayNew, $cache);
            };
            return $arrayNew;
        }
        return null;
    }
1254656
private function checkSystemTemporaryFolder(): string
    {
        $open_basedir  = ini_get('open_basedir');
        $open_basedirs = explode(PATH_SEPARATOR, $open_basedir);
        $sys_temp_dir  = sys_get_temp_dir();

        if ($open_basedir === '' || Str::startsWith($sys_temp_dir, $open_basedirs)) {
            return '';
        }

        $message = I18N::translate('The server’s temporary folder cannot be accessed.');
        $message .= '<br>sys_get_temp_dir() = "' . e($sys_temp_dir) . '"';
        $message .= '<br>ini_get("open_basedir") = "' . e($open_basedir) . '"';

        return $message;
    }
583355
protected function checkStatus( $post ) {

		$slug	= $post->slug;

		switch( $post->status ) {

			case Post::STATUS_BASIC: {

				return $this->redirect( [ "$this->basePath/info?slug=$slug" ] );
			}

			case Post::STATUS_SETTINGS: {

				return $this->redirect( [ "$this->basePath/attributes?slug=$slug" ] );
			}
			case Post::STATUS_ATTRIBUTES: {

				return $this->redirect( [ "$this->basePath/review?slug=$slug" ] );
			}
			case Post::STATUS_REJECTED: {

				return $this->redirect( [ "$this->basePath/review?slug=$slug" ] );
			}
			case Post::STATUS_RE_SUBMIT: {

				return $this->redirect( [ "$this->basePath/basic?slug=$slug" ] );
			}
			default: {

				return $this->redirect( [ "$this->basePath/info?slug=$slug" ] );
			}
		}
	}
1102886
protected function realpath($folder)
    {
        $separator = (string) DIRECTORY_SEPARATOR;

        $search = array('\\', '/', (string) '\\\\');

        $path = str_replace($search, $separator, $folder);

        file_exists($path) || mkdir((string) $path);

        $exists = in_array(substr($path, -1), $search);

        return $exists ? $path : $path . $separator;
    }
616887
public function get_message($uid, $folder = null)
    {
        if (!strlen($folder)) {
            $folder = $this->folder;
        }

        // decode combined UID-folder identifier
        if (preg_match('/^\d+-.+/', $uid)) {
            list($uid, $folder) = explode('-', $uid, 2);
        }

        // Check internal cache
        if (!empty($this->icache['message'])) {
            if (($headers = $this->icache['message']) && $headers->uid == $uid) {
                return $headers;
            }
        }

        $headers = $this->get_message_headers($uid, $folder);

        // message doesn't exist?
        if (empty($headers)) {
            return null;
        }

        // structure might be cached
        if (!empty($headers->structure)) {
            return $headers;
        }

        $this->msg_uid = $uid;

        if (!$this->check_connection()) {
            return $headers;
        }

        if (empty($headers->bodystructure)) {
            $headers->bodystructure = $this->conn->getStructure($folder, $uid, true);
        }

        $structure = $headers->bodystructure;

        if (empty($structure)) {
            return $headers;
        }

        // set message charset from message headers
        if ($headers->charset) {
            $this->struct_charset = $headers->charset;
        }
        else {
            $this->struct_charset = $this->structure_charset($structure);
        }

        $headers->ctype = @strtolower($headers->ctype);

        // Here we can recognize malformed BODYSTRUCTURE and
        // 1. [@TODO] parse the message in other way to create our own message structure
        // 2. or just show the raw message body.
        // Example of structure for malformed MIME message:
        // ("text" "plain" NIL NIL NIL "7bit" 2154 70 NIL NIL NIL)
        if ($headers->ctype && !is_array($structure[0]) && $headers->ctype != 'text/plain'
            && strtolower($structure[0].'/'.$structure[1]) == 'text/plain'
        ) {
            // A special known case "Content-type: text" (#1488968)
            if ($headers->ctype == 'text') {
                $structure[1]   = 'plain';
                $headers->ctype = 'text/plain';
            }
            // we can handle single-part messages, by simple fix in structure (#1486898)
            else if (preg_match('/^(text|application)\/(.*)/', $headers->ctype, $m)) {
                $structure[0] = $m[1];
                $structure[1] = $m[2];
            }
            else {
                // Try to parse the message using rcube_mime_decode.
                // We need a better solution, it parses message
                // in memory, which wouldn't work for very big messages,
                // (it uses up to 10x more memory than the message size)
                // it's also buggy and not actively developed
                if ($headers->size && rcube_utils::mem_check($headers->size * 10)) {
                    $raw_msg = $this->get_raw_body($uid);
                    $struct = rcube_mime::parse_message($raw_msg);
                }
                else {
                    return $headers;
                }
            }
        }

        if (empty($struct)) {
            $struct = $this->structure_part($structure, 0, '', $headers);
        }

        // some workarounds on simple messages...
        if (empty($struct->parts)) {
            // ...don't trust given content-type
            if (!empty($headers->ctype)) {
                $struct->mime_id  = '1';
                $struct->mimetype = strtolower($headers->ctype);
                list($struct->ctype_primary, $struct->ctype_secondary) = explode('/', $struct->mimetype);
            }

            // ...and charset (there's a case described in #1488968 where invalid content-type
            // results in invalid charset in BODYSTRUCTURE)
            if (!empty($headers->charset) && $headers->charset != $struct->ctype_parameters['charset']) {
                $struct->charset                     = $headers->charset;
                $struct->ctype_parameters['charset'] = $headers->charset;
            }
        }

        $headers->structure = $struct;

        return $this->icache['message'] = $headers;
    }
312090
protected function saveBlocksFromFolder($folder)
    {
        $ids = [];
        if (is_dir($folder)) {
            foreach (FileHelper::findFiles($folder) as $blockItem) {
                $ids[] = $this->saveBlockByPath($blockItem);
            }
        }
        
        return $ids;
    }
195997
public function handleFolderContents(SS_HTTPRequest $request)
    {
        if (!$request->param('FolderID')) {
            $folder = Injector::inst()->get('Folder');
            $folder->Filename = ASSETS_DIR;
        } else {
            $folder = Folder::get()->byID($request->param('FolderID'));
        }

        if (!$folder) {
            return $this->httpError(404, 'That folder does not exist');
        }

        $cursor = (int)$request->getVar('cursor');
        $result = array(
            'folder' => $this->createFolderJson($folder),
            'breadcrumbs' => $this->createBreadcrumbJson($folder),
            'children' => array()
        );

        $files = File::get()
            ->filter(array(
                'ParentID' => $folder->ID
            ))
            ->sort($this->getSortClause($request->getVar('sort')));

        $totalFiles = (int)$files->count();
        $files = $files->limit($this->config()->folder_items_limit, $cursor);

        foreach ($files as $file) {
            if (!$file->canView()) {
                continue;
            }

            $result['children'][] = ($file instanceof Folder) ?
                $this->createFolderJson($file) :
                $this->createFileJson($file, $folder);
        }

        $cursor += $files->count();
        $result['cursor'] = $cursor;
        $result['has_more'] = ($cursor < $totalFiles);
        $result['total_items'] = $totalFiles;

        $response = new SS_HTTPResponse(
            Convert::array2json($result), 200
        );

        return $response->addHeader('Content-Type', 'application/json');
    }
9547
public function list_flags($folder, $uids, $mod_seq = null)
    {
        if (!strlen($folder)) {
            $folder = $this->folder;
        }

        if (!$this->check_connection()) {
            return array();
        }

        // @TODO: when cache was synchronized in this request
        // we might already have asked for flag updates, use it.

        $flags  = $this->conn->fetch($folder, $uids, true, array('FLAGS'), $mod_seq);
        $result = array();

        if (!empty($flags)) {
            foreach ($flags as $message) {
                $result[$message->uid] = $message->flags;
            }
        }

        return $result;
    }
1078036
public static function getStatusList()
    {
        return [
            self::STATUS_OK => 'ok',
            self::STATUS_SENDING => 'sending',
            self::STATUS_PENDING => 'pending',
            self::STATUS_ERROR => 'error',
            self::STATUS_ENCODING => 'encoding',
        ];
    }
1372145
public static function getLangs($folder = '')
    {
        $langs = [];

        $iterator = new \DirectoryIterator(ForumEnv::get('FORUM_ROOT').'lang/');
        foreach ($iterator as $child) {
            if (!$child->isDot() && $child->isDir() &&
                file_exists($child->getPathname().DIRECTORY_SEPARATOR.'install.po')) {
                // If the lang pack is well formed, add it to the list
                $langs[] = $child->getFileName();
            }
        }

        natcasesort($langs);
        return $langs;
    }
723226
public function getStatus()
    {
        $status = self::STATUS_OK;

        foreach ($this->getItems() as $item) {
            if ($item->getStatus() === self::STATUS_ERROR) {
                return self::STATUS_ERROR;
            }

            if ($item->getStatus() === self::STATUS_WARNING) {
                $status = self::STATUS_WARNING;
            }
        }

        return $status;
    }