September 19th, 2007 by admin
mit propel können in php relationale datenbanken(z.b. mysql,mssyl oder oracle) objektrelational gemappt werden, ne super sache. also dache ich mir, ich probier das ganze mal aus.
die trac seite konnte mir dazu ein sehr gutes tutorial liefern. doch leider hab ich es nicht geschaft das propel auf meine mysql datenbank zugreift. nunja ein bischen gegoogelt und dabei hab ich ein schönes deutsches tutorial auf dem tech-nick-blog gefunden, leider hat mir das auch nicht geholfen, da propel danach die folgende fehlermeldung ausgespuckt hat:
CODE:
-
wrapped: No driver has been registered to handle connection type:
nachdem ich bei zend endlich fündig geworden bin konnte der folgende code vom tech-nick-blog als verursacher ausgemacht werden (in der runtime-conf.xml).
CODE:
-
<dsn>mysql:host=localhost;dbname=newssystem</dsn>
-
<user>nutzername</user>
-
<password>passwort</password>
das ganze wird dann einfach mit der zend variante ersetzt und fertig.
CODE:
-
runtime-conf.xml:
-
<connection>
-
<phptype>mysql</phptype>
-
<hostspec>localhost</hostspec>
-
<database>test</database>
-
<username>root</username>
-
<password>passss</password>
-
<options>
mein propel funktioniert jetzt 
Posted in coding, php | No Comments »
Mai 22nd, 2007 by admin
reblog has a powerful metaweblog api plugin called "metaweblog_RPC.plugin.php". it is very useful to distribute rss-news to your blog(s). but the script submits all characters in uft8 format. that is a problem because wordpress (maybe other blog software too) can not handle it (for example here or here the character like ö,ä,ü are displayed as garbage). i found the solution in the php.net comments (thanks to johan andersson) and it works.
here is my fixed metaweblog_RPC.plugin.php
Posted in coding, php | No Comments »
März 6th, 2007 by admin
wordpress hat eine initiative ins leben gerufen die sich "pro-backup" nennt.
alle user werden angehalten regelmäßig backups von ihren datenbanken zu erstellen.
leider empfiehlt wordpress nur phpmyadmin, was ich persönlich nict verstehe. phpmyadmin ist ein sehr nützliches tool um eine datenbank zu verwalten, jedoch nicht für automatische backups ausgelegt.
ich nutze seit ich denken kann mysqldumper. dieses script ist für die erstellung von backupdaten komzipiert.
quote:
MySQLDumpers sorgt dafür, dass Datenbanken automatisch per Cronjob gesichert werden.
mehr infos gibt es unter pro-backup.de und mysqldumper.de
Posted in backup, php | No Comments »
Februar 1st, 2007 by admin
in my previous post i released a class which "decrypt" php scripts that hide source code with special functions like eval, gzinflate, base64_decode or str_rot13. i also create a class to "encrypt" php source code (not yet released). so i think it is a good idea to mix up both classes in one script. the resulting php script modify it's own code.
what is modifying code (quote from wikipedia)?
In computer science, self-modifying code is code that alters its own instructions, whether or not it is on purpose, while it is executing.
what is it good for?
- Hiding of code to prevent reverse engineering, as through use of a disassembler or debugger (PHP is an interpreter -> you can reverse the code)
- Hiding of code to evade detection by virus/spyware scanning software and the like
- Compression of code to be decompressed and executed at runtime, e.g. when memory or disk space is limited
- obscure the source code
how does it work?
- the script execute your source code
- at the end of code the magic happens (self modifying code)
- the script retrieve it's own crypted source code
- decrypt it
- obscure the code (replaces function and variable names by a random generated md5 string)
- crypt the source 10 times (if you like to change this do it on line 31)
- write the crypted source back to the file
- that's it
the source. sadly my wordpress syntax highlighter doesn't work properly with the new wordpress 2.1.
you got 2 options to get the proper source code:
1. push the "PLAINTEXT" button
2. click here for the highlighted code
any comments would be nice.
PHP:
-
function mod()
-
{
-
$file = __FILE__;
-
$nag =
strpos($file,
"(1) : eval()'d code");
-
if($nag != false)
-
-
-
-
$decoder = new decoder($cont);
-
$cont = $decoder->decode_it();
-
$arr = $decoder->used_functions();
-
-
-
-
foreach($result[0] as $line)
-
{
-
if($line!='$this')
-
-
}
-
-
-
-
foreach($result[0] as $line)
-
{
-
-
-
-
}
-
$encoder = new encoder($cont);
-
for($i=0;$i <10;$i++)
-
{
-
-
}
-
$encoder->fill_with_php_tags();
-
$cont = $encoder->get_crypt_source();
-
-
-
file_put_contents($file, $cont );
-
else
-
error();
-
-
-
-
-
-
-
}
-
-
class encoder
-
{
-
function __construct($source)
-
{
-
$this->source = $source;
-
$this->crypt_source = $source;
-
}
-
-
public function rand_function()
-
{
-
-
$possible_functions =
array('str_rot13_cr',
'gzflate');
-
return $possible_functions[rand(0,
count($possible_functions)-
1)];
-
}
-
-
public function base64_cr()
-
{
-
$this->crypt_source =
'eval(base64_decode('.
"'".
base64_encode($this->crypt_source
).
"'".
'));';
-
}
-
-
public function str_rot13_cr()
-
{
-
$this->crypt_source =
'eval(str_rot13(base64_decode('.
"'".
base64_encode(str_rot13($this->crypt_source
)).
"'".
')));';
-
}
-
-
public function gzflate()
-
{
-
$this->crypt_source =
'eval(gzinflate(base64_decode('.
"'".
base64_encode(gzdeflate($this->crypt_source,
9)).
"'".
')));';
-
}
-
-
public function fill_with_php_tags()
-
{
-
$this->crypt_source = '<?php '.$this->crypt_source.' ?>';
-
}
-
-
public function get_crypt_source()
-
{
-
return ($this->crypt_source);
-
}
-
}
-
-
class decoder
-
{
-
private
$used_functions =
array();
-
function __construct($data)
-
{
-
$data = $this->strip_php_tags($data);
-
$this->org_data = $data;
-
$this->result = $this->org_data;
-
$this->done = false;
-
}
-
-
function strip_php_tags($data)
-
{
-
$pos =
strpos($data,
'<?php');
-
$len = 5;
-
if($pos===false)
-
{
-
-
$len = 2;
-
if($pos===false)
-
-
}
-
$ende =
strrpos($data,
'?>')-
$len;
-
$data =
substr($data,
$len,
$ende);
-
return $data;
-
}
-
-
function strip_what_to_execute()
-
{
-
$possible_code =
substr($this->result,
0,
strpos($this->result,
"'"));
-
if($possible_code=='')
-
$possible_code =
substr($this->result,
0,
strpos($this->result,
'"'));
-
-
$execute_arr = $this->test_possible_code($possible_code);
-
if(count($execute_arr)>
1)
-
{
-
$possible_code_start =
strlen($possible_code)+
1;
-
$possible_code_end =
strrpos($this->result,
"'");
-
$this->result =
substr($this->result,
$possible_code_start,
$possible_code_end-
$possible_code_start);
-
return $execute_arr;
-
}
-
else
-
return false;
-
}
-
-
function clean_string($str)
-
{
-
-
return $str;
-
}
-
-
function test_possible_code($str)
-
{
-
$str = $this->clean_string($str);
-
-
-
-
{
-
$this->done = true;
-
return false;
-
}
-
foreach($functions as $function)
-
{
-
if($function!='' && $function!='eval')
-
{
-
-
error();
-
else
-
$execute_arr[] = $function;
-
}
-
}
-
return $execute_arr;
-
}
-
-
function do_it($execute_arr)
-
{
-
$cmd_str = '';
-
$cmd_end = '';
-
foreach($execute_arr as $cmd)
-
{
-
$this->used_functions[] = $cmd;
-
$cmd_str .= $cmd.'(';
-
$cmd_end .= ')';
-
}
-
$eval = $cmd_str."'".$this->result."'".$cmd_end;
-
eval ("\$this->result = ".
$eval.
";");
-
}
-
-
function decode_it()
-
{
-
$execute_arr = $this->strip_what_to_execute();
-
if($this->done==
false &&
count($execute_arr)>
0)
-
{
-
$this->do_it($execute_arr);
-
$this->decode_it();
-
}
-
return $this->result;
-
}
-
-
function used_functions()
-
{
-
return ($this->used_functions);
-
}
-
}
-
-
function error()
-
{
-
-
}
-
-
-
-
/*real code*/
-
Posted in coding, php | 2 Comments »
Dezember 11th, 2006 by admin
PHProxy 0.4 is a very nice web-proxy-server. but the script got one big disadvantage.
the script declares the following functions in phpproxy.class.php:
PHP:
-
if ($this->flags['rotate13'])
-
{
-
function encode_url($url)
-
{
-
-
}
-
function decode_url($url)
-
{
-
-
}
-
}
-
else if ($this->flags['base64_encode'])
-
{
-
function encode_url($url)
-
{
-
-
}
-
function decode_url($url)
-
{
-
-
}
-
}
-
else
-
{
-
function encode_url($url)
-
{
-
-
}
-
function decode_url($url)
-
{
-
-
}
-
}
this is really bad coding style, but works with the old php4. php5 does not support such a crap style therefor php5 give us the following error code:
Parse error: parse error, unexpected T_FUNCTION, expecting T_VARIABLE in ...\proxy\PHProxy.class.php on line 118
to avoid this error you can use my mod of phproxy. i modified the following files to get a working phproxy on php5: PHProxy.class.php,index.php and url_form.inc
proxy0.4_macos.zip
Posted in coding, php | 2 Comments »