Welcome Guest, Not a member yet? Register   Sign In
Adding standalone blog
#1

Hi guys, I have this site built with CI.
Standard folder structure. css, img, js folders outside the application folder.
I'm replacing one of the page with a standalone simple blog (http://simpleblogphp.com/).
The folder contains hundreds of files. Right now this folder sits outside the application folder, next to the css and img folders.
I created a blog view and controller. Now when I navigate to the blog page I get errors.
To make this blog display within my site and based on the blog's documentation I'm adding this in my blog view:
PHP Code:
<?php include(base_url()."/blogger/blog.php"); ?>

Resulting in:

Code:
<h4>A PHP Error was encountered</h4>
<p>Severity: Warning</p>
<p>Message:  include() [<a href='function.include'>function.include</a>]: http:// wrapper is disabled in the server configuration by allow_url_include=0</p>
<p>Filename: views/blog.php</p>
<p>Line Number: 3</p>
</div>
<div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;">
<h4>A PHP Error was encountered</h4>
<p>Severity: Warning</p>
<p>Message:  include(http://dev.mysite.com/20150607-Adding-blog/blogger/blog.php) [<a href='function.include'>function.include</a>]: failed to open stream: no suitable wrapper could be found</p>
<p>Filename: views/blog.php</p>
<p>Line Number: 3</p>
</div>
<div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;">
<h4>A PHP Error was encountered</h4>
<p>Severity: Warning</p>
<p>Message:  include() [<a href='function.include'>function.include</a>]: Failed opening 'http://dev.mysite.com/20150607-Adding-blog/blogger/blog.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php')</p>
<p>Filename: views/blog.php</p>
<p>Line Number: 3</p>

Where else can I put that blog folder so it would display correctly?

Thank you in advance.
Reply
#2

(06-07-2015, 05:04 PM)keld Wrote: Hi guys, I have this site built with CI.
Standard folder structure. css, img, js folders outside the application folder.
I'm replacing one of the page with a standalone simple blog (http://simpleblogphp.com/).
The folder contains hundreds of files. Right now this folder sits outside the application folder, next to the css and img folders.
I created a blog view and controller. Now when I navigate to the blog page I get errors.
To make this blog display within my site and based on the blog's documentation I'm adding this in my blog view:


PHP Code:
<?php include(base_url()."/blogger/blog.php"); ?>

Resulting in:



Code:
<h4>A PHP Error was encountered</h4>
<p>Severity: Warning</p>
<p>Message:  include() [<a href='function.include'>function.include</a>]: http:// wrapper is disabled in the server configuration by allow_url_include=0</p>
<p>Filename: views/blog.php</p>
<p>Line Number: 3</p>
</div>
<div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;">
<h4>A PHP Error was encountered</h4>
<p>Severity: Warning</p>
<p>Message:  include(http://dev.mysite.com/20150607-Adding-blog/blogger/blog.php) [<a href='function.include'>function.include</a>]: failed to open stream: no suitable wrapper could be found</p>
<p>Filename: views/blog.php</p>
<p>Line Number: 3</p>
</div>
<div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;">
<h4>A PHP Error was encountered</h4>
<p>Severity: Warning</p>
<p>Message:  include() [<a href='function.include'>function.include</a>]: Failed opening 'http://dev.mysite.com/20150607-Adding-blog/blogger/blog.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php')</p>
<p>Filename: views/blog.php</p>
<p>Line Number: 3</p>

Where else can I put that blog folder so it would display correctly?

Thank you in advance.

base_url() will get you an url. your PHP config prevents you from including files from an url. you should keep it that way in order to prevent RFI attacks. if you really need to include() something on CI, you should use CI constants. FCPATH instead of base_url() should get you what you want. but you might want to use a redirect instead.
Reply
#3

Thanks, using
PHP Code:
<?php include(FCPATH."/blogger/blog.php"); ?>
worked but now I have another problem.
The blog config file contains this
PHP Code:
if ($installed!='yes') { 
 
$connBl mysqli_connect($CONFIG["hostname"], $CONFIG["mysql_user"], $CONFIG["mysql_password"], $CONFIG["mysql_database"]);
 if (
mysqli_connect_errno()) {
 die(
'MySQL connection error: .'.mysqli_connect_error());
 }
 
mysqli_set_charset($connBl"utf8");
}

// function that replace SELECT, INSERT, UPDATE and DELETE sql statements
if(!function_exists('sql_result')){ 
 function 
sql_result($sql) {
 global 
$connBl;
 
       echo "connBL = ".$connBl;die();
 
$sql_result mysqli_query ($connBl$sql) or die ('Could not execute MySQL query: '.$sql.' . Error: '.mysqli_error($connBl));
 return 
$sql_result;
 }

and in the sql_result function, somehow global $connBl is empty so I get an error fetching the results from the database but there's no error connecting to the DB, mysqli_connect_error() returns no error.
Now what's interesting is that I don't get that error and the blog displays fine if I access to it directly from the URL (mysite.com/blog/blog.php) but inserting it into a view makes the global variable not working. Is that a CI thing?
Reply
#4

(This post was last modified: 06-11-2015, 12:10 PM by mwhitney.)

That script is apparently intended to operate as a stand-alone blog. While a CI view is capable of executing a great deal of PHP code, it is very likely that the script will have a lot of issues trying to co-exist with CI since it was never intended to work alongside CI.

You could try removing the code you've quoted and creating a helper which defines the sql_result() function to call $this->db->query() and return the query result, but you'll really have to pay attention to how it uses the result to make sure what you're returning will work with the script.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB