[ Avaa Bypassed ]




Upload:

Command:

hmhc3928@3.133.131.180: ~ $
<?php
/**
 * SegmentPlugin for phplist.
 *
 * This file is a part of SegmentPlugin.
 *
 * SegmentPlugin is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * CriteriaPlugin is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * @category  phplist
 *
 * @author    Duncan Cameron
 * @copyright 2014-2017 Duncan Cameron
 * @license   http://www.gnu.org/licenses/gpl.html GNU General Public License, Version 3
 */

/**
 * @category  phplist
 */
class SegmentPlugin_SavedSegments
{
    private $segments = array();
    private $summary = array();

    /**
     * Synchronise the summary and saved segments so that they contain the same entries.
     */
    private function synchronise()
    {
        // remove from summary any entries that do not exist in saved segments
        $names = array_column($this->segments, 'name', 'name');
        $this->summary = array_values(
            array_filter(
                $this->summary,
                function ($value) use ($names) {
                    return isset($names[$value]);
                }
            )
        );

        // remove from saved segments any entries that do not exist in summary
        $newSegments = array();

        foreach ($this->segments as $k => $v) {
            $pos = array_search($v['name'], $this->summary, true);

            if ($pos !== false) {
                $newSegments[$pos] = $v;
            }
        }
        $this->segments = $newSegments;
        SaveConfig('segment_saved', serialize($this->segments));
        SaveConfig('segment_saved_summary', $this->stringify());
    }

    /**
     * Convert the summary array to text for displaying on the Settings page.
     *
     * @return string the summary array converted to a string
     */
    private function stringify()
    {
        return implode("\n", $this->summary);
    }

    /**
     * Convert the summary text to an array by splitting into an array of lines.
     *
     * @param string $summary
     *
     * @return string the summary array converted to a string
     */
    private function unstringify($summary)
    {
        return preg_split("/[\r\n|\r|\n]+/", $summary);
    }

    /**
     * Constructor.
     */
    public function __construct()
    {
        $summary = getConfig('segment_saved_summary');
        $saved = getConfig('segment_saved');

        if ($summary) {
            $this->summary = $this->unstringify($summary);
        }

        if ($saved) {
            $this->segments = unserialize($saved);
            $this->synchronise();
        }
    }

    /**
     * Add a segment to the summary and saved segments
     * If the segment name already exists then the current segment is replaced.
     *
     * @param string $name       the segment name
     * @param array  $conditions array of conditions
     */
    public function addSegment($name, array $conditions)
    {
        $position = array_search($name, $this->summary, true);

        if ($position === false) {
            $position = count($this->summary);
        }
        $this->segments[$position] = array(
            'name' => $name,
            'conditions' => $conditions,
        );
        $this->summary[$position] = $name;

        SaveConfig('segment_saved', serialize($this->segments));
        SaveConfig('segment_saved_summary', $this->stringify());
    }

    /**
     * Return a saved segment.
     *
     * @param int $id the segment id
     *
     * @return array the segment's conditions
     */
    public function segmentById($id)
    {
        if (!isset($this->segments[$id])) {
            throw new Exception("Invalid segment id $id");
        }

        return $this->segments[$id]['conditions'];
    }

    /**
     * Provides the data to populate a select list.
     *
     * @return array data for select list options - value => display
     */
    public function selectListData()
    {
        return $this->summary;
    }
}

Filemanager

Name Type Size Permission Actions
Controller Folder 0755
lan Folder 0755
AttributeConditionCheckbox.php File 1.56 KB 0644
AttributeConditionCheckboxgroup.php File 2.37 KB 0644
AttributeConditionDate.php File 2.09 KB 0644
AttributeConditionSelect.php File 1.93 KB 0644
AttributeConditionText.php File 3.17 KB 0644
Condition.php File 1.58 KB 0644
ConditionException.php File 889 B 0644
ConditionFactory.php File 3.67 KB 0644
ControllerFactory.php File 1.54 KB 0644
DAO.php File 5.78 KB 0644
DateConditionBase.php File 3.13 KB 0644
NoConditionsException.php File 892 B 0644
Operator.php File 1.34 KB 0644
SavedSegments.php File 4.18 KB 0644
Segment.php File 6.9 KB 0644
SelectedSubscribersExport.php File 1.39 KB 0644
SubscriberConditionActivity.php File 3.6 KB 0644
SubscriberConditionEmail.php File 2.28 KB 0644
SubscriberConditionEntered.php File 1.78 KB 0644
SubscriberConditionIdentity.php File 1.81 KB 0644
SubscriberConditionListEntered.php File 1.62 KB 0644
SubscriberConditionLists.php File 1.82 KB 0644
ValueException.php File 925 B 0644
class_map.php File 1.58 KB 0644
depends.php File 1.7 KB 0644
export.php File 887 B 0644
script.html File 772 B 0644
sendtab.tpl.php File 3.17 KB 0644
styles.html File 1.12 KB 0644
version.txt File 14 B 0644
viewmessage.tpl.php File 1.51 KB 0644