Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Froist
Jun 6, 2004

haywire posted:

Client side anything is not secure. Are you saying the authentication status is stored in the client's memory? Baad.

Sorry, I might have over-complicated what I meant. It's not stored in client memory because it's not written yet :). I'm just wondering how other 'secure' sites do it, eg GMail - I can boot my PC, start a new browser session and go to GMail and it will log in without prompts. Clearly this is stored in a cookie (as a server-side session wouldn't exist at that point), I'm just wondering what the secure way of doing this is?

haywire posted:

I suppose you COULD buffer all done operations, and then when they're sent every 10 seconds or so, check that all of the operations done are legit, but it seems kind of pointless. What if someone saves something then quits, the operation would not be sent!

I was just trying to cut down on server load, it would be far easier to process each event individually! I might just go with that method anyway though, it's probably not going to be used by many people.

Adbot
ADBOT LOVES YOU

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



SFrost007 posted:

I was just trying to cut down on server load, it would be far easier to process each event individually! I might just go with that method anyway though, it's probably not going to be used by many people.

You could easily queue up the events in Javascript and send them in batches on a timer or after the queue fills. Then you'd only have to check the login status of the user once per batch. It would just take some effort to package them on the client and unpack them on the server, but both the server and client should still be able to re-use almost all of the code you already have written (assuming you have any written yet).

KracKiwi
Mar 29, 2002

:byodood: well excuse me, princess!
Could anyone point me towards the best method for posting a facebook status from a remote website using php?

DarkLotus
Sep 30, 2001

Lithium Hosting
Personal, Reseller & VPS Hosting
30-day no risk Free Trial &
90-days Money Back Guarantee!

KracKiwi posted:

Could anyone point me towards the best method for posting a facebook status from a remote website using php?
I would start here:
http://developers.facebook.com/
You'll need to register your site with them before you can do anything.

LP0 ON FIRE
Jan 25, 2006

beep boop
I can't seem to get the Daylight Savings date parameter working (capital I). It's supposed to return a 1 if it is daylight savings, and 0 if it isn't. I've tested several different dates converted from Etc/GMT+1 to EST.

For example:

php:
<?
$dateSrc ="2009-11-06 06:51:21";
$timeZone = 'Etc/GMT+1';
$dateTime = new DateTime($dateSrc, new DateTimeZone('EST')); 
$dateTime->setTimeZone(new DateTimeZone($timeZone)); 
echo $dateTime->format('n/j/y e I');

//echos "11/6/09 Etc/GMT+1 0"


$dateSrc ="2009-2-06 06:51:21";
$timeZone = 'Etc/GMT+1';
$dateTime = new DateTime($dateSrc, new DateTimeZone('EST')); 
$dateTime->setTimeZone(new DateTimeZone($timeZone)); 
echo $dateTime->format('n/j/y e I');

//echos "2/6/09 Etc/GMT+1 0"
?>
No matter what, "I" always seems to echo back "0". What am I doing wrong here?

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



GMT doesn't have daylight savings time, so it will always be 0.

LP0 ON FIRE
Jan 25, 2006

beep boop

Munkeymon posted:

GMT doesn't have daylight savings time, so it will always be 0.

Even if I establish a new timezone, EST, like in that example? The problem is that it's returning time's an hour ahead. I was thinking that I could get the value of "I" and just add that on if needed. I'm surprised that converting to EST doesn't compensate for the daylight savings in the first place.

edit: I guess another question would be, why is "e" returning Etc/GMT+1? Shouldn't it be EST now that it was converted?

LP0 ON FIRE fucked around with this message at 16:53 on Nov 6, 2009

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



awdio posted:

Even if I establish a new timezone, EST, like in that example? The problem is that it's returning time's an hour ahead. I was thinking that I could get the value of "I" and just add that on if needed. I'm surprised that converting to EST doesn't compensate for the daylight savings in the first place.

But you're converting from EST, which does have daylight savings time to an offset of GMT, which doesn't have DST.

php:
<?
$dateSrc = '2009-06-06 06:51:21';
$timeZone = 'Etc/GMT+1';
$dateTime = new DateTime($dateSrc, new DateTimeZone($timeZone)); //new date is in GMT+1
$dateTime->setTimeZone(new DateTimeZone('EST')); //convert to EST
echo $dateTime->format('n/j/y e I');
//6/6/09 America/New_York 1
//(because php's date/time library loves those stupid loving location-based 'zones')
?>

Begby
Apr 7, 2005

Light saber? Check. Black boots? Check. Codpiece? Check. He's more machine than kid now.

SFrost007 posted:

I was just trying to cut down on server load, it would be far easier to process each event individually! I might just go with that method anyway though, it's probably not going to be used by many people.

Is it truly a lot of server load though? I can't imagine that an authentication database query would add a lot of overhead.

LP0 ON FIRE
Jan 25, 2006

beep boop
Thanks for all your help, Munkeymon. It's giving me back the correct daylight savings numbers but now the time is 7 hours earlier. I'm sure I can probably figure this out.

Froist
Jun 6, 2004

Begby posted:

Is it truly a lot of server load though? I can't imagine that an authentication database query would add a lot of overhead.

Maybe not, load wise. I was just thinking that in an 'active' period, sending all the events individually would mean one user could spawn maybe 20-30 requests a minute (completely plucked out of the air figure, could be more than that). But as I say, I've just gone ahead and implemented it this way for now as there probably won't be many users at all.

Contero
Mar 28, 2004

I've pretty much never used PHP before today and I don't seem to get the point of Interfaces.

php:
<?
interface Clusterable
{
   public function distanceTo($other);
}

class Does implements Clusterable
{
   public function distanceTo($other)
   {
      return 1.0;
   }
}

class Doesnt
{
   public function distanceTo($other)
   {
      return 2.0;
   }
}

function check($thing)
{
   return $thing->distanceTo($thing);
}

$one = new Does();
$two = new Doesnt();

echo check($one);
echo check($two);
?>
Since php is dynamically typed, what's the point of creating something that doesn't serve as anything other than a type? Is it just to verify that you're not retarded and implemented a list of methods?

supster
Sep 26, 2003

I'M TOO FUCKING STUPID
TO READ A SIMPLE GRAPH

Contero posted:

I've pretty much never used PHP before today and I don't seem to get the point of Interfaces.

Since php is dynamically typed, what's the point of creating something that doesn't serve as anything other than a type? Is it just to verify that you're not retarded and implemented a list of methods?
Yes, basically. Dynamically typed and strongly typed are not mutually exclusive. You can get PHP to act that way (kinda-sorta) with something called type hinting (implemented in PHP 5.1):
php:
<?
function check(Clusterable $thing)
{
   return $thing->distanceTo($thing);
}
?>
Now you'll get a runtime error if you pass an object that doesn't implement Clusterable to check().

supster fucked around with this message at 00:05 on Nov 10, 2009

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Contero posted:

Since php is dynamically typed, what's the point of creating something that doesn't serve as anything other than a type? Is it just to verify that you're not retarded and implemented a list of methods?

I'd like to point out that you didn't actually use the interface as a type in your example and you could come up with something about as contrived in many languages.

Just off the top of my head if($something instanceof Something) is pretty easy compared to checking for the existence of each method in the interface.

Contero
Mar 28, 2004

supster posted:

Yes, basically. Dynamically typed and strongly typed are not mutually exclusive. You can get PHP to act that way (kinda-sorta) with something called type hinting (implemented in PHP 5.1):
php:
<?
function check(Clusterable $thing)
{
   return $thing->distanceTo($thing);
}
?>
Now you'll get a runtime error if you pass an object that doesn't implement Clusterable to check().

That's what I was looking for. Thanks.

Hanpan
Dec 5, 2004

In response to my previous post about __autoload.. it seems the general consensus is that having more than one class in per file is frowned upon. I am putting together a very basic framework, for my 'model' class, I have a collection of tiny classes for the different 'field' types. I like it this way, as if I want to expand on a particular field type, I can obviously do it very easily.

It seems very wasteful to have these tiny classes in separate files, and there could be a fair few of them depending on how many field types I end up using. In this situation, is housing these classes inside my model.class.php file acceptable?

Also, I am aware of libraries such as Doctrine. I just wanted to code this myself in order to keep it very simple.

Opinions very much appreciated!

Begby
Apr 7, 2005

Light saber? Check. Black boots? Check. Codpiece? Check. He's more machine than kid now.

Hanpan posted:

In response to my previous post about __autoload.. it seems the general consensus is that having more than one class in per file is frowned upon. I am putting together a very basic framework, for my 'model' class, I have a collection of tiny classes for the different 'field' types. I like it this way, as if I want to expand on a particular field type, I can obviously do it very easily.

It seems very wasteful to have these tiny classes in separate files, and there could be a fair few of them depending on how many field types I end up using. In this situation, is housing these classes inside my model.class.php file acceptable?

Also, I am aware of libraries such as Doctrine. I just wanted to code this myself in order to keep it very simple.

Opinions very much appreciated!

Don't over optimize or optimize too early. The one thing that you don't want to waste is programming time. IMO programmer time is way more valuable than CPU cycles because often it is less expensive to buy more hardware than it is to pay for more labor, and it really hardly ever comes down to that. So code for maintainability above all else where possible.

Splitting classes up into files will make your code easier to edit and maintain, and make it especially easier for others to maintain. Its pretty making GBS threads going through someone's code and having to look through a dozen files and some crazy twisted mess of file includes to find the class you need to edit.

Its also popular to sort it into a directory structure such as

LibraryName_Entity_Class_SubClass

i.e. if your model project is called Weasel then you might have a class called

Weasel_Model_Field_VarChar

This indicates that Field is part of Model, and VarChar inherits from Weasel_Model_Field. Your varchar class would then be stored in the following folder

Library/Weasel/Model/Field/VarChar.php

Then Weasel_Model_Field would be stored in

Library/Weasel/Model/Field.php - and so on and so forth.

Now your class is really easy for people to find, and really easy for your autoloader to find. Yeah, the long rear end class names are gay, but wasting time trying to find some class you wrote 6 years ago is even gayer.


Of course there are a million ways to skin a cat, the way above is not how you HAVE to do it, and I am sure there are plenty of arguments about why this method might suck, nothing is perfect in PHP.

Do whatever works best for you. Don't over think it though, and don't over optimize. After your site is getting so many hits that it makes sense to try to cut down on file includes, then go ahead and start optimizing.

LP0 ON FIRE
Jan 25, 2006

beep boop
Why does getimagesize sometimes not return both an image height and width, even if the image exists? Is there a better way to get an image width and height?

Hanpan
Dec 5, 2004

Begby posted:

Do whatever works best for you. Don't over think it though, and don't over optimize. After your site is getting so many hits that it makes sense to try to cut down on file includes, then go ahead and start optimizing.

I appreciate the response, but optimizing is what I enjoy most about coding PHP. This is more of a hobby project more than anything, so I want to make sure I am doing things in the best possible ways so I know how things should be done.

spiritual bypass
Feb 19, 2008

Grimey Drawer

Hanpan posted:

I appreciate the response, but optimizing is what I enjoy most about coding PHP. This is more of a hobby project more than anything, so I want to make sure I am doing things in the best possible ways so I know how things should be done.

The way things should be done
  1. Plan what you want the computer to do
  2. Make a flowchart of it (or anything with a rigid structure)
  3. Transform that into code
  4. Make note of all the bugs
  5. Fix all the bugs
  6. Make it faster (but only if it's too slow)
Seriously, don't worry about speed until it's too slow. For most applications on modern desktops and servers, it's never even an issue.

Begby
Apr 7, 2005

Light saber? Check. Black boots? Check. Codpiece? Check. He's more machine than kid now.

Hanpan posted:

I appreciate the response, but optimizing is what I enjoy most about coding PHP. This is more of a hobby project more than anything, so I want to make sure I am doing things in the best possible ways so I know how things should be done.

Well the best possible way is to get it done, make it maintainable, then worry about speed only when its an issue as rt4 indicated in his post.

So there, now you have your answer.

KuruMonkey
Jul 23, 2004
As Begby said; optimising is more than just "make faster".

You can optimise for speed, for memory footprint, or for rapid development.

The normal mantra I go by is;

Write a specification. (if you are going to "optimise" then the spec should include timing for operations)

Design the interface

Make something with the right interface. (make anything; but the right shape!)
(at this point you can make a test suites and watch it fail all the tests!)

do
{
Make it work!
Run test suite
}
while(failed_tests > 0)

(don't forget to test that it fails in the way you expect when you feed it poo poo instead of input!)

If your spec included timings and you can't meet them:
Make it fast enough. (optimise!!!)

Walk away.

(writing maintainable code is something you should be doing at all stages of the process, its not something you go back and add at the end - mainly as your optimisation will usually involve some compromise of style - but also because you...won't go back and make it maintainable)

yatagan
Aug 31, 2009

by Ozma
Test driven development is a great way to develop things if you don't care when they get done, if you know the program code is going to be updated very frequently, or if you're not really sure what you're coding and want to take a step back and analyze the program via tests. In most cases I've run into, programs are needed ASAP and the code will never be seriously looked at again once the initial bugs are worked out.

yatagan fucked around with this message at 14:30 on Nov 12, 2009

er0k
Nov 21, 2002

i like ham.

awdio posted:

Why does getimagesize sometimes not return both an image height and width, even if the image exists? Is there a better way to get an image width and height?

getimagesize() downloads the entire image, so if it's remote and huge, it might be timing out before it finishes. check the man page on php.net, there are a bunch of functions there you can use to get height and width from the image header using curl, fread, etc

Gyshall
Feb 24, 2009

Had a couple of drinks.
Saw a couple of things.
I'm slowly learning some PHP right now, and I'm working on a SimpleMachines forum. I've got a custom template and what I'm trying to do is add a div element that pops up when you hover over top of a username. When I say I'm slowly learning PHP, I mean it - I can do some basic stuff but I don't know how to exactly approach this problem.

There are two main parts of the SMF template I'm customizing. The first, shows the Username on posts:

php:
<?
        // Show information about the poster of this message.
        echo '
                <div class="floatleft poster">
                    <h4 class="username">', $message['member']['link'] , ($message['member']['id'] == $context['topic_starter_id']) ? '<img src="'.$settings['images_url'].'/topic_starter.gif" height="16" width="16" alt="'.$txt['TopicStarter_txt'].'" title="'.$txt['TopicStarter_txt'].'" style="vertical-align:bottom; padding-left:5px;" />' : '' , '</h4>
                    <ul class="smalltext" id="msg_', $message['id'], '_extra_info">';
?>
and the second shows contact and profile icons (Steam, AIM, etc.) on the post as well. The problem is that these look really ugly and can tend to crowd up the posting information rather quickly.

php:
<?
            // This shows the popular messaging icons.
            if ($message['member']['can_view_profile'])
                echo '<div class="hambuttonwrapper"><a class="buttontooltip" href="#"><span class="hambutton"></span><span class="buttontooltip">
                        <li class="margintop">
                            <ul class="nolist">
                                ', !isset($context['disabled_fields']['xfire']) && !empty($message['member']['xfire']['link']) ? '<li>' . $message['member']['xfire']['link'] . '</li>' : '', '

                                ', !isset($context['disabled_fields']['xfire']) && !empty($message['member']['steam']['link']) ? '<li>' . $message['member']['steam']['link'] . '</li>' : '', '

                                ', !isset($context['disabled_fields']['gamertag']) && !empty($message['member']['gamertag']['link']) ? '<li>' . $message['member']['gamertag']['link'] . '</li>' : '', '

                                ', !isset($context['disabled_fields']['psn']) && !empty($message['member']['psn']['link']) ? '<li>' . $message['member']['psn']['link'] . '</li>' : '', '

                                ', !isset($context['disabled_fields']['lastfm']) && !empty($message['member']['lastfm']['link']) ? '<li>' . $message['member']['lastfm']['link'] . '</li>' : '', '
                                ', !isset($context['disabled_fields']['fah']) && !empty($message['member']['fah']['link']) ? '<li>' . $message['member']['fah']['link'] . '</li>' : '', '
                                ', !isset($context['disabled_fields']['icq']) && !empty($message['member']['icq']['link']) ? '<li>' . $message['member']['icq']['link'] . '</li>' : '', '
                                ', !isset($context['disabled_fields']['msn']) && !empty($message['member']['msn']['link']) ? '<li>' . $message['member']['msn']['link'] . '</li>' : '', '
                                ', !isset($context['disabled_fields']['aim']) && !empty($message['member']['aim']['link']) ? '<li>' . $message['member']['aim']['link'] . '</li>' : '', '
                                ', !isset($context['disabled_fields']['yim']) && !empty($message['member']['yim']['link']) ? '<li>' . $message['member']['yim']['link'] . '</li>' : '', '
                            </ul>
                        </li>';
?>
Right now, I'm using this bit of CSS to hide the div containing all the parsed buttons (above) until moused over, but I'd like to display it in the username link (the first PHP snippet I posted) instead.

code:
.hambutton {
	display:block;
   	background: url(images/custom/hamcircle.png) no-repeat;
	background-position: 0 0;
	text-decoration: none;
	height: 30px;
	width: 30px;
	cursor: default;
}

.hambutton:hover {
	display:block;
   	background: url(images/custom/hamcircle.png) no-repeat;
	background-position: 0 -80px;
	text-decoration: none;
	height: 30px;
	width: 30px;
	cursor: default;
}

.hambuttonwrapper {
	text-align: center;
	padding-left: 75px;
}
My question is this - how would I go about getting the second PHP snippet somewhere between the <h4 class=username> and </h4> parts in the first snippet? The CSS and everything I will take care of later, I just don't know enough to get the second into the first and still parse correctly, and I've been banging my head against this for a couple of days now, so I thought I'd ask, or at least if someone could point me in the right direction.

Gyshall fucked around with this message at 23:16 on Nov 16, 2009

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe
I don't know if I've understood what you want correctly, but can't you just assign the messaging stuff to a variable and echo it along with the other stuff in the first bit of code? Like the following:

NB. The following is a total mess because I'm neither familiar nor happy with two stylistic choices that the authors of the original code seem to use extensively: 1) the use of "echo x_1, x_2, x_3, ..., x_n" instead of "echo x_1; echo x_2; echo x_3; ... echo x_n;" and 2) the use of "x ? y : z" instead of "if ( x ) { y; } else { z; }". I've butchered it into a style I'm more comfortable with, without much attention to niceties in the formatting. If I was concerned with elegance I wouldn't substitute in what I've written here, but it may meet your needs. Anyway, I've typed the poo poo now, so I may as well post it.

php:
<?
            // This shows the popular messaging icons.
            if ($message['member']['can_view_profile']) {
                $MyVariable = '<div class="hambuttonwrapper"><a class="buttontooltip" href="#"><span class="hambutton"></span><span class="buttontooltip">
                        <li class="margintop">
                            <ul class="nolist">
                                ';
if ( !isset($context['disabled_fields']['xfire']) && !empty($message['member']['xfire']['link']) ) { $MyVariable .= '<li>' . $message['member']['xfire']['link'] . '</li>'; }
$MyVariable .= '

                                ';
if ( !isset($context['disabled_fields']['xfire']) && !empty($message['member']['steam']['link']) ) { $MyVariable .= '<li>' . $message['member']['steam']['link'] . '</li>'; }
$MyVariable .= '

                                ';
if ( !isset($context['disabled_fields']['gamertag']) && !empty($message['member']['gamertag']['link']) ) { $MyVariable .= '<li>' . $message['member']['gamertag']['link'] . '</li>'; }
$MyVariable .= '

                                ';
if ( !isset($context['disabled_fields']['psn']) && !empty($message['member']['psn']['link']) ) { $MyVariable .= '<li>' . $message['member']['psn']['link'] . '</li>'; }
$MyVariable .= '

                                ';
if ( !isset($context['disabled_fields']['lastfm']) && !empty($message['member']['lastfm']['link']) ) { $MyVariable .= '<li>' . $message['member']['lastfm']['link'] . '</li>'; }
$MyVariable .= '
                                ';
if ( !isset($context['disabled_fields']['fah']) && !empty($message['member']['fah']['link']) ) { $MyVariable .= '<li>' . $message['member']['fah']['link'] . '</li>'; }
$MyVariable .= '
                                ';
if ( !isset($context['disabled_fields']['icq']) && !empty($message['member']['icq']['link']) ) { $MyVariable .= '<li>' . $message['member']['icq']['link'] . '</li>'; }
$MyVariable .= '
                                ';
if ( !isset($context['disabled_fields']['msn']) && !empty($message['member']['msn']['link']) ) { $MyVariable .= '<li>' . $message['member']['msn']['link'] . '</li>'; }
$MyVariable .= '
                                ';
if ( !isset($context['disabled_fields']['aim']) && !empty($message['member']['aim']['link']) ) { $MyVariable .= '<li>' . $message['member']['aim']['link'] . '</li>'; }
$MyVariable .= '
                                ';
if ( !isset($context['disabled_fields']['yim']) && !empty($message['member']['yim']['link']) ) { $MyVariable .= '<li>' . $message['member']['yim']['link'] . '</li>'; }
$MyVariable .= '
                            </ul>
                        </li>';
}
?>
php:
<?
        // Show information about the poster of this message.
        echo '
                <div class="floatleft poster">
                    <h4 class="username">', $message['member']['link'] , ($message['member']['id'] == $context['topic_starter_id']) ? '<img src="'.$settings['images_url'].'/topic_starter.gif" height="16" width="16" alt="'.$txt['TopicStarter_txt'].'" title="'.$txt['TopicStarter_txt'].'" style="vertical-align:bottom; padding-left:5px;" />' : '' , $MyVariable , '</h4>
                    <ul class="smalltext" id="msg_', $message['id'], '_extra_info">';
?>

Gyshall
Feb 24, 2009

Had a couple of drinks.
Saw a couple of things.
That is exactly what I needed. Thanks!

e: One more question. I'm trying to get this PHP within the same span, but it looks like it follows different rules than the first code I posted (checks to see if the user is logged in or if he has permissions to view a profile or not, as well as checking if they filled in the fields or not). These buttons show up in the same area the first couple do, but again, because of the other variables they call it won't parse correctly.

Thanks again, I'm really oblivious to this poo poo right now.

php:
<?
            // Show the profile, website, email address, and personal message buttons.
            if ($settings['show_profile_buttons'])
            {
                echo '
                        <li class="margintop">
                            <ul class="nolist">';
                // Don't show the profile button if you're not allowed to view the profile.
                if ($message['member']['can_view_profile'])
                    echo '
                                <li><a href="', $message['member']['href'], '">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/icons/profile_sm.gif" alt="' . $txt['view_profile'] . '" title="' . $txt['view_profile'] . '" border="0" />' : $txt['view_profile']), '</a></li>';

                // Don't show an icon if they haven't specified a website.
                if ($message['member']['website']['url'] != '' && !isset($context['disabled_fields']['website']))
                    echo '
                                <li><a href="', $message['member']['website']['url'], '" title="' . $message['member']['website']['title'] . '" target="_blank" class="new_win">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/www_sm.gif" alt="' . $txt['www'] . '" border="0" />' : $txt['www']), '</a></li>';

                // Don't show the email address if they want it hidden.
                if (in_array($message['member']['show_email'], array('yes', 'yes_permission_override', 'no_through_forum')))
                    echo '
                                <li><a href="', $scripturl, '?action=emailuser;sa=email;msg=', $message['id'], '" rel="nofollow">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/email_sm.gif" alt="' . $txt['email'] . '" title="' . $txt['email'] . '" />' : $txt['email']), '</a></li>';

                // Since we know this person isn't a guest, you *can* message them.
                if ($context['can_send_pm'])
                    echo '
                                <li><a href="', $scripturl, '?action=pm;sa=send;u=', $message['member']['id'], '" title="', $message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline'], '">', $settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/im_' . ($message['member']['online']['is_online'] ? 'on' : 'off') . '.gif" alt="' . ($message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline']) . '" border="0" />' : ($message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline']), '</a></li>';

                echo '
                            </ul>
                        </li>';
            }
?>

Gyshall fucked around with this message at 02:44 on Nov 17, 2009

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe
It occurred to me that I slipped up - at the end of that first block of code I modified, instead of just a closing brace } it should say
code:
} else { $MyVariable = ''; }
Otherwise you might end up with, say, one user's IM details being added to every subsequent post until you get to another user for whom the if condition evaluates to true.

Gyshall posted:

That is exactly what I needed. Thanks!

e: One more question. I'm trying to get this PHP within the same span, but it looks like it follows different rules than the first code I posted (checks to see if the user is logged in or if he has permissions to view a profile or not, as well as checking if they filled in the fields or not). These buttons show up in the same area the first couple do, but again, because of the other variables they call it won't parse correctly.

Thanks again, I'm really oblivious to this poo poo right now.

I don't really know what you mean. You want that stuff to also appear within the <h4> block where we added $MyVariable?

Gyshall
Feb 24, 2009

Had a couple of drinks.
Saw a couple of things.

Hammerite posted:

I don't really know what you mean. You want that stuff to also appear within the <h4> block where we added $MyVariable?

Yeah. I'm gathering that tinkering with SMF isn't the best spot to start with learning PHP as I go, eh?

e: To elaborate, the other stuff (// Show the profile, website, email address, and personal message button) ideally should show up with other buttons in the H4 span part, so yeah.

Gyshall fucked around with this message at 21:44 on Nov 17, 2009

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

Gyshall posted:

Yeah. I'm gathering that tinkering with SMF isn't the best spot to start with learning PHP as I go, eh?

e: To elaborate, the other stuff (// Show the profile, website, email address, and personal message button) ideally should show up with other buttons in the H4 span part, so yeah.

OK. Let the block of code you posted in your second post - the one starting if ($settings['show_profile_buttons'])
- be B (for ease of reference). Modify the <h4> block so that instead of reading as follows
code:
echo '
                <div class="floatleft poster">
                    <h4 class="username">', SOME STUFF, $MyVariable , '</h4>
                    <ul class="smalltext" id="msg_', $message['id'], '_extra_info">';
it reads
code:
echo '
                <div class="floatleft poster">
                    <h4 class="username">', SOME STUFF, $MyVariable;

B

echo '</h4>
                    <ul class="smalltext" id="msg_', $message['id'], '_extra_info">';

Gyshall
Feb 24, 2009

Had a couple of drinks.
Saw a couple of things.
Thanks. I owe you a beer!

Xarthor
Nov 11, 2003

Need Ink or Toner for
Your Printer?

Check out my
Thread in SA-Mart!



Lipstick Apathy
Hopefully this doesn't need it's own thread.

Here's my situation: I just started a website using Word Press (http://www.intensivepurposes.net). At the top of the page you'll notice I have a text banner. I'd like to change that into a .jpg graphic banner, but I can't seem to figure out how to do it.

Everything on the right side of the page (from the Twitter brid down) is controlled by sidebar.php.

There is a topbanner.php, but all it contains is

code:
<?php if(get_theme_option('topbanner') != '') {
	?>
	<div style="text-align: center; padding: 10px;">
		<?php echo(get_theme_option('topbanner')); ?>
	</div>
<?php } ?>
I'm trying to figure out:
1) What the dimensions of a graphic banner would be (to me it looks around 600x200)
2) Where I would insert the <img src=> HTML.

If it matters, I'm using the Modern Style Theme, which you can view/download at http://flexithemes.com

Thanks in advance!

Xarthor fucked around with this message at 19:10 on Nov 18, 2009

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

Xarthor posted:

Hopefully this doesn't need it's own thread.

Here's my situation: I just started a website using Word Press (http://www.intensivepurposes.net). At the top of the page you'll notice I have a text banner. I'd like to change that into a .jpg graphic banner, but I can't seem to figure out how to do it.

Everything on the right side of the page (from the Twitter brid down) is controlled by sidebar.php.

There is a topbanner.php, but all it contains is

code:
<?php if(get_theme_option('topbanner') != '') {
	?>
	<div style="text-align: center; padding: 10px;">
		<?php echo(get_theme_option('topbanner')); ?>
	</div>
<?php } ?>
I'm trying to figure out:
1) What the dimensions of a graphic banner would be (to me it looks around 600x200)
2) Where I would insert the <img src=> HTML.

If it matters, I'm using the Modern Style Theme, which you can view/download at http://flexithemes.com

Thanks in advance!

The fine folks in the Wordpress Thread could probably help you out better than us slobs.

Xarthor
Nov 11, 2003

Need Ink or Toner for
Your Printer?

Check out my
Thread in SA-Mart!



Lipstick Apathy

Lumpy posted:

The fine folks in the Wordpress Thread could probably help you out better than us slobs.

Woops! :suicide: Totally missed that. Thanks.

Xarthor fucked around with this message at 20:13 on Nov 18, 2009

Rat Supremacy
Jul 15, 2007

The custom title is an image and/or line of text that appears below your name in the forums

Hammerite posted:

I don't know if I've understood what you want correctly, but can't you just assign the messaging stuff to a variable and echo it along with the other stuff in the first bit of code? Like the following:

NB. The following is a total mess because I'm neither familiar nor happy with two stylistic choices that the authors of the original code seem to use extensively: 1) the use of "echo x_1, x_2, x_3, ..., x_n" instead of "echo x_1; echo x_2; echo x_3; ... echo x_n;" and 2) the use of "x ? y : z" instead of "if ( x ) { y; } else { z; }". I've butchered it into a style I'm more comfortable with, without much attention to niceties in the formatting. If I was concerned with elegance I wouldn't substitute in what I've written here, but it may meet your needs. Anyway, I've typed the poo poo now, so I may as well post it.

php:
<?
            // This shows the popular messaging icons.
            if ($message['member']['can_view_profile']) {
                $MyVariable = '<div class="hambuttonwrapper"><a class="buttontooltip" href="#"><span class="hambutton"></span><span class="buttontooltip">
                        <li class="margintop">
                            <ul class="nolist">
                                ';
if ( !isset($context['disabled_fields']['xfire']) && !empty($message['member']['xfire']['link']) ) { $MyVariable .= '<li>' . $message['member']['xfire']['link'] . '</li>'; }
$MyVariable .= '

                                ';
if ( !isset($context['disabled_fields']['xfire']) && !empty($message['member']['steam']['link']) ) { $MyVariable .= '<li>' . $message['member']['steam']['link'] . '</li>'; }
$MyVariable .= '

                                ';
if ( !isset($context['disabled_fields']['gamertag']) && !empty($message['member']['gamertag']['link']) ) { $MyVariable .= '<li>' . $message['member']['gamertag']['link'] . '</li>'; }
$MyVariable .= '

                                ';
if ( !isset($context['disabled_fields']['psn']) && !empty($message['member']['psn']['link']) ) { $MyVariable .= '<li>' . $message['member']['psn']['link'] . '</li>'; }
$MyVariable .= '

                                ';
if ( !isset($context['disabled_fields']['lastfm']) && !empty($message['member']['lastfm']['link']) ) { $MyVariable .= '<li>' . $message['member']['lastfm']['link'] . '</li>'; }
$MyVariable .= '
                                ';
if ( !isset($context['disabled_fields']['fah']) && !empty($message['member']['fah']['link']) ) { $MyVariable .= '<li>' . $message['member']['fah']['link'] . '</li>'; }
$MyVariable .= '
                                ';
if ( !isset($context['disabled_fields']['icq']) && !empty($message['member']['icq']['link']) ) { $MyVariable .= '<li>' . $message['member']['icq']['link'] . '</li>'; }
$MyVariable .= '
                                ';
if ( !isset($context['disabled_fields']['msn']) && !empty($message['member']['msn']['link']) ) { $MyVariable .= '<li>' . $message['member']['msn']['link'] . '</li>'; }
$MyVariable .= '
                                ';
if ( !isset($context['disabled_fields']['aim']) && !empty($message['member']['aim']['link']) ) { $MyVariable .= '<li>' . $message['member']['aim']['link'] . '</li>'; }
$MyVariable .= '
                                ';
if ( !isset($context['disabled_fields']['yim']) && !empty($message['member']['yim']['link']) ) { $MyVariable .= '<li>' . $message['member']['yim']['link'] . '</li>'; }
$MyVariable .= '
                            </ul>
                        </li>';
}
?>
php:
<?
        // Show information about the poster of this message.
        echo '
                <div class="floatleft poster">
                    <h4 class="username">', $message['member']['link'] , ($message['member']['id'] == $context['topic_starter_id']) ? '<img src="'.$settings['images_url'].'/topic_starter.gif" height="16" width="16" alt="'.$txt['TopicStarter_txt'].'" title="'.$txt['TopicStarter_txt'].'" style="vertical-align:bottom; padding-left:5px;" />' : '' , $MyVariable , '</h4>
                    <ul class="smalltext" id="msg_', $message['id'], '_extra_info">';
?>

Whoa, that is a hell-load of redundant code.

Surely you should just have an array of the fields you want to test and then do a foreach loop?

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

haywire posted:

Whoa, that is a hell-load of redundant code.

Surely you should just have an array of the fields you want to test and then do a foreach loop?

Yeah, that would be a lot better.

Soks
Apr 1, 2006
lol internet
Anyone have any ideas for making an image scroll in the background slower than the rest of the page? I'm trying to make a neat 3D effect where instead of just having a static background and a foreground that scrolls normally, I want the foreground to scroll normally and the background to scroll slowly and in relation to the length of the page.

The idea is that the page is made up of a header, 3 columns, and a footer. The left column is navigation and it looks like a tree, the right column is just a sliver of another tree, and the center column is where the content goes. It has a big 1000px by 2400x px canopy picture as it's background. This canopy picture is currently just static, with only the top 1000-1200px showing. I want this image to slowly scroll while the two left columns and the content ontop of the canopy (in semi-transparent background divs) scroll normally. By the bottom of the page, the bottom 1000-1200px would be showing and the top of it would be hidden. It would also have a minimum scroll setting so that it wouldn't scroll too fast on shorter pages.

I'll post up a diagram of what I mean when I get home. I don't even know where to start with this, I'm new to php so I don't know if it even has the capabilities to do something like this, maybe Java? I just don't know. Could someone point me in the right direction?

spiritual bypass
Feb 19, 2008

Grimey Drawer
PHP doesn't interact with the browser; people just use PHP to generate HTML.

If you want to do something to change the behavior of the page, use HTML, CSS, and JavaScript.

You'll want to head over to the JavaScript thread and ask there, but I'll say right now that I doubt it's possible outside of Flash (which is a poison to the web).

er0k
Nov 21, 2002

i like ham.

Soks posted:

:words:

this is called parallax scrolling and there are several CSS tutorials and even a jquery plugin to accomplish this

Adbot
ADBOT LOVES YOU

Soks
Apr 1, 2006
lol internet

er0k posted:

this is called parallax scrolling and there are several CSS tutorials and even a jquery plugin to accomplish this

Holy poo poo, thank you so much! My work place uses IE 6.0, so I can't see the drat effect, but there seems to be a lot of sites that implement it and several tutorials... Looking at the code, it looks very simple. Thanks, wow.

Edit: This one even works on IE 6.0, amazing. I actually know my way around Java code decently, just never used it for anything web based, so I'm pretty confident I can get the code here to do exactly what I want... with only a little help.

Soks fucked around with this message at 21:48 on Nov 23, 2009

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply