Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2011-12-12 22:56:15

gomedia
Plugin Author
Registered: 2008-06-01
Posts: 1,303
Website

adi_globals - Global variables

Summary

adi_globals is a way of getting hold of those handy, but fiddly, backroom global variables. Something to make the txpath of your life a little smoother.

See the help supplied with the plugin, or have a look online. You can download the latest version from here.

Usage

Just specify the variable you’re interested in & adi_globals will find it & return it’s value.

For example:

<txp:adi_globals name="page" />

will return the current Page template name from $pretext.

adi_globals automatically searches through $prefs, $pretext, $thisarticle, $thispage, thissection, thisimage, $thiscomment, thiscategory, $thislink & $thisfile.

And, just for good measure, a TXP variable of the same name will be set as well.

Requirements

Simple enough to work in most versions of Textpattern.

Version history

  • 0.3
    • TXP 4.6 tag registration
  • 0.2
    • added thisimage, thissection, thiscategory (thanks bloke)
    • removed txpcfg (thanks joebaich)
    • disabled debug option if PHP is disallowed in articles
  • 0.1
    • initial release

Feedback

Comments are most welcome.

Spread the love

If you find this plugin useful and would like a warm and fuzzy feeling to go with it, please consider donating to the Textpattern development team.

Last edited by gomedia (2015-06-15 04:07:33)

Offline

#2 2011-12-12 23:02:44

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 10,240
Website GitHub

Re: adi_globals - Global variables

Another little adi corker, thanks!

Any reason why $thisimage is omitted? I’ve probably just not thought it through properly in my haste to try it out.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#3 2011-12-12 23:16:44

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,238

Re: adi_globals - Global variables

That’s a pretty cool oracle for a PHP whimp like me. If I only knew what I could ask …? Are there variable lists out there?


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#4 2011-12-12 23:18:21

gomedia
Plugin Author
Registered: 2008-06-01
Posts: 1,303
Website

Re: adi_globals - Global variables

Bloke wrote:

Another little adi corker, thanks!

My pleasure.

Any reason why $thisimage is omitted? I’ve probably just not thought it through properly in my haste to try it out.

None at all … I got the list from Kevin Potts’ book, which covered my immediate requirements, but it’s probably getting a little out of date now. I’ve just found Jeff’s list which has $thiscomment, $thiscategory & $thissection as well.

Could there be any others?

Offline

#5 2011-12-12 23:27:51

joebaich
Member
From: DC Metro Area and elsewhere
Registered: 2006-09-24
Posts: 507
Website

Re: adi_globals - Global variables

Adi,

Should I be uneasy about $pass, $db and $user being made so readily available to any of my users? All they have to do is add <txp:adi_globals name="pass" />|<txp:adi_globals name="pass" />|<txp:adi_globals name="pass" /> to an article in via the TXP admin interface and they have access to the database.

Offline

#6 2011-12-12 23:35:12

gomedia
Plugin Author
Registered: 2008-06-01
Posts: 1,303
Website

Re: adi_globals - Global variables

joebaich wrote:

Should I be uneasy about $pass, $db and $user being made so readily available to any of my users? All they have to do is add <txp:adi_globals name="pass" />|<txp:adi_globals name="pass" />|<txp:adi_globals name="pass" /> to an article in via the TXP admin interface and they have access to the database.

That’s probably a fair concern, although it’s possible at the moment using <txp:php> (if php is allowed in articles).

OK, some options:

  • disallow access to $txpcfg in article context
  • disallow access to db/user/pass in $txpcfg
  • disallow access to $txpcfg completely

Offline

#7 2011-12-12 23:46:26

joebaich
Member
From: DC Metro Area and elsewhere
Registered: 2006-09-24
Posts: 507
Website

Re: adi_globals - Global variables

Adi,

I meant <txp:adi_globals name="db" />|<txp:adi_globals name="user" />|<txp:adi_globals name="pass" /> but you got the message as usual anyway. I guess that disallowing access to $txpcfg in an article context would be in line with the ability to disallow php in articles via site preferences.

Offline

#8 2011-12-12 23:47:43

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 10,240
Website GitHub

Re: adi_globals - Global variables

gomedia wrote:

Could there be any others?

Not that I’m aware of: that pretty much nails the list.

disallow access to $txpcfg completely

Gets my vote: can’t think of any application where these values would be useful to any casual content architect / designer without PHP access. But at very least disallow in article context (unless you can find a legitimate use for the great unwashed to get their mitts on $txpcfg vars).

The possible exception is txpath I suppose, even though that does give away the server folder structure which may or may not please shared host owners (yeah yeah, some error conditions like include_once() also leak this if files are missing which makes it not the world’s best kept secret).

Last edited by Bloke (2011-12-12 23:50:10)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#9 2011-12-12 23:56:25

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,238

Re: adi_globals - Global variables

Guys, I’m not a security expert, so I need to ask you: Should we publicly post about potential vulnerabilities?

And: are there lists of variables available like as cheat sheets?

Last edited by uli (2011-12-12 23:57:52)


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#10 2011-12-13 00:37:51

gomedia
Plugin Author
Registered: 2008-06-01
Posts: 1,303
Website

Re: adi_globals - Global variables

And quickly out of the stalls – version 0.2:

  • added $thisimage, $thissection, $thiscategory (thanks bloke)
  • removed $txpcfg (thanks joebaich)
  • disabled debug option if PHP is disallowed in articles (an attempt to prevent accidental indecent exposure)

Offline

#11 2011-12-13 01:19:12

tye
Member
From: Pottsville, NSW
Registered: 2005-07-06
Posts: 858
Website

Re: adi_globals - Global variables

Cool :) Great plugin – thanks Adi

Offline

#12 2011-12-19 04:21:23

Gocom
Plugin Author
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: adi_globals - Global variables

Btw, what about when there are two matches? Two or more arrays can have same keys, especially considering that Textpattern has custom fields.

Offline

Board footer

Powered by FluxBB