function step_pre_show_form()
 {
     echo '<h2>Attach News Items</h2>';
     if (!empty($this->unattached_news_item_names_by_id)) {
         echo '<p>In this step, choose a publication and select unattached published news items to attach to the publication.</p>';
     } else {
         if (empty($this->unattached_news_items_names_by_id)) {
             echo '<p>All news items on the site are attached to a publication.</p>';
         }
         if ($this->site_has_issue_type) {
             if (empty($this->unattached_issue_names_by_id)) {
                 echo '<p>All issues on the site are attached to a publication.</p>';
             } else {
                 $options[] = '<a href="' . carl_make_link(array('active_screen' => 6)) . '">Attach issues to a publication</a>';
             }
         }
         if ($this->site_has_section_type) {
             if (empty($this->unattached_section_names_by_id)) {
                 echo '<p>All news sections attached to a publication.</p>';
             } else {
                 $options[] = '<a href="' . carl_make_link(array('active_screen' => 7)) . '">Attach news sections to a publcation</a>';
             }
         }
         echo '<p>You may proceed do the following:</p>';
         $options[] = '<a href="' . carl_make_link(array('active_screen' => 4)) . '">Modify page types on the site</a>';
         $options[] = '<a href="' . carl_make_link(array('active_screen' => 3)) . '">Create a new publication</a>';
         $options[] = '<a href="' . carl_construct_link() . '">Choose another site</a>';
         echo '<ul><li>' . implode('</li><li>', $options) . '</li></ul>';
     }
 }
示例#2
0
 /**
  * Passes form content to the Akismet API. If spam is detected, sends an error message back to the user.
  */
 public function detect_spam()
 {
     $form_contents = '';
     foreach ($this->disco_form->get_values() as $k => $v) {
         if (is_array($v)) {
             $form_contents .= implode($v, ' ') . ' ';
         } else {
             // don't include hidden elements which contain objects as values
             if (!(get_class($this->disco_form->get_element($k)) == 'hiddenType' && substr($v, 0, 3) == 'id_')) {
                 $form_contents .= $v . ' ';
             }
         }
     }
     $akismet_api_key = constant("AKISMET_API_KEY");
     if (!empty($akismet_api_key)) {
         $url = carl_construct_link();
         //$akismet = new Akismet($url, $akismet_api_key, $is_test=1); // for testing
         $akismet = new Akismet($url, $akismet_api_key);
         $akismet->setCommentContent($form_contents);
         //$akismet->setCommentAuthor('viagra-test-123'); // for testing
         if ($akismet->isCommentSpam()) {
             $this->disco_form->set_error(NULL, 'Spam detected in this submission. If this message was made in error, please contact an administrator.', $element_must_exist = false);
         }
     }
 }
    function step_pre_show_form()
    {
        echo '<h2>Modify Page Types</h2>';
        if (!empty($this->pages_using_news_modules)) {
            echo '<p>This phase does some analysis of page types and allows you to modify the pages that currently use old-style news to use page types 
				  compatible with the new publications module. This process is imperfect - many custom page types cannot be mapped directly onto a 
			      publication page type and will require the creation of new page types. Also, CSS files may need to be updated depending upon whether 
			      or not the site was using custom CSS for the display of news pages/sidebars.</p>';
        } else {
            echo '<p>There are no pages on the site using old-style news. You are probably finished!</p>';
            $options[] = '<a href="' . carl_construct_link() . '">Choose another site</a>';
            echo '<ul><li>' . implode('</li><li>', $options) . '</li></ul>';
        }
    }
示例#4
0
 function run()
 {
     if (!empty($this->publication) && $this->publication->get_value('name')) {
         if (!empty($this->request['story_id']) || !empty($this->request['section_id']) || !empty($this->request['filters']) || !empty($this->request['search'])) {
             $link = carl_construct_link(array(), array('textonly'));
             // preserve only textonly
             $pubname = '<a href="' . $link . '">' . $this->publication->get_value('name') . '</a>';
         } else {
             $pubname = $this->publication->get_value('name');
         }
         echo '<h2 class="pageTitle publicationTitle"><span>' . $pubname . '</span></h2>';
     } elseif (!empty($this->parent->title)) {
         parent::run();
     }
 }
 function run()
 {
     $master_admin_link = carl_construct_link(array('site_id' => id_of('master_admin')));
     $link[] = '<a href="' . $master_admin_link . '">Return to master admin</a>';
     if ($this->authenticate() && $this->table_admin->get_table_row_action()) {
         $url2 = carl_make_link($this->table_admin->get_menu_links_base_with_filters());
         $link[] = '<a href="' . $url2 . '">Show allowable relationships list</a>';
     }
     echo implode(' | ', $link);
     if (!$this->authenticate()) {
         echo '<h3>You do not have the proper privileges to use this module</h3>';
     } else {
         $this->table_admin->run();
     }
 }
 function show_completed_list()
 {
     $choose_another_term = carl_construct_link(array('type_id' => $this->helper->get_type_id(), 'site_id' => $this->helper->get_site_id(), 'active_screen' => "3"), array('type_fields'));
     $start_over = carl_construct_link(array(''));
     $find_more = carl_construct_link(array('type_id' => $this->helper->get_type_id(), 'site_id' => $this->helper->get_site_id(), 'type_fields' => $this->helper->get_type_fields(), 'limit' => $this->helper->get_limit(), 'active_screen' => "3", 'find' => $this->helper->get_search_term(), 'replace' => $this->helper->get_replace_term()));
     echo '<ul>';
     echo '<li><a href="' . $find_more . '">Find more</a> for these fields and terms</li>';
     echo '<li><a href="' . $choose_another_term . '">Choose another search term</a> with these fields to find and replace</li>';
     echo '<li><a href="' . $start_over . '">Start over</a></li>';
     echo '</ul>';
 }
示例#7
0
 function banner()
 {
     echo '<table class="banner">' . "\n";
     echo '<tr>' . "\n";
     echo '<td class="crumbs"> ' . REASON_ADMIN_LOGO_MARKUP;
     echo '<span>';
     echo '<strong> :: <a href="' . $this->make_link(array('cur_module' => 'about_reason')) . '" class="bannerLink">Reason ' . reason_get_version() . '</a></strong>';
     if ($this->site_id != id_of('master_admin')) {
         $sites = $this->get_sites();
         if (isset($sites[id_of('master_admin')])) {
             echo ' :: <a href="' . carl_construct_link(array('site_id' => id_of('master_admin')), array('user_id')) . '">Master Admin</a>';
         }
     }
     echo '</span></td>' . "\n";
     echo '<td class="id">';
     $this->show_user();
     echo '</td>' . "\n";
     echo '</tr>' . "\n";
     echo '</table>' . "\n";
 }
 /**
  * Generate the status sidebar
  */
 function show_site_status()
 {
     $site_id = $this->helper->get_site_id();
     if ($site_id > 0) {
         $status_html[] = '<strong>Active site is ' . $this->helper->get_site_name() . '</strong>';
         $publications = $this->helper->get_site_publication_names_by_id();
         $pub_count = !empty($publications) ? count($publications) : '0';
         $pub_string = $pub_count == 1 ? 'publication' : 'publications';
         $status_html[] = 'Site has ' . $pub_count . ' ' . $pub_string;
         $unattached_news_items = $this->helper->get_unattached_news_item_names_by_id();
         if (!empty($unattached_news_items)) {
             $status_html[] = 'Site has ' . count($unattached_news_items) . ' unattached news items';
         }
         $attached_news_items = $this->helper->get_attached_news_item_names_by_id();
         if (!empty($attached_news_items)) {
             $status_html[] = 'Site has ' . count($attached_news_items) . ' attached news items';
         }
         $unattached_issues = $this->helper->get_unattached_issue_names_by_id();
         if (!empty($unattached_issues)) {
             $status_html[] = 'Site has ' . count($unattached_issues) . ' unattached issues';
         }
         $attached_issues = $this->helper->get_attached_issue_names_by_id();
         if (!empty($attached_issues)) {
             $status_html[] = 'Site has ' . count($attached_issues) . ' attached issues';
         }
         $unattached_sections = $this->helper->get_unattached_section_names_by_id();
         if (!empty($unattached_sections)) {
             $status_html[] = 'Site has ' . count($unattached_sections) . ' unattached news sections';
         }
         $attached_sections = $this->helper->get_attached_section_names_by_id();
         if (!empty($attached_sections)) {
             $status_html[] = 'Site has ' . count($attached_sections) . ' attached news sections';
         }
         $status_html = '<ul><li>' . implode('</li><li>', $status_html) . '</li></ul>';
         $start_over_link = true;
     } else {
         $status_html = '<ul><li>No site is selected</li></ul>';
     }
     echo '<div id="status">';
     echo '<h2>Status</h2>';
     echo $status_html;
     if (isset($start_over_link)) {
         echo '<p><a href="' . carl_construct_link() . '">Start Over</a></p>';
     }
     echo '</div>';
 }
 function step_pre_show_form()
 {
     $link = carl_construct_link();
     echo '<h4>Finished</h4>';
     echo '<p><a href="' . $link . '">Start Over</a></p>';
 }
示例#10
0
        // STANDALONE UPGRADERS //
        $standalone_upgraders = $rua->get_standalone_upgraders($step);
        if (!empty($standalone_upgraders)) {
            $str .= '<h3>Run Standalone Upgrades</h3>' . "\n";
            $str .= '<ul>' . "\n";
            foreach ($standalone_upgraders as $name => $upgrader) {
                $str .= '<li><a href="?upgrade_step=' . urlencode($step) . '&amp;upgrader=' . urlencode($name) . '">' . $upgrader->title() . '</a>';
                // if we have a description lets show it.
                $desc = $upgrader->description();
                if (!empty($desc)) {
                    $str .= '<ul><li>' . $desc . '</li></ul>';
                }
                $str .= '</li>' . "\n";
            }
            $str .= '</ul>' . "\n";
            $ret_link = carl_construct_link(array('upgrade_step' => ''));
            $str .= '<hr/><p><a href="' . $ret_link . '">&lt; All Upgrades</a></p>';
        }
    }
} else {
    $str = '<p>Each new version of Reason CMS includes a set of scripts that you should ';
    $str .= 'run to update your database to work with the latest version of the Reason code base. ';
    $str .= 'The scripts are designed to be used from one release to the next; you cannot necessarily update ';
    $str .= 'a Reason CMS database across multiple steps after downloading the most current code base.</p>';
    $str .= '<p>If you have trouble upgrading and you are using an old version of Reason CMS, try downloading ';
    $str .= 'the point release after the one you are currently using and upgrade incrementally.</p>';
    $str .= '<p><a href="http://reasoncms.org/get-started/download/">Reason CMS download page</a></p>';
    $str .= '<h2>Reason Upgrade Scripts</h2>';
    $str .= '<ul>';
    foreach ($upgrade_steps as $k => $v) {
        $str .= '<li><a href="?upgrade_step=' . urlencode($k) . '">' . htmlspecialchars($v) . '</a></li>';
 /**
  * Checks for errors with the uploaded file and uploads to Zencoder.
  */
 function _run_error_checks_callback()
 {
     if (!$this->manager->has_error('upload_file') && !$this->manager->has_error('upload_url')) {
         // Make sure only one
         if ($this->manager->get_value('upload_file') && $this->manager->get_value('upload_url')) {
             $this->manager->set_error('upload_file', 'Cannot upload file and provide a url at the same time. Only use one.');
             $this->manager->set_error('upload_url', 'Cannot upload file and provide a url at the same time. Only use one.');
             return;
         }
         if ($this->manager->get_value('upload_file')) {
             $file = $this->manager->get_element('upload_file');
             if (!empty($file)) {
                 if (($file->state == 'received' or $file->state == 'pending') and file_exists($file->tmp_full_path)) {
                     $this->manager->set_value('original_filename', $this->_sanitize_filename(urldecode($file->file['name'])));
                     $this->_set_salt();
                     $user = new entity($this->manager->admin_page->authenticated_user_id);
                     $filePath = $file->tmp_full_path;
                     $filename_parts = explode('/', $filePath);
                     $filename = end($filename_parts);
                     $this->manager->set_value('tmp_file_name', $filename);
                     // convert filePath to web accessible url
                     $filePath = carl_construct_link(array(), array(), WEB_TEMP . $filename);
                     $this->_process_work($filePath, false);
                 }
             }
         } elseif ($this->manager->get_value('upload_url')) {
             $url = $this->manager->get_value('upload_url');
             // check if url is valid
             // check to see if url exists
             $name = basename($url);
             $encoded_url = str_replace($name, rawurlencode($name), $url);
             $ch = curl_init($encoded_url);
             curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
             curl_setopt($ch, CURLOPT_NOBODY, true);
             curl_exec($ch);
             $retcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
             curl_close($ch);
             if ($retcode != 200) {
                 $this->manager->set_error('upload_url', 'The provided url was invalid.');
                 return;
             }
             $filename = basename($url);
             $sanitized_filename = $this->_sanitize_filename(urldecode($filename));
             $this->manager->set_value('original_filename', $sanitized_filename);
             $this->_set_salt();
             $this->manager->set_value('tmp_file_name', $url);
             $this->_process_work($url, true);
         }
     }
     // checkboxes are strange, so this hack ensures their values are correctly set.
     if ($this->manager->get_value('email_notification')) {
         $this->manager->set_value('email_notification', true);
     }
     if ($this->manager->get_value('show_embed')) {
         $this->manager->set_value('show_embed', true);
     }
     if ($this->manager->get_value('show_download')) {
         $this->manager->set_value('show_download', true);
     }
 }
 /**
  * Checks for errors with uploading, and actually does the uploading to kaltura.
  */
 function _run_error_checks_callback()
 {
     if (!$this->manager->has_error('upload_file') && !$this->manager->has_error('upload_url')) {
         // Make sure only one
         if ($this->manager->get_value('upload_file') && $this->manager->get_value('upload_url')) {
             $this->manager->set_error('upload_file', 'Cannot upload file and provide a url at the same time. Only use one.');
             $this->manager->set_error('upload_url', 'Cannot upload file and provide a url at the same time. Only use one.');
             return;
         }
         if ($this->manager->get_value('upload_file')) {
             $file = $this->manager->get_element('upload_file');
             if (!empty($file)) {
                 if (($file->state == 'received' or $file->state == 'pending') and file_exists($file->tmp_full_path)) {
                     $this->manager->set_value('original_filename', $this->_sanitize_filename(urldecode($file->file['name'])));
                     $user = new entity($this->manager->admin_page->authenticated_user_id);
                     $filePath = $file->tmp_full_path;
                     $filename_parts = explode('/', $filePath);
                     $filename = end($filename_parts);
                     $this->manager->set_value('tmp_file_name', $filename);
                     // convert filePath to web accessible url
                     $filePath = carl_construct_link(array(), array(), WEB_TEMP . $filename);
                     $this->_process_work($filePath, false);
                 }
             }
         } elseif ($this->manager->get_value('upload_url')) {
             $url = $this->manager->get_value('upload_url');
             $filename = basename($url);
             $sanitized_filename = $this->_sanitize_filename(urldecode($filename));
             $this->manager->set_value('original_filename', $sanitized_filename);
             $this->manager->set_value('tmp_file_name', $filename);
             $this->_process_work($url, true);
         }
     }
     // checkboxes are strange, so this hack ensures their values are correctly set.
     if ($this->manager->get_value('email_notification')) {
         $this->manager->set_value('email_notification', true);
     }
     if ($this->manager->get_value('show_embed')) {
         $this->manager->set_value('show_embed', true);
     }
     if ($this->manager->get_value('show_download')) {
         $this->manager->set_value('show_download', true);
     }
 }
示例#13
0
		function get_create_new_submission_html()
		{
			$create_link = carl_construct_link( array('form_id' => '0'), array('textonly', 'netid') );
			return '<p class="create_new"><a href="'.$create_link.'">Create New Form Submission</a></p>';
		}
示例#14
0
	function do_notifications()
	{
		if($this->publication->get_value('notify_upon_post'))
		{
			$subject = 'New post on '.strip_tags($this->publication->get_value('name'));
			$message = 'A post has beeen added to '.strip_tags($this->publication->get_value('name'));
			$message .= ' on the site '.strip_tags($this->site_info->get_value('name')).'.';
			$message .= "\n\n";

			if($this->hold_posts_for_review)
			{
				$message .= 'This post is currently held for review. Review this post:'."\n\n";
				$message .= securest_available_protocol().'://'.REASON_WEB_ADMIN_PATH.'?site_id='.$this->site_info->id().'&type_id='.id_of('news').'&id='.$this->new_post_id."\n\n";
			}
			else
			{
				$message .= 'View post:'."\n\n";
				$message .= carl_construct_link(array('story_id'=>$this->new_post_id));
			}

			include_once(TYR_INC.'email.php');
			$e = new Email($this->publication->get_value('notify_upon_post'), WEBMASTER_EMAIL_ADDRESS, WEBMASTER_EMAIL_ADDRESS, $subject, $message);
			$e->send();
		}
	}
示例#15
0
 /**
  * We make this static to avoid various requests for the same resource on pages that might use multiple instances of this class.
  */
 function get_server_ip()
 {
     static $server_ip;
     if (!isset($server_ip)) {
         $get_ip_url = carl_construct_link(array(''), array(''), REASON_HTTP_BASE_PATH . 'displayers/ip.php');
         $result_ip = carl_util_get_url_contents($get_ip_url);
         $server_ip = !empty($result_ip) ? $result_ip : false;
     }
     return $server_ip;
 }
示例#16
0
/**
 * Is mod rewrite available and working? We check like this:
 *
 * 1. create an .htaccess file
 * 2. create an .html file
 * 3. test the rewrite with curl
 * 4. cleanup
 * 5. return true or false
 *
 */
function mod_rewrite_check()
{
    $test_string = 'reason_rocks';
    // randomize me
    $dir_name = 'mod_rewrite_check/';
    $dir_url = $path = carl_construct_link(array(''), array(''), WEB_TEMP . $dir_name);
    $dir_path = rtrim($_SERVER['DOCUMENT_ROOT'], DIRECTORY_SEPARATOR) . WEB_TEMP . $dir_name;
    $file_content = "<?php\nif (isset(\$_GET['zzz']))\n{\necho ('" . $test_string . "');\n}\n?>";
    $file_name = 'test_file.php';
    $file_path = $dir_path . $file_name;
    $file_url = $dir_url . $file_name;
    $htaccess_path = $dir_path . '.htaccess';
    $htaccess_content = 'RewriteEngine ON' . "\n" . 'RewriteRule ^$ ' . WEB_TEMP . $dir_name . $file_name . '?zzz=1';
    mkdir($dir_path, 0775);
    chmod($dir_path, 0775);
    $h = fopen($file_path, "x+");
    fwrite($h, $file_content);
    fclose($h);
    $h2 = fopen($htaccess_path, "x+");
    fwrite($h2, $htaccess_content);
    fclose($h2);
    $test = trim(get_reason_url_contents($dir_url)) == $test_string;
    // cleanup
    unlink($file_path);
    unlink($htaccess_path);
    rmdir($dir_path);
    if ($test) {
        return msg('<span class="success">Apache mod_rewrite appears to be functional</span> - check passed', true);
    } else {
        $msg = '<span class="error">Apache mod_rewrite is not working</span> - check failed';
        $msg .= '<p>You need to make sure that mod_rewrite is an installed module in your apache configuration, and that it is functioning properly. Please note:</p>';
        $msg .= '<ul>';
        $msg .= '<li>mod_rewrite is not necessarily enabled in a default apache install. Check your apache config file (probably httpd.conf) for a line like "LoadModule rewrite_module modules/mod_rewrite.so" and make sure it is uncommented.</li>';
        $msg .= '<li>mod_rewrite requires AllowOverride at a minimum be set to FileInfo Options in your apache config files.</li>';
        $msg .= '<li>Remember to restart apache to reload any updates to the config.</li>';
        $msg .= '</ul>';
        return msg($msg, false);
    }
}
 function send_email($media_work, $status, $netid)
 {
     if ($media_work->get_value('email_notification')) {
         $user = new entity(get_user_id($netid));
         $dir = new directory_service();
         $dir->search_by_attribute('ds_username', $netid, array('ds_email', 'ds_fullname', 'ds_phone'));
         $to = $dir->get_first_value('ds_email');
         $owner = $media_work->get_owner();
         $params = array('site_id' => $owner->id(), 'type_id' => id_of('av'), 'id' => $media_work->id(), 'cur_module' => 'Editor');
         $link = html_entity_decode(carl_construct_link($params, array(''), '/reason/index.php'));
         if ($status == 'success') {
             $subject = '[Reason] Media processing complete: ' . html_entity_decode(strip_tags($media_work->get_value('name')));
             $message = 'Media Work Processed' . "\n\n";
             $message .= 'Name:' . "\n" . html_entity_decode(strip_tags($media_work->get_value('name'))) . "\n\n";
             $message .= 'Site:' . "\n" . html_entity_decode(strip_tags($owner->get_value('name'))) . "\n\n";
             $message .= 'View it at this url: ' . $link . "\n\n";
             $message .= 'Uploaded by:' . "\n" . $user->get_value('name') . "\n\n";
         } else {
             $subject = '[Reason] Media error: ' . html_entity_decode(strip_tags($media_work->get_value('name')));
             $message = 'Media Work Error During Processing' . "\n\n";
             $message .= 'Name:' . "\n" . html_entity_decode(strip_tags($media_work->get_value('name'))) . "\n\n";
             $message .= 'Site:' . "\n" . html_entity_decode(strip_tags($owner->get_value('name'))) . "\n\n";
             $message .= 'Uploaded by:' . "\n" . $user->get_value('name') . "\n\n";
             $message .= 'View it at this url: ' . $link . "\n\n";
             $message .= 'If you continue to get this error after multiple attempts, please contact your Reason Administrator regarding this issue: ' . WEBMASTER_EMAIL_ADDRESS . "\n\n";
         }
         mail($to, $subject, $message);
     }
 }
示例#18
0
 /**
  * Uploads an audio file to Zencoder.  Zencoder will encode .ogg and .mp3 file.  If the 
  * uploaded file is either an mp3 or an ogg with a reasonable bitrate, we keep that file
  * for one of the resulting media files, and only ask for the other output from Zencoder.
  * encodings.
  * @param $filepath string
  * @param $media_work obj
  * @param $netid string
  * @param $at_remote_url boolean (true if $filepath is at a remote url)
  * @param $force_both_encodings boolean (true if both mp3 and ogg versions should be encoded)
  * @return mixed object or false
  */
 public function upload_audio($filepath, $media_work, $netid, $at_remote_url = false, $force_both_encodings = false)
 {
     $media_files_to_delete = $this->_get_media_files($media_work);
     $media_work_to_delete = new entity($media_work->id());
     $filename = $this->_sanitize_filename(basename($filepath));
     $filepath = str_replace(basename($filepath), rawurlencode(basename($filepath)), $filepath);
     $extension = end(explode('.', $filename));
     $needs_deleting = false;
     if (strpos($filepath, 'http://') === 0 || $at_remote_url) {
         $bitrate = $this->_get_bitrate($filepath);
     } else {
         if (strpos($filepath, 'https://') === 0) {
             $filepath = str_replace('https://', 'http://', $filepath);
             $bitrate = $this->_get_bitrate($filepath);
         } else {
             $bitrate = $this->_get_bitrate($filepath);
             if ($force_both_encodings) {
                 $filepath = self::get_storage_class()->get_base_url() . $filepath;
             } else {
                 $filepath = carl_construct_link(array(''), array(''), WEB_TEMP . $filename);
             }
             $filepath = str_replace('https://', 'http://', $filepath);
         }
     }
     /*if (!$force_both_encodings)
     		{
      			$profile = $this->_get_audio_profile($extension, $bitrate);
      		}
      		else
      		{
      			$profile = 'both';
      		}*/
     // TEMPORARY HACK TO GET REASONABLE AUDIO ENCODINGS!  INSTALL ffmpeg ON CHICAGO!!
     $profile = 'both';
     $zencoder = new Services_Zencoder(ZENCODER_FULL_ACCESS_KEY);
     try {
         if ($profile == 'mp3') {
             $media_files = $this->_create_media_files($media_work, 'mp3', $filename);
             $output = array(array("label" => "ogg_" . $media_files[0], "format" => "ogg", "audio_codec" => "vorbis", "audio_quality" => 3, "url" => self::get_storage_class()->get_destination_url_for_transcoded_file($media_files[0], 'ogg', $media_work), "public" => true, "notifications" => $this->get_notification_receiver_url()));
             $output = self::get_storage_class()->add_additional_outputs($output, $filename, $media_work, $this, 'Audio');
             $encoding_job = $zencoder->jobs->create(array("input" => $filepath, "private" => true, "test" => ZENCODER_TEST_MODE, "outputs" => $output, "notifications" => array($this->get_final_notification_receiver_url())));
             if ($encoding_job) {
                 $this->_remove_existing_media($media_files_to_delete, $media_work_to_delete, $media_work, get_user_id($netid));
             }
             return $encoding_job;
         } elseif ($profile == 'ogg') {
             $media_files = $this->_create_media_files($media_work, 'ogg', $filename);
             $output = array(array("label" => "mp3_" . $media_files[0], "format" => "mp3", "audio_codec" => "mp3", "audio_quality" => 3, "url" => self::get_storage_class()->get_destination_url_for_transcoded_file($media_files[0], 'mp3', $media_work), "public" => true, "notifications" => $this->get_notification_receiver_url()));
             $output = self::get_storage_class()->add_additional_outputs($output, $filename, $media_work, $this, 'Audio');
             $encoding_job = $zencoder->jobs->create(array("input" => $filepath, "private" => true, "test" => ZENCODER_TEST_MODE, "outputs" => $output, "notifications" => array($this->get_final_notification_receiver_url())));
             if ($encoding_job) {
                 $this->_remove_existing_media($media_files_to_delete, $media_work_to_delete, $media_work, get_user_id($netid));
             }
             return $encoding_job;
         } else {
             if ($needs_deleting) {
                 unlink($newpath);
             }
             $media_files = $this->_create_media_files($media_work, 'audio', $filename);
             $dest_url = self::get_storage_class()->get_destination_url_for_transcoded_file(false, $extension, $media_work, 'original');
             $pass_through = null;
             if ($force_both_encodings) {
                 $pass_through = 'reencoding_audio';
             }
             $output = array(array("label" => "mp3_" . $media_files[0], "format" => "mp3", "audio_codec" => "mp3", "audio_quality" => 3, "url" => self::get_storage_class()->get_destination_url_for_transcoded_file($media_files[0], 'mp3', $media_work), "public" => true, "notifications" => $this->get_notification_receiver_url()), array("label" => "ogg_" . $media_files[1], "format" => "ogg", "audio_codec" => "vorbis", "audio_quality" => 3, "url" => self::get_storage_class()->get_destination_url_for_transcoded_file($media_files[1], 'ogg', $media_work), "public" => true, "notifications" => $this->get_notification_receiver_url()));
             $output = self::get_storage_class()->add_additional_outputs($output, $filename, $media_work, $this, 'Audio');
             $encoding_job = $zencoder->jobs->create(array("input" => $filepath, "private" => true, "test" => ZENCODER_TEST_MODE, "outputs" => $output, "notifications" => array($this->get_final_notification_receiver_url()), "pass_through" => $pass_through));
             if ($encoding_job) {
                 if ($force_both_encodings) {
                     $this->_remove_existing_media_files($media_files_to_delete, $media_work, get_user_id($netid), true);
                 } else {
                     $this->_remove_existing_media($media_files_to_delete, $media_work_to_delete, $media_work, get_user_id($netid));
                 }
             }
             return $encoding_job;
         }
     } catch (Services_Zencoder_Exception $e) {
         return false;
     }
 }
示例#19
0
	/**
	 * If we are integrated with askimet lets check this comment to make sure it isn't spam.
	 */
	function is_comment_spam()
	{
		$akismet_api_key = constant("AKISMET_API_KEY");
		if (!empty($akismet_api_key))
		{	
			include_once( AKISMET_INC . 'Akismet.class.php' );
			$url = carl_construct_link();
			$akismet = new Akismet($url, $akismet_api_key);
			$akismet->setCommentAuthor($this->get_value('author'));
			$akismet->setCommentContent($this->get_value('comment_content'));
			return ($akismet->isCommentSpam());
		}
		return false;
	}
示例#20
0
	/**
	 * Add basic metadata using the open graph protocol (http://ogp.me/).
	 *
	 * This should improve how shared items appear on facebook and possibly other social networks.
	 *
	 * @todo add integration with propietary tags for specific social networks.
	 */
	function _add_open_graph_tags_for_item()
	{
		$item = new entity($this->current_item_id);
		if (reason_is_entity($item, 'news'))
		{
			$title = htmlspecialchars(trim(strip_tags($item->get_value('release_title'))),ENT_QUOTES,'UTF-8');
			$description = htmlspecialchars(trim(str_replace('&nbsp;', '', strip_tags($item->get_value('description')))),ENT_QUOTES,'UTF-8');
			if (empty($description)) // lets look to the content field if description is missing.
			{
				$content = htmlspecialchars(trim(str_replace('&nbsp;', '', strip_tags($item->get_value('content')))),ENT_QUOTES,'UTF-8');
				if (!empty($content))
				{
					$words = explode(' ', $content, 31);
					unset($words[count($words)-1]);
					$description = implode(' ', $words).'…';
				}
			}
			$url = carl_construct_link(array(''), array('story_id', 'issue_id', 'section_id'));
			if ($teaser = $this->get_teaser_image($item))
			{
				$teaser = reset($teaser);
				$image_urls[] = reason_get_image_url($teaser);
			}
			elseif ($images = $this->get_item_images($item))
			{
				foreach ($images as $image)
				{
					$image_urls[] = reason_get_image_url($image);
				}
			}
			$site = $this->get_site_entity();
			if ($site) $site_name = htmlspecialchars(trim(strip_tags($site->get_value('name'))),ENT_QUOTES,'UTF-8');
			$head_items =& $this->get_head_items();
			$head_items->add_head_item('meta',array( 'property' => 'og:type', 'content' => 'article'));
			$head_items->add_head_item('meta',array( 'property' => 'og:title', 'content' => $title));
			$head_items->add_head_item('meta',array( 'property' => 'og:url', 'content' => $url));
			if (!empty($description)) $head_items->add_head_item('meta',array( 'property' => 'og:description', 'content' => $description));
			if (!empty($image_urls))
			{
				foreach ($image_urls as $image_url)
				{
					$head_items->add_head_item('meta',array( 'property' => 'og:image', 'content' => 'http://'.$_SERVER['HTTP_HOST'].$image_url));
					if (HTTPS_AVAILABLE) $head_items->add_head_item('meta',array( 'property' => 'og:image:secure_url', 'content' => 'https://'.$_SERVER['HTTP_HOST'].$image_url));
				}	
			}
			if (!empty($site_name)) $head_items->add_head_item('meta',array( 'property' => 'og:site_name', 'content' => $site_name));
		}
	}
示例#21
0
	/**
	 * We can only provide a link if the form saves to a database and is editable by the submitter
	 */
	function get_link_for_email_submitter_view()
	{
		if ($this->should_email_link() && $this->should_save_form_data() && $this->is_editable())
		{
			$link = carl_construct_link(array('form_id' => $this->get_form_id()));
			return $link;
		}
		else return '';
	}
示例#22
0
	function get_options_for_email_submitter_view()
	{
		if ($this->should_email_link())
		{
			$email_link = $this->get_link_for_email_submitter_view();
			if (!empty($email_link))
			{
				$options['access_link'] = $email_link;
			}
			else
			{
				$options['origin_link'] = carl_construct_link(array('')); // we use the origin if no link to edit is available
			}
		}
		$options['email_empty_fields'] = $this->should_email_empty_fields();
		$options['subject'] = 'Form Submission Confirmation: ' . $this->get_form_name(); // should i include form name
		$options['header'] = $this->get_form_name() . " - " . "Successfully Submitted " . carl_date('l, F jS Y \\a\t h:i:s A');
		$options['to'] = $this->get_email_of_submitter();
		$options['disclaimer'] = false;
		$view =& $this->get_view();
		if (method_exists($view, 'get_custom_options_for_email_submitter_view'))
		{
			$view_options = $view->get_custom_options_for_email_submitter_view();
			if (is_array($view_options))
			{
				$options = array_merge($options, $view_options);
			}
			else trigger_error('The method get_custom_options_for_email_submitter_view, if defined in the view, needs to return an array.');
		}
		return $options;
	}
 /**
  * Handles uploading to Vimeo
  */
 function _handle_uploaded_file()
 {
     if (!$this->manager->has_error('upload_file') && !$this->manager->has_error('upload_url')) {
         // Make sure only one
         if ($this->manager->get_value('upload_file') && $this->manager->get_value('upload_url')) {
             $this->manager->set_error('upload_file', 'Cannot upload file and provide a url at the same time. Only use one.');
             $this->manager->set_error('upload_url', 'Cannot upload file and provide a url at the same time. Only use one.');
             return;
         }
         if ($this->manager->get_value('upload_file')) {
             $file = $this->manager->get_element('upload_file');
             if (($file->state == 'received' or $file->state == 'pending') and file_exists($file->tmp_full_path)) {
                 $user = new entity($this->manager->admin_page->authenticated_user_id);
                 $filePath = $file->tmp_full_path;
                 $filename_parts = explode('/', $filePath);
                 $filename = end($filename_parts);
                 $this->manager->set_value('tmp_file_name', $filename);
                 // convert filePath to web accessible url
                 $filePath = carl_construct_link(array(), array(), WEB_TEMP . $filename);
                 $this->_process_work($filePath, $file->tmp_full_path, false);
             }
         } elseif ($this->manager->get_value('upload_url')) {
             $this->_process_work($this->manager->get_value('upload_url'), '', true);
         }
     }
 }
示例#24
0
/**
 * Deprecated -- use carl_construct_link()
 * @deprecated
 */
function construct_link($new_request_vars = array(''), $preserve_request_vars = array(''), $base_path = '')
{
    $call_info = array_shift(debug_backtrace());
    $code_line = $call_info['line'];
    $file = array_pop(explode('/', $call_info['file']));
    trigger_error('deprecated function construct_link called by ' . $file . ' on line ' . $code_line . ' - use carl_construct_link instead', WARNING);
    return carl_construct_link($new_request_vars, $preserve_request_vars, $base_path);
}
 /**
  * Most of the work in setting up the form happens here
  * This function has been broken up into several sub-functions for ease of reading and modification:
  * prefill_name(), massage_delivery_method_elements(), do_basic_field_modification(), add_file_import_selector(), modify_url_field(), and add_file_preview().
  * 
  */
 public function alter_data()
 {
     if (REASON_MANAGES_MEDIA && !empty($this->file_transfer_utility_class) && class_exists($this->file_transfer_utility_class)) {
         $this->manages_media = true;
     }
     if (MEDIA_ALLOW_DIRECT_UPLOAD) {
         $this->form_enctype = 'multipart/form-data';
     }
     $this->prefill_name();
     $this->massage_delivery_method_elements();
     $this->do_basic_field_modification();
     if (MEDIA_ALLOW_DIRECT_UPLOAD) {
         $this->add_file_upload_element();
     }
     if (MEDIA_ALLOW_IMPORT_FROM_FILESYSTEM) {
         $this->add_file_import_selector();
     }
     $this->modify_url_field();
     $this->add_file_preview();
     $this->add_parts_toggler();
     if ($this->manager->get_element('caption_url') && $this->manager->get_element('audio_description_url')) {
         $this->modify_caption_url_field();
         $this->modify_audio_description_field();
     } else {
         $script_link = carl_construct_link(array(''), array(''), REASON_HTTP_BASE_PATH . 'scripts/upgrade/4.0b7_to_4.0b8/update_types.php');
         trigger_error('The media file type is missing fields for captioning and audio description. Please run the Reason 4 Beta 8 upgrade types script (' . $script_link . ').');
     }
     $this->manager->set_order(array('file_preview', 'name', 'link', 'replacement_header', 'upload_file', 'import_file_as_alternate', 'import_file', 'url', 'caption_url', 'audio_description_url', 'file_info_header', 'delivery_methods', 'default_media_delivery_method', 'media_format', 'av_type', 'media_duration', 'media_size', 'media_quality', 'width', 'height', 'parts_hr_1', 'parts', 'is_part', 'av_part_number', 'av_part_total', 'description', 'parts_hr_2'));
     $this->manager->change_element_type('flavor_id', 'hidden');
     $this->manager->change_element_type('mime_type', 'hidden');
     $this->manager->change_element_type('download_url', 'hidden');
 }
示例#26
0
 function show_admin_control_box()
 {
     $table_admin =& $this->get_table_admin();
     $custom_form =& $this->get_custom_form();
     if ($table_admin) {
         $url = carl_construct_link(array('form_admin_view' => ''), array('textonly'));
         $link[] = '<a href="' . $url . '">' . $this->params['exit_admin_view_text'] . '</a>';
         if ($table_admin->get_table_row_action()) {
             $url2 = carl_make_link($table_admin->get_menu_links_base_with_filters());
             $link[] = '<a href="' . $url2 . '">' . $this->params['show_lister_view_text'] . '</a>';
         }
     } elseif ($this->has_admin_access() && $custom_form->allow_show_admin_control_box()) {
         $url = carl_construct_link(array('form_admin_view' => 'true'), array('textonly'));
         $link[] = '<a href="' . $url . '">' . $this->params['enter_admin_view_text'] . '</a>';
     }
     if (!empty($link)) {
         echo '<div id="formAdminControlBox">';
         echo '<p>' . implode(' | ', $link) . '</p>';
         echo '</div>';
     }
 }