[TYPO3-english] Run PHP code

bernd wilke t3ng at bernd-wilke.net
Wed Nov 20 09:56:56 CET 2013


Am 19.11.13 20:23, schrieb Mike Kane:
> Greetings everyone.
>
> I'm trying to do a self-made solution to deal with expiring usergroups
> (itypo_expiring_fe_groups) with some PHP code... I made some successful
> tests in XAMPP in a "normal" database, but when i tried to apply this to
> typo3, it was a big failure, as it does nothing.
>
> Here it is my code ( used page_php_content extension to place it in one
> random page)
>
> <?php
>
> $exp_date = mysql_query("SELECT tx_itypoexpiringfegroups_groups,
> SUBSTRING(tx_itypoexpiringfegroups_groups,15,10) FROM fe_users WHERE
> uid=24702");
>
> while($row = mysql_fetch_array($exp_date))
>   {
>   echo (strftime ( '%b-%d-%Y, %H:%M', $row
> ['SUBSTRING(tx_itypoexpiringfegroups_groups,15,10)'])). "<br />";
>   $teste = mysql_query("UPDATE fe_users SET usergroup='2' WHERE
> date(from_unixtime(SUBSTRING(tx_itypoexpiringfegroups_groups,15,10))) <
> date(now())");
>   }

substring(...,15,10) ???
do you really know that your usergroup is identified with only one char?
substring is no good solution! you can't avoid a split at the splitchars

>
> ?>
>
> If by this code is not very clear what i want to do, the main goal is to
> read the date of expiration of the membership (i used SUBSTRING because
> the field has other information like this "23|1383569880|1415105880*"
> and then compare it with the date of the server....If the server date is
> more recent than the expiration date, the usergroup must be changed.
>
> Like i said before, i ran tests in Apache with a normal database and it
> worked perfectly, so maybe this is a wrong way to do what i need.
>

anyway: if you have problems with the extension itypoexpiringfegroups, 
there is another one which works in another way: timed_ugs
maybe you can use it more easier.

bernd
-- 
http://www.pi-phi.de/cheatsheet.html


More information about the TYPO3-english mailing list