Exemple #1
0
 /**
  * Add Input
  *
  * @param	\IPS\Helpers\Form\Abstract	$input	Form element to add
  * @param	string|NULL					$after	The key of element to insert after
  * @param	string|NULL					$tab	The tab to insert onto
  * @return	void
  */
 public function add($input, $after = NULL, $tab = NULL)
 {
     if ($this->langPrefix && !$input->label) {
         $input->label = \IPS\Member::loggedIn()->language()->addToStack("{$this->langPrefix}_{$input->name}");
     }
     return call_user_func_array('parent::add', func_get_args());
 }
Exemple #2
0
 /**
  * Show edit form
  * 
  * @return void
  */
 protected function edit()
 {
     if (!$this->marker->canEdit() and !\IPS\Request::i()->form_submitted) {
         \IPS\Output::i()->error('edit_no_perm_err', '2MM1/2', 403, '');
     }
     $form = $this->marker->buildEditForm();
     if ($values = $form->values()) {
         if ($this->marker->canEdit()) {
             $this->marker->processForm($values);
             /* Old custom markers did not store the author ID, update them now to the current member */
             if ($this->marker->member_id == 0) {
                 $this->marker->member_id = \IPS\Member::loggedIn()->member_id;
             }
             $this->marker->updated = time();
             $this->marker->save();
             $this->marker->processAfterEdit($values);
             \IPS\Output::i()->redirect($this->marker->url());
         } else {
             $form->error = \IPS\Member::loggedIn()->language()->addToStack('edit_no_perm_err');
         }
     }
     /* Display */
     \IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('membermap_edit_a_marker');
     \IPS\Output::i()->sidebar['enabled'] = FALSE;
     \IPS\Output::i()->breadcrumb[] = array(NULL, \IPS\Member::loggedIn()->language()->addToStack('membermap_edit_a_marker'));
     \IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('submit')->submitPage($form->customTemplate(array(call_user_func_array(array(\IPS\Theme::i(), 'getTemplate'), array('submit', 'membermap')), 'submitForm')));
 }
Exemple #3
0
 /**
  * Generate a fake node
  *
  * @param   \IPS\Node\Model|null    $parent Parent node, or NULL to generate a root node
  * @param   array                   $values Generator form values
  * @return  \IPS\Node\Model
  */
 public function generateSingle($parent = NULL, array $values)
 {
     $nodeClass = static::$nodeClass;
     $node = new $nodeClass();
     /* Handle submissions */
     if (isset($node::$databaseColumnOrder)) {
         $orderColumn = $node::$databaseColumnOrder;
         $node->{$orderColumn} = \IPS\Db::i()->select('MAX(' . $node::$databasePrefix . $orderColumn . ')', $node::$databaseTable)->first() + 1;
     }
     $nodeValues = array('forum_name' => $this->generator->title(), 'forum_description' => $values['description'] ? $this->generator->description() : ' ', 'forum_type' => $values['forum_type'], 'forum_parent_id' => $parent, 'forum_password' => $values['password']);
     if ($parent) {
         $parentColumn = NULL;
         if (\IPS\Request::i()->subnode) {
             if (isset($nodeClass::$parentNodeColumnId)) {
                 $parentColumn = $nodeClass::$parentNodeColumnId;
             }
         } elseif (isset($nodeClass::$databaseColumnParent)) {
             $parentColumn = $nodeClass::$databaseColumnParent;
         }
         if ($parentColumn !== NULL) {
             $node->{$parentColumn} = $parent;
         }
     }
     $node->saveForm($node->formatFormValues($nodeValues));
     $this->map(static::$nodeClass, $node->_id);
     $this->setPermissions($node);
     return \IPS\Member::loggedIn()->language()->addToStack(static::$message, TRUE, array('sprintf' => array($parent ? $parent->_title : 'root')));
 }
Exemple #4
0
 /**
  * Generate a fake member account
  *
  * @param   array   $values Generator form values
  * @return  string  Progress message
  */
 public function generateSingle(array $values)
 {
     /* Create Member */
     $member = new \IPS\Member();
     $member->name = $values['__generator_message'] = $this->generator->userName();
     $password = isset($values['password']) ? $member->name : $this->generator->password();
     $member->email = $this->generator->email();
     $member->members_pass_salt = $member->generateSalt();
     $member->members_pass_hash = $member->encryptedPassword($password);
     $member->allow_admin_mails = 0;
     $member->member_group_id = $values['member_group'];
     $member->members_bitoptions['view_sigs'] = TRUE;
     if ($values['profile_photo']) {
         $photoUrl = new \IPS\Http\Url($this->generator->photoUrl());
         $response = $photoUrl->request()->get();
         $filename = preg_replace("/(.+?)(\\?|\$)/", "\$1", mb_substr((string) $photoUrl, mb_strrpos((string) $photoUrl, '/') + 1));
         $photoFile = \IPS\File::create('core_Profile', $filename, $response);
         $member->pp_photo_type = 'custom';
         $member->pp_main_photo = NULL;
         $member->pp_main_photo = (string) $photoFile;
         $thumbnail = $photoFile->thumbnail('core_Profile', \IPS\PHOTO_THUMBNAIL_SIZE, \IPS\PHOTO_THUMBNAIL_SIZE, TRUE);
         $member->pp_thumb_photo = (string) $thumbnail;
     }
     $member->save();
     $this->map(static::$activeRecordClass, $member->member_id);
     return \IPS\Member::loggedIn()->language()->addToStack(static::$message, true, array('sprintf' => array($member->name)));
 }
Exemple #5
0
 /**
  * Generate a fake topic post
  *
  * @param   \IPS\Content\Item   $topic  The topic
  * @param   array               $values Generator form values
  * @param   bool                $first  Indicates this is the first post in a topic
  * @return  string|\IPS\Content\Comment Progress message or comment object if first comment
  */
 public function generateSingle(\IPS\Content\Item $topic, array $values, $first = FALSE)
 {
     $commentClass = static::$commentClass;
     /* Generate the author */
     if ($first) {
         $member = $topic->author();
     } elseif ($values['author']) {
         $member = $values['author'];
     } elseif ($values['author_type'] == 'random_fake') {
         $member = $this->generator->fakeMember();
     } else {
         $member = $this->generator->guest();
     }
     /* Create and save the post */
     $obj = $commentClass::create($topic, $this->generator->comment(), $first, !$member->name ? NULL : $member->name, $topic->hidden() ? FALSE : NULL, $member);
     $obj->ip_address = $this->generator->ipAddress();
     $obj->save();
     if (!$first) {
         $this->map($commentClass, $obj->pid);
     }
     // Only map if this is NOT the first comment
     $itemClass = static::$itemClass;
     call_user_func_array(array('IPS\\File', 'claimAttachments'), array_merge(array('newContentItem-' . $topic::$application . '/' . $itemClass::$module . '-' . 0), $obj->attachmentIds()));
     return $first ? $obj : \IPS\Member::loggedIn()->language()->addToStack(static::$message, TRUE, array('sprintf' => array($topic->mapped('title'))));
 }
Exemple #6
0
 /**
  * Show marker group index
  * 
  * @return void
  */
 protected function _index()
 {
     /* Online User Location */
     \IPS\Session::i()->setLocation(\IPS\Http\Url::internal('app=membermap&module=markers&controller=groups', 'front', 'markers'), array(), 'loc_membermap_browsing_groups');
     \IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('membermap_marker_groups');
     \IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('markers')->index();
 }
Exemple #7
0
 /**
  * ...
  *
  * @return	void
  */
 protected function manage()
 {
     $defaultMaps = \IPS\membermap\Application::getEnabledMaps();
     \IPS\Output::i()->jsVars['membermap_defaultMaps'] = $defaultMaps;
     \IPS\Output::i()->sidebar['actions']['preview'] = array('icon' => 'eye', 'link' => \IPS\Http\Url::external('https://leaflet-extras.github.io/leaflet-providers/preview/index.html'), 'title' => 'membermap_mapmanager_preview', 'target' => '_blank');
     \IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('menu__membermap_membermap_mapmanager');
     \IPS\Output::i()->output .= \IPS\Theme::i()->getTemplate('mapmanager')->wrapper();
 }
Exemple #8
0
 /**
  * Process Form
  *
  * @param	\IPS\Helpers\Form		$form	The form
  * @param	\IPS\Member\Group		$group	Existing Group
  * @return	void
  */
 public function process(&$form, $group)
 {
     $bgColour = $group->g_membermap_markerColour ? $group->g_membermap_markerColour : 'darkblue';
     /* Selected a valid colour? */
     $bgColour = in_array($bgColour, $this->colours) ? $bgColour : 'darkblue';
     foreach ($this->colours as $c) {
         $radioOpt[$c] = \IPS\Theme::i()->resource("awesome-marker-icon-{$c}.png", "membermap", 'admin');
     }
     $form->add(new \IPS\Helpers\Form\Radio('g_membermap_markerColour', $bgColour, TRUE, array('options' => $radioOpt, 'parse' => 'image', 'descriptions' => array('white' => \IPS\Member::loggedIn()->language()->addToStack('group_pin_bg_colour_white')))));
 }
Exemple #9
0
 public function formatValue()
 {
     if (in_array($this->htmlId, array('marker_lat', 'marker_lon'))) {
         $value = $this->value;
         $value = floatval($value);
         $value = round($value, 6);
         /* Convert decimal point and thousand separators to a way PHP understand */
         $value = str_replace(trim(\IPS\Member::loggedIn()->language()->locale['thousands_sep']), '', $value);
         $value = str_replace(trim(\IPS\Member::loggedIn()->language()->locale['decimal_point']), '.', $value);
         /* If it's not numeric, throw an exception */
         if (!is_numeric($value) and $value !== '' and $this->required === FALSE or !is_numeric($value) and $this->required === TRUE) {
             throw new \InvalidArgumentException('form_number_bad');
         }
         return $value;
     } else {
         return parent::formatValue();
     }
 }
 /**
  * Payment Screen
  */
 public function paymentScreen(\IPS\Helpers\Form $form, $member, $donation)
 {
     /* Get any gateway settings */
     $settings = json_decode($this->settings, TRUE);
     /* We need this before continuing */
     if (!isset($settings['api_key']) or !isset($settings['api_secretkey']) or !isset($settings['widget_code'])) {
         return $form;
     }
     /* Init paymentwall */
     $this->initPaymentwall($settings['api_key'], $settings['api_secretkey']);
     /* Setup widget */
     $productNames[] = \IPS\Member::loggedIn()->language()->get('forum_donation');
     $product = new \Paymentwall_Product("D1", $donation['amount'], $donation['currency'], implode(',', $productNames));
     $widget = new \Paymentwall_Widget(\IPS\Member::loggedIn()->member_id, $settings['widget_code'], array($product), array('goal' => $donation['goal']));
     /* Add widget to form */
     $form->addHtml($widget->getHtmlCode());
     return $form;
 }
Exemple #11
0
 /**
  * Display the generator form
  *
  * @return  void
  */
 protected function manage()
 {
     list($ext, $extApp, $extension, $controller) = $this->extData();
     /* Build the generator form */
     $form = new \IPS\faker\Decorators\Form('form', 'faker_form_generate', \IPS\Http\Url::internal("app=faker&module=generator&controller={$controller}&extApp={$extApp}&extension={$extension}"));
     $form->langPrefix = "{$extApp}_faker_{$controller}";
     $ext->buildGenerateForm($form);
     /* Cycle field */
     $cycle = new \IPS\Helpers\Form\Number('per_go', $ext::$cycleDefault, TRUE, array('min' => 1));
     $cycle->label = \IPS\Member::loggedIn()->language()->addToStack('faker_perGo');
     $form->add($cycle);
     if ($values = $form->values()) {
         \IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('faker_generator_title', true, array('sprintf' => \IPS\Member::loggedIn()->language()->addToStack("menu__faker_{$extApp}_{$extension}")));
         \IPS\Output::i()->output = (string) $ext->generateBulk($values);
         return;
     }
     \IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack($ext::$title);
     \IPS\Output::i()->output = $form;
 }
Exemple #12
0
 /**
  * ...
  *
  * @return	void
  */
 protected function manage()
 {
     \IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('menu__membermap_membermap_settings');
     \IPS\Output::i()->jsFiles = array_merge(\IPS\Output::i()->jsFiles, \IPS\Output::i()->js('jquery/jquery-ui.js', 'membermap', 'interface'));
     \IPS\Output::i()->jsFiles = array_merge(\IPS\Output::i()->jsFiles, \IPS\Output::i()->js('admin_membermap.js', 'membermap', 'admin'));
     \IPS\Output::i()->cssFiles = array_merge(\IPS\Output::i()->cssFiles, \IPS\Theme::i()->css('jquery-ui.css', 'membermap', 'global'));
     \IPS\Output::i()->jsVars['membermap_mapquestAPI'] = \IPS\membermap\Application::getApiKeys('mapquest');
     $form = new \IPS\Helpers\Form();
     $form->addHeader('api_settings');
     $form->add(new \IPS\Helpers\Form\Text('membermap_mapQuestAPI', \IPS\Settings::i()->membermap_mapQuestAPI, TRUE, array(), NULL, NULL, NULL, 'membermap_mapQuestAPI'));
     if (!empty(\IPS\Settings::i()->membermap_mapQuestAPI)) {
         $form->attributes['data-controller'] = 'membermap.admin.membermap.settings';
         $form->attributes['id'] = 'membermap_form_settings';
         $form->addHeader('map_settings');
         $form->add(new \IPS\Helpers\Form\YesNo('membermap_groupByMemberGroup', \IPS\Settings::i()->membermap_groupByMemberGroup));
         $form->add(new \IPS\Helpers\Form\YesNo('membermap_enable_clustering', \IPS\Settings::i()->membermap_enable_clustering));
         $form->add(new \IPS\Helpers\Form\Text('membermap_bbox_location', \IPS\Settings::i()->membermap_bbox_location, FALSE, array(), NULL, NULL, NULL, 'membermap_bbox_location'));
         $form->add(new \IPS\Helpers\Form\Number('membermap_bbox_zoom', intval(\IPS\Settings::i()->membermap_bbox_zoom), FALSE, array('min' => 1, 'max' => 18)));
         $form->hiddenValues['membermap_bbox'] = \IPS\Settings::i()->membermap_bbox;
         $form->addHeader('membermap_autoUpdate');
         $profileFields = array('' => ' -- ' . \IPS\Member::loggedIn()->language()->addToStack('membermap_profileLocationField') . ' -- ');
         foreach (\IPS\core\ProfileFields\Field::fields(array(), \IPS\core\ProfileFields\Field::PROFILE) as $group => $fields) {
             foreach ($fields as $id => $field) {
                 $profileFields['core_pfieldgroups_' . $group][$id] = $field->name;
             }
         }
         $form->add(new \IPS\Helpers\Form\YesNo('membermap_monitorLocationField', \IPS\Settings::i()->membermap_monitorLocationField, FALSE, array('togglesOn' => array('membermap_profileLocationField', 'membermap_monitorLocationField_groupPerm', 'membermap_syncLocationField'))));
         $form->add(new \IPS\Helpers\Form\Select('membermap_profileLocationField', \IPS\Settings::i()->membermap_profileLocationField ? intval(\IPS\Settings::i()->membermap_profileLocationField) : NULL, FALSE, array('options' => $profileFields), NULL, NULL, NULL, 'membermap_profileLocationField'));
         $form->add(new \IPS\Helpers\Form\Select('membermap_monitorLocationField_groupPerm', \IPS\Settings::i()->membermap_monitorLocationField_groupPerm != '' ? \IPS\Settings::i()->membermap_monitorLocationField_groupPerm === '*' ? '*' : explode(",", \IPS\Settings::i()->membermap_monitorLocationField_groupPerm) : '*', FALSE, array('options' => \IPS\Member\Group::groups(), 'multiple' => TRUE, 'parse' => 'normal', 'unlimited' => '*', 'unlimitedLang' => 'all'), NULL, NULL, NULL, 'membermap_monitorLocationField_groupPerm'));
         $form->add(new \IPS\Helpers\Form\YesNo('membermap_syncLocationField', \IPS\Settings::i()->membermap_syncLocationField, FALSE, array(), NULL, NULL, NULL, 'membermap_syncLocationField'));
     }
     if ($values = $form->values(TRUE)) {
         $values['membermap_bbox'] = \IPS\Request::i()->membermap_bbox;
         if (empty($values['membermap_bbox_location'])) {
             $values['membermap_bbox'] = "";
         }
         \IPS\DB::i()->update('core_tasks', array('enabled' => isset($values['membermap_syncLocationField']) and $values['membermap_syncLocationField'] ? 1 : 0), array('`key`=?', 'locationSync'));
         $form->saveAsSettings($values);
         \IPS\Session::i()->log('acplogs__membermap_settings');
         \IPS\Output::i()->redirect(\IPS\Http\Url::internal("app=membermap&module=membermap&controller=settings"), 'saved');
     }
     \IPS\Output::i()->output = $form;
 }
Exemple #13
0
 /**
  * Submit Event
  *
  * @return	void
  */
 protected function manage()
 {
     $group = NULL;
     if (isset(\IPS\Request::i()->group)) {
         try {
             $group = \IPS\membermap\Markers\Groups::loadAndCheckPerms(\IPS\Request::i()->group);
             \IPS\Output::i()->breadcrumb[] = array(\IPS\Http\Url::internal('app=membermap&module=groups&controller=groups&id=' . $group->_id, 'front', 'markers_group', $group->name_seo), $group->_title);
         } catch (\OutOfRangeException $e) {
         }
     }
     $form = \IPS\membermap\Markers\Markers::create($group);
     if (\IPS\membermap\Markers\Markers::moderateNewItems(\IPS\Member::loggedIn())) {
         $form = \IPS\Theme::i()->getTemplate('forms', 'core')->modQueueMessage(\IPS\Member::loggedIn()->warnings(5, NULL, 'mq'), \IPS\Member::loggedIn()->mod_posts) . $form;
     }
     /* Display */
     \IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('membermap_submit_a_marker');
     \IPS\Output::i()->sidebar['enabled'] = FALSE;
     \IPS\Output::i()->breadcrumb[] = array(NULL, \IPS\Member::loggedIn()->language()->addToStack('membermap_submit_a_marker'));
     \IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('submit')->submitPage($form->customTemplate(array(call_user_func_array(array(\IPS\Theme::i(), 'getTemplate'), array('submit', 'membermap')), 'submitForm')));
 }
Exemple #14
0
 /**
  * Get API keys
  * Currently it only serves MapQuest, but others may be added in the future
  * 
  * @param  string 	$service 	Name of the service, will return all keys if param is empty
  * @return mixed 	Single API key, or all in an array
  */
 public static function getApiKeys($service)
 {
     if (!isset(static::$apiKeys['mapquest'])) {
         if (\IPS\Settings::i()->membermap_mapQuestAPI) {
             static::$apiKeys['mapquest'] = \IPS\Settings::i()->membermap_mapQuestAPI;
         }
     }
     if (\IPS\Dispatcher::i()->controllerLocation == 'front' and (!isset(static::$apiKeys['mapquest']) or empty(static::$apiKeys['mapquest']))) {
         if (\IPS\Member::loggedIn()->isAdmin()) {
             \IPS\Output::i()->error('membermap_noAPI_admin', '4MM5/1', 401);
         } else {
             \IPS\Output::i()->error('401_error_title', '4MM5/2', 401);
         }
     }
     try {
         if ($service) {
             return static::$apiKeys[$service];
         }
     } catch (\Exception $e) {
     }
     return static::$apiKeys;
 }
Exemple #15
0
 /**
  * Check permissions
  *
  * @param	mixed								$permission		A key which has a value in static::$permissionMap['view'] matching a column ID in core_permission_index
  * @param	\IPS\Member|\IPS\Member\Group|NULL	$member			The member or group to check (NULL for currently logged in member)
  * @return	bool
  * @throws	\OutOfBoundsException	If $permission does not exist in static::$permissionMap
  */
 public function can($permission, $member = NULL)
 {
     $parent = parent::can($permission, $member);
     if ($parent === TRUE) {
         $_member = $member ?: \IPS\Member::loggedIn();
         if ($this->type == 'member' and $permission == 'add') {
             $existing = \IPS\membermap\Map::i()->getMarkerByMember($_member->member_id, FALSE);
             return isset($existing) and $existing !== FALSE ? FALSE : TRUE;
         }
     }
     return $parent;
 }
 /**
  * Build a dynamic set of query schema elements for use in individual query types
  *
  * @param           $form
  * @param   string  $prefix
  * @param   array   $noAutoToggle
  * @param   array   $exclude
  * @param   array   $defaults
  */
 protected function _buildQueryBoxSchema(&$form, $prefix = 'database_', $noAutoToggle = array(), $exclude = array(), $defaults = array())
 {
     $toggles = array('TINYINT' => array("{$prefix}column_length", "{$prefix}column_unsigned", "{$prefix}column_zerofill", "{$prefix}column_auto_increment", "{$prefix}column_default"), 'SMALLINT' => array("{$prefix}column_length", "{$prefix}column_unsigned", "{$prefix}column_zerofill", "{$prefix}column_auto_increment", "{$prefix}column_default"), 'MEDIUMINT' => array("{$prefix}column_length", "{$prefix}column_unsigned", "{$prefix}column_zerofill", "{$prefix}column_auto_increment", "{$prefix}column_default"), 'INT' => array("{$prefix}column_length", "{$prefix}column_unsigned", "{$prefix}column_zerofill", "{$prefix}column_auto_increment", "{$prefix}column_default"), 'BIGINT' => array("{$prefix}column_length", "{$prefix}column_unsigned", "{$prefix}column_zerofill", "{$prefix}column_auto_increment", "{$prefix}column_default"), 'DECIMAL' => array("{$prefix}column_length", "{$prefix}column_unsigned", "{$prefix}column_zerofill", "{$prefix}column_decimals", "{$prefix}column_default"), 'FLOAT' => array("{$prefix}column_length", "{$prefix}column_unsigned", "{$prefix}column_zerofill", "{$prefix}column_decimals", "{$prefix}column_default"), 'BIT' => array("{$prefix}column_length", "{$prefix}column_default"), 'DATE' => array("{$prefix}column_default"), 'DATETIME' => array("{$prefix}column_default"), 'TIMESTAMP' => array("{$prefix}column_default"), 'TIME' => array("{$prefix}column_default"), 'YEAR' => array("{$prefix}column_default"), 'CHAR' => array("{$prefix}column_length", "{$prefix}column_binary", "{$prefix}column_default"), 'VARCHAR' => array("{$prefix}column_length", "{$prefix}column_binary", "{$prefix}column_default"), 'TINYTEXT' => array("{$prefix}column_binary"), 'TEXT' => array("{$prefix}column_binary"), 'MEDIUMTEXT' => array("{$prefix}column_binary"), 'LONGTEXT' => array("{$prefix}column_binary"), 'BINARY' => array("{$prefix}column_length", "{$prefix}column_default"), 'VARBINARY' => array("{$prefix}column_length", "{$prefix}column_default"), 'TINYBLOB' => array(), 'BLOB' => array(), 'MEDIUMBLOB' => array(), 'BIGBLOB' => array(), 'ENUM' => array("{$prefix}column_values", "{$prefix}column_default"), 'SET' => array("{$prefix}column_values", "{$prefix}column_default"));
     if ($noAutoToggle) {
         foreach ($toggles as &$toggle) {
             foreach ($noAutoToggle as $toBeRemoved) {
                 if (($key = array_search($prefix . $toBeRemoved, $toggle)) !== false) {
                     unset($toggle[$key]);
                 }
             }
         }
     }
     $elements = array();
     $elements[] = new \IPS\Helpers\Form\Select("{$prefix}column_type", 'VARCHAR', TRUE, array('options' => \IPS\Db::$dataTypes, 'toggles' => $toggles));
     $elements[] = new \IPS\Helpers\Form\Number("{$prefix}column_length", -1, FALSE, array('unlimited' => -1, 'unlimitedLang' => 'no_value'), NULL, NULL, NULL, "{$prefix}column_length");
     $elements[] = new \IPS\Helpers\Form\Number("{$prefix}column_decimals", -1, FALSE, array('unlimited' => -1, 'unlimitedLang' => 'no_value'), NULL, NULL, NULL, "{$prefix}column_decimals");
     $elements[] = new \IPS\Helpers\Form\Stack("{$prefix}column_values", NULL, FALSE, array(), NULL, NULL, NULL, "{$prefix}column_values");
     $elements[] = new \IPS\Helpers\Form\YesNo("{$prefix}column_allow_null", FALSE, TRUE);
     $elements[] = new \IPS\Helpers\Form\TextArea("{$prefix}column_default", NULL, FALSE, array('nullLang' => 'NULL'), NULL, NULL, NULL, "{$prefix}column_default");
     $elements[] = new \IPS\Helpers\Form\TextArea("{$prefix}column_comment", NULL, FALSE);
     $elements[] = new \IPS\Helpers\Form\YesNo("{$prefix}column_unsigned", TRUE, FALSE, array(), NULL, NULL, NULL, "{$prefix}column_unsigned");
     $elements[] = new \IPS\Helpers\Form\YesNo("{$prefix}column_zerofill", FALSE, FALSE, array(), NULL, NULL, NULL, "{$prefix}column_zerofill");
     $elements[] = new \IPS\Helpers\Form\YesNo("{$prefix}column_auto_increment", FALSE, FALSE, array(), NULL, NULL, NULL, "{$prefix}column_auto_increment");
     $elements[] = new \IPS\Helpers\Form\YesNo("{$prefix}column_binary", FALSE, FALSE, array(), NULL, NULL, NULL, "{$prefix}column_binary");
     $lang = \IPS\Member::loggedIn()->language();
     foreach ($elements as $element) {
         // Trim the prefix so we can replace the label with the standard database_ language string
         $label = mb_substr($element->name, mb_strlen($prefix));
         $element->label = $lang->addToStack("database_{$label}");
         // Is this element being excluded?
         if (in_array($label, $exclude)) {
             continue;
         }
         // Do we have a custom default value for this element?
         if (isset($defaults[$label])) {
             $element->defaultValue = $defaults[$label];
             $element->setValue(TRUE);
         }
         $form->add($element);
     }
 }
Exemple #17
0
 /**
  * Can edit?
  * Authors can always edit their own markers
  *
  * @param	\IPS\Member|NULL	$member	The member to check for (NULL for currently logged in member)
  * @return	bool
  */
 public function canEdit($member = NULL)
 {
     $member = $member ?: \IPS\Member::loggedIn();
     return $member->member_id == $this->author()->member_id or parent::canEdit($member);
 }
Exemple #18
0
 /**
  * Delete a marker
  *
  * @return	void
  */
 protected function delete()
 {
     \IPS\Session::i()->csrfCheck();
     if (!\IPS\Member::loggedIn()->member_id or !intval(\IPS\Request::i()->member_id)) {
         \IPS\Output::i()->error('no_permission', '2MM3/4', 403, '');
     }
     /* Get the marker */
     $existing = \IPS\membermap\Map::i()->getMarkerByMember(intval(\IPS\Request::i()->member_id), FALSE);
     if (isset($existing)) {
         $is_supmod = \IPS\Member::loggedIn()->modPermission() ?: 0;
         if ($is_supmod or $existing->mapped('author') == \IPS\Member::loggedIn()->member_id and $existing->canDelete()) {
             $existing->delete();
             \IPS\Output::i()->json('OK');
         }
     }
     /* Fall back to a generic error */
     \IPS\Output::i()->error('no_permission', '2MM3/5', 403, '');
 }
Exemple #19
0
 /**
  * Get Title
  *
  * @return	string
  */
 public function title()
 {
     return \IPS\Member::loggedIn()->language()->addToStack('frontnavigation_membermap');
 }
Exemple #20
0
 public static function create($item, $comment, $first = FALSE, $guestName = NULL, $incrementPostCount = NULL, $member = NULL, \IPS\DateTime $time = NULL)
 {
     $topic = $item;
     if ($member === NULL) {
         $member = \IPS\Member::loggedIn();
     }
     if (isset($_POST['topic_title'])) {
         $comment = $_POST['topic_title'] . "\n" . $comment;
     }
     $access_key = \IPS\Settings::i()->access_key;
     if (isset($member) && !$member->isAdmin() && $member->member_posts <= 10 && \IPS\Settings::i()->moderate_new == 1) {
         require_once dirname($_SERVER['SCRIPT_FILENAME']) . "/uploads/cleantalk.class.php";
         require_once dirname($_SERVER['SCRIPT_FILENAME']) . "/uploads/JSON.php";
         session_name('cleantalksession');
         if (!isset($_SESSION)) {
             session_start();
         }
         if (array_key_exists('formtime', $_SESSION)) {
             $submit_time = time() - (int) $_SESSION['formtime'];
         } else {
             $submit_time = NULL;
         }
         $_SESSION['formtime'] = time();
         $post_info = '';
         $lang = \IPS\Lang::getEnabledLanguages();
         $locale = $lang[\IPS\Lang::defaultLanguage()]->short;
         if (function_exists('json_encode')) {
             $arr = array('cms_lang' => $locale, 'REFFERRER' => $_SERVER['HTTP_REFERER'], 'USER_AGENT' => $_SERVER['HTTP_USER_AGENT']);
             $post_info = json_encode($arr);
         }
         if ($post_info === FALSE) {
             $post_info = '';
         }
         $ct_url = 'http://moderate.cleantalk.ru';
         $config_work_url = $ct_url;
         $config_ttl = 43200;
         $config_changed = 1349162987;
         $config_key = $access_key;
         $ct = new \Cleantalk();
         $ct->work_url = $config_work_url;
         $ct->server_url = $ct_url;
         $ct->server_ttl = $config_ttl;
         $ct->server_changed = $config_changed;
         $sender_email = filter_var($member->email, FILTER_SANITIZE_EMAIL);
         $sender_ip = $ct->ct_session_ip($_SERVER['REMOTE_ADDR']);
         $ct_request = new \CleantalkRequest();
         $ct_request->auth_key = $config_key;
         if (isset($_POST['guest_name'])) {
             $ct_request->sender_nickname = $_POST['guest_name'];
         } else {
             $ct_request->sender_nickname = $member->name;
         }
         $ct_request->sender_ip = $sender_ip;
         $ct_request->sender_email = $sender_email;
         $ct_request->sender_info = $post_info;
         $ct_request->agent = 'ipboard4-18';
         $js_keys = array();
         for ($i = -5; $i <= 1; $i++) {
             $js_keys[] = md5(\IPS\Settings::i()->access_key . '+' . \IPS\Settings::i()->email_in . date("Ymd", time() + 86400 * $i));
         }
         $ct_request->js_on = in_array($_COOKIE['ct_checkjs'], $js_keys) ? 1 : 0;
         $ct_request->submit_time = $submit_time;
         $ct_request->message = $comment;
         $ct_result = $ct->isAllowMessage($ct_request);
         if (isset($ct_result->errno) && $ct_result->errno > 0) {
             //sendErrorMessage("CleanTalk has some problems, errno is ".$ct_result->errno.", errstr is '".$ct_result->errstr."'")
         }
         if ($ct_result->allow == 1) {
             // Not spammer.
             //call_user_func_array( 'parent::save', func_get_args() );
             return call_user_func_array('parent::create', func_get_args());
         } else {
             if (isset($_POST['topic_title'])) {
                 $topic->delete();
             }
             if (\IPS\Request::i()->isAjax()) {
                 $result = array("type" => "error", "message" => $ct_result->comment);
                 $result = json_encode($result);
                 \IPS\Output::i()->sendOutput($result, 200, "application/json");
             } else {
                 \IPS\Output::i()->sidebar['enabled'] = FALSE;
                 \IPS\Output::i()->sendOutput(\IPS\Theme::i()->getTemplate('global', 'core')->globalTemplate("Forbidden", \IPS\Theme::i()->getTemplate('global', 'core')->error("Forbidden", $ct_result->comment, 1, ""), array('app' => \IPS\Dispatcher::i()->application ? \IPS\Dispatcher::i()->application->directory : NULL, 'module' => \IPS\Dispatcher::i()->module ? \IPS\Dispatcher::i()->module->key : NULL, 'controller' => \IPS\Dispatcher::i()->controller)), 200, 'text/html', array(), FALSE, FALSE);
             }
             die;
             return call_user_func_array('parent::create', func_get_args());
         }
     }
     return call_user_func_array('parent::create', func_get_args());
 }
Exemple #21
0
 public function import()
 {
     $id = isset(\IPS\Request::i()->id) ? intval(\IPS\Request::i()->id) : 0;
     /* Build form */
     $form = new \IPS\Helpers\Form(NULL, 'import');
     if (isset(\IPS\Request::i()->id)) {
         $group = \IPS\membermap\Markers\Groups::load(intval(\IPS\Request::i()->id));
         if ($group->type == 'member') {
             \IPS\Output::i()->error('generic_error', '1MM4/1', 403, '');
         }
     }
     $form->add(new \IPS\Helpers\Form\Upload('import_upload', NULL, TRUE, array('allowedFileTypes' => array('kml'), 'temporary' => TRUE)));
     $form->add(new \IPS\Helpers\Form\YesNo('import_creategroups', FALSE, FALSE, array('togglesOff' => array('import_group'))));
     $form->add(new \IPS\Helpers\Form\Node('import_group', $id ?: 0, FALSE, array('class' => '\\IPS\\membermap\\Markers\\Groups', 'permissionCheck' => 'add', 'subnodes' => false, 'where' => array('group_type != ?', 'member')), NULL, NULL, NULL, 'import_group'));
     if ($values = $form->values()) {
         try {
             $xml = \IPS\Xml\SimpleXML::loadFile($values['import_upload']);
         } catch (\InvalidArgumentException $e) {
             $form->error = \IPS\Member::loggedIn()->language()->addToStack('xml_upload_invalid');
             \IPS\Output::i()->output = $form;
             return;
         }
         /* No group selected, and don't create groups?! */
         if ($values['import_creategroups'] == FALSE and !$values['import_group']) {
             $form->error = \IPS\Member::loggedIn()->language()->addToStack('membermap_error_no_id_no_create');
             \IPS\Output::i()->output = $form;
             return;
         }
         $markers = array();
         $groupOrder = NULL;
         $imported = 0;
         foreach ($xml->Document->Folder as $folder) {
             if (!isset($folder->Placemark)) {
                 continue;
             }
             $folderName = (string) $folder->name;
             foreach ($folder->Placemark as $placemark) {
                 if (!isset($placemark->Point->coordinates)) {
                     continue;
                 }
                 list($lon, $lat, $elev) = explode(',', $placemark->Point->coordinates);
                 $markers[] = array('marker_name' => (string) $placemark->name, 'marker_name_seo' => \IPS\Http\Url::seoTitle((string) $placemark->name), 'marker_description' => (string) $placemark->description, 'marker_lat' => $lat, 'marker_lon' => $lon, 'marker_member_id' => \IPS\Member::loggedIn()->member_id, 'marker_added' => time(), 'marker_open' => 1, 'marker_parent_id' => isset($values['import_group']) ? $values['import_group']->id : NULL);
             }
             /* Create a new group per "folder" */
             if ($values['import_creategroups'] == TRUE and count($markers) > 0) {
                 if ($groupOrder === NULL) {
                     $groupOrder = \IPS\Db::i()->select(array("MAX( `group_position` ) as position"), 'membermap_markers_groups')->first();
                 }
                 $groupOrder = $groupOrder + 1;
                 $group = new \IPS\membermap\Markers\Groups();
                 $group->name = $folderName;
                 $group->name_seo = \IPS\Http\Url::seoTitle($folderName);
                 $group->type = 'custom';
                 $group->pin_colour = '#FFFFFF';
                 $group->pin_bg_colour = 'red';
                 $group->pin_icon = 'fa-globe';
                 $group->position = $groupOrder;
                 $group->save();
                 \IPS\Lang::saveCustom('membermap', "membermap_marker_group_{$group->id}", trim($folderName));
                 \IPS\Lang::saveCustom('membermap', "membermap_marker_group_{$group->id}_JS", trim($folderName), 1);
                 // Add group id to all elements of the array
                 array_walk($markers, function (&$v, $k) use($group) {
                     $v['marker_parent_id'] = $group->id;
                 });
                 // Insert
                 \IPS\Db::i()->insert('membermap_markers', $markers);
                 $group->setLastComment();
                 $group->save();
                 // Set default permissions
                 $perms = $group->permissions();
                 \IPS\Db::i()->update('core_permission_index', array('perm_view' => '*', 'perm_2' => '*', 'perm_3' => \IPS\Settings::i()->admin_group, 'perm_4' => \IPS\Settings::i()->admin_group), array('perm_id=?', $perms['perm_id']));
                 // Reset
                 $imported += count($markers);
                 $markers = array();
             }
         }
         /* If we still got markers here, it's all pushed to one group, probably */
         if (is_array($markers) and count($markers) > 0) {
             \IPS\Db::i()->insert('membermap_markers', $markers);
             $group = $values['import_group'];
             $group->setLastComment();
             $group->save();
             $imported += count($markers);
         }
         \IPS\membermap\Map::i()->invalidateJsonCache();
         $message = \IPS\Member::loggedIn()->language()->addToStack('membermap_import_thumbup', FALSE, array('sprintf' => array($imported)));
         \IPS\Output::i()->redirect(\IPS\Http\Url::internal("app=membermap&module=membermap&controller=markers"), $message);
     }
     /* Display */
     \IPS\Output::i()->output = $form;
 }
Exemple #22
0
 /**
  * Get Progress
  *
  * @param	mixed					$data	Data as it was passed to \IPS\Task::queue()
  * @param	int						$offset	Offset
  * @return	array( 'text' => 'Doing something...', 'complete' => 50 )	Text explaining task and percentage complete
  * @throws	\OutOfRangeException	Indicates offset doesn't exist and thus task is complete
  */
 public function getProgress($data, $offset)
 {
     return array('text' => \IPS\Member::loggedIn()->language()->addToStack('membermap_rebuilding_cache'), 'complete' => round(100 / $data['count'] * $offset, 2));
 }
Exemple #23
0
 /**
  * Create a map to a fake content item
  *
  * @param   string              $class      Content class
  * @param   int                 $contentId  Content ID
  * @param   \IPS\Member|null    $author     Member that generated the item, or NULL for the logged in member
  * @return  int Insert ID
  */
 public static function createMap($class, $contentId, $author = NULL)
 {
     $author = $author ?: \IPS\Member::loggedIn();
     return \IPS\Db::i()->insert(static::$databaseTable, array('class' => trim($class, '\\'), 'content_id' => $contentId, 'author' => $author->member_id, 'created_at' => time()));
 }
Exemple #24
0
 /**
  * Generate a fake forum topic
  *
  * @param	\IPS\Node\Model	$forum	The forum container
  * @param   array           $values Generator form values
  * @return  string  Progress message
  */
 public function generateSingle(\IPS\Node\Model $forum = null, array $values)
 {
     $itemClass = static::$itemClass;
     $tagsContainer = $values['add_tags'] ? $this->generator->tags() : array('tags' => null, 'prefix' => null);
     /* Generate the author */
     if ($values['author']) {
         $member = $values['author'];
     } elseif ($values['author_type'] == 'random_fake') {
         $member = $this->generator->fakeMember();
     } else {
         $member = $this->generator->guest();
     }
     /* Assign topic values */
     $topicValues = array('topic_title' => $this->generator->title(), 'topic_content' => $this->generator->comment(), 'topic_tags' => $tagsContainer['tags'], 'topic_tags_prefix' => $tagsContainer['prefix'], 'topic_create_state' => $values['after_posting']);
     /* Create and save the topic */
     $itemClass = static::$itemClass;
     $obj = $itemClass::createItem($member, $ipAddress = $this->generator->ipAddress(), new \IPS\DateTime(), $forum);
     $obj->processForm($topicValues);
     $obj->save();
     $this->map(static::$itemClass, $obj->tid);
     /* Create and save the first post in the topic */
     $comment = $this->commentExt()->generateSingle($obj, $values, TRUE);
     /* Create any additional posts if necessary */
     if ($values['add_comments']) {
         $postCount = mt_rand($values['comment_range']['start'], $values['comment_range']['end']);
         for ($pc = 0; $pc < $postCount; $pc++) {
             $this->commentExt()->generateSingle($obj, $values);
         }
     }
     /* Claim attachments and map the first comment ID */
     $commentClass = $itemClass::$commentClass;
     $commentIdColumn = $commentClass::$databaseColumnId;
     call_user_func_array(array('IPS\\File', 'claimAttachments'), array_merge(array('newContentItem-' . \IPS\forums\Topic::$application . '/' . \IPS\forums\Topic::$module . '-' . ($forum ? $forum->_id : 0)), $comment->attachmentIds()));
     if (isset(\IPS\forums\Topic::$databaseColumnMap['first_comment_id'])) {
         $firstCommentIdColumn = \IPS\forums\Topic::$databaseColumnMap['first_comment_id'];
         $obj->{$firstCommentIdColumn} = $comment->{$commentIdColumn};
         $obj->save();
     }
     return \IPS\Member::loggedIn()->language()->addToStack(static::$message, TRUE, array('sprintf' => array($forum->_title)));
 }
Exemple #25
0
<?php

/**
 * @author 		Sijad aka Mr.Wosi
 * @link		<a href='http://skinod.com'>Skinod.com</a>
 * @copyright	2015 <a href='http://skinod.com'>Skinod.com</a>
 */
/**
 * Path to your IP.Board directory with a trailing /
 */
$_SERVER['SCRIPT_FILENAME'] = __FILE__;
$path = '';
require_once $path . 'init.php';
\IPS\Session\Front::i();
if (\IPS\Member::loggedIn()->member_id) {
    \IPS\Member::loggedIn()->skin = (int) \IPS\Request::i()->id;
    \IPS\Member::loggedIn()->save();
} else {
    \IPS\Request::i()->setCookie('theme', (int) \IPS\Request::i()->id);
}
/* Make sure VSE cookie is killed */
if (isset(\IPS\Request::i()->cookie['vseThemeId'])) {
    \IPS\Request::i()->setCookie('vseThemeId', 0);
}
\IPS\Output::i()->redirect(\IPS\Http\Url::internal(''));
 /**
  * Test Settings
  *
  * @return    bool
  * @throws    \IPS\Http\Request\Exception
  * @throws    \UnexpectedValueException    If response code is not 200
  */
 public function testSettings()
 {
     if ($this->settings['api_key']) {
         try {
             $response = \IPS\Http\Url::external("http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key={$this->settings['api_key']}&steamids=")->request()->get();
             if ($response->httpResponseCode != 200) {
                 throw new \InvalidArgumentException(\IPS\Member::loggedIn()->language()->addToStack('login_3p_bad', false, array('sprintf' => array(\IPS\Member::loggedIn()->language()->addToStack('login_handler_steam')))));
             }
         } catch (\IPS\Http\Request\Exception $e) {
             throw new \InvalidArgumentException(\IPS\Member::loggedIn()->language()->addToStack('login_3p_bad', false, array('sprintf' => array(\IPS\Member::loggedIn()->language()->addToStack('login_handler_steam')))));
         }
     }
     return true;
 }
Exemple #27
0
 /**
  * Member account has been updated
  *
  * @param	$member		\IPS\Member	Member updating profile
  * @param	$changes	array		The changes
  * @return	void
  */
 public function onProfileUpdate($member, $changes)
 {
     /* An endless loop is formed when \Item::createItem() is saving \Member, which then fire this membersync, which then calls \Item::createItem, and so on, and so on */
     static $wereDoneHere = false;
     if ($wereDoneHere) {
         return;
     }
     $wereDoneHere = true;
     if (isset($changes['name'])) {
         $existingMarker = \IPS\membermap\Map::i()->getMarkerByMember($member->member_id, FALSE, FALSE);
         if ($existingMarker instanceof \IPS\membermap\Markers\Markers) {
             $existingMarker->name = $member->name;
             $existingMarker->updated = time();
             $existingMarker->save();
         }
     }
     if (count($changes) and \IPS\Settings::i()->membermap_monitorLocationField and !$member->members_bitoptions['bw_is_spammer']) {
         if (\IPS\Settings::i()->membermap_monitorLocationField_groupPerm === '*' or \IPS\Member::loggedIn()->inGroup(explode(',', \IPS\Settings::i()->membermap_monitorLocationField_groupPerm))) {
             if (isset($changes['field_' . \IPS\Settings::i()->membermap_profileLocationField]) and !empty($changes['field_' . \IPS\Settings::i()->membermap_profileLocationField])) {
                 try {
                     $lat = $lng = $location = NULL;
                     $fieldValue = $changes['field_' . \IPS\Settings::i()->membermap_profileLocationField];
                     /* If it's an array, it might be from an address field, which already have the lat/lng data */
                     if (is_array(json_decode($fieldValue, TRUE))) {
                         $addressData = json_decode($fieldValue, TRUE);
                         if (is_float($addressData['lat']) and is_float($addressData['long'])) {
                             $lat = floatval($addressData['lat']);
                             $lng = floatval($addressData['long']);
                         }
                         $addressData['addressLines'][] = $addressData['city'];
                         if (count($addressData['addressLines'])) {
                             $location = implode(', ', $addressData['addressLines']);
                         }
                     } else {
                         /* Remove HTML, newlines, tab, etc, etc */
                         $fieldValue = preg_replace("/[\\x00-\\x20]|\\xc2|\\xa0+/", ' ', strip_tags($fieldValue));
                         $fieldValue = trim(preg_replace("/\\s\\s+/", ' ', $fieldValue));
                         /* To my understanding we're not allowed to use \IPS\Geolocation, as that uses Google API, and we're not showing the info on a Google Map. */
                         $nominatim = \IPS\membermap\Map::i()->getLatLng($fieldValue);
                         if (is_array($nominatim) and count($nominatim)) {
                             $lat = $nominatim['lat'];
                             $lng = $nominatim['lng'];
                             $location = $nominatim['location'];
                         }
                     }
                     if ($lat and $lng) {
                         $existingMarker = \IPS\membermap\Map::i()->getMarkerByMember($member->member_id, FALSE);
                         if ($existingMarker instanceof \IPS\membermap\Markers\Markers) {
                             $marker = $existingMarker;
                             $marker->updated = time();
                         } else {
                             $groupId = \IPS\membermap\Map::i()->getMemberGroupId();
                             $marker = \IPS\membermap\Markers\Markers::createItem($member, \IPS\Request::i()->ipAddress(), new \IPS\DateTime(), \IPS\membermap\Markers\Groups::load($groupId));
                         }
                         $marker->name = $member->name;
                         $marker->lat = $lat;
                         $marker->lon = $lng;
                         $marker->location = $location ?: $fieldValue;
                         /* Save and add to search index */
                         $marker->save();
                         \IPS\Content\Search\Index::i()->index($marker);
                     }
                 } catch (\Exception $e) {
                     /* Something went wrong. Such as the input field being an editor */
                     \IPS\Log::log($e, 'membermap');
                     return false;
                 }
             }
         }
     }
 }
Exemple #28
0
 /**
  * Execute
  *
  * @return	void
  */
 public function execute()
 {
     \IPS\Dispatcher::i()->checkAcpPermission('faker_tools_purge');
     \IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('faker_title_purge');
     parent::execute();
 }