Recent Topics

1 Sep 07, 2007 21:18    

My b2evolution Version: 1.10.x

Afwas wrote (in a previous thread):

May I add that you can place the stubfile in another directory on the server, so you can call the blog from there?

samredman responded:

Afwas, I have always wanted to do that... and I have seen a few threads where others talked about wanting to do it. I know that ¥åßßå tried very hard to describe ways get it working (and I know you participated in those discussions) as can be seen in this thread:

http://forums.b2evolution.net/viewtopic.php?t=11360&start=15

... but, to date, I have never seen anything that I have been able to use to make that work.

Somehow getting that path entered correctly for the:

[quote]require_once dirname(__FILE__).'/conf/_config.php';

...seems to be a mystery. Do you have any new information about how to do that?[/quote]

Afwas gave this answer:

dirname(__FILE__) points to the actual folder the stub file is in. From there it needs to find th file _config.php. So now you want: actual path -> relative direction to _config.php or in other words: actual path -> road to _config.php.

Hope this helps. If not, give me the data from your site and we will sort it out.

Good luck

samredman gave this reply:

Afwas - thanks, yes, I would like to know how to do that specifically.

I have set up a blog just to examine such things. You can view the blog at this address:

http://samredman.com/testdemo/myblog.php

I, of course, have created a "myblog.php" stub file, which resides in the blog "root." Then, as a test, I put the stubfile in this folder (directory):

http://samredman.com/blogother

(Right now, there is just an index.htm there to act as a marker).

All attempts failed, irrespective of how I tried to put it:

I tried relative references like:

[quote]require_once dirname(__FILE__).'/../testdemo/conf/_config.php'; (does not work)

I tried absolute url paths: (but error trapping shows that those are rejected as well):

Just FYI, the total internal server path to that is:

/home/siteusername/public_html/testdemo/myblog.php

So I am left with these... how do I change them?

require_once dirname(__FILE__).'/conf/_config.php';

require $inc_path.'_blog_main.inc.php';
?>

Tell me what to try. And I will give as many trials as is necessary to make it work.[/quote]

Afwas then said:

In the stub file, in the folder where you want it, try this before "require once ..." or in stead if this generates an error before the output:
PHP:
echo dirname(__FILE__);

The path should be set up from here to http://samredman.com/testdemo/...config.php or perhaps http://samredman.com/testdemo/conf/_config.php.

Good luck

2 Sep 07, 2007 21:21

I tested this:

This is in a new stub file (called myblogtest1.php) located as follows:

samredman.com/blogother/myblogtest1.php

NOTE: I am removing it each time after a test... because the error is revealing my site username (which might be bad for security).

* That's it, now let b2evolution do the rest! :)
*/
echo dirname(__FILE__) http://samredman.com/testdemo/conf/_config.php

require $inc_path.'_blog_main.inc.php';
?>

I got this error:

Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/siteusername/public_html/blogother/myblogtest1.php on line 58

3 Sep 07, 2007 21:45

I understand your security issue.

In the error, where does the URL http://samredman.com/testblog/conf/_config.php come from? Please try this:

echo dirname(__FILE__);


(this time, don't forget the trailing ; :p .
To get the debug text error free, comment out the line:

require $inc_path.'_blog_main.inc.php';

Good luck

4 Sep 07, 2007 21:49

Test 2.

Next I did this...

/**
* That's it, now let b2evolution do the rest! :)
*/
echo dirname(__FILE__) 'http://samredman.com/testdemo/conf/_config.php';

require $inc_path.'_blog_main.inc.php';
?>

I got this error message:

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in /home/samredma/public_html/blogother/myblogtest2.php on line 58

5 Sep 07, 2007 21:55

Afwas... could you give me the example code you are talking about.. .like here:

* That's it, now let b2evolution do the rest! :)
*/
what goes here...?

what goes here...?
?>

Just to remind you this is the path to my blog:

http://samredman.com/testdemo/myblog.php (that's the stub file in the blog root).

Path to my conf directory:

http://samredman/testdmo/conf

This is the path to my "other" directory:

http://samredman.com/blogother (that's where I am putting the test stub files)

6 Sep 07, 2007 21:59

/**
* That's it, now let b2evolution do the rest! :)
*/
echo dirname(__FILE__);
?>

7 Sep 07, 2007 22:13

Next, test 3:

Following is the code (at the bottom of the remote stubfile, located at:

samredman.com/blogother,

remote stub is attempting to access a blog located at

samredman.com/testdemo

my conf directory is at

Path to my conf directory:

http://samredman/testdemo/conf

* That's it, now let b2evolution do the rest! :)
*/
echo dirname(__FILE__);
?>

This is the error message:

Parse error: syntax error, unexpected '*' in /home/myusername/public_html/blogother/myblogtest4.php on line 56

8 Sep 07, 2007 22:17

It should start with the /**, see the first line in my code.

9 Sep 07, 2007 23:08

Test 4

Ok... I did this:

/**
* That's it, now let b2evolution do the rest! :)
*/
echo dirname(__FILE__);
?>

http://samredman.com/blogother/myblogtest4.php

it shows this (no error just this):

/home/siteusername/public_html/blogother

Note:

That remote stub in samredman/blogother is attempting to access a blog located at: samredman.com/testdemo

10 Sep 07, 2007 23:17

OK, this makes sense; it is not going to find ../blogs/conf/_config.php from dirname(__FILE__). Try it the direct way:

/**
* That's it, now let b2evolution do the rest! :)
*/ 
require_once ('http://www.samredman.com/testblog/conf/_config.php');

require $inc_path.'_blog_main.inc.php'; 
?>


unless the file _config.php is in the directory h^tp://www.samredman.com/testblog/blogs/conf/_config.php, then you hade to give that URL.

Good luck

11 Sep 07, 2007 23:23

New test (5).
Using this code (at the end of the stub file in samredman/blogother)::

/**
* That's it, now let b2evolution do the rest! :)
*/
require_once ('http://www.samredman.com/testdemo/conf/_config.php');

require $inc_path.'_blog_main.inc.php';
?>

I get this error message:

Warning: main(_blog_main.inc.php) [function.main]: failed to open stream: No such file or directory in /home/siteusername/public_html/blogother/myblogtest5.php on line 60

Fatal error: main() [function.require]: Failed opening required '_blog_main.inc.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/testdemo/public_html/blogother/myblogtest5.php on line 60

Note: That remote stub in samredman/blogother is attempting to access a files located at: samredman.com/testdemo/conf (yes... that's exactly where they are).

12 Sep 07, 2007 23:42

This on the other hand doesn't make sense; it should work.
Can you provide me with a working link to the index.php that I can click, so I can get into your testblog? At the moment I get 404s to all URLs where I expect to find it.

Good luck

14 Sep 08, 2007 00:07

This is what the last lines of the stub file should look like:

/**
* That's it, now let b2evolution do the rest! :)
*/ 
require_once ('http://samredman.com/testdemo/conf/_config.php');

require $inc_path.'_blog_main.inc.php'; 
?>


There's a good chance this works.

Good luck

15 Sep 08, 2007 00:13

Test 6:

last lines of the stub file (located in samredman.com/blogother):

/**
* That's it, now let b2evolution do the rest! :)
*/
require_once ('http://samredman.com/testdemo/conf/_config.php');

require $inc_path.'_blog_main.inc.php';
?>

Error message:

Warning: main(_blog_main.inc.php) [function.main]: failed to open stream: No such file or directory in /home/siteusername/public_html/blogother/myblogtest6.php on line 60

Fatal error: main() [function.require]: Failed opening required '_blog_main.inc.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/siteusername/public_html/blogother/myblogtest6.php on line 60

16 Sep 08, 2007 00:30

If you weren't cheering already, i advice you to do so. It actually found ../conf/_config.php. Now it's complaining about the other file. Let's try the same trick:

/**
* That's it, now let b2evolution do the rest! :)
*/ 
require_once ('http://samredman.com/testdemo/conf/_config.php');

require ('http://samredman.com/testdemo/inc/_blog_main.inc.php'); 
?> 


but this time I am not completely sure it does what I want, because it still needs to set the $inc_path variable for other purposes. But try it anyway.

Good luck

17 Sep 08, 2007 01:00

Test 7

Well... that's progress:

Using this code at the end of the remotely placed stub file:

/**
* That's it, now let b2evolution do the rest! :)
*/
require_once ('http://samredman.com/testdemo/conf/_config.php');

require ('http://samredman.com/testdemo/inc/_blog_main.inc.php');
?>

It says:

Please, do not access this page directly.

Take a look yourself:

http://samredman.com/blogother/myblogtest7.php

18 Sep 08, 2007 01:30

*edit*

Deleted this post, it was a mistake and will only confuse future readers.

19 Sep 08, 2007 01:51

Test 8... Same results as test 7

Placed this code at the end of the remotely placed stubfile:

/**
* That's it, now let b2evolution do the rest! :)
*/
require_once ('http://samredman.com/testdemo/conf/_config.php');

require ('http://samredman.com/testdemo/inc/_main.inc.php');
?>

It says this (just like test 7):

Please, do not access this page directly.

You can view it here:

http://samredman.com/blogother/myblogtest8.php

20 Sep 08, 2007 02:18

It's half / half what I expected, but certainly not which I hoped for. Unfortunately it doesn't say what file threw the notice (all files in the distribution can give this message).

I present to you the one and only working guide to the definitive solution to your problem.

1) Restore the stub file to it's original default:

/**
* That's it, now let b2evolution do the rest! :)
*/ 
require_once (dirname(__FILE__).'/conf/_config.php');

require $inc_path.'_blog_main.inc.php'; 
?>

place this file in h*tp://samredman.com/testdemo/ and delete it from h*tp://samredman.com/otherLocation

2) create a file called new_stub.php or whatever you want, with this in it:

<?php
require_once ('http://samredman.com/testdemo/myblog.php');
?>


and place this file anywhere on the internet.

Don't get confused by the names I just invented.

Good luck

21 Sep 08, 2007 05:52

Afwas, yes that is interesting... but, it is not a remote stub file. However, that "require_once" code of yours does, very excellently, provide a useful cloaking redirect, which will serve a lot of people's needs. The problem with cloaking (as your example does) is that, certainly it does display the remote blog with the address initially as the location where the redirect originated, but if the user does any navigation (like to another page) then that url in the browser is lost. So, you might as well have just done a simple redirect rather than cloak it (unless someone is satisfied with that initial page effect).

I can do redirects lots of ways.

1. HTML (meta header expiration, also called "meta refresh")
2. HTML (frames, also known as URL cloaking)
3. PHP (Header function)
4. Perl (Header function)
5. ASP (Header function (I guess so, I don't use ASP))
6. mod_rewrite (to redirect URLs based on a .htaccess file)

- and I just learned this:

7. PHP - The Afwas cloaking redirect method - using "require_once ":

See it here: http://samredman.com/blogother/test9.php (it cloaks, temporarily keeping the original url when showing the remote blog).

And here is Afwas' code:

<?php 
require_once ('http://samredman.com/testdemo/myblog.php'); 
?> 

I have used the following kind of header php approach in the past for other purposes (this isn't a cloak, but a pure redirect):

See it here: http://samredman.com/blogother/test10.php (doesn't cloak, just re-directs to a new url).

And here is my code:

<?php
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://samredman.com/testdemo/myblog.php");
exit();

?> 

I was hoping for something that would meet this definition from the manual:

Now if you want more flexibility, what you do is create a stub file.

A stub file is a .php file onto which the webserver can hit, at any URL you may fancy. That stub file will in turn call b2evo to do the displaying job for a particular blog, and using a particular skin, based on the parameters you set inside of the stub file.

If you want your blog to be accessed at http://www.server.com/this/is/a/fancy/path/my_blog.php, then you just put a stub file called my_blog.php in the /this/is/a/fancy/path folder.

That description seems to say you can use a stub file which will be located at a distant location which will allow you to specify the skin in that remote location. But, I am beginning to think that whoever wrote that manual description didn't know what they were talking about (unless someone can show how to do it).

Really, who needs a remote stub file anyway? My simple php header redirect is just fine for most situations.. The Afwas cloaking redirect is great for other situations, where you want to keep the original url in the browser address window (at least initially, until any navigation link is clicked).

22 Sep 08, 2007 09:51

Hey sam, what happens if you create /blogother/test.php and have :

<?php
require_once dirname(__FILE__).'/../testdemo/conf/_config.php';
echo preg_replace( '~^.+?public_html~', '', $inc_path.'_blog_main.inc.php' );
?>

¥

23 Sep 08, 2007 18:23

Test 12 -

Using this code from ¥åßßå (as a standalone php file):

<?php 
require_once dirname(__FILE__).'/../testdemo/conf/_config.php'; 
echo preg_replace( '~^.+?public_html~', '', $inc_path.'_blog_main.inc.php' ); 
?> 

Produced this, "printed" on the screen:

/testdemo/inc/_blog_main.inc.php

You can see it for yourself here:

http://samredman.com/blogother/myblogtest12.php

24 Sep 09, 2007 01:52

Hi samredman,

You can have multiple stubfiles, as long as they are in a (sub)directory from the blog. You could make several subdires in h*tp://www.samredman.com/testdemo/. In each subdir you place the same stubfile. Then you can start tweaking, making each stubfile different to your needs. From the different location, you can call the stubfile you want.
But perhaps we find a solution to your problem and then you can have a stubfile in any directory you want. The problem being your stubfile in another branch of the server tree.

I agree the text in the manual is wrong. The [url=http://forums.b2evolution.net/viewtopic.php?t=1230]original post by François[/url] is clearer. Many of the docs are still from 1.6.8 or even prehistoric 0.9.2.

What ¥åßßå asked you to do sounds promising. Still it's a clumsy way to call a blog (in each other location you need to edit the stub file to change the relative location).

I am wondering, does this work (in the stub file). Something similar works in all my testblogs:

/**
* That's it, now let b2evolution do the rest! :)
*/
require_once dirname(__FILE__).'/../testdemo/conf/_config.php';

require $inc_path.'_blog_main.inc.php';
?>

Good luck

25 Sep 09, 2007 04:18

Test 13

Afwas... that worked!

13 was the lucky number

I am amazed. Honestly, I tried that one myself (at least I thought I did)... as I mentioned in my first post on this. I must have not had it exactly as you stated it. Not only does it work... it continues to keep that address in the browser address window as I navigate. Well.. I am just floored.
:
You can see it working here

http://samredman.com/blogother/myblogtest13.php

Plus, it functions as a true stub file... I can use it to specify a unique skin:

You can see the a specific skin working here:

http://samredman.com/blogother/myblogtest14.php

All I can say is: well done, Afwas!

Now can you figure out a way to make it work outside of the same domain? Hey.. might as well ask for the impossible.

26 Sep 09, 2007 06:05

Hi samredman,

I am very glad you got things workig the way you wanted it. For your last question: It doesn't seem to work to call the _config.php directly. Therefore it will not be possible to put the stub file on another domain, but you might get away with it if it's on the same server. You still have the possibility to have multiple stub files that you can call from other places.

Good luck


Form is loading...