Author Topic: Few fixes and addons  (Read 7280 times)

Marble

  • Global Moderator
  • Veteran Member
  • *****
  • Posts: 1004
  • Karma: +56/-7
Re: Few fixes and addons
« Reply #15 on: May 18, 2015, 10:05:33 AM »
Is it possible to modify this so that only the first 3 views show up in the list and in order to see the rest, the user has to upgrade their subscription?
If you see that I'm logged in forever... it just means I turned the page on my browser and forgot to logout.

flyer5

  • Active Member
  • ***
  • Posts: 96
  • Karma: +4/-0
    • North East Nudists
Re: Few fixes and addons
« Reply #16 on: May 19, 2015, 11:24:05 AM »
Beware of using google recaptcha!
I installed this and it was working perfectly for 3 days then for no apparent reason stopped working. I had to undo the changes made by this mod to get the old verification working.

Marble

  • Global Moderator
  • Veteran Member
  • *****
  • Posts: 1004
  • Karma: +56/-7
Re: Few fixes and addons
« Reply #17 on: May 19, 2015, 12:00:01 PM »
I haven't had problems with google recaptcha since installing it. my favorite was to click on the images that had ice cream.  :D
If you see that I'm logged in forever... it just means I turned the page on my browser and forgot to logout.

SwingersGezocht

  • Active Member
  • ***
  • Posts: 30
  • Karma: +0/-0
Re: Few fixes and addons
« Reply #18 on: May 19, 2015, 12:48:25 PM »
I don`t get the chapta code :-(

Marble

  • Global Moderator
  • Veteran Member
  • *****
  • Posts: 1004
  • Karma: +56/-7
Re: Few fixes and addons
« Reply #19 on: May 26, 2015, 10:55:27 AM »
I don`t get the chapta code :-(

Go to this link: http://www.testing-site.info/etano-addons.html
and look for the download link for Google Apps addon. In there, you will find info about setting up Google reCaptcha. I didn't install the Google reCaptcha this way, but as an addon for the package installer, it should simplify the installation for you.
If you see that I'm logged in forever... it just means I turned the page on my browser and forgot to logout.

Marble

  • Global Moderator
  • Veteran Member
  • *****
  • Posts: 1004
  • Karma: +56/-7
Re: Few fixes and addons
« Reply #20 on: June 15, 2015, 11:37:29 AM »
How do you suggest I set up Google reCaptcha on the contact.php page?
If you see that I'm logged in forever... it just means I turned the page on my browser and forgot to logout.

KHDev

  • Global Moderator
  • Veteran Member
  • *****
  • Posts: 501
  • Karma: +43/-2
  • Etano Contributor (Skins & Mods)
    • KH Web Development
Re: Few fixes and addons
« Reply #21 on: June 29, 2015, 08:17:34 AM »
How do you suggest I set up Google reCaptcha on the contact.php page?


Hey, not sure if you still want this and since you didn't get a reply, this should work for you: :)

Open contact.php

Code: [Select]
### Find this block  lines 29 - 32 ####

require _BASEPATH_.'/includes/classes/sco_captcha.class.php';
$c=new sco_captcha(_BASEPATH_.'/includes/fonts',4);
$_SESSION['captcha_word']=$c->gen_rnd_string(4);
$output['rand']=make_seed();

### Replace it with ####

$siteKey = get_site_option('google_site_key','core');
$tpl->set_var('siteKey',$siteKey);



Open processors/contact.php

Code: [Select]
# # # Find Block lines 54 - 60 ####

$captcha=sanitize_and_format_gpc($_POST,'captcha',TYPE_STRING,0,'');
if (!$error && (!isset($_SESSION['captcha_word']) || strcasecmp($captcha,$_SESSION['captcha_word'])!=0)) {
$error=true;
$topass['message']['type']=MESSAGE_ERROR;
$topass['message']['text']=$GLOBALS['_lang'][24];
$input['error_captcha']='red_border';
}

### Replace it with ####

$captcha=sanitize_and_format_gpc($_POST,'g-recaptcha-response',TYPE_STRING,$__field2format[FIELD_TEXTFIELD],'');
$response=file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=".get_site_option('google_sec_key','core')."&response=".$captcha."&remoteip=".$_SERVER['REMOTE_ADDR']);
$response = json_decode($response);
if (!$error && (!$captcha || $response->{'success'}==false)) {
$error=true;
$topass['message']['type']=MESSAGE_ERROR;
$topass['message']['text'][]=$GLOBALS['_lang'][24];
$input['error_captcha']='red_border';
}

and ## Delete ##

unset($_SESSION['captcha_word']);



Open contact.html and replace the old captcha with:

Code: [Select]
<!--opt name="output.use_captcha"-->
<fieldset><dl>
<dt>&nbsp;</dt>
<dd>
<div class="g-recaptcha" data-sitekey="{siteKey}"></div>
<script type="text/javascript"src="https://www.google.com/recaptcha/api.js?hl=en"></script>
</dd>
</dl> </fieldset>
<!--/opt name="output.use_captcha"-->

Marble

  • Global Moderator
  • Veteran Member
  • *****
  • Posts: 1004
  • Karma: +56/-7
Re: Few fixes and addons
« Reply #22 on: June 29, 2015, 08:52:49 AM »
Thanks! I'll look into this when I return from my ocean sailing adventure.
If you see that I'm logged in forever... it just means I turned the page on my browser and forgot to logout.

Hornyflings

  • Prime Member
  • ****
  • Posts: 192
  • Karma: +3/-0
    • AsiasHeart
Re: Few fixes and addons
« Reply #23 on: July 23, 2015, 02:20:07 AM »
Is it possible to get instruction to add the mod "Who viewed me" manually?
Reason is, for those who aren't using the standard theme and try to install the mod through package manager it will not work because the file photo_view.html isn't original anymore.

starmindfr

  • Confirmed Member
  • **
  • Posts: 16
  • Karma: +0/-0
    • www.embrassezmoi.com
Re: Few fixes and addons
« Reply #24 on: July 24, 2015, 05:22:16 AM »
Thanks! I'll look into this when I return from my ocean sailing adventure.

just in case you get no change i have also added this to previous code

in contact php :

      $output['use_captcha']=true;

and in contact.html i removed the 2 flags <!--opt name="!tplvars.user_logged"--><!--opt/ name="!tplvars.user_logged"-->
so everyone have to suffer the recapcha

www.embrassezmoi.com (custom: whoIsOnline,whoVisitedMe,scores,game,androidAPK,GoogleMaps)

KHDev

  • Global Moderator
  • Veteran Member
  • *****
  • Posts: 501
  • Karma: +43/-2
  • Etano Contributor (Skins & Mods)
    • KH Web Development
Re: Few fixes and addons
« Reply #25 on: July 24, 2015, 06:39:32 AM »
just in case you get no change i have also added this to previous code

in contact php :

      $output['use_captcha']=true;

That line should have already of been in contact.php...

starmindfr

  • Confirmed Member
  • **
  • Posts: 16
  • Karma: +0/-0
    • www.embrassezmoi.com
Re: Few fixes and addons
« Reply #26 on: July 24, 2015, 07:29:18 AM »
yes it should be in (as i see original etano code with it) but i dont know why, like on the sample you provided on this page i dont have the line in my contact.php
www.embrassezmoi.com (custom: whoIsOnline,whoVisitedMe,scores,game,androidAPK,GoogleMaps)

Marble

  • Global Moderator
  • Veteran Member
  • *****
  • Posts: 1004
  • Karma: +56/-7
Re: Few fixes and addons
« Reply #27 on: September 03, 2015, 11:28:27 PM »
Will make those cron jobs and other recommendations a bit later

Did you ever make those cron jobs and figure out how to delete the WVM data?

Also, I decided to go back and give this another try. I ended up manually adding the modifications. Once I had everything up and running to my liking, I saw that the See All link next to Members Who I viewed doesn't work.
Here is the error that I see:
Quote
No results found that match your search criteria. Go Back and broaden your criteria selections and try again.   
I viewed more than 4. The See All link next to Members Who Viewed Me is working. Do you have a solution to this problem?
If you see that I'm logged in forever... it just means I turned the page on my browser and forgot to logout.

Marble

  • Global Moderator
  • Veteran Member
  • *****
  • Posts: 1004
  • Karma: +56/-7
Re: Few fixes and addons
« Reply #28 on: September 04, 2015, 10:36:47 AM »
I noticed in your "who viewed me" mod it doesn't include a cron job or function to purge old data.

I know it might not be mandatory but people should consider purging data older than a set time frame.

Also, consider that when a user deletes their account perhaps delete the stored WVM data which relates to that user to help keep things upto date.

:)

KHDev, I created a purge_who_viewed_me option just like I did for the spambox. I set it for 1 day in the admin panel about 35 minutes ago and will see what happens when the one day period completes it's cycle. To share what I did, here are the instructions. If anyone finds an error in my code, please mention it.

#1
in your database dsb_site_options3, run this line in SQL
Code: [Select]
INSERT INTO `dsb_site_options3` (`config_option`, `config_value`, `config_diz`, `option_type`, `choices`, `fk_module_code`, `per_user`) VALUES ('purge_who_viewed_me', '', 'Purge old whos viewed me data after how many days? (0 for never)', '104', '', 'core', '0');
#2
go to yoursiteroot.com/tools/cron/jobs/d and open 1purges.php
replace this code with what you have in this file.
Code: [Select]
<?php
$jobs
[]='purges';

function 
purges() {
global $dbtable_prefix;

$now=gmdate('YmdHis');
$config=get_site_option(array('purge_unverified','purge_inbox','purge_trash','purge_folders','purge_outbox','purge_spambox''purge_who_viewed_me'),'core'); //added purge_who_viewed_me - by Marble 9-04-2015

// these are orphaned accounts, not activated and with no profile data. These should not exist unless a critical error occured during join.
$query="SELECT `".USER_ACCOUNT_ID."` FROM `".USER_ACCOUNTS_TABLE."` a LEFT JOIN `{$dbtable_prefix}user_profiles` b ON a.`".USER_ACCOUNT_ID."`=b.`fk_user_id` WHERE a.`status`=".ASTAT_UNVERIFIED." AND b.`fk_user_id` IS NULL";
if (!($res=@mysql_query($query))) {trigger_error(mysql_error(),E_USER_ERROR);}
$to_del=array();
for ($i=0;$i<mysql_num_rows($res);++$i) {
$to_del[]=mysql_result($res,$i,0);
}
if (!empty($to_del)) {
$query="DELETE FROM `".USER_ACCOUNTS_TABLE."` WHERE `".USER_ACCOUNT_ID."` IN ('".join("','",$to_del)."')";
if (!($res=@mysql_query($query))) {trigger_error(mysql_error(),E_USER_ERROR);}
}

// these are orphaned accounts, with profile data but not activated. We cannot delete them but we can't let them like this. We need a profile for them
$query="SELECT `".USER_ACCOUNT_ID."` FROM `".USER_ACCOUNTS_TABLE."` a LEFT JOIN `{$dbtable_prefix}user_profiles` b ON a.`".USER_ACCOUNT_ID."`=b.`fk_user_id` WHERE a.`status`=".ASTAT_ACTIVE." AND b.`fk_user_id` IS NULL";
if (!($res=@mysql_query($query))) {trigger_error(mysql_error(),E_USER_ERROR);}
$to_profile=array();
for ($i=0;$i<mysql_num_rows($res);++$i) {
$to_profile[]=mysql_result($res,$i,0);
}
if (!empty($to_profile)) {
if (get_site_option('manual_profile_approval','core')==1) {
$pstat=STAT_PENDING;
} else {
$pstat=STAT_APPROVED;
}
$query="INSERT INTO `{$dbtable_prefix}user_profiles` (`fk_user_id`,`status`,`date_added`,`_user`) SELECT `".USER_ACCOUNT_ID."`,$pstat,'$now',`".USER_ACCOUNT_USER."` FROM `".USER_ACCOUNTS_TABLE."` WHERE `".USER_ACCOUNT_ID."` IN ('".join("','",$to_profile)."')";
if (!($res=@mysql_query($query))) {trigger_error(mysql_error(),E_USER_ERROR);}
}

if (!empty($config['purge_unverified'])) {
$query="SELECT `".USER_ACCOUNT_ID."` FROM `".USER_ACCOUNTS_TABLE."` a,`{$dbtable_prefix}user_profiles` b WHERE a.`".USER_ACCOUNT_ID."`=b.`fk_user_id` AND a.`status`=".ASTAT_UNVERIFIED." AND b.`date_added`<DATE_SUB('$now',INTERVAL ".$config['purge_unverified']." DAY)";
if (!($res=@mysql_query($query))) {trigger_error(mysql_error(),E_USER_ERROR);}
$to_del=array();
for ($i=0;$i<mysql_num_rows($res);++$i) {
$to_del[]=mysql_result($res,$i,0);
}
if (!empty($to_del)) {
$query="UPDATE `{$dbtable_prefix}user_profiles` SET `del`=1 WHERE `fk_user_id` IN ('".join("','",$to_del)."')";
if (!($res=@mysql_query($query))) {trigger_error(mysql_error(),E_USER_ERROR);}
}
}

if (!empty($config['purge_inbox'])) {
$query="DELETE FROM `{$dbtable_prefix}user_inbox` WHERE `date_sent`<DATE_SUB('$now',INTERVAL ".$config['purge_inbox']." DAY) AND `del`=0 AND `fk_folder_id`=0";
if (!($res=@mysql_query($query))) {trigger_error(mysql_error(),E_USER_ERROR);}
}

if (!empty($config['purge_trash'])) {
$query="DELETE FROM `{$dbtable_prefix}user_inbox` WHERE `date_sent`<DATE_SUB('$now',INTERVAL ".$config['purge_trash']." DAY) AND `del`=1";
if (!($res=@mysql_query($query))) {trigger_error(mysql_error(),E_USER_ERROR);}
}


if (!empty($config['purge_folders'])) {
$query="DELETE FROM `{$dbtable_prefix}user_inbox` WHERE `date_sent`<DATE_SUB('$now',INTERVAL ".$config['purge_folders']." DAY) AND `del`=0 AND `fk_folder_id`<>0";
if (!($res=@mysql_query($query))) {trigger_error(mysql_error(),E_USER_ERROR);}
}

if (!empty($config['purge_outbox'])) {
$query="DELETE FROM `{$dbtable_prefix}user_outbox` WHERE `date_sent`<DATE_SUB('$now',INTERVAL ".$config['purge_outbox']." DAY)";
if (!($res=@mysql_query($query))) {trigger_error(mysql_error(),E_USER_ERROR);}
}

// allow member spam boxes to be purged automatically - Marble from Datemill
if (!empty($config['purge_spambox'])) {
$query="DELETE FROM `{$dbtable_prefix}user_spambox` WHERE `date_sent`<DATE_SUB('$now',INTERVAL ".$config['purge_spambox']." DAY)";
if (!($res=@mysql_query($query))) {trigger_error(mysql_error(),E_USER_ERROR);}
}

//allow who viewed me data to be purged automatically - by Marble 9-04-2015
if (!empty($config['purge_who_viewed_me'])) {
$query="DELETE FROM `{$dbtable_prefix}who_viewed_me` WHERE `date`<DATE_SUB('$now',INTERVAL ".$config['purge_who_viewed_me']." DAY)";
if (!($res=@mysql_query($query))) {trigger_error(mysql_error(),E_USER_ERROR);}
}

return true;
}


The changes I made are on lines #8 and #79

#3
go to your Admin Control Panel > General Settings > Features and Options and set a number value in the text box for after how many days do you want to wait for the data to be purged


I don't know how to delete the stored WVM data. Does anyone else know?


***************************
first error of the day. I made a little mistake and corrected it in the above code. I changed in line #81 it was written with WHERE `date_sent` . The error indicated that this column didn't exist, which was correct. I changed it to WHERE `date`.
If you see that I'm logged in forever... it just means I turned the page on my browser and forgot to logout.

KHDev

  • Global Moderator
  • Veteran Member
  • *****
  • Posts: 501
  • Karma: +43/-2
  • Etano Contributor (Skins & Mods)
    • KH Web Development
Re: Few fixes and addons
« Reply #29 on: September 04, 2015, 12:42:05 PM »
To delete related data when a users account is deleted then you'll need to modify

Admin > processors > member_delete_now.php
 Tools > cron > jobs > 120 > 1delete_members.php

I'll be playing about with etano tonight as I need to check something with my winks mod  so ill  look into the coding for this one.