예제 #1
0
 /**
  * Creates a new client
  *
  * @param string $companyName The client company name.
  * @param string $contactName The personal name of the principle contact for this client.
  * @param string $email An email address to which this client will be sent application-related emails.
  * @param string[optional] $country This client’s country.
  * @param string[optional] $timezone Client timezone for tracking and reporting data.
  */
 public static function createClient($companyName, $contactName, $email, $country = 'Belgium', $timezone = '(GMT+01:00) Brussels, Copenhagen, Madrid, Paris')
 {
     // create client
     $clientId = self::getCM()->createClient($companyName, $contactName, $email, $country, $timezone);
     // add client ID as a module setting for mailmotor
     BackendModel::setModuleSetting('mailmotor', 'cm_client_id', $clientId);
 }
예제 #2
0
 /**
  * Validates the settings form
  *
  * @return	void
  */
 private function validateForm()
 {
     // form is submitted
     if ($this->frm->isSubmitted()) {
         // cleanup the submitted fields, ignore fields that were added by hackers
         $this->frm->cleanupFields();
         // form is validated
         if ($this->frm->isCorrect()) {
             // set our settings (overview map)
             BackendModel::setModuleSetting($this->URL->getModule(), 'zoom_level', (string) $this->frm->getField('zoom_level')->getValue());
             BackendModel::setModuleSetting($this->URL->getModule(), 'width', (int) $this->frm->getField('width')->getValue());
             BackendModel::setModuleSetting($this->URL->getModule(), 'height', (int) $this->frm->getField('height')->getValue());
             BackendModel::setModuleSetting($this->URL->getModule(), 'map_type', (string) $this->frm->getField('map_type')->getValue());
             // set our settings (widgets)
             BackendModel::setModuleSetting($this->URL->getModule(), 'zoom_level_widget', (string) $this->frm->getField('zoom_level_widget')->getValue());
             BackendModel::setModuleSetting($this->URL->getModule(), 'width_widget', (int) $this->frm->getField('width_widget')->getValue());
             BackendModel::setModuleSetting($this->URL->getModule(), 'height_widget', (int) $this->frm->getField('height_widget')->getValue());
             BackendModel::setModuleSetting($this->URL->getModule(), 'map_type_widget', (string) $this->frm->getField('map_type_widget')->getValue());
             // trigger event
             BackendModel::triggerEvent($this->getModule(), 'after_saved_settings');
             // redirect to the settings page
             $this->redirect(BackendModel::createURLForAction('settings') . '&report=saved');
         }
     }
 }
 /**
  * Execute the action
  *
  * @return	void
  */
 public function execute()
 {
     // call parent, this will probably add some general CSS/JS or other required files
     parent::execute();
     // fork is no longer authorized to collect analytics data
     if (BackendAnalyticsHelper::getStatus() == 'UNAUTHORIZED') {
         // remove all parameters from the module settings
         BackendModel::setModuleSetting($this->getModule(), 'session_token', null);
         BackendModel::setModuleSetting($this->getModule(), 'account_name', null);
         BackendModel::setModuleSetting($this->getModule(), 'table_id', null);
         BackendModel::setModuleSetting($this->getModule(), 'profile_title', null);
         // remove cache files
         BackendAnalyticsModel::removeCacheFiles();
         // clear tables
         BackendAnalyticsModel::clearTables();
         // return status
         $this->output(self::OK, array('status' => 'unauthorized', 'message' => BL::msg('Redirecting')), 'No longer authorized.');
     }
     // get data
     $this->getData();
     // get html
     $referrersHtml = $this->parseReferrers();
     $keywordsHtml = $this->parseKeywords();
     // return status
     $this->output(self::OK, array('status' => 'success', 'referrersHtml' => $referrersHtml, 'keywordsHtml' => $keywordsHtml, 'date' => BL::lbl('Today'), 'message' => BL::msg('RefreshedTrafficSources')), 'Data has been retrieved.');
 }
예제 #4
0
 /**
  * Validates the settings form
  */
 private function validateForm()
 {
     if ($this->frm->isSubmitted()) {
         $this->frm->cleanupFields();
         if ($this->frm->isCorrect()) {
             // set the base values
             $width = (int) $this->frm->getField('width_widget')->getValue();
             $height = (int) $this->frm->getField('height_widget')->getValue();
             if ($width > 800) {
                 $width = 800;
             } elseif ($width < 300) {
                 $width = BackendModel::getModuleSetting('location', 'width_widget');
             }
             if ($height < 150) {
                 $height = BackendModel::getModuleSetting('location', 'height_widget');
             }
             // set our settings (widgets)
             BackendModel::setModuleSetting($this->URL->getModule(), 'zoom_level_widget', (string) $this->frm->getField('zoom_level_widget')->getValue());
             BackendModel::setModuleSetting($this->URL->getModule(), 'width_widget', $width);
             BackendModel::setModuleSetting($this->URL->getModule(), 'height_widget', $height);
             BackendModel::setModuleSetting($this->URL->getModule(), 'map_type_widget', (string) $this->frm->getField('map_type_widget')->getValue());
             // trigger event
             BackendModel::triggerEvent($this->getModule(), 'after_saved_settings');
             // redirect to the settings page
             $this->redirect(BackendModel::createURLForAction('settings') . '&report=saved');
         }
     }
 }
예제 #5
0
 /**
  * Execute the action
  */
 public function execute()
 {
     parent::execute();
     // get parameters
     $url = SpoonFilter::getPostValue('url', null, '');
     $username = SpoonFilter::getPostValue('username', null, '');
     $password = SpoonFilter::getPostValue('password', null, '');
     // filter out the 'http://' from the URL
     if (strpos($url, 'http://') !== false) {
         $url = str_replace('http://', '', $url);
     }
     if (strpos($url, 'https://') !== false) {
         $url = str_replace('https://', '', $url);
     }
     // check input
     if (empty($url)) {
         $this->output(self::BAD_REQUEST, array('field' => 'url'), BL::err('NoCMAccountCredentials'));
     }
     if (empty($username)) {
         $this->output(self::BAD_REQUEST, array('field' => 'username'), BL::err('NoCMAccountCredentials'));
     }
     if (empty($password)) {
         $this->output(self::BAD_REQUEST, array('field' => 'password'), BL::err('NoCMAccountCredentials'));
     }
     try {
         // check if the CampaignMonitor class exists
         if (!SpoonFile::exists(PATH_LIBRARY . '/external/campaignmonitor.php')) {
             // the class doesn't exist, so stop here
             $this->output(self::BAD_REQUEST, null, BL::err('ClassDoesNotExist', $this->getModule()));
         }
         // require CampaignMonitor class
         require_once 'external/campaignmonitor.php';
         // init CampaignMonitor object
         new CampaignMonitor($url, $username, $password, 10);
         // save the new data
         BackendModel::setModuleSetting($this->getModule(), 'cm_url', $url);
         BackendModel::setModuleSetting($this->getModule(), 'cm_username', $username);
         BackendModel::setModuleSetting($this->getModule(), 'cm_password', $password);
         // account was linked
         BackendModel::setModuleSetting($this->getModule(), 'cm_account', true);
     } catch (Exception $e) {
         // timeout occured
         if ($e->getMessage() == 'Error Fetching http headers') {
             $this->output(self::BAD_REQUEST, null, BL::err('CmTimeout', $this->getModule()));
         }
         // other error
         $this->output(self::ERROR, array('field' => 'url'), sprintf(BL::err('CampaignMonitorError', $this->getModule()), $e->getMessage()));
     }
     // trigger event
     BackendModel::triggerEvent($this->getModule(), 'after_account_linked');
     // CM was successfully initialized
     $this->output(self::OK, array('message' => 'account-linked'), BL::msg('AccountLinked', $this->getModule()));
 }
예제 #6
0
 /**
  * Validates the settings form
  *
  * @return	void
  */
 private function validateForm()
 {
     // form is submitted
     if ($this->frm->isSubmitted()) {
         // form is validated
         if ($this->frm->isCorrect()) {
             // set our settings
             BackendModel::setModuleSetting($this->getModule(), 'meta_navigation', (bool) $this->frm->getField('meta_navigation')->getValue());
             // trigger event
             BackendModel::triggerEvent($this->getModule(), 'after_saved_settings');
             // redirect to the settings page
             $this->redirect(BackendModel::createURLForAction('settings') . '&report=saved');
         }
     }
 }
 /**
  * Execute the action
  */
 public function execute()
 {
     parent::execute();
     // fork is no longer authorized to collect analytics data
     if (BackendAnalyticsHelper::getStatus() == 'UNAUTHORIZED') {
         // remove all parameters from the module settings
         BackendModel::setModuleSetting('analytics', 'session_token', null);
         BackendModel::setModuleSetting('analytics', 'account_name', null);
         BackendModel::setModuleSetting('analytics', 'table_id', null);
         BackendModel::setModuleSetting('analytics', 'profile_title', null);
         BackendAnalyticsModel::removeCacheFiles();
         BackendAnalyticsModel::clearTables();
         return;
     }
     $this->getData();
 }
예제 #8
0
 /**
  * Validates the form
  *
  * @return	void
  */
 private function validateForm()
 {
     // is the form submitted?
     if ($this->frm->isSubmitted()) {
         // no errors ?
         if ($this->frm->isCorrect()) {
             // smtp settings
             BackendModel::setModuleSetting('core', 'seo_noodp', $this->frm->getField('seo_noodp')->getValue());
             BackendModel::setModuleSetting('core', 'seo_noydir', $this->frm->getField('seo_noydir')->getValue());
             BackendModel::setModuleSetting('core', 'seo_nofollow_in_comments', $this->frm->getField('seo_nofollow_in_comments')->getValue());
             // assign report
             $this->tpl->assign('report', true);
             $this->tpl->assign('reportMessage', BL::msg('Saved'));
         }
     }
 }
예제 #9
0
 public function __construct()
 {
     // because some cronjobs will be run on the command line we should pass parameters
     if (isset($_SERVER['argv'])) {
         // init var
         $first = true;
         // loop all passes arguments
         foreach ($_SERVER['argv'] as $parameter) {
             // ignore first, because this is the scripts name.
             if ($first) {
                 // reset
                 $first = false;
                 // skip
                 continue;
             }
             // split into chunks
             $chunks = explode('=', $parameter, 2);
             // valid paramters?
             if (count($chunks) == 2) {
                 // build key and value
                 $key = trim($chunks[0], '--');
                 $value = $chunks[1];
                 // set in GET
                 if ($key != '' && $value != '') {
                     $_GET[$key] = $value;
                 }
             }
         }
     }
     // define the Named Application
     if (!defined('NAMED_APPLICATION')) {
         define('NAMED_APPLICATION', 'backend');
     }
     // set the module
     $this->setModule(SpoonFilter::getGetValue('module', null, ''));
     // set the requested file
     $this->setAction(SpoonFilter::getGetValue('action', null, ''));
     // set the language
     $this->setLanguage(SpoonFilter::getGetValue('language', FrontendLanguage::getActiveLanguages(), SITE_DEFAULT_LANGUAGE));
     // mark cronjob as run
     $cronjobs = (array) BackendModel::getModuleSetting('core', 'cronjobs');
     $cronjobs[] = $this->getModule() . '.' . $this->getAction();
     BackendModel::setModuleSetting('core', 'cronjobs', array_unique($cronjobs));
     // create new action
     $action = new BackendCronjobAction($this->getAction(), $this->getModule());
     $action->execute();
 }
예제 #10
0
 /**
  * Returns true if every working language has a default group set, false if at least one is missing.
  *
  * @return bool
  */
 public static function checkDefaultGroups()
 {
     // check if the defaults were set already, and return true if they were
     if (BackendModel::getModuleSetting('mailmotor', 'cm_groups_defaults_set')) {
         return true;
     }
     // get all default groups
     $defaults = self::getDefaultGroups();
     // if the total amount of working languages do not add up to the total amount of default groups not all default groups were set.
     if (count(BL::getWorkingLanguages()) === count($defaults)) {
         // cm_groups_defaults_set status is now true
         BackendModel::setModuleSetting('mailmotor', 'cm_groups_defaults_set', true);
         // return true
         return true;
     }
     // if we made it here, not all default groups were set; return false
     return false;
 }
예제 #11
0
 /**
  * Validates the settings form
  */
 private function validateForm()
 {
     if ($this->frm->isSubmitted()) {
         if ($this->frm->isCorrect()) {
             // set our settings
             BackendModel::setModuleSetting($this->URL->getModule(), 'overview_num_items_per_category', (int) $this->frm->getField('overview_number_of_items_per_category')->getValue());
             BackendModel::setModuleSetting($this->URL->getModule(), 'most_read_num_items', (int) $this->frm->getField('most_read_number_of_items')->getValue());
             BackendModel::setModuleSetting($this->URL->getModule(), 'related_num_items', (int) $this->frm->getField('related_number_of_items')->getValue());
             BackendModel::setModuleSetting($this->URL->getModule(), 'spamfilter', (bool) $this->frm->getField('spamfilter')->getValue());
             BackendModel::setModuleSetting($this->URL->getModule(), 'allow_feedback', (bool) $this->frm->getField('allow_feedback')->getValue());
             BackendModel::setModuleSetting($this->URL->getModule(), 'allow_own_question', (bool) $this->frm->getField('allow_own_question')->getValue());
             BackendModel::setModuleSetting($this->URL->getModule(), 'send_email_on_new_feedback', (bool) $this->frm->getField('send_email_on_new_feedback')->getValue());
             if (BackendModel::getModuleSetting('core', 'akismet_key') === null) {
                 BackendModel::setModuleSetting($this->URL->getModule(), 'spamfilter', false);
             }
             // redirect to the settings page
             $this->redirect(BackendModel::createURLForAction('settings') . '&report=saved');
         }
     }
 }
예제 #12
0
 /**
  * Execute the action
  *
  * @return	void
  */
 public function execute()
 {
     // call parent, this will probably add some general CSS/JS or other required files
     parent::execute();
     // fork is no longer authorized to collect analytics data
     if (BackendAnalyticsHelper::getStatus() == 'UNAUTHORIZED') {
         // remove all parameters from the module settings
         BackendModel::setModuleSetting('analytics', 'session_token', null);
         BackendModel::setModuleSetting('analytics', 'account_name', null);
         BackendModel::setModuleSetting('analytics', 'table_id', null);
         BackendModel::setModuleSetting('analytics', 'profile_title', null);
         // remove cache files
         BackendAnalyticsModel::removeCacheFiles();
         // clear tables
         BackendAnalyticsModel::clearTables();
         // stop here
         return;
     }
     // get data
     $this->getData();
 }
예제 #13
0
    /**
     * Calculate the maximum number of blocks for all active templates and store into a module-settings
     *
     * @return	void
     */
    public static function setMaximumBlocks()
    {
        // get maximum number of blocks for active templates
        $maximumNumberOfBlocks = (int) BackendModel::getDB()->getVar('SELECT MAX(i.num_blocks) AS max_num_blocks
																		FROM pages_templates AS i
																		WHERE i.active = ? AND i.theme = ?', array('Y', BackendModel::getModuleSetting('core', 'theme', 'core')));
        // store
        BackendModel::setModuleSetting('pages', 'template_max_blocks', $maximumNumberOfBlocks);
    }
예제 #14
0
 /**
  * Validates the settings form
  */
 private function validateForm()
 {
     // form is submitted
     if ($this->frm->isSubmitted()) {
         // validate module weights
         foreach ($this->modules as $i => $module) {
             // only if this module is enabled
             if ($this->frm->getField('search_' . $module['module'])->getChecked()) {
                 // valid weight?
                 $this->frm->getField('search_' . $module['module'] . '_weight')->isDigital(BL::err('WeightNotNumeric'));
                 $this->modules[$i]['txtError'] = $this->frm->getField('search_' . $module['module'] . '_weight')->getErrors();
             }
         }
         // form is validated
         if ($this->frm->isCorrect()) {
             // set our settings
             BackendModel::setModuleSetting($this->URL->getModule(), 'overview_num_items', $this->frm->getField('overview_num_items')->getValue());
             BackendModel::setModuleSetting($this->URL->getModule(), 'autocomplete_num_items', $this->frm->getField('autocomplete_num_items')->getValue());
             BackendModel::setModuleSetting($this->URL->getModule(), 'autosuggest_num_items', $this->frm->getField('autosuggest_num_items')->getValue());
             // module search
             foreach ((array) $this->modules as $module) {
                 $searchable = $this->frm->getField('search_' . $module['module'])->getChecked() ? 'Y' : 'N';
                 $weight = $this->frm->getField('search_' . $module['module'] . '_weight')->getValue();
                 // insert, or update
                 BackendSearchModel::insertModuleSettings($module, $searchable, $weight);
             }
             // trigger event
             BackendModel::triggerEvent($this->getModule(), 'after_changed_settings');
             // redirect to the settings page
             $this->redirect(BackendModel::createURLForAction('settings') . '&report=saved');
         }
     }
 }
예제 #15
0
 /**
  * Validate the form
  *
  * @return	void
  */
 private function validateForm()
 {
     // is the form submitted?
     if ($this->frm->isSubmitted()) {
         // cleanup the submitted fields, ignore fields that were added by hackers
         $this->frm->cleanupFields();
         // no errors?
         if ($this->frm->isCorrect()) {
             // the total amount of subscribers
             $subscribersTotal = 0;
             // loop all groups
             foreach ($this->externalGroups as $group) {
                 // insert them in our database
                 $groupID = BackendModel::getDB(true)->insert('mailmotor_groups', array('name' => $group['name'], 'custom_fields' => $group['custom_fields'], 'created_on' => BackendModel::getUTCDate()));
                 // insert the CM ID
                 BackendMailmotorCMHelper::insertCampaignMonitorID('list', $group['id'], $groupID);
                 // continue looping if this group has no subscribers
                 if (empty($group['subscribers'])) {
                     continue;
                 }
                 // add this groups subscribers amount to the total
                 $subscribersTotal += $group['subscribers_amount'];
                 // loop the subscribers for this group, and import them
                 foreach ($group['subscribers'] as $subscriber) {
                     // build new subscriber record
                     $item = array();
                     $item['email'] = $subscriber['email'];
                     $item['source'] = 'import';
                     $item['created_on'] = $subscriber['date'];
                     // add an additional custom field 'name', if it was set in the subscriber record
                     if (!empty($subscriber['name'])) {
                         $subscriber['custom_fields']['Name'] = $subscriber['name'];
                     }
                     // save the subscriber in our database, and subscribe it to this group
                     BackendMailmotorModel::saveAddress($item, $groupID, !empty($subscriber['custom_fields']) ? $subscriber['custom_fields'] : null);
                 }
             }
             // at this point, groups are set
             BackendModel::setModuleSetting($this->getModule(), 'cm_groups_set', true);
             // trigger event
             BackendModel::triggerEvent($this->getModule(), 'after_import_groups');
             // redirect to the index
             $this->redirect(BackendModel::createURLForAction('index', $this->getModule()) . '&report=groups-imported&var[]=' . count($this->externalGroups) . '&var[]=' . $subscribersTotal);
         }
     }
 }
예제 #16
0
 /**
  * Validates the form
  *
  * @return	void
  */
 private function validateForm()
 {
     // is the form submitted?
     if ($this->frm->isSubmitted()) {
         // no errors?
         if ($this->frm->isCorrect()) {
             // determine themes
             $newTheme = $this->frm->getField('theme')->getValue();
             $oldTheme = BackendModel::getModuleSetting('core', 'theme', 'core');
             // check if we actually switched themes
             if ($newTheme != $oldTheme) {
                 // fetch templates
                 $oldTemplates = BackendPagesModel::getTemplates($oldTheme);
                 $newTemplates = BackendPagesModel::getTemplates($newTheme);
                 // check if templates already exist
                 if (empty($newTemplates)) {
                     // templates do not yet exist; don't switch
                     $this->redirect(BackendModel::createURLForAction('themes') . '&error=no-templates-available');
                     exit;
                 }
                 // fetch current default template
                 $oldDefaultTemplatePath = $oldTemplates[BackendModel::getModuleSetting('pages', 'default_template')]['path'];
                 // loop new templates
                 foreach ($newTemplates as $newTemplateId => $newTemplate) {
                     // check if a a similar default template exists
                     if ($newTemplate['path'] == $oldDefaultTemplatePath) {
                         // set new default id
                         $newDefaultTemplateId = (int) $newTemplateId;
                         break;
                     }
                 }
                 // no default template was found, set first template as default
                 if (!isset($newDefaultTemplateId)) {
                     $newDefaultTemplateId = array_keys($newTemplates);
                     $newDefaultTemplateId = $newDefaultTemplateId[0];
                 }
                 // update theme
                 BackendModel::setModuleSetting('core', 'theme', $newTheme);
                 // set amount of blocks
                 BackendPagesModel::setMaximumBlocks();
                 // save new default template
                 BackendModel::setModuleSetting('pages', 'default_template', $newDefaultTemplateId);
                 // loop old templates
                 foreach ($oldTemplates as $oldTemplateId => $oldTemplate) {
                     // loop new templates
                     foreach ($newTemplates as $newTemplateId => $newTemplate) {
                         // check if we have a matching template
                         if ($oldTemplate['path'] == $newTemplate['path']) {
                             // switch template
                             BackendPagesModel::updatePagesTemplates($oldTemplateId, $newTemplateId);
                             // break loop
                             continue 2;
                         }
                     }
                     // getting here meant we found no matching template for the new theme; pick first theme's template as default
                     BackendPagesModel::updatePagesTemplates($oldTemplateId, $newDefaultTemplateId);
                 }
                 // trigger event
                 BackendModel::triggerEvent($this->getModule(), 'after_changed_theme');
             }
             // assign report
             $this->tpl->assign('report', true);
             $this->tpl->assign('reportMessage', BL::msg('Saved'));
         }
     }
 }
예제 #17
0
 /**
  * Gets all the needed parameters to link a google analytics account to fork
  */
 private function getAnalyticsParameters()
 {
     $remove = SpoonFilter::getGetValue('remove', array('session_token', 'table_id'), null);
     // something has to be removed before proceeding
     if (!empty($remove)) {
         // the session token has te be removed
         if ($remove == 'session_token') {
             // remove all parameters from the module settings
             BackendModel::setModuleSetting($this->getModule(), 'session_token', null);
         }
         // remove all profile parameters from the module settings
         BackendModel::setModuleSetting($this->getModule(), 'account_name', null);
         BackendModel::setModuleSetting($this->getModule(), 'table_id', null);
         BackendModel::setModuleSetting($this->getModule(), 'profile_title', null);
         // remove cache files
         BackendAnalyticsModel::removeCacheFiles();
         // clear tables
         BackendAnalyticsModel::clearTables();
     }
     // get session token, account name, the profile's table id, the profile's title
     $this->sessionToken = BackendModel::getModuleSetting($this->getModule(), 'session_token', null);
     $this->accountName = BackendModel::getModuleSetting($this->getModule(), 'account_name', null);
     $this->tableId = BackendModel::getModuleSetting($this->getModule(), 'table_id', null);
     $this->profileTitle = BackendModel::getModuleSetting($this->getModule(), 'profile_title', null);
     // no session token
     if (!isset($this->sessionToken)) {
         $token = SpoonFilter::getGetValue('token', null, null);
         // a one time token is given in the get parameters
         if (!empty($token) && $token !== 'true') {
             // get google analytics instance
             $ga = BackendAnalyticsHelper::getGoogleAnalyticsInstance();
             // get a session token
             $this->sessionToken = $ga->getSessionToken($token);
             // store the session token in the settings
             BackendModel::setModuleSetting($this->getModule(), 'session_token', $this->sessionToken);
         }
     }
     // session id is present but there is no table_id
     if (isset($this->sessionToken) && !isset($this->tableId)) {
         // get google analytics instance
         $ga = BackendAnalyticsHelper::getGoogleAnalyticsInstance();
         // get all possible profiles in this account
         $this->profiles = $ga->getAnalyticsAccountList($this->sessionToken);
         // not authorized
         if ($this->profiles == 'UNAUTHORIZED') {
             // remove invalid session token
             BackendModel::setModuleSetting($this->getModule(), 'session_token', null);
             // redirect to the settings page without parameters
             $this->redirect(BackendModel::createURLForAction('settings'));
         } elseif (is_array($this->profiles)) {
             $tableId = SpoonFilter::getGetValue('table_id', null, null);
             // a table id is given in the get parameters
             if (!empty($tableId)) {
                 $profiles = array();
                 // set the table ids as keys
                 foreach ($this->profiles as $profile) {
                     $profiles[$profile['tableId']] = $profile;
                 }
                 // correct table id
                 if (isset($profiles[$tableId])) {
                     // save table id and account title
                     $this->tableId = $tableId;
                     $this->accountName = $profiles[$this->tableId]['accountName'];
                     $this->profileTitle = $profiles[$this->tableId]['title'];
                     $webPropertyId = $profiles[$this->tableId]['webPropertyId'];
                     // store the table id and account title in the settings
                     BackendModel::setModuleSetting($this->getModule(), 'account_name', $this->accountName);
                     BackendModel::setModuleSetting($this->getModule(), 'table_id', $this->tableId);
                     BackendModel::setModuleSetting($this->getModule(), 'profile_title', $this->profileTitle);
                     BackendModel::setModuleSetting($this->getModule(), 'web_property_id', $webPropertyId);
                 }
             }
         }
     }
 }
예제 #18
0
 /**
  * Checks if any groups are made yet. Depending on the client that is linked to Fork, it will creates default groups if none were found in CampaignMonitor.
  * If they were, the user is presented with an overview to import all groups and their subscribers in Fork.
  *
  * @return	void
  */
 private function checkForGroups()
 {
     // groups are already set
     if (BackendModel::getModuleSetting('mailmotor', 'cm_groups_set')) {
         return false;
     }
     // no CM data found
     if (!BackendMailmotorCMHelper::checkAccount()) {
         return false;
     }
     // check if there are external groups present in CampaignMonitor
     if ($this->checkForExternalGroups()) {
         // external groups were found, so redirect to the import_groups action
         SpoonHTTP::redirect(BackendModel::createURLForAction('import_groups', 'mailmotor'));
     }
     // fetch the default groups, language abbreviation is the array key
     $groups = BackendMailmotorModel::getDefaultGroups();
     // loop languages
     foreach (BL::getActiveLanguages() as $language) {
         // this language does not have a default group set
         if (!isset($groups[$language])) {
             // set group record
             $group['name'] = 'Website (' . strtoupper($language) . ')';
             $group['language'] = $language;
             $group['is_default'] = 'Y';
             $group['created_on'] = date('Y-m-d H:i:s');
             try {
                 // insert the group in CampaignMonitor
                 BackendMailmotorCMHelper::insertGroup($group);
             } catch (CampaignMonitorException $e) {
                 // ignore
             }
         }
     }
     // we have groups set, and default groups chosen
     BackendModel::setModuleSetting('mailmotor', 'cm_groups_set', true);
     BackendModel::setModuleSetting('mailmotor', 'cm_groups_defaults_set', true);
 }
예제 #19
0
 /**
  * Validates the form
  *
  * @return	void
  */
 private function validateForm()
 {
     // is the form submitted?
     if ($this->frm->isSubmitted()) {
         // validate required fields
         $this->frm->getField('site_title')->isFilled(BL::err('FieldIsRequired'));
         // date & time
         $this->frm->getField('time_format')->isFilled(BL::err('FieldIsRequired'));
         $this->frm->getField('date_format_short')->isFilled(BL::err('FieldIsRequired'));
         $this->frm->getField('date_format_long')->isFilled(BL::err('FieldIsRequired'));
         // number
         $this->frm->getField('number_format')->isFilled(BL::err('FieldIsRequired'));
         // akismet key may be filled in
         if ($this->needsAkismet && $this->frm->getField('akismet_key')->isFilled()) {
             // key has changed
             if ($this->frm->getField('akismet_key')->getValue() != BackendModel::getModuleSetting('core', 'akismet_key', null)) {
                 // load akismet
                 require_once PATH_LIBRARY . '/external/akismet.php';
                 // create instance
                 $akismet = new Akismet($this->frm->getField('akismet_key')->getValue(), SITE_URL);
                 // invalid key
                 if (!$akismet->verifyKey()) {
                     $this->frm->getField('akismet_key')->setError(BL::err('InvalidAPIKey'));
                 }
             }
         }
         // domains filled in
         if ($this->frm->getField('site_domains')->isFilled()) {
             // split on newlines
             $domains = explode("\n", trim($this->frm->getField('site_domains')->getValue()));
             // loop domains
             foreach ($domains as $domain) {
                 // strip funky stuff
                 $domain = trim(str_replace(array('www.', 'http://', 'https://'), '', $domain));
                 // invalid URL
                 if (!SpoonFilter::isURL('http://' . $domain)) {
                     // set error
                     $this->frm->getField('site_domains')->setError(BL::err('InvalidDomain'));
                     // stop looping domains
                     break;
                 }
             }
         }
         // no errors ?
         if ($this->frm->isCorrect()) {
             // general settings
             BackendModel::setModuleSetting('core', 'site_title_' . BL::getWorkingLanguage(), $this->frm->getField('site_title')->getValue());
             BackendModel::setModuleSetting('core', 'site_html_header', $this->frm->getField('site_html_header')->getValue());
             BackendModel::setModuleSetting('core', 'site_html_footer', $this->frm->getField('site_html_footer')->getValue());
             // facebook settings
             BackendModel::setModuleSetting('core', 'facebook_admin_ids', $this->frm->getField('facebook_admin_ids')->isFilled() ? $this->frm->getField('facebook_admin_ids')->getValue() : null);
             BackendModel::setModuleSetting('core', 'facebook_app_id', $this->frm->getField('facebook_application_id')->isFilled() ? $this->frm->getField('facebook_application_id')->getValue() : null);
             BackendModel::setModuleSetting('core', 'facebook_app_secret', $this->frm->getField('facebook_application_secret')->isFilled() ? $this->frm->getField('facebook_application_secret')->getValue() : null);
             // api keys
             BackendModel::setModuleSetting('core', 'fork_api_public_key', $this->frm->getField('fork_api_public_key')->getValue());
             BackendModel::setModuleSetting('core', 'fork_api_private_key', $this->frm->getField('fork_api_private_key')->getValue());
             if ($this->needsAkismet) {
                 BackendModel::setModuleSetting('core', 'akismet_key', $this->frm->getField('akismet_key')->getValue());
             }
             if ($this->needsGoogleMaps) {
                 BackendModel::setModuleSetting('core', 'google_maps_key', $this->frm->getField('google_maps_key')->getValue());
             }
             // date & time formats
             BackendModel::setModuleSetting('core', 'time_format', $this->frm->getField('time_format')->getValue());
             BackendModel::setModuleSetting('core', 'date_format_short', $this->frm->getField('date_format_short')->getValue());
             BackendModel::setModuleSetting('core', 'date_format_long', $this->frm->getField('date_format_long')->getValue());
             // date & time formats
             BackendModel::setModuleSetting('core', 'number_format', $this->frm->getField('number_format')->getValue());
             // before we save the languages, we need to ensure that each language actually exists and may be chosen.
             $languages = array(SITE_DEFAULT_LANGUAGE);
             // save active languages
             BackendModel::setModuleSetting('core', 'active_languages', array_unique(array_merge($languages, $this->frm->getField('active_languages')->getValue())));
             BackendModel::setModuleSetting('core', 'redirect_languages', array_unique(array_merge($languages, $this->frm->getField('redirect_languages')->getValue())));
             // domains may not contain www, http or https. Therefor we must loop and create the list of domains.
             $siteDomains = array();
             // domains filled in
             if ($this->frm->getField('site_domains')->isFilled()) {
                 // split on newlines
                 $domains = explode("\n", trim($this->frm->getField('site_domains')->getValue()));
                 // loop domains
                 foreach ($domains as $domain) {
                     // strip funky stuff
                     $siteDomains[] = trim(str_replace(array('www.', 'http://', 'https://'), '', $domain));
                 }
             }
             // save domains
             BackendModel::setModuleSetting('core', 'site_domains', $siteDomains);
             // assign report
             $this->tpl->assign('report', true);
             $this->tpl->assign('reportMessage', BL::msg('Saved'));
         }
     }
 }
예제 #20
0
 /**
  * Validates the general tab
  *
  * @return	void
  */
 private function validateGeneralForm()
 {
     // form is submitted
     if ($this->frmGeneral->isSubmitted()) {
         // validate required fields
         $this->frmGeneral->getField('from_name')->isFilled(BL::getError('FieldIsRequired'));
         $this->frmGeneral->getField('from_email')->isEmail(BL::getError('EmailIsInvalid'));
         $this->frmGeneral->getField('reply_to_email')->isEmail(BL::getError('EmailIsInvalid'));
         // user is god
         if (BackendAuthentication::getUser()->isGod()) {
             $this->frmGeneral->getField('price_per_email')->isFilled(BL::err('FieldIsRequired'));
         }
         // form is validated
         if ($this->frmGeneral->isCorrect()) {
             // set sender info
             BackendModel::setModuleSetting($this->getModule(), 'from_name', $this->frmGeneral->getField('from_name')->getValue());
             BackendModel::setModuleSetting($this->getModule(), 'from_email', $this->frmGeneral->getField('from_email')->getValue());
             BackendModel::setModuleSetting($this->getModule(), 'reply_to_email', $this->frmGeneral->getField('reply_to_email')->getValue());
             BackendModel::setModuleSetting($this->getModule(), 'plain_text_editable', $this->frmGeneral->getField('plain_text_editable')->getValue());
             // set price per email
             if (BackendAuthentication::getUser()->isGod()) {
                 BackendModel::setModuleSetting($this->getModule(), 'price_per_email', $this->frmGeneral->getField('price_per_email')->getValue());
             }
             // trigger event
             BackendModel::triggerEvent($this->getModule(), 'after_saved_general_settings');
             // redirect to the settings page
             $this->redirect(BackendModel::createURLForAction('settings') . '&report=saved#tabGeneral');
         }
     }
 }
 /**
  * Validate the form
  */
 private function validateForm()
 {
     // is the form submitted?
     if ($this->frm->isSubmitted()) {
         // cleanup the submitted fields, ignore fields that were added by hackers
         $this->frm->cleanupFields();
         // required fields
         $this->frm->getField('file')->isFilled(BL::err('FieldIsRequired'));
         $this->frm->getField('label')->isFilled(BL::err('FieldIsRequired'));
         $this->frm->getField('format')->isFilled(BL::err('FieldIsRequired'));
         // validate syntax
         $syntax = trim(str_replace(array("\n", "\r", ' '), '', $this->frm->getField('format')->getValue()));
         // init var
         $table = BackendExtensionsModel::templateSyntaxToArray($syntax);
         // validate the syntax
         if ($table === false) {
             $this->frm->getField('format')->addError(BL::err('InvalidTemplateSyntax'));
         } else {
             $html = BackendExtensionsModel::buildTemplateHTML($syntax);
             $cellCount = 0;
             $first = true;
             $errors = array();
             // loop rows
             foreach ($table as $row) {
                 // first row defines the cellcount
                 if ($first) {
                     $cellCount = count($row);
                 }
                 // not same number of cells
                 if (count($row) != $cellCount) {
                     // add error
                     $errors[] = BL::err('InvalidTemplateSyntax');
                     // stop
                     break;
                 }
                 // doublecheck position names
                 foreach ($row as $cell) {
                     // ignore unavailable space
                     if ($cell != '/') {
                         // not alphanumeric -> error
                         if (!in_array($cell, $this->names)) {
                             $errors[] = sprintf(BL::getError('NonExistingPositionName'), $cell);
                         } elseif (substr_count($html, '"#position-' . $cell . '"') != 1) {
                             $errors[] = BL::err('InvalidTemplateSyntax');
                         }
                     }
                 }
                 // reset
                 $first = false;
             }
             // add errors
             if ($errors) {
                 $this->frm->getField('format')->addError(implode('<br />', array_unique($errors)));
             }
         }
         // no errors?
         if ($this->frm->isCorrect()) {
             // build array
             $item['id'] = $this->id;
             $item['theme'] = $this->frm->getField('theme')->getValue();
             $item['label'] = $this->frm->getField('label')->getValue();
             $item['path'] = 'core/layout/templates/' . $this->frm->getField('file')->getValue();
             $item['active'] = $this->frm->getField('active')->getChecked() ? 'Y' : 'N';
             $item['data']['format'] = trim(str_replace(array("\n", "\r", ' '), '', $this->frm->getField('format')->getValue()));
             $item['data']['names'] = $this->names;
             $item['data']['default_extras'] = $this->extras;
             $item['data']['default_extras_' . BackendLanguage::getWorkingLanguage()] = $this->extras;
             // serialize
             $item['data'] = serialize($item['data']);
             // if this is the default template make the template active
             if (BackendModel::getModuleSetting('pages', 'default_template') == $this->record['id']) {
                 $item['active'] = 'Y';
             }
             // if the template is in use we can't de-activate it
             if (BackendExtensionsModel::isTemplateInUse($item['id'])) {
                 $item['active'] = 'Y';
             }
             // insert the item
             BackendExtensionsModel::updateTemplate($item);
             // trigger event
             BackendModel::triggerEvent($this->getModule(), 'after_edit_template', array('item' => $item));
             // set default template
             if ($this->frm->getField('default')->getChecked() && $item['theme'] == BackendModel::getModuleSetting('core', 'theme', 'core')) {
                 BackendModel::setModuleSetting('pages', 'default_template', $item['id']);
             }
             // update all existing pages using this template to add the newly inserted block(s)
             if (BackendExtensionsModel::isTemplateInUse($item['id'])) {
                 BackendPagesModel::updatePagesTemplates($item['id'], $item['id'], $this->frm->getField('overwrite')->getChecked());
             }
             // everything is saved, so redirect to the overview
             $this->redirect(BackendModel::createURLForAction('theme_templates') . '&theme=' . $item['theme'] . '&report=edited-template&var=' . urlencode($item['label']) . '&highlight=row-' . $item['id']);
         }
     }
 }
예제 #22
0
 /**
  * Validate the form
  *
  * @return	void
  */
 private function validateForm()
 {
     // is the form submitted?
     if ($this->frm->isSubmitted()) {
         // cleanup the submitted fields, ignore fields that were added by hackers
         $this->frm->cleanupFields();
         // required fields
         $this->frm->getField('file')->isFilled(BL::err('FieldIsRequired'));
         $this->frm->getField('label')->isFilled(BL::err('FieldIsRequired'));
         $this->frm->getField('format')->isFilled(BL::err('FieldIsRequired'));
         // loop the know fields and validate them
         for ($i = 1; $i <= $this->frm->getField('num_blocks')->getValue(); $i++) {
             $this->frm->getField('name_' . $i)->isFilled(BL::err('FieldIsRequired'));
         }
         // validate syntax
         $syntax = trim(str_replace(array("\n", "\r"), '', $this->frm->getField('format')->getValue()));
         // init var
         $table = BackendPagesModel::templateSyntaxToArray($syntax);
         $cellCount = 0;
         $first = true;
         // loop rows
         foreach ($table as $row) {
             // first row defines the cellcount
             if ($first) {
                 $cellCount = count($row);
             }
             // not same number of cells
             if (count($row) != $cellCount) {
                 // add error
                 $this->frm->getField('format')->addError(BL::err('InvalidTemplateSyntax'));
                 // stop
                 break;
             }
             // reset
             $first = false;
         }
         // no errors?
         if ($this->frm->isCorrect()) {
             // build array
             $item['theme'] = $this->frm->getField('theme')->getValue();
             $item['label'] = $this->frm->getField('label')->getValue();
             $item['path'] = 'core/layout/templates/' . $this->frm->getField('file')->getValue();
             $item['num_blocks'] = $this->frm->getField('num_blocks')->getValue();
             $item['active'] = $this->frm->getField('active')->getChecked() ? 'Y' : 'N';
             $item['data']['format'] = trim(str_replace(array("\n", "\r"), '', $this->frm->getField('format')->getValue()));
             // loop fields
             for ($i = 1; $i <= $this->frm->getField('num_blocks')->getValue(); $i++) {
                 $item['data']['names'][] = $this->frm->getField('name_' . $i)->getValue();
                 $item['data']['default_extras'][] = $this->frm->getField('type_' . $i)->getValue();
                 $item['data']['default_extras_' . BackendLanguage::getWorkingLanguage()][] = $this->frm->getField('type_' . $i)->getValue();
             }
             // serialize the data
             $item['data'] = serialize($item['data']);
             // insert the item
             $item['id'] = BackendPagesModel::insertTemplate($item);
             // trigger event
             BackendModel::triggerEvent($this->getModule(), 'after_add_template', array('item' => $item));
             // set default template
             if ($this->frm->getField('default')->getChecked() && $item['theme'] == BackendModel::getModuleSetting('core', 'theme', 'core')) {
                 BackendModel::setModuleSetting($this->getModule(), 'default_template', $item['id']);
             }
             // everything is saved, so redirect to the overview
             $this->redirect(BackendModel::createURLForAction('templates') . '&theme=' . $item['theme'] . '&report=added-template&var=' . urlencode($item['label']) . '&highlight=row-' . $item['id']);
         }
     }
 }
예제 #23
0
 /**
  * Validates the settings form
  *
  * @return	void
  */
 private function validateForm()
 {
     // form is submitted
     if ($this->frm->isSubmitted()) {
         // shorten fields
         $feedburnerURL = $this->frm->getField('feedburner_url');
         // validation
         $this->frm->getField('rss_title')->isFilled(BL::err('FieldIsRequired'));
         // feedburner URL is set
         if ($feedburnerURL->isFilled()) {
             // check if http:// is set and add if necessary
             $feedburner = !strstr($feedburnerURL->getValue(), 'http://') ? 'http://' . $feedburnerURL->getValue() : $feedburnerURL->getValue();
             // check if feedburner URL is valid
             if (!SpoonFilter::isURL($feedburner)) {
                 $feedburnerURL->addError(BL::err('InvalidURL'));
             }
         } else {
             $feedburner = null;
         }
         // form is validated
         if ($this->frm->isCorrect()) {
             // set our settings
             BackendModel::setModuleSetting($this->URL->getModule(), 'overview_num_items', (int) $this->frm->getField('overview_number_of_items')->getValue());
             BackendModel::setModuleSetting($this->URL->getModule(), 'recent_articles_full_num_items', (int) $this->frm->getField('recent_articles_full_number_of_items')->getValue());
             BackendModel::setModuleSetting($this->URL->getModule(), 'recent_articles_list_num_items', (int) $this->frm->getField('recent_articles_list_number_of_items')->getValue());
             BackendModel::setModuleSetting($this->URL->getModule(), 'spamfilter', (bool) $this->frm->getField('spamfilter')->getValue());
             BackendModel::setModuleSetting($this->URL->getModule(), 'allow_comments', (bool) $this->frm->getField('allow_comments')->getValue());
             BackendModel::setModuleSetting($this->URL->getModule(), 'moderation', (bool) $this->frm->getField('moderation')->getValue());
             BackendModel::setModuleSetting($this->URL->getModule(), 'notify_by_email_on_new_comment_to_moderate', (bool) $this->frm->getField('notify_by_email_on_new_comment_to_moderate')->getValue());
             BackendModel::setModuleSetting($this->URL->getModule(), 'notify_by_email_on_new_comment', (bool) $this->frm->getField('notify_by_email_on_new_comment')->getValue());
             BackendModel::setModuleSetting($this->URL->getModule(), 'ping_services', (bool) $this->frm->getField('ping_services')->getValue());
             BackendModel::setModuleSetting($this->URL->getModule(), 'rss_title_' . BL::getWorkingLanguage(), $this->frm->getField('rss_title')->getValue());
             BackendModel::setModuleSetting($this->URL->getModule(), 'rss_description_' . BL::getWorkingLanguage(), $this->frm->getField('rss_description')->getValue());
             BackendModel::setModuleSetting($this->URL->getModule(), 'rss_meta_' . BL::getWorkingLanguage(), $this->frm->getField('rss_meta')->getValue());
             BackendModel::setModuleSetting($this->URL->getModule(), 'feedburner_url_' . BL::getWorkingLanguage(), $feedburner);
             if (BackendModel::getModuleSetting('core', 'akismet_key') === null) {
                 BackendModel::setModuleSetting($this->URL->getModule(), 'spamfilter', false);
             }
             // trigger event
             BackendModel::triggerEvent($this->getModule(), 'after_saved_settings');
             // redirect to the settings page
             $this->redirect(BackendModel::createURLForAction('settings') . '&report=saved');
         }
     }
 }
예제 #24
0
 /**
  * Validates the form
  *
  * @return	void
  */
 private function validateForm()
 {
     // is the form submitted?
     if ($this->frm->isSubmitted()) {
         // validate required fields
         $this->frm->getField('mailer_from_name')->isFilled(BL::err('FieldIsRequired'));
         $this->frm->getField('mailer_from_email')->isEmail(BL::err('EmailIsInvalid'));
         $this->frm->getField('mailer_to_name')->isFilled(BL::err('FieldIsRequired'));
         $this->frm->getField('mailer_to_email')->isEmail(BL::err('EmailIsInvalid'));
         $this->frm->getField('mailer_reply_to_name')->isFilled(BL::err('FieldIsRequired'));
         $this->frm->getField('mailer_reply_to_email')->isEmail(BL::err('EmailIsInvalid'));
         // SMTP type was chosen
         if ($this->frm->getField('mailer_type')->getValue() == 'smtp') {
             // server & port are required
             $this->frm->getField('smtp_server')->isFilled(BL::err('FieldIsRequired'));
             $this->frm->getField('smtp_port')->isFilled(BL::err('FieldIsRequired'));
         }
         // no errors ?
         if ($this->frm->isCorrect()) {
             // e-mail settings
             BackendModel::setModuleSetting('core', 'mailer_type', $this->frm->getField('mailer_type')->getValue());
             BackendModel::setModuleSetting('core', 'mailer_from', array('name' => $this->frm->getField('mailer_from_name')->getValue(), 'email' => $this->frm->getField('mailer_from_email')->getValue()));
             BackendModel::setModuleSetting('core', 'mailer_to', array('name' => $this->frm->getField('mailer_to_name')->getValue(), 'email' => $this->frm->getField('mailer_to_email')->getValue()));
             BackendModel::setModuleSetting('core', 'mailer_reply_to', array('name' => $this->frm->getField('mailer_reply_to_name')->getValue(), 'email' => $this->frm->getField('mailer_reply_to_email')->getValue()));
             // smtp settings
             BackendModel::setModuleSetting('core', 'smtp_server', $this->frm->getField('smtp_server')->getValue());
             BackendModel::setModuleSetting('core', 'smtp_port', $this->frm->getField('smtp_port')->getValue());
             BackendModel::setModuleSetting('core', 'smtp_username', $this->frm->getField('smtp_username')->getValue());
             BackendModel::setModuleSetting('core', 'smtp_password', $this->frm->getField('smtp_password')->getValue());
             // assign report
             $this->tpl->assign('report', true);
             $this->tpl->assign('reportMessage', BL::msg('Saved'));
         }
     }
 }
예제 #25
0
 /**
  * Execute the action
  *
  * @return	void
  */
 public function execute()
 {
     // call parent, this will probably add some general CSS/JS or other required files
     parent::execute();
     // get parameters
     $page = trim(SpoonFilter::getPostValue('page', null, ''));
     $identifier = trim(SpoonFilter::getPostValue('identifier', null, ''));
     // validate
     if ($page == '' || $identifier == '') {
         $this->output(self::BAD_REQUEST, null, 'No page provided.');
     }
     // init vars
     $filename = BACKEND_CACHE_PATH . '/analytics/' . $page . '_' . $identifier . '.txt';
     // does the temporary file still exits?
     $status = SpoonFile::getContent($filename);
     // no file - create one
     if ($status === false) {
         // create file with initial counter
         SpoonFile::setContent($filename, 'missing1');
         // return status
         $this->output(self::OK, array('status' => false), 'Temporary file was missing. We created one.');
     }
     // busy status
     if (strpos($status, 'busy') !== false) {
         // get counter
         $counter = (int) substr($status, 4) + 1;
         // file's been busy for more than hundred cycles - just stop here
         if ($counter > 100) {
             // remove file
             SpoonFile::delete($filename);
             // return status
             $this->output(self::ERROR, array('status' => 'timeout'), 'Error while retrieving data - the script took too long to retrieve data.');
         }
         // change file content to increase counter
         SpoonFile::setContent($filename, 'busy' . $counter);
         // return status
         $this->output(self::OK, array('status' => 'busy'), 'Data is being retrieved. (' . $counter . ')');
     }
     // unauthorized status
     if ($status == 'unauthorized') {
         // remove file
         SpoonFile::delete($filename);
         // remove all parameters from the module settings
         BackendModel::setModuleSetting($this->getModule(), 'session_token', null);
         BackendModel::setModuleSetting($this->getModule(), 'account_name', null);
         BackendModel::setModuleSetting($this->getModule(), 'table_id', null);
         BackendModel::setModuleSetting($this->getModule(), 'profile_title', null);
         // remove cache files
         BackendAnalyticsModel::removeCacheFiles();
         // clear tables
         BackendAnalyticsModel::clearTables();
         // return status
         $this->output(self::OK, array('status' => 'unauthorized'), 'No longer authorized.');
     }
     // done status
     if ($status == 'done') {
         // remove file
         SpoonFile::delete($filename);
         // return status
         $this->output(self::OK, array('status' => 'done'), 'Data retrieved.');
     }
     // missing status
     if (strpos($status, 'missing') !== false) {
         // get counter
         $counter = (int) substr($status, 7) + 1;
         // file's been missing for more than ten cycles - just stop here
         if ($counter > 10) {
             // remove file
             SpoonFile::delete($filename);
             // return status
             $this->output(self::ERROR, array('status' => 'missing'), 'Error while retrieving data - file was never created.');
         }
         // change file content to increase counter
         SpoonFile::setContent($filename, 'missing' . $counter);
         // return status
         $this->output(self::OK, array('status' => 'busy'), 'Temporary file was still in status missing. (' . $counter . ')');
     }
     /* FALLBACK - SOMETHING WENT WRONG */
     // remove file
     SpoonFile::delete($filename);
     // return status
     $this->output(self::ERROR, array('status' => 'error'), 'Error while retrieving data.');
 }