Beispiel #1
0
 public function __get($variable)
 {
     switch (strtolower($variable)) {
         case 'ids':
             return $this->Query('ids');
         case 'amount':
             return $this->calculated_amount === null ? $this->Query('amount') : $this->calculated_amount;
         case 'handle':
             return $this->Query('handle');
         case 'formatted_amount':
             return NumberFormatInteger($this->amount);
         case 'type':
             return $this->type;
         case 'message':
             return sprintf('%s %s %s', $this->formatted_amount, $this->type, $this->amount == 1 ? $this->xtable->naming->textLower : $this->xtable->naming->textLowerPlural);
     }
 }
Beispiel #2
0
function ResizeableColumn($label, $value, $numeric = false, $joiner = null, $type = null, $link = null)
{
    if (is_array($value)) {
        if ($numeric) {
            $value = array_map('NumberFormatInteger', $value);
        }
        $value = join($joiner, $value);
    } else {
        if ($numeric) {
            $value = NumberFormatInteger($value);
        }
    }
    $overflow = strlen($value) > 40;
    $value = preg_replace(array('~^(http(s)?://[\\w-]+\\.[\\w-]+(\\S+)?)$~i', '~^([\\w\\d][\\w\\d\\,\\.\\-]*\\@([\\w\\d\\-]+\\.)+([a-zA-Z]+))$~i'), array('<a href="$1" target="_blank">$1</a>', '<a href="mailto:$1" target="_blank">$1</a>'), $value);
    switch ($type) {
        case Form_Field::CHECKBOX:
            $value = '<span style="vertical-align: middle">' . '<img src="images/' . ($value ? 'approve' : 'reject') . '-16x16.png" border="0" />' . '</span>';
            break;
        default:
            $value = '<span>' . (!empty($link) ? '<a href="' . $link . '">' . $value . '</a>' : $value) . '</span>';
            break;
    }
    return '<span class="resizeable-column">' . '<b' . ($overflow ? ' class="clickable overflow"' : '') . '>' . String::Truncate($label, 18) . ':</b> ' . $value . '</span>';
}
Beispiel #3
0
            <span class="index-user-text">
              <b><?php 
    echo $user['username'];
    ?>
</b><br />
              <span class="small defaultvalue">
                <?php 
    echo $user['date_created'];
    ?>
<br />
                <?php 
    echo NumberFormatInteger($stats['total_videos_uploaded']);
    ?>
 Videos,
                <?php 
    echo NumberFormatInteger($stats['total_videos_watched']);
    ?>
 Watched
              </span>
            </span>
          </div>
          <?php 
}
?>
        </div>
      </div>
    </div>
    <!-- TABS END -->

    <div style="height: 50px;"></div>
echo $DB->NumRows($result) > 0 ? 'display: none;' : '';
?>
">No feature reasons have been logged for this video since the last clearing</div>
          <?php 
if ($DB->NumRows($result) > 0) {
    ?>
          <div class="reason-container reason-container-header">
            <span>Times</span>
            <span>Reason</span>
          </div>
          <?php 
    while ($reason = $DB->NextRow($result)) {
        ?>
          <div class="reason-container">
            <span><?php 
        echo NumberFormatInteger($reason['times']);
        ?>
</span>
            <span><?php 
        echo $reason['description'];
        ?>
</span>
          </div>
          <?php 
    }
}
?>

        </div>
      </div>
    <tr class="search-hilite search-result" id="<?php 
echo $item['category_id'];
?>
">
      <td class="selectable" style="width: 40px;" title="Select">
      </td>
      <td>
       <?php 
echo $item['name'];
?>
      </td>
      <td>
       <?php 
echo $item['url_name'];
?>
      </td>
      <td>
        <?php 
echo NumberFormatInteger($item['num_videos']);
?>
      </td>
      <td valign="top" class="search-result-icons">
        <img src="images/video-22x22.png" class="item-icon" title="Videos" meta="{t: 'link', u: 'index.php?r=tbxGenericShowSearch(video)&pds=category&name=<?php 
echo urlencode($original['name']);
?>
'}" />
        <img src="images/edit-22x22.png" class="item-icon" title="Edit" meta="{t: 'dialog', r: 'tbxGenericShowEdit(category)'}" />
        <img src="images/delete-22x22.png" class="item-icon" title="Delete" meta="{t: 'action', r: 'tbxGenericAction(category,delete)'}" />
      </td>
    </tr>
    <tr class="search-hilite search-result" id="<?php 
echo $item['user_level_id'];
?>
">
      <td class="selectable" style="width: 40px;" title="Select">
      </td>
      <td>
        <?php 
echo $item['name'];
?>
      </td>
      <td>
        <?php 
echo NumberFormatInteger($item['daily_view_limit']);
?>
      </td>
      <td>
        <?php 
echo Format::BytesToString($item['daily_bandwidth_limit']);
?>
      </td>
      <td class="text-center">
        <img src="images/<?php 
echo $item['is_guest'] ? 'approve' : 'reject';
?>
-22x22.png" />
      </td>
      <td class="text-center">
        <img src="images/<?php 
echo $item['is_default'] ? 'approve' : 'reject';
?>
Beispiel #7
0
function tbxDatabaseQuery()
{
    Privileges::Check(Privileges::DATABASE);
    $DB = GetDB();
    $query = Request::Get('query');
    $output = array();
    if (String::IsEmpty($query)) {
        return JSON::Failure(array('message' => 'The Query field must be filled in'));
    }
    // A data retrieval query
    if (preg_match('~^(select|show|describe)~i', $query)) {
        $result = $DB->Query($query);
        $rows = $DB->NumRows($result);
        $fields = mysql_num_fields($result);
        $output['message'] = 'Database query has been successfully executed';
        $output['html'] = "<table cellpadding=\"4\" cellspacing=\"0\" border=\"0\">" . "<tr>" . "<td colspan=\"{$fields}\">Rows returned: " . NumberFormatInteger($rows) . "</td>" . "</tr>" . "<tr class=\"db-fields\">";
        for ($i = 0; $i < $fields; $i++) {
            $name = mysql_field_name($result, $i);
            $output['html'] .= "<td><b>{$name}</b></td>";
        }
        $output['html'] .= '</tr>';
        $counter = 0;
        while ($row = mysql_fetch_array($result)) {
            $output['html'] .= "<tr class=\"db-rows\">";
            for ($i = 0; $i < $fields; $i++) {
                $output['html'] .= "<td>" . htmlspecialchars($row[$i]) . "</td>";
            }
            $output['html'] .= "</tr>";
            if (++$counter >= 100) {
                break;
            }
        }
        $output['html'] .= '</table>';
        $DB->Free($result);
    } else {
        $affected = $DB->Update($query);
        $output['message'] = sprintf('Database query has been successfully executed.  A total of %s row%s affected', NumberFormatInteger($affected), $affected == 1 ? ' was' : 's were');
    }
    JSON::Success($output);
}
Beispiel #8
0
 public function QueryWithPagination($query, $binds = array(), $page = 1, $per_page = 20, $primary_key = null)
 {
     $result = array();
     // Get total number of results
     $count_query = preg_replace(array('~SELECT DISTINCT #\\.\\* FROM~i', '~SELECT \\*.*? FROM~i', '~ ORDER BY (.*?)$~i'), array("SELECT COUNT(DISTINCT #.`{$primary_key}`) FROM", 'SELECT COUNT(*) FROM', ''), $query);
     if (stristr($count_query, 'GROUP BY')) {
         $temp_result = $this->Query($count_query, $binds);
         $result['total'] = $this->NumRows($temp_result);
         $this->Free($temp_result);
     } else {
         $result['total'] = $this->QuerySingleColumn($count_query, $binds);
     }
     // Calculate pagination
     $result['formatted']['total'] = $result['total'];
     $result['formatted']['pages'] = $result['pages'] = ceil($result['total'] / $per_page);
     $result['page'] = min(max($page, 1), $result['pages']);
     $result['limit'] = max(($result['page'] - 1) * $per_page, 0);
     $result['formatted']['start'] = $result['start'] = max(($result['page'] - 1) * $per_page + 1, 0);
     $result['formatted']['end'] = $result['end'] = min($result['start'] - 1 + $per_page, $result['total']);
     $result['prev'] = $result['page'] > 1;
     $result['next'] = $result['end'] < $result['total'];
     if (class_exists('config')) {
         $result['formatted']['pages'] = NumberFormatInteger($result['formatted']['pages']);
         $result['formatted']['start'] = NumberFormatInteger($result['formatted']['start']);
         $result['formatted']['end'] = NumberFormatInteger($result['formatted']['end']);
         $result['formatted']['total'] = NumberFormatInteger($result['formatted']['total']);
     }
     if ($result['next']) {
         $result['next_page'] = $result['page'] + 1;
     }
     if ($result['prev']) {
         $result['prev_page'] = $result['page'] - 1;
     }
     if ($result['total'] > 0) {
         $result['handle'] = $this->Query("{$query} LIMIT {$result['limit']},{$per_page}", $binds);
         $result['numrows'] = $this->NumRows($result['handle']);
     } else {
         $result['handle'] = false;
         $result['numrows'] = 0;
     }
     return $result;
 }
echo $item['name'];
?>
      </td>
      <td>
        <?php 
echo ResizeableColumn('Main', $item['url']);
?>
        <?php 
echo ResizeableColumn('2257', $item['us2257_url']);
?>
      </td>
      <td>
        <?php 
echo NumberFormatInteger($item['videos']);
?>
      </td>
      <td>
        <?php 
$banners = $DB->QueryCount('SELECT COUNT(*) FROM `tbx_banner` WHERE `sponsor_id`=?', array($item['sponsor_id']));
echo NumberFormatInteger($banners);
?>
      </td>
      <td valign="top" class="search-result-icons">
        <img src="images/video-22x22.png" class="item-icon" title="Videos" meta="{t: 'link', u: 'index.php?r=tbxGenericShowSearch(video)&pds=sponsor&name=<?php 
echo urlencode($original['name']);
?>
'}" />
        <img src="images/edit-22x22.png" class="item-icon" title="Edit" meta="{t: 'dialog', r: 'tbxGenericShowEdit(sponsor)'}" />
        <img src="images/delete-22x22.png" class="item-icon" title="Delete" meta="{t: 'action', r: 'tbxGenericAction(sponsor,delete)'}" />
      </td>
    </tr>
Beispiel #10
0
 public static function Import($settings)
 {
     $DB = GetDB();
     ProgressBarShow('pb-import');
     $file = TEMP_DIR . '/' . File::Sanitize($settings['import_file']);
     $fp = fopen($file, 'r');
     $filesize = filesize($file);
     $line = $read = $imported = 0;
     $expected = count($settings['fields']);
     while (!feof($fp)) {
         $line++;
         $string = fgets($fp);
         $read += strlen($string);
         $data = explode($settings['delimiter'], trim($string));
         ProgressBarUpdate('pb-import', $read / $filesize * 100);
         // Line does not have the expected number of fields
         if (count($data) != $expected) {
             continue;
         }
         $video = array();
         $defaults = array('category_id' => $settings['category_id'], 'sponsor_id' => $settings['sponsor_id'], 'username' => $settings['username'], 'duration' => Format::DurationToSeconds($settings['duration']), 'status' => $settings['status'], 'next_status' => $settings['status'], 'allow_comments' => $settings['allow_comments'], 'allow_ratings' => $settings['allow_ratings'], 'allow_embedding' => $settings['allow_embedding'], 'is_private' => $settings['is_private'], 'date_added' => Database_MySQL::Now(), 'is_featured' => 0, 'is_user_submitted' => 0, 'conversion_failed' => 0, 'tags' => null, 'title' => null, 'description' => null);
         foreach ($settings['fields'] as $index => $field) {
             if (!empty($field)) {
                 $video[$field] = trim($data[$index]);
             }
         }
         // Setup clips
         $clips = array();
         $thumbs = array();
         $clip_type = 'URL';
         if (isset($video['embed_code'])) {
             // Cannot convert or thumbnail from embed code
             $settings['flag_convert'] = $settings['flag_thumb'] = false;
             $clips[] = $video['embed_code'];
             $clip_type = 'Embed';
         } else {
             if (isset($video['gallery_url'])) {
                 $http = new HTTP();
                 if (!$http->Get($video['gallery_url'])) {
                     // Broken gallery URL, continue
                     continue;
                 }
                 list($thumbs, $clips) = Video_Source_Gallery::ExtractUrls($http->url, $http->body);
             } else {
                 if (!isset($video['video_url']) && isset($video['base_video_url'])) {
                     if (!preg_match('~/$~', $video['base_video_url'])) {
                         $video['base_video_url'] .= '/';
                     }
                     foreach (explode(',', $video['video_filename']) as $filename) {
                         $clips[] = $video['base_video_url'] . $filename;
                     }
                 } else {
                     $clips[] = $video['video_url'];
                 }
             }
         }
         // Check for duplicate clips
         $duplicate = false;
         foreach ($clips as $clip) {
             if (!Request::Get('flag_skip_imported_check') && $DB->QueryCount('SELECT COUNT(*) FROM `tbx_imported` WHERE `video_url`=?', array($clip)) > 0) {
                 $duplicate = true;
             }
             $DB->Update('REPLACE INTO `tbx_imported` VALUES (?)', array($clip));
         }
         // Dupe found
         if ($duplicate) {
             continue;
         }
         // Setup thumbs
         if (!isset($video['gallery_url']) && !isset($video['thumbnail_url']) && isset($video['base_thumbnail_url'])) {
             if (!preg_match('~/$~', $video['base_thumbnail_url'])) {
                 $video['base_thumbnail_url'] .= '/';
             }
             foreach (explode(',', String::FormatCommaSeparated($video['thumbnail_filename'])) as $filename) {
                 $thumbs[] = $video['base_thumbnail_url'] . $filename;
             }
         } else {
             if (!isset($video['gallery_url']) && isset($video['thumbnail_url'])) {
                 $thumbs[] = $video['thumbnail_url'];
             }
         }
         // Setup duration
         if (isset($video['duration_seconds'])) {
             $video['duration'] = $video['duration_seconds'];
         } else {
             if (isset($video['duration_formatted'])) {
                 $video['duration'] = Format::DurationToSeconds($video['duration_formatted']);
             }
         }
         // Use description for title
         if (empty($video['title'])) {
             $video['title'] = isset($video['description']) ? $video['description'] : '';
         }
         // Use title for description
         if (empty($video['description'])) {
             $video['description'] = isset($video['title']) ? $video['title'] : '';
         }
         // Use title for tags
         if (empty($video['tags'])) {
             $video['tags'] = isset($video['title']) ? $video['title'] : '';
         }
         // Setup category
         if (isset($video['category']) && ($category_id = $DB->QuerySingleColumn('SELECT `category_id` FROM `tbx_category` WHERE `name` LIKE ?', array($video['category']))) !== false) {
             $video['category_id'] = $category_id;
         } else {
             if (($category_id = GetBestCategory($video['title'] . ' ' . $video['description'])) !== null) {
                 $video['category_id'] = $category_id;
             }
         }
         // Merge in the defaults
         $video = array_merge($defaults, $video);
         // Format tags and convert to UTF-8
         $video['tags'] = Tags::Format($video['tags']);
         $video = String::ToUTF8($video);
         if (Request::Get('flag_convert')) {
             $video['status'] = STATUS_QUEUED;
         }
         // Add to database
         $video['video_id'] = DatabaseAdd('tbx_video', $video);
         DatabaseAdd('tbx_video_custom', $video);
         DatabaseAdd('tbx_video_stat', $video);
         if ($video['is_private']) {
             $video['private_id'] = sha1(uniqid(mt_rand(), true));
             DatabaseAdd('tbx_video_private', $video);
         }
         if ($video['status'] == STATUS_QUEUED) {
             $video['queued'] = time();
             DatabaseAdd('tbx_conversion_queue', $video);
         }
         if (Request::Get('flag_thumb')) {
             $video['queued'] = time();
             DatabaseAdd('tbx_thumb_queue', $video);
         }
         if ($video['status'] == STATUS_ACTIVE && !$video['is_private']) {
             Tags::AddToFrequency($video['tags']);
         }
         // Add clips
         foreach ($clips as $clip) {
             DatabaseAdd('tbx_video_clip', array('video_id' => $video['video_id'], 'type' => $clip_type, 'clip' => $clip));
         }
         $dir = new Video_Dir(Video_Dir::DirNameFromId($video['video_id']));
         // Process thumbs
         $thumb_ids = array();
         foreach ($thumbs as $thumb) {
             $http = new HTTP();
             if ($http->Get($thumb, $thumb)) {
                 if (Video_Thumbnail::CanResize()) {
                     $thumb_temp = $dir->AddTempFromVar($http->body, 'jpg');
                     $thumb_file = Video_Thumbnail::Resize($thumb_temp, Config::Get('thumb_size'), Config::Get('thumb_quality'), $dir->GetThumbsDir());
                 } else {
                     $thumb_file = $dir->AddThumbFromVar($http->body);
                 }
                 if (!empty($thumb_file)) {
                     $thumb_ids[] = DatabaseAdd('tbx_video_thumbnail', array('video_id' => $video['video_id'], 'thumbnail' => str_replace(Config::Get('document_root'), '', $thumb_file)));
                 }
             }
         }
         // Determine number of thumbnails and select random display thumbnail
         $num_thumbnails = count($thumb_ids);
         $display_thumbnail = null;
         if ($num_thumbnails > 0) {
             // Select display thumbnail randomly from the first 40%
             $display_thumbnail = $thumb_ids[rand(0, floor(0.4 * $num_thumbnails))];
         }
         DatabaseUpdate('tbx_video', array('video_id' => $video['video_id'], 'num_thumbnails' => $num_thumbnails, 'display_thumbnail' => $display_thumbnail));
         $imported++;
     }
     fclose($fp);
     UpdateCategoryStats();
     UpdateSponsorStats($settings['sponsor_id']);
     $t = new Template();
     $t->ClearCache('categories.tpl');
     ProgressBarHide('pb-import', NumberFormatInteger($imported) . ' videos have been imported!');
     // Start up the thumbnail and converson queues if needed
     if (!Config::Get('flag_using_cron')) {
         if (Request::Get('flag_convert')) {
             ConversionQueue::Start();
         }
         if (Request::Get('flag_thumb')) {
             ThumbQueue::Start();
         }
     }
     File::Delete($file);
 }
    <tr class="search-hilite search-result" id="<?php 
echo $item['term_id'];
?>
">
      <td class="selectable" style="width: 40px;" title="Select">
      </td>
      <td>
        <?php 
echo $item['term'];
?>
      </td>
      <td>
        <?php 
echo NumberFormatInteger($item['frequency']);
?>
      </td>
      <td valign="top" class="search-result-icons">
        <img src="images/edit-22x22.png" class="item-icon" title="Edit" meta="{t: 'dialog', r: 'tbxGenericShowEdit(search-term)'}" />

        <img src="images/delete-22x22.png" class="item-icon" title="Delete" meta="{t: 'action', r: 'tbxGenericAction(search-term,delete)'}" />
      </td>
    </tr>