load php extension in windows - windows

I have a problem loading my extension in php in windows 7.
I've already installed php and IIS on my windows and when I check the phpinfo() page I find out that my extension_dir is c:/php/ext. so I copy my dll file in to that directory and also add extension=php_mylib.dll to php.ini file, then I restart the IIS and check if my extension has been loaded:
<?PHP
if (dl('php_mylib.dll')){ print ("YES")}
else{ print ("NO")}
?>
But I got "NO" every time I run this code. I appreciate any helps.

Encountered a similar problem today on a slightly different system -
Win 2008 R2 / IIS 7.5 / PHP 5.3.9 nts
I was looking to enable php_printer.dll for network printing. Haven't found a resolution that doesn't involve compiling the dll, but I did learn someone had enabled safe mode.
This information is from the manual # function.dl.php.
Information posted 7 years ago helped me out, seems appropriate for my system.
Here are the parts I found useful, from mag_2000 at front dot ru:
//make sure that we are ABLE to load libraries
if( !(bool)ini_get( "enable_dl" ) || (bool)ini_get( "safe_mode" ) ) {
die( "dh_local(): Loading extensions is not permitted.\n" );
}
//check to make sure the file exists
if( !file_exists( $extensionFile ) ) {
die( "dl_local(): File '$extensionFile' does not exist.\n" );
}
//check the file permissions
if( !is_executable( $extensionFile ) ) {
die( "dl_local(): File '$extensionFile' is not executable.\n" );
}
Hope that helps!

Related

codeigniter2 deploy on windows 10 with wamp server, memcached error fix

I am trying to run the old codigniter2 website on windows 10 with a wamp server.
But I get the following error:
A PHP Error was encountered
Severity: Error
Message: Call to a member function get() on null
Filename: C:/wamp64/www/website.test/system/libraries/Cache/drivers/Cache_memcached.php:52
full error
What should I do?
I solved my problem:
Step 1 (enable Memcache in WAMPserver):
download the Memcache package that compatible with your PHP version
and Wamp version (32 or 64 bits). I download the Thread Safe one.
extract the downloaded package then copy the php_memcache.dll into
your extensions folder of your PHP such as
C:\wamp64\bin\php\php5.6.40\ext. The php5.6.40 is your PHP folder.
open the php.ini file and search for extension=php_bz2.dll which
should be the first extension on the extensions list then copy
extension=php_memcache.dll and paste at the end of the extensions
list.
restart Wamp server
now you should see the Memcache loaded when you visit
http://localhost
If the steps above don’t work, you just open the error log file at the logs folder at the root directory and check the error there.
Step 2 (Changes in /system/libraries/Cache/drivers/Cache_memcached.php):
Using this github link, i made changes in Cache_memcached.php:
Replace this:
$this->_memcached = new Memcached();
With this:
if (class_exists('Memcached')) {
$this->_memcached = new Memcached();
}
else if (class_exists('Memcache')) {
$this->_memcached = new Memcache();
}
else {
log_message('error', 'Failed to create object for Memcached Cache; extension not loaded?');
return FALSE;
}
And replace this:
if ( ! extension_loaded('memcached'))
With this:
if ( ! extension_loaded('memcached') && ! extension_loaded('memcache'))
Then delete (if exists):
$this->_memcached->setOption(Memcached::OPT_DISTRIBUTION, Memcached::DISTRIBUTION_CONSISTENT);
$this->_memcached->setOption(Memcached::OPT_LIBKETAMA_COMPATIBLE, true);
And this (if exists):
$this->_memcached->setOption(Memcached::OPT_PREFIX_KEY, $prefix);
Step 3 (Refresh Database):
Delete and create new database
import data (if big data you can import it via wamp server mysql
console "use dbname; source c:/wamp64/www/dataname.sql")
restart wamp server

Deprecated: mysql_connect() message and Warnings occur in step 3 of the opencart configuration setup after we enter the details and hit continue

We need help trying to upload our opencart templatemonster.com template correctly on godaddy but we are not clear on how to do that.
FYI our public_html/system/database folder contains a mysqli.php file as well.
We made sure to upload the template via fullpackage (The name of the file is themeXXX(full).zip, where XXX is your theme number) to the public_html folder.
Extracted the zip files in the public_html folder.
Performed the installation using the installation manager .
At step 3 configuration we were prompted to input our database access details and made sure the database was empty. (GoDaddy told us to use the localhost)
After hitting continue:
The deprecated: mysql_connect() message and Warnings occur in step 3 of the opencart configuration setup after we enter the details and hit continue.
Where ‘store’ is the new directory name. Where ‘user’ is your server
account address. Where ‘yourdomainname.co.uk’ is the web domain of
your new website:
(DUMMY LINK FOR DEMONSTRATION PURPOSES) http://www.yourdomainname.co.uk/install/index.php?route=step_3
Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home/user /public_html/system/database/mysql.php on line 6
Lines 5-16:
public function __construct($hostname, $username, $password, $database) {
if (!$this->link = mysql_connect($hostname, $username, $password)) {
trigger_error('Error: Could not make a database link using ' . $username . '#' . $hostname);
}
if (!mysql_select_db($database, $this->link)) {
trigger_error('Error: Could not connect to database ' . $database);
}
Errors:
Warning: Cannot modify header information - headers already sent by (output started at /home/user/public_html/system/database/mysql.php:6) in /home/user/public_html/system/engine/controller.php on line 28
Warning: Cannot modify header information - headers already sent by (output started at /home/user/public_html/system/database/mysql.php:6) in /home/user/public_html/system/engine/controller.php on line 29
Lines 27-31
protected function redirect($url, $status = 302) {
header('Status: ' . $status);
header('Location: ' . str_replace(array('&', "\n", "\r"), array('&', '', ''), $url));
exit();
}
Template Features
OpenCart Compatibility: 1.5.6.x
OpenCart Engine: 1.5.6.4
(Trimmed)
Sources Available
PSD PNG PHP TPL JS
Hosting Requirements
Web Server (preferably Apache)
PHP (at least 5.2)
MySQL
Curl
Fsock
OpenCart Templates Help Center
Software Required
Adobe Photoshop CS+
For uncompressing a template ZIP package: WinZip 9+ (Windows);
Stuffit Expander 10+ (Mac)
Apache Server
PHP v. 5 or higher
MySQL 4.1.14 or later
OpenCart 1.5.6.4
Sublime Text2 or later, Notepad++ or any php-editor
A commenter stated
mysql_ calls will work on this server but are causing deprecation
notices. A quick fix would be to turn off warnings in your php.ini
file, in your error_reporting value. Or you could try turning off
display errors, set display_errors to 0.
I like the comment but could someone provide a slightly more comprehensive explanation or visual resource to this suggestion? Such as articulating a little further how to proceed? Should I download the file through GoDaddys public FTP or should I use FileZilla FTP client (does it matter), make a copy, make the proper changes then re-upload?
I like the possible solution but I am curious to know if these are the only ones.
UPDATE
I just changed display_errors = 1; to display_errors = 0;
saved the file (I edited the file withing GoDaddy's text editor)
re-input our database access details
hit continue on step 3 configuration and got the same error.
php.ini
magic_quotes_gpc = Off;
register_globals = Off;
default_charset = UTF-8;
memory_limit = 64M;
max_execution_time = 36000;
upload_max_filesize = 999M;
safe_mode = Off;
mysql.connect_timeout = 20;
session.use_only_cookies = On;
session.use_trans_sid = Off;
session.cookie_httponly = On;
session.gc_maxlifetime = 172800;
allow_url_fopen = on;
;display_errors = 0;
;error_reporting = E_ALL;
???
I have a similar experience! You don't need to enable these extensions the PHP Version needs to be update:
Sign into GoDaddy
Go to My Products under your sign in name at the top right.
Go to Web Hosting and click the Manage button.
Click manage again.
Scroll to the Software header and click "Select PHP Version"
Then change to an earlier version, in which this extension is not deprecated.
Let me know how that works for you.

Manual installation of Magento extension turns every file into a folder

I am completely baffled by this. I packaged up an extension and manually installed it on a fresh Magento instance. (Both the packaging and installing machine were running Magento 1.7). The installation went smoothly, except every single file I installed was turned into a folder, named after the file. Every single file. Has anyone run into this? Could it be a Magento bug?
I used to see this problem when I manually created a tar archive to use as a Magento Connect archive. Unfortunately, I don't have a solution, but here's what I understand about the problem.
While Magento Connect tgz packages are technically gzip compressed tar archives — the code that creates and extracts these archives in not the standard *nix tar tool. Instead, Magento implemented its own packing and unpacking tar code for Magento Connect
downloader/lib/Mage/Archive/Tar.php
Unfortunately, this packing and unpacking code hasn't been robustly tested across operating systems or against tar archives created with standard *nix tools. My problem with this code was archives created on my Mac OS system via tar wouldn't unpack correctly with Magento Connect's code on a system running linux.
Hard to track down, hard to report, hard to reproduce means hard to fix.
These directories are being created when Magento Connect unpacks the tgz file. I'm be 99% sure your directories are being created by this bit of code
#File: downloader/lib/Mage/Archive/Tar.php
if (in_array($header['type'], array("0",chr(0), ''))) {
if(!file_exists($dirname)) {
$mkdirResult = #mkdir($dirname, 0777, true);
if (false === $mkdirResult) {
throw new Mage_Exception('Failed to create directory ' . $dirname);
}
}
$this->_extractAndWriteFile($header, $currentFile);
$list[] = $currentFile;
} elseif ($header['type'] == '5') {
if(!file_exists($dirname)) {
$mkdirResult = #mkdir($currentFile, $header['mode'], true);
if (false === $mkdirResult) {
throw new Mage_Exception('Failed to create directory ' . $currentFile);
}
}
$list[] = $currentFile . DS;
These are the two locations where Magento unpacks the archives and creates a folder. For some reason, there's a certain condition on your two systems where the data is being packed, or unpacked, incorrectly in/out of the archive file. Try un-archiving the tgz file manually with a command line tool or your operating system's built in un-archive program. If weird things happen then at least you know it's the packing code that's the problem.
It's definitely a bug, and while I'd report it, the only "solution" would be to not create your archive on your local machine (which I realize is an awful solution, but Ours is not to question why and all that)
This is a bug that has been present since 1.7, due to an if comparison never evaluating to false when reading the #././LongLink header. I answered it more on this question:
https://magento.stackexchange.com/questions/5585/long-file-names-and-magento-connect-extension-packager/45187#45187
I found that issue happening when packing a Magento Extension on OS X that is linked (modman) into magento folders. Folder creation only occured on Windows systems.
Might that happen here too?
Rico
I encountered it, when for some reason my plugin file was set with suffix .gz
so it was plugin.tgz.gz
unzip it to plugin.tgz solved my issue
I think the issue is because of PHP version. I faced the same issue while installing extension on Magento 1.8.1 , but I found a fix by changing _getFormatParseHeader() function in /downloader/lib/Mage/Archive/Tar.php file.
Originally the function was :
protected static final function _getFormatParseHeader()
{
return 'a100name/a8mode/a8uid/a8gid/a12size/a12mtime/a8checksum/a1type/a100symlink/a6magic/a2version/'
. 'a32uname/a32gname/a8devmajor/a8devminor/a155prefix/a12closer';
}
I changed it to :
protected static final function _getFormatParseHeader()
{
if (version_compare(phpversion(), '5.5.0', '<') === true) {
return 'a100name/a8mode/a8uid/a8gid/a12size/a12mtime/a8checksum/a1type/a100symlink/a6magic/a2version/'
. 'a32uname/a32gname/a8devmajor/a8devminor/a155prefix/a12closer';
}
return 'Z100name/Z8mode/Z8uid/Z8gid/Z12size/Z12mtime/Z8checksum/Z1type/Z100symlink/Z6magic/Z2version/'
. 'Z32uname/Z32gname/Z8devmajor/Z8devminor/Z155prefix/Z12closer';
}
Really nasty bug.
For me it renaming my manually packed file from *.tar.gz to *.tgz solved it.
At least it worked on my ubuntu 15.04
Tested with magento 1.8
it's more likely that you choose the wrong path when adding content to your extension.
For me the bug happened when I added (non existing) files from layout/base instead from layout/base/default.

saving image from HTTP_RAW_POST_DATA does not work in MAMP

I'm using the following to upload an image from post data. it works on my server using php version: 5.2.16
When I try running the exact same script on my local server using MAMp and PHP Version 5.2.17
the file is not created.
if (isset($HTTP_RAW_POST_DATA))
{
// Get the data
$imageData=$HTTP_RAW_POST_DATA;
// Remove the headers (data:,) part.
// A real application should use them according to needs such as to check image type
$filteredData=substr($imageData, strpos($imageData, ",")+1);
// Need to decode before saving since the data we received is already base64 encoded
$unencodedData=base64_decode($filteredData);
echo "unencodedData: ".$unencodedData;
$key = microtime();
$key = md5($key);
// Save file.
$fp = fopen( '../../../uploadedImages/original/' . $key . '.jpg', 'wb' );
fwrite( $fp, $unencodedData);
fclose( $fp );
}
it looks like the post data does exist if I look at it in firebug. Any ideas why this isn't working in mamp?
Some things to try:
Check to make sure you are getting the raw data when the script is running on MAMP
Check the permissions of the directory it is trying to write to and make sure you have write access to it and apache has write access to it.
I had issues running some php modules on MAMP so I switched to using versions I installed using MacPorts. It gave me more control of extra extension I wanted to install and I got the latest versions of apache, php, and the php extensions.

Zend OSX, and a "." added to context path

I downloaded and unpacked the latest version of Zend Framework, onto OSX (10.6) (am also running webserver with XAMPP, but I added the include_path change to both XAMPP and OSX path, but this is all command line so I dont think the php compiler is using the XAMPP install)
I try to create a project and get the following: (note that i am replacing part of the path with "----" just for the purpose of privacy)
sh-3.2# zf create project
testProject
Fatal error: Uncaught exception
'Zend_Exception' with message 'File "Zend/Tool/Project/Context/Zf/./AbstractClassFile.php" does not exist or class "Zend_Tool_Project_Context_Zf_._AbstractClassFile" was not found in the file' in /Volumes/----/----/z/library/Zend/Loader.php:99 Stack trace:
0 /Volumes/----/----/z/library/Zend/Tool/Project/Context/Repository.php(88):
Zend_Loader::loadClass('Zend_Tool_Proje...')
1 /Volumes/----/----/z/library/Zend/Tool/Project/Context/Repository.php(79):
Zend_Tool_Project_Context_Repository->addContextClass('Zend_Tool_Proje...')
2 /Volumes/----/----/z/library/Zend/Tool/Project/Provider/Abstract.php(87):
Zend_Tool_Project_Context_Repository->addContextsFromDirectory('/Volumes/----/...',
'Zend_Tool_Proje...')
3 /Volumes/----/----/z/library/Zend/Tool/Framework/Provider/Repository.php(187):
Zend_Tool_Project_Provider_Abstract->initialize()
4 /Volumes/----/----/z/library/Zend/Tool/Framework/Client/Abstract.php(128):
Zend_Tool_F in
/Volumes/----/----/z/library/Zend/Loader.php
on line 99 sh-3.2#
Note the period after "Context_Zf_"
I've narrowed it down to this block of code:
File: /Volumes/----/----/z/library/Zend/Tool/Project/Provider/Abstract.php
public function initialize()
{
// initialize the ZF Contexts (only once per php request)
if (!self::$_isInitialized) {
// load all base contexts ONCE
$contextRegistry = Zend_Tool_Project_Context_Repository::getInstance();
$contextRegistry->addContextsFromDirectory(
dirname(dirname(__FILE__)) . '/Context/Zf/', 'Zend_Tool_Project_Context_Zf_'
);
$contextRegistry->addContextsFromDirectory(
dirname(dirname(__FILE__)) . '/Context/Filesystem/', 'Zend_Tool_Project_Context_Filesystem_'
);
// determine if there are project specfic providers ONCE
Specifically "dirname(dirname(FILE))" is echoing as "."
if I wrap the block with an 'if (dirname(dirname(__FILE))!=".") { … } ', then I don't get that error, but I get another:
sh-3.2# zf create project testProject
An Error Has Occurred
Context by name applicationDirectory does not exist in the registry.
Zend Framework Command Line Console
Tool v1.11.3 Details for action
"Create" and provider "Project"
Project
zf create project path name-of-profile file-of-profile
I tested on my Mac and it works fine. Have you tried to restart you xampp server, I don't really know how it works as I use Apache & PHP already installed versions not a "AMP pack". Maybe it's a problem with the php.ini include_path which has not been reloaded.
It's clearly a problem with the path as it don't succeed to build the class name :
"Zend/Tool/Project/Context/Zf/./AbstractClassFile.php"
the dot should not appear here.
Can you share you PATH variable from the terminal and your include_path from your php.ini.
Sadly the solution was to install zend server community edition, and have that take care of everything for me. For anyone else on OSX going this route, check out: http://cmorrell.com/webdev/installing-zend-server-zend-framework-on-os-x-291
includes the steps for enabling CLI support.

Resources