• Resolved Cubeloop

    (@cubeloop)


    Hi,
    I’m a newbie with both WP and PHP and need your help.
    I’m setting up a blog which will use rendered images with the use of a php file. I have downloaded the script from here https://cube.crider.co.uk/visualcube.php which is under GNU licence (free to use)
    I have uploaded the files into /wp-content/themes/twentyeleven/vcube/
    I have the “Allow PHP in posts and pages” plugin installed and trying to run the script with

    [php debug=1]
    include ('/wp-content/themes/twentyeleven/vcube/visualcube.php?fmt=gif&size=200&view=plan&case=RURURU2RURUR2U2Ry2&arw=U1U5,U5U1,U3U7,U7U3');
    [/php]

    What am I doing wrong here?
    I get the following errors

    Warning: include(/wp-content/themes/twentyeleven/vcube/visualcube.php?fmt=gif&size=200&view=plan&case=RURURU2RURUR2U2Ry2&arw=U1U5,U5U1,U3U7,U7U3) [function.include]: failed to open stream: No such file or directory in /home/c/cubeloop/cubeloop/cubeloop.com/www/wp-content/plugins/allow-php-in-posts-and-pages/allowphp.php(50) : eval()'d code on line 2
    
    Warning: include() [function.include]: Failed opening '/wp-content/themes/twentyeleven/vcube/visualcube.php?fmt=gif&size=200&view=plan&case=RURURU2RURUR2U2Ry2&arw=U1U5,U5U1,U3U7,U7U3' for inclusion (include_path='.:/usr/local/php5/share/pear') in /home/c/cubeloop/cubeloop/cubeloop.com/www/wp-content/plugins/allow-php-in-posts-and-pages/allowphp.php(50) : eval()'d code on line 2
    
    Notice: Undefined variable: res in /home/c/cubeloop/cubeloop/cubeloop.com/www/wp-content/plugins/allow-php-in-posts-and-pages/allowphp.php on line 52

Viewing 8 replies - 1 through 8 (of 8 total)
  • First rather than changing the default theme use a child theme as your changes will be lost if The next WordPress upgrade included the theme, as the upgrade deletes the files and re-writes them.

    Once you have that sorted then You need the full path!

    get_stylesheet_directory_uri() will find the url for the theme.

    [php debug=0]
    include_once(get_stylesheet_directory_uri() .'/vcube/visualcube.php?fmt=gif&size=200&view=plan&case=RURURU2RURUR2U2Ry2&arw=U1U5,U5U1,U3U7,U7U3');
    [/php]
    Thread Starter Cubeloop

    (@cubeloop)

    Hi,
    I created a child theme in /wp-content/themes/vcube
    I created the style.css file to contain

    /*
    Theme Name:     Twenty Eleven Child
    Theme URI:      http: //example.com/
    Description:    Child theme for the Twenty Eleven theme
    Author:         Your name here
    Author URI:     http: //example.com/about/
    Template:       twentyeleven
    Version:        0.1.0
    */
    
    @import url("../twentyeleven/style.css");

    It messes with the parent style (as stated in the child theme link you gave, but I thought as long as I did’nt add anything to the child the parent should still be valid via the @import url tag. Now the logo is gone for instance…

    Anyway,
    I use the code you gave me

    [php debug=0]
    include_once(get_stylesheet_directory_uri() .'/vcube/visualcube.php?fmt=gif&size=200&view=plan&case=RURURU2RURUR2U2Ry2&arw=U1U5,U5U1,U3U7,U7U3');
    [/php]

    But I now get these errors

    Warning: include_once() [function.include-once]: URL file-access is disabled in the server configuration in /home/c/cubeloop/cubeloop/cubeloop.com/www/wp-content/plugins/allow-php-in-posts-and-pages/allowphp.php(50) : eval()'d code on line 2
    
    Warning: include_once(https://cubeloop.com/wp-content/themes/vcube/vcube/visualcube.php?fmt=gif&size=200&view=plan&case=RURURU2RURUR2U2Ry2&arw=U1U5,U5U1,U3U7,U7U3) [function.include-once]: failed to open stream: no suitable wrapper could be found in /home/c/cubeloop/cubeloop/cubeloop.com/www/wp-content/plugins/allow-php-in-posts-and-pages/allowphp.php(50) : eval()'d code on line 2
    
    Warning: include_once() [function.include]: Failed opening 'https://cubeloop.com/wp-content/themes/vcube/vcube/visualcube.php?fmt=gif&size=200&view=plan&case=RURURU2RURUR2U2Ry2&arw=U1U5,U5U1,U3U7,U7U3' for inclusion (include_path='.:/usr/local/php5/share/pear') in /home/c/cubeloop/cubeloop/cubeloop.com/www/wp-content/plugins/allow-php-in-posts-and-pages/allowphp.php(50) : eval()'d code on line 2

    It makes no sense to me

    /Dennis

    If you want to include the script then do it in the child themes functions.php and not in a page or post, includes are ok in the functions.php.

    function get_visualcube() {
       if( is_singular() ) {
          include_once(get_stylesheet_directory_uri() .'/vcube/visualcube.php?fmt=gif&size=200&view=plan&case=RURURU2RURUR2U2Ry2&arw=U1U5,U5U1,U3U7,U7U3');
       }
    }

    In the page call the function?

    [php debug=0]
    get_visualcube();
    [/php]

    HTH

    David

    Thread Starter Cubeloop

    (@cubeloop)

    Hi David,
    I’m at work and don’t have access to upload the file to the server right now. I will check it later tonight.

    BUT, I don’t think it will work since the arguments passed to the visualcube.php will change for every image I create
    For instance a 3d view of the rubiks cube with the moves RUR’ (*) applied to it will look like https://cube.crider.co.uk/visualcube.php?fmt=gif&size=200&alg=RUR’
    a top view of the cube were you have to orient the 4 corners and permute the for edges will look like https://cube.crider.co.uk/visualcube.php?fmt=gif&size=200&view=plan&case=RUR’U’R’U2RUR’UR2U2R’y2&arw=U1U5,U5U1,U3U7,U7U3

    I also think I will have problems with the single quote (‘) in the parameters above, but I think that \’ will do the trick?

    The reason is that I want the script to generate different cases for me as .png or .gif instead of spending lot of time photoshop’ing

    * It’s rubiks cube notation where R is the right face and U is the upper face. R is clockwise, R’ is counterclockwise

    Thread Starter Cubeloop

    (@cubeloop)

    Hi,
    the only thing that happens is that
    function get_visualcube() { if( is_singular() ) { include_once(get_stylesheet_directory_uri() .’/vcube/visualcube.php?fmt=gif&size=200&view=plan&case=RURURU2RURUR2U2Ry2&arw=U1U5,U5U1,U3U7,U7U3′); } }
    is output on the top of the screen

    /Dennis

    It requires database tables and a connebt for the visualcube, not sure if it is for WordPress.

    I created a test function and passed in arguments, but it is looking for a database connection in the visualcube file.

    I added the localhost database connections then got table errors, so it looks like you will need to do some more digging!

    Here is my code for functions.php

    [Code moderated as per the Forum Rules. Please use the pastebin]

    HTH

    David

    HaHa!
    After all that someone has already turned it into a wordpress plugin!

    https://www.vanderblonk.com/tools/wordpress-rubik-plugin/

    If that works, please mark this one resolved!

    HTH

    David

    Thread Starter Cubeloop

    (@cubeloop)

    Hi David,
    figured it out! ??

    I thought like this, the .php file creats an image. Then I inserted the file and parameters within the <img> tag. like
    <img src="https://www.cubeloop.com/vcube/visualcube.php?fmt=png&size=200&view=plan&bg=t&case=RUR'U'R'U2RUR'UR2U2R'y2&arw=U1U5,U5U1,U3U7,U7U3"/>

    I also moved the file outside WP and deleted the child theme. In the visualcube.php file I noticed that it calls for image caching (mysql requests), but since my site will not generate many hits (…) I modified the value $ENABLE_CACHE to false. Now it works like a charm.

    I also did try the vanderblonk plugin. It work out of the box! It has not as many options like the other one. I will have to dig deeper of which is best suited for me. There is also a third option https://software.rubikscube.info/icube/ which I have not tried yet

    Thanks for all the help and effort you have given me, truly appriciated

    /Dennis

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘include php script from file’ is closed to new replies.