Jump to content

newbie LAC

+Security Consultant
  • Posts

    5,244
  • Joined

  • Days Won

    40

Community Answers

  1. newbie LAC's post in How to check what a Storage Setting Configuration is set to? was marked as the answer   
    if (get_class(\IPS\File::getClass('core_Emoticons')) == 'IPS\File\Amazon') { } if (get_class(\IPS\File::getClass('core_Theme')) == 'IPS\File\FileSystem') { }  
  2. newbie LAC's post in Error 2S100/6: requested_route_404 was marked as the answer   
    Hello,
    Debug next code (system\Dispatcher\Standard.php)
    try { $this->module = \IPS\Application\Module::get( $this->application->directory, \IPS\Request::i()->module, static::i()->controllerLocation ); } catch ( \OutOfRangeException $e ) { \IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'app.js' ) ); throw new \DomainException( 'requested_route_404', 6 ); }  
  3. newbie LAC's post in Double htmlPurifying in system/Text/Parser.php, why? was marked as the answer   
  4. newbie LAC's post in Select Bug When using $form->error? was marked as the answer   
    You can't use integers values as keys options
    Try on front side
    On admin side works because uses the template applications\core\dev\html\admin\forms\select.phtml
    On front side uses \applications\core\dev\html\front\forms\select.phtml
    admin
    {{if ( ( $value === 0 and $k === 0 ) or ( $value !== 0 and $value === $k ) or ( $value !== 0 and \is_numeric( $value ) and \is_numeric( $k ) and $value == $k ) ) or ( \is_array( $value ) and \in_array( $k, $value ) ) or ( !empty( $userSuppliedInput ) and !\in_array( $value, array_keys( $options ) ) and $k == $userSuppliedInput )}}selected{{endif}} vs
    front
    {{if ( ( $value === 0 and $k === 0 ) or ( $value !== 0 and $value === $k ) ) or ( \is_array( $value ) and \in_array( $k, $value ) )}}selected{{endif}}  
  5. newbie LAC's post in Queue on installOther() was marked as the answer   
    The reason is that during installation the application is disabled and enabled on the finished step

    But the queue runs for enabled apps

    So your queue is stopped
    Enable your application before run queue
    To IPS developers:
    - Any reason why you use 
    $application->enabled = 1; $application->save(); instead of 
    $application->_enabled = 1; $application->save();
    - The installHooks method calls twice
    1 call
    /* Rebuild data */ \IPS\Application::load( $data['key'] )->installJsonData(); /** * Rebuild common data during an install or upgrade. This is a shortcut method which * * Installs module data from JSON file * * Installs task data from JSON file * * Installs setting data from JSON file * * Installs ACP live search keywords from JSON file * * Installs hooks from JSON file * * Updates latest version in the database * * @param bool $skipMember Skip clearing member cache clearing * @return void */ public function installJsonData( $skipMember=FALSE ) { ................ /* Rebuild hooks */ $this->installHooks(); 2 call
    /* Install hooks - do this after enabling the application */ $application->installHooks();  
  6. newbie LAC's post in Bug permissions with custom block & block manager ? was marked as the answer   
    Fixed in the 4.4.5 (Released 08/06/2019)
  7. newbie LAC's post in Let us manipulate translate table before it's sent to output was marked as the answer   
    Hello,
    Check this
  8. newbie LAC's post in Custom login handler was marked as the answer   
    Read 
     
    - Create MyCustomLoginHandler.php
    /applications/testapp/sources/MyCustomLoginHandler/MyCustomLoginHandler.php
    <?php namespace IPS\testapp; /* To prevent PHP errors (extending class does not exist) revealing path */ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) ) { header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' ); exit; } class _MyCustomLoginHandler extends \IPS\Login\Handler { // .... } - 
    $return[] = 'IPS\mycustomloginhandler\MyLoginHandler'; change to 
    $return[] = 'IPS\testapp\MyCustomLoginHandler';  
  9. newbie LAC's post in Adding payment gateway was marked as the answer   
    You can also download some free files
    https://invisioncommunity.com/search/?q=gateway&type=downloads_file
  10. newbie LAC's post in Template, Inlcude external php was marked as the answer   
  11. newbie LAC's post in Exclude groups - php error was marked as the answer   
    Hello,
    if (\in_array($sid, explode(',', \IPS\Settings::i()->ips1s2kSGIExclude))) { unset($allGroups[$sid]); }  
  12. newbie LAC's post in Sorting groups was marked as the answer   
    Hello,
    Hook in \IPS\Member
    public function sortedGroups() { $allGroups = \IPS\Member\Group::groups(); $ips1s2ktest = explode(',', \IPS\Settings::i()->ips1s2kSGI); $otherGroups = array_flip(explode(',', $this->mgroup_others)); $sortedGroups = array(); $notSortedGroups = array(); foreach ($ips1s2ktest as $id) { if (isset($allGroups[$id]) and isset($otherGroups[$id])) { $sortedGroups[$id] = $allGroups[$id]; unset($otherGroups[$id]); } } foreach ($otherGroups as $sid => $i) { if (isset($allGroups[$sid])) { $notSortedGroups[$sid] = $allGroups[$sid]; } } return ($sortedGroups + $notSortedGroups); } Then use
    In the profile
    {{if $member->sortedGroups()}} {{foreach $member->sortedGroups() as $group}} {$group->formattedName|raw} {{endforeach}} {{endif}} In the post
    {{if $comment->author()->sortedGroups()}} {{foreach $comment->author()->sortedGroups() as $group}} {$group->formattedName|raw} {{endforeach}} {{endif}}  
  13. newbie LAC's post in Comparing member's password hash to a string was marked as the answer   
    Hello,
    See
    \system\Member\Member.php
    /** * Set local password * * BE CAREFUL: The standard login handler may be disabled, only call this method * if you have alreadu checked it is enabled. In most cases, it is better to let * the available login handlers handle password management * * @param object $password Password to encrypt, wrapped in an object that can be cast to a string so it doesn't show in any logs * @return void */ public function setLocalPassword( $password ) { $this->members_pass_hash = password_hash( $password, PASSWORD_DEFAULT ); $this->members_pass_salt = NULL; } \system\Login\Handler\Standard\Standard.php
    /** * Authenticate * * @param \IPS\Member $member The member * @param object $password The plaintext password provided by the user, wrapped in an object that can be cast to a string so it doesn't show in any logs * @return bool */ public function authenticatePasswordForMember( \IPS\Member $member, $password ) { if ( password_verify( $password, $member->members_pass_hash ) === TRUE ) { return TRUE; } elseif ( $member->members_pass_salt and mb_strlen( $member->members_pass_hash ) === 32 ) { return $member->verifyLegacyPassword( $password ); } return FALSE; }  
  14. newbie LAC's post in Custom login handler was marked as the answer   
    Hello,
    The load method doesn't throw exception
    For non existing members will be return Guest
    Correct
    $member = \IPS\Member::load($id); if ($member->member_id) { // User } else { // Guest }
    \IPS\Member::load($forumId); Load by $forumId. Is this correct?

    $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); you can use built-in methods
    try { $response = \IPS\Http\Url::external($this->rebornEndPoint . '/api/forum/account/auth')->request()->post(array('api_key' => $this->rebornApiKey, 'accountId' => $accountId, 'forumId' => $forumId))->decodeJson(false); } catch (\Exception $e) { }
    Also look at
    $return[] = 'IPS\mycustomloginhandler\MyLoginHandler'; and
    class _MyCustomLoginHandler extends \IPS\Login\Handler MyLoginHandler vs. MyCustomLoginHandler
  15. newbie LAC's post in Adding Javascript to widget was marked as the answer   
    \IPS\Output::i()->jsFiles = array_merge(\IPS\Output::i()->jsFiles, \IPS\Output::i()->js('location_section.js', 'app'));  
  16. newbie LAC's post in ContentModeratorPermissions x ModeratorPermissions extension was marked as the answer   
    You couldn't add ContentModeratorPermissions extension if you haven't ContentRouter extension with declared classes
    ContentRouter extension will automaticaly add a tab. Just call it ItemModPermissions

    Comment 
    $this->classes[] = 'IPS\downloads\File'; in the \applications\downloads\extensions\core\ContentRouter\Files.php
    Result

     
    ContentModeratorPermissions will add new permission(s) to ItemModPermissions
    Create new for Downloads
    Result


    ModeratorPermissions will add a new tab. See Downloads (\applications\downloads\extensions\core\ModeratorPermissions\Files.php) for example.

    Read also

    ContentModeratorPermissions -> \IPS\application\Item::modPermission('permission', NULL, $container) -> \IPS\downloads\File::modPermission('hide', NULL, $container)
    ModeratorPermissions -> \IPS\Member::loggedIn()->modPermission('permission') -> \IPS\Member::loggedIn()->modPermission('can_make_purchasable')
  17. newbie LAC's post in The equivalent of $hanLogin->loginWithoutCheckingCredentials was marked as the answer   
    Hello,
     
  18. newbie LAC's post in zeroVal usage in node-setting. Problems with checkbox was marked as the answer   
    Hello,
    {{if $value === 0}}checked{{endif}} So your value should be 0 (integer)
    0 (integer)
    Yes
    You can have 3 values
    0 (string) - the checkbox checked
    empty string - No selected forums and the checkbox unchecked
    not empty string (ex. 1,2,3,4,5) - selected forums with IDs 1,2,3,4,5
    this
    You have checked checkbox, then uncheck it and save the form the code runs again so you have
    1. you have checked checkbox
    2. checks next code
    if( \IPS\Settings::i()->anon_inforums === '0' )
    {
        \IPS\Settings::i()->anon_inforums = 0;
    }
    3. you have overridden the setting value
    4. save the form
    \system\Settings\Settings.php
    if ( $this->$k != $valueToCache ) { $this->$k = $valueToCache; \IPS\Db::i()->update( 'core_sys_conf_settings', array( 'conf_value' => $v ), array( 'conf_key=?', $k ) ); 0 != '' return false. In your case
    '0' != '' return true

    I use
    $form->add( new \IPS\Helpers\Form\Node( 'setting_key', \IPS\Settings::i()->setting_key === '0' ? 0 : \IPS\Settings::i()->setting_key,  
  19. newbie LAC's post in How to extend the REST API was marked as the answer   
    Hello,
    Pay attention on what bfarber said

    This mean you have in phpdoc block
    /** * GET ethereal/members/hwid/{id}&key=my_license If your app folder is hwid and file ethereal.php (applications/hwid/api/ethereal.php) the above line should be
    /** * GET /hwid/ethereal/{id}  
  20. newbie LAC's post in Lazy load in 3rd-party resources was marked as the answer   
    You should to use additional attributes
    img[data-src]
    [data-background-src]
    iframe[data-embed-src]
    video[data-video-embed]
    + controllers which support lazy load or attribute data-ipsLazyLoad
     
    Examples
    <div data-controller='core.front.core.lightboxedImages'> {{if settings.lazy_load_enabled}} <img src='{expression="\IPS\Text\Parser::blankImage()"}' data-src='link_to_img' alt="alt_text"> {{else}} <img src='link_to_img' alt="alt_text"> {{endif}} </div>  
    <div data-ipsLazyLoad> {{if settings.lazy_load_enabled}} <img src='{expression="\IPS\Text\Parser::blankImage()"}' data-src='link_to_img' alt="alt_text"> {{else}} <img src='link_to_img' alt="alt_text"> {{endif}} </div>  
  21. newbie LAC's post in No Link was marked as the answer   
    The defaultFrontNavigation method will only be called when you install your app
  22. newbie LAC's post in How do I load a content item object? was marked as the answer   
    $post = \IPS\forums\Topic\Post::load(1); or
    try { $post = \IPS\forums\Topic\Post::loadAndCheckPerms(1); } catch (\Exception $e) { }  
  23. newbie LAC's post in Adding an application icon? was marked as the answer   
    Add in \applications\%application%\dev\lang.php
    'menutab__application_icon' => 'icon', In my case
    'menutab__football_icon' => 'futbol-o',

    Add in \applications\%application%\Application.php
    /** * [Node] Get Icon for tree * * @note Return the class for the icon (e.g. 'globe') * @return string|null */ protected function get__icon() { return 'icon'; } In my case
    /** * [Node] Get Icon for tree * * @note Return the class for the icon (e.g. 'globe') * @return string|null */ protected function get__icon() { return 'futbol-o'; }  
  24. newbie LAC's post in Issue with Source/ActiveRecord was marked as the answer   
    Again
    In your case Personal not personal
    namespace IPS\avovix\Personal; + rename the folder from personal to Personal
  25. newbie LAC's post in \IPS\Content::$includeInUserProfiles was marked as the answer   
    IPS removed this in 4.3
×
×
  • Create New...