PHP Classes

File: swypeserver.php

Recommend this page to a friend!
  Classes of Richard Keizer   Swype for PHP   swypeserver.php   Download  
File: swypeserver.php
Role: Example script
Content type: text/plain
Description: server example
Class: Swype for PHP
Auto-complete words entered with a Swype keyboard
Author: By
Last change: improved feedback
Date: 12 years ago
Size: 1,776 bytes
 

Contents

Class file image Download
<?php
 
 
/**------------------------------------------------------------------------------
   * Title: swypeserver
   * Filename: swypeserver.php
   * Version: 0.1
   * Author: Richard Keizer
   * Email: ra dot keizer at gmail dot com
   *-------------------------------------------------------------------------------
   * COPYRIGHT (c) 2011 Richard Keizer
   *
   * The source code included in this package is free software; you can
   * redistribute it and/or modify it under the terms of the GNU General Public
   * License as published by the Free Software Foundation. This license can be
   * read at:
   *
   * http://www.opensource.org/licenses/gpl-license.php
   *
   * This program is distributed in the hope that it will be useful, but WITHOUT
   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
   * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
   *------------------------------------------------------------------------------
   *
   * Simple implementation of a swipe-decoder service
   * Make sure this file is accessible from a webserver!
   *
   * This example is not ment to be secure!
   *
   */
 
 
error_reporting(E_ALL);
 
ini_set('display_errors', 1);
 
  include_once
'swypedecoder.class.php';
 
 
$input = isset($_REQUEST['text']) ? $_REQUEST['text'] : '';
 
$input = preg_replace('{(.)\1*}', '$1', $input); //remove double characters
 
 
if (strlen($input) > 1) {
   
$lang = isset($_REQUEST['lang']) ? preg_replace("/[^a-z]/i", '', $_REQUEST['lang']) : 'en';
   
$swype = new SwypeDecoder($lang);
   
$suggestions = $swype->unSwype($input);
    echo empty(
$suggestions) ? '??' : implode(', ', $suggestions);
  } else {
    echo
$input;
  }