<commit_before><?php

/**
 * @file
 * 
 * Mention services.
 * 
 * @package core
 * @copyright <NAME> 2013
 * @license The MIT License (see LICENCE.txt), other licenses available.
 * @author <NAME> <<EMAIL>>
 * @link http://www.marcus-povey.co.uk
 */

namespace pingback2hook\mention {
    
    use pingback2hook\core\Page as Page;
    use pingback2hook\core\Input as Input;
    use pingback2hook\endpoints\Endpoint as Endpoint;
    use pingback2hook\templates\Template as Template;
    
    class Webmention extends Mention {
        
        public function init() {
            
            Page::create('webmention', function($page, $subpages){
                
                if ($endpoint = Endpoint::get($subpages[0])) {
                 
                    $source_url = Input::getPOST('source');
                    $target_url = Input::getPOST('target');

                    // Do we have a source and target URL?
                    if ($source_url && $target_url) {

                        // Check we haven't already got this one registered.
                        if (self::isTargetRegistered($source_url, $target_url))
                            throw new AlreadyRegisteredException("Target $target_url has already been registered.");
                        
                        // Check whether target is in source url
                        if (!$details = self::checkSourceUrl($source_url, $target_url))
                            throw new NoLinkFoundException("$target_url not found in $source_url");
                        
                        if (self::saveMention($target_url, $source_url, $details)) {
                            
                            header('HTTP/1.1 202 Accepted');
                            
                            Template::getInstance()->outputPage("Webmention of $target_url from $source_url", array(
                                'result' => 'Ok.'
                            ));
                        }
                        else
                            throw new TargetNotSupportedException("Problem saving mention to $target_url from $source_url.");
                    }
                    else
                        throw new SourceNotFoundException('Source and target variables missing.');
                    
                }
                else
                    throw new TargetNotFoundException('No endpoint of that definition specified.');
                
            });
        }
    }
}<commit_msg>Adding endpoint to pinged data<commit_after><?php

/**
 * @file
 * 
 * Mention services.
 * 
 * @package core
 * @copyright <NAME> 2013
 * @license The MIT License (see LICENCE.txt), other licenses available.
 * @author <NAME> <<EMAIL>>
 * @link http://www.marcus-povey.co.uk
 */

namespace pingback2hook\mention {
    
    use pingback2hook\core\Page as Page;
    use pingback2hook\core\Input as Input;
    use pingback2hook\endpoints\Endpoint as Endpoint;
    use pingback2hook\templates\Template as Template;
    
    class Webmention extends Mention {
        
        public function init() {
            
            Page::create('webmention', function($page, $subpages){
                
                if ($endpoint = Endpoint::get($subpages[0])) {
                 
                    $source_url = Input::getPOST('source');
                    $target_url = Input::getPOST('target');

                    // Do we have a source and target URL?
                    if ($source_url && $target_url) {

                        // Check we haven't already got this one registered.
                        if (self::isTargetRegistered($source_url, $target_url))
                            throw new AlreadyRegisteredException("Target $target_url has already been registered.");
                        
                        // Check whether target is in source url
                        if (!$details = self::checkSourceUrl($source_url, $target_url))
                            throw new NoLinkFoundException("$target_url not found in $source_url");
                        
                        // Append configuration details
                        $details['endpoint'] = $subpages[0];
                        
                        // Save
                        if (self::saveMention($target_url, $source_url, $details)) {
                            
                            header('HTTP/1.1 202 Accepted');
                            
                            Template::getInstance()->outputPage("Webmention of $target_url from $source_url", array(
                                'result' => 'Ok.'
                            ));
                        }
                        else
                            throw new TargetNotSupportedException("Problem saving mention to $target_url from $source_url.");
                    }
                    else
                        throw new SourceNotFoundException('Source and target variables missing.');
                    
                }
                else
                    throw new TargetNotFoundException('No endpoint of that definition specified.');
                
            });
        }
    }
}
{'fraction_non_alphanumeric': 0.09015921734126223, 'fraction_numerical': 0.005946671782083254, 'mean_word_length': 1.273877017008286, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2366251', 'n_tokens_mistral': 1234, 'n_tokens_neox': 1153, 'n_words': 306}