SlideShare ist ein Scribd-Unternehmen logo
1 von 35
Downloaden Sie, um offline zu lesen
Using Geeklog as a
 Web Application
   Framework
        Dirk Haun
      www.geeklog.net




   Creative Commons Attribution-NonCommercial 2.5 License
What is Geeklog?
Geeklog is a PHP/MySQL based application
for managing dynamic web content.

• post quot;newsquot;
• syndication
• comments
• trackbacks
• spam protection
groklaw.net
macfixit.com
... and many others ...
Why use Geeklog?

• News + Static content
• Extensibility
• Hierarchical Groups
  & Permissions

• Focus on Security
• Open Source
When not to use Geeklog

When your
requirements include ...

• complex workflows
• interaction with
  proprietory protocols
  or applications

... then you'd better use
something else.
Requirements

• PHP 4.1.0 or later
• MySQL 3.23.2 or later
  (Microsoft SQL Server
  under development)

• Apache (any version),
  Zeus, IIS
Groups & Permissions


• Give access only to
  certain groups

• Inherit from groups:
  Hierarchies

• 'Rights' to fine-tune
  access
Groups
Rights
Permissions
Integration Options

• PHP Blocks
• Static Pages




                          (c) m.wickenkamp
• Hooks and Callbacks
• quot;roll your ownquot;
• Plugin API
PHP Blocks

                           function phpblock_whos_new()

• a PHP function that      {
                               global $_CONF, $_TABLES;

  returns something to         $result = DB_query(quot;SELECT uid,username,photo FROM {$_TABLES
                           ['users']} WHERE status <> 0 ORDER BY regdate DESC LIMIT 5quot;);

  be displayed in a side       $nrows = DB_numRows($result);
                               for ($i = 0; $i < $nrows; $i++) {
  block                            $A = DB_fetchArray($result);
                                   $retval .= '<a href=quot;' . $_CONF['site_url'] . '/
                           users.php?mode=profile&amp;uid=' . $A['uid'] . 'quot;>' . $A
                           ['username'] . '</a>';


• prefix phpblock_                   if (!empty($A['photo'])) {
                                        $retval .= ' <a href=quot;' . $_CONF['site_url'] .
                             '/users.php?mode=profile&amp;uid=' . $A['uid'] . 'quot;><img
                           src=quot;' . $_CONF['layout_url'] . '/images/smallcamera.gifquot;


• located in lib-
                           border=quot;0quot; alt=quot;quot;></a>';
                                    }
                                    $retval .= '<br>';

  custom.php                    }
                                return $retval;
                           }
PHP Blocks

• a PHP function that
  returns something to
  be displayed in a side
  block

• prefix phpblock_
• located in lib-
  custom.php
Static Pages

                          global $_CONF, $_TABLES, $_DB_table_prefix;


• despite the name,       $_TABLES['topstories'] = $_DB_table_prefix . 'topstories';

                          $top = '<p>The 25 most visited stories during the last 8

  Static Pages can also   days:</p>';


  contain PHP code
                          $result = DB_query (quot;SELECT sid,hits FROM {$_TABLES
                          ['topstories']} ORDER BY hits DESCquot;);
                          $num = DB_numRows ($result);

                          $top .= '<ol>';

• good for integrating    for ($i = 0; $i < $num; $i++) {
                              list($sid, $hits) = DB_fetchArray ($result);

  short scripts               $top .= '<li><a href=quot;' . COM_buildUrl ($_CONF
                          ['site_url'] . '/article.php?story=' . $sid) . 'quot;>' .
                          stripslashes (DB_getItem ($_TABLES['stories'], 'title', quot;sid
                          = '$sid'quot;)) . '</a> (' . $hits . ')</li>';
                          }

• often used for forms    $top .= '</ol>';

                          return $top;
Static Pages


• despite the name,
  Static Pages can also
  contain PHP code

• good for integrating
  short scripts

• often used for forms
Hooks and Callbacks

• Custom registration    /**
  functions              * Check if it's okay to create a new user.
                         */
                         function CUSTOM_userCheck ($username, $email)

• Dynamic block
                         {
                             $msg = '';

  functions                  //   Example: check that the new user has
                             //   entered their full name and complain
                             //   if it's missing

• PHP in theme headers       if   (empty ($_POST['fullname'])) {
                                   $msg = 'Please enter your full name!';
                             }

• Override some built-   }
                             return $msg;

  in functions
Roll your own


• include lib-           <?php

    common.php           require_once('lib-common.php');


•   emit site header     echo COM_siteHeader();

                         // your code here
• do whatever you want
                         echo COM_siteFooter();

• emit site footer       ?>
Plugin API


• more than 50 API
  functions

• almost all optional
• central install /
  uninstall
plugin_getwhatsnew_
                              plugin_group_changed_
                              plugin_handlepingoperation_
                              plugin_install_
  plugin_abortsave_
                              plugin_ismoderator_
  plugin_autotags_
                              plugin_itemsaved_
  plugin_cclabel_
                              plugin_moderationapprove_
  plugin_centerblock_
                              plugin_moderationdelete_
  plugin_checkforSpam_
                              plugin_moderationvalues_
  plugin_chkVersion_
                              plugin_profileblocksdisplay_
  plugin_commentPreSave_
                              plugin_profileblocksedit_
  plugin_deletecomment_
                              plugin_profileextrassave_
  plugin_displaycomment_
                              plugin_profilevariablesedit_
  plugin_dopluginsearch_
                              plugin_runScheduledTask_
  plugin_feedExtensionTags_
                              plugin_savecomment_
  plugin_feedNSExtensions_
                              plugin_savesubmission_
  plugin_feedupdatecheck_
                              plugin_searchtypes_
  plugin_getBlocks_
                              plugin_showstats_
  plugin_getadminoption_
                              plugin_statssummary_
  plugin_getcommenturlid_
                              plugin_submissioncount_
  plugin_getfeedcontent_
                              plugin_submit_
  plugin_getfeednames_
                              plugin_templatesetvars_
  plugin_getheadercode_
                              plugin_uninstall_
  plugin_geticon_
                              plugin_upgrade_
  plugin_getiteminfo_
                              plugin_user_changed_
  plugin_getmenuitems_
                              plugin_user_create_
                              plugin_user_delete_
                              plugin_user_login_


Plugin API functions
                              plugin_user_logout_
                              plugin_whatsnewsupported_
/**
  * This will put an option for static pages in the
  * quot;command and controlquot; block on moderation.php
  */
  function plugin_cclabel_staticpages()
  {
      global $_CONF, $LANG_STATIC;

      if (SEC_hasRights
  ('staticpages.edit,staticpages.delete', 'OR')) {
          return array ($LANG_STATIC['staticpages'],
                  $_CONF['site_admin_url'] .
                    '/plugins/staticpages/index.php',
                  plugin_geticon_staticpages ());
      }

      return false;
  }




Sample API function
function plugin_autotags_staticpages ($op, $content = '',
                                        $autotag = '')
  {
      global $_CONF, $_TABLES;

      if ($op == 'tagname' ) {
          return 'staticpage';
      } else if ($op == 'parse') {
          $sp_id = COM_applyFilter ($autotag['parm1']);
          if (empty ($autotag['parm2'])) {
              $linktext = DB_getItem ($_TABLES['staticpage'],
                           'sp_title', quot;sp_id = '$sp_id'quot;);
          } else {
              $linktext = $autotag['parm2'];
          }
          $url = COM_buildUrl ($_CONF['site_url'] .
                     '/staticpages/index.php?page=' . $sp_id);
          $link = '<a href=quot;' . $url . 'quot;>' . $linktext .
                   '</a>';
          $content = str_replace ($autotag['tagstr'], $link,
                                   $content);

          return $content;
      }
  }




[staticpage:] autotag
Geeklog vs.
    other frameworks
Why not use a modern, object oriented
framework?
  • object oriented; database
    abstraction layer; XML; ...
If you have the resources and the time,
then by all means do it!
  • i.e. hardware and software
    requirements; develop new code
Existing Integrations


• Gallery (1.x and 2.x)
• phpBB
• EWiki
  (MediaWiki under
  development)
Practical problems
• Name clashes         ➡ no good solution
• Database tables      ➡ use a prefix
• Syncing userdata     ➡ depends ...
• Login                ➡ tricky, but doable
• Security models      ➡ leave as is
• CSS and JavaScript   ➡ doable
  conflicts
The Real World Dilemma

In an ideal world ...

• all code would be
  object oriented

• there would be
  namespaces

... and hence no name
clashes
The Real World Dilemma

However, ...

• a lot of real-world
  code is not object
  oriented

• PHP does not have
  namespaces

... hence you will have to
deal with name clashes
Function Prefixes
always there:    may also be there:

• COM_           • ADMIN_
• CUSTOM_        • CMT_
• DB_            • PNB_
• MBYTE_         • STORY_
• PLG_           • SYND_
• SEC_           • TRB_
• SESS_          • USER_
What to do in case of
 integration problems?

• Talk to the developers
  - both parties!




                           (c) elfi kaut
• If nothing else helps:
  Fork it!
To get you started


• Plugin Developer's
  Guide

  ➡ Universal Plugin
     (skeleton code)

• Look at the existing
  plugins ...
Resources

• wiki.geeklog.net
• mailing lists:
  • geeklog-devtalk
  • geeklog-modules
• www.geeklog.net
Problems?
Talk to us!
Thanks


• Sebastian Celis
• Andy Maloney
• Euan McKay
Photos: flickr.com
coba                                                   elfis gallery
                                                       (c) elfi kaut


Giant Ginkgo                                           sfegette

fallsroad                                              digital-blink

massenpunkt                                            gojumeister
besides                                                manuki
(c) m.wickenkamp


jmsmytaste

    Photos released under the Creative Commons license, unless otherwise noted.

Weitere ähnliche Inhalte

Was ist angesagt?

Php login system with admin features evolt
Php login system with admin features   evoltPhp login system with admin features   evolt
Php login system with admin features evolt
GIMT
 
The state of Symfony2 - SymfonyDay 2010
The state of Symfony2 - SymfonyDay 2010The state of Symfony2 - SymfonyDay 2010
The state of Symfony2 - SymfonyDay 2010
Fabien Potencier
 
PHP 5.3 Overview
PHP 5.3 OverviewPHP 5.3 Overview
PHP 5.3 Overview
jsmith92
 
OSDC 2009 Rails Turtorial
OSDC 2009 Rails TurtorialOSDC 2009 Rails Turtorial
OSDC 2009 Rails Turtorial
Yi-Ting Cheng
 
Action View Form Helpers - 1, Season 2
Action View Form Helpers - 1, Season 2Action View Form Helpers - 1, Season 2
Action View Form Helpers - 1, Season 2
RORLAB
 

Was ist angesagt? (20)

PhpBB meets Symfony2
PhpBB meets Symfony2PhpBB meets Symfony2
PhpBB meets Symfony2
 
Symfony2 - OSIDays 2010
Symfony2 - OSIDays 2010Symfony2 - OSIDays 2010
Symfony2 - OSIDays 2010
 
Php login system with admin features evolt
Php login system with admin features   evoltPhp login system with admin features   evolt
Php login system with admin features evolt
 
WordPress REST API hacking
WordPress REST API hackingWordPress REST API hacking
WordPress REST API hacking
 
The state of Symfony2 - SymfonyDay 2010
The state of Symfony2 - SymfonyDay 2010The state of Symfony2 - SymfonyDay 2010
The state of Symfony2 - SymfonyDay 2010
 
PHP 5.3 Overview
PHP 5.3 OverviewPHP 5.3 Overview
PHP 5.3 Overview
 
The Enterprise Wor/d/thy/Press
The Enterprise Wor/d/thy/PressThe Enterprise Wor/d/thy/Press
The Enterprise Wor/d/thy/Press
 
Zero to SOLID
Zero to SOLIDZero to SOLID
Zero to SOLID
 
New: Two Methods of Installing Drupal on Windows XP with XAMPP
New: Two Methods of Installing Drupal on Windows XP with XAMPPNew: Two Methods of Installing Drupal on Windows XP with XAMPP
New: Two Methods of Installing Drupal on Windows XP with XAMPP
 
New in php 7
New in php 7New in php 7
New in php 7
 
OSDC 2009 Rails Turtorial
OSDC 2009 Rails TurtorialOSDC 2009 Rails Turtorial
OSDC 2009 Rails Turtorial
 
Login and Registration form using oop in php
Login and Registration form using oop in phpLogin and Registration form using oop in php
Login and Registration form using oop in php
 
Php Security
Php SecurityPhp Security
Php Security
 
Slimme Joomla! Templating Tips en Truuks
Slimme Joomla! Templating Tips en TruuksSlimme Joomla! Templating Tips en Truuks
Slimme Joomla! Templating Tips en Truuks
 
Single Page Web Apps As WordPress Admin Interfaces Using AngularJS & The Word...
Single Page Web Apps As WordPress Admin Interfaces Using AngularJS & The Word...Single Page Web Apps As WordPress Admin Interfaces Using AngularJS & The Word...
Single Page Web Apps As WordPress Admin Interfaces Using AngularJS & The Word...
 
Service approach for development Rest API in Symfony2
Service approach for development Rest API in Symfony2Service approach for development Rest API in Symfony2
Service approach for development Rest API in Symfony2
 
Silex Cheat Sheet
Silex Cheat SheetSilex Cheat Sheet
Silex Cheat Sheet
 
Action View Form Helpers - 1, Season 2
Action View Form Helpers - 1, Season 2Action View Form Helpers - 1, Season 2
Action View Form Helpers - 1, Season 2
 
Symfony without the framework
Symfony without the frameworkSymfony without the framework
Symfony without the framework
 
Api Design
Api DesignApi Design
Api Design
 

Andere mochten auch

People &amp; Performance UK
People &amp; Performance UKPeople &amp; Performance UK
People &amp; Performance UK
tn
 

Andere mochten auch (18)

Atom Publishing Protocol
Atom Publishing ProtocolAtom Publishing Protocol
Atom Publishing Protocol
 
Is C going the way of the Dodo?
Is C going the way of the Dodo?Is C going the way of the Dodo?
Is C going the way of the Dodo?
 
Webspam (English Version)
Webspam (English Version)Webspam (English Version)
Webspam (English Version)
 
Send Sms
Send SmsSend Sms
Send Sms
 
Google Summer of Code 2010 (in English)
Google Summer of Code 2010 (in English)Google Summer of Code 2010 (in English)
Google Summer of Code 2010 (in English)
 
Google Summer of Code: Neue Mitstreiter mit Geld (und T-Shirts) gewinnen - kl...
Google Summer of Code: Neue Mitstreiter mit Geld (und T-Shirts) gewinnen - kl...Google Summer of Code: Neue Mitstreiter mit Geld (und T-Shirts) gewinnen - kl...
Google Summer of Code: Neue Mitstreiter mit Geld (und T-Shirts) gewinnen - kl...
 
Kurzeinführung: Atom Publishing Protocol
Kurzeinführung: Atom Publishing ProtocolKurzeinführung: Atom Publishing Protocol
Kurzeinführung: Atom Publishing Protocol
 
Rewriting not recommended
Rewriting not recommendedRewriting not recommended
Rewriting not recommended
 
Ribbit for Salesforce - General
Ribbit for Salesforce - GeneralRibbit for Salesforce - General
Ribbit for Salesforce - General
 
Google Summer of Code 2011 (English)
Google Summer of Code 2011 (English)Google Summer of Code 2011 (English)
Google Summer of Code 2011 (English)
 
People &amp; Performance UK
People &amp; Performance UKPeople &amp; Performance UK
People &amp; Performance UK
 
Google Summer of Code™ (in English; neutral version)
Google Summer of Code™ (in English; neutral version)Google Summer of Code™ (in English; neutral version)
Google Summer of Code™ (in English; neutral version)
 
Will Stacy Talks Productivity from Sales 2.0
Will Stacy Talks Productivity from Sales 2.0Will Stacy Talks Productivity from Sales 2.0
Will Stacy Talks Productivity from Sales 2.0
 
Continuous Integration - Does it scale?
Continuous Integration - Does it scale?Continuous Integration - Does it scale?
Continuous Integration - Does it scale?
 
Open Source is good for you
Open Source is good for youOpen Source is good for you
Open Source is good for you
 
What's our Status?
What's our Status?What's our Status?
What's our Status?
 
Continuous Integration in der Praxis
Continuous Integration in der PraxisContinuous Integration in der Praxis
Continuous Integration in der Praxis
 
Braindump - How to leave your Knowledge when leaving your Job
Braindump - How to leave your Knowledge when leaving your JobBraindump - How to leave your Knowledge when leaving your Job
Braindump - How to leave your Knowledge when leaving your Job
 

Ähnlich wie Using Geeklog as a Web Application Framework

10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
arcware
 
Intro To Mvc Development In Php
Intro To Mvc Development In PhpIntro To Mvc Development In Php
Intro To Mvc Development In Php
funkatron
 

Ähnlich wie Using Geeklog as a Web Application Framework (20)

Curso Symfony - Clase 4
Curso Symfony - Clase 4Curso Symfony - Clase 4
Curso Symfony - Clase 4
 
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
 
関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい
 
Framework
FrameworkFramework
Framework
 
Exploring Symfony's Code
Exploring Symfony's CodeExploring Symfony's Code
Exploring Symfony's Code
 
Intro To Mvc Development In Php
Intro To Mvc Development In PhpIntro To Mvc Development In Php
Intro To Mvc Development In Php
 
Mojolicious
MojoliciousMojolicious
Mojolicious
 
WordPress as a Content Management System
WordPress as a Content Management SystemWordPress as a Content Management System
WordPress as a Content Management System
 
Php frameworks
Php frameworksPhp frameworks
Php frameworks
 
Best Practices in Plugin Development (WordCamp Seattle)
Best Practices in Plugin Development (WordCamp Seattle)Best Practices in Plugin Development (WordCamp Seattle)
Best Practices in Plugin Development (WordCamp Seattle)
 
Как получить чёрный пояс по WordPress?
Как получить чёрный пояс по WordPress?Как получить чёрный пояс по WordPress?
Как получить чёрный пояс по WordPress?
 
Create a web-app with Cgi Appplication
Create a web-app with Cgi AppplicationCreate a web-app with Cgi Appplication
Create a web-app with Cgi Appplication
 
Extend sdk
Extend sdkExtend sdk
Extend sdk
 
Curso Symfony - Clase 3
Curso Symfony - Clase 3Curso Symfony - Clase 3
Curso Symfony - Clase 3
 
Becoming a better WordPress Developer
Becoming a better WordPress DeveloperBecoming a better WordPress Developer
Becoming a better WordPress Developer
 
What's new in Rails 2?
What's new in Rails 2?What's new in Rails 2?
What's new in Rails 2?
 
I Love codeigniter, You?
I Love codeigniter, You?I Love codeigniter, You?
I Love codeigniter, You?
 
ActiveWeb: Chicago Java User Group Presentation
ActiveWeb: Chicago Java User Group PresentationActiveWeb: Chicago Java User Group Presentation
ActiveWeb: Chicago Java User Group Presentation
 
CodeIgniter PHP MVC Framework
CodeIgniter PHP MVC FrameworkCodeIgniter PHP MVC Framework
CodeIgniter PHP MVC Framework
 
Curso Symfony - Clase 2
Curso Symfony - Clase 2Curso Symfony - Clase 2
Curso Symfony - Clase 2
 

Mehr von Dirk Haun

Mehr von Dirk Haun (17)

Reverse Bildersuche mit TinEye
Reverse Bildersuche mit TinEyeReverse Bildersuche mit TinEye
Reverse Bildersuche mit TinEye
 
Vorsicht, Kamera!
Vorsicht, Kamera!Vorsicht, Kamera!
Vorsicht, Kamera!
 
Vorsicht Kamera!
Vorsicht Kamera!Vorsicht Kamera!
Vorsicht Kamera!
 
Botschaften optimieren für Erinnerung und Verbreitung
Botschaften optimieren für Erinnerung und VerbreitungBotschaften optimieren für Erinnerung und Verbreitung
Botschaften optimieren für Erinnerung und Verbreitung
 
Smile, you're on camera!
Smile, you're on camera!Smile, you're on camera!
Smile, you're on camera!
 
What's our Status?
What's our Status?What's our Status?
What's our Status?
 
Google Summer of Code 2012
Google Summer of Code 2012Google Summer of Code 2012
Google Summer of Code 2012
 
Geeklog: The secure CMS.
Geeklog: The secure CMS.Geeklog: The secure CMS.
Geeklog: The secure CMS.
 
Google Summer of Code 2011 (German)
Google Summer of Code 2011 (German)Google Summer of Code 2011 (German)
Google Summer of Code 2011 (German)
 
Apple iPad als Reisebegleiter
Apple iPad als ReisebegleiterApple iPad als Reisebegleiter
Apple iPad als Reisebegleiter
 
Verteilte Versionskontrolle in der Praxis
Verteilte Versionskontrolle in der PraxisVerteilte Versionskontrolle in der Praxis
Verteilte Versionskontrolle in der Praxis
 
Verteilte Versionskontrolle in der Praxis
Verteilte Versionskontrolle in der PraxisVerteilte Versionskontrolle in der Praxis
Verteilte Versionskontrolle in der Praxis
 
Adventures in QA
Adventures in QAAdventures in QA
Adventures in QA
 
Google Summer of Code 2010 (in German)
Google Summer of Code 2010 (in German)Google Summer of Code 2010 (in German)
Google Summer of Code 2010 (in German)
 
GSoC@Webmontag (in German)
GSoC@Webmontag (in German)GSoC@Webmontag (in German)
GSoC@Webmontag (in German)
 
Google Summer of Code™ (in German)
Google Summer of Code™ (in German)Google Summer of Code™ (in German)
Google Summer of Code™ (in German)
 
Google Summer of Code™ (in German; neutral version)
Google Summer of Code™ (in German; neutral version)Google Summer of Code™ (in German; neutral version)
Google Summer of Code™ (in German; neutral version)
 

Kürzlich hochgeladen

Kürzlich hochgeladen (20)

AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 

Using Geeklog as a Web Application Framework

  • 1. Using Geeklog as a Web Application Framework Dirk Haun www.geeklog.net Creative Commons Attribution-NonCommercial 2.5 License
  • 2. What is Geeklog? Geeklog is a PHP/MySQL based application for managing dynamic web content. • post quot;newsquot; • syndication • comments • trackbacks • spam protection
  • 5. ... and many others ...
  • 6. Why use Geeklog? • News + Static content • Extensibility • Hierarchical Groups & Permissions • Focus on Security • Open Source
  • 7. When not to use Geeklog When your requirements include ... • complex workflows • interaction with proprietory protocols or applications ... then you'd better use something else.
  • 8. Requirements • PHP 4.1.0 or later • MySQL 3.23.2 or later (Microsoft SQL Server under development) • Apache (any version), Zeus, IIS
  • 9. Groups & Permissions • Give access only to certain groups • Inherit from groups: Hierarchies • 'Rights' to fine-tune access
  • 13. Integration Options • PHP Blocks • Static Pages (c) m.wickenkamp • Hooks and Callbacks • quot;roll your ownquot; • Plugin API
  • 14. PHP Blocks function phpblock_whos_new() • a PHP function that { global $_CONF, $_TABLES; returns something to $result = DB_query(quot;SELECT uid,username,photo FROM {$_TABLES ['users']} WHERE status <> 0 ORDER BY regdate DESC LIMIT 5quot;); be displayed in a side $nrows = DB_numRows($result); for ($i = 0; $i < $nrows; $i++) { block $A = DB_fetchArray($result); $retval .= '<a href=quot;' . $_CONF['site_url'] . '/ users.php?mode=profile&amp;uid=' . $A['uid'] . 'quot;>' . $A ['username'] . '</a>'; • prefix phpblock_ if (!empty($A['photo'])) { $retval .= ' <a href=quot;' . $_CONF['site_url'] . '/users.php?mode=profile&amp;uid=' . $A['uid'] . 'quot;><img src=quot;' . $_CONF['layout_url'] . '/images/smallcamera.gifquot; • located in lib- border=quot;0quot; alt=quot;quot;></a>'; } $retval .= '<br>'; custom.php } return $retval; }
  • 15. PHP Blocks • a PHP function that returns something to be displayed in a side block • prefix phpblock_ • located in lib- custom.php
  • 16. Static Pages global $_CONF, $_TABLES, $_DB_table_prefix; • despite the name, $_TABLES['topstories'] = $_DB_table_prefix . 'topstories'; $top = '<p>The 25 most visited stories during the last 8 Static Pages can also days:</p>'; contain PHP code $result = DB_query (quot;SELECT sid,hits FROM {$_TABLES ['topstories']} ORDER BY hits DESCquot;); $num = DB_numRows ($result); $top .= '<ol>'; • good for integrating for ($i = 0; $i < $num; $i++) { list($sid, $hits) = DB_fetchArray ($result); short scripts $top .= '<li><a href=quot;' . COM_buildUrl ($_CONF ['site_url'] . '/article.php?story=' . $sid) . 'quot;>' . stripslashes (DB_getItem ($_TABLES['stories'], 'title', quot;sid = '$sid'quot;)) . '</a> (' . $hits . ')</li>'; } • often used for forms $top .= '</ol>'; return $top;
  • 17. Static Pages • despite the name, Static Pages can also contain PHP code • good for integrating short scripts • often used for forms
  • 18. Hooks and Callbacks • Custom registration /** functions * Check if it's okay to create a new user. */ function CUSTOM_userCheck ($username, $email) • Dynamic block { $msg = ''; functions // Example: check that the new user has // entered their full name and complain // if it's missing • PHP in theme headers if (empty ($_POST['fullname'])) { $msg = 'Please enter your full name!'; } • Override some built- } return $msg; in functions
  • 19. Roll your own • include lib- <?php common.php require_once('lib-common.php'); • emit site header echo COM_siteHeader(); // your code here • do whatever you want echo COM_siteFooter(); • emit site footer ?>
  • 20. Plugin API • more than 50 API functions • almost all optional • central install / uninstall
  • 21. plugin_getwhatsnew_ plugin_group_changed_ plugin_handlepingoperation_ plugin_install_ plugin_abortsave_ plugin_ismoderator_ plugin_autotags_ plugin_itemsaved_ plugin_cclabel_ plugin_moderationapprove_ plugin_centerblock_ plugin_moderationdelete_ plugin_checkforSpam_ plugin_moderationvalues_ plugin_chkVersion_ plugin_profileblocksdisplay_ plugin_commentPreSave_ plugin_profileblocksedit_ plugin_deletecomment_ plugin_profileextrassave_ plugin_displaycomment_ plugin_profilevariablesedit_ plugin_dopluginsearch_ plugin_runScheduledTask_ plugin_feedExtensionTags_ plugin_savecomment_ plugin_feedNSExtensions_ plugin_savesubmission_ plugin_feedupdatecheck_ plugin_searchtypes_ plugin_getBlocks_ plugin_showstats_ plugin_getadminoption_ plugin_statssummary_ plugin_getcommenturlid_ plugin_submissioncount_ plugin_getfeedcontent_ plugin_submit_ plugin_getfeednames_ plugin_templatesetvars_ plugin_getheadercode_ plugin_uninstall_ plugin_geticon_ plugin_upgrade_ plugin_getiteminfo_ plugin_user_changed_ plugin_getmenuitems_ plugin_user_create_ plugin_user_delete_ plugin_user_login_ Plugin API functions plugin_user_logout_ plugin_whatsnewsupported_
  • 22. /** * This will put an option for static pages in the * quot;command and controlquot; block on moderation.php */ function plugin_cclabel_staticpages() { global $_CONF, $LANG_STATIC; if (SEC_hasRights ('staticpages.edit,staticpages.delete', 'OR')) { return array ($LANG_STATIC['staticpages'], $_CONF['site_admin_url'] . '/plugins/staticpages/index.php', plugin_geticon_staticpages ()); } return false; } Sample API function
  • 23. function plugin_autotags_staticpages ($op, $content = '', $autotag = '') { global $_CONF, $_TABLES; if ($op == 'tagname' ) { return 'staticpage'; } else if ($op == 'parse') { $sp_id = COM_applyFilter ($autotag['parm1']); if (empty ($autotag['parm2'])) { $linktext = DB_getItem ($_TABLES['staticpage'], 'sp_title', quot;sp_id = '$sp_id'quot;); } else { $linktext = $autotag['parm2']; } $url = COM_buildUrl ($_CONF['site_url'] . '/staticpages/index.php?page=' . $sp_id); $link = '<a href=quot;' . $url . 'quot;>' . $linktext . '</a>'; $content = str_replace ($autotag['tagstr'], $link, $content); return $content; } } [staticpage:] autotag
  • 24. Geeklog vs. other frameworks Why not use a modern, object oriented framework? • object oriented; database abstraction layer; XML; ... If you have the resources and the time, then by all means do it! • i.e. hardware and software requirements; develop new code
  • 25. Existing Integrations • Gallery (1.x and 2.x) • phpBB • EWiki (MediaWiki under development)
  • 26. Practical problems • Name clashes ➡ no good solution • Database tables ➡ use a prefix • Syncing userdata ➡ depends ... • Login ➡ tricky, but doable • Security models ➡ leave as is • CSS and JavaScript ➡ doable conflicts
  • 27. The Real World Dilemma In an ideal world ... • all code would be object oriented • there would be namespaces ... and hence no name clashes
  • 28. The Real World Dilemma However, ... • a lot of real-world code is not object oriented • PHP does not have namespaces ... hence you will have to deal with name clashes
  • 29. Function Prefixes always there: may also be there: • COM_ • ADMIN_ • CUSTOM_ • CMT_ • DB_ • PNB_ • MBYTE_ • STORY_ • PLG_ • SYND_ • SEC_ • TRB_ • SESS_ • USER_
  • 30. What to do in case of integration problems? • Talk to the developers - both parties! (c) elfi kaut • If nothing else helps: Fork it!
  • 31. To get you started • Plugin Developer's Guide ➡ Universal Plugin (skeleton code) • Look at the existing plugins ...
  • 32. Resources • wiki.geeklog.net • mailing lists: • geeklog-devtalk • geeklog-modules • www.geeklog.net
  • 34. Thanks • Sebastian Celis • Andy Maloney • Euan McKay
  • 35. Photos: flickr.com coba elfis gallery (c) elfi kaut Giant Ginkgo sfegette fallsroad digital-blink massenpunkt gojumeister besides manuki (c) m.wickenkamp jmsmytaste Photos released under the Creative Commons license, unless otherwise noted.