Example #1
0
 /**
  * Executes the match against a needle (second comparison subject).
  *
  * @param   mixed   $needle
  *          Value to compare with.
  *          
  * @access  public
  * @uses    JaxpString
  * @return  bool    True if both values match, false otherwise.
  * @since   1.1
  */
 function MatchAgainst($needle)
 {
     # Convert the needle value to a JaxpString object,
     # in case the required comparison type involves text
     # operations.
     $text_needle = new JaxpString($needle);
     switch ($this->ComparisonType) {
         case JAXP_MYSQL_MATCH_CONTAINS:
             $result = $text_needle->Contains($this->Value);
             break;
         case JAXP_MYSQL_MATCH_STARTS_WITH:
             $result = $text_needle->StartsWith($this->Value);
             break;
         case JAXP_MYSQL_MATCH_ENDS_WITH:
             $result = $text_needle->EndsWith($this->Value);
             break;
         case JAXP_MYSQL_MATCH_DISTINCT:
         case JAXP_MYSQL_MATCH_EQUAL:
         case JAXP_MYSQL_MATCH_GREATER_OR_EQUAL_THAN:
         case JAXP_MYSQL_MATCH_GREATER_THAN:
         case JAXP_MYSQL_MATCH_LESS_OR_EQUAL_THAN:
         case JAXP_MYSQL_MATCH_LESS_THAN:
             $match_template = "\$" . "result = \$" . "needle %s %s;";
             $code = sprintf($match_template, $this->ComparisonTypeToLogicOperator(), $this->Column->HasQuotes() ? "'" . $this->Value . "'" : $this->Value);
             eval($code);
             break;
     }
     return $result;
 }
Example #2
0
 /**
  * Loads into the database a new ad file.
  *
  * @uses   JaxpMySqlHandler
  *
  * @param  string $file_name   Name of the uploaded ad file.
  *
  * @return void
  * @access public
  *
  * @internal    Still untested.
  */
 function RegisterAdFile($file_name)
 {
     $path = $this->PlatformSettings->Journal->BaseUrl . "/" . $this->PlatformSettings->Journal->AdPath . "/";
     $file = new JaxpString($file_name);
     $ad_table = $this->MySqlHandler->Database->LoadTable("journal_advertisements");
     $ad_row = $this->MySqlHandler->CreateRow($ad_table);
     if (!$file->Contains(".flv")) {
         list($width, $height, $type) = getimagesize($path . $file_name);
         $ad_row->Columns["width"]->Value = $width;
         $ad_row->Columns["height"]->Value = $height;
         switch ($type) {
             case IMAGETYPE_JPEG:
                 $jaxp_type = JAXP_JOURNAL_JPEG_AD;
                 break;
             case IMAGETYPE_GIF:
                 $jaxp_type = JAXP_JOURNAL_GIF_AD;
                 break;
             case IMAGETYPE_PNG:
                 $jaxp_type = JAXP_JOURNAL_PNG_AD;
                 break;
             case IMAGETYPE_SWF:
                 $jaxp_type = JAXP_JOURNAL_SWF_AD;
                 break;
         }
     } else {
         $width = 0;
         $height = 0;
         $jaxp_type = JAXP_JOURNAL_FLV_AD;
     }
     $ad_row->Columns["width"]->Value = $width;
     $ad_row->Columns["height"]->Value = $height;
     $ad_row->Columns["ad_type"]->Value = $jaxp_type;
     $ad_row->Columns["source_file"]->Value = $file_name;
     return $this->MySqlHandler->Insert($ad_row, $ad_table);
 }