function main()
 {
     global $fpdb;
     $fpdb->query(array('count' => -1, 'fullparse' => true));
     $q = $fpdb->getQuery();
     $comments = $entries = array('count' => 0, 'words' => 0, 'chars' => 0, 'size' => 0, 'topten' => array());
     $entries['comments'] = 0;
     $toplist = array();
     while ($q->hasMore()) {
         list($id, $e) = $q->getEntry();
         $entries['count']++;
         $entries['words'] += str_word_count($e['subject']) + str_word_count($e['content']);
         $entries['chars'] += strlen($e['subject']) + strlen($e['content']);
         $entries['size'] += filesize(entry_exists($id));
         $cc = $q->hasComments();
         $entries['comments'] += $cc;
         $toplist[$id] = $cc;
         $toplistsubj[$id] = $e['subject'];
         $comments['count'] += $cc;
         while ($q->comments->hasMore()) {
             list($cid, $c) = $q->comments->getComment();
             $comments['words'] += str_word_count($c['content']);
             $comments['chars'] += strlen($c['content']);
             $comments['size'] += filesize(comment_exists($id, $cid));
         }
     }
     arsort($toplist);
     $i = 0;
     foreach ($toplist as $k => $v) {
         if ($i >= 10 || $v < 1) {
             break;
         }
         $entries['topten'][$k] = array('subject' => $toplistsubj[$k], 'comments' => $v);
         $i++;
     }
     $decunit = array('', 'Thousand', 'Million', 'Billion', 'Trillion', 'Zillion', 'Gazillion');
     $binunit = array('Bytes', 'KiloBytes', 'MegaBytes', 'GigaBytes', 'TeraBytes', 'Many', 'ManyBytes');
     list($count, $approx) = $this->format_number($entries['count'], 1000);
     $entries['count'] = $count . ' ' . $decunit[$approx];
     list($count, $approx) = $this->format_number($entries['words'], 1000);
     $entries['words'] = $count . ' ' . $decunit[$approx];
     list($count, $approx) = $this->format_number($entries['chars'], 1000);
     $entries['chars'] = $count . ' ' . $decunit[$approx];
     list($count, $approx) = $this->format_number($entries['comments'], 1000);
     $entries['comments'] = $count . ' ' . $decunit[$approx];
     list($count, $approx) = $this->format_number($entries['size'], 1024);
     $entries['size'] = $count . ' ' . $binunit[$approx];
     $this->smarty->assign('entries', $entries);
     list($count, $approx) = $this->format_number($comments['count'], 1000);
     $comments['count'] = $count . ' ' . $decunit[$approx];
     list($count, $approx) = $this->format_number($comments['words'], 1000);
     $comments['words'] = $count . ' ' . $decunit[$approx];
     list($count, $approx) = $this->format_number($comments['chars'], 1000);
     $comments['chars'] = $count . ' ' . $decunit[$approx];
     list($count, $approx) = $this->format_number($comments['size'], 1024);
     $comments['size'] = $count . ' ' . $binunit[$approx];
     $this->smarty->assign('comments', $comments);
 }
 function validate_array($params)
 {
     global $fp_config;
     if (isset($params['id'])) {
         if (entry_exists($params['id'])) {
             $this->id = $params['id'];
         } else {
             // let it fail
             $this->count = 0;
             return;
         }
     }
     if (isset($params['fullparse'])) {
         $this->fullparse = is_string($params['fullparse']) ? $params['fullparse'] != 'false' : $params['fullparse'];
         if ($this->fullparse) {
             $this->comments = true;
         }
     }
     if (isset($params['y'])) {
         $this->y = $this->pad_date($params['y']);
         if ($this->y && isset($params['m'])) {
             $this->m = $this->pad_date($params['m']);
             if ($this->m && isset($params['d'])) {
                 $this->d = $this->pad_date($params['d']);
             }
         }
     }
     if (isset($params['random']) && !$this->id) {
         $this->random = intval($params['random']);
         $this->count = $this->random;
     }
     if (isset($params['page'])) {
         $this->page = $params['page'];
     } else {
         $this->page = 1;
     }
     if ($this->page < 1) {
         $this->page = 1;
     }
     if (isset($params['count'])) {
         $this->count = intval($params['count']);
     } else {
         $this->count = intval($fp_config['general']['maxentries']);
     }
     $this->start = ($this->page - 1) * $this->count;
     if (isset($params['start'])) {
         $this->start = intval($params['start']);
     }
     if (isset($params['category'])) {
         $this->category = intval($params['category']);
     }
     if (isset($params['comments'])) {
         $this->comments = true;
     }
     if (isset($params['exclude'])) {
         $this->exclude = intval($params['exclude']);
     }
 }
Exemple #3
0
function comment_exists($entryid, $id)
{
    if (!preg_match('|^comment[0-9]{6}-[0-9]{6}$|', $id)) {
        return false;
    }
    $f = entry_exists($entryid);
    if (!$f) {
        return false;
    }
    $f2 = substr($f, 0, -strlen(EXT)) . '/comments/' . $id . EXT;
    if (!file_exists($f2)) {
        return false;
    }
    return $f2;
}
 $fn = filename_for_message($line['contact'], $line['date']);
 if (!file_exists(dirname($fn))) {
     mkdir(dirname($fn));
 }
 if (!file_exists($fn)) {
     file_put_contents($fn, html_template());
 }
 $attachment_query = $db->query('SELECT attachment.*
 FROM attachment 
 JOIN message_attachment_join ON message_attachment_join.attachment_id=attachment.ROWID
 WHERE message_attachment_join.message_id = ' . $line['ROWID']);
 $attachments = array();
 while ($attachment = $attachment_query->fetch(PDO::FETCH_ASSOC)) {
     $attachments[] = $attachment;
 }
 if (!entry_exists($line, $attachments, $fn)) {
     $fp = fopen($fn, 'a');
     $log = format_line($line, $attachments);
     fwrite($fp, $log . "\n");
     fclose($fp);
     echo date('c', $line['date']) . "\t" . $line['contact'] . "\t" . $line['text'] . "\n";
     foreach ($attachments as $at) {
         $imgsrc = attachment_folder($line['contact'], $line['date']) . $at['transfer_name'];
         if (!file_exists(dirname($imgsrc))) {
             mkdir(dirname($imgsrc));
         }
         copy(str_replace('~/', $_SERVER['HOME'] . '/', $at['filename']), $imgsrc);
     }
 }
 if ($line['date'] > $last_timestamp) {
     $last_timestamp = $line['date'];
        if ($table_attachments['physical_filename'][$i] != '') {
            if (!in_array(trim($table_attachments['physical_filename'][$i]), $file_attachments)) {
                $shadow_row['attach_id'][] = $table_attachments['attach_id'][$i];
                $shadow_row['physical_filename'][] = trim($table_attachments['physical_filename'][$i]);
                $shadow_row['comment'][] = $table_attachments['comment'][$i];
                // Delete this entry from the table_attachments, to not interfere with the next step
                $table_attachments['attach_id'][$i] = 0;
                $table_attachments['physical_filename'][$i] = '';
                $table_attachments['comment'][$i] = '';
            }
        }
    }
    // Now look at the missing posts and PM's
    for ($i = 0; $i < sizeof($table_attachments['attach_id']); $i++) {
        if ($table_attachments['attach_id'][$i]) {
            if (!entry_exists($table_attachments['attach_id'][$i])) {
                $shadow_row['attach_id'][] = $table_attachments['attach_id'][$i];
                $shadow_row['physical_filename'][] = trim($table_attachments['physical_filename'][$i]);
                $shadow_row['comment'][] = $table_attachments['comment'][$i];
            }
        }
    }
    for ($i = 0; $i < sizeof($shadow_attachments); $i++) {
        $template->assign_block_vars('file_shadow_row', array('ATTACH_ID' => $shadow_attachments[$i], 'ATTACH_FILENAME' => $shadow_attachments[$i], 'ATTACH_COMMENT' => $lang['No_file_comment_available'], 'U_ATTACHMENT' => $upload_dir . '/' . basename($shadow_attachments[$i])));
    }
    for ($i = 0; $i < sizeof($shadow_row['attach_id']); $i++) {
        $template->assign_block_vars('table_shadow_row', array('ATTACH_ID' => $shadow_row['attach_id'][$i], 'ATTACH_FILENAME' => basename($shadow_row['physical_filename'][$i]), 'ATTACH_COMMENT' => trim($shadow_row['comment'][$i]) == '' ? $lang['No_file_comment_available'] : trim($shadow_row['comment'][$i])));
    }
}
if ($submit && $mode == 'cats') {
    if (!$error) {
Exemple #6
0
function entry_delete($id)
{
    if (!($f = entry_exists($id))) {
        return;
    }
    /*
    $d = bdb_idtofile($id,BDB_COMMENT);
    fs_delete_recursive("$d");
    
    // thanks to cimangi for noticing this
    $f = dirname($d) . '/view_counter' .EXT;
    fs_delete($f);
    
    
    $f = bdb_idtofile($id);
    */
    $d = entry_dir($id);
    fs_delete_recursive($d);
    $obj =& entry_init();
    $obj->delete($id, entry_parse($id));
    do_action('delete_post', $id);
    return fs_delete($f);
}
 function mark_for_deletion($client, $checked_messages)
 {
     foreach ($checked_messages as $message) {
         $CG = get_instance();
         if (entry_exists('messages', 'access_id', $message)) {
             $email = $CG->db->get_where('messages', array('access_id' => $message))->row();
             if (isset($email->uid)) {
                 if (!is_null($email->parent)) {
                     $email = $CG->db->get_where('messages', array('message_id' => $email->parent))->row();
                 }
                 //Delete message and all its children
                 $CG->db->start_cache();
                 $CG->db->where('access_id', $email->access_id);
                 $CG->db->or_where('parent', $email->message_id);
                 $CG->db->stop_cache();
                 $CG->db->select('access_id, uid');
                 $results = $CG->db->get('messages')->result();
                 $CG->db->delete('messages');
                 $CG->db->flush_cache();
                 $uid_list = '';
                 //Delete message's tag lookups
                 foreach ($results as $message) {
                     $uid_list .= ',' . $message->uid;
                     $CG->db->where('access_id', $message->access_id);
                     $CG->db->delete('email_tag_x');
                 }
                 imap_mail_move($client, $uid_list, '[Gmail]/Trash', CP_UID);
             }
         }
     }
     imap_expunge($client);
 }