function listAdministratorsLog() { global $toC_Json, $osC_Database; $start = empty($_REQUEST['start']) ? 0 : $_REQUEST['start']; $limit = empty($_REQUEST['limit']) ? MAX_DISPLAY_SEARCH_RESULTS : $_REQUEST['limit']; $Qlog = $osC_Database->query('select SQL_CALC_FOUND_ROWS count(al.id) as total, al.id, al.module, al.module_action, al.module_id, al.action, a.user_name, unix_timestamp(al.datestamp) as datestamp from :table_administrators_log al, :table_administrators a where'); if (!empty($_REQUEST['fm']) && in_array($_REQUEST['fm'], $_SESSION['admin']['access'])) { $Qlog->appendQuery('al.module = :module'); $Qlog->bindValue(':module', $_REQUEST['fm']); } else { $Qlog->appendQuery('al.module in (":modules")'); $Qlog->bindRaw(':modules', implode('", "', $_SESSION['admin']['access'])); } $Qlog->appendQuery('and'); if (is_numeric($_REQUEST['fu']) && !empty($_REQUEST['fu'])) { $Qlog->appendQuery('al.administrators_id = :administrators_id and'); $Qlog->bindInt(':administrators_id', $_REQUEST['fu']); } $Qlog->appendQuery('al.administrators_id = a.id group by al.id order by al.id desc'); $Qlog->bindTable(':table_administrators_log', TABLE_ADMINISTRATORS_LOG); $Qlog->bindTable(':table_administrators', TABLE_ADMINISTRATORS); $Qlog->setExtBatchLimit($start, $limit); $Qlog->execute(); $records = array(); while ($Qlog->next()) { $records[] = array('administrators_log_id' => $Qlog->valueInt('id'), 'administrators_id' => $Qlog->valueInt('administrators_id'), 'module' => $Qlog->value('module') . ' (' . $Qlog->valueInt('total') . ')', 'module_id' => $Qlog->valueInt('module_id'), 'module_action' => $Qlog->valueProtected('module_action'), 'user_name' => $Qlog->valueProtected('user_name'), 'date' => osC_DateTime::getShort(osC_DateTime::fromUnixTimestamp($Qlog->value('datestamp')), true), 'logo_info_title' => osc_icon('info.png') . ' ' . $Qlog->valueProtected('user_name') . ' » ' . $Qlog->valueProtected('module_action') . ' » ' . $Qlog->value('module') . ' » ' . $Qlog->valueInt('module_id')); } $Qlog->freeResult(); $response = array(EXT_JSON_READER_TOTAL => $Qlog->getBatchSize(), EXT_JSON_READER_ROOT => $records); echo $toC_Json->encode($response); }
function listCache() { global $toC_Json; $osC_DirectoryListing = new osC_DirectoryListing(DIR_FS_WORK); $osC_DirectoryListing->setIncludeDirectories(false); $osC_DirectoryListing->setCheckExtension('cache'); $response = array(); foreach ($osC_DirectoryListing->getFiles() as $file) { $last_modified = filemtime(DIR_FS_WORK . '/' . $file['name']); if (strpos($file['name'], '-') !== false) { $code = substr($file['name'], 0, strpos($file['name'], '-')); } else { $code = substr($file['name'], 0, strpos($file['name'], '.')); } if (isset($cached_files[$code])) { $cached_files[$code]['total']++; if ($last_modified > $cached_files[$code]['last_modified']) { $cached_files[$code]['last_modified'] = $last_modified; } } else { $cached_files[$code] = array('total' => 1, 'last_modified' => $last_modified); } $response[] = array('code' => $code, 'total' => $cached_files[$code]['total'], 'last_modified' => osC_DateTime::getShort(osC_DateTime::fromUnixTimestamp($cached_files[$code]['last_modified']), true)); } $response = array(EXT_JSON_READER_ROOT => $response); echo $toC_Json->encode($response); }
function listDirectory() { global $osC_Language, $toC_Json, $osC_MessageStack; $directory = OSC_ADMIN_FILE_MANAGER_ROOT_PATH; if (isset($_REQUEST['directory']) && !empty($_REQUEST['directory'])) { $directory .= '/' . urldecode($_REQUEST['directory']); } elseif (isset($_REQUEST['goto']) && !empty($_REQUEST['goto'])) { $directory .= '/' . urldecode($_REQUEST['goto']); } $osC_DirectoryListing = new osC_DirectoryListing($directory); $osC_DirectoryListing->setStats(true); $records = array(); foreach ($osC_DirectoryListing->getFiles() as $file) { $file_owner = function_exists('posix_getpwuid') ? posix_getpwuid($file['user_id']) : '-?-'; $group_owner = function_exists('posix_getgrgid') ? posix_getgrgid($file['group_id']) : '-?-'; if ($file['is_directory'] === true) { $entry_icon = osc_icon('folder_red.png'); $action = array(array('class' => 'icon-empty-record', 'qtip' => ''), array('class' => 'icon-empty-record', 'qtip' => ''), array('class' => 'icon-delete-record', 'qtip' => $osC_Language->get('icon_trash'))); } else { $entry_icon = osc_icon('file.png'); $action = array(array('class' => 'icon-edit-record', 'qtip' => $osC_Language->get('icon_edit')), array('class' => 'icon-download-record', 'qtip' => $osC_Language->get('icon_download')), array('class' => 'icon-delete-record', 'qtip' => $osC_Language->get('icon_trash'))); } $records[] = array('icon' => $entry_icon, 'file_name' => $file['name'], 'is_directory' => $file['is_directory'], 'size' => number_format($file['size']), 'permission' => osc_get_file_permissions($file['permissions']), 'file_owner' => $file_owner, 'group_owner' => $group_owner, 'writeable' => osc_icon(is_writable($osC_DirectoryListing->getDirectory() . '/' . $file['name']) ? 'checkbox_ticked.gif' : 'checkbox_crossed.gif'), 'last_modified_date' => osC_DateTime::getShort(osC_DateTime::fromUnixTimestamp($file['last_modified']), true), 'action' => $action); } $response = array(EXT_JSON_READER_ROOT => $records); echo $toC_Json->encode($response); }
function listBackup() { global $toC_Json; $osC_DirectoryListing = new osC_DirectoryListing(DIR_FS_BACKUP); $osC_DirectoryListing->setIncludeDirectories(false); $osC_DirectoryListing->setExcludeEntries('.htaccess'); $response = array(); foreach ($osC_DirectoryListing->getFiles() as $file) { $response[] = array('file' => $file['name'], 'date' => osC_DateTime::getDate(osC_DateTime::fromUnixTimestamp(filemtime(DIR_FS_BACKUP . $file['name'])), true), 'size' => number_format(filesize(DIR_FS_BACKUP . $file['name']))); } $response = array(EXT_JSON_READER_ROOT => $response); echo $toC_Json->encode($response); }
function listMessages() { global $toC_Json, $osC_Database; $max_execution_time = ini_get('max_execution_time'); ini_set('max_execution_time', 1800); $start = empty($_REQUEST['start']) ? 0 : $_REQUEST['start']; $limit = empty($_REQUEST['limit']) ? MAX_DISPLAY_SEARCH_RESULTS : $_REQUEST['limit']; $toC_Email_Account = new toC_Email_Account($_REQUEST['accounts_id']); if (isset($_REQUEST['check_email']) && $_REQUEST['check_email'] == 'true' || $toC_Email_Account->isImap()) { $toC_Email_Account->fetchEmail($_REQUEST['folders_id']); } $Qmessages = $osC_Database->query('select * from :table_email_messages where accounts_id = :accounts_id and folders_id = :folders_id'); $Qmessages->bindTable(':table_email_messages', TABLE_EMAIL_MESSAGES); $Qmessages->bindInt(':accounts_id', $toC_Email_Account->getAccountId()); $Qmessages->bindInt(':folders_id', $_REQUEST['folders_id']); if (isset($_REQUEST['search']) && !empty($_REQUEST['search'])) { $Qmessages->appendQuery('and (subject like :subject or from_address like :from)'); $Qmessages->bindValue(':subject', '%' . $_REQUEST['search'] . '%'); $Qmessages->bindValue(':from', '%' . $_REQUEST['search'] . '%'); } $Qmessages->appendQuery('order by id desc'); $Qmessages->setExtBatchLimit($start, $limit); $Qmessages->execute(); $day_start = mktime(0, 0, 0); $day_end = mktime(0, 0, 0, date('m'), date('d') + 1); $records = array(); while ($Qmessages->next()) { $date = $Qmessages->value('udate'); if ($date > $day_start && $date < $day_end) { $date = date('H:i', $date); } else { $date = osC_DateTime::getShort(osC_DateTime::fromUnixTimestamp($date)); } $records[] = array('id' => $Qmessages->valueInt('id'), 'fetch_time' => $Qmessages->value('fetch_timestamp'), 'attachments' => $Qmessages->valueInt('attachments'), 'icon' => $Qmessages->valueInt('attachments') == 1 ? osc_icon('email_attachment.png') : '', 'new' => $Qmessages->valueInt('new'), 'subject' => $Qmessages->value('subject'), 'from_address' => htmlentities($Qmessages->value('from_address'), ENT_QUOTES, 'UTF-8'), 'size' => $Qmessages->valueInt('size'), 'sender' => $Qmessages->value('reply_to'), 'date' => $date, 'priority' => $Qmessages->valueInt('priority'), 'messages_flag' => $Qmessages->valueInt('messages_flag')); } $response = array(EXT_JSON_READER_TOTAL => $Qmessages->getBatchSize(), EXT_JSON_READER_ROOT => $records, 'unseen' => toC_Email_Accounts_Admin::getNewMessagesAmount($_REQUEST['accounts_id'], $_REQUEST['folders_id'])); ini_set('max_execution_time', $max_execution_time); echo $toC_Json->encode($response); }
function getDateOrTime($date) { $day_start = mktime(0, 0, 0); $day_end = mktime(0, 0, 0, date('m'), date('d') + 1); if ($date > $day_start && $date < $day_end) { $date = date('H:i', $date); } else { $date = osC_DateTime::getShort(osC_DateTime::fromUnixTimestamp($date)); } return $date; }
<td onclick="document.getElementById('batch<?php echo $cache; ?> ').checked = !document.getElementById('batch<?php echo $cache; ?> ').checked;"><?php echo $cache; ?> </td> <td align="center"><?php echo $stats['total']; ?> </td> <td align="right"><?php echo osC_DateTime::getShort(osC_DateTime::fromUnixTimestamp($stats['last_modified']), true); ?> </td> <td align="right"><?php echo osc_link_object(osc_href_link_admin(FILENAME_DEFAULT, $osC_Template->getModule() . '&block=' . $cache . '&action=delete'), osc_icon('trash.png')); ?> </td> <td align="center"><?php echo osc_draw_checkbox_field('batch[]', $cache, null, 'id="batch' . $cache . '"'); ?> </td> </tr> <?php } ?>
function cacheMessage($id, $data) { $data['subject'] = htmlspecialchars($data['subject'], ENT_QUOTES, 'UTF-8'); $data['account_id'] = $this->_data['account_id']; $data['full_from'] = htmlspecialchars($data['from'], ENT_QUOTES, 'UTF-8'); $RFC822 = new RFC822(); $address = $RFC822->parse_address_list($data['from']); $data['sender'] = isset($address[0]['email']) ? htmlspecialchars($address[0]['email'], ENT_QUOTES, 'UTF-8') : ''; $data['from'] = isset($address[0]['personal']) ? htmlspecialchars($address[0]['personal'], ENT_QUOTES, 'UTF-8') : ''; //to if (!empty($data['to'])) { $to = array(); foreach ($data['to'] as $address) { $address = $RFC822->parse_address_list($address); $to[] = array('email' => htmlspecialchars($address[0]['email'], ENT_QUOTES, 'UTF-8'), 'name' => htmlspecialchars($address[0]['personal'], ENT_QUOTES, 'UTF-8')); } $data['to'] = $to; } //cc if (!empty($data['cc'])) { $cc = array(); foreach ($data['cc'] as $address) { $address = $RFC822->parse_address_list($address); $cc[] = array('email' => htmlspecialchars($address[0]['email'], ENT_QUOTES, 'UTF-8'), 'name' => htmlspecialchars($address[0]['personal'], ENT_QUOTES, 'UTF-8')); } $data['cc'] = $cc; } //bcc if (!empty($data['bcc'])) { $bcc = array(); foreach ($data['bcc'] as $address) { $address = $RFC822->parse_address_list($address); $bcc[] = array('email' => htmlspecialchars($address[0]['email'], ENT_QUOTES, 'UTF-8'), 'name' => htmlspecialchars($address[0]['personal'], ENT_QUOTES, 'UTF-8')); } $data['bcc'] = $bcc; } $data['date'] = osC_DateTime::getShort(osC_DateTime::fromUnixTimestamp($data['udate']), true); $parts = array_reverse($this->_inbox->f("parts")); $html_alternative = false; for ($i = 0; $i < count($parts); $i++) { if (eregi('html', $parts[$i]['mime']) && (strtolower($parts[$i]['type']) == 'alternative' || strtolower($parts[$i]['type']) == 'related')) { $html_alternative = true; } } $data['body'] = ''; //attachments $attachments = array(); if (eregi('html', $data['content_type'])) { $default_mime = 'text/html'; } else { $default_mime = 'text/plain'; } $part_count = count($parts); if ($part_count == 1) { //if there's only one part use the message parameters. if (eregi('plain', $parts[0]['mime'])) { $parts[0]['mime'] = $default_mime; } if (!empty($data['content_transfer_encoding'])) { $parts[0]['transfer'] = $data['content_transfer_encoding']; } } while ($part = array_shift($parts)) { $mime = isset($part["mime"]) ? strtolower($part["mime"]) : $default_mime; //some clients just send html if ($mime == 'html') { $mime = 'text/html'; } if (empty($data['body']) && !eregi('attachment', $part["disposition"]) && (eregi('html', $mime) || eregi('plain', $mime) && (!$html_alternative || strtolower($part['type']) != 'alternative') || $mime == "text/enriched" || $mime == "unknown/unknown")) { $part_body = $this->_inbox->view_part($data['uid'], $part["number"], $part["transfer"], $part["charset"]); switch ($mime) { case 'unknown/unknown': case 'text/plain': $uuencoded_attachments = $this->_inbox->extract_uuencoded_attachments($part_body); $part_body = Imap::text_to_html($part_body); for ($i = 0; $i < count($uuencoded_attachments); $i++) { $attachment = $uuencoded_attachments[$i]; $attachment['number'] = $part['number']; unset($attachment['data']); $attachment['uuencoded_partnumber'] = $i + 1; $attachments[] = $attachment; } break; case 'text/html': $part_body = Imap::convert_html($part_body); break; case 'text/enriched': $part_body = Imap::enriched_to_html($part_body); break; } $data['body'] .= $part_body; } else { $attachments[] = $part; } } //$data['event']=false; $data['attachments'] = array(); $index = 0; for ($i = 0; $i < count($attachments); $i++) { if ($this->_inbox->part_is_attachment($attachments[$i])) { $attachment = $attachments[$i]; $attachment['index'] = $index; $attachment['extension'] = Imap::get_extension($attachments[$i]["name"]); $data['attachments'][] = $attachment; $index++; } if (!empty($attachments[$i]["id"])) { //when an image has an id it belongs somewhere in the text we gathered above so replace the //source id with the correct link to display the image. if ($attachments[$i]["id"] != '') { $tmp_id = $attachments[$i]["id"]; if (strpos($tmp_id, '>')) { $tmp_id = substr($attachments[$i]["id"], 1, strlen($attachments[$i]["id"]) - 2); } $image_id = "cid:" . $tmp_id; // $url = $GO_MODULES->modules['email']['url']."attachment.php?account_id=".$account['id']."&mailbox=".urlencode($mailbox)."&uid=".$uid."&part=".$attachments[$i]["number"]."&transfer=".$attachments[$i]["transfer"]."&mime=".$attachments[$i]["mime"]."&filename=".urlencode($attachments[$i]["name"]); // $data['body'] = str_replace($id, $url, $data['body']); } } } //save message cache $file = DIR_FS_CACHE_ADMIN . 'emails/' . md5($this->_data['accounts_id'] . $this->_data['accounts_email']) . '/messages/' . md5($id . $data['fetch_timestamp']) . '.php'; if ($h = fopen($file, 'w')) { $cached_message = var_export($data, true); $date = date("r"); $cached_message_string = '<?php //created: {' . $date . 'accounts_id: ' . $this->_data['accounts_id'] . ';;;id:' . $id . ';;;time_stamp:' . $data['fetch_timestamp'] . '}' . "\n\n" . '$cacheFile = ' . $cached_message . "\n\n" . '?>'; fputs($h, $cached_message_string); fclose($h); } //save attachments cache $conn = $this->_inbox->conn; $msg_no = imap_msgno($conn, $data['uid']); $structure = imap_fetchstructure($conn, $msg_no); $file_attachment = DIR_FS_CACHE_ADMIN . 'emails/' . md5($this->_data['accounts_id'] . $this->_data['accounts_email']) . '/attachments/' . md5($id . $data['fetch_timestamp']); if ($structure->type == 1 && !empty($structure->parts)) { $this->cacheAttachments($msg_no, $structure->parts, 0, $file_attachment); } return true; }
</th> </tr> </tfoot> <tbody> <?php foreach ($osC_DirectoryListing->getFiles() as $file) { ?> <tr onmouseover="rowOverEffect(this);" onmouseout="rowOutEffect(this);"> <td><?php echo osc_link_object(osc_href_link_admin(FILENAME_DEFAULT, $osC_Template->getModule() . '&file=' . $file['name'] . '&action=download'), osc_icon('download.png') . ' ' . $file['name']); ?> </td> <td><?php echo osC_DateTime::getShort(osC_DateTime::fromUnixTimestamp(filemtime(DIR_FS_BACKUP . $file['name'])), true); ?> </td> <td><?php echo number_format(filesize(DIR_FS_BACKUP . $file['name'])); ?> bytes</td> <td align="right"> <?php echo osc_link_object(osc_href_link_admin(FILENAME_DEFAULT, $osC_Template->getModule() . '&file=' . $file['name'] . '&action=restore'), osc_icon('restore.png')) . ' ' . osc_link_object(osc_href_link_admin(FILENAME_DEFAULT, $osC_Template->getModule() . '&file=' . $file['name'] . '&action=delete'), osc_icon('trash.png')); ?> </td> <td align="center"><?php echo osc_draw_checkbox_field('batch[]', $file['name'], null, 'id="batch' . addslashes($file['name']) . '"');