Difference between revisions of "Geshi"

From CPCWiki - THE Amstrad CPC encyclopedia!
Jump to: navigation, search
(New page: <source lang="z80"> ld de,&4000 ld hl,&c000 ld bc,&FFFF ldir ret </source>)
 
m
Line 6: Line 6:
 
ret
 
ret
 
</source>
 
</source>
 +
 +
== GeSHi ==
 +
<php><?php
 +
  echo 'Hello, world!';
 +
  # What else?
 +
  $my_cnx = mysql_open('localhost', 'user', 'pass');
 +
  if ($my_cnx === false)
 +
    die('Unable to open connection with MySQL database engine');
 +
  mysql_select_db('database', $my_cnx) or die('Unable to select database');
 +
  $request = sprintf('UPDATE table SET column=data WHERE othercolumn=\'%s\'', $_SESSION['text']);
 +
  $my_success = mysql_query($request, $my_cnx);
 +
  if ($my_success === false) {
 +
    die('Error when trying to update table');
 +
  }
 +
  mysql_close($my_cnx);</php>
 +
 +
<geshi lang=sql>
 +
select * from lib.tbl where this=that
 +
</geshi>
 +
 +
<geshi lang=bash>
 +
#!/bin/ksh
 +
 +
HOST=host
 +
USER=username
 +
PASS=password
 +
FILE=bad.txt
 +
LOGFILE=log.txt
 +
 +
ftp -n -v -i ${HOST} > ${LOGFILE} 2>&1 << EOF
 +
quote USER ${USER}
 +
quote PASS ${PASS}
 +
binary
 +
put ${FILE}
 +
quit
 +
EOF
 +
 +
grep -q "Transfer complete." ${LOGFILE}
 +
 +
if [[ $? != 0 ]]; then
 +
  echo "ftp failed"
 +
else
 +
  echo "ftp succeeded"
 +
fi
 +
 +
rm ${LOGFILE}
 +
</geshi>

Revision as of 07:23, 28 March 2009

<source lang="z80"> ld de,&4000 ld hl,&c000 ld bc,&FFFF ldir ret </source>

GeSHi

<php><?php

 echo 'Hello, world!';
 # What else?
 $my_cnx = mysql_open('localhost', 'user', 'pass');
 if ($my_cnx === false)
   die('Unable to open connection with MySQL database engine');
 mysql_select_db('database', $my_cnx) or die('Unable to select database');
 $request = sprintf('UPDATE table SET column=data WHERE othercolumn=\'%s\, $_SESSION['text']);
 $my_success = mysql_query($request, $my_cnx);
 if ($my_success === false) {
   die('Error when trying to update table');
 }
 mysql_close($my_cnx);</php>

<geshi lang=sql> select * from lib.tbl where this=that </geshi>

<geshi lang=bash>

  1. !/bin/ksh

HOST=host USER=username PASS=password FILE=bad.txt LOGFILE=log.txt

ftp -n -v -i ${HOST} > ${LOGFILE} 2>&1 << EOF quote USER ${USER} quote PASS ${PASS} binary put ${FILE} quit EOF

grep -q "Transfer complete." ${LOGFILE}

if $? != 0 ; then

  echo "ftp failed"

else

  echo "ftp succeeded"

fi

rm ${LOGFILE} </geshi>