$percentage = calcPercentage($discountAmount, $originalPrice);
     }
 }
 echo "\n percentage " . $percentage;
 if ($originalPrice == "") {
     $originalPrice = calcOriginalPrice($discountedPrice, $percentage);
 }
 echo "\n originalPrice " . $originalPrice;
 echo "\n";
 echo "foo";
 echo "\n";
 echo "bar";
 echo "\n";
 #### deal with dates ####
 $getToMonth = getToMonth($specialOffer);
 $getToDate = getToDate($specialOffer, $getToMonth);
 $getToDate = getDaysinMonth($getToMonth);
 $dateTo = date('Y-m-d', strtotime($getToDate . " " . $getToMonth));
 $getFromMonth = getFromMonth($specialOffer);
 $getFromDate = getFromDate($specialOffer, $getFromMonth);
 if ($getFromDate == "") {
     // the whole month is on offer as there is no set date
     $getFromDate = "1st";
 }
 $dateFrom = date('Y-m-d', strtotime($getFromDate . " " . $getFromMonth));
 echo "start";
 echo $dateFrom;
 echo $dateTo;
 // Update dateFrom to saturdays date
 $tmptime = strtotime($getFromDate . " " . $getFromMonth);
 $tme = mktime(0, 0, 0, date('m', $tmptime), date('d', $tmptime), date('Y', $tmptime));
          <tr>
            <th scope="row">时间范围</th>
            <td>
            <input type="text" class="text" name="s[start_time]" value="<?php 
echo getToDate($_REQUEST['s']['start_time']);
?>
" onFocus="WdatePicker({startDate:'<?php 
echo getToDate($_REQUEST['s']['start_time']);
?>
',dateFmt:'yyyy-MM-dd HH:mm:ss',alwaysUseStartDate:true})"/>
            至
            <input type="text" class="text" name="s[end_time]" value="<?php 
echo getToDate($_REQUEST['s']['end_time']);
?>
" onFocus="WdatePicker({startDate:'<?php 
echo getToDate($_REQUEST['s']['end_time']);
?>
',dateFmt:'yyyy-MM-dd HH:mm:ss',alwaysUseStartDate:true})"/>
            </td>
          </tr>
          <tr>
            <th scope="row">添加人</th>
            <td><select name="s[user_id]"><option value="">请选择</option><?php 
echo $viewClass->options(array('options' => $viewClass->var['users'], 'selected' => $_REQUEST['s']['user_id']));
?>
</select></td>
          </tr>
          <tr>
            <th colspan="2" scope="row"><input type="submit" value="提交" class="btn-blue" /></th>
          </tr>
      </table>
</td>
      </tr>
      <tr>
        <th>游戏名称</th>
        <td><input type="text" class="text" value="<?php 
echo $viewClass->var['dataList']['name'];
?>
" name="name" size="50" /></td>
      </tr>
      <tr>
        <th>游戏上架时间</th>
        <td><input type="text" class="text" name="time" value="<?php 
echo getToDate($viewClass->var['dataList']['time']);
?>
" onFocus="WdatePicker({startDate:'<?php 
echo getToDate($viewClass->var['dataList']['time']);
?>
',dateFmt:'yyyy-MM-dd HH:mm:ss',alwaysUseStartDate:true})"/></td>
      </tr>
      <tr>
        <th>游戏图片</th>
        <td>
        	小图URL:<input type="text" class="text" name="small_img" value="<?php 
echo $viewClass->var['dataList']['small_img'];
?>
" size="50" /><br>
        	中图URL:<input type="text" class="text" name="normal_img" value="<?php 
echo $viewClass->var['dataList']['normal_img'];
?>
" size="50" /><br>
        	大图URL:<input type="text" class="text" name="big_img" value="<?php 
$specialOffer = "";
date_default_timezone_set('GMT');
$date = new DateTime();
foreach ($dom->find('p') as $data) {
    $discountedPrice = "";
    $specialOffer = $data->plaintext;
    $valid = isOffer($specialOffer);
    if ($valid) {
        # break the text down into the deals available
        # $ok = false;
        $str = $specialOffer;
        // functions to parse the special offer string
        // deal with price
        // initialise variables
        $discountAmount = "";
        $originalPrice = "";
        $calcPercentage = "";
        $getfromDate = getfromDate($specialOffer);
        $getFromMonth = getFromMonth($specialOffer);
        $getToMonth = getToMonth($specialOffer);
        $getToDate = getToDate($specialOffer);
        echo "\n---";
        echo $getToDate . " " . $getToMonth;
        echo "---\n";
        $i++;
    } else {
        $record = array('ID' => $i, 'TEXT' => $specialOffer, 'DATE' => $date->getTimestamp());
        scraperwiki::sqliteexecute("insert into turk_table values (?,?,?)", array($i, $specialOffer, $date->getTimestamp()));
        $i++;
    }
}