September 27th, 2006 by admin
wer in php ein mini images benötigt das 1x1 pixel groß und weiß bzw. leer ist.
hier ist die funktion.
PHP:
-
function mini_image()
-
{
-
header("Content-Type: image/jpg");
-
header("Content-Length: 631");
-
-
AsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBg
-
NDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/w
-
AARCAABAAEDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgE
-
DAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJ
-
icoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5i
-
ZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/
-
8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxE
-
EBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHS
-
ElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba
-
3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwD3+iiig
-
D//2Q==');
-
}
Posted in coding, php | No Comments »
September 25th, 2006 by admin
i forgot an really important file: redirect.php for scuttle
just extract the file in the scuttle folder. the file calls the scuttle redirector template. without the redirect.php you will get an 404 error.
another small bug is in the rrs-feed. just copy my rss.php for scuttle to your scuttle directory and your rss-feeds will work also.
Posted in coding, php | 3 Comments »
September 24th, 2006 by admin
in der php dokumentation kann man nachlesen das es viele wege gibt ein string darzustellen.
unter anderem ist dort auch die octale schreibweise aufgeführt.
wenn man nun alle ausgabe in octal codiert sieht der user nur noch strings wie diesen "\147\145\164\105\154\145\155\145\156\164\102".
einige scriptentwickler in php benutzen diese schreibweise um das script zu verschlüßeln und unleserlich zu halten. problem gibt es dann wenn ein script nicht richtig funktioniert oder fehler ausgibt. für diesen fall hab ich mal ein kleinen satz an funktionen geschrieben.
die funktionen codieren und decodieren den strings in die octal schreibweise.
PHP:
-
function string2oct_str($string)
-
{
-
$base = 8;
-
for ($i=0;$i <strlen($string);$i++)
-
{
-
$ascii =
ord($string[$i]);
-
-
}
-
return $oct_string;
-
}
-
-
function oct2char($oct)
-
{
-
-
}
-
-
function octstring2string($oct_string)
-
{
-
//regex -> \[0-7]{1,3} = oct
-
-
}
-
-
//aufruf
-
-
echo octstring2string
('\147\145\164\105\154\145\155\145\156\164\102');
-
echo string2oct_str
('getElementB');
da ein script meist aus viele dateien besteht hab ich noch eine funktion die rekursiv ordner scannt und alle strings von octal in "normale" schreibweise umwandelt
PHP:
-
function dirTree($dir) {
-
-
if($d == false)
-
-
while (false !== ($entry = $d->read())) {
-
if($entry !=
'.' &&
$entry !=
'..' && !
is_dir($dir.
$entry)&&
substr($entry,-
4)==
'.php')
-
{
-
echo('decode->'.
$entry.
"\n");
-
$filename = $dir.$entry;
-
-
if($file_content == false)
-
-
$file_content = octstring2string($file_content);
-
if(file_put_contents($filename, $file_content)==0)
-
die('es wurden 0 bytes geschrieben.');
-
}
-
}
-
$d->close();
-
return $arDir;
-
}
-
-
//aufruf
-
print_r(dirTree
('/srv/www/htdocs-default_16/script/'));
Posted in coding, php | No Comments »
September 23rd, 2006 by admin
scuttle is a nice social bookmark tool. you can compare scuttle to the famous del.icio.us.
the current version 0.7.2 has many features but there is no counter that counts your bookmark visits.
i will instruct you how to create a working counter for your bookmarks and tell you how to "secure"(without the nasty referer) redirect to the url.
so lets start.
1. we need a template that redirect us to the url (without any trace). just copy the scuttle redirector in you "templates" folder.
2. we need to edit the "bookmarks.tpl.php" (also in the "templates" folder).
just replace the file with this bookmarks.tpl.php
3. now we edit the "bookmarkservice.php" file wich is located in the "services" directory in your scuttle forder.
search for
PHP:
-
function & getBookmarks($start = 0, $perpage = NULL, $user = NULL, $tags = NULL, $terms = NULL, $sortOrder = NULL, $watched = NULL, $startdate = NULL, $enddate = NULL, $hash = NULL) {
and insert ABOVE
PHP:
-
//macosmod
-
function updateBookmarkCounter($bId, $visits) {
-
-
return false;
-
$updates =
array('visits' =>
$visits+
1);
-
$sql =
'UPDATE '.
$GLOBALS['tableprefix'] .
'bookmarks SET '.
$this->
db->
sql_build_array('UPDATE',
$updates) .
' WHERE bId = '.
intval($bId);
-
$this->db->sql_transaction('begin');
-
if (!($dbresult = & $this->db->sql_query($sql))) {
-
$this->db->sql_transaction('rollback');
-
message_die(GENERAL_ERROR, 'Could not update bookmark', '', __LINE__, __FILE__, $sql, $this->db);
-
return false;
-
}
-
$this->db->sql_transaction('commit');
-
return true;
-
}
-
//macosmod
now search for
PHP:
-
default:
-
$query_5 = ' ORDER BY B.bDatetime DESC ';
and insert ABOVE
PHP:
-
//macosmod
-
case 'visits_desc':
-
$query_5 = ' ORDER BY B.visits DESC ';
-
break;
-
case 'visits_asc':
-
$query_5 = ' ORDER BY B.visits ASC ';
-
break;
-
//macosmod
4. mysql needs an field that counts our visits, so go to your mysql admin (eg. phpmyadmin), select your scuttle database and execute the following sql code
CODE:
-
ALTER TABLE `sc_bookmarks` ADD `visits` INT NOT NULL AFTER `bHash`
5. activate the redirector. go to your "config.inc.php" and set the following values
CODE:
-
$useredir = true;
-
-
$url_redir = 'visit_counter';
thats it. now our scuttle counts the hits and redirect us to the url in a "secure" way.
Posted in coding, php | 3 Comments »
September 13th, 2006 by admin
ihr habt eine *.src.rpm und habt keine ahnung wie ihr die installiert bzw. compiliert bekommt.
CODE:
-
rpmbuild --rebuild NAME_DER_RPM .scr.rpm
das ganze sollte die source rpm für euer system compilieren und bei den rpm files abspeichern.
wo winde ich das compilierte rpm file? einfach mal im root suchen da jede distri. die dateien an verschiedenen orten speichert.
CODE:
-
find -name *NAME_DER_RPM*
bei suse finden wir das ganze in /usr/src/packages/RPMS/ARCH/NAME_DER_RPM.rpm
Posted in misc | No Comments »