Expat-IT Tech Bits

Home

Contact

Links

Search this site:

Categories:

/ (287)
  Admin/ (122)
    Apache/ (10)
      HTTPS-SSL/ (4)
      PHP/ (3)
      performance/ (2)
    Cherokee/ (1)
    LAN/ (4)
    LVM/ (6)
    Monitoring/ (2)
      munin/ (2)
    SSH/ (6)
    SSL/ (1)
    Samba/ (1)
    VPN-options/ (6)
      OpenVPN/ (1)
      SSH-Proxy/ (3)
      Tinc/ (1)
      sshuttle/ (1)
    backups/ (17)
      SpiderOak/ (1)
      backuppc/ (5)
      dirvish/ (1)
      misc/ (6)
      rdiff-backup/ (1)
      rsync/ (1)
      unison/ (2)
    commandLine/ (24)
      files/ (8)
      misc/ (10)
      network/ (6)
    crontab/ (1)
    databases/ (15)
      MSSQL/ (2)
      MySQL/ (8)
      Oracle/ (3)
      PostgreSQL/ (1)
    dynamicDNS/ (2)
    email/ (11)
      Dovecot/ (1)
      deliverability/ (1)
      misc/ (1)
      postfix/ (7)
      puppet/ (1)
    iptables/ (3)
    tripwire/ (1)
    virtualization/ (9)
      VMware/ (1)
      virtualBox/ (8)
  Coding/ (14)
    bash/ (1)
    gdb/ (1)
    git/ (3)
    php/ (5)
    python/ (4)
      Django/ (2)
  Education/ (1)
  Hosting/ (27)
    Amazon/ (18)
      EBS/ (3)
      EC2/ (10)
      S3/ (1)
      commandline/ (4)
    Godaddy/ (2)
    NearlyFreeSpeech/ (3)
    Rackspace/ (1)
    vpslink/ (3)
  Linux/ (30)
    Android/ (1)
    Awesome/ (3)
    CPUfreq/ (1)
    China/ (2)
    Debian/ (8)
      APT/ (3)
      WPA/ (1)
    audio/ (1)
    encryption/ (3)
    fonts/ (1)
    misc/ (6)
    remoteDesktop/ (1)
    router-bridge/ (3)
  SW/ (45)
    Micro$soft/ (1)
    browser/ (2)
      Chrome/ (1)
      Firefox/ (1)
    business/ (28)
      Drupal/ (9)
      KnowledgeTree/ (6)
      Redmine/ (2)
      SugarCRM/ (7)
      WebERP/ (2)
      WordPress/ (1)
      eGroupware/ (1)
    chat/ (1)
    email/ (1)
    fileSharing/ (2)
      btsync/ (1)
      mldonkey/ (1)
    graphics/ (2)
    research/ (2)
    website/ (6)
      blog/ (6)
        blosxom/ (3)
        rss2email/ (1)
        webgen/ (1)
  Security/ (15)
    IMchat/ (2)
    circumvention/ (2)
    cryptoCurrency/ (1)
    e-mail/ (4)
    greatFirewall/ (1)
    hacking/ (1)
    password/ (1)
    privacy/ (2)
    skype/ (1)
  Services/ (1)
    fileSharing/ (1)
  TechWriting/ (1)
  xHW/ (14)
    Lenovo/ (1)
    Motorola_A1200/ (2)
    Thinkpad_600e/ (1)
    Thinkpad_a21m/ (3)
    Thinkpad_i1300/ (1)
    Thinkpad_x24/ (1)
    USB_audio/ (1)
    scanner/ (1)
    wirelessCards/ (2)
  xLife/ (17)
    China/ (9)
      Beijing/ (5)
        OpenSource/ (3)
    Expatriation/ (1)
    Vietnam/ (7)

Archives:

  • 2016/07
  • 2016/05
  • 2016/02
  • 2016/01
  • 2015/12
  • 2015/11
  • 2015/06
  • 2015/01
  • 2014/12
  • 2014/11
  • 2014/10
  • 2014/09
  • 2014/07
  • 2014/04
  • 2014/02
  • 2014/01
  • 2013/12
  • 2013/10
  • 2013/08
  • 2013/07
  • 2013/06
  • 2013/05
  • 2013/04
  • 2013/02
  • 2013/01
  • 2012/12
  • 2012/10
  • 2012/09
  • 2012/08
  • 2012/07
  • 2012/06
  • 2012/05
  • 2012/04
  • 2012/03
  • 2012/01
  • 2011/12
  • 2011/11
  • 2011/10
  • 2011/09
  • 2011/08
  • 2011/07
  • 2011/06
  • 2011/05
  • 2011/04
  • 2011/02
  • 2010/12
  • 2010/11
  • 2010/10
  • 2010/09
  • 2010/08
  • 2010/07
  • 2010/06
  • 2010/05
  • 2010/04
  • 2010/03
  • 2010/02
  • 2010/01
  • 2009/12
  • 2009/11
  • 2009/10
  • 2009/09
  • 2009/08
  • 2009/07
  • 2009/06
  • 2009/05
  • 2009/04
  • 2009/03
  • 2009/02
  • 2009/01
  • 2008/12
  • 2008/11
  • 2008/10
  • 2008/09
  • Subscribe XML RSS Feed

    Creative Commons License
    This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
    PyBlosxom

    This site has no ads. To help with hosting, crypto donations are accepted:
    Bitcoin: 1JErV8ga9UY7wE8Bbf1KYsA5bkdh8n1Bxc
    Zcash: zcLYqtXYFEWHFtEfM6wg5eCV8frxWtZYkT8WyxvevzNC6SBgmqPS3tkg6nBarmzRzWYAurgs4ThkpkD5QgiSwxqoB7xrCxs

    Wed, 09 Sep 2009


    /SW/business/KnowledgeTree: Installing a New KnowledgeTree instance

    If this is a first install on a new server, this guide[1] is a must read. Some of the highlights:

    apt-get install apache2 php5 php5-curl php5-mysql mysql-server mysql-client xpdf zip unzip catdoc pstotext

    apt-get install python-reportlab python-imaging python-uno antiword sun-java5-jre sun-java5-bin lynx openoffice.org-java

    And do not forget to bump memory_limit up to at least 64 in /etc/php5/apache2/php.ini.

    Get the latest source tarball from here[2][3].

    In your desired web root, make a copy of knowledgetree for this instance, then sim link a simpler name, ie.

    tar -xvf ktdms-src-oss-3.5.4a.tgz 
    mv kt-dms-oss/ kt-dms-oss-3.5.4a
    ln -s kt-dms-oss-3.5.4a/ knowledgetree
    

    Give ownership to the web server process:

    chown -R www-data:www-data kt-dms-oss-3.5.4a
    Create a new MySQL database for the new instance:
    #  mysql -u root -p
    Enter password: mr4gvc7s
    mysql> create database apps_kt;
    mysql> grant all on apps_kt.* to 'apps_kt'@'%' identified by 'password';
    flush privileges;
    

    Edit config/config.ini to agree:

    dbName           = apps_kt
    dbUser           = apps_kt
    dbPass           = password
    dbAdminUser      = apps_kt
    dbAdminPass      = password
    
    Now import the database from sql/mysql/install:
    mysql -u root -p apps_kt < structure.sql
    mysql -u root -p apps_kt < data.sql
    
    Separate out the configuration and the data:
    mv knowledgetree/var/ kt-var
    mv knowledgetree/config/config.ini kt-config.ini
    cd knowledgetree
    ln -s ../kt-var/ var
    cd config/
    ln -s ../../kt-config.ini config.ini
    

    Now login to the new KnowledgeTree instance with the default:

    user: admin
    password: admin
    

    and change the admin password.

    Anticipated path for upgrading to a new version of Knowledgetree:

    [1] http://wiki.knowledgetree.com/Debian_4_Installation_Instructions#Grab_a_few_more_packages
    [2] http://www.knowledgetree.com/try-now/knowledgetree_open_source_download
    [3] http://www.knowledgetree.com/products/opensource/downloadopensource

    posted at: 08:46 | path: /SW/business/KnowledgeTree | permanent link to this entry

    Fri, 22 May 2009


    /SW/business/KnowledgeTree: Metadata and the KnowledgeTree REST API

    The only way I have personally been able to get this working is by patching KnowledgeTree. The problem is that there is a function get_packed_metadata in ktapi/KTAPIDocument.inc.php that expects to receive metadata in the form of an array. There is no way to pass an array through a URL as a POST parameter using PHP (at least, none that I have yet found....)

    What I have found is that the PHP serialize() / unserialize() functions are meant to get this job done: serialize() the array before passing, unserialize() it after passing, and then process the array on the receiving end. So I have added this chunk of code to the top of function get_packed_metadata in ktapi/KTAPIDocument.inc.php:

    if (!is_array($metadata)) { $metadata = unserialize($metadata); }

    And then if I serialize my metadata array before sending it into the API, everything works. The exact structure of the metadata array was also a bit of a hard-won mystery, so I will reproduce below an actual working metadata update snippet of code:

    <?php $url = 'https://apps.vancouversolidcomputing.com/kt-dms-oss-3.6.0/ktwebservice/KTWebService.php'; require_once('funCurlPost.php'); // ************************** // Login // ************************** $postfields = "method=login&password=123456&username=admin"; $response = curlPost($url, $postfields); $xml = new SimpleXMLElement($response); if( $xml->status_code != 0 ){ echo 'Error - authentication failed: ' . $xml->message; } else { $session_id = $xml->results; echo "Login successful, session ID = " . $session_id; } // *********************************** // Update document metadata // *********************************** $metadata = array( array( "fieldset" => "Tag Cloud", "fields" => array( array( "name" => "Tag", "value" => "Tag name from API call" ) ) ) ); $metadata = serialize($metadata); $postfields = "method=update_document_metadata&session_id=$session_id&document_id=36&metadata=$metadata"; $response = curlPost($url, $postfields); $xml = new SimpleXMLElement($response); echo "<p>Update document metadata:<br>"; if( $xml->status_code != 0 ){ echo 'Error - get_document_metadata failed: ' . $xml->message; } else { echo 'Metadata updated!!'; }

    I have posted on this subject to both the KnowledgeTree forum[1] and the issue tracker[2], and received just about zero response.

    I have a working example of a file upload followed by an add-document-with-metadata API operation, if anyone is interested in seeing that.

    [1] http://forums.knowledgetree.com/viewtopic.php?f=10&t=14291&p=31392#p31392
    [2] http://issues.knowledgetree.com/browse/WSA-169

    posted at: 00:03 | path: /SW/business/KnowledgeTree | permanent link to this entry

    Wed, 29 Apr 2009


    /SW/business/KnowledgeTree: Accessing the KnowledgeTree API

    KnowledgeTree[1] is a very popular server-based Open Source document management system. Something that some users (like me, or rather my clients) need to do is allow certain people to add or manipulate documents in KnowledgeTree without having to have a login ID and knowledge of the KnowledgeTree user interface. Enter the API, and a little custom PHP scripting....

    Oddly enough, I found at least three different documents on the wiki[2] that seemed to talk about three different approaches to using the API. Oddly (should I say suspiciously?) because the level of detail was just enough to be interesting, but just short of being useful. Ie. for two of them, I just could not figure it out. I even saw a post on the KnowledgeTree forum asking for more detail / a concrete example (me too! me too!) and the only reply was a curt link to one of the near useless wiki pages that I have already mentioned. And needless to say, my own post was ignored. Whats up? (Some conspiratorial possibilities come to mind....)

    The only API approach that I have been able to get working is the "REST web service framework"[3], which, for better or worse, only works as of the currently bleeding edge KnowledgeTree version 3.6.0 (will NOT work with current stable 3.5.4a). [3] is also sorely lacking in detail, but in combination with a little code surfing in

    knowledgetree/ktwebservice/webservice.php

    I was able to divine what was needed to get it working. Here I will hopefully provide some missing detail for Google to find....

    One can of course play with the KnowledgeTree REST web service through a browser, as the means of communication with the server is via POST parameters attached to the server URL. This is also a good way to see the exact format of the XML response the server gives back.

    To achieve the same result with PHP one must use libcurl through the PHP curl extension[4]. Since [4] is also a little skimpy on detail, [5] is a very useful supplement. To cut to the chase, I created a function as follows:

    <?php function curlPost($site, $fields){ $ch = curl_init(); // initialize curl handle curl_setopt($ch, CURLOPT_URL,$site); // set url to post to curl_setopt($ch, CURLOPT_FAILONERROR, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);// allow redirects curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return into a variable curl_setopt($ch, CURLOPT_TIMEOUT, 9); // times out after 10s curl_setopt($ch, CURLOPT_POST, 1); // set POST method curl_setopt($ch, CURLOPT_POSTFIELDS, $fields); $answer = curl_exec($ch); // run the whole process // print_r(curl_getinfo($ch)); // echo "\n\ncURL error number:" .curl_errno($ch); // echo "\n\ncURL error:" . curl_error($ch); curl_close($ch); return $answer; } ?>

    $site is the REST URL of the KnowledgeTree server, and $fields are the POST parameters that are to go along with it. This function simply POSTs these parameters to the URL (exactly the same as entering $site?$fields into your web browser).

    Here is a concrete and currently working example of how to get the contents of the KnowledgeTree root directory:

    <?php $url = 'https://www.server.com/kt-dms-oss-3.6.0/ktwebservice/KTWebService.php'; require_once('funCurlPost.php'); // ************************** // Login // ************************** $postfields = "method=login&password=123456&username=admin"; $response = curlPost($url, $postfields); $xml = new SimpleXMLElement($response); if( $xml->status_code != 0 ){ echo 'Error - authentication failed: ' . $xml->message; } else { $session_id = $xml->results; echo "Login successful, session ID = " . $session_id; } // *********************************** // List contents of root folder (id=1) // *********************************** $postfields = "method=get_folder_contents&session_id=$session_id&folder_id=1"; $response = curlPost($url, $postfields); $xml = new SimpleXMLElement($response); echo "<p>Get root folder contents:<br>"; if( $xml->status_code != 0 ){ echo 'Error - get_folder_contents failed: ' . $xml->message; } else { // print_r($xml); // to see data structure echo "<p>folder ID = " . $xml->results->folder_id . "<br>"; echo "folder name = " . $xml->results->folder_name . "<br>"; echo "folder path = " . $xml->results->full_path . "<p>"; foreach ($xml->results->items->item as $value) { echo "item type = " . $value->item_type . " "; echo "item ID = " . $value->id . " "; echo "item name = " . $value->filename . "<br>"; } } // *********************************** // Logout // *********************************** $postfields = "method=logout&session_id=$session_id"; $response = curlPost($url, $postfields); $xml = new SimpleXMLElement($response); echo "<p>Logging out....<br>"; if( $xml->status_code != 0 ){ echo 'Error - get_folder_contents failed: ' . $xml->message; } else { echo 'successful!'; } ?>

    The key point is that there were three operations in the above script, with three corresponding POST strings:

    OperationPOST string
    Loginlogin&password=123456&username=admin
    List Directory get_folder_contents&session_id=$session_id&folder_id=1
    Logoutmethod=logout&session_id=$session_id

    And something else that is already working -- to add a document to KnowledgeTree, use this POST string:

    $document = "bodybg.jpg"; // located in /var/uploads

    $postfields = "method=add_document&session_id=$session_id&folder_id=1&title=$document&filename=$document&documenttype=Default&tempfilename=/vol/www/vsc/apps/kt-dms-oss-3.6.0/var/uploads/$document";

    [1] http://www.knowledgetree.com/
    [2] http://wiki.knowledgetree.com/
    [3] http://wiki.knowledgetree.com/REST_Web_Service
    [4] http://php.net/manual/en/book.curl.php
    [5] http://devzone.zend.com/article/1081-Using-cURL-and-libcurl-with-PHP

    posted at: 01:08 | path: /SW/business/KnowledgeTree | permanent link to this entry

    Tue, 28 Apr 2009


    /SW/business/KnowledgeTree: Upgrading KnowledgeTree

    Per this link http://wiki.knowledgetree.com/Upgrading_KnowledgeTree it is exceedingly simple. Here is the way I do it (unpacking into a new directory each time, not unpacking over top of the old version):

    Make sure ownership is correct for the new version:

    chown -R www-data:www-data kt-3.6.0/

    Then bring up the login dialog, and add "setup/upgrade.php" to the end of the browser URL, for example:

    https://apps.vancouversolidcomputing.com/knowledgetree/setup/upgrade.php

    Click the "Next" button a hand full of times and it should just work.

    posted at: 08:32 | path: /SW/business/KnowledgeTree | permanent link to this entry

    Mon, 13 Apr 2009


    /SW/business/KnowledgeTree: Adding a Chinese Language Pack Plugin to Knowledgetree

    This was really quite unnecessarily hard to find. Turns out they are found on the KnowledgeTree Forge[1], and here[2] is the list. There are actually two Simplified Chinese packs, this one[3] seemed more official so that is what I downloaded[4].

    Installation is then quite simple. Move the downloaded tarball into knowledgetree/plugins/i18n and then untar it, ie.

    tar -xvf SimplifiedChinese.tgz

    You should then see a "SimplifiedChinese" sub-directory appear under i18n, and in my experience the plugin should activate automatically, ie. if you now go to the Knowledgetree login dialog "Simplified Chinese" should appear in the language drop-down menu. If it does not, login as a Knowledgetree admin and go to

    Administration » Miscellaneous » Plugins

    where you might have to hit the "Reread Plugins" button at the bottom, or click on the "Simplified Chinese Translation" check box to activate it.

    [1] http://forge.knowledgetree.com/
    [2] http://forge.knowledgetree.com/gf/project/?action=ProjectTroveBrowse&_trove_category_id=306
    [3] http://forge.knowledgetree.com/gf/project/zhcn/
    [4] http://forge.knowledgetree.com/gf/project/zhcn/frs/

    posted at: 06:23 | path: /SW/business/KnowledgeTree | permanent link to this entry

    Fri, 03 Apr 2009


    /SW/business/KnowledgeTree: How to Move Knowledgetree

    Knowledgetree is Document Management software, so not only does it store things in MySQL, but it also stores a lot in the file system. So one cannot move a KnowledgeTree (KT) instance to a different directory and expect it to just continue working. In fact, it normally does not.

    So first step: make a good backup both of the web root directory and the MySQL database.

    Then the trick, tipped-off to me courtesy of a forum[1], is to go through the (quite simple) upgrade process by running, for instance

    http://ofri.vancouversolidcomputing.com/knowledgetree/setup/upgrade.php

    The first prompt is for the admin userid and password of the KT instance (not the MySQL password).

    After that, just click through the "Next" button on several screens, and finally you will be presented with a login dialog. All done.

    [1] http://forums.knowledgetree.com/viewtopic.php?t=1670

    posted at: 01:58 | path: /SW/business/KnowledgeTree | permanent link to this entry