Exemplo n.º 1
0
<?php

/* Codeine
 * @author bergstein@trickyplan.com
 * @description  
 * @package Codeine
 * @version 8.x
 */
setFn('Check', function ($Call) {
    $Filters = F::Run('IO', 'Read', ['Storage' => 'Web', 'Format' => 'Formats.JSON', 'RTTL' => 86400, 'Where' => ['ID' => $Call['IDS']['Filters URL']]]);
    $Filters = array_pop($Filters);
    $Score = 0;
    F::Log('*' . count($Filters['filters']['filter']) . '* filters loaded', LOG_INFO, 'Security');
    foreach ($Filters['filters']['filter'] as $Filter) {
        if (preg_match('/' . $Filter['rule'] . '/Ssu', $Call['HTTP']['URI'])) {
            F::Log('IDS-' . $Filter['id'] . ': ' . $Filter['description'] . ' with impact ' . $Filter['impact'], LOG_NOTICE - $Filter['impact'], 'Security');
            $Score += $Filter['impact'];
        }
    }
    $Verbose = LOG_INFO;
    if ($Score > $Call['IDS']['Impact Levels']['Red']) {
        $Call = F::Hook('onRedImpactLevel', $Call);
        $Verbose = LOG_ERR;
    } elseif ($Score > $Call['IDS']['Impact Levels']['Yellow']) {
        $Call = F::Hook('onYellowImpactLevel', $Call);
        $Verbose = LOG_WARNING;
    }
    F::Log('Overall IDS Impact: ' . $Score, $Verbose, 'Security');
    return $Call;
});
Exemplo n.º 2
0
<?php

/* Codeine
 * @author bergstein@trickyplan.com
 * @description  
 * @package Codeine
 * @version 8.x
 */
setFn('Length', function ($Call) {
    if (isset($Call['View']['HTML']['Keywords']) && is_string($Call['View']['HTML']['Keywords'])) {
        $Length = mb_strlen($Call['View']['HTML']['Keywords']);
        if ($Length > $Call['SEO']['Audit']['Keywords']['Length']['Maximum']) {
            $Call = F::Hook('SEO.Audit.Keywords.TooLong', $Call);
            F::Log('SEO Keywords is too long *' . $Length . ' chars* over *' . $Call['SEO']['Audit']['Keywords']['Length']['Maximum'] . '*', LOG_WARNING, 'Marketing');
        } elseif ($Length < $Call['SEO']['Audit']['Keywords']['Length']['Minimum']) {
            $Call = F::Hook('SEO.Audit.Keywords.TooShort', $Call);
            F::Log('SEO Keywords is too short *' . $Length . ' chars* over *' . $Call['SEO']['Audit']['Keywords']['Length']['Minimum'] . '*', LOG_WARNING, 'Marketing');
        } else {
            F::Log('SEO Keywords length is optimal ', LOG_NOTICE, 'Marketing');
        }
    }
    return $Call;
});
Exemplo n.º 3
0
<?php

/* Codeine
 * @author bergstein@trickyplan.com
 * @description  
 * @package Codeine
 * @version 7.6,2
 */
setFn('Widget', function ($Call) {
    return F::Apply($Call['Modes'][$Call['Mode']], 'Widget', $Call);
});
setFn('Check', function ($Call) {
    if (!isset($Call['CAPTCHA']['Bypass'])) {
        if (!F::Run($Call['Modes'][$Call['Mode']], 'Check', $Call)) {
            F::Log('CAPTCHA Failed from IP ' . F::Live($Call['HTTP']['IP']), LOG_ERR, 'Security');
            $Call['Failure'] = true;
            $Call = F::Hook('CAPTCHA.Failed', $Call);
        }
    }
    return $Call;
});
Exemplo n.º 4
0
                }
            }
        }
        // Вывести
        $Call['Output']['Content']['Form Widget']['Action'] = isset($Call['Action']) ? $Call['Action'] : '';
    }
    $Call = F::Hook('afterVerifyGet', $Call);
    return $Call;
});
setFn('POST', function ($Call) {
    if (isset($Call['Request']['Data'])) {
        $Call['Data'] = $Call['Request']['Data'];
    } else {
        $Call['Data'] = [];
    }
    $Call = F::Hook('beforeVerifyPost', $Call);
    // Отправляем в Entity.Verify
    $Call['Data'] = F::Merge(F::Run('Entity', 'Read', $Call, ['Time' => microtime(true)]), F::Apply('Entity', 'Update', $Call));
    // Выводим результат
    if (empty($Call['Errors'])) {
        $Call = F::Hook('afterVerifyPost', $Call);
    } else {
        foreach ($Call['Errors'] as $Name => $Node) {
            foreach ($Node as $Error) {
                $Call['Output']['Message'][] = ['Type' => 'Block', 'Class' => 'alert alert-danger', 'Value' => '<l>' . $Call['Entity'] . '.Error:' . $Name . '.' . $Error . '</l>'];
            }
        }
        $Call = F::Apply(null, 'GET', $Call);
    }
    return $Call;
});
Exemplo n.º 5
0
            } else {
                $Table = [];
            }
            foreach ($Call['Nodes'] as $Name => $Node) {
                $NewValue = F::Dot($New, $Name);
                $OldValue = F::Dot($Old[$IX], $Name);
                if ($OldValue == $NewValue || $Name == 'ID') {
                } else {
                    $Table[] = ['<l>' . $Call['Entity'] . '.Entity:' . $Name . '</l>', $OldValue, $NewValue];
                }
            }
            $Call['Output']['Content'][] = ['Type' => 'Table', 'Value' => $Table];
        }
        $Call['Output']['Content'][] = ['Type' => 'Block', 'Class' => 'alert alert-success', 'Value' => count($New) . ' object touched'];
    }
    $Call = F::Hook('afterTouch', $Call);
    return $Call;
});
setFn('All', function ($Call) {
    $Call = F::Apply('Entity', 'Load', $Call);
    $Total = F::Run('Entity', 'Count', $Call);
    $Amount = ceil($Total / $Call['All']['Limit']);
    set_time_limit(10 * $Total);
    $Call = F::Apply('Code.Progress', 'Start', $Call);
    $Call['Progress']['Max'] = $Amount;
    for ($i = 0; $i < $Amount; $i++) {
        F::Run('Entity', 'Update', ['Entity' => $Call['Entity'], 'Where' => $Call['Where'], 'Data' => [], 'One' => false, 'Limit' => ['From' => $i * $Call['All']['Limit'], 'To' => ($i + 1) * $Call['All']['Limit']]]);
        $Call['Progress']['Now']++;
        $Call = F::Apply('Code.Progress', 'Log', $Call);
        F::Log('Touch Iteration № ' . ($i + 1) / $Amount, LOG_NOTICE);
    }
Exemplo n.º 6
0
<?php

/* Codeine
 * @author bergstein@trickyplan.com
 * @description  
 * @package Codeine
 * @version 8.x
 */
setFn('Do', function ($Call) {
    F::Log('User ' . $Call['Session']['User']['ID'] . ' logged in ' . $Call['Where'], LOG_INFO, 'Security');
    $Call = F::Apply('Session', 'Write', $Call, ['Session Data' => ['Secondary' => $Call['Where']]]);
    $Call = F::Apply('Entity', 'Load', $Call, ['Entity' => 'User']);
    $Call = F::Hook('afterLogin', $Call);
    return $Call;
});
Exemplo n.º 7
0
            $XML->text(date(DATE_RSS, $Element['Data']['Created']));
            $XML->endElement();
            // description
            if (isset($Element['Data']['Description'])) {
                $XML->startElement('description');
                $XML->writeCdata($Element['Data']['Description']);
                $XML->endElement();
                // description
            }
            $XML->startElement('link');
            if (isset($Element['Data']['Slug'])) {
                $XML->text($Call['HTTP']['Proto'] . $Call['HTTP']['Host'] . '/' . $Call['Slug']['Entity'] . '/' . $Element['Data']['Slug'] . '?Channel=RSS');
            } else {
                $XML->text($Call['HTTP']['Proto'] . $Call['HTTP']['Host'] . '/' . $Call['Slug']['Entity'] . '/' . $Element['Data']['ID'] . '?Channel=RSS');
            }
            // FIXME It's double shit!
            $XML->endElement();
            // title
            $XML->endElement();
            // item
        }
    }
    $XML->endElement();
    // Channel
    $XML->endElement();
    // rss
    $XML->endDocument();
    $Call['Output'] = $XML->outputMemory(true);
    $Call = F::Hook('afterRSSPipeline', $Call);
    return $Call;
});
Exemplo n.º 8
0
<?php

/* Codeine
 * @author bergstein@trickyplan.com
 * @description  
 * @package Codeine
 * @version 8.x
 */
setFn('Run', function ($Call) {
    F::Log('API Call *' . $Call['Run']['Service'] . ':' . $Call['Run']['Method'] . '* started', LOG_NOTICE);
    $Call = F::Hook('beforeAPIRun', $Call);
    // В этом месте, практически всегда, происходит роутинг.
    if (F::Dot($Call, 'API.Run.' . $Call['Run']['Service'] . '.' . $Call['Run']['Method'] . '.Allowed')) {
        $AllowedCall = F::Dot($Call, 'API.Run.' . $Call['Run']['Service'] . '.' . $Call['Run']['Method'] . '.Params');
        $Call['Run']['Call'] = $Call['Request'];
        $Run = [];
        foreach ($AllowedCall as $Key) {
            if (isset($Call['Run']['Call'][$Key])) {
                $Run[$Key] = $Call['Run']['Call'][$Key];
            }
        }
        $Call = F::Run($Call['Run']['Service'], $Call['Run']['Method'], $Call, $Run);
    }
    $Call = F::Hook('afterAPIRun', $Call);
    // А здесь - рендеринг
    F::Log('Application *' . $Call['Run']['Service'] . ':' . $Call['Run']['Method'] . '* finished', LOG_INFO);
    return $Call;
});
Exemplo n.º 9
0
<?php

/* Codeine
 * @author bergstein@trickyplan.com
 * @description  
 * @package Codeine
 * @version 8.x
 */
setFn('Write', function ($Call) {
    $Call['Value'] = $_FILES['file'];
    $Call['ID'] = F::Run('Security.UID', 'Get', $Call);
    $Call['Data'] = file_get_contents($_FILES['file']['tmp_name']);
    $Call['Name'] = F::Live($Call['Naming'], $Call);
    F::Run('IO', 'Write', $Call, ['Storage' => 'Uploader', 'Scope' => 'wysiwyg', 'Where' => $Call['Name']]);
    $Call['Output']['Content']['filelink'] = '/uploads/wysiwyg/' . $Call['Name'];
    // FIXME Scope support
    return $Call;
});
setFn('Read', function ($Call) {
    $Call['Output']['Content'] = F::Run('IO', 'Read', $Call, ['Storage' => 'Upload', 'Scope' => 'WYSIWYG']);
    if (empty($Call['Output']['Content'])) {
        $Call = F::Hook('onUploaderNotFound', $Call);
    }
    return $Call;
});
Exemplo n.º 10
0
 * @description  
 * @package Codeine
 * @version 8.x
 */
setFn('Detect', function ($Call) {
    $Call = F::Hook('beforeLocaleDetect', $Call);
    if (isset($Call['Locale'])) {
        F::Log('Locale selected: *' . $Call['Locale'] . '*', LOG_INFO);
    } else {
        $Call['Locale'] = $Call['Default']['Locale'];
        if (F::Dot($Call, 'Locales.Detect.Accept-language')) {
            $Call = F::Apply(null, 'Check Accept-language', $Call);
        }
    }
    setlocale(LC_ALL, $Call['Locales']['PHP'][$Call['Locale']]);
    $Call = F::Hook('afterLocaleDetect', $Call);
    return $Call;
});
setFn('Check Accept-language', function ($Call) {
    if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
        preg_match_all('/([a-z]{1,8}(-[a-z]{1,8})?)\\s*(;\\s*q\\s*=\\s*(1|0\\.[0-9]+))?/i', $_SERVER['HTTP_ACCEPT_LANGUAGE'], $Parsed);
        $Locales = array_combine($Parsed[1], $Parsed[4]);
        foreach ($Locales as $Locale => $Q) {
            if ($Q === '') {
                $Locales[$Locale] = 1;
            }
        }
        arsort($Locales, SORT_NUMERIC);
        foreach ($Locales as $Locale => $Quality) {
            if (isset($Call['Accept-Language'][$Locale])) {
                $Call['Locale'] = $Call['Accept-Language'][$Locale];
Exemplo n.º 11
0
/* Codeine
 * @author bergstein@trickyplan.com
 * @description  
 * @package Codeine
 * @version 8.x
 */
setFn('Do', function ($Call) {
    F::Log('CLI Interface Started', LOG_NOTICE);
    $Call = F::Hook('beforeInterfaceRun', $Call);
    $Call['HTTP']['IP'] = F::Live($Call['HTTP']['IP'], $Call);
    if (isset($Call['Project']['Hosts'][F::Environment()])) {
        $Call['HTTP']['Host'] = $Call['Project']['Hosts'][F::Environment()];
    }
    $Call['HTTP']['Proto'] = 'https';
    $Call['HTTP']['URL'] = '/';
    if (isset($Call['Skip Run'])) {
        F::Log('Run Skipped, because ' . $Call['Skip Run'], LOG_INFO);
    } else {
        F::Log($Call['Service'] . ':' . $Call['Method'] . ' started', LOG_NOTICE);
        $Call = F::Apply($Call['Service'], $Call['Method'], $Call);
    }
    $Call = F::Hook('afterInterfaceRun', $Call);
    if (is_array($Call) && isset($Call['Output'])) {
        F::Run('IO', 'Write', $Call, ['Storage' => 'Output', 'Where' => $Call['Service'] . ':' . $Call['Method'], 'Data' => $Call['Output']]);
        if (isset($Call['Failure']) && $Call['Failure']) {
            $Call['Return Code'] = 1;
        }
    }
    F::Log('CLI Finished', LOG_NOTICE);
    return $Call;
});
Exemplo n.º 12
0
    return $Call;
});
setFn('Do', function ($Call) {
    $Call = F::Hook('beforeShow', $Call);
    $Call = F::Hook('beforeShowDo', $Call);
    /*foreach ($Call['Data'] as $Node => $Value)
      {
          if (isset($Call['Nodes'][$Node]['Widgets']))
              ;
          else
              unset ($Call['Data'][$Node]);
      }*/
    if (isset($Call['Data']['Redirect']) && !empty($Call['Data']['Redirect'])) {
        $Call = F::Apply('System.Interface.HTTP', 'Redirect', $Call, ['Redirect' => $Call['Data']['Redirect']]);
    } else {
        $Call['Layouts'][] = ['Scope' => $Call['Entity'], 'ID' => 'Show', 'Context' => $Call['Context']];
        $Call['Scope'] = isset($Call['Scope']) ? $Call['Entity'] . '/' . $Call['Scope'] : $Call['Entity'];
        if (empty($Call['Data'])) {
            $Call = F::Hook('onShowNotFound', $Call);
        } else {
            $Call['Output']['Content'][] = array('Type' => 'Template', 'Scope' => $Call['Scope'], 'ID' => 'Show/' . (isset($Call['Template']) ? $Call['Template'] : 'Full'), 'Data' => $Call['Data']);
            $Call = F::Hook('afterShow', $Call);
        }
    }
    /*        if (isset($Call['Data']['Modified']))
                $Call['HTTP']['Headers']['Last-Modified:'] = date(DATE_RFC2822, $Call['Data']['Modified']);
            else
                $Call['HTTP']['Headers']['Last-Modified:'] = date(DATE_RFC2822, $Call['Data']['Created']);*/
    F::Log($Call['Data'], LOG_DEBUG);
    return $Call;
});
Exemplo n.º 13
0
                    F::Log($Request . j($Result), LOG_ERR, 'Administrator');
                }
                unset($Call['Data']['_id']);
                // Mongo, are you kiddin'me?
            } else {
                $Request = 'db.*' . $Call['Scope'] . '*.remove()';
                $Result = $Call['Link']->{$Call}['Scope']->remove([], ['justOne' => $Call['Mongo']['Just One'], 'w' => $Call['Mongo']['Write Concerns']]);
                if ($Result) {
                    F::Log($Request, LOG_INFO, 'Administrator');
                } else {
                    F::Log($Request . j($Result), LOG_ERR, 'Administrator');
                }
            }
        }
    } catch (MongoException $e) {
        return F::Hook('IO.Mongo.Write.Failed', $Call);
    }
    return isset($Call['Data']) ? $Call['Data'] : null;
});
setFn('Close', function ($Call) {
    return true;
});
setFn('Execute', function ($Call) {
    F::Log($Call['Command'], LOG_INFO);
    return $Call['Link']->execute($Call['Command']);
});
setFn('Count', function ($Call) {
    $Call['Scope'] = strtr($Call['Scope'], '.', '_');
    if (isset($Call['Where']) and $Call['Where'] !== null) {
        $Call = F::Apply(null, 'Where', $Call);
        if (isset($Call['Distinct']) && $Call['Distinct']) {
Exemplo n.º 14
0
        foreach ($Call['Latency']['Audit']['Limits'] as $Limit => $Value) {
            if ($Total >= $Value) {
                $Decision = $Limit;
            }
        }
        $Verbose = LOG_DEBUG;
        switch ($Decision) {
            case 'Green':
                $Verbose = PHP_INT_MAX;
                break;
            case 'Orange':
                $Verbose = LOG_DEBUG;
                break;
            case 'Yellow':
                $Verbose = LOG_INFO;
                break;
            case 'Red':
                $Verbose = LOG_NOTICE;
                break;
            case 'Black':
                $Verbose = LOG_ERR;
                break;
        }
        F::Log('Latency level is *' . $Decision . '*, because total page time *' . $Total . '* ms', $Verbose, 'Performance');
        if ($Verbose <= LOG_NOTICE) {
            self::$_Performance = true;
        }
        $Call = F::Hook('Latency.Audit.' . $Decision, $Call);
    }
    return $Call;
});
Exemplo n.º 15
0
<?php

/* Codeine
 * @author bergstein@trickyplan.com
 * @description  
 * @package Codeine
 * @version 8.x
 */
setFn('Render', function ($Call) {
    $Call = F::Hook('beforeJSONRender', $Call);
    $Call = F::Run('View.Pipeline', 'Do', $Call);
    $Call['Output'] = j($Call['Output']['Content']);
    $Call = F::Hook('afterJSONRender', $Call);
    return $Call;
});
Exemplo n.º 16
0
                $Call['JS']['Fullpath'] = strtr($Call['JS']['Fullpath'], ':', '_') . '_' . sha1($Call['JS']['Source']) . $Call['JS']['Extension'];
                $Write = true;
                if ($Call['JS']['Caching']) {
                    if (F::Run('IO', 'Execute', $Call, ['Storage' => 'JS Cache', 'Execute' => 'Exist', 'Where' => ['ID' => $Call['JS']['Fullpath']]]) === null) {
                        F::Log('Cache *miss* *' . $Call['JS']['Fullpath'] . '*', LOG_NOTICE);
                    } else {
                        F::Log('Cache *hit* ' . $Call['JS']['Fullpath'], LOG_DEBUG);
                        $Write = false;
                    }
                }
                if ($Write) {
                    $Call = F::Hook('beforeJSWrite', $Call);
                    F::Run('IO', 'Write', $Call, ['Storage' => 'JS Cache', 'Where' => $Call['JS']['Fullpath'], 'Data' => $Call['JS']['Source']]);
                    $Call = F::Hook('afterJSWrite', $Call);
                }
                $SRC = F::Run('IO', 'Execute', $Call, ['Storage' => 'JS Cache', 'Execute' => 'Filename', 'Where' => $Call['JS']['Fullpath']]);
                if (isset($Call['JS']['Host']) && !empty($Call['JS']['Host'])) {
                    $JSFilename = $Call['HTTP']['Proto'] . $Call['JS']['Host'] . $SRC;
                } else {
                    $JSFilename = $SRC;
                }
                $Call['JS']['Links'][$JSFilename] = '<script src="' . $JSFilename . '" type="' . $Call['JS']['Type'] . '"></script>';
            }
            $Call = F::Hook('afterJSOutput', $Call);
            $Call['Output'] = str_replace('<place>JS</place>', implode(PHP_EOL, $Call['JS']['Links']), $Call['Output']);
        }
        $Call['Output'] = str_replace($Parsed[0], '', $Call['Output']);
    }
    unset($Call['JS']);
    return $Call;
});
Exemplo n.º 17
0
<?php

/* Codeine
 * @author bergstein@trickyplan.com
 * @description: Фронт контроллер
 * @package Codeine
 * @version 8.x
 * @date 31.08.11
 * @time 1:12
 */
setFn('Run', function ($Call) {
    list($Call['Service'], $Call['Method']) = array($Call['Run']['Service'], $Call['Run']['Method']);
    F::Log('Application *' . $Call['Service'] . ':' . $Call['Method'] . '* started', LOG_NOTICE);
    $Call = F::Hook('beforeApplicationRun', $Call);
    // В этом месте, практически всегда, происходит роутинг.
    $Call = F::Live($Call['Run'], $Call);
    $Call = F::Hook('afterApplicationRun', $Call);
    // А здесь - рендеринг
    //        F::Log('Application *'.$Call['Run']['Service'].':'.$Call['Run']['Method'].'* finished', LOG_INFO);
    if (is_array($Call)) {
        $Call['Context'] = '';
    }
    return $Call;
});
Exemplo n.º 18
0
                    $Widget['Options'] = F::Live($Widget['Options'], $Call);
                } else {
                    $Widget['Options'] = [];
                }
                /*                    if($ic == 0)
                                      $Widget['Autofocus'] = true;*/
                // Если есть значение, добавляем
                if (isset($Call['Data'])) {
                    if (($Widget['Value'] = F::Dot($Call['Data'], $Name)) === null) {
                        if (isset($Node['Default'])) {
                            $Widget['Value'] = F::Live($Node['Default']);
                        }
                    }
                }
                // Упростить
                if (isset($Widget['Value'])) {
                    $Widget['Value'] = F::Live($Widget['Value']);
                } else {
                    $Widget['Value'] = null;
                }
                // Помещаем виджет в поток
                $ic++;
                $Call = F::Apply('Entity.Form.Layout.' . $Call['FormLayout'], 'Add', $Call, ['IC' => $ic, 'Name' => $Name, 'Widget' => $Widget]);
                $Call['Widget'] = null;
            }
        }
    }
    // Вывести
    $Call = F::Hook('afterFilterDo', $Call);
    return $Call;
});
Exemplo n.º 19
0
<?php

/* Codeine
 * @author bergstein@trickyplan.com
 * @description  
 * @package Codeine
 * @version 8.x
 */
setFn('Open', function ($Call) {
    return $Call;
});
setFn('Read', function ($Call) {
    if (PHP_SAPI == 'cli') {
        return null;
    }
    return isset($Call['HTTP']['Cookie'][$Call['Where']['ID']]) ? $Call['HTTP']['Cookie'][$Call['Where']['ID']] : null;
});
setFn('Write', function ($Call) {
    if (null !== $Call['Data']) {
        if (setcookie($Call['Where']['ID'], $Call['Data'], time() + $Call['TTL'], $Call['Path'], $Call['HTTP']['Host'], $Call['Secure'], $Call['HTTP Only'])) {
            $Call['HTTP']['Cookie'][$Call['Where']['ID']] = $Call['Data'];
        } else {
            $Call = F::Hook('Cookie.Set.Failed', $Call);
        }
    } else {
        setcookie($Call['HTTP']['Cookie'][$Call['Where']['ID']], '');
    }
    return $Call;
});
Exemplo n.º 20
0
 * @package Codeine
 * @version 8.x
 */
setFn('Do', function ($Call) {
    $Call = F::Apply('Entity', 'Load', $Call);
    if (isset($Call['Where'])) {
        $Call['Where'] = F::Live($Call['Where']);
    }
    // FIXME
    $Call = F::Hook('beforeAllowDo', $Call);
    if ($Call['Allow']['Mode'] == 'Confirmation') {
        $Call = F::Run(null, $Call['HTTP']['Method'], $Call);
    } elseif ($Call['Allow']['Mode'] == 'Direct') {
        $Call = F::Run(null, 'POST', $Call);
    }
    $Call = F::Hook('afterAllowDo', $Call);
    return $Call;
});
setFn('GET', function ($Call) {
    $Call = F::Hook('beforeAllowGet', $Call);
    $Call = F::Apply('Entity.List', 'Do', $Call, ['Context' => 'app']);
    $Call['Context'] = '';
    $Call = F::Hook('afterAllowGet', $Call);
    return $Call;
});
setFn('POST', function ($Call) {
    $Call = F::Hook('beforeAllowPost', $Call);
    $Call['Data'] = F::Run('Entity', 'Update', $Call, ['Data!' => ['Status' => 1, 'Moderated' => F::Run('System.Time', 'Get', $Call), 'Moderator' => $Call['Session']['User']['ID']]]);
    $Call = F::Hook('afterAllowPost', $Call);
    return $Call;
});
Exemplo n.º 21
0
<?php

/* Codeine
 * @author bergstein@trickyplan.com
 * @description  
 * @package Codeine
 * @version 8.x
 */
setFn('Do', function ($Call) {
    $Call = F::Run('Entity', 'Load', $Call);
    $Call = F::Hook('beforeEntityGo', $Call);
    $Call['Data'] = F::Run('Entity', 'Read', $Call);
    $Call = F::Run('System.Interface.HTTP', 'Remote Redirect', $Call, ['Redirect' => $Call['Data']['URL']]);
    $Call = F::Hook('afterEntityGo', $Call);
    return $Call;
});
Exemplo n.º 22
0
    if (empty($Call['Where']['ID'])) {
        $Call['Result'] = false;
    } else {
        foreach ($Call['Where']['ID'] as $ID) {
            $Filename = F::findFile($Call['Link'] . DS . $ID);
            $Call['Result'] = F::file_exists($Filename);
        }
    }
    $Call = F::Hook('afterFileSystemOperation', $Call);
    return $Call['Result'];
});
setFn('Status', function ($Call) {
    $Call = F::Hook('beforeFileSystemOperation', $Call);
    $ic = 0;
    $Directory = new RecursiveDirectoryIterator(Root . '/' . $Call['Path']);
    $Iterator = new RecursiveIteratorIterator($Directory);
    $Regex = new RegexIterator($Iterator, '/' . $Call['Prefix'] . '(.+)' . $Call['Postfix'] . '$/i', RecursiveRegexIterator::GET_MATCH);
    foreach ($Regex as $File) {
        $ic++;
    }
    $Call = F::Hook('afterFileSystemOperation', $Call);
    return [['Files', $ic]];
});
setFn('Size', function ($Call) {
    $Call = F::Hook('beforeFileSystemOperation', $Call);
    chdir(Root);
    $Output = shell_exec('du --max-depth=0 -h ' . $Call['Directory']);
    list($Size, ) = explode("\t", $Output);
    $Call = F::Hook('afterFileSystemOperation', $Call);
    return $Size;
});
Exemplo n.º 23
0
        for ($SI = 1; $SI <= $IndexesCount; $SI++) {
            $Call['Sitemap Indexes'][] = $Call['HTTP']['Proto'] . $Call['HTTP']['Host'] . '/sitemap/' . $Name . '-' . $SI . '.xml';
            $Call['Output']['Content'][] = ['sitemap' => ['loc' => $Call['HTTP']['Proto'] . $Call['HTTP']['Host'] . '/sitemap/' . $Name . '-' . $SI . '.xml']];
        }
    }
    return $Call;
});
setFn('Show Sitemap Index', function ($Call) {
    $Call = F::Hook('beforeSitemapIndexShow', $Call);
    $Call['Output'] = ['Root' => 'sitemapindex', 'Content' => []];
    $Handler = $Call['Sitemap']['Handlers'][$Call['Index']];
    $Call = F::Apply($Handler['Driver'], null, $Call, $Handler);
    $Call = F::Hook('afterSitemapIndexShow', $Call);
    return $Call;
});
setFn('Sitemap', function ($Call) {
    $Call = F::Hook('beforeSitemapShow', $Call);
    $Call['Output'] = ['Root' => 'urlset', 'Content' => []];
    $Handler = $Call['Sitemap']['Handlers'][$Call['Index']];
    $Call = F::Apply($Handler['Driver'], null, $Call, $Handler);
    $Call = F::Hook('afterSitemapShow', $Call);
    return $Call;
});
setFn('Sitemaps.Generate', function ($Call) {
    $Call = F::Hook('beforeSitemapShow', $Call);
    $Call['Output'] = ['Root' => 'urlset', 'Content' => []];
    $Handler = $Call['Sitemap']['Handlers'][$Call['Index']];
    $Call = F::Apply($Handler['Driver'], null, $Call, $Handler);
    $Call = F::Hook('afterSitemapShow', $Call);
    return $Call;
});
Exemplo n.º 24
0
<?php

/* Codeine
 * @author bergstein@trickyplan.com
 * @description  
 * @package Codeine
 * @version 8.x
 */
setFn('Check', function ($Call) {
    $Invite = F::Run('Entity', 'Read', ['Entity' => 'Invite', 'Where' => $Call['Request']['Invite']])[0];
    if (null === $Invite) {
        $Call = F::Hook('InviteNotExist', $Call);
    } else {
        if ($Invite['Active']) {
            F::Run('Entity', 'Update', ['Entity' => 'Invite', 'Where' => $Call['Request']['Invite'], 'Data' => ['Active' => 0]]);
        } else {
            $Call = F::Hook('InviteAlreadyUsed', $Call);
        }
    }
    return $Call;
});
Exemplo n.º 25
0
<?php

/* Codeine
 * @author bergstein@trickyplan.com
 * @description  
 * @package Codeine
 * @version 8.x
 */
setFn('Length', function ($Call) {
    if (isset($Call['View']['HTML']['Title']) && is_string($Call['View']['HTML']['Title'])) {
        $Length = mb_strlen($Call['View']['HTML']['Title']);
        if ($Length > $Call['SEO']['Audit']['Title']['Length']['Maximum']) {
            $Call = F::Hook('SEO.Audit.Title.TooLong', $Call);
            F::Log('SEO Title is too long *' . $Length . ' chars* over *' . $Call['SEO']['Audit']['Title']['Length']['Maximum'] . '*', LOG_WARNING, 'Marketing');
        } elseif ($Length < $Call['SEO']['Audit']['Title']['Length']['Minimum']) {
            $Call = F::Hook('SEO.Audit.Title.TooShort', $Call);
            F::Log('SEO Title is too short *' . $Length . ' chars* over *' . $Call['SEO']['Audit']['Title']['Length']['Minimum'] . '*', LOG_WARNING, 'Marketing');
        } else {
            F::Log('SEO Title length is optimal ', LOG_NOTICE, 'Marketing');
        }
    }
    return $Call;
});
Exemplo n.º 26
0
    $Call['IX'] = 0;
    while ($Call['Live']) {
        $Call['URL'] = array_shift($Call['URLs']);
        F::Log('URL: ' . $Call['Host'] . $Call['URL'] . ' selected', LOG_WARNING);
        $Call = F::Run(null, 'Fetch', $Call);
        $URLs = F::Run(null, 'Get Links', $Call);
        $Call['Processed'][] = $Call['URL'];
        foreach ($URLs as $cURL) {
            $Links[$Call['URL']][$cURL] = $cURL;
        }
        $Call['URLs'] = array_merge($Call['URLs'], $URLs);
        $Call['URLs'] = array_unique($Call['URLs']);
        F::Log(count($Call['URLs']) . ' URLs queued', LOG_WARNING);
        F::Log(count($Call['Processed']) . ' URLs processed', LOG_WARNING);
        if (count($Call['URLs']) == 0 or count($Links) > 200) {
            break;
        }
        F::Run('IO', 'Write', ['Storage' => 'Scraped', 'Where' => ['ID' => strtr($Call['URL'], '/', '_')], 'Data' => $Call['Body']]);
        $Call['IX']++;
    }
    return $Call;
});
setFn('Fetch', function ($Call) {
    F::Log('Fetching ' . $Call['URL'], LOG_WARNING);
    $Call = F::Hook('beforeFetch', $Call);
    $Result = F::Run('IO', 'Read', ['Storage' => 'Web', 'Where' => $Call['Host'] . $Call['URL']]);
    $Call['Body'] = array_pop($Result);
    $Call = F::Hook('afterFetch', $Call);
    F::Log('Fetched ' . strlen($Call['Body']), LOG_WARNING);
    return $Call;
});
Exemplo n.º 27
0
<?php

/* Codeine
 * @author bergstein@trickyplan.com
 * @description  
 * @package Codeine
 * @version 8.x
 */
setFn('Do', function ($Call) {
    $Call = F::Hook('beforeIncreaseDo', $Call);
    $Call = F::Run('Entity', 'Load', $Call);
    if (isset($Call['Nodes'][$Call['Key']]['Widgets']['Write']) or isset($Call['Nodes'][$Call['Key']]['Widgets']['Update'])) {
        $Data = F::Run('Entity', 'Read', $Call, ['One' => true]);
        $Data = F::Dot($Data, $Call['Key'], F::Dot($Data, $Call['Key']) + $Call['Value']);
        F::Run('Entity', 'Update', $Call, ['Data' => $Data]);
        $Call['Output']['Content'][] = 'OK';
    }
    $Call = F::Hook('afterIncreaseDo', $Call);
    return $Call;
});
Exemplo n.º 28
0
        $Call['Data'] = ['Value' => $Call['Data']];
    }
    if ($Call['Value'] !== null) {
        $Call = F::Hook('afterViewLoad', $Call);
    }
    return $Call['Value'];
});
setFn('Render', function ($Call) {
    $Call = F::Hook('beforeRender', $Call);
    $Call['Environment'] = self::$_Environment;
    if (isset($Call['View']['Renderer'])) {
        F::Log('Start ' . $Call['View']['Renderer']['Service'] . ' Rendering', LOG_NOTICE);
        $Call = F::Live($Call['View']['Renderer'], $Call);
        F::Log('Finish ' . $Call['View']['Renderer']['Service'] . ' Rendering', LOG_NOTICE);
    }
    return F::Hook('afterRender', $Call);
});
setFn('Asset.Route', function ($Call) {
    if (strpos($Call['Value'], ':') !== false) {
        list($Scope, $ID) = explode(':', $Call['Value']);
        if (isset($Call['Scope']) && $Scope != '') {
            $Scope .= '/' . $Call['Scope'];
        }
    } else {
        $Scope = $Call['Value'];
        $ID = $Scope;
        if (isset($Call['Scope']) && $Scope != '') {
            $Scope .= '/' . $Call['Scope'];
        }
    }
    return [$Scope, $ID];
Exemplo n.º 29
0
/* Codeine
 * @author bergstein@trickyplan.com
 * @description: Фронт контроллер
 * @package Codeine
 * @version 8.x
 * @date 31.08.11
 * @time 1:12
 */
setFn('Run', function ($Call) {
    // В этом месте, практически всегда, происходит роутинг.
    $Call = F::Hook('beforeFrontRun', $Call);
    // Если передан нормальный вызов, совершаем его
    F::Log('Front Controlled *' . $Call['Service'] . ':' . $Call['Method'] . '* started', LOG_NOTICE);
    if (F::Dot($Call, 'Skip Front')) {
        F::Log('Front Skip Enabled', LOG_NOTICE);
    } else {
        if (F::isCall($Call['Run'])) {
            if (!isset($Call['Run']['Method'])) {
                $Call['Run']['Method'] = 'Do';
            }
            list($Call['Service'], $Call['Method']) = [$Call['Run']['Service'], $Call['Run']['Method']];
            if (isset($Call['Run']['Call'])) {
                F::Log($Call['Run']['Call'], LOG_INFO);
            }
            $Call = F::Live($Call['Run'], $Call);
        }
    }
    // А здесь - рендеринг
    $Call = F::Hook('afterFrontRun', $Call);
    return $Call;
});
Exemplo n.º 30
0
<?php

/* Codeine
 * @author bergstein@trickyplan.com
 * @description  
 * @package Codeine
 * @version 8.x
 */
setFn('Do', function ($Call) {
    $Call = F::Apply('Entity', 'Load', $Call);
    if (isset($Call['Where'])) {
        $Call['Where'] = F::Live($Call['Where'], $Call);
    }
    $Call = F::Hook('beforeCount', $Call);
    $Call['Count'] = F::Run('Entity', 'Count', $Call);
    $Call = F::Hook('afterCount', $Call);
    return $Call['Count'];
});