Example #1
0
 public function get($params)
 {
     $shopId = $this->__checkAuth($params);
     $filter['disabled'] = 0;
     $filter['target_id'] = $shopId;
     $filter['target_type'] = 'shop';
     if ($params['img_type'] != 'all') {
         $filter['img_type'] = $params['img_type'] != 'other' ? $params['img_type'] : '';
     }
     if ($params['image_name']) {
         $filter['image_name|has'] = $params['image_name'];
     }
     $total = app::get('image')->model('images')->count($filter);
     $result['total'] = $total;
     if ($total) {
         $page = $this->__page($total, $params['page_no'], $params['page_size']);
         $orderBy = $params['orderBy'] ? $params['orderBy'] : 'last_modified desc';
         $result['list'] = app::get('image')->model('images')->getList('*', $filter, $page['offset'], $page['limit'], $orderBy);
         foreach ($result['list'] as $k => $v) {
             $result['list'][$k]['format_size'] = format_filesize($v['size']);
         }
     } else {
         $result['list'] = [];
     }
     return $result;
 }
Example #2
0
 function test_format_filesize()
 {
     $this->assertEquals(format_filesize(-25), '-25 b');
     $this->assertEquals(format_filesize(25), '25 b');
     $this->assertEquals(format_filesize(2500), '2 KB');
     $this->assertEquals(format_filesize(2500000), '2.4 MB');
     $this->assertEquals(format_filesize(25000000), '23.8 MB');
     $this->assertEquals(format_filesize(2500000000), '2.3 GB');
 }
	protected function format_files_column_value($col, $object, $template_url) {
		$html = "";
		switch ($col) {
			case 'icon': $html .= "<td class='table_row_value'><img src='".array_var($object, 'icon')."' alt='icon'/></td>"; break;
			case 'icon_l': $html .= "<td class='table_row_value'><img src='".array_var($object, 'icon_l')."' alt='icon'/></td>"; break;
			case 'name': $html .= "<td class='table_row_value'><a href='$template_url'>".array_var($object, 'name')."</a></td>";break;
			case 'size': $html .= "<td class='table_row_value'>".format_filesize(array_var($object, 'size'))."</td>"; break;
			default : $html .= "<td class='table_row_value'>".array_var($object, $col, '')."</td>"; break;
		}
		return $html;
	}
Example #4
0
 public function index()
 {
     requireadmin();
     $query = $this->mdb->dashboard();
     $items = array();
     if ($query->num_rows()) {
         $row = $query->row();
         $admins = array();
         $adminsQ = $this->mdb->get_admins();
         foreach ($adminsQ->result() as $adminRow) {
             $admins[] = array('id' => $adminRow->id, 'display_name' => $adminRow->display_name);
         }
         $items = array('projects' => number_format($row->projects), 'users_active' => number_format($row->active_users), 'users_pending' => number_format($row->pending_users), 'users_banned' => number_format($row->banned_users), 'storage_used' => format_filesize($row->storage_used), 'admins' => $admins);
     }
     generate_json(array('status' => 1, 'items' => $items));
 }
Example #5
0
 /**
  * Handle list directory requests (/filemanager/api/ls).
  */
 public function get_ls()
 {
     $file = urldecode(join('/', func_get_args()));
     $res = FileManager::dir($file);
     if (!$res) {
         return $this->error(FileManager::error());
     }
     foreach ($res['dirs'] as $k => $dir) {
         $res['dirs'][$k]['mtime'] = I18n::date_time($dir['mtime']);
     }
     foreach ($res['files'] as $k => $file) {
         $res['files'][$k]['mtime'] = I18n::date_time($file['mtime']);
         $res['files'][$k]['fsize'] = format_filesize($file['fsize']);
     }
     return $res;
 }
Example #6
0
function get_portable_serverinfo()
{
    echo '
	<br class="clear" />
	<table class="widefat">
		<thead>
			<tr>
				<th>Variable Name</th>
				<th>Value</th>
				<th>Variable Name</th>
				<th>Value</th>
			</tr>
		</thead>
		<tbody>
			<tr>
				<td>OS</td>
				<td>' . PHP_OS . '</td>
				<td>Database Data Disk Usage</td>
				<td>' . format_filesize(get_mysql_data_usage()) . '</td>
			</tr>
			<tr class="alternate">
				<td>Server</td>
				<td>' . $_SERVER['SERVER_SOFTWARE'] . '</td>
				<td>Database Index Disk Usage</td>
				<td>' . format_filesize(get_mysql_index_usage()) . '</td>
			</tr>
			<tr>
				<td>PHP</td>
				<td>v' . PHP_VERSION . '</td>
				<td>MYSQL Maximum Packet Size</td>
				<td>' . format_filesize(get_mysql_max_allowed_packet()) . '</td>
			</tr>
			<tr class="alternate">
				<td>MYSQL</td>
				<td>v' . get_mysql_version() . '</td>
				<td>MYSQL Maximum Allowed Connections</td>
				<td>' . number_format_i18n(get_mysql_max_allowed_connections()) . '</td>
			</tr>
		</tbody>
	</table>
	<br class="clear" />';
}
Example #7
0
 /**
  * Handle list directory requests (/filemanager/api/ls).
  */
 public function get_ls()
 {
     $file = urldecode(join('/', func_get_args()));
     if (!self::verify_folder($file, $this->root)) {
         return $this->error(i18n_get('Invalid folder name'));
     }
     $d = dir($this->root . $file);
     $out = array('dirs' => array(), 'files' => array());
     while (false != ($entry = $d->read())) {
         if (preg_match('/^\\./', $entry)) {
             continue;
         } elseif (@is_dir($this->root . $file . '/' . $entry)) {
             $out['dirs'][] = array('name' => $entry, 'path' => ltrim($file . '/' . $entry, '/'), 'mtime' => I18n::date_time(filemtime($this->root . $file . '/' . $entry)));
         } else {
             $out['files'][] = array('name' => $entry, 'path' => ltrim($file . '/' . $entry, '/'), 'mtime' => I18n::date_time(filemtime($this->root . $file . '/' . $entry)), 'fsize' => format_filesize(filesize($this->root . $file . '/' . $entry)));
         }
     }
     $d->close();
     usort($out['dirs'], array('FileManager', 'fsort'));
     usort($out['files'], array('FileManager', 'fsort'));
     return $out;
 }
                     $sql = "";
                     $first_row = true;
                 }
             }
         }
         $processed_objects[] = $cobj->getId();
         // check memory to stop script
         if (count($processed_objects) >= OBJECT_COUNT || memory_get_usage(true) > SCRIPT_MEMORY_LIMIT) {
             $processed_objects_ids = "(" . implode("),(", $processed_objects) . ")";
             DB::execute("INSERT INTO " . TABLE_PREFIX . "processed_objects (object_id) VALUES {$processed_objects_ids} ON DUPLICATE KEY UPDATE object_id=object_id");
             $rest = Objects::count("id NOT IN(SELECT object_id FROM " . TABLE_PREFIX . "processed_objects)");
             $row = DB::executeOne("SELECT COUNT(object_id) AS 'row_count' FROM " . TABLE_PREFIX . "processed_objects");
             $proc_count = $row['row_count'];
             $status_message = "Memory limit exceeded (" . format_filesize(memory_get_usage(true)) . "). Script terminated. Processed Objects: {$proc_count}. Total: " . ($proc_count + $rest) . ". Please execute 'Fill searchable objects and sharing table' again.";
             $_SESSION['hide_back_button'] = 1;
             complete_migration_print("\n" . date("H:i:s") . " - Iteration finished or Memory limit exceeded (" . format_filesize(memory_get_usage(true)) . ") script terminated.\nProcessed Objects: " . count($processed_objects) . ".\nTotal processed objects: {$proc_count}.\n{$rest} objects left.\n{$separator}\n");
             $processed_objects = array();
             break;
         }
         $cant++;
     } else {
         $processed_objects[] = $obj;
     }
     $cobj = null;
 }
 // add mails to sharing table for account owners
 if ($sql != "") {
     $sql .= " ON DUPLICATE KEY UPDATE group_id=group_id;";
     DB::execute($sql);
     $sql = "";
 }
<?php

chdir(dirname(__FILE__));
header("Content-type: text/plain");
define("CONSOLE_MODE", true);
include "init.php";
Env::useHelper('format');
define('SCRIPT_MEMORY_LIMIT', 1024 * 1024 * 1024);
// 1 GB
@set_time_limit(0);
ini_set('memory_limit', SCRIPT_MEMORY_LIMIT / (1024 * 1024) + 50 . 'M');
$i = 0;
$objects_ids = Objects::instance()->findAll(array('columns' => array('id'), 'id' => true));
//,'conditions' => 'object_type_id = 6'
echo "\nObjects to process: " . count($objects_ids) . "\n-----------------------------------------------------------------";
foreach ($objects_ids as $object_id) {
    $object = Objects::findObject($object_id);
    $i++;
    if ($object instanceof ContentDataObject) {
        $members = $object->getMembers();
        DB::execute("DELETE FROM " . TABLE_PREFIX . "object_members WHERE object_id = " . $object->getId() . " AND is_optimization = 1;");
        ObjectMembers::addObjectToMembers($object->getId(), $members);
    } else {
        //
    }
    if ($i % 100 == 0) {
        echo "\n{$i} objects processed. Mem usage: " . format_filesize(memory_get_usage(true));
    }
}
Example #10
0
	if(empty($record['description'])) $record['description'] = JText::_('STATS_LABEL_NODESCRIPTION');
	?>
		<tr class="row<?php echo $id; ?>">
			<td><?php echo $check; ?></td>
			<td>
				<?php echo $this->escape($record['description']) ?>
			</td>
			<td>
				<?php if( AKEEBA_JVERSION == '16' ): ?>
					<?php echo $startTime->format(JText::_('DATE_FORMAT_LC2'), true); ?>
				<?php else: ?>
					<?php echo $startTime->toFormat(JText::_('DATE_FORMAT_LC2')); ?>
				<?php endif; ?>
			</td>
			<td class="bufa-<?php echo $record['meta']; ?>"><?php echo $status ?></td>
			<td><?php echo ($record['meta'] == 'ok') ? format_filesize($record['size']) : ($record['total_size'] > 0 ? "(<i>".format_filesize($record['total_size'])."</i>)" : '&mdash;') ?></td>
			<td>
				<?php echo $filename_col; ?>
				<?php if($record['meta'] == 'ok'): ?>
					<br/>
					<?php
						$infoParts = explode("\n", $record['comment']);
						$info = json_decode($infoParts[1]);
					?>
					<?php echo JText::_($info->type) .': '. $info->name ?>
					<?php if($info->version): ?>
					&bull;
					<?php echo JText::_('BUADMIN_LABEL_VERSION')?>: <?php echo $info->version ?>
					<?php if($info->date) echo " &bull; "?>
					<?php endif?>
					<?php if($info->date): ?>
    <li>
<?php 
        $attached_file_options = array();
        $attached_file_options[] = '<a href="' . $attached_file->getDetailsUrl() . '">' . lang('file details') . '</a>';
        if ($attached_files_object->canDetachFile(logged_user(), $attached_file)) {
            $attached_file_options[] = '<a href="' . $attached_files_object->getDetachFileUrl($attached_file) . '" onclick="return confirm(\'' . lang('confirm detach file') . '\')">' . lang('detach file') . '</a>';
        }
        ?>
      <a href="<?php 
        echo $attached_file->getDownloadUrl();
        ?>
"><span><?php 
        echo clean($attached_file->getFilename());
        ?>
</span> (<?php 
        echo format_filesize($attached_file->getFilesize());
        ?>
)</a> | <?php 
        echo implode(' | ', $attached_file_options);
        ?>
    </li>
<?php 
    }
    // foreach
    ?>
  </ul>
<?php 
    if ($attached_files_object->canAttachFile(logged_user(), $attached_files_object->getProject())) {
        ?>
  <p><a href="<?php 
        echo $attached_files_object->getAttachFilesUrl();
 function SaveMail(&$content, MailAccount $account, $uidl, $state = 0, $imap_folder_name = '')
 {
     if (defined('DEBUG_EMAIL_RETRIEVAL') && DEBUG_EMAIL_RETRIEVAL) {
         self::log_connection_status();
         Logger::log("UID: {$uidl}");
     }
     if (!mysql_ping(DB::connection()->getLink())) {
         DB::connection()->reconnect();
         Logger::log("*** Connection Lost -> Reconnected ***");
     }
     if (defined('DEBUG_EMAIL_RETRIEVAL') && DEBUG_EMAIL_RETRIEVAL) {
         Logger::log("mem  1) " . format_filesize(memory_get_usage()));
     }
     if (strpos($content, '+OK ') > 0) {
         $content = substr($content, strpos($content, '+OK '));
     }
     if (defined('DEBUG_EMAIL_RETRIEVAL') && DEBUG_EMAIL_RETRIEVAL) {
         Logger::log("mem  2) " . format_filesize(memory_get_usage()));
     }
     self::parseMail($content, $decoded, $parsedMail, $warnings);
     if (defined('DEBUG_EMAIL_RETRIEVAL') && DEBUG_EMAIL_RETRIEVAL) {
         Logger::log("mem  3) " . format_filesize(memory_get_usage()));
     }
     $encoding = array_var($parsedMail, 'Encoding', 'UTF-8');
     $enc_conv = EncodingConverter::instance();
     $to_addresses = self::getAddresses(array_var($parsedMail, "To"));
     $from = self::getAddresses(array_var($parsedMail, "From"));
     $message_id = self::getHeaderValueFromContent($content, "Message-ID");
     $in_reply_to_id = self::getHeaderValueFromContent($content, "In-Reply-To");
     if (defined('DEBUG_EMAIL_RETRIEVAL') && DEBUG_EMAIL_RETRIEVAL) {
         Logger::log("mem  4) " . format_filesize(memory_get_usage()));
     }
     $uid = trim($uidl);
     if (str_starts_with($uid, '<') && str_ends_with($uid, '>')) {
         $uid = utf8_substr($uid, 1, utf8_strlen($uid, $encoding) - 2, $encoding);
     }
     if ($uid == '') {
         $uid = trim($message_id);
         if ($uid == '') {
             $uid = array_var($parsedMail, 'Subject', 'MISSING UID');
         }
         if (str_starts_with($uid, '<') && str_ends_with($uid, '>')) {
             $uid = utf8_substr($uid, 1, utf8_strlen($uid, $encoding) - 2, $encoding);
         }
         if (MailContents::mailRecordExists($account->getId(), $uid, $imap_folder_name == '' ? null : $imap_folder_name)) {
             return;
         }
     }
     if (!$from) {
         $parsedMail["From"] = self::getFromAddressFromContent($content);
         $from = array_var($parsedMail["From"][0], 'address', '');
         if (defined('DEBUG_EMAIL_RETRIEVAL') && DEBUG_EMAIL_RETRIEVAL) {
             Logger::log("mem  4.1) " . format_filesize(memory_get_usage()));
         }
     }
     if (defined('DEBUG_EMAIL_RETRIEVAL') && DEBUG_EMAIL_RETRIEVAL) {
         Logger::log("mem  5) " . format_filesize(memory_get_usage()));
     }
     if (defined('EMAIL_MESSAGEID_CONTROL') && EMAIL_MESSAGEID_CONTROL) {
         if (trim($message_id) != "") {
             $id_condition = " AND `message_id`='" . trim($message_id) . "'";
         } else {
             $id_condition = " AND `subject`='" . trim(array_var($parsedMail, 'Subject')) . "' AND `from`='{$from}'";
             if (array_var($parsedMail, 'Date')) {
                 $sent_date_dt = new DateTimeValue(strtotime(array_var($parsedMail, 'Date')));
                 $sent_date_str = $sent_date_dt->toMySQL();
                 $id_condition .= " AND `sent_date`='" . $sent_date_str . "'";
             }
         }
         $same = MailContents::findOne(array('conditions' => "`account_id`=" . $account->getId() . $id_condition, 'include_trashed' => true));
         if ($same instanceof MailContent) {
             return;
         }
     }
     if ($state == 0) {
         if ($from == $account->getEmailAddress()) {
             if (strpos($to_addresses, $from) !== FALSE) {
                 $state = 5;
             } else {
                 $state = 1;
             }
             //Show only in sent folder
         }
     }
     if (defined('DEBUG_EMAIL_RETRIEVAL') && DEBUG_EMAIL_RETRIEVAL) {
         Logger::log("mem  6) " . format_filesize(memory_get_usage()));
         self::log_connection_status();
     }
     $from_spam_junk_folder = strpos(strtolower($imap_folder_name), 'spam') !== FALSE || strpos(strtolower($imap_folder_name), 'junk') !== FALSE || strpos(strtolower($imap_folder_name), 'trash') !== FALSE;
     $user_id = logged_user() instanceof User ? logged_user()->getId() : $account->getUserId();
     if (defined('DEBUG_EMAIL_RETRIEVAL') && DEBUG_EMAIL_RETRIEVAL) {
         self::log_connection_status();
     }
     $max_spam_level = user_config_option('max_spam_level', null, $user_id);
     if ($max_spam_level < 0) {
         $max_spam_level = 0;
     }
     $mail_spam_level = strlen(trim(array_var($decoded[0]['Headers'], 'x-spam-level:', '')));
     // if max_spam_level >= 10 then nothing goes to junk folder
     $spam_in_subject = false;
     if (config_option('check_spam_in_subject')) {
         $spam_in_subject = strpos_utf(strtoupper(array_var($parsedMail, 'Subject')), "**SPAM**") !== false;
     }
     if ($max_spam_level < 10 && ($mail_spam_level > $max_spam_level || $from_spam_junk_folder) || $spam_in_subject) {
         $state = 4;
         // send to Junk folder
     }
     if (defined('DEBUG_EMAIL_RETRIEVAL') && DEBUG_EMAIL_RETRIEVAL) {
         Logger::log("mem  7) " . format_filesize(memory_get_usage()));
         self::log_connection_status();
     }
     if (!isset($parsedMail['Subject'])) {
         $parsedMail['Subject'] = '';
     }
     $mail = new MailContent();
     $mail->setAccountId($account->getId());
     $mail->setState($state);
     $mail->setImapFolderName($imap_folder_name);
     $mail->setFrom($from);
     $cc = trim(self::getAddresses(array_var($parsedMail, "Cc")));
     if ($cc == '' && array_var($decoded, 0) && array_var($decoded[0], 'Headers')) {
         $cc = array_var($decoded[0]['Headers'], 'cc:', '');
     }
     if (defined('DEBUG_EMAIL_RETRIEVAL') && DEBUG_EMAIL_RETRIEVAL) {
         self::log_connection_status();
         Logger::log("mem  8) " . format_filesize(memory_get_usage()));
     }
     $mail->setCc($cc);
     $from_name = trim(array_var(array_var(array_var($parsedMail, 'From'), 0), 'name'));
     $from_encoding = detect_encoding($from_name);
     if ($from_name == '') {
         $from_name = $from;
     } else {
         if (strtoupper($encoding) == 'KOI8-R' || strtoupper($encoding) == 'CP866' || $from_encoding != 'UTF-8' || !$enc_conv->isUtf8RegExp($from_name)) {
             //KOI8-R and CP866 are Russian encodings which PHP does not detect
             $utf8_from = $enc_conv->convert($encoding, 'UTF-8', $from_name);
             if ($enc_conv->hasError()) {
                 $utf8_from = utf8_encode($from_name);
             }
             $utf8_from = utf8_safe($utf8_from);
             $mail->setFromName($utf8_from);
         } else {
             $mail->setFromName($from_name);
         }
     }
     $subject_aux = $parsedMail['Subject'];
     $subject_encoding = detect_encoding($subject_aux);
     if (strtoupper($encoding) == 'KOI8-R' || strtoupper($encoding) == 'CP866' || $subject_encoding != 'UTF-8' || !$enc_conv->isUtf8RegExp($subject_aux)) {
         //KOI8-R and CP866 are Russian encodings which PHP does not detect
         $utf8_subject = $enc_conv->convert($encoding, 'UTF-8', $subject_aux);
         if ($enc_conv->hasError()) {
             $utf8_subject = utf8_encode($subject_aux);
         }
         $utf8_subject = utf8_safe($utf8_subject);
         $mail->setSubject($utf8_subject);
     } else {
         $utf8_subject = utf8_safe($subject_aux);
         $mail->setSubject($utf8_subject);
     }
     if (defined('DEBUG_EMAIL_RETRIEVAL') && DEBUG_EMAIL_RETRIEVAL) {
         self::log_connection_status();
         Logger::log("mem  9) " . format_filesize(memory_get_usage()));
     }
     $mail->setTo($to_addresses);
     $sent_timestamp = false;
     if (array_key_exists("Date", $parsedMail)) {
         $sent_timestamp = strtotime($parsedMail["Date"]);
     }
     if ($sent_timestamp === false || $sent_timestamp === -1 || $sent_timestamp === 0) {
         $mail->setSentDate(DateTimeValueLib::now());
     } else {
         $mail->setSentDate(new DateTimeValue($sent_timestamp));
     }
     // if this constant is defined, mails older than this date will not be fetched
     if (defined('FIRST_MAIL_DATE')) {
         $first_mail_date = DateTimeValueLib::makeFromString(FIRST_MAIL_DATE);
         if ($mail->getSentDate()->getTimestamp() < $first_mail_date->getTimestamp()) {
             // return true to stop getting older mails from the server
             return true;
         }
     }
     $received_timestamp = false;
     if (array_key_exists("Received", $parsedMail) && $parsedMail["Received"]) {
         $received_timestamp = strtotime($parsedMail["Received"]);
     }
     if ($received_timestamp === false || $received_timestamp === -1 || $received_timestamp === 0) {
         $mail->setReceivedDate($mail->getSentDate());
     } else {
         $mail->setReceivedDate(new DateTimeValue($received_timestamp));
         if ($state == 5 && $mail->getSentDate()->getTimestamp() > $received_timestamp) {
             $mail->setReceivedDate($mail->getSentDate());
         }
     }
     if (defined('DEBUG_EMAIL_RETRIEVAL') && DEBUG_EMAIL_RETRIEVAL) {
         self::log_connection_status();
         Logger::log("mem 10) " . format_filesize(memory_get_usage()));
     }
     $mail->setSize(strlen($content));
     $mail->setHasAttachments(!empty($parsedMail["Attachments"]));
     $mail->setCreatedOn(new DateTimeValue(time()));
     $mail->setCreatedById($account->getUserId());
     $mail->setAccountEmail($account->getEmail());
     $mail->setMessageId($message_id);
     $mail->setInReplyToId($in_reply_to_id);
     $mail->setUid($uid);
     $type = array_var($parsedMail, 'Type', 'text');
     switch ($type) {
         case 'html':
             $utf8_body = $enc_conv->convert($encoding, 'UTF-8', array_var($parsedMail, 'Data', ''));
             if ($enc_conv->hasError()) {
                 $utf8_body = utf8_encode(array_var($parsedMail, 'Data', ''));
             }
             $utf8_body = utf8_safe($utf8_body);
             $mail->setBodyHtml($utf8_body);
             break;
         case 'text':
             $utf8_body = $enc_conv->convert($encoding, 'UTF-8', array_var($parsedMail, 'Data', ''));
             if ($enc_conv->hasError()) {
                 $utf8_body = utf8_encode(array_var($parsedMail, 'Data', ''));
             }
             $utf8_body = utf8_safe($utf8_body);
             $mail->setBodyPlain($utf8_body);
             break;
         case 'delivery-status':
             $utf8_body = $enc_conv->convert($encoding, 'UTF-8', array_var($parsedMail, 'Response', ''));
             if ($enc_conv->hasError()) {
                 $utf8_body = utf8_encode(array_var($parsedMail, 'Response', ''));
             }
             $utf8_body = utf8_safe($utf8_body);
             $mail->setBodyPlain($utf8_body);
             break;
         default:
             break;
     }
     if (isset($parsedMail['Alternative'])) {
         foreach ($parsedMail['Alternative'] as $alt) {
             if ($alt['Type'] == 'html' || $alt['Type'] == 'text') {
                 $body = $enc_conv->convert(array_var($alt, 'Encoding', 'UTF-8'), 'UTF-8', array_var($alt, 'Data', ''));
                 if ($enc_conv->hasError()) {
                     $body = utf8_encode(array_var($alt, 'Data', ''));
                 }
                 // remove large white spaces
                 $exploded = preg_split("/[\\s]+/", $body, -1, PREG_SPLIT_NO_EMPTY);
                 $body = implode(" ", $exploded);
                 // remove html comments
                 $body = preg_replace('/<!--.*-->/i', '', $body);
             }
             $body = utf8_safe($body);
             if ($alt['Type'] == 'html') {
                 $mail->setBodyHtml($body);
             } else {
                 if ($alt['Type'] == 'text') {
                     $plain = html_to_text(html_entity_decode($utf8_body, null, "UTF-8"));
                     $mail->setBodyPlain($plain);
                 }
             }
             // other alternative parts (like images) are not saved in database.
         }
     }
     $repository_id = self::SaveContentToFilesystem($mail->getUid(), $content);
     $mail->setContentFileId($repository_id);
     if (defined('DEBUG_EMAIL_RETRIEVAL') && DEBUG_EMAIL_RETRIEVAL) {
         self::log_connection_status();
         Logger::log("mem 11) " . format_filesize(memory_get_usage()));
     }
     try {
         if ($in_reply_to_id != "") {
             if ($message_id != "") {
                 $conv_mail = MailContents::findOne(array("conditions" => "`account_id`=" . $account->getId() . " AND `in_reply_to_id` = '{$message_id}'"));
                 if (!$conv_mail) {
                     $conv_mail = MailContents::findOne(array("conditions" => "`account_id`=" . $account->getId() . " AND `message_id` = '{$in_reply_to_id}'"));
                 } else {
                     // Search for other discontinued conversation part to link it
                     $other_conv_emails = MailContents::findAll(array("conditions" => "`account_id`=" . $account->getId() . " AND `message_id` = '{$in_reply_to_id}' AND `conversation_id`<>" . $conv_mail->getConversationId()));
                 }
             } else {
                 $conv_mail = MailContents::findOne(array("conditions" => "`account_id`=" . $account->getId() . " AND `message_id` = '{$in_reply_to_id}'"));
             }
             if ($conv_mail instanceof MailContent) {
                 // Remove "Re: ", "Fwd: ", etc to compare the subjects
                 $conv_original_subject = strtolower($conv_mail->getSubject());
                 if (($pos = strrpos($conv_original_subject, ":")) !== false) {
                     $conv_original_subject = trim(substr($conv_original_subject, $pos + 1));
                 }
             }
             if ($conv_mail instanceof MailContent && strpos(strtolower($mail->getSubject()), strtolower($conv_original_subject)) !== false) {
                 $mail->setConversationId($conv_mail->getConversationId());
                 if (isset($other_conv_emails) && is_array($other_conv_emails)) {
                     foreach ($other_conv_emails as $ocm) {
                         $ocm->setConversationId($conv_mail->getConversationId());
                         $ocm->save();
                     }
                 }
             } else {
                 $conv_id = MailContents::getNextConversationId($account->getId());
                 $mail->setConversationId($conv_id);
             }
         } else {
             $conv_id = MailContents::getNextConversationId($account->getId());
             $mail->setConversationId($conv_id);
         }
         if (defined('DEBUG_EMAIL_RETRIEVAL') && DEBUG_EMAIL_RETRIEVAL) {
             self::log_connection_status();
             Logger::log("mem 12) " . format_filesize(memory_get_usage()));
         }
         $mail->save();
         if (defined('DEBUG_EMAIL_RETRIEVAL') && DEBUG_EMAIL_RETRIEVAL) {
             self::log_connection_status();
             Logger::log("mem 13) " . format_filesize(memory_get_usage()));
         }
         // CLASSIFY RECEIVED MAIL WITH THE CONVERSATION
         if (user_config_option('classify_mail_with_conversation', null, $account->getUserId()) && isset($conv_mail) && $conv_mail instanceof MailContent) {
             $wss = $conv_mail->getWorkspaces();
             foreach ($wss as $ws) {
                 $acc_user = Users::findById($account->getUserId());
                 if ($acc_user instanceof User && $acc_user->hasProjectPermission($ws, ProjectUsers::CAN_READ_MAILS)) {
                     $mail->addToWorkspace($ws);
                 }
             }
         }
         // CLASSIFY MAILS IF THE ACCOUNT HAS A WORKSPACE
         if ($account->getColumnValue('workspace', 0) != 0) {
             $workspace = Projects::findById($account->getColumnValue('workspace', 0));
             if ($workspace && $workspace instanceof Project && !$mail->hasWorkspace($workspace)) {
                 $mail->addToWorkspace($workspace);
             }
         }
         //END CLASSIFY
         $user = Users::findById($account->getUserId());
         if ($user instanceof User) {
             $mail->subscribeUser($user);
         }
     } catch (Exception $e) {
         FileRepository::deleteFile($repository_id);
         if (strpos($e->getMessage(), "Query failed with message 'Got a packet bigger than 'max_allowed_packet' bytes'") === false) {
             throw $e;
         }
     }
     unset($parsedMail);
     if (defined('DEBUG_EMAIL_RETRIEVAL') && DEBUG_EMAIL_RETRIEVAL) {
         Logger::log("mem fin) " . format_filesize(memory_get_usage()));
         self::log_connection_status();
     }
     return false;
 }
Example #13
0
                    $sql = "";
                    $first_row = true;
                }
            }
        }
        $processed_objects[] = $cobj->getId();
        // check memory to stop script
        if (memory_get_usage(true) > SCRIPT_MEMORY_LIMIT) {
            $processed_objects_ids = "(" . implode("),(", $processed_objects) . ")";
            DB::execute("INSERT INTO " . TABLE_PREFIX . "processed_objects (object_id) VALUES {$processed_objects_ids} ON DUPLICATE KEY UPDATE object_id=object_id");
            $rest = Objects::count("id NOT IN(SELECT object_id FROM " . TABLE_PREFIX . "processed_objects)");
            $row = DB::executeOne("SELECT COUNT(object_id) AS 'row_count' FROM " . TABLE_PREFIX . "processed_objects");
            $proc_count = $row['row_count'];
            $status_message = "Memory limit exceeded (" . format_filesize(memory_get_usage(true)) . "). Script terminated. Processed Objects: {$proc_count}. Total: " . ($proc_count + $rest) . ". Please execute 'Fill searchable objects and sharing table' again.";
            $_SESSION['hide_back_button'] = 1;
            complete_migration_print("\n" . date("H:i:s") . " - Memory limit exceeded (" . format_filesize(memory_get_usage(true)) . ") script terminated. Processed Objects: " . count($processed_objects) . ". Total: {$proc_count}.");
            $processed_objects = array();
            break;
        }
        $cant++;
    }
    $cobj = null;
}
// add mails to sharing table for account owners
if ($sql != "") {
    $sql .= " ON DUPLICATE KEY UPDATE group_id=group_id;";
    DB::execute($sql);
    $sql = "";
}
if (count($processed_objects) > 0) {
    $processed_objects_ids = "(" . implode("),(", $processed_objects) . ")";
Example #14
0
 /**
 * Returns product signature (name and version). If user is not logged in and
 * is not member of owner company he will see only product name
 *
 * @param void
 * @return string
 */
 function product_signature() {
   if (function_exists('logged_user') && (logged_user() instanceof User) && logged_user()->isMemberOfOwnerCompany()) {
     $result = lang('footer powered', 'http://www.projectpier.org/', clean(product_name()) . ' ' . product_version());
     if (Env::isDebugging()) {
       ob_start();
       benchmark_timer_display(false);
       $result .= '. ' . ob_get_clean();
       if (function_exists('memory_get_usage')) {
         $result .= '. ' . format_filesize(memory_get_usage());
       } // if
     } // if
     return $result;
   } else {
     return lang('footer powered', 'http://www.ProjectPier.org/', clean(product_name()));
   } // if
 } // product_signature
Example #15
0
			<?php 
			if($file->getType() == ProjectFiles::TYPE_DOCUMENT){
				if (!isset($checkin)) {?>
				<div class="header">
					<?php echo checkbox_field('file[update_file]', array_var($file_data, 'update_file'), array('class' => 'checkbox', 'id' => $genid . 'fileFormUpdateFile', 'tabindex' => '60', 'onclick' => 'App.modules.addFileForm.updateFileClick(\'' . $genid .'\')')) ?>
					<?php echo label_tag(lang('update file'), $genid .'fileFormUpdateFile', false, array('class' => 'checkbox'), '') ?>
				</div>
				<div id="<?php echo $genid ?>updateFileDescription">
					<p><?php echo lang('replace file description') ?></p>
				</div>
			<?php } // if ?>
			<div id="<?php echo $genid ?>updateFileForm"  style="<?php echo isset($checkin) ? '': 'display:none' ?>">
				<p>
					<strong><?php echo lang('existing file') ?>:</strong>
					<a target="_blank" href="<?php echo $file->getDownloadUrl() ?>" id="extension_old"><?php echo clean($file->getFilename()) ?></a>
					| <?php echo format_filesize($file->getFilesize()) ?>
				</p>
				<p id="warning_extension_file"></p>
				<div id="<?php echo $genid ?>selectFileControlDiv">
					<?php echo label_tag(lang('new file'), $genid.'fileFormFile', true) ?>
					<?php
						Hook::fire('render_upload_control', array(
							"genid" => $genid,
							"attributes" => array(
								"id" => $genid . "fileFormFile",
								"tabindex" => "65",
								"size" => 88,
								"style" => 'width:530px',
							)
						), $ret);
					?>
Example #16
0
	<a href="<?=site_url('products/web_hosting/reset_ftp_password/'.$psid.'/'.$domain)?>" class="button">
		Reset FTP Password
	</a>
</div>
<div class="mid header">
	<h5>Profile and System Resources</h5>
</div>
<div class="mid body">
	<div class="floatr">
		<img src="<?=$charts['disk_usage']?>" /> <br/>
		<img src="<?=$charts['bandwidth_usage']?>" />
	</div>
	<p class="clearfix">
		<strong>GUID:</strong> <?=$data['gen_info']['guid']?><br/>
		<strong>Bandwidth Usage:</strong> <?=format_filesize($data['stat']['traffic'])?> / <?=format_filesize($data['limits']['max_traffic'])?><br/>
		<strong>Disk Usage:</strong> <?=format_filesize($data['gen_info']['real_size'])?> / <?=format_filesize($data['limits']['disk_space'])?><br/>
		<strong>Database Count:</strong> <?=$data['stat']['db']?> / <?=($data['limits']['max_db'] == -1) ? 'Unlimited' : $data['limits']['max_db']?><br/>
		<?php 
			$hosting = $data['hosting'];
			foreach ($hosting as $key=>$property) {
				
				// Ditch The Useless Data
				if (
					$key == 'ftp_password' OR
					substr($key, 0, 2) == "fp"
				) {
					unset($hosting[$key]);
				} else {
					// Replacements
					$replace['PHP'] = '/php/';
					$replace['CGI'] = '/cgi/';
Example #17
0
</span></a></td>
	
	<td style="text-align:right;">
	<?php 
if ($linked_object instanceof ProjectFile && $linked_object->getType() == ProjectFiles::TYPE_DOCUMENT) {
    $download_url = $linked_object->getDownloadUrl();
    include_once ROOT . "/library/browser/Browser.php";
    if (Browser::instance()->getBrowser() == Browser::BROWSER_IE) {
        $download_url = "javascript:location.href = '{$download_url}';";
    }
    ?>
		<a target="_self" href="<?php 
    echo $download_url;
    ?>
"><?php 
    echo lang('download') . ' (' . format_filesize($linked_object->getFilesize()) . ')';
    ?>
</a> | 
	<?php 
}
if ($linked_object instanceof ProjectWebpage || $linked_object instanceof ProjectFile && $linked_object->getType() == ProjectFiles::TYPE_WEBLINK) {
    ?>
		<a target="_blank" href="<?php 
    echo $linked_object->getUrl();
    ?>
"><?php 
    echo lang('open weblink');
    ?>
</a> |
	<?php 
}
 function list_files()
 {
     ajx_current("empty");
     // get query parameters
     $start = (int) array_var($_GET, 'start');
     $limit = (int) array_var($_GET, 'limit');
     if (!$start) {
         $start = 0;
     }
     if (!$limit) {
         $limit = config_option('files_per_page');
     }
     $order = array_var($_GET, 'sort');
     $order_dir = array_var($_GET, 'dir');
     $page = (int) ($start / $limit) + 1;
     $hide_private = !logged_user()->isMemberOfOwnerCompany();
     $type = array_var($_GET, 'type');
     $user = array_var($_GET, 'user');
     // if there's an action to execute, do so
     if (array_var($_GET, 'action') == 'delete') {
         $ids = explode(',', array_var($_GET, 'objects'));
         $succ = 0;
         $err = 0;
         foreach ($ids as $id) {
             $file = ProjectFiles::findById($id);
             if (isset($file) && $file->canDelete(logged_user())) {
                 try {
                     DB::beginWork();
                     $file->trash();
                     DB::commit();
                     ApplicationLogs::createLog($file, ApplicationLogs::ACTION_TRASH);
                     $succ++;
                 } catch (Exception $e) {
                     DB::rollback();
                     $err++;
                 }
             } else {
                 if (!$file instanceof ProjectFile) {
                     evt_add("popup", array('title' => lang('error'), 'message' => lang("file dnx")));
                 } else {
                     if (!$file->canDelete(logged_user())) {
                         evt_add("popup", array('title' => lang('error'), 'message' => lang("cannot delete file", $file->getObjectName())));
                     }
                 }
                 $err++;
             }
         }
         if ($succ > 0) {
             flash_success(lang("success delete files", $succ));
         } else {
             flash_error(lang("error delete files", $err));
         }
     } else {
         if (array_var($_GET, 'action') == 'markasread') {
             $ids = explode(',', array_var($_GET, 'objects'));
             $succ = 0;
             $err = 0;
             foreach ($ids as $id) {
                 $file = ProjectFiles::findById($id);
                 try {
                     $file->setIsRead(logged_user()->getId(), true);
                     $succ++;
                 } catch (Exception $e) {
                     $err++;
                 }
                 // try
             }
             //for
             if ($succ <= 0) {
                 flash_error(lang("error markasread files", $err));
             }
         } else {
             if (array_var($_GET, 'action') == 'markasunread') {
                 $ids = explode(',', array_var($_GET, 'objects'));
                 $succ = 0;
                 $err = 0;
                 foreach ($ids as $id) {
                     $file = ProjectFiles::findById($id);
                     try {
                         $file->setIsRead(logged_user()->getId(), false);
                         $succ++;
                     } catch (Exception $e) {
                         $err++;
                     }
                     // try
                 }
                 //for
                 if ($succ <= 0) {
                     flash_error(lang("error markasunread files", $err));
                 }
             } else {
                 if (array_var($_GET, 'action') == 'zip_add') {
                     $this->zip_add();
                 } else {
                     if (array_var($_GET, 'action') == 'archive') {
                         $ids = explode(',', array_var($_GET, 'ids'));
                         $succ = 0;
                         $err = 0;
                         foreach ($ids as $id) {
                             $file = ProjectFiles::findById($id);
                             if (isset($file) && $file->canEdit(logged_user())) {
                                 try {
                                     DB::beginWork();
                                     $file->archive();
                                     DB::commit();
                                     ApplicationLogs::createLog($file, ApplicationLogs::ACTION_ARCHIVE);
                                     $succ++;
                                 } catch (Exception $e) {
                                     DB::rollback();
                                     $err++;
                                 }
                             } else {
                                 $err++;
                             }
                         }
                         if ($succ > 0) {
                             flash_success(lang("success archive objects", $succ));
                         } else {
                             flash_error(lang("error archive objects", $err));
                         }
                     }
                 }
             }
         }
     }
     Hook::fire('classify_action', null, $ret);
     $join_params = null;
     $select_columns = null;
     $extra_conditions = "";
     if (strpos($order, 'p_') == 1) {
         $cpId = substr($order, 3);
         $order = 'customProp';
     }
     if ($order == ProjectFiles::ORDER_BY_POSTTIME) {
         $order = '`created_on`';
     } else {
         if ($order == ProjectFiles::ORDER_BY_MODIFYTIME) {
             $order = '`updated_on`';
         } else {
             if ($order == ProjectFiles::ORDER_BY_SIZE) {
                 $order = '`jt`.`filesize`';
                 $join_params = array('table' => ProjectFileRevisions::instance()->getTableName(), 'jt_field' => 'file_id', 'e_field' => 'object_id');
                 $extra_conditions .= " AND `jt`.`object_id` = (SELECT max(`x`.`object_id`) FROM " . TABLE_PREFIX . "project_file_revisions `x` WHERE `x`.`file_id` = `e`.`object_id`)";
             } else {
                 if ($order == 'customProp') {
                     $order = 'IF(ISNULL(jt.value),1,0),jt.value';
                     $join_params['join_type'] = "LEFT ";
                     $join_params['table'] = "" . TABLE_PREFIX . "custom_property_values";
                     $join_params['jt_field'] = "object_id";
                     $join_params['e_field'] = "object_id";
                     $join_params['on_extra'] = "AND custom_property_id = " . $cpId;
                     $extra_conditions .= " AND ( custom_property_id = " . $cpId . " OR custom_property_id IS NULL)";
                     $select_columns = array("DISTINCT o.*", "e.*");
                 } else {
                     $order = '`name`';
                 }
             }
         }
     }
     // if
     $extra_conditions .= $hide_private ? 'AND `is_visible` = 1' : '';
     // filter attachments of other people if not filtering
     $tmp_mids = array();
     foreach (active_context() as $selection) {
         if ($selection instanceof Member) {
             $d = $selection->getDimension();
             if ($d instanceof Dimension && $d->getIsManageable()) {
                 $tmp_mids[] = $selection->getId();
             }
         }
     }
     if (count($tmp_mids) == 0) {
         if (Plugins::instance()->isActivePlugin('mail')) {
             $extra_conditions .= " AND IF(e.mail_id=0, true, EXISTS (SELECT mac.contact_id FROM " . TABLE_PREFIX . "mail_account_contacts mac \r\n\t\t\t\t\tWHERE mac.contact_id=o.created_by_id AND mac.account_id=(SELECT mc.account_id FROM " . TABLE_PREFIX . "mail_contents mc WHERE mc.object_id=e.mail_id)))";
         }
     }
     Hook::fire("listing_extra_conditions", null, $extra_conditions);
     $only_count_result = array_var($_GET, 'only_result', false);
     $context = active_context();
     $objects = ProjectFiles::instance()->listing(array("order" => $order, "order_dir" => $order_dir, "extra_conditions" => $extra_conditions, "show_only_member_objects" => user_config_option('show_only_member_files'), 'count_results' => false, 'only_count_results' => $only_count_result, "join_params" => $join_params, "start" => $start, "limit" => $limit, "select_columns" => $select_columns));
     $custom_properties = CustomProperties::getAllCustomPropertiesByObjectType(ProjectFiles::instance()->getObjectTypeId());
     // prepare response object
     $listing = array("totalCount" => $objects->total, "start" => $start, "objType" => ProjectFiles::instance()->getObjectTypeId(), "files" => array());
     if (is_array($objects->objects)) {
         $index = 0;
         $ids = array();
         foreach ($objects->objects as $o) {
             $coName = "";
             $coId = $o->getCheckedOutById();
             if ($coId != 0) {
                 if ($coId == logged_user()->getId()) {
                     $coName = "self";
                 } else {
                     $coUser = Contacts::findById($coId);
                     if ($coUser instanceof Contact) {
                         $coName = $coUser->getObjectName();
                     } else {
                         $coName = "";
                     }
                 }
             }
             if ($o->isMP3()) {
                 $songname = $o->getProperty("songname");
                 $artist = $o->getProperty("songartist");
                 $album = $o->getProperty("songalbum");
                 $track = $o->getProperty("songtrack");
                 $year = $o->getProperty("songyear");
                 $duration = $o->getProperty("songduration");
                 $songInfo = json_encode(array($songname, $artist, $album, $track, $year, $duration, $o->getDownloadUrl(), $o->getFilename(), $o->getId()));
             } else {
                 $songInfo = array();
             }
             $ids[] = $o->getId();
             $values = array("id" => $o->getId(), "ix" => $index++, "object_id" => $o->getId(), "ot_id" => $o->getObjectTypeId(), "name" => $o->getObjectName(), "type" => $o->getTypeString(), "mimeType" => $o->getTypeString(), "createdBy" => clean($o->getCreatedByDisplayName()), "createdById" => $o->getCreatedById(), "dateCreated" => $o->getCreatedOn() instanceof DateTimeValue ? $o->getCreatedOn()->isToday() ? format_time($o->getCreatedOn()) : format_datetime($o->getCreatedOn()) : '', "dateCreated_today" => $o->getCreatedOn() instanceof DateTimeValue ? $o->getCreatedOn()->isToday() : 0, "updatedBy" => clean($o->getUpdatedByDisplayName()), "updatedById" => $o->getUpdatedById(), "dateUpdated" => $o->getUpdatedOn() instanceof DateTimeValue ? $o->getUpdatedOn()->isToday() ? format_time($o->getUpdatedOn()) : format_datetime($o->getUpdatedOn()) : '', "dateUpdated_today" => $o->getUpdatedOn() instanceof DateTimeValue ? $o->getUpdatedOn()->isToday() : 0, "icon" => $o->getTypeIconUrl(), "size" => format_filesize($o->getFileSize()), "url" => $o->getOpenUrl(), "manager" => get_class($o->manager()), "checkedOutByName" => $coName, "checkedOutById" => $coId, "isModifiable" => $o->isModifiable() && $o->canEdit(logged_user()), "modifyUrl" => $o->getModifyUrl(), "songInfo" => $songInfo, "ftype" => $o->getType(), "url" => $o->getUrl(), "memPath" => json_encode($o->getMembersIdsToDisplayPath()), "genid" => gen_id());
             if ($o->isMP3()) {
                 $values['isMP3'] = true;
             }
             Hook::fire('add_classification_value', $o, $values);
             foreach ($custom_properties as $cp) {
                 $values['cp_' . $cp->getId()] = get_custom_property_value_for_listing($cp, $o);
             }
             $listing["files"][] = $values;
         }
         $read_objects = ReadObjects::getReadByObjectList($ids, logged_user()->getId());
         foreach ($listing["files"] as &$data) {
             $data['isRead'] = isset($read_objects[$data['object_id']]);
         }
         ajx_extra_data($listing);
         tpl_assign("listing", $listing);
     } else {
         throw new Error("Not array", $code);
     }
 }
Example #19
0
			<?php 
				if (
					is_array($entry['attachments']) 
					AND count($entry['attachments']) > 0
					AND isset($entry['attachments']['recording.mp3']) !== true
				): 
			?>
			<h5>Attachments (<?=count($entry['attachments'])?>)</h5>
			<p>
				<ul>
					<?php foreach ($entry['attachments'] as $file) : ?>
					<li>
						<a href="<?=site_url('communication/attachment/'.$entry['fingerprint'].'/'.basename($file['name']))?>">
							<?=basename($file['name'])?>
						</a>
						<em><?=format_filesize($file['size'])?></em>
					</li>
					<?php endforeach; ?>
				</ul>
			</p>
			<?php endif; ?>
			<div>
				<?php $profile = $this->profile->get($entry['source']) ?>
				<em>Received from <?php 
					if ($profile->exists())
					{
						echo profile_link($entry['source']);
					}
					elseif (is_tel($entry['source']) === true)
					{
						echo tel_format($entry['source']);
Example #20
0
  <div class="availableVerion">
    <h2><a href="<?php 
        echo $version->getDetailsUrl();
        ?>
"><?php 
        echo clean($version->getSignature());
        ?>
</a></h2>
    <div class="releaseNotes"><?php 
        echo do_textile($version->getReleaseNotes());
        ?>
</div>
<?php 
        $download_links = array();
        foreach ($version->getDownloadLinks() as $download_link) {
            $download_links[] = '<a href="' . $download_link->getUrl() . '">' . clean($download_link->getFormat()) . ' (' . format_filesize($download_link->getSize()) . ')</a>';
        }
        // foreach
        ?>
    <div class="downloadLinks"><strong><?php 
        echo lang('download');
        ?>
:</strong> <?php 
        echo implode(' | ', $download_links);
        ?>
</div>
  </div>
<?php 
    }
    // foreach
    ?>
Example #21
0
<div id="attachments">
  <h3>File Attachments</h3>
  <div class="files">
  </div>
  <div id="addline">
    <button id="btnAttach" class="native" type="button">Add attachment</button>
  </div>
  <?php 
if ($attachments) {
    ?>
    <script type="text/javascript">
      $(function() {
        <?php 
    while ($attach = $attachments->next()) {
        $size = format_filesize($attach->size);
        echo "addFile({$attach->id}, '{$attach->filename}', '{$size}');";
    }
    ?>
      });
    </script>
   <?php 
}
?>
</div>

<div class="actionbar" style="text-align: right">
  <div style="float:left">
    <button class="native" id="btnInsert" type="button">Insert placeholder</button>
    <select id="selInsertMenu">
      <option value="#firstname#">Applicant's first name</option>
$processed_objects = array();
$i = 0;
$msg = "";
echo "\nObjects to process: " . count($objects) . "\n-----------------------------------------------------------------";
foreach ($objects as $key => $object) {
    ContentDataObjects::addObjToSharingTable($object['id'], $object['object_type_id'], !is_null($object['member_id']));
    $processed_objects[] = $object['id'];
    $i++;
    $memory_limit_exceeded = memory_get_usage(true) > SCRIPT_MEMORY_LIMIT;
    if ($i % 100 == 0 || $memory_limit_exceeded) {
        echo "\n{$i} objects processed. Mem usage: " . format_filesize(memory_get_usage(true));
        if (count($processed_objects) > 0) {
            DB::execute("INSERT INTO fixed_objects (object_id) VALUES (" . implode('),(', $processed_objects) . ");");
            $processed_objects = array();
        }
        ob_flush();
        if ($memory_limit_exceeded) {
            $msg = "Memory limit exceeded: " . format_filesize(memory_get_usage(true));
            $drop_tmp_table = false;
            break;
        }
    }
}
echo "\n-----------------------------------------------------------------\nFinished: {$i} objects processed. {$msg}\n";
if (count($processed_objects) > 0) {
    DB::execute("INSERT INTO fixed_objects (object_id) VALUES (" . implode('),(', $processed_objects) . ");");
    $processed_objects = array();
    if ($drop_tmp_table) {
        DB::execute("DROP TABLE `fixed_objects`;");
    }
}
Example #23
0
    }
    ?>
  </div>
</div>
  <?php 
}
if ($dg_theme == 'customtheme') {
    $bg_img_over = '#' . $dg_body_background_td_hover;
    $bg_img_out = '#' . $dg_body_background;
} else {
    $bg_img_over = $dg_theme != 'lightteme' && $dg_theme == 'darktheme' ? '#909090' : '#FCFCFC';
    $bg_img_out = $dg_theme != 'lightteme' && $dg_theme == 'darktheme' ? '#808080' : '#F9F9F9';
}
if ($ad_showdetail) {
    $imgsize = filesize(JPATH_SITE . dgPath($ad_pathoriginals) . DS . $obj->imgoriginalname);
    $dgfilesize = format_filesize($imgsize);
    $size_pic[0] = "";
    $size_pic[1] = "";
    $size_pic = getimagesize(JPATH_SITE . dgPath($ad_pathoriginals) . DS . $obj->imgoriginalname);
    $x = "x";
    $res = "{$size_pic['0']} {$x} {$size_pic['1']}";
    $types = array(1 => 'GIF', 2 => 'JPG', 3 => 'PNG');
    $type = $types[$size_pic[2]];
    if ($is_admin || $user->id == $obj->owner_id) {
        echo "<script type=\"text/javascript\">\n      datso(document).ready(function(){\n       datso('#" . $obj->id . "-editimg').editInPlace({\n        bg_img_over:  'transparent url(" . JURI::base(true) . "/components/com_datsogallery/images/" . $dg_theme . "/edit.png) no-repeat 98% center',\n        bg_img_out:   'transparent',\n        show_buttons: false,\n        url:          'index.php?option=com_datsogallery&task=edittitle&format=raw',\n        update_value: 'imgtitle',\n        element_id:   'id',\n        saving_image: '" . JURI::base(true) . "/components/com_datsogallery/images/" . $dg_theme . "/loading.gif',\n        success: function(response){ datso('#" . $obj->id . "-edit').html(response); }\n        });\n      });\n    </script>";
    }
    ?>
<div class="dg_head_background"><div style="position:relative;display:inline;padding:4px 24px 4px 0" id="<?php 
    echo $obj->id;
    ?>
-editimg"><?php 
    <div class="revisionComment"><?php 
            echo do_textile($revision->getComment());
            ?>
</div>
<?php 
        }
        // if
        $options = array();
        if ($revision->canEdit(logged_user())) {
            $options[] = '<a href="' . $revision->getEditUrl() . '">' . lang('edit') . '</a>';
        }
        if ($revision->canDelete(logged_user())) {
            $options[] = '<a href="' . $revision->getDeleteUrl() . '">' . lang('delete') . '</a>';
        }
        if ($revision->canDownload(logged_user())) {
            $options[] = '<a href="' . $revision->getDownloadUrl() . '" class="downloadLink">' . lang('download') . ' <span>(' . format_filesize($revision->getFileSize()) . ')</span></a>';
        }
        if (count($options)) {
            ?>
    <div class="revisionOptions"><?php 
            echo implode(' | ', $options);
            ?>
</div>
<?php 
        }
        // if
        ?>
  </div>
<?php 
    }
    // foreach
Example #25
0
<h2><?php 
        echo lang('files');
        ?>
</h2>
<ul>
<?php 
        foreach ($tagged_objects['files'] as $file) {
            ?>
  <li><a href="<?php 
            echo $file->getDetailsUrl();
            ?>
"><?php 
            echo clean($file->getFilename());
            ?>
</a> <span class="desc">(<?php 
            echo format_filesize($file->getFilesize());
            ?>
)</span></li>
<?php 
        }
        // foreach
        ?>
</ul>
<?php 
    }
    // if
    ?>

<?php 
    if (isset($tagged_objects['wiki']) && is_array($tagged_objects['wiki']) && count($tagged_objects['wiki'])) {
        ?>
Example #26
0
    ?>
	    	<?php 
    echo radio_field($genid . '_rg', false, array('id' => $genid . 'weblinkRadio', 'onchange' => 'og.addDocumentTypeChanged(1, "' . $genid . '")', 'value' => '1')) . ' ' . lang('weblink');
    ?>
	        <div id="<?php 
    echo $genid;
    ?>
fileUploadDiv">
			<?php 
    echo label_tag(lang('file'), $genid . 'fileFormFile', true);
    ?>
			<?php 
    Hook::fire('render_upload_control', array("genid" => $genid, "attributes" => array("id" => $genid . "fileFormFile", "class" => "title", "size" => "50", "tabindex" => "10", "onchange" => "javascript:og.updateFileName('" . $genid . "', this.value);")), $ret);
    ?>
			<p><?php 
    echo lang('upload file desc', format_filesize(get_max_upload_size()));
    ?>
</p>
			</div>
	    	<div id="<?php 
    echo $genid;
    ?>
weblinkDiv" style="display:none;">
	        	<?php 
    echo label_tag(lang('weblink'), 'file[url]', true, array('id' => $genid . 'weblinkLbl', 'type' => 'text'));
    ?>
	    		<?php 
    echo text_field('file[url]', '', array('id' => $genid . 'url', 'style' => 'width:500px;', "onchange" => "javascript:og.updateFileName('" . $genid . "', this.value);"));
    ?>
	    	</div>
		</div>
				</span>
			</td>
			<td class="hidden-phone"><?php 
        echo $origin;
        ?>
</td>
			<td class="hidden-phone"><?php 
        echo $type;
        ?>
</td>
			<td class="hidden-phone"><?php 
        echo $record['profile_id'];
        ?>
</td>
			<td class="hidden-phone"><?php 
        echo $record['meta'] == 'ok' ? format_filesize($record['size']) : ($record['total_size'] > 0 ? "(<i>" . format_filesize($record['total_size']) . "</i>)" : '&mdash;');
        ?>
</td>
			<td class="hidden-phone"><?php 
        echo $filename_col;
        ?>
</td>
		</tr>
		<?php 
    }
    ?>
		<?php 
}
?>
	</tbody>
</table>
 /**
  * View specific email
  *
  */
 function view()
 {
     $this->addHelper('textile');
     $email = MailContents::findById(get_id());
     if (!$email instanceof MailContent) {
         flash_error(lang('email dnx'));
         ajx_current("empty");
         return;
     }
     if ($email->getIsDeleted()) {
         flash_error(lang('email dnx deleted'));
         ajx_current("empty");
         return;
     }
     if (!$email->canView(logged_user())) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     tpl_assign('email', $email);
     $attachments = array();
     if ($email->getState() >= 200) {
         $old_memory_limit = ini_get('memory_limit');
         if (php_config_value_to_bytes($old_memory_limit) < 256 * 1024 * 1024) {
             ini_set('memory_limit', '256M');
         }
         $attachments = self::readAttachmentsFromFileSystem($email, $att_ver);
         if ($attachments && is_array($attachments)) {
             foreach ($attachments as &$attach) {
                 if ($att_ver < 2) {
                     $attach["FileName"] = $attach['name'];
                     $attach['size'] = format_filesize(strlen($attach["data"]));
                     unset($attach['name']);
                     unset($attach['data']);
                 } else {
                     $attach["FileName"] = $attach['name'];
                     $attach['size'] = format_filesize(filesize($attach["path"]));
                     unset($attach['name']);
                 }
             }
         } else {
         }
         ini_set('memory_limit', $old_memory_limit);
     } else {
         MailUtilities::parseMail($email->getContent(), $decoded, $parsedEmail, $warnings);
         if (isset($parsedEmail['Attachments'])) {
             $attachments = $parsedEmail['Attachments'];
         }
         foreach ($attachments as &$attach) {
             $attach['size'] = format_filesize(strlen($attach["Data"]));
             unset($attach['Data']);
         }
     }
     if ($email->getBodyHtml() != '') {
         $tmp_folder = "/tmp/" . $email->getAccountId() . "_" . logged_user()->getId() . "_" . $email->getId() . "_temp_mail_content_res";
         if (is_dir(ROOT . $tmp_folder)) {
             remove_dir(ROOT . $tmp_folder);
         }
         $parts_array = array_var($decoded, 0, array('Parts' => ''));
         $email->setBodyHtml(self::rebuild_body_html($email->getBodyHtml(), array_var($parts_array, 'Parts'), $tmp_folder));
     }
     tpl_assign('attachments', $attachments);
     ajx_extra_data(array("title" => $email->getSubject(), 'icon' => 'ico-email'));
     ajx_set_no_toolbar(true);
     if (array_var($_GET, 'replace')) {
         ajx_replace(true);
     }
     $email->setIsRead(logged_user()->getId(), true);
     ApplicationReadLogs::createLog($email, $email->getWorkspaces(), ApplicationReadLogs::ACTION_READ);
 }
function wp_dashboard_serverinfo()
{
    global $text_direction;
    if ('rtl' == $text_direction) {
        echo '<style type="text/css"> #wp-serverinfo ul { padding-left: 15px !important; } </style>';
        echo '<div id="wp-serverinfo" style="direction: ltr; text-align: left;">';
    }
    echo '<p><strong>' . __('General', 'wp-serverinfo') . '</strong></p>';
    echo '<ul>';
    echo '<li>' . __('OS', 'wp-serverinfo') . ': <strong>' . PHP_OS . '</strong></li>';
    echo '<li>' . __('Server', 'wp-serverinfo') . ': <strong>' . $_SERVER["SERVER_SOFTWARE"] . '</strong></li>';
    echo '<li>' . __('Hostname', 'wp-serverinfo') . ': <strong>' . $_SERVER['SERVER_NAME'] . '</strong></li>';
    echo '<li>' . __('IP:Port', 'wp-serverinfo') . ': <strong>' . $_SERVER['SERVER_ADDR'] . ':' . $_SERVER['SERVER_PORT'] . '</strong></li>';
    echo '<li>' . __('Document Root', 'wp-serverinfo') . ': <strong>' . $_SERVER['DOCUMENT_ROOT'] . '</strong></li>';
    echo '</ul>';
    echo '<p><strong>PHP</strong></p>';
    echo '<ul>';
    echo '<li>v<strong>' . PHP_VERSION . '</strong></li>';
    echo '<li>GD: <strong>' . get_gd_version() . '</strong></li>';
    echo '<li>' . __('Magic Quotes GPC', 'wp-serverinfo') . ': <strong>' . get_php_magic_quotes_gpc() . '</strong></li>';
    echo '<li>' . __('Memory Limit', 'wp-serverinfo') . ': <strong>' . format_php_size(get_php_memory_limit()) . '</strong></li>';
    echo '<li>' . __('Max Upload Size', 'wp-serverinfo') . ': <strong>' . format_php_size(get_php_upload_max()) . '</strong></li>';
    echo '</ul>';
    echo '<p><strong>MYSQL</strong></p>';
    echo '<ul>';
    echo '<li>v<strong>' . get_mysql_version() . '</strong></li>';
    echo '<li>' . __('Maximum No. Connections', 'wp-serverinfo') . ': <strong>' . number_format_i18n(get_mysql_max_allowed_connections(), 0) . '</strong></li>';
    echo '<li>' . __('Maximum Packet Size', 'wp-serverinfo') . ': <strong>' . format_filesize(get_mysql_max_allowed_packet()) . '</strong></li>';
    echo '<li>' . __('Data Disk Usage', 'wp-serverinfo') . ': <strong>' . format_filesize(get_mysql_data_usage()) . '</strong></li>';
    echo '<li>' . __('Index Disk Usage', 'wp-serverinfo') . ': <strong>' . format_filesize(get_mysql_index_usage()) . '</strong></li>';
    echo '</ul>';
    echo '<p class="textright"><a href="' . admin_url('index.php?page=wp-serverinfo/wp-serverinfo.php') . '" class="button">' . __('View all', 'wp-serverinfo') . '</a></p>';
    if ('rtl' == $text_direction) {
        echo '</div>';
    }
}
	function list_files() {
		
		ajx_current("empty");
		// get query parameters 
		$start = (integer)array_var($_GET,'start');
		$limit = (integer)array_var($_GET,'limit');
		if (! $start) {
			$start = 0;
		}
		if (! $limit) {
			$limit = config_option('files_per_page');
		}
		$order = array_var($_GET,'sort');
		$order_dir = array_var($_GET,'dir');
		$page = (integer) ($start / $limit)+1;
		$hide_private = !logged_user()->isMemberOfOwnerCompany();
		$type = array_var($_GET,'type');
		$user = array_var($_GET,'user');

		// if there's an action to execute, do so 
		if (array_var($_GET, 'action') == 'delete') {
			$ids = explode(',', array_var($_GET, 'objects'));
			$succ = 0; $err = 0;
			foreach ($ids as $id) {
				$file = ProjectFiles::findById($id);
				if (isset($file) && $file->canDelete(logged_user())) {
					try{
						DB::beginWork();
						$file->trash();
						ApplicationLogs::createLog($file, ApplicationLogs::ACTION_TRASH);
						DB::commit();
						$succ++;
					} catch(Exception $e){
						DB::rollback();
						$err++;
					}
				} else {
					$err++;
				}
			}
			if ($succ > 0) {
				flash_success(lang("success delete files", $succ));
			} else {
				flash_error(lang("error delete files", $err));
			}

		} else if (array_var($_GET, 'action') == 'markasread') {
			$ids = explode(',', array_var($_GET, 'objects'));
			$succ = 0; $err = 0;
				foreach ($ids as $id) {
				$file = ProjectFiles::findById($id);
					try {
						$file->setIsRead(logged_user()->getId(),true);
						$succ++;
						
					} catch(Exception $e) {
						$err ++;
					} // try
				}//for
			if ($succ <= 0) {
				flash_error(lang("error markasread files", $err));
			}
		}else if (array_var($_GET, 'action') == 'markasunread') {
			$ids = explode(',', array_var($_GET, 'objects'));
			$succ = 0; $err = 0;
				foreach ($ids as $id) {
				$file = ProjectFiles::findById($id);
					try {
						$file->setIsRead(logged_user()->getId(),false);
						$succ++;

					} catch(Exception $e) {
						$err ++;
					} // try
				}//for
			if ($succ <= 0) {
				flash_error(lang("error markasunread files", $err));
			}
		}
		 else if (array_var($_GET, 'action') == 'zip_add') {
			$this->zip_add();
		} else if (array_var($_GET, 'action') == 'archive') {
			$ids = explode(',', array_var($_GET, 'ids'));
			$succ = 0; $err = 0;
			foreach ($ids as $id) {
				$file = ProjectFiles::findById($id);
				if (isset($file) && $file->canEdit(logged_user())) {
					try{
						DB::beginWork();
						$file->archive();
						ApplicationLogs::createLog($file, ApplicationLogs::ACTION_ARCHIVE);
						DB::commit();
						$succ++;
					} catch(Exception $e){
						DB::rollback();
						$err++;
					}
				} else {
					$err++;
				}
			}
			if ($succ > 0) {
				flash_success(lang("success archive objects", $succ));
			} else {
				flash_error(lang("error archive objects", $err));
			}
		}
		
		Hook::fire('classify_action', null, $ret);		
		$join_params = null;
		
		if ($order == ProjectFiles::ORDER_BY_POSTTIME) {
			$order = '`created_on`';
		} else if ($order == ProjectFiles::ORDER_BY_MODIFYTIME) {
			$order = '`updated_on`';
		} else if ($order == ProjectFiles::ORDER_BY_SIZE) {
			$order = '`jt`.`filesize`';
			$join_params = array(
				'table' => ProjectFileRevisions::instance()->getTableName(),
				'jt_field' => 'object_id',
				'j_sub_q' => "SELECT max(`x`.`object_id`) FROM ".ProjectFileRevisions::instance()->getTableName()." `x` WHERE `x`.`file_id` = `e`.`object_id`"
			);
		} else {
			$order = '`name`';
		} // if
		
		$extra_conditions = $hide_private ? 'AND `is_visible` = 1' : '';
		
		$context = active_context();
		$objects = ProjectFiles::instance()->listing(array(
			"order"=>$order,
			"order_dir" => $order_dir,
			"extra_conditions"=> $extra_conditions,
			"join_params"=> $join_params,
			"start"=> $start,
			"limit"=> $limit
		));
		
		
		$custom_properties = CustomProperties::getAllCustomPropertiesByObjectType(ProjectFiles::instance()->getObjectTypeId());
		
		// prepare response object 
		$listing = array(
			"totalCount" => $objects->total,
			"start" => $start,
			"objType" => ProjectFiles::instance()->getObjectTypeId(),
			"files" => array(),
		);
		
		if (is_array($objects->objects)) {
			$index = 0;
			$ids = array();
			foreach ($objects->objects as $o) {
				$coName = "";
				$coId = $o->getCheckedOutById();
				if ($coId != 0) {
					if ($coId == logged_user()->getId()) {
						$coName = "self";
					} else {
						$coUser = Contacts::findById($coId);
						if ($coUser instanceof Contact) {
							$coName = $coUser->getUsername();
						} else {
							$coName = "";
						}
					}
				}

				if ($o->isMP3()) {
					$songname = $o->getProperty("songname");
					$artist = $o->getProperty("songartist");
					$album = $o->getProperty("songalbum");
					$track = $o->getProperty("songtrack");
					$year = $o->getProperty("songyear");
					$duration = $o->getProperty("songduration");
					$songInfo = json_encode(array($songname, $artist, $album, $track, $year, $duration, $o->getDownloadUrl(), $o->getFilename(), $o->getId()));
				} else {
					$songInfo = array();
				}
				
				$ids[] = $o->getId();
				$values = array(
					"id" => $o->getId(),
					"ix" => $index++,
					"object_id" => $o->getId(),
					"ot_id" => $o->getObjectTypeId(),
					"name" => $o->getObjectName(),
					"type" => $o->getTypeString(),
					"mimeType" => $o->getTypeString(),
					"createdBy" => clean($o->getCreatedByDisplayName()),
					"createdById" => $o->getCreatedById(),
					"dateCreated" => $o->getCreatedOn() instanceof DateTimeValue ? ($o->getCreatedOn()->isToday() ? format_time($o->getCreatedOn()) : format_datetime($o->getCreatedOn())) : '',
					"dateCreated_today" => $o->getCreatedOn() instanceof DateTimeValue ? $o->getCreatedOn()->isToday() : 0,
					"updatedBy" => clean($o->getUpdatedByDisplayName()),
					"updatedById" => $o->getUpdatedById(),
					"dateUpdated" => $o->getUpdatedOn() instanceof DateTimeValue ? ($o->getUpdatedOn()->isToday() ? format_time($o->getUpdatedOn()) : format_datetime($o->getUpdatedOn())) : '',
					"dateUpdated_today" => $o->getUpdatedOn() instanceof DateTimeValue ? $o->getUpdatedOn()->isToday() : 0,
					"icon" => $o->getTypeIconUrl(),
					"size" => format_filesize($o->getFileSize()),
					"url" => $o->getOpenUrl(),
					"manager" => get_class($o->manager()),
					"checkedOutByName" => $coName,
					"checkedOutById" => $coId,
					"isModifiable" => $o->isModifiable() && $o->canEdit(logged_user()),
					"modifyUrl" => $o->getModifyUrl(),
					"songInfo" => $songInfo,
					"ftype" => $o->getType(),
					"url" => $o->getUrl(),
					"memPath" => json_encode($o->getMembersToDisplayPath()),
				);
				if ($o->isMP3()) {
					$values['isMP3'] = true;
				}
				Hook::fire('add_classification_value', $o, $values);
				
				foreach ($custom_properties as $cp) {
					$cp_value = CustomPropertyValues::getCustomPropertyValue($o->getId(), $cp->getId());
					$values['cp_'.$cp->getId()] = $cp_value instanceof CustomPropertyValue ? $cp_value->getValue() : '';
				}
				
				$listing["files"][] = $values;
			}
			
			$read_objects = ReadObjects::getReadByObjectList($ids, logged_user()->getId());
			foreach($listing["files"] as &$data) {
				$data['isRead'] = isset($read_objects[$data['object_id']]);
			}
			
			ajx_extra_data($listing);
			tpl_assign("listing", $listing);
		}else{
			throw new Error("Not array", $code);			
		}
	}