/**
  * @param $arguments
  * @return object
  * @throws \Exception
  */
 public function callController($arguments)
 {
     $params = [];
     /*
     | Check if whether user trying to access module
     | If module we will setup module configuration
     | or else setup default MVC configurations
     */
     if (string_has($arguments[0], '::')) {
         $exp = string_split($arguments[0], '::');
         $this->setModuleConfiguration($exp);
     } else {
         $this->setUpControllerAndMethodName($arguments);
     }
     if (isset($arguments[1])) {
         $params = $arguments[1];
     }
     $file = CYGNITE_BASE . str_replace('\\', DS, '\\src' . $this->controllerWithNS) . EXT;
     if (!is_readable($file)) {
         throw new \Exception("Route class " . $this->controllerWithNS . " not found. ");
     }
     $args = [];
     $args = !is_array($params) ? [$params] : $params;
     /*
     | Get the instance of controller from Cygnite Container
     | and inject all dependencies into controller dynamically.
     | It's cool! You can write powerful rest api using restful
     | routing
     */
     return $this->handleControllerDependencies($this->controllerWithNS, $this->method, $args);
 }
Beispiel #2
0
 /**
  * Execute the command.
  *
  * @return int|null|void
  */
 public function process()
 {
     // Migrate init - to create migration table
     $name = $this->argument('name');
     if (!is_null($name)) {
         if (string_has($name, ',')) {
             $this->seeder()->executeOnly($name);
         } else {
             $this->seeder()->executeOnly($name);
         }
     }
     $this->seeder()->run();
     $this->info('Seeding Completed Successfully!');
 }
Beispiel #3
0
 /**
  * We will check whether event is registered,
  * if so we will trigger the event.
  *
  * @param       $name
  * @param array $data
  * @throws \Exception
  * @return mixed
  */
 public function trigger($name, $data = [])
 {
     if (!isset($this->events[$name])) {
         throw new \Exception("Event '{$name}' not found in " . __CLASS__ . " in stack!");
     }
     foreach ($this->events[$name] as $callback) {
         switch ($callback) {
             case is_object($callback) && $callback instanceof Closure:
                 return $callback($name, $data);
                 break;
             case string_has($callback, '@'):
                 return $this->callFunction($callback, $data);
                 break;
             case string_has($callback, '::'):
                 return $this->callUserFunctionEvent($callback);
                 break;
             case is_string($callback) && !string_has($callback, '@'):
                 call_user_func($callback, $data);
                 break;
         }
     }
 }
Beispiel #4
0
function print_mail_dir($location)
{
    global $auth_zid;
    print_header($location, array("Compose"), array("mail-compose"), array("/mail/compose"));
    writeln('<table class="fill">');
    writeln('<tr>');
    writeln('<td style="vertical-align: top">');
    beg_tab();
    writeln('	<tr>');
    writeln('		<td><a href="/mail/" class="icon_16" style="background-image: url(/images/inbox-16.png)">Inbox</a></td>');
    writeln('	</tr>');
    writeln('	<tr>');
    writeln('		<td><a href="/mail/sent" class="icon_16" style="background-image: url(/images/sent-16.png)">Sent</a></td>');
    writeln('	</tr>');
    writeln('	<tr>');
    writeln('		<td><a href="/mail/junk" class="icon_16" style="background-image: url(/images/junk-16.png)">Junk</a></td>');
    writeln('	</tr>');
    writeln('	<tr>');
    writeln('		<td><a href="/mail/trash" class="icon_16" style="background-image: url(/images/trash-16.png)">Trash</a></td>');
    writeln('	</tr>');
    end_tab();
    writeln('</td>');
    writeln('<td class="fill" style="padding-left: 8px">');
    beg_tab();
    $list = db_get_list("mail", "received_time", array("zid" => $auth_zid, "location" => $location));
    $keys = array_keys($list);
    if (count($list) == 0) {
        writeln('<tr><td>(no messages)</td></tr>');
    }
    for ($i = 0; $i < count($list); $i++) {
        $message = $list[$keys[$i]];
        if ($location == "Sent") {
            $address = parse_mail_address($message["rcpt_to"]);
        } else {
            $address = parse_mail_address($message["mail_from"]);
        }
        if ($message["subject"] == "") {
            $subject = "(no subject)";
        } else {
            $subject = $message["subject"];
        }
        writeln('	<tr>');
        writeln('		<td><a href="view?mid=' . $message["mail_id"] . '" class="icon_16" style="background-image: url(/images/mail-16.png)">' . $message["subject"] . '</a></td>');
        if (string_has($address["email"], "no-reply@")) {
            writeln('		<td class="center">' . $address["email"] . '</td>');
        } else {
            writeln('		<td class="center"><a href="compose?to=' . $address["email"] . '">' . $address["email"] . '</a></td>');
        }
        writeln('		<td class="right">' . date("Y-m-d H:i", $message["received_time"]) . '</td>');
        writeln('	</tr>');
    }
    end_tab();
    writeln('</td>');
    writeln('</tr>');
    writeln('</table>');
    if (count($list) > 0) {
        writeln('<form method="post">');
        if ($location == "Junk" || $location == "Trash") {
            right_box("Empty");
        } else {
            right_box("Delete All");
        }
        writeln('</form>');
    }
    print_footer();
}
Beispiel #5
0
 /**
  * We will combine all assets tagged to the given key
  * and make a final file which will contain all asset
  * source.
  *
  * $asset->add('style', array('path' => ''))
  *       ->add('style', array('path' => ''))
  *       ->combine('style', 'final_css', 'assets/css/final.css');
  *
  * @param      $name
  * @param      $path
  * @param      $file
  * @param bool $compress
  *
  * @return $this
  */
 public function combine($name, $path, $file, $compress = false)
 {
     $this->combine = true;
     if (file_exists(CYGNITE_BASE . DS . $path . $file)) {
         $cssAsset = file_get_contents(CYGNITE_BASE . DS . $path . $file);
         if (string_has($cssAsset, '@generator')) {
             return $this;
         }
     }
     $filePointer = fopen(CYGNITE_BASE . DS . $path . $file, 'w') or die('Please set folder ' . CYGNITE_BASE . DS . $path . $file . ' permission to 777.');
     $content = "\n        /**\n\n         | Import All CSS Assets here \n\n         | @generator Cygnite AssetManager\n\n         */\n\n";
     foreach ($this->paths[$this->tag[$this->where]][$name] as $key => $src) {
         if ($name == 'style') {
             $content .= $this->combineStylesheets($src, $compress);
         } elseif ($name == 'script') {
             $content .= $this->combineScripts($src, $compress);
         }
     }
     fwrite($filePointer, $content);
     $content = '';
     fclose($filePointer);
     $assetName = trim($this->getNameFromPathInfo($file));
     $styleTag = '';
     $styleTag = static::$stylesheet . ' title="' . $file . '" href="' . $this->getBaseUrl() . $path . $file . '" >' . PHP_EOL;
     $this->combinedAssets[$this->tag[$this->where]][$name . '.' . $assetName][] = (string) $styleTag;
     return $this;
 }
Beispiel #6
0
//
// Pipecode is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Pipecode is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Pipecode.  If not, see <http://www.gnu.org/licenses/>.
//
print_header("Icons");
writeln('<table class="fill">');
writeln('<tr>');
writeln('<td>');
$a = fs_dir("{$doc_root}/images");
for ($i = 0; $i < count($a); $i++) {
    if (fs_ext($a[$i]) == "png" && string_has($a[$i], "-64")) {
        writeln('<div class="topic_box">');
        writeln('	<img src="/images/' . $a[$i] . '"/>');
        writeln('	' . substr($a[$i], 0, -7));
        writeln('</div>');
    }
}
writeln('</td>');
writeln('</tr>');
writeln('</table>');
print_footer();
Beispiel #7
0
//$link[] = "/mail/mark?mid=$mail_id";
//}
//if ($message["location"] == "Trash") {
//$name[] = "Delete";
//$icon[] = "shred";
//$link[] = "/mail/delete?mid=$mail_id";
//} else {
//	$name[] = "Delete";
//	$icon[] = "delete";
//	$link[] = "/mail/delete?mid=$mail_id";
//}
//$name[] = "Inbox";
//$icon[] = "inbox";
//$link[] = "/mail/";
//print_header($message["subject"], $name, $icon, $link);
if (string_has($message["mail_from"], "no-reply@")) {
    print_header($message["subject"], array("Inbox"), array("inbox"), array("/mail/"));
} else {
    print_header($message["subject"], array("Reply", "Inbox"), array("mail-reply", "inbox"), array("/mail/compose?mid={$mail_id}", "/mail/"));
}
beg_tab();
writeln('	<tr>');
writeln('		<td style="width: 140px">From:</td>');
writeln('		<td>' . htmlentities($message["mail_from"]) . '</td>');
writeln('	</tr>');
writeln('	<tr>');
writeln('		<td style="width: 140px">Subject:</td>');
writeln('		<td>' . htmlentities($message["subject"]) . '</td>');
writeln('	</tr>');
writeln('	<tr>');
writeln('		<td style="width: 140px">To:</td>');
Beispiel #8
0
function right_box($buttons, $style = "")
{
    if ($style == "") {
        writeln('<div class="right_box">');
    } else {
        writeln('<div class="right_box" style="' . $style . '">');
    }
    if (string_has($buttons, "<")) {
        writeln($buttons);
    } else {
        $a = explode(",", $buttons);
        for ($i = 0; $i < count($a); $i++) {
            $value = trim($a[$i]);
            $name = strtolower($value);
            $name = str_replace(" ", "_", $name);
            writeln('<input type="submit" name="' . $name . '" value="' . $value . '"/>');
        }
    }
    writeln('</div>');
}
Beispiel #9
0
 /**
  * Set up widget view path
  * @return string
  */
 protected function setupWidget()
 {
     /*
     | If widget not belongs to HMVC modules and
     | has ":" in the view name, we will convert name as path
     */
     if (string_has($this->getWidgetName(), ':')) {
         $widget = null;
         $widget = str_replace(':', DS, $this->getWidgetName());
         return $this->getWidgetPath($widget);
     }
 }
Beispiel #10
0
 /**
  * Method to compile a simple column separated value for HAVING clause.
  * If column passed as array, we will add condition for each column.
  *
  * @param $type
  * @param $column
  * @param $separator
  * @param $value
  *
  * @return $this
  */
 protected function addCondition($type, $column, $separator, $value)
 {
     $multiple = is_array($column) ? $column : [$column => $value];
     foreach ($multiple as $key => $val) {
         // Add the table name in case of ambiguous columns
         if (count($this->joinSources) > 0 && string_has($key, '.')) {
             $table = !is_null($this->tableAlias) ? $this->tableAlias : $this->formTable;
             $key = "{$table}.{$key}";
         }
         $key = $this->quoteIdentifier($key);
         $this->bindCondition($type, "{$key} {$separator} ?", $val);
     }
     return $this;
 }
Beispiel #11
0
 /**
  * Returns Translator of a string. If no Translator exists, the original
  * string will be returned.
  *
  * trans('Hello, :user', array(':user' => $username));
  * $hello = $trans->get('welcome.Hello friends, my name is :name');
  *
  * @param      $key to translate
  * @param null $locale target language
  * @return  string
  */
 public function get($key, $locale = null)
 {
     if (!$locale) {
         // Use the global target language
         $locale = $this->locale();
     }
     if (string_has($key, '.')) {
         $exp = string_split($key);
         // Load the translation table for this language
         $translator = $this->load($locale . '-' . $exp[0]);
         // Return the translated string if it exists
         return isset($translator[$exp[1]]) ? $translator[$exp[1]] : $key;
     }
     // Load the Translator array for this language
     $translator = $this->load($locale);
     // Return the translated string if it exists
     return isset($translator[$key]) ? $translator[$key] : $key;
 }
Beispiel #12
0
 }
 $reserved_usernames = array("admin", "administrator", "anonymous", "blog", "bugs", "code", "donate", "feed", "feedback", "forum", "git", "img", "legal", "list", "lists", "mail", "pipe", "pipecode", "pipedot", "pipeline", "root", "scm", "ssladmin", "wiki");
 if (in_array($luser, $reserved_usernames)) {
     die("username is reserved [{$username}]");
 }
 if ($mail_1 != $mail_2) {
     die("email addresses do not match [{$mail_1}] [{$mail_2}]");
 }
 $a = explode("@", $mail_1);
 if (count($a) != 2) {
     die("invalid email address [{$mail_1}]");
 }
 if (strlen($a[0]) == 0) {
     die("invalid username in email address [{$mail_1}]");
 }
 if (strlen($a[1]) < 3 || !string_has($a[1], ".")) {
     die("invalid domain in email address [{$mail_1}]");
 }
 if (is_local_user("{$luser}@{$server_name}")) {
     die("username already exists [{$username}]");
 }
 if (!captcha_verify($answer)) {
     die("captcha failed");
 }
 print_header("Email Sent");
 writeln('<h1>Email Sent</h1>');
 writeln('<p>Please visit the link in the email within 3 days to activate your account.</p>');
 print_footer();
 $ip = $_SERVER["REMOTE_ADDR"];
 $hash = crypt_sha256(rand());
 $email_challenge = array();
 private function overwriteBlueScreenStyle($path)
 {
     $vendor = CYGNITE_BASE . DS . 'vendor';
     $stylePath = Config::get('global.config', 'bluescreen.style');
     $screenPath = $vendor . DS . str_replace('.', DS, $stylePath) . DS . "bluescreen.css";
     if (!file_exists($screenPath)) {
         throw new Exception("Tracy debugger bluescreen.css not found inside vendor directory");
     }
     $blueScreen = file_get_contents($screenPath);
     $pretty = file_get_contents($path . self::$style . '.css');
     $blueScreen = (string) $blueScreen . "\n" . $pretty;
     if (!string_has($blueScreen, '@Author:Cygnite')) {
         file_put_contents($blueScreen);
     }
 }
Beispiel #14
0
 /**
  * @param $arguments
  * @return object
  * @throws \Exception
  */
 private function callController($arguments)
 {
     $params = array();
     $this->setUpControllerAndMethodName($arguments);
     // Check if whether user trying to access module
     if (string_has($arguments[0], '::')) {
         $exp = string_split($arguments[0], '::');
         $this->setModuleConfiguration($exp);
     }
     if (isset($arguments[1])) {
         $params = $arguments[1];
     }
     $file = CYGNITE_BASE . str_replace('\\', DS, $this->controllerWithNS) . EXT;
     if (!is_readable($file)) {
         throw new \Exception("Route " . $this->controllerWithNS . " not found. ");
     }
     $me = $this;
     // Get the instance of controller from Cygnite Container
     // and inject all dependencies into controller dynamically
     // It's cool. You can write powerful rest api using restful
     // routing
     return App::instance(function ($app) use($me, $params) {
         // make and return instance of controller
         $instance = $app->make($me->controllerWithNS);
         // inject all properties of controller defined in definition
         $app->propertyInjection($instance, $me->controllerWithNS);
         $args = array();
         $args = !is_array($params) ? array($params) : $params;
         return call_user_func_array(array($instance, $me->method), $args);
     });
 }
Beispiel #15
0
 public function skip()
 {
     if (string_has($this->except, '.')) {
         $arr = explode('.', $this->except);
         foreach ($arr as $key => $value) {
             unset($this->request['post'][$value]);
         }
     } else {
         unset($this->request['post'][$this->except]);
     }
 }
Beispiel #16
0
 private function _select($column)
 {
     if ($column === 'all' || $column == '*') {
         $this->_selectColumns = $this->quoteIdentifier(self::cyrus()->getTableName()) . '.*';
     } else {
         if (string_has($column, 'as') || string_has($column, 'AS')) {
             return $this->selectExpr($column);
         }
         $this->_selectColumns = (string) str_replace(' ', '', $this->quoteIdentifier(explode(',', $column)));
     }
     return $this;
 }
Beispiel #17
0
 public static function callFinderBy($method, $class, $arguments, $type = 'And')
 {
     if (string_has($method, $type)) {
         $query = static::$ar->query()->buildFindersWhereCondition($method, $arguments, $type);
         return $query->findAll();
     }
 }
Beispiel #18
0
 /**
  * Returns Translator of a string. If no Translator exists, the original
  * string will be returned.
  *
  * trans('Hello, :user', array(':user' => $username));
  * $hello = $trans->get('welcome.Hello friends, my name is :name');
  *
  * @param      $key    to translate
  * @param null $locale target language
  *
  * @return string
  */
 public function get($key, $locale = null)
 {
     if (!$locale) {
         // Use the global target language
         $locale = $this->locale();
     }
     if (string_has($key, ':')) {
         $exp = string_split($key, ':');
         // Load the translation table for this language
         $translator = $this->load($locale . '-' . $exp[0]);
         unset($exp[0]);
         $string = ArrayAccessor::make($translator, function ($a) use($exp) {
             return $a->toString(implode('.', $exp));
         });
         // Return the translated string if it exists
         return !is_null($string) ? $string : $key;
     }
     // Load the Translator array for this language
     $translator = $this->load($locale);
     // Return the translated string if it exists
     return isset($translator[$key]) ? $translator[$key] : $key;
 }
Beispiel #19
0
 /**
  * @param array $middlewares
  *
  * @return array
  */
 protected function parseMiddlewareToPipelines(array $middlewares)
 {
     $pipes = [];
     // check all types and store value into pipes array
     foreach ($middlewares as $middleware) {
         if (is_object($middleware)) {
             $pipes[] = $middleware;
         } elseif (string_has($middleware, ':')) {
             $pipes[] = $middleware;
         } else {
             $pipes[] = $this->app->make($middleware);
         }
     }
     return $pipes;
 }
Beispiel #20
0
 /**
  * We will replace dot / slash(/) to directory separator
  *
  * @param $string
  * @return string
  */
 function toPath($string)
 {
     switch ($string) {
         case string_has($string, '.'):
             $string = str_replace('.', DS, $string);
             break;
         case string_has($string, '/'):
             $string = str_replace('/', DS, $string);
             break;
     }
     return $string;
 }
Beispiel #21
0
function str_replace_all($search, $replacement, $source)
{
    while (string_has($source, $search)) {
        $source = str_replace($search, $replacement, $source);
    }
    return $source;
}
Beispiel #22
0
 /**
  * @param $pattern
  * @return bool|mixed
  */
 public function hasNamedPattern($pattern)
 {
     return string_has($pattern, '{:') ? $this->replace($pattern) : false;
 }
Beispiel #23
0
function clean_html($html)
{
    $clean = "";
    $pre = 0;
    $html = clean_unicode($html);
    for ($i = 0; $i < mb_strlen($html); $i++) {
        //$c = substr($html, $i, 1);
        $c = mb_substr($html, $i, 1);
        if ($c == "<") {
            $s = "";
            for ($i = $i + 1; $i < mb_strlen($html); $i++) {
                //$c = substr($html, $i, 1);
                $c = mb_substr($html, $i, 1);
                if ($c == ">") {
                    break;
                }
                $s .= $c;
            }
            $tag = clean_tag($s);
            if ($tag == "<pre>") {
                $pre++;
            } else {
                if ($tag == "</pre>") {
                    $pre--;
                }
            }
            $clean .= $tag;
        } else {
            //if ($pre > 0 && $c == "\n") {
            //	$clean .= "<br/>";
            //} else {
            $clean .= $c;
            //}
        }
    }
    $clean = str_replace("\t", " ", $clean);
    $clean = str_replace("\n", " ", $clean);
    $clean = str_replace("\r", " ", $clean);
    while (string_has($clean, "  ")) {
        $clean = str_replace("  ", " ", $clean);
    }
    $clean = str_replace("> ", ">", $clean);
    $clean = str_replace(" <", "<", $clean);
    $clean = str_replace("FORCEWHITESPACE", " ", $clean);
    $clean = trim($clean);
    $clean = str_replace_all("  ", " ", $clean);
    $clean = str_replace_all("<br/><br/><br/>", "<br/><br/>", $clean);
    //	print "clean [$clean]";
    //	$clean = str_replace("<pre><br/>", "<pre>", $clean);
    //	$clean = str_replace("<br/></pre>", "</pre>", $clean);
    //	$clean = str_replace("<li><br/>", "<li>", $clean);
    //	$clean = str_replace("<br/></li>", "</li>", $clean);
    //	$clean = str_replace("<ul><br/>", "<ul>", $clean);
    //	$clean = str_replace("<br/></ul>", "</ul>", $clean);
    //	$clean = str_replace("<ol><br/>", "<ol>", $clean);
    //	$clean = str_replace("<br/></ol>", "</ol>", $clean);
    //	print "clean2 [$clean]";
    $clean = clean_newlines("pre", $clean);
    $clean = clean_newlines("ol", $clean);
    $clean = clean_newlines("ul", $clean);
    $clean = clean_newlines("li", $clean);
    $clean = clean_newlines("blockquote", $clean);
    $clean = clean_entities($clean);
    $clean = make_clickable($clean);
    return $clean;
}
Beispiel #24
0
 /**
  * @param bool $isModule
  * @return null
  */
 public function render($isModule = false)
 {
     /*
     | In some case you may not want to write much code
     | in such case you have option to pass param into render
     | so that we will understand you are trying to invoke module view
     */
     if ($isModule) {
         $this->isModule($isModule);
     }
     /*
     | We will check if widget is cached, return if already cached
     */
     if ($this->has($this->widgetName)) {
         return $this->getWidget($this->widgetName);
     }
     $path = null;
     if ($this->module) {
         /*
         | If widget belongs to HMVC modules and
         | has ":" in the view name, we will think first param
         | as module name and second param as view name
         */
         if (string_has($this->widgetName, ':')) {
             $exp = array();
             $exp = explode(':', $this->widgetName);
             $moduleName = $exp[0];
             $view = $exp[1];
             $path = getcwd() . DS . APPPATH . DS . 'modules' . DS . $moduleName . DS . 'Views' . DS . $view . '.view' . EXT;
             $this->widgetName = null;
             $this->module = false;
         }
     } else {
         /*
         | If widget not belongs to HMVC modules and
         | has ":" in the view name, we will convert name as path
         */
         if (string_has($this->widgetName, ':')) {
             $widget = null;
             $widget = str_replace(':', DS, $this->widgetName);
             $path = getcwd() . DS . APPPATH . DS . 'views' . DS . $widget . '.view' . EXT;
         }
     }
     $output = (new Output($this->widgetName))->buffer($path, $this->data)->clean();
     $this->setWidget($this->widgetName, $output);
     return $this->getWidget($this->widgetName);
 }