Per Thykjaer Jensen

  • <? 
    global $wpdb; // henter klassen
    
    if (isset($_POST['submitted'])) { 
    foreach($_POST AS $key => $value) { $_POST[$key] = mysql_real_escape_string($value); } 
    $sql = "INSERT INTO `KbnLog` ( `Id` ,  `Date` ,  `KbnProjects_Id` ,  `KbnNotes_Id` ,  `KbnStates_Id`  ) VALUES(  '{$_POST['Id']}' ,  '{$_POST['Date']}' ,  '{$_POST['KbnProjects_Id']}' ,  '{$_POST['KbnNotes_Id']}' ,  '{$_POST['KbnStates_Id']}'  ); "; 
    
    // mysql_query($sql) or die(mysql_error()); 
    $wpdb->query($wpdb->prepare($sql)); // Query
    
    echo "Added row.<br />"; 
    } 
    ?>
    
    <form action='' method='POST'> 
    <p><b>Id:</b><br /><input type='text' name='Id'/> 
    <p><b>Date:</b><br /><input type='text' name='Date'/> 
    <p><b>KbnProjects Id:</b><br /><input type='text' name='KbnProjects_Id'/> 
    <p><b>KbnNotes Id:</b><br /><input type='text' name='KbnNotes_Id'/> 
    <p><b>KbnStates Id:</b><br /><input type='text' name='KbnStates_Id'/> 
    <p><input type='submit' value='Add Row' /><input type='hidden' value='1' name='submitted' /> 
    </form>

    Phpscaffold genererer en kode, der næsten kan anvendes; men et par linjer skal rettes. For det føste skal wpdb gøres global. For det andet anvendes wpdb-klassen til at udføre en SQL query:

    <? global $wpdb; // henter klassen // include('config.php'); - denne linje slettes er ikke noedvendig if (isset($_POST['submitted'])) { foreach($_POST AS $key => $value) { $_POST[$key] = mysql_real_escape_string($value); } $sql = "INSERT INTO `KbnLog` ( `Id` , `Date` , `KbnProjects_Id` , `KbnNotes_Id` , `KbnStates_Id` ) VALUES( '{$_POST['Id']}' , '{$_POST['Date']}' , '{$_POST['KbnProjects_Id']}' , '{$_POST['KbnNotes_Id']}' , '{$_POST['KbnStates_Id']}' ); "; // linjen herunder skal aendres til en wpdb klasse // se denne vejledning http://codex.wordpress.org/Class_Reference/wpdb // mysql_query($sql) or die(mysql_error()); // sikkerhed: brug wp prepare // echo $sql; // rens evt. m. prepare $wpdb->query($sql); // query //echo "Added row.<br />"; //echo "<a href='log-list.php'>Back To Listing</a>"; } ?> <form action='' method='POST'> <p><b>Id:</b><br /><input type='text' name='Id'/> <p><b>Date:</b><br /><input type='text' name='Date'/> <p><b>KbnProjects Id:</b><br /><input type='text' name='KbnProjects_Id'/> <p><b>KbnNotes Id:</b><br /><input type='text' name='KbnNotes_Id'/> <p><b>KbnStates Id:</b><br /><input type='text' name='KbnStates_Id'/> <p><input type='submit' value='Add Row' /><input type='hidden' value='1' name='submitted' /> </form>

    Phpscaffolds kildekode burde relativt enkelt kunne redigeres til at “kompilere” en WordPress egnet kode; men det et andet projekt.

    Ovenstående kode beskytter ikke mod forsøg på SQL-indsprøjtninger. Ved hjælp af prepare opnås en bedre beskyttelse. Wpdblinjen skal se sådan ud:

    $wpdb->query($wpdb->prepare($sql));

    Den rensede kode ser herefter sådan ud:

    <? 
    global $wpdb; // henter klassen
    
    if (isset($_POST['submitted'])) { 
    foreach($_POST AS $key => $value) { $_POST[$key] = mysql_real_escape_string($value); } 
    $sql = "INSERT INTO `KbnLog` ( `Id` ,  `Date` ,  `KbnProjects_Id` ,  `KbnNotes_Id` ,  `KbnStates_Id`  ) VALUES(  '{$_POST['Id']}' ,  '{$_POST['Date']}' ,  '{$_POST['KbnProjects_Id']}' ,  '{$_POST['KbnNotes_Id']}' ,  '{$_POST['KbnStates_Id']}'  ); "; 
    
    $wpdb->query($wpdb->prepare($sql)); // Query
    
    echo "Added row.<br />"; 
    } 
    ?>
    
    <form action='' method='POST'> 
    <p><b>Id:</b><br /><input type='text' name='Id'/> 
    <p><b>Date:</b><br /><input type='text' name='Date'/> 
    <p><b>KbnProjects Id:</b><br /><input type='text' name='KbnProjects_Id'/> 
    <p><b>KbnNotes Id:</b><br /><input type='text' name='KbnNotes_Id'/> 
    <p><b>KbnStates Id:</b><br /><input type='text' name='KbnStates_Id'/> 
    <p><input type='submit' value='Add Row' /><input type='hidden' value='1' name='submitted' /> 
    </form>

    I stedet for at rette global-linjen i alle filerne kan man bevare include(‘config.php’); – og lave en phpfil med dette indhold:

    <?php global $wpdb; ?>
  • Dagens arbejde består i at få phpscaffold til at generere en kode, der kan bruges af WordPress. Jeg tager udgangspunkt i en relativt enkel tabel.

    1. Generere “stillads”.
    2. Omdanne “stilladset” til en WP plugin i Dashboard.
    ER-golden
    ER-diagram for webkanban.

    Phpscaffold skaber fire CRUD-filer og forudsætter import af en databasekonfigurationsfil.

    Phpscaffold eksempel
    Phpscaffold eksempel
  • I den kommende uge vil jeg prøve at programmere en fungerende prototype til en webkanban ved hjælp af phpscaffold. Databasen er eksporteret til min server, så nu kan arbejdet begynde. Regner med at der skabes en simpel CRUD-funktionalitet.

    CRUD skal betjenes via et administrationspanel i WP. Det skal desuden være muligt at editere de enkelte “tegn” via en knap, der leder til et redigeringsfelt.

    Når “stilladset” er på plads skal en præsentationskanban programmeres. Der skal laves en shortcode, som looper gennem databasen. CSS formatterer alt efter skærmstørrelse.

    Mht. editor vil jeg arbejde med Pico og Emacs

  • Århus: På fredag afholdes seminar for masterstuderende, der skriver den sidste afhandling i forløbet. Man skal medbringe problemformulering mv.

  • Think again! Try to use some desk research. It’s not hard to find the amazing facts about Twitter.

    100 most popular Twitters
    100 most popular Twitters

    Let’s have a look at http://twittercounter.com/pages/100

    Lady Gaga was the most followed on Twitter. At the moment it’s Justin Bieber.

    Who – Justin Bieber
    Right now Justin Bieber is the most popular guy on Twitter. But – is it really Justin’s just tweeping his days away. His fingers must glow like red hot iron on the phone. Allegedly he’s the author of not less than some 20.000+ tweeps.

    That’s an amazing number of tweeps – especially if you compare to the tweeps of Lady Gaga. She tweeped around 2500 times or so.

    Kipling’s “six honest serving men”
    From the poem “Six Honest Serving Men” from “The Elephant’s Child” you can learn how to analyze communication:

    I KEEP six honest serving-men
    (They taught me all I knew);
    Their names are What and Why and When
    And How and Where and Who.
    I send them over land and sea,

    I send them east and west;
    But after they have worked for me,
    I give them all a rest.
    I let them rest from nine till five,
    For I am busy then,
    As well as breakfast, lunch, and tea,
    For they are hungry men.
    But different folk have different views;

    I know a person small—
    She keeps ten million serving-men,
    Who get no rest at all!
    She sends’em abroad on her own affairs,
    From the second she opens her eyes—
    One million Hows, two million Wheres,
    And seven million Whys!

     

    What – Twitter

    So where are we? Twitter is a micro blog. You can post max 140 characters. That’s it. You can also post images, video or sound. Twitter is for short statements. It sounds boring. But professional authors and artists can reach out to a big audience.

    When – anytime
    Justin can tweep anytime – at least if he’s in reach of the internet somehow. He might use a browser – or his smartphone. Whatever device he prefers there might be some app where he can write his updates.

    An so he did. 20.000+ times. That’s a lot of micro blogging.

    Why – the most important question!
    The most important question is: “Why?”. Do you really think that this is just Mr. Bieber having fun? When I click send around 60 persons will receive my tweep. When Justin does the same thing

    33.728.223 

    can read his tweeps. That’s a lot of readers.

    To me Twitter may be a kind of social media. But when you reach out to millions of readers it’s not a passtime any more. It’s hardly a hobby. So for people like Justin Bieber Twitter is a mass media channel.

    In comes Laswell’s classic communication model:

     Who is the author?
    It could be Justin. At least some of the time. But the page looks strangely welldesigned. It’s nice in an almost boring way. Here it is relevant to ask yourself – is the page really made by Justin – or do you think that a ghostwriter is afoot? Are the pictures really made by Justin?

    • Did Justin write all of the text, some of it or nothing whatsoever? 
    • Can Justin really read the tweeps from the 123.772 persons he follows?
    • Will this page even pass a Turing test? (Could we suspect robotic activities here?)

    Perhaps part of the site is made by professionals. Perhaps all of it. If somebody was payed to help Justin they did a good job if you can take the number of followers as a sign of such a thing.  Have a good look at the site.

    Justin Bieber on Twitter
    Justin Bieber on Twitter – so nice, sooo boring.

    Have a good look at this – and the other 100 most poplar Twitter sites. Asking yourself who the sender really is might light a candle. So from the point of view of the multimedia programme you can say, that:

    • Twitter is business
    • Twitter is communication
    • Twitter is webdesign
    • Twitter is interaction
  • I begyndelsen af januar scorede teamet en opslagstavle og aftalte korte ugentlige scrummøder i en frokostpause. Scrumboardet er ikke kommet fra start, fordi vi mangler … af alle ting … knappenåle.

  • Bruger phpscaffold.com til at lave et stativ af filer til editering af kanban databasen. Resultatet er 16 filer, der igen skal tilrettes til et WordPress miljø. Hvis det virker, så har jeg sparet mange timers arbejde.

    Lige nu eksperimenterer jeg med sed i bash (og her er det jo herligt at Macs terminal er en unixklon!). Det må være muligt at fjerne og editere linjer en masse via en trunkering a la *.php. Det er dog ikke lykkedes at fjerne mønstre i mere end én fil endnu.

    De 16 filer skal have fjernet linje 1 – og tabellerne skal formatteres ordentligt (border = 1 er ikke kønt, og friseringen bør ligge i css – border = 1 bør ændres til en class).

    Lægger hovedet i blød for en smart sed – eller noget i den stil…

  • Jeg havde sat en virtualbox linux server op; men den kører alt for langsomt på en Mac. Så nu er filerne exporteret til en anden lokal server.

  • Phpscaffold skaber en række filer, der kan inkluderes i et plugin. Men filerne skal editeres en anelse. Linjen include(‘config.php’);  skal fjernes, og resten burde teoretisk set fungere a la det her:

    $Id = (int) $_GET['Id']; 
    // mysql_query("DELETE FROM `kbnNotes` WHERE `Id` = '$Id' ") ; 
    $wpdb->query("DELETE FROM `kbnNotes` WHERE `Id` = '$Id' ");
    echo (mysql_affected_rows()) ? "Row deleted.<br /> " : "Nothing deleted.<br /> ";

    (NB: jeg har ikke afprøvet koden endnu, så det her er kun noter…)

  • Efter lidt søgen på nettet med nøgleord som “CRUD” og “PHP” faldt jeg over http://www.phpscaffold.com/ – hvis det fungerer, så sparer man en masse tid. Scaffolding er et glansnummer som CakePHP, Symphony, Ruby on Rails – og andre MVC frameworks kan udføre. Mindre kan altså gøre det. Herligt site 🙂

    Phpscaffold

    Det skal da afprøves. Jeg vil se om dette stillads virker sammen med mit kanban plugin. Hvis det fungerer kan man spare mange timers arbejde i pico.

    Includefilen må kunne ændres til noget, som $wpdb forstår.

  • Indrømmet – drag and drop er lækkert. Funktionen giver de samme metaforiske oplevelser som et grafisk skrivebordsmiljø. Men HTML5 og CSS3 er ikke en standard endnu. Ældre browsere vil ikke understøtte metoderne.

    Derfor fravælger jeg drag and drop.

  • MULTIMUSEN-2004
    Multimusen som den så ud i 2004. Skærmdump fra way back machine.

    Konstaterer, at multimusen.dk er ni år gammel:

    Domain: multimusen.dk
    DNS: multimusen.dk
    Registered: 2003-12-02

Enable Notifications OK No thanks

We use cookies - more information

Multimusen.dk will set a few cookies from Doubleclick, Google and the Social Media plugins they ay set some cookies. Some of my pages use APIs - such as YouTube, LinkedIn, Google Fonts, Google Maps, Mapbox, Spotify, Jetpack, Twitter, Facebook &c.. Such plugins may set the odd cookie.

Close