zenphoto as plugin

i've setup a basic php page that is nothing but the default setting as described in the howto:
`code`<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head><?php

define('ZENFOLDER', 'zp-core');
define('WEBPATH', 'http://mysite.com/gallery');
require_once(WEBPATH . "/" . ZENFOLDER . "/template-functions.php");

$randomImage = getRandomImages();
$randomImageURL = getURL($randomImage);
echo "<img src='".
$randomImage->getSizedImage(getOption('image_size')) .
"' alt=\"random image\"\n" . $randomImage->getTitle() .
'" />
';

?>
<body>
</body>
</html>
`code`

but i'm getting this error:

Fatal error: Call to undefined function: getrandomimages() in /xxxxx/index.php on line 12

any ideas?

i'm not trying to use it as a plugin for any CMS type systems.. just straight PHP pages i've already got setup on my site.

Comments

  • The define of WEBPATH should be `define('WEBPATH', 'gallery');`
  • pogo Member
    I've gone thru various testing and that is one of them.. this is the error i get on that path.

    Fatal error: main() [function.require]: Failed opening required 'gallery/zp-core/template-functions.php' (include_path='.:/usr/lib/php') in /homepages/10/xxxxxx/htdocs/xxxx/test/index2.php on line 10

    i've also tried the full server path to folder, and the domain base path .. all without results.

    what does '(include_path='.:/usr/lib/php')' mean??

    yet the gallery functions perfectly from the gallery install folder.

    i'm trying to use the function on other pages in my site that are not in the zenphoto folder.
  • pogo Member
    continuing to try different paths..
    with:
    define('WEBPATH', '../gallery');

    i get:
    Warning: Cannot modify header information - headers already sent by (output started at /homepages/10/xxxxxx/htdocs/xxxx/test/index2.php:6) in /homepages/10/xxxxxx/htdocs/xxxx/gallery/zp-core/functions.php on line 1561
    Zenphoto Error
    MySQL Query ( SELECT `zp_images`.filename,`zp_images`.title, `zp_albums`.folder, `zp_images`.show, `zp_albums`.show, `zp_albums`.password FROM `zp_images` INNER JOIN `zp_albums` ON `zp_images`.albumid = `zp_albums`.id WHERE `zp_albums`.folder!="" AND `zp_albums`.show=1 AND `zp_images`.show=1 ORDER BY RAND() LIMIT 1 ) Failed. Error: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'show, `zp_albums`.show, `zp_albums`.password FROM `zp_images` I

    so far these are not working:
    define('WEBPATH', 'gallery');
    define('WEBPATH', 'http://mysite.com/gallery');
    define('WEBPATH', '../gallery');
    define('WEBPATH', '/homepages/10/xxxxxx/htdocs/xxxx/gallery/');

    thank you
  • What is the folder structure of your site. That is, what folder contains the php file where you are trying to reference the zenphoto functionality. Your WEBPATH must be a path that will get you to the zenphoto gallery folders from the folder where the code is.
  • pogo Member
    within the zp-config.php it's got the place for path overrides... i have them commented out(i've also tried with them filled in)
    .. but this is the 'folder structure' of the site:

    zenphoto folder is in http://mysite.com/gallery
    the 'SERVERPATH' to it is /homepages/13/d101687662/htdocs/mysite/gallery
    i'm trying to do a test in a folder called 'test' that sit at the root
    so that would be http://mysite.com/test
    in this folder i have the basic 'plug-in' code in an index.php file that only has the copy and pasted code for using zenphoto as a plugin (this is the 1st post of this topic)

    i've tried all of the
    define('WEBPATH', 'gallery');
    that i could think of ... as listed just above.

    i think that all of the information on it.
  • try `define('WEBPATH', '/gallery');`
  • pogo Member
    yes, i've tried '/gallery' too.

    would the .htaccess have anything to do with this?
    i've got an .htaccess for the root re-writes and another one in the zenphoto location.

    i'll try some tests with the .htaccess file disabled at the root....
  • pogo Member
    ok.. just tried a test at the root level of the site with .htaccess disabled and still got an error.

    Fatal error: main() [function.require]: Failed opening required '/gallery/zp-core/template-functions.php' (include_path='.:/usr/lib/php') in /homepages/13/d101687662/htdocs/mysite/index3.php on line 11

    this is the body of my index3.php testing file:
    -----------------------------------------------
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title></title>
    </head>
    <body><?php

    define('ZENFOLDER', 'zp-core');
    define('WEBPATH', '/gallery');
    require_once(WEBPATH . "/" . ZENFOLDER . "/template-functions.php");

    $randomImage = getRandomImages();
    $randomImageURL = getURL($randomImage);
    echo "<img src='".
    $randomImage->getSizedImage(getOption('image_size')) .
    "' alt=\"random image\"\n" . $randomImage->getTitle() .
    '" />
    ';

    ?>

    </body>
    </html>

    ---------------------------
    when using:
    define('WEBPATH', 'http://mysite.org/gallery');

    this error:
    Fatal error: Call to undefined function: getrandomimages() in /homepages/13/d101687662/htdocs/mysite/index3.php on line 13

    when using:
    define('WEBPATH', 'gallery');

    this error:
    Warning: Cannot modify header information - headers already sent by (output started at /homepages/13/d101687662/htdocs/mysite/index3.php:7) in /homepages/13/d101687662/htdocs/mysite/gallery/zp-core/functions.php on line 1561
    Zenphoto Error
    MySQL Query ( SELECT `zp_images`.filename,`zp_images`.title, `zp_albums`.folder, `zp_images`.show, `zp_albums`.show, `zp_albums`.password FROM `zp_images` INNER JOIN `zp_albums` ON `zp_images`.albumid = `zp_albums`.id WHERE `zp_albums`.folder!="" AND `zp_albums`.show=1 AND `zp_images`.show=1 ORDER BY RAND() LIMIT 1 ) Failed. Error: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'show, `zp_albums`.show, `zp_albums`.password FROM `zp_images` I

    and the same error if i place the entire server path in
    define('WEBPATH', '/homepages/13/d101687662/htdocs/mysite/gallery');
  • pogo Member
    i guess this just doesn't work on some servers. i'll try to find a work around ... i really do like zenphoto. i hope there is a fix someday.

    i appreciate trying to help out, thanks.
  • acrylian Administrator, Developer
    Did you try placing zenphoto in a subfolder of your main site (if you not already did)?
  • pogo Member
    yes, thank you..

    as shown in the above posts:
    define('WEBPATH', 'gallery');
    and
    define('WEBPATH', 'http://mysite.org/gallery');

    means that 'zenphoto' is a subfolder of the mainsite renamed to 'gallery'

    is this what you mean?
    ============================

    i would be willing to offer FTP access to the zenphoto dev team to work out this fix. i run a Managed 1&1 Dedicated Server that has given me no problems with any installs including: Joomla(and all of its components,modules,plugins), Wordpress (+plugins), phpCalendar and so on. i think it would be worthwhile for this to be solid and working trouble-free for the future of Zenphoto users. i have posted all of my code and i am a developer too - so by all means this 'zen as plugin' should be working by now if it was bug-free.
  • acrylian Administrator, Developer
    Actually that is what I meant, sorry, I didn't notice that detail being confused by the test folder you refered to.
    One thing you could try is setting path overrides at the bottom of your zp-config.php file. Some servers need that to run Zenphoto successfully.
  • You are having some kind of pathing problem on your server. I don't really have any idea why they are not working, though. Zenphoto as a plugin does work. You can see an example here: http://testalbum-2.sbillard.org/.

    This case has the calling index.php in the root folder and zenpoto install in the /zenphoto folder. Here is the PHP:

    `<?php <br />
    define('ZENFOLDER', 'zp-core');

    define('WEBPATH', 'zenphoto');

    require_once(WEBPATH . "/" . ZENFOLDER . "/template-functions.php");

    //load extensions

    $_zp_plugin_scripts = array();

    $_zp_flash_player = NULL;

    $curdir = getcwd();

    chdir(SERVERPATH . "/" . ZENFOLDER . PLUGIN_FOLDER);

    $filelist = safe_glob('*'.'php');

    chdir($curdir);

    foreach ($filelist as $extension) {

    $opt = 'zp_plugin_'.substr($extension, 0, strlen($extension)-4);

    if (getOption($opt)) {

    require_once(SERVERPATH . "/" . ZENFOLDER . PLUGIN_FOLDER . $extension);

    }

    }

    header ('Content-Type: text/html; charset=' . getOption('charset'));

    ?>





    Test Index





    <?php <br />
    $images = getImageStatistic(6, "latest");

    foreach ($images as $image) {

    echo "
    n";

    $imageURL = getURL($image);

    echo '
    $image->getTitle() . '">image
    $image->getCustomImage(null, 44, 44, null, null, null, null, true) .

    '" alt="' . $image->getTitle() . "\"/>
    n";

    echo "
    n";

    }

    printRandomImages();

    ?>



    `
  • pogo Member
    cool. i did try the zp-config paths very early on - before even writing into this forum, because i knew it was a pathing issue .. but i had no luck.

    thanks for the above example!
    i am still getting errors but i've taken out enough to be error free and display the images/titles/links.

    this is my code now (error free):
    `<?php<br />
    define('ZENFOLDER', 'zp-core');

    define('WEBPATH', 'gallery');

    require_once(WEBPATH . "/" . ZENFOLDER . "/template-functions.php");

    ?>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"<br />
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">





    TEST





    <?php<br />
    $images = getImageStatistic(6, "latest");

    echo "n"; foreach ($images as $image) {
    echo "";
    $imageURL = getURL($image);
    echo '
    $image->getTitle() . '">
    $image->getCustomImage(null, 100, 100, null, null, null, null, true) .
    '" alt="' . $image->getTitle() . ""/>n";
    echo "". $image->getTitle()."";
    }
    echo "
    ";

    ?>



    `
    =====================
    BUT - notice that i needed to remove the function
    `printRandomImages();`

    if i leave that in it gives me this error:
    `# Zenphoto Error

    MySQL Query ( SELECT `zp_images`.filename,`zp_images`.title, `zp_albums`.folder, `zp_images`.show, `zp_albums`.show, `zp_albums`.password FROM `zp_images` INNER JOIN `zp_albums` ON `zp_images`.albumid = `zp_albums`.id WHERE `zp_albums`.folder!="" AND `zp_albums`.show=1 AND `zp_images`.show=1 ORDER BY RAND() LIMIT 1 ) Failed. Error: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'show, `zp_albums`.show, `zp_albums`.password FROM `zp_images` I`

    =======================
    and i needed to modify the top pre-header php in order to be error free like so:
    `<?php<br />
    define('ZENFOLDER', 'zp-core');

    define('WEBPATH', 'gallery');

    require_once(WEBPATH . "/" . ZENFOLDER . "/template-functions.php");

    //load extensions

    $_zp_plugin_scripts = array();

    $_zp_flash_player = NULL;

    $curdir = getcwd();

    //chdir(SERVERPATH . "/" . ZENFOLDER . PLUGIN_FOLDER);

    $filelist = safe_glob('*'.'php');

    chdir($curdir);

    foreach ($filelist as $extension) {

    $opt = 'zp_plugin_'.substr($extension, 0, strlen($extension)-4);

    if (getOption($opt)) {

    require_once(SERVERPATH . "/" . ZENFOLDER . PLUGIN_FOLDER . $extension);

    }

    }

    //header ('Content-Type: text/html; charset=' . getOption('charset'));

    ?>`

    it was causing errors on the following lines:
    `//chdir(SERVERPATH . "/" . ZENFOLDER . PLUGIN_FOLDER);

    //header ('Content-Type: text/html; charset=' . getOption('charset'));`

    with this i will continue working on it and try to see why it is getting errors on the function calls like: `printRandomImages();`

    thanks again
  • The part starting at //load extesnions and ending just before the header statement is only for plugins and only if you are using the nightly build. You can probably remove that code for now. Or you can upgrade your installation to the current nightly build.
  • I do note that the query looks different in the current nightly from what is shown in your error message. Perhaps updgading to the nightlly fixes that problem.
  • pogo Member
    OK. will do.

    i am interested in the same thing as:
    http://www.zenphoto.org/support/topic.php?id=2165&replies=4#post-12797

    which is displaying the getImageStatistic on only a certain album and not the entire gallery. has that been implemented into the current nightly build?

    acrylian has stated in the topic that it would be, but there is no definite follow up that says it has been.

    + i can't seem to find 'getImageStatistic' function in the documentation. i have used FireFox to 'search' for it within every page of the online userguide and it is not showing up. where will i find its docs?
  • pogo Member
    i just upgraded to the nightly build: zenphoto-2008-05-11-trunk.tar.gz

    1. the main gallery page (index.php) shows no thumbnails - yet no errors too - after re-cache.
    2. the album page (album.php) displays fine but the link back to the (index.php) is `path to ablum +
    Warning Division by zero in +server path stuff...` and that error remains on all instances of that link on other pages.
    3. the image page (image.php) dispays fine
    4. the link to the Archive page displays the same errored link as in #2 on all pages.

    ........................
    this is in the normal gallery - not the 'zen as plugin'
    the normal gallery was working 100% fine before the upgrade to the nightly build.

    i am posting now to the bug tracker.
  • acrylian Administrator, Developer
    image statistic: Yes, that feature is already there. The doc (nightly version) is actually directly in the sidebar when you open the main doc page. It's combined as a plugin with album statistic, because of that you might have missed it: http://www.zenphoto.org/documentation/zenphoto/_plugins---image_album_statistics.php.html

    You have a really weird server...:-( I have neither any idea what that causes nor am I able to reproduce it with the latest nightly.
    Probably some files are not updated correctly. Did you try disabling mod_rewrite or may I dare to suggest a clean reinstall...?
  • pogo Member
    i will be doing a clean install and on another part/domain of the server just until this is all worked out.
    then i can give you some real URLs to look at.
  • pogo Member
    very sweet. i just did a complete install of the 51108 nightly build and everything is working perfectly so far.
    thanks so much for the help.
Sign In or Register to comment.