Questions About Putenv

Simple _putenv example not working

I tried using getenv and setenv under cl.exe under Visual Studio 2008. getenv worked but setenv didn't. After some browsing I found out that _putenv is an alternative.

The following snippet didn't work

#include <stdio.h>
#include <stdlib.h>

int main()
{
   _putenv("Hello=123");
}

C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC>putenv.exe

C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC>echo %Hello%
%Hello%

What could be the reason?

http://www.stackoverflow.com/questions/12688096/simple-putenv-example-not-working

Underline text using imagettftext

My question is, how do I underline all the text in the image?

Code:

function createImage($text)
{
    $text .= "\n";
    $text = wordwrap($text, 40, "\n");
    $newlines = substr_count($text, "\n");
    if($newlines == 0)
    {
        $height = 30;
    }
    else
    {
        $height = 30*$newlines-$newlines*7;
    }
    putenv('GDFONTPATH=' . realpath('.'));
    header('Content-Type: image/png');

    $im = imagecreatetruecolor(315, $height);
    $white = imagecolorallocate($im, 255, 255, 255);
    $grey = imagecolorallocate($im, 128, 128, 128);
    $black = imagecolorallocate($im, 0, 0, 0);
    $purple = imagecolorallocate($im, 97, 26, 139);
    imagefilledrectangle($im, 0, 0, 399, $height, $white);
    $font = 'arialbd.ttf';

    imagettftext($im, 11, 0, 10, 20, $purple, $font, $text);
    imagepng($im);
    imagedestroy($im);
}

createImage("Stackoverflow Stackoverflow Stackoverflow Stackoverflow Stackoverflow Stackoverflow Stackoverfl
    
http://www.stackoverflow.com/questions/14741622/underline-text-using-imagettftext

Is there a way in PHP to use persistent data as in Java EE? (sharing objects between PHP threads) without session nor cache/DB

Is there a way in PHP to use "out of session" variables, which would not be loaded/unloaded at every connexion, like in a Java server ?

Please excuse me for the lack of accuracy, I don't figure out how to write it in a proper way.

The main idea would be to have something like this :

<?php
    ...
    // $variablesAlreadyLoaded is kind of "static" and shared between all PHP threads
    // No need to initialize/load/instantiate it.
    $myVar = $variablesAlreadyLoaded['aConstantValueForEveryone'];
    ...
?>

I already did things like this using shmop and other weird things, but if there is a "clean" way to do this in "pure PHP" without using caching systems (I think about APC, Redis...), nor database.

EDIT 1 :

Since people (thanks to them having spent time for me) are answering me the same way with sessions, I add a constraint I missed to write : no sessions please.

<

http://www.stackoverflow.com/questions/15086349/is-there-a-way-in-php-to-use-persistent-data-as-in-java-ee-sharing-objects-between-php-threads-without

Problems with PHP, MySQL based log-in system

IMPORTANT

After following the advice in the answers below, the client was able to log-in without any problems but did not attempt to actually navigate the secured pages. When he attempted to do so later, he was returned to log-in as before with the "Please log in" error. After much head scratching, something incredibly simple came to mind - the client was accessing the site with http://www.example.com/admin and everything in the login script was redirecting to http://example.com, so the session cookie that it was looking for was set for another domain. This also explains why he had problems logging in the first time but not subsequent times - the script redirected him to the log-in form without the www.

A quick fix was to write a .htaccess file to remove the www, problem solved. Of course this could also be handled within the login script, which

http://www.stackoverflow.com/questions/12749353/problems-with-php-mysql-based-log-in-system

centos 6 ps aux hangs up

I have problem with my server. Server is running centos 6 (CloudLinux Server release 6.2). uname -a = 2.6.32-320.4.1.lve1.1.4.el6.x86_64 That is a kvm guest. On host is debian 6.

If i run command ps aux, it stuck on random process (shows some processes only), top command is working fine. htop doesn't work too (black screen).

top - 12:11:51 up 34 min,  1 user,  load average: 4.26, 6.71, 16.15
Tasks: 201 total,   7 running, 192 sleeping,   0 stopped,   2 zombie
Cpu(s):  7.9%us,  2.8%sy,  0.0%ni, 87.5%id,  1.6%wa,  0.0%hi,  0.2%si,  0.0%st
Mem:   9862044k total,  2359484k used,  7502560k free,   171720k buffers
Swap: 10485720k total,        0k used, 10485720k free,  1336872k cached

server has one Intel(R) Xeon(R) CPU E5606 @ 2.13GHz,

free -m

             total       used       free     shared    buffers     cached
Mem:          9630       2336       729
    
http://www.serverfault.com/questions/454866/centos-6-ps-aux-hangs-up

PHP GD2 How to show in-fly generated image without modifying header?

I'm working at my own signature generator. How to show in-fly generated image without modifying header? I need to know it, because my site (based on WordPress) already sent headers, and I cannot modify it. Of course I can modify theme, but I am just beginning in PHP. If I modify headers everything works (almost working script), but when I want to open it in WordPress, the image isn't generated. I have also second question: how to add to my generated any extension to show it on any forum (it's example) - in this case: png? I don't want save generated image, but if I must after save image must be deleted.

<?php
if( ! empty($_GET['nick']) ){
    //default
    $nick = $_GET['nick'];
    if(empty($_GET['server']))
        $server = 'eu';
        else $server = $_GET['server'];
    if(empty($_GET['font']))
        $font = 'calibri'
    
http://www.stackoverflow.com/questions/12807800/php-gd2-how-to-show-in-fly-generated-image-without-modifying-header

Permanently setting environment variables from a C++ program after exit

I am writing a bash script that runs a C++ program multiple times. I use getenv() and putenv() to create, get, and update environment variables in the C++ program. After the C++ program ends, the bash script needs to grab these variables and perform some basic logic. The problem is that when the C++ program exits, the environment variables disappear. Is there any way to permanently store these variables after the program's termination so that the bash script can use them? If not, what is the best way to share variables between a bash script and a C++ program? The only solution I can think of is writing output to files. I do not want to print this data in the console. Any help would be greatly appreciated.

http://www.stackoverflow.com/questions/12886018/permanently-setting-environment-variables-from-a-c-program-after-exit

How to use PHP with Oracle Wallet?

Possible Duplicate:
Connect from PHP to an Oracle DB using an Oracle Wallet

We are planning to implement Oracle Wallet. It works from sqlplus as shown below. That shows that wallet functionality is working.

    export ORACLE_HOME=/afs/engg/g/lcls/package/oracle/product/11.1.0.6/client
    export PATH=$ORACLE_HOME/bin:${PATH}
    export TNS_ADMIN=/afs/engg/g/lcls/tools/oracle/wallets/engg_reader


    $ sqlplus /@enggdev
    SQL> show user
    USER is "ENGG_READER"

I am so far unsuccessful to make it work from php. We have php installed with OCI8 extension. Please guide me especially about oci_connect command and it's syntax.

This is my php file -

    <?php
    // Create connection to Oracle
    PutEnv("ORACLE_HOME=/afs/engg/g/lcls/package/oracle
    
http://www.stackoverflow.com/questions/12947873/how-to-use-php-with-oracle-wallet

PHP: make translations in multiple languages

I have my php gettext default language in English let's say

I would like in one of my controller, to translate some words in 2 other languages and put them all in an array.

ideally I could do

$word_sv = gettext($word, 'sv_SV');
$word_fi = gettext($word, 'fi_FI');

but it doesn't exist.

Is the only way to change the overall gettext settings each time?

function setLang($lang){
    putenv("LC_ALL=$lang");
    setlocale(LC_ALL, $lang);
    bindtextdomain("myPHPApp", "./locale");
    textdomain("myPHPApp");
}

setLang('sv_SV');
$word_sv = gettext($word);
setLang('fi_FI');
$word_fi = gettext($word);

related: saw it on Google after : i18n with gettext bu

http://www.stackoverflow.com/questions/12975499/php-make-translations-in-multiple-languages

PHPUnit with a Zend Framework 2 module

I'm struggling in getting a PHPUnit test to work with ZF2.

My directory structure looks as follows

project
- src
  - config, data, module, public, vendor
  - init_autoloader.php
- test
  - bootstrap.php
  - SimpleTest.php

The application itself works well.

Now for running PHPUnit tests, my bootstrap.php looks as follows

putenv('ZF2=../src/vendor/zendframework/zendframework/library');
$loader = include '../src/vendor/autoload.php';
include '../src/init_autoloader.php';

This works for ZF2 related things but does not find my module. I then read that I have to add the following line to my bootstrap.php

Zend\Mvc\Application::init(include '../src/config/application.config.php');

But now I get the following error:

PHP Fatal error:  Uncaught exception 'Zend\ModuleManager\Exception\RuntimeException' with message 'Module (Mymodule) could not be initialized.' in
    
http://www.stackoverflow.com/questions/12980033/phpunit-with-a-zend-framework-2-module

Php gettext is not displaying the translated text (after generationg the .pot and .mo files with poEdit)!

I followed the folling tutorial: http://mel.melaxis.com/devblog/2005/08/06/localizing-php-web-sites-using-gettext/

about Php gettext extension (I unchecked the comment in the php.ini)

The gettext is activated but it doesn't show up the translation (German).

Here are the files:

C:\wamp\www\php-test\test.php:

<?php
require_once("localization.php");
echo _("Hello World!");
?>

C:\wamp\www\php-test\localization.php:

<?php
$locale = "de_DE";
if (isSet($_GET["locale"])) $locale = $_GET["locale"];
putenv("LC_ALL=$locale");
setlocale(LC_ALL, $locale);
bindtextdomain("messages", "./locale");
textdomain("messages");
?>

C:\wamp\www\php-test\locale\de_DE\LC_MESSAGES\messages.po:

msgid ""
msgstr ""
"Project-Id-V
    
http://stackoverflow.com/questions/2261571/php-gettext-is-not-displaying-the-translated-text-after-generationg-the-pot-and-mo-files-with-poedit

Php gettext extension works on my local host but its not working on my hosting

I tried php gettext in my localhost and everything worked, but when I uploaded the files to my hosting it said the following:

Warning: putenv(): Safe Mode warning: Cannot set environment variable 'LC_ALL' - it's not in the allowed list in /www/zxq.net/w/e/e/weedcl/htdocs/localization.php on line 4 Fatal error: Call to undefined function bindtextdomain() in /www/zxq.net/w/e/e/weedcl/htdocs/localization.php on line 6

I'm using the free hosting service Zymic (Does it have to do with the fact that its FREE?).

My localization.php:

<?php
$locale = "de_DE";
if (isSet($_GET["locale"])) $locale = $_GET["locale"];
putenv("LC_ALL=$locale");
setlocale(LC_ALL, $locale);
bindtextdomain("messages", "./locale");
bind_textdomain_codeset("messages", 'UTF-8');
textdomain("messages");
?>
http://stackoverflow.com/questions/2274692/php-gettext-extension-works-on-my-local-host-but-its-not-working-on-my-hosting

What should COMSPEC and PATH environmental variables be to locate the command-interpreter, using system()?

Are the OS (XP) environmental variables the same used in a process running from visual studio .NET C++?

It seems the command interpreter is not found:
When using NULL as the command, system() returns 0 and with command - ENOENT Command interpreter cannot be found.

In windows (System->Environmental Variables), COMSPEC contains the path to cmd.exe
PATH does not.

What should PATH be?

Other than this, not sure why it can not find the interpreter.

Any suggestions are appreciated. Thanks.

  if( system("tail -500 log.txt") == -1)
  {
      //Error calling tail.exe on log 
      //errno is a system macro that expands int returning
      //the last error. strerror() converts the error to it's
      //corresponding error message. 
      printf("Error calling tail.exe with system(): %s",strerror( errno ));

  }
<
    
http://stackoverflow.com/questions/2276483/what-should-comspec-and-path-environmental-variables-be-to-locate-the-command-interpreter-using-system

Dealing with eacute and other special characters using Oracle, PHP and Oci8

Hi I am trying to store names into an Oracle database and fetch them back using PHP and oci8.

However, if I insert the directly into the Oracle database and use oci8 to fetch it back I just receive an e

Do I have to encode all special characters (including ) into html entities (ie: &eacute;) before inserting into database ... or am I missing something ?

Thx


UPDATE: Mar 1 at 18:40

found this function: http://www.php.net/manual/en/function.utf8-decode.php#85034

function charset_decode_utf_8($string) {
    if(@!ereg("[\200-\237]",$string) && @!ereg("[\241-\377]",$string)) {
        return $string;
    }
$string = preg_replace("/([\340-\357])([\200-\277])([\200-\277])/e","'&#'.((ord('\1')-224)*4096 + (ord('\2')-128)*64 + (ord('\3')-128)).';'",$str
    
http://stackoverflow.com/questions/2357680/dealing-with-eacute-and-other-special-characters-using-oracle-php-and-oci8

PHP and Gettext don't work on my server

I have a website. I'm trying to get gettext to work so that my English, Sweden and Norway sites can come up. I can't get it to work. What have I done wrong?

This is my config code:

// define constants ( defualt - danish )
$lang = 'da_DA';
$lang_short = '';
$lang_prefix = 'da';

if ( isset( $_GET['lang'] ) )
{
    switch( $_GET['lang'] )
    {
        case 'en':
            $lang = 'en_EN';
            $lang_short = 'en/';
            $lang_prefix = 'en';
            break;
        case 'se':
            $lang = 'se_SE';
            $lang_short = 'se/';
            $lang_prefix = 'se';
            break;
        case 'no':
            $lang = 'no_NO';
            $lang_short = 'no/';
            $lang_prefix = 'no';
            break;
    }
}
define( 'LANG', $lang_short );
define( 'LANG_PREFIX', $lang_prefix );

putenv("LC_ALL=". $lang );
bindtextdomain('messages', ROOT .'lang/');

And my path is /var/www/rssbot.dk/lang/. Should

http://stackoverflow.com/questions/2915056/php-and-gettext-don-t-work-on-my-server