opendir(C:\php5\pear\Image\Barcode) [function.opendir]: fail

Problems with the Windows version of XAMPP, questions, comments, and anything related.

opendir(C:\php5\pear\Image\Barcode) [function.opendir]: fail

Postby gadjodilo » 14. September 2005 07:25

Hi,

I just installed the image-barcode Package, but now I have a few
problems using it.

When I run the following code (http://localhost/test.php):

<?php
require_once("Image/Barcode.php");
$bc = new Image_Barcode;
$bc->draw($_GET['bctext'], "Code39", "png");
?>

I get the following error in my browser:

Warning: opendir(C:\php5\pear\Image\Barcode) [function.opendir]: failed
to open dir: Invalid argument in C:\xampp\php\pear\Image\Barcode.php on
line 66

Does anyone perhaps know a solution? :lol:

thank you in advance.

Grt,

Kabbi

(Does it have something to do with the: "C:\php5\pear\Image\Barcode" path? ... cause it doesn't exist. It should be "C:\xampp\php\pear\Image\Barcode" I Guess.... isn't it? But does anyone know where I can change / fix this?)


Code: Select all
 $barcodepath = PEAR_INSTALL_DIR . DIRECTORY_SEPARATOR . "Image" . DIRECTORY_SEPARATOR . "Barcode";
        $supportedtypes = array();
        if ( $incdir = opendir($barcodepath) ) {
            while ( false != ( $avaiabletype = readdir($incdir) ) ) {
                if ( strstr($avaiabletype, ".php") ) {
                    $supportedtypes[] = $avaiabletype;
                }
            }
            closedir($incdir);
        }

        if ( in_array($type . ".php", $supportedtypes) ) {
            include_once("Image/Barcode/${type}.php");
        } else {
            return PEAR::raiseError("$type barcode is not supported");
        }

        $classname = "Image_Barcode_${type}";

        if (!class_exists($classname)) {
            return PEAR::raiseError("Unable to include the Image/Barcode/${type}.php file");
        }

        if (!in_array('draw',get_class_methods($classname))) {
            return PEAR::raiseError("Unable to find create method in '$classname' class");
        }

        @$obj =& new $classname;

        $obj->draw($text, $imgtype);
    }

}

?>
gadjodilo
 
Posts: 14
Joined: 13. September 2005 12:32
Location: Groningen, Netherlands

Postby gadjodilo » 16. September 2005 06:53

When I open test.php in my browser I get the following error:

Warning: opendir(C:\php5\pear\Image\Barcode) [function.opendir]: failed to open dir: Invalid argument in C:\xampp\php\pear\Image\Barcode.php on line 66



This is the code of Barcode.php:

Code:
Code: Select all

require_once("PEAR.php");

class Image_Barcode extends PEAR
{

    function draw($text, $type = 'Code39', $imgtype = 'png') {

$barcodepath = PEAR_INSTALL_DIR . DIRECTORY_SEPARATOR . "Image" . DIRECTORY_SEPARATOR . "Barcode";
        $supportedtypes = array();
        if ( $incdir = opendir($barcodepath) ) {          /** <-- line 66*/
            while ( false != ( $avaiabletype = readdir($incdir) ) ) {
                if ( strstr($avaiabletype, ".php") ) {
                    $supportedtypes[] = $avaiabletype;
                }
            }
            closedir($incdir);
        }

        if ( in_array($type . ".php", $supportedtypes) ) {
            include_once("Image/Barcode/${type}.php");
        } else {
            return PEAR::raiseError("$type barcode is not supported");
        }

        $classname = "Image_Barcode_${type}";

        if (!class_exists($classname)) {
            return PEAR::raiseError("Unable to include the Image/Barcode/${type}.php file");
        }

        if (!in_array('draw',get_class_methods($classname))) {
            return PEAR::raiseError("Unable to find create method in '$classname' class");
        }

        @$obj =& new $classname;

        $obj->draw($text, $imgtype);
    }

}

?>


The test.php code:

Code:
Code: Select all
<?php
require_once("Image/Barcode.php");
$bc = new Image_Barcode;
$bc->draw($_GET['bctext'], "Code39", "png");
?>
 



The paths in my comp:

C:\xampp\php\pear\pear.php

C:\xampp\php\pear\Image\Barcode.php

C:\xampp\htdocs\test.php


I don't know if it's relevant but here is the pear.bat script:

pear.bat:
Code: Select all
REM PHP version 5
REM ----------------------------------------------------------------------
REM Copyright (c) 1997-2004 The PHP Group
REM ----------------------------------------------------------------------
REM This source file is subject to version 3.0 of the PHP license,
REM that is bundled with this package in the file LICENSE, and is
REM available at through the world-wide-web at
REM http://www.php.net/license/3_0.txt.
REM If you did not receive a copy of the PHP license and are unable to
REM obtain it through the world-wide-web, please send a note to
REM license@php.net so we can mail you a copy immediately.
REM ----------------------------------------------------------------------
REM Authors: Alexander Merz (alexmerz@php.net)
REM ----------------------------------------------------------------------
REM
REM Last updated 3/13/2004 ($Id$ is not replaced if the file is binary)

REM change this lines to match the paths of your system
REM -------------------

@ECHO OFF
:: Check PEAR global ENV, set them if they do not exist
IF "%PHP_PEAR_INSTALL_DIR%"=="" SET "PHP_PEAR_INSTALL_DIR=\xampp\php\pear"
IF "%PHP_PEAR_BIN_DIR%"=="" SET "PHP_PEAR_BIN_DIR=\xampp\php"
IF "%PHP_PEAR_PHP_BIN%"=="" SET "PHP_PEAR_PHP_BIN=%PHP_PEAR_BIN_DIR%\php.exe"
IF "%PHP_PEAR_SYSCONF_DIR%"=="" SET "PHP_PEAR_SYSCONF_DIR=%PHP_PEAR_BIN_DIR%"
IF "%PHP_PEAR_EXTENSION_DIR%"=="" SET "PHP_PEAR_EXTENSION_DIR=%PHP_PEAR_BIN_DIR%\ext"
IF "%PHP_PEAR_DOC_DIR%"=="" SET "PHP_PEAR_DOC_DIR=%PHP_PEAR_INSTALL_DIR%\docs"
IF "%PHP_PEAR_DATA_DIR%"=="" SET "PHP_PEAR_DATA_DIR=%PHP_PEAR_INSTALL_DIR%\data"
IF "%PHP_PEAR_TEST_DIR%"=="" SET "PHP_PEAR_TEST_DIR=%PHP_PEAR_INSTALL_DIR%\tests"
IF "%PHP_PEAR_CACHE_DIR%"=="" SET "PHP_PEAR_CACHE_DIR=\xampp\tmp"

:: Check Folders and files
IF NOT EXIST "%PHP_PEAR_INSTALL_DIR%" GOTO PEAR_INSTALL_ERROR
IF NOT EXIST "%PHP_PEAR_INSTALL_DIR%\pearcmd.php" GOTO PEAR_INSTALL_ERROR2
IF NOT EXIST "%PHP_PEAR_BIN_DIR%" GOTO PEAR_BIN_ERROR
IF NOT EXIST "%PHP_PEAR_PHP_BIN%" GOTO PEAR_PHPBIN_ERROR
attrib +r %PHP_PEAR_BIN_DIR%\pear.bat >nul 2<&1
attrib -h %PHP_PEAR_INSTALL_DIR%\.filemap >nul 2<&1
attrib -h %PHP_PEAR_INSTALL_DIR%\.lock >nul 2<&1

:: launch pearcmd
GOTO RUN
:PEAR_INSTALL_ERROR
ECHO PHP_PEAR_INSTALL_DIR is not set correctly.
ECHO Please fix it using your environment variable or modify
ECHO the default value in pear.bat
ECHO The current value is:
ECHO %PHP_PEAR_INSTALL_DIR%
GOTO END
:PEAR_INSTALL_ERROR2
ECHO PHP_PEAR_INSTALL_DIR is not set correctly.
ECHO pearcmd.php could not be found there.
ECHO Please fix it using your environment variable or modify
ECHO the default value in pear.bat
ECHO The current value is:
ECHO %PHP_PEAR_INSTALL_DIR%
GOTO END
:PEAR_BIN_ERROR
ECHO PHP_PEAR_BIN_DIR is not set correctly.
ECHO Please fix it using your environment variable or modify
ECHO the default value in pear.bat
ECHO The current value is:
ECHO %PHP_PEAR_BIN_DIR%
GOTO END
:PEAR_PHPBIN_ERROR
ECHO PHP_PEAR_PHP_BIN is not set correctly.
ECHO Please fix it using your environment variable or modify
ECHO the default value in pear.bat
ECHO The current value is:
ECHO %PHP_PEAR_PHP_BIN%
GOTO END
:RUN
"%PHP_PEAR_PHP_BIN%" -C -d output_buffering=1 -f "%PHP_PEAR_INSTALL_DIR%\pearcmd.php" -- %1 %2 %3 %4 %5 %6 %7 %8 %9
:END
attrib -r %PHP_PEAR_BIN_DIR%\pear.bat >nul 2<&1
@ECHO ON


Hopefully there is someone who can finally help me,

Thank you in advance,

Grt,
Kabbi

Groningen,
The Nethelands
gadjodilo
 
Posts: 14
Joined: 13. September 2005 12:32
Location: Groningen, Netherlands

Postby Wiedmann » 16. September 2005 09:06

Wiedmann
AF Moderator
 
Posts: 17102
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Postby gadjodilo » 16. September 2005 10:41

Hi Wiedmann,

Thank you very much, I looked at the link and this actually works, the script is now being processed!

However, instead of an barcode image I get a line of text:

‰PNG  IHDR 2ªK'PLTEÿÿÿ¥ÙŸÝIDATxœc(q-qeVÄ ‚ê@\•¸Á6IEND®B`‚

Do you perhaps also know a solution for this problem?

Grt,
Kabbi
gadjodilo
 
Posts: 14
Joined: 13. September 2005 12:32
Location: Groningen, Netherlands

Postby Wiedmann » 16. September 2005 10:50

The sample script in your first post works correct.

Maybe you have some spaces and/or newlines before this code? Or you are using utf-8 as text format?
Wiedmann
AF Moderator
 
Posts: 17102
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Postby gadjodilo » 16. September 2005 11:32

Hi,

Yes I believe I'm using utf-8 as text format. This is not good? How and where should I change this?

Grt
gadjodilo
 
Posts: 14
Joined: 13. September 2005 12:32
Location: Groningen, Netherlands

Postby gadjodilo » 16. September 2005 11:35

The barcode_img.php page which they included as an example works fine. However I'm only able to print numeric barcodes.. I set the code to code128 or Code39 It prints, but I can only read it with a scanner if it's numeric....
Has this also something to do with utf-8 ?

Grt
gadjodilo
 
Posts: 14
Joined: 13. September 2005 12:32
Location: Groningen, Netherlands

Postby gadjodilo » 16. September 2005 11:38

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<?php
require_once("Image/Barcode.php");
$bc = new Image_Barcode;
$bc->draw($_GET['bctext'], "Code39", "png");
?>
</body>
</html>
gadjodilo
 
Posts: 14
Joined: 13. September 2005 12:32
Location: Groningen, Netherlands

Postby gadjodilo » 16. September 2005 11:45

Sorry for al this posts.

If I run this code:

Code: Select all
<?php

require_once("Image/Barcode.php");

$num = isset($_REQUEST['num']) ? $_REQUEST['num'] : '122312';
$type = isset($_REQUEST['type']) ? $_REQUEST['type'] : 'code128';
$imgtype = isset($_REQUEST['imgtype']) ? $_REQUEST['imgtype'] : 'png';

Image_Barcode::draw($num, $type, $imgtype);

?>


Then I'll get an barcode image. If I print this then it prints out 3 stickers(1 of 3 2 of 3 etc..).If I print it out and set in the print range pages from 1 till 1, then the image can be scanned by a scanner. However If I change the $num into a non numeric code like B-05-1023 for instance then it is impossible to scan the barcode image....

Is it because the image size should be adjusted??

(on the sticker there is still space left!)

Grt,

Kabbi
gadjodilo
 
Posts: 14
Joined: 13. September 2005 12:32
Location: Groningen, Netherlands

Postby gadjodilo » 16. September 2005 11:51

Here I'am again :oops: .... it seems it is also possible to print and read characters like "b" "H" "F" etc... but nothing like "-" for instance... Is this correct? or can this be fixed.
Do you know?
gadjodilo
 
Posts: 14
Joined: 13. September 2005 12:32
Location: Groningen, Netherlands

Postby Wiedmann » 16. September 2005 13:28

You should read the ISO/IEC 16388 documentation.

BTW: A dash is not possible.
Wiedmann
AF Moderator
 
Posts: 17102
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 63 guests