5671
wishcraft
@request -- User Signup Basic Sentry -- Avatar, Rego Date & Posts

The following is the basic outline for a sentry on signup to drop maligant signup bots form threading:-

The first file is the sentry preloader in system

/**
 * System Preloads
 *
 * You may not change or alter any portion of this comment or credits
 * of supporting developers from this source code or any supporting source code
 * which is considered copyrighted (c) material of the original comment or credit authors.
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 *
 * @copyright   The XOOPS Project http://sourceforge.net/projects/xoops/
 * @license     GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
 * @author      Simon Roberts (AKA +61252661492)
 * @version     $Id: sentry.php 
 */

defined('XOOPS_ROOT_PATH') or die('Restricted access');

class 
SystemSentryPreload extends XoopsPreloadItem
{
    function 
eventCoreIncludeCommonEnd($args)
    {
                if (!
$GLOBALS['xoopsUserConfig']['sentry_enabled'])
                          return 
false;
        
$criteriaAvarta = new Criteria('user_avatar''%blank.gif%''LIKE');
        
$criteriaNewReg = new CriteriaCompo(new Criteria('user_regdate'time() - (24 3600 $GLOBALS['xoopsUserConfig']['sentry_regodays']), '<'));
        
$criteriaNewReg->add(new Criteria('last_login'time() - (24 3600 $GLOBALS['xoopsUserConfig']['sentry_loindays']), "<"), 'AND');
        
$criteriaNewReg->add(new Criteria('posts'$GLOBALS['xoopsUserConfig']['sentry_posts'], "<"), 'AND');
        
$criteria = new CriteriaCompo($criteriaAvarta);
        
$criteria->add($criteriaNewReg"AND");
        
$member_handler xoops_gethandler('member');
        
$tokill = array();
        foreach(
$member_handler->getUsers($criteriatrue) as $key => $user)
        {
            if (!
$user->isAdmin())
                
$tokill[$user->getVar("uid")] = $user;
        }
        if (
count($tokill))
        {
            
xoops_loadLanguage('user');
            
$xoopsMailer =& xoops_getMailer();
            
$xoopsMailer->useMail();
            
$xoopsMailer->setTemplate('sentrydropped.tpl');
            
$xoopsMailer->setSubject(sprintf("Your account on '%s' has been deleted by the sentry!"$GLOBALS['xoopsConfig']['sitename']));
            
$xoopsMailer->setToUsers($tokill);
            @
$xoopsMailer->send();
            
$sql = array();
            
$GLOBALS["xoopsDB"]->queryF($sql[] = "DELETE FROM `" $GLOBALS["xoopsDB"]->prefix('users') . "` WHERE `uid` IN(" implode(", "array_keys($tokill)) . ")");
            
$GLOBALS["xoopsDB"]->queryF($sql[] = "DELETE FROM `" $GLOBALS["xoopsDB"]->prefix('groups_users_link') . "` WHERE `uid` IN(" implode(", "array_keys($tokill)) . ")");

        }
      }
}
?>


You will have to create the following variable I suggest they are made as a single item drop down options list, variable from 2 weeks down to 3 days for the first avriable, then something that is from 24 month down to 1 month an then 2 - 20 items for the number of posts, you will see these variables that will have to be created specified in the function above with the $GLOBALS['xoopsUserConfig'] variable, these go in the User Preferences in the system module, default is this option is turned off.

You will also have to add a template to language/english/mail_template/sentrydropped.tpl, an example of this would be:-
To {X_UNAME},

Your account on "{SITENAME}" has been removed due to the User Sentry finding that you have
either not changed your avatar
, or you where in active without enough posts and also not
changing your avatar
!

- as 
you didn't change your 'avatar' from the blank default image; 
  with 7 - 14 days in consecutive selection, your account has been removed 
  off the systems' 
and terminated!!

Many thanks,

{
SITE_COMPANY}
{
SITE_URL}


You will probably also want to have a register_sentry.tpl like so which you will have to alter the class/??.php too enable this if the sentry is turn on, it will need the number of days passed to the emailer so it can be populated as ie. {X_SENTRYDAYS}.

Hello {X_UNAME},

Thank you for registering as a member of {SITENAME}. As a registered member your can:
Send private messages among members
Participate in discussion boards
Get the latest news
Submit content
Muchmuch more....

The email address ({X_UEMAIL}) has been used to create a user profile for you.

NOTICE:-

 - 
You will have to change your avatar within {X_SENTRYDAYSdays cause if you haven't somewhere 
   between these times you will be deleted if your avatar remains on the default blank
   as well as remain inactive for a period of 24 Months!

To become a member of {SITENAME}, please confirm your
request by clicking on the link below:

{X_UACTLINK}

-----------
Best Regards
{SITENAME}
({SITEURL}) 
{ADMINMAIL}



5672
wishcraft
@request - cache files need to be reduces for cpanel machines

The Cache Files need to be reduced for the xoops_data folder, this is quite easy to do some example basic work around routines are included here to be worked into XoopsCache::read(), XoopsCache::write() & XoopsCache::delete().

XoopsCache::read() in class/cache/file.php
/**
     * Read a key from the cache
     *
     * @param  string $key Identifier for the data
     * @return mixed  The cached data, or false if the data doesn't exist, has expired, or if there was an error fetching it
     * @access public
     */
    
function read($key)
    {
        
$fingerprint md5(implode('',array_reverse(explode("_",$key)));
        if (
$this->setKey(sha1(substr($fingerprint,0,2))) === false || ! $this->init) {
            return 
false;
        }
        if (
$this->settings['lock']) {
            
$this->file->lock true;
        }
        
$data $this->file->read(true);
        if (!empty(
$data) && !empty($this->settings['serialize'])) {
            
$data stripslashes($data);
            
$data preg_replace('!s:(d+):"(.*?)";!se'"'s:'.strlen('$2').':"$2";'"$data);
            
$data unserialize($data);
            if (
is_array($data)) {
                
XoopsLoad::load('XoopsUtility');
                
$data XoopsUtility::recursive('stripslashes'$data);
            }
        } else if (
$data && empty($this->settings['serialize'])) {
            
$data = eval($data);
        }
        
$unset false;
        foreach(
$data['keys'] as $kiy => $cachetime)
        {
            if (
$cachetime !== false && intval($cachetime) < time()) {
                unset(
$data['values'][$kiy]);
                unset(
$data['keys'][$kiy]);
                
$unset true;
            }
        }
        
$this->file->close();
        return !empty(
$data['values'][$key])?$data['values'][$key]:false;
    }


XoopsCache::write() in class/cache/file.php
/**
     * Write data for key into cache
     *
     * @param  string  $key      Identifier for the data
     * @param  mixed   $data     Data to be cached
     * @param  mixed   $duration How long to cache the data, in seconds
     * @return boolean True if the data was successfully cached, false on failure
     * @access public
     */
    
function write($key$values null$duration null)
    {
        if (!isset(
$data) || ! $this->init) {
            return 
false;
        }

        
$fingerprint md5(implode('',array_reverse(explode("_",$key)));
        if (
$this->setKey(sha1(substr($fingerprint,0,2))) === false || ! $this->init) {
            return 
false;
        }

        if (
$duration == null) {
            
$duration $this->settings['duration'];
        }
        
$data $this->file->read(true);
        if (!empty(
$data) && !empty($this->settings['serialize'])) {
            
$data stripslashes($data);
            
$data preg_replace('!s:(d+):"(.*?)";!se'"'s:'.strlen('$2').':"$2";'"$data);
            
$data unserialize($data);
            if (
is_array($data)) {
                
XoopsLoad::load('XoopsUtility');
                
$data XoopsUtility::recursive('stripslashes'$data);
            }
        } else if (
$data && empty($this->settings['serialize'])) {
            
$data = eval($data);
        }
        foreach(
$data['keys'] as $kiy => $cachetime)
        {
            if (
$cachetime !== false && intval($cachetime) < time()) {
                unset(
$data['values'][$kiy]);
                unset(
$data['keys'][$kiy]);
            }
        }
        
$data['keys'][$key] = $expires time() + $duration;
        
$data['values'][$key] = $values;
        
        
$windows false;
        
$lineBreak "n";

        if (
substr(PHP_OS03) == "WIN") {
            
$lineBreak "rn";
            
$windows true;
        }
        ;
        if (!empty(
$this->settings['serialize'])) {
            if (
$windows) {
                
$data str_replace('\''\\\\'serialize($data));
            } else {
                
$data serialize($data);
            }
            
$contents $data $lineBreak;
        } else {
            
$contents "return " var_export($datatrue) . ";" $lineBreak;
        }

        if (
$this->settings['lock']) {
            
$this->file->lock true;
        }
        
$success $this->file->write($contents);
        
$this->file->close();

        return 
$success;
    }


XoopsCache::delete() in class/cache/file.php
/**
     * Delete a key from the cache
     *
     * @param  string  $key Identifier for the data
     * @return boolean True if the value was successfully deleted, false if it didn't exist or couldn't be removed
     * @access public
     */
    
function delete($key)
    {
        
$fingerprint md5(implode('',array_reverse(explode("_",$key)));
        if (
$this->setKey(sha1(substr($fingerprint,0,2))) === false || ! $this->init) {
            return 
false;
        }
        if (
$this->settings['lock']) {
            
$this->file->lock true;
        }
        
$data $this->file->read(true);
        if (!empty(
$data) && !empty($this->settings['serialize'])) {
            
$data stripslashes($data);
            
$data preg_replace('!s:(d+):"(.*?)";!se'"'s:'.strlen('$2').':"$2";'"$data);
            
$data unserialize($data);
            if (
is_array($data)) {
                
XoopsLoad::load('XoopsUtility');
                
$data XoopsUtility::recursive('stripslashes'$data);
            }
        } else if (
$data && empty($this->settings['serialize'])) {
            
$data = eval($data);
        }
        
$unset false;
        foreach(
$data['keys'] as $kiy => $cachetime)
        {
            if (
$cachetime !== false && intval($cachetime) < time()) {
                unset(
$data['values'][$kiy]);
                unset(
$data['keys'][$kiy]);
                
$unset true;
            }
        }
        unset(
$data['values'][$key]);
        unset(
$data['keys'][$key]);
        
        
$windows false;
        
$lineBreak "n";

        if (
substr(PHP_OS03) == "WIN") {
            
$lineBreak "rn";
            
$windows true;
        }
        ;
        if (!empty(
$this->settings['serialize'])) {
            if (
$windows) {
                
$data str_replace('\''\\\\'serialize($data));
            } else {
                
$data serialize($data);
            }
            
$contents $data $lineBreak;
        } else {
            
$contents "return " var_export($datatrue) . ";" $lineBreak;
        }

        if (
$this->settings['lock']) {
            
$this->file->lock true;
        }
        
$success $this->file->write($contents);
        
$this->file->close();

        return 
true;
    }



5673
brutalicuss
Re: Rating system in publisher module

Yes, you are just great Mamba :))

I was adding the new lines in my files. Thats the fault !
Now, in new installation its working. And we can choose sort type of the list.

But I have still trouble (maybe personal) because I want to have more than one option for sorting, at the same time. There must be all sorting option. Now im trying to editing blocks php files to achieve this wishes :) Because after that I can clone the block and will have all sorting option :)

But if you plan to upload new publisher version and if you want this module to be just perfect, you should thinking about this option in "recent block" or some similar. Will be great to sort by all features - date/hits/rating/weight, even comments count.




5674
wishcraft
Re: @required ::- Open all access pathways with NPN and HTML Headers (Additional Headers)

You can also us .htaccess lijje so:-

# Opens Access Origin Via networking Route NPN 
<IfModule mod_headers.c>
  
Header set Origin *
  
Header set Access-Control-Allow-Origin *
IfModule>



5675
Mamba
Re: Rating system in publisher module
  • 2015/6/24 10:30

  • Mamba

  • Moderator

  • Posts: 11373

  • Since: 2004/4/23


Quote:
I tried with the new correction in index.php/category.php to sort items by rating/votes but its seems to not working. Still sorting only by the time.

You need to go to Preferences and select which way you want to sort. You'll have the five choices there:

- date
- title
- weight
- rating
- votes

If you just copied the news files over your existing test site, then you'll need to update the module to have the changes visible in Preferences.

Please note: this is still only for "test sites", and not production sites....
Support XOOPS => DONATE
Use 2.5.10 | Docs | Modules | Bugs



5676
brutalicuss
Re: Rating system in publisher module

Hi Mamba! Thank you very much! Im really glad that you want to improve publisher module.

But I have still trouble with the sorting

I mean that I need to sort items by many orders like time/votes/hits/comments in recent/latest list or some other way like publisher blocks - "recent publisher items" or any other possible way

I tried with the new correction in index.php/category.php to sort items by rating/votes but its seems to not working. Still sorting only by the time.

For hits and weight we have option in one publisher block, but for new features rating and votes (guess that is comments) we havent because these new functions are not included

Maybe I dont know how to use your editing or doing something wrong, and I will be thankful if you have time to explain me



5677
wishcraft
@upgrade::- Hooking Stratum Preloaders by Trabis and Myself need to be exploited!!

The hooking strata need's too be exploited further; this is similar to an event handler, exactly that what it is -- it is made with a cursor style entry.

Example in this call this is how you would change it in class/model/read.php.
/**
     * retrieve objects from the database
     *
     * For performance consideration, getAll() is recommended
     *
     * @param CriteriaElement|null $criteria {@link CriteriaElement} conditions to be met
     * @param bool $id_as_key use the ID as key for the array
     * @param bool $as_object return an array of objects?
     * @return array
     */
    
public function getObjects(CriteriaElement $criteria null$id_as_key false$as_object true)
    {
        
$objects $this->getAll($criterianull$as_object$id_as_key);
        
$xoopsPreload XoopsPreload::getInstance();
        return 
$xoopsPreload->triggerFunction('core.'.basename(dirname(__DIR__)).'.'.__CLASS__.'.'.__FUNCTION__$objects, array('criteria'=>$criteria));;
    }


Example in this call this is how you would change it in class/model/read.php.
/**
     * get all objects matching a condition
     *
     * @param CriteriaElement|null $criteria {@link CriteriaElement} to match
     * @param array $fields variables to fetch
     * @param bool $asObject flag indicating as object, otherwise as array
     * @param bool $id_as_key use the ID as key for the array
     * @return array of objects/array {@link XoopsObject}
     */
    
public function getAll(CriteriaElement $criteria null$fields null$asObject true$id_as_key true)
    {
        if (
is_array($fields) && count($fields) > 0) {
            if (!
in_array($this->handler->keyName$fields)) {
                
$fields[] = $this->handler->keyName;
            }
            
$select "`" implode("`, `"$fields) . "`";
        } else {
            
$select "*";
        }
        
$limit null;
        
$start null;
        
$sql "SELECT {$select} FROM `{$this->handler->table}`";
        if (isset(
$criteria)) {
            
$sql .= " " $criteria->renderWhere();
            if (
$groupby $criteria->getGroupby()) {
                
$sql .= ' GROUP BY (' $groupby ')';
            }
            if (
$sort $criteria->getSort()) {
                
$sql .= " ORDER BY {$sort} " $criteria->getOrder();
                
$orderSet true;
            } else if (
$order $criteria->getOrder()) {
                
$sql .= " ORDER BY {$this->handler->keyName} " $order;
                
$orderSet true;
            }
            
$limit $criteria->getLimit();
            
$start $criteria->getStart();
        }
        if (empty(
$orderSet)) {
            
//$sql .= " ORDER BY `{$this->handler->keyName}` DESC";
        
}
        
$result $this->handler->db->query($sql$limit$start);
        
$ret = array();
        if (
$asObject) {
            while (
$myrow $this->handler->db->fetchArray($result)) {
                
$object $this->handler->create(false);
                
$object->assignVars($myrow);
                if (
$id_as_key) {
                    
$ret[$myrow[$this->handler->keyName]] = $object;
                } else {
                    
$ret[] = $object;
                }
                unset(
$object);
            }
        } else {
            
$object $this->handler->create(false);
            while (
$myrow $this->handler->db->fetchArray($result)) {
                
$object->assignVars($myrow);
                if (
$id_as_key) {
                    
$ret[$myrow[$this->handler->keyName]] = $object->getValues();
                } else {
                    
$ret[] = $object->getValues();
                }
            }
            unset(
$object);
        }
        
$xoopsPreload XoopsPreload::getInstance();
        return 
$xoopsPreload->triggerFunction('core.'.basename(dirname(__DIR__)).'.'.__CLASS__.'.'.__FUNCTION__.'.'.$this->handler->table$objects, array('criteria'=>$criteria));
    }


The line that changed in this example between the two functions is, the part that has been added to include the child objects table name so it session more lower layer:-

// Added to the line in second example call :[.'.'.$this->handler->table]:
$xoopsPreload->triggerFunction('core.'.basename(dirname(__DIR__)).'.'.__CLASS__.'.'.__FUNCTION__.'.'.$this->handler->table$objects, array('criteria'=>$criteria));


The function triggerFunction will need to be created as well I am sure they might be some other type of preloaded apart from event... maybe you could make something as a handler class that set class sessioning.




5678
wishcraft
@required ::- Open all access pathways with NPN and HTML Headers (Additional Headers)

I would like to bring your attention to the following code that need to be sent when buffering the output on XOOPS CMS:

/**
 * Opens Access Origin Via networking Route NPN
 */
header('Access-Control-Allow-Origin: *');
header('Origin: *');


This sent with the packet headers means it will route all predominant routes and session the route any way when needed. It is part of NPN - Plugin & Play Networks, and words on reverse direction with simaltype as this would be MAC Networks but in IP Routes!

An example of this in use would be found at: salty/apiconfig.php


You can also set it for example for access controlling:-
/**
 * Opens Access Origin Via networking Route NPN
 */
header('Access-Control-Allow-Origin: fonts.labs.coop, fonts.syd.labs.coop, fonts.api.hempembassy.net,fonts.ringwould.com.au');
header('Access-Control-Disallow-Origin: localhost,127.0.0.1');
header('Origin: *');


These three net to be set in General preferences as a textarea with default *, except for Access-Control-Disallow-Origin needs to be localhost,127.0.0.1

*geekw::- It would be really good in 2.6 if the functions and class calls; all had preloader external so on return in them it runs that value threw:- $GLOBALS['xoopsPreloads']->etc...

This would make all facits of the portal accessible for minor changes and forcing as well as adding stuff!!




5679
wishcraft
Re: @fixed::- xoops_getBaseDomain() -- required for multitiered cookies!

This is the finite improved version for this function the following are required:-

data/stratas.diz
http://strata.api.hempembassy.net
https://strata.ringwould.com.au
http://strata.labs.coop


The following constant is required:
define("API_FILE_IO_STRATA"__DIR__ DIRECTORY_SEPARATOR 'data' DIRECTORY_SEPARATOR 'stratas.diz');


The following is the functions for XOOPS
if (!function_exists("getURIData")) {

    
/* function getURIData()
     *
    *     Get a supporting domain system for the API
    * @author         Simon Roberts (Chronolabs) simon@labs.coop
    *
    * @return         float()
    */
    
function getURIData($uri ''$timeout 25$connectout 25)
    {
        if (!
function_exists("curl_init"))
        {
            return 
file_get_contents($uri);
        }
        if (!
$btt curl_init($uri)) {
            return 
false;
        }
        
curl_setopt($bttCURLOPT_HEADER0);
        
curl_setopt($bttCURLOPT_POST0);
        
curl_setopt($bttCURLOPT_CONNECTTIMEOUT$connectout);
        
curl_setopt($bttCURLOPT_TIMEOUT$timeout);
        
curl_setopt($bttCURLOPT_RETURNTRANSFERtrue);
        
curl_setopt($bttCURLOPT_VERBOSEfalse);
        
curl_setopt($bttCURLOPT_SSL_VERIFYHOSTfalse);
        
curl_setopt($bttCURLOPT_SSL_VERIFYPEERfalse);
        
$data curl_exec($btt);
        
curl_close($btt);
        return 
$data;
    }
}

if (!
function_exists("getBaseDomain")) {
    
/**
     * getBaseDomain
     * 
     * @param string $url
     * @return string|unknown
     */
    
function getBaseDomain($url)
    {
        
        static 
$strata$fallout$stratas;

        
xoops_load('XoopsCache');

        if (empty(
$strata))
        {
            if (!
$strata XoopsCache::read('internets_stratas'))
            {
                if (empty(
$stratas))
                    
$stratas file(API_FILE_IO_STRATA);
                
shuffle($stratas);
                
$attempts 0;
                while(empty(
$strata) || $attempts < (count($strata) * 1.65))
                {
                    
$attempts++;
                    
$strata array_keys(unserialize(getURIData($stratas[mt_rand(0count($stratas)-1)] ."/v1/strata/serial.api"1519)));
                }
                if (!empty(
$strata))
                    
XoopsCache::write('internets_stratas'$strata3600*24*mt(3.75,11));
            }
        }
        if (empty(
$fallout))
        {
            if (!
$fallout XoopsCache::read('internets_fallouts'))
            {
                if (empty(
$stratas))
                    
$stratas file(API_FILE_IO_STRATA);
                
shuffle($stratas);
                
$attempts 0;
                while(empty(
$fallout) || $attempts < (count($strata) * 1.65))
                {
                    
$attempts++;
                    
$fallout array_keys(unserialize(getURIData($stratas[mt_rand(0count($stratas)-1)] ."/v1/fallout/serial.api"1519)));
                }
                if (!empty(
$fallout))
                    
XoopsCache::write('internets_fallouts'$fallout3600*24*mt(3.75,11));
            }
        }
        
        
// Get Full Hostname
        
$url strtolower($url);
        
$hostname parse_url($urlPHP_URL_HOST);
        if (!
filter_var($hostnameFILTER_VALIDATE_IP) === true
            return 
$hostname;
    
        
// break up domain, reverse
        
$elements explode('.'$hostname);
        
$elements array_reverse($elements);
        
        
// Returns Base Domain
        
if (in_array($elements[0], $fallout) && in_array($elements[1], $strata))
            return 
$elements[2] . '.' $elements[1] . '.' $elements[0];
        elseif (
in_array($elements[0], $fallout) || in_array($elements[0], $strata))
            return 
$elements[1] . '.' $elements[0];
        
        
// Nothing Found
        
return $hostname;
    }
}



5680
Mamba
Re: Rating system in publisher module
  • 2015/6/23 21:31

  • Mamba

  • Moderator

  • Posts: 11373

  • Since: 2004/4/23


Yes, it is possible!

Do you want to do it yourself, or do you want to wait for the next version?

You can download the updated version from GitHub as a Zip file and test it. If I don't hear anything about issues/bugs, then I'll probably will release this version by July 1st.

To see what has changed, you can look here
Support XOOPS => DONATE
Use 2.5.10 | Docs | Modules | Bugs




TopTop
« 1 ... 565 566 567 (568) 569 570 571 ... 29425 »



Login

Who's Online

430 user(s) are online (327 user(s) are browsing Support Forums)


Members: 0


Guests: 430


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Jul 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits