1

(1 replies, posted in Python)

Looks like MySQL server isn’t running. Or the name «localhost» does not point to 127.0.0.1, if TCP connection us used.

2

(8 replies, posted in C/C++)

Since it’s a compiled language, it’s impossible to perform all needed checks. Arrays are very basic — they are just a memory area of size N * sizeof(T) where N is number of elements and T is data type. Array variable is a pointer to the beginning of that area. The operation [M] only makes an offset by M * sizeof(T) from the pointer… So, you should care about this yourself smile

If you don’t know how much elements you will need, you may use malloc to allocate your array in dynamic memory.

int *b;

int main () {
…
b = malloc(sizeof(int) * number);
b[20] = 12;
…
}

3

(8 replies, posted in C/C++)

3 types of “Hello, world† in C and C++. The third example shows class definition syntax and also shows how to compile multiple source files into a single application. Sorry for russian language in the interface.

http://averkov.web.id/video/hellos.mpg

But you do not need video streaming if you need just to embed a video player into your web page to play static video files. If this is what you are looking for, just take flowplayer and configure it as described…

It’s impossible to make with only PHP. You should have a server-side streaming application.
This may help: http://ffmpeg.org/ffserver.html

6

(2 replies, posted in PHP)

http://www.phpmyadmin.net/home_page/docs.php

You can use ncurses for advanced console manipulation smile

8

(5 replies, posted in Mimpi)

Why don’t you update Openfire btw?

It’s not well known, but jsmart.web.id has became the world’s largest community powered Jabber server. But less than 1% of the users are from Indonesia. It disappoints a lot.

10

(0 replies, posted in PHP)

Just for share.
I’ve written a small image processing class for some of my projects. Maybe you’ll find it useful. Here are a couple of examples.

$image = new BSM\Image('drawing.bmp');
$image->reduceSizeBy(640, 480);
$image->drawBorder(0x00, 0x00, 0x00);
$image->saveAsPng('result.png');
$image = new BSM\Image(320, 240);
$image->fillBackground(0xFF, 0xFF, 0xFF);
$image->drawBorder(0x00, 0x00, 0x00);
header('content-type: text/html');
echo "<html><head>test</head><body>$image</body></html>";

Bug fixes and feature requests are accepted in the issue tracker: http://dev.jsmart.web.id/projects/miniclasses/issues , the class itself can be downloaded from SVN: svn://svn.jsmart.web.id/miniclasses/bsmimage

Example project using this class is my Jabber RSS gateway which can be downloaded here and my photo gallery creator (Linux only) which can be got from SVN: svn://svn.jsmart.web.id/miniscripts/gallerizer

smile

11

(1 replies, posted in PHP)

Day/night feature is fine now btw…

http://weather.jsmart.web.id/Jakarta.png

12

(1 replies, posted in PHP)

Sorry if this is not directly related with PHP, but at least it’s related with making websites smile
http://weather.jsmart.web.id/ — my small web service that generates weather widgets for embedding into websites
It’s still running in testing mode and some problems are already known (for example, at nights you will see sun on the images), but I am going to fix them soon.
Feedback via Jabber/XMPP is appreciated…

New article if anyone’s interested…
http://jsmart.web.id/Konfigurasi_nginx_ … dengan_PHP

14

(2 replies, posted in MySQL)

500 megs? phpmyadmin?
Use mysql console client

# mysql -u username -p123456
mysql> SOURCE /path/to/your/500_megs_file.sql;
…

15

(0 replies, posted in Diskusi Bebas)

For your interest
http://averkov.maykop.ru/files/40788817.mpg
smile

Ada fitur yang bagus untuk parsing XML: http://id.php.net/DOM
For saving parsing result you may try to use: http://id.php.net/serialize

$data = DOMDocument::load('filename.xml');
file_put_contents('filename.xml.parsed', serialize($data));

Unsure if serializing works properly with DOM trees, but if does then it's the simpliest way smile

It’s now time for me to ask. Does anybody know whether it is possible to calculate vhost’s traffic or not? For example, if I want to make limit 10G/month for some vhost and to show HTTP 509 error to site visitors if the vhost exceeded it’s quota…

18

(3 replies, posted in PHP)

b.indonesia saya sedikit

19

(3 replies, posted in PHP)

http://opensource.telkomspeedy.com/foru … hp?id=8820

Hmm? What’s the problem? Don’t know how to get data by HTTP or how to parse?

Getting remote XML (the simpliest way)

$xml_anda = @ file_get_contents('http://url_of_xml_file');

Please note that your hoster may disallow such things, so better to use sockets in that case.

Parsing is easy, too. Write some class, like mine one:

<?php

class ATXmlParser
{
    private $xml;
    private $parser;
    private $result = NULL;
    private $stack;
    private $i = 0;
    
    public function __construct($xml) {
        $this->parser = xml_parser_create();
        $this->xml = $xml;
        xml_set_object($this->parser, $this);
        xml_set_element_handler($this->parser, 'tag_open', 'tag_close');
        xml_set_character_data_handler($this->parser, 'cdata');
        xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0);
        xml_parser_set_option($this->parser, XML_OPTION_SKIP_WHITE, 0);
        xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, 'UTF-8');
    }
    
    public static function parseFile($filename) {
        $f = new ATTextFile($filename);
        $parser = new self($f->asString());
        $parser->parse();
        return $parser->fetchResult();
    }
    
    public static function parseXML($data) {
        $parser = new self($data);
        $parser->parse();
        return $parser->fetchResult();
    }
    
    private function cdata($parser, $data) {
        $this->stack[$this->i-1]->insertCharacterData($data);
    }
    
    private function tag_open($parser, $tag, $attributes) {
        $t = new ATXmlTag($tag, $attributes);
        if(is_null($this->result)) {
            $this->result = $t;
            $this->stack[$this->i++] = $t;
        } else {
            $this->stack[$this->i-1]->insertChildElement($t);
            $this->stack[$this->i++] = $t;
        }
    }
    
    private function tag_close() {
        unset($this->stack[--$this->i]);
    }
    
    public function parse() {
        if(!xml_parse($this->parser, $this->xml)) {
            $errno = xml_get_error_code($this->parser);
            $error = xml_error_string($errno);
            throw new ATXmlParserException($error);
        }
    }
    
    public function & asString() {
        return $this->xml;
    }
    
    public function & fetchResult() {
        return $this->result;
    }
}

?>

ATXmlTag in this example is tag abstraction class. It has child elements list, the children are all sub tags and cdata blocks.

21

(43 replies, posted in PHP)

PHP is a coding language.
Jabber is a messaging network.
Jabber-related project can be written in PHP language, too.
Just for your note.

hermawan_fsi wrote:

this what i am worry about building webserver,

If some web server is down then there is some reason for that. For example, with nginx you may get 502 or 504 errors if you configure your FastCGI server not well. 502 (“Bad gateway† or “Proxy error†) error may occur when the FastCGI server is busy and cannot handle new request, 504 may occur when the FastCGI server processes the request too long time. So, if you get 502 error, it is needed to increase FastCGI workers count, if 504 then needed to analyse your website for slow parts and rewrite them if needed (or order a more powerful server).
502 error may also occur when you are using proxy_pass directive (for example, to forward Apache’s output).

23

(43 replies, posted in PHP)

I can provide free web hosting (PHP 5.3, MySQL 5.0) for a Jabber-related project.
It can be a Jabber/XMPP client application (J2ME-based are the most welcome), Jabber/XMPP server, library and so on. The only requirement is that I need to like your project wink

Contact e-mail: admin (put “@† here) jsmart.web.id.

hermawan_fsi,
So, what is the problem? Uding webalizer for nginx’s logs? I never used webalizer, but I think it should not be a problem — nginx’s log format is fully customizable. The official documentation is available here (unfortunately, Russian only, but you may try to read it with Google Translate).

---

Btw… I wanted to say some words on how to use nginx for chosing the most suitable mirror of the web site.
For example, you have 2 servers — one in Singapore and the other in Moscow. Singapore server serves website sg.site.com, Moscow server serves ru.site.com and site.com. You need to solve next task: visitors from Indonesia, Malaysia and Singapore should be directed to sg.your_site.com and all the others — to ru.site.com. It can be easilly done with nginx — all what you need is to add some checks to your vhost configuration:

if ($geoip_country_code = ID) {
  rewrite ^(.*)$ http://sg.site.com$1 permanent;
}
if ($geoip_country_code = SG) {
  rewrite ^(.*)$ http://sg.site.com$1 permanent;
}
if ($geoip_country_code = MY) {
  rewrite ^(.*)$ http://sg.site.com$1 permanent;
}

rewrite ^(.*)$ http://ru.site.com$1 permanent;

The variable $geoip_country_code is automatically set by ngx_http_geoip_module, be sure to have compiled it (--with-http_geoip_module). You will also need to specify path to GeoIP database:

http {
  geoip_country  /path/to/GeoIP.dat;
  …

Maaf untuk inggris… Saya gak bisa bhs indonesia.

I never saw nginx tutorials in indonesian language, but I know some servers running nginx (http://unpad.ac.id, http://mirror.unej.ac.id, http://indowebster.com and many others). I use nginx, too.

Anyway, if you have any questions, feel free to ask here, I will try to help.