예제 #1
0
 /**
  * Function: __construct
  * See Also:
  *     <Model::grab>
  */
 public function __construct($extension_id, $options = array())
 {
     if (!isset($extension_id) and empty($options)) {
         return;
     }
     $options["left_join"][] = array("table" => "versions", "where" => "extension_id = extensions.id");
     $options["select"][] = "extensions.*";
     $options["select"][] = "MAX(versions.created_at) AS last_update";
     $options["group"][] = "id";
     $options["order"] = array("__last_update DESC", "extensions.id DESC");
     parent::grab($this, $extension_id, $options);
     if ($this->no_results) {
         return false;
     }
     $this->textID = $this->url;
     $this->filtered = !isset($options["filter"]) or $options["filter"];
     $trigger = Trigger::current();
     if ($this->filtered) {
         if (!$this->user->group->can("code_in_extensions")) {
             $this->name = fix($this->name);
         }
         $trigger->filter($this->name, array("markup_title", "markup_extension_title"), $this);
     }
     $trigger->filter($this, "extension");
 }
예제 #2
0
파일: Version.php 프로젝트: vito/chyrp-site
 /**
  * Function: __construct
  * See Also:
  *     <Model::grab>
  */
 public function __construct($version_id, $options = array())
 {
     if (!isset($version_id) and empty($options)) {
         return;
     }
     $options["left_join"][] = array("table" => "notes", "where" => "version_id = versions.id");
     $options["select"][] = "versions.*";
     $options["select"][] = "COUNT(notes.id) AS note_count";
     $options["select"][] = "MAX(notes.created_at) AS last_note";
     $options["group"][] = "id";
     parent::grab($this, $version_id, $options);
     if ($this->no_results) {
         return false;
     }
     $this->compatible = array_map(array("Version", "numberfy"), (array) YAML::load($this->compatible));
     $this->tags = !empty($this->tags) ? YAML::load($this->tags) : array();
     $this->linked_tags = self::link_tags($this->tags);
     $this->filtered = !isset($options["filter"]) or $options["filter"];
     $trigger = Trigger::current();
     if ($this->filtered) {
         $this->description_unfiltered = $this->description;
         if (!$this->extension->user->group->can("code_in_extensions")) {
             $this->description = fix($this->description);
         }
         $trigger->filter($this->description, array("markup_text", "markup_version_text"), $this);
     }
     $trigger->filter($this, "version");
 }
예제 #3
0
파일: Ticket.php 프로젝트: vito/chyrp-site
 /**
  * Function: __construct
  * See Also:
  *     <Model::grab>
  */
 public function __construct($ticket_id, $options = array())
 {
     if (!isset($ticket_id) and empty($options)) {
         return;
     }
     $options["left_join"][] = array("table" => "revisions", "where" => "ticket_id = tickets.id");
     $options["select"][] = "tickets.*";
     $options["select"][] = "COUNT(revisions.id) AS revision_count";
     $options["select"][] = "MAX(revisions.created_at) AS last_revision";
     $options["select"][] = "MAX(revisions.updated_at) AS last_update";
     $options["group"][] = "id";
     parent::grab($this, $ticket_id, $options);
     if ($this->no_results) {
         return false;
     }
     $this->last_activity = max(array_map("strtotime", array($this->last_revision, $this->last_update, $this->created_at, $this->updated_at)));
     $this->done = in_array($this->state, array("resolved", "invalid", "declined"));
     $this->filtered = !isset($options["filter"]) or $options["filter"];
     $trigger = Trigger::current();
     if ($this->filtered) {
         if (!$this->user->group->can("code_in_revisions")) {
             $this->title = fix($this->title);
             $this->description = fix($this->description);
         }
         $trigger->filter($this->title, array("markup_title", "markup_ticket_title"), $this);
         $trigger->filter($this->description, array("markup_text", "markup_ticket_text"), $this);
     }
     $trigger->filter($this, "ticket");
 }
예제 #4
0
 static function __install()
 {
     $digest = MAIN_DIR . DIR . "digest.txt.php";
     $output = "<?php header(\"Status: 403\"); exit(\"Access denied.\"); ?>\n" . "MIME-Version: 1.0\r\n" . "Content-Type: multipart/digest; boundary=\"---correspondence---\"\r\n" . "\r\n---correspondence---\r\n";
     if (!file_exists($digest) and !@file_put_contents($digest, $output)) {
         error(__("Error"), _f("The digest file <em>%s</em> could not be created.", fix($digest), "mail_to_file"));
     }
 }
예제 #5
0
 public function test_create_queries_with_alternate_columns()
 {
     $fname = path('symmetric.csv');
     $this->assertTrue($this->csv->uses($fname));
     $columns = array('header_a', 'header_c');
     $res = $this->csv->createQueries('test_table', $columns);
     $this->assertEquals(fix('alternated_header_queries'), $res);
 }
예제 #6
0
파일: chat.php 프로젝트: eadz/chyrp
 public function format_dialogue($text, $post = null)
 {
     if (isset($post)) {
         $post->dialogue_unformatted = $text;
     }
     $split = explode("\n", $text);
     $return = '<ul class="dialogue">';
     $count = 0;
     $my_name = "";
     $links = array();
     foreach ($split as $line) {
         # Remove the timstamps
         $line = preg_replace("/[ ]?[\\[|\\(]?[0-9]{1,2}:[0-9]{2}(:[0-9]{2})?[ ]?(pm|am)?[\\]|\\)]?[ ]?/i", "", $line);
         preg_match("/(<?)(.+)(:|>)\\s*(.+)/i", $line, $matches);
         if (empty($matches)) {
             continue;
         }
         if (preg_match("/\\s*\\(([^\\)]+)\\)\$/", $matches[2], $attribution)) {
             if ($attribution[1] == "me") {
                 $my_name = $matches[2] = str_replace($attribution[0], "", $matches[2]);
             } else {
                 $matches[2] = str_replace($attribution[0], "", $matches[2]);
                 $links[$matches[2]] = $attribution[1];
             }
         }
         $link = oneof(@$links[$matches[2]], "");
         $me = $my_name == $matches[2] ? " me" : "";
         $username = $matches[1] . $matches[2] . $matches[3];
         $class = $count % 2 ? "even" : "odd";
         $return .= '<li class="' . $class . $me . '">';
         if (!empty($link)) {
             $return .= '<span class="label">' . $matches[1] . '<a href="' . $link . '">' . fix($matches[2], false) . '</a>' . $matches[3] . '</span> ' . $matches[4] . "\n";
         } else {
             $return .= '<span class="label">' . fix($username, false) . '</span> ' . $matches[4] . "\n";
         }
         $return .= '</li>';
         $count++;
     }
     $return .= "</ul>";
     # If they're previewing.
     if (!isset($post)) {
         $return = preg_replace("/(<li class=\"(even|odd) me\"><span class=\"label\">)(.+)(<\\/span> (.+)\n<\\/li>)/", "\\1<strong>\\3</strong>\\4", $return);
     }
     return $return;
 }
예제 #7
0
파일: Message.php 프로젝트: vito/chyrp-site
 /**
  * Function: __construct
  * See Also:
  *     <Model::grab>
  */
 public function __construct($message_id, $options = array())
 {
     if (!isset($message_id) and empty($options)) {
         return;
     }
     fallback($options["order"], array("created_at ASC", "id ASC"));
     parent::grab($this, $message_id, $options);
     if ($this->no_results) {
         return false;
     }
     $this->filtered = !isset($options["filter"]) or $options["filter"];
     $trigger = Trigger::current();
     if ($this->filtered) {
         if (!$this->user->group->can("code_in_messages")) {
             $this->body = fix($this->body);
         }
         $trigger->filter($this->body, array("markup_text", "markup_message_text"), $this);
     }
     $trigger->filter($this, "message");
 }
예제 #8
0
 /**
  * Function: __construct
  * See Also:
  *     <Model::grab>
  */
 public function __construct($revision_id, $options = array())
 {
     if (!isset($revision_id) and empty($options)) {
         return;
     }
     parent::grab($this, $revision_id, $options);
     $options["order"] = "created_at ASC, id ASC";
     if ($this->no_results) {
         return false;
     }
     $this->changes = YAML::load($this->changes);
     $this->filtered = !isset($options["filter"]) or $options["filter"];
     $trigger = Trigger::current();
     if ($this->filtered) {
         if (!$this->user->group->can("code_in_revisions")) {
             $this->body = fix($this->body);
         }
         $trigger->filter($this->body, array("markup_text", "markup_revision_text"), $this);
     }
     $trigger->filter($this, "revision");
 }
예제 #9
0
파일: Admin.php 프로젝트: eadz/chyrp
 /**
  * Function: feathers
  * Feather enabling/disabling.
  */
 public function feathers()
 {
     if (!Visitor::current()->group->can("toggle_extensions")) {
         show_403(__("Access Denied"), __("You do not have sufficient privileges to enable/disable feathers."));
     }
     $config = Config::current();
     $this->context["enabled_feathers"] = $this->context["disabled_feathers"] = array();
     if (!($open = @opendir(FEATHERS_DIR))) {
         return Flash::warning(__("Could not read feathers directory."));
     }
     while (($folder = readdir($open)) !== false) {
         if (!file_exists(FEATHERS_DIR . "/" . $folder . "/" . $folder . ".php") or !file_exists(FEATHERS_DIR . "/" . $folder . "/info.yaml")) {
             continue;
         }
         if (file_exists(FEATHERS_DIR . "/" . $folder . "/locale/" . $config->locale . ".mo")) {
             load_translator($folder, FEATHERS_DIR . "/" . $folder . "/locale/" . $config->locale . ".mo");
         }
         $info = YAML::load(FEATHERS_DIR . "/" . $folder . "/info.yaml");
         fallback($info["name"], $folder);
         fallback($info["version"], "0");
         fallback($info["url"]);
         fallback($info["description"]);
         fallback($info["author"], array("name" => "", "url" => ""));
         fallback($info["help"]);
         $info["description"] = __($info["description"], $folder);
         $info["description"] = preg_replace("/<code>(.+)<\\/code>/se", "'<code>'.fix('\\1').'</code>'", $info["description"]);
         $info["description"] = preg_replace("/<pre>(.+)<\\/pre>/se", "'<pre>'.fix('\\1').'</pre>'", $info["description"]);
         $info["author"]["link"] = !empty($info["author"]["url"]) ? '<a href="' . fix($info["author"]["url"]) . '">' . fix($info["author"]["name"]) . '</a>' : $info["author"]["name"];
         $category = feather_enabled($folder) ? "enabled_feathers" : "disabled_feathers";
         $this->context[$category][$folder] = array("name" => $info["name"], "version" => $info["version"], "url" => $info["url"], "description" => $info["description"], "author" => $info["author"], "help" => $info["help"]);
     }
     $this->display("feathers");
 }
예제 #10
0
파일: helpers.php 프로젝트: homebru/bandb
/**
 * Function: arr2xml
 * Recursively adds an array (or object I guess) to a SimpleXML object.
 *
 * Parameters:
 *     &$object - The SimpleXML object to modify.
 *     $data - The data to add to the SimpleXML object.
 */
function arr2xml(&$object, $data)
{
    foreach ($data as $key => $val) {
        if (is_int($key) and (empty($val) or is_string($val) and trim($val) == "")) {
            unset($data[$key]);
            continue;
        }
        if (is_array($val)) {
            if (in_array(0, array_keys($val))) {
                # Numeric-indexed things need to be added as duplicates
                foreach ($val as $dup) {
                    $xml = $object->addChild($key);
                    arr2xml($xml, $dup);
                }
            } else {
                $xml = $object->addChild($key);
                arr2xml($xml, $val);
            }
        } else {
            $object->addChild($key, fix($val, false, false));
        }
    }
}
예제 #11
0
파일: Main.php 프로젝트: vito/chyrp-site
 /**
  * Function: search
  * Grabs the posts for a search query.
  */
 public function search()
 {
     fallback($_GET['query'], "");
     $config = Config::current();
     if ($config->clean_urls and substr_count($_SERVER['REQUEST_URI'], "?") and !substr_count($_SERVER['REQUEST_URI'], "%2F")) {
         # Searches with / and clean URLs = server 404
         redirect("search/" . urlencode($_GET['query']) . "/");
     }
     if (empty($_GET['query'])) {
         return Flash::warning(__("Please enter a search term."));
     }
     list($where, $params) = keywords($_GET['query'], "post_attributes.value LIKE :query OR url LIKE :query", "posts");
     $results = Post::find(array("placeholders" => true, "where" => $where, "params" => $params));
     $ids = array();
     foreach ($results[0] as $result) {
         $ids[] = $result["id"];
     }
     if (!empty($ids)) {
         $posts = new Paginator(Post::find(array("placeholders" => true, "where" => array("id" => $ids))), $this->post_limit);
     } else {
         $posts = new Paginator(array());
     }
     $this->display(array("pages/search", "pages/index"), array("posts" => $posts, "search" => $_GET['query']), fix(_f("Search results for \"%s\"", array($_GET['query']))));
 }
예제 #12
0
<?php

$iterator = new \CallbackFilterIterator(new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator(__DIR__ . '/../src/Bond/')), function (\SplFileInfo $file) {
    return $file->isFile() and $file->getExtension() === 'php';
});
foreach ($iterator as $file) {
    echo fix($file) ? "{$file->getRealPath()}\n" : '';
}
function fix($file)
{
    $contents = file_get_contents($file->getRealPath());
    // rtrim every line
    $string = implode("\n", array_map(function ($line) {
        return rtrim(str_replace("\t", "    ", $line));
    }, explode("\n", $contents)));
    $regex = '/\\v{3,}/m';
    file_put_contents($file->getRealPath(), preg_replace($regex, "\n\n", $string));
    return $contents !== $string;
}
예제 #13
0
파일: index.php 프로젝트: vito/chyrp-site
     $errors[] = __("Password cannot be blank.");
 }
 if ($settings['password_1'] != $settings['password_2']) {
     $errors[] = __("Passwords do not match.");
 }
 if (empty($settings['email'])) {
     $errors[] = __("E-Mail address cannot be blank.");
 }
 if (empty($errors)) {
     if (!$htaccess_has_chyrp) {
         if (!file_exists(MAIN_DIR . "/.htaccess")) {
             if (!@file_put_contents(MAIN_DIR . "/.htaccess", $htaccess)) {
                 $errors[] = _f("Could not generate .htaccess file. Clean URLs will not be available unless you create it and put this in it:\n<pre>%s</pre>", array(fix($htaccess)));
             }
         } elseif (!@file_put_contents(MAIN_DIR . "/.htaccess", "\n\n" . $htaccess, FILE_APPEND)) {
             $errors[] = _f("Could not generate .htaccess file. Clean URLs will not be available unless you create it and put this in it:\n<pre>%s</pre>", array(fix($htaccess)));
         }
     }
     $config->set("sql", array());
     $config->set("name", $settings['name']);
     $config->set("description", $settings['description']);
     $config->set("url", $url);
     $config->set("chyrp_url", $url);
     $config->set("feed_url", "");
     $config->set("email", $settings['email']);
     $config->set("locale", "en_US");
     $config->set("theme", "stardust");
     $config->set("posts_per_page", 5);
     $config->set("feed_items", 20);
     $config->set("clean_urls", false);
     $config->set("post_url", "(year)/(month)/(day)/(url)/");
예제 #14
0
파일: tags.php 프로젝트: vito/chyrp-site
 function feed_item($post)
 {
     $config = Config::current();
     foreach ($post->tags as $tag => $clean) {
         echo "        <category scheme=\"" . $config->url . "/tag/\" term=\"" . $clean . "\" label=\"" . fix($tag) . "\" />\n";
     }
 }
예제 #15
0
파일: Main.php 프로젝트: betsyzhang/chyrp
 /**
  * Function: register
  * Process registration. If registration is disabled or if the user is already logged in, it will error.
  */
 public function register()
 {
     $config = Config::current();
     if (!$config->can_register) {
         error(__("Registration Disabled"), __("I'm sorry, but this site is not allowing registration."));
     }
     if (logged_in()) {
         error(__("Error"), __("You're already logged in."));
     }
     if (!empty($_POST)) {
         if (empty($_POST['login'])) {
             Flash::warning(__("Please enter a username for your account."));
         } elseif (count(User::find(array("where" => array("login" => $_POST['login']))))) {
             Flash::warning(__("That username is already in use."));
         }
         if (empty($_POST['password1'])) {
             Flash::warning(__("Password cannot be blank."));
         } elseif ($_POST['password1'] != $_POST['password2']) {
             Flash::warning(__("Passwords do not match."));
         }
         if (empty($_POST['email'])) {
             Flash::warning(__("E-mail address cannot be blank."));
         } elseif (!preg_match("/^[_A-z0-9-]+((\\.|\\+)[_A-z0-9-]+)*@[A-z0-9-]+(\\.[A-z0-9-]+)*(\\.[A-z]{2,4})\$/", $_POST['email'])) {
             Flash::warning(__("Invalid e-mail address."));
         }
         if ($config->enable_recaptcha and !check_captcha()) {
             Flash::warning(__("Incorrect captcha code. Please try again."));
         }
         if (!Flash::exists("warning")) {
             if ($config->email_activation) {
                 $to = $_POST['email'];
                 $subject = _f($config->name . " Registration Pending");
                 $message = _f("Hello, " . fix($_POST['login']) . ".\n\nYou are receiving this message because you recently registered at " . $config->chyrp_url . "\nTo complete your registration, go to " . $config->chyrp_url . "/?action=validate&login="******"&token=" . sha1($_POST['login'] . $_POST['email']));
                 $headers = "From:" . $config->email . "\r\n" . "Reply-To:" . $config->email . "\r\n" . "X-Mailer: PHP/" . phpversion();
                 $user = User::add($_POST['login'], $_POST['password1'], $_POST['email'], "", "", 5, false);
                 $sent = email($to, $subject, $message, $headers);
                 if ($sent) {
                     Flash::notice(__("The email address you provided has been sent details to confirm registration."), "/");
                 } else {
                     Flash::notice(__("There was an error emailing the activation link to your email address."), "/");
                 }
             } else {
                 $user = User::add($_POST['login'], $_POST['password1'], $_POST['email']);
                 Trigger::current()->call("user_registered", $user);
                 $_SESSION['user_id'] = $user->id;
                 Flash::notice(__("Registration successful."), "/");
             }
         }
     }
     $this->display("forms/user/register", array(), __("Register"));
 }
예제 #16
0
파일: feed.php 프로젝트: relisher/chyrp
    ?>
" />
        <author>
            <name><?php 
    echo fix($author);
    ?>
</name>
<?php 
    if (!empty($post->user->website)) {
        ?>
            <uri><?php 
        echo fix($post->user->website);
        ?>
</uri>
<?php 
    }
    ?>
        </author>
        <content type="html"><?php 
    echo fix($post->feed_content());
    ?>
</content>
<?php 
    $trigger->call("feed_item", $post);
    ?>
    </entry>
<?php 
}
?>
</feed>
예제 #17
0
 public function admin_delete_milestone($admin)
 {
     if (!isset($_GET['id'])) {
         error(__("Error"), __("No milestone ID specified.", "progress"));
     }
     $milestone = new Milestone($_GET['id']);
     if ($milestone->no_results) {
         error(__("Error"), __("Invalid milestone ID specified.", "progress"));
     }
     if (!$milestone->deletable()) {
         show_403(__("Access Denied"), __("You do not have sufficient privileges to delete this milestone.", "progress"));
     }
     $admin->display("delete_milestone", array("milestone" => $milestone, "milestones" => Milestone::find(array("where" => array("id not" => $milestone->id)))), _f("Delete Milestone &#8220;%s&#8221;", array(fix($milestone->name)), "progress"));
 }
예제 #18
0
 public function test_must_use_headers_as_max_row_padding_when_headers_length_is_longer_than_all_rows_length()
 {
     $this->csv = new File_CSV_DataSource(path('longer_headers.csv'));
     $this->csv->symmetrize();
     $this->assertEquals(fix('longer_headers'), $this->csv->connect());
 }
예제 #19
0
function twig_escape_filter($string, $quotes = true, $decode = true)
{
    if (!is_string($string)) {
        # Certain post attributes might be parsed from YAML to an array,
        return $string;
    }
    # in which case the module provides a value. However, the attr
    # is still passed to the "fallback" and "fix" filters when editing.
    $safe = fix($string, $quotes);
    return $decode ? preg_replace("/&amp;(#?[A-Za-z0-9]+);/", "&\\1;", $safe) : $safe;
}
예제 #20
0
function replaceDim2($DimList, $DimName)
{
    $ZD = '';
    $splStr = '';
    $i = '';
    $s = '';
    $nMod = '';
    $nInt = '';
    $c = '';
    $replaceDim2 = $DimName;
    $ZD = 'abcdefghijklmnopqrstuvwxyz';
    $DimName = lCase($DimName);
    $splStr = aspSplit($DimList, ',');
    for ($i = 0; $i <= uBound($splStr); $i++) {
        $s = $splStr[$i];
        if ($s == $DimName) {
            $nMod = $i % len($ZD) + 1;
            $nInt = fix($i / len($ZD));
            if ($nMod != 0) {
                $c = $c . mid($ZD, $nMod, 1);
            }
            if ($nInt != 0) {
                $c = $c . copyStr(mid($ZD, $nInt, 1), $nInt);
            }
            //Call Echo(I,Len(ZD))
            //Call Echo("nMod",nMod)
            //Call Echo("nInt",nInt)
            //Call Echo("C",C)
            $replaceDim2 = $c;
            return @$replaceDim2;
        }
    }
    return @$replaceDim2;
}
예제 #21
0
파일: Theme.php 프로젝트: eadz/chyrp
 /**
  * Function: feeds
  * Outputs the Feed references.
  */
 public function feeds()
 {
     // Compute the URL of the per-page feed (if any):
     $config = Config::current();
     $request = $config->clean_urls ? rtrim(Route::current()->request, "/") : fix($_SERVER['REQUEST_URI']);
     $append = $config->clean_urls ? "/feed" : ((count($_GET) == 1 and Route::current()->action == "index") ? "/?feed" : "&amp;feed");
     $append .= $config->clean_urls ? "/" . urlencode($this->title) : "&amp;title=" . urlencode($this->title);
     # Create basic list of links (site and page Atom feeds):
     $feedurl = oneof(@$config->feed_url, url("feed"));
     $pagefeedurl = $config->url . $request . $append;
     $links = array(array("href" => $feedurl, "type" => "application/atom+xml", "title" => $config->name));
     if ($pagefeedurl != $feedurl) {
         $links[] = array("href" => $pagefeedurl, "type" => "application/atom+xml", "title" => "Current Page (if applicable)");
     }
     # Ask modules to pitch in by adding their own <link> tag items to $links.
     # Each item must be an array with "href" and "rel" properties (and optionally "title" and "type"):
     Trigger::current()->filter($links, "links");
     # Generate <link> tags:
     $tags = array();
     foreach ($links as $link) {
         $rel = oneof(@$link["rel"], "alternate");
         $href = $link["href"];
         $type = @$link["type"];
         $title = @$link["title"];
         $tag = '<link rel="' . $rel . '" href="' . $link["href"] . '"';
         if ($type) {
             $tag .= ' type="' . $type . '"';
         }
         if ($title) {
             $tag .= ' title="' . $title . '"';
         }
         $tags[] = $tag . ' />';
     }
     return implode("\n\t", $tags);
 }
예제 #22
0
$add_ten_to_two_numbers = $add_three_numbers(10);
var_dump($add_ten_to_two_numbers(1, 2));
// int(13)
$add_15_to_one_number = $add_ten_to_two_numbers(5);
var_dump($add_15_to_one_number(27));
// int(42)
//composition: (f.g)x == f(g(x))
$not_return_value = composition("doubleValue", "add5");
var_dump($not_return_value(1));
//int(12)
var_dump($not_return_value(0));
//int(10)
//fix: passes the function into it's self as the first parameter, allows resursive annoymous functions
$fib = fix(function ($fib, $n) {
    if ($n <= 0) {
        return 0;
    }
    if ($n <= 2) {
        return 1;
    }
    return $fib($fib, $n - 1) + $fib($fib, $n - 2);
});
//lazy_map: maps each element in the array to the function (like array_map). Outputted value is only evaluated on demand
$lazy_map = lazy_map($fib, array(2, 5, 100000, 10));
var_dump($lazy_map[0]);
//int(1)
var_dump($lazy_map[1]);
//int(5)
//$fib( 100000 ) is never evaluated, since we don't ask for it
var_dump($lazy_map[3]);
//int(55)
예제 #23
0
 public function test_symetrize_must_not_alter_symmetric_data()
 {
     $this->assertTrue($this->csv->uses(path('symmetric.csv')));
     $this->csv->symmetrize();
     $this->assertEquals(fix('symmetric_headers'), $this->csv->headers());
     $this->assertEquals(fix('symmetric_rows'), $this->csv->rows());
     $this->assertEquals(fix('symmetric_raw_data'), $this->csv->rawArray());
 }
예제 #24
0
파일: comments.php 프로젝트: relisher/chyrp
 public function posts_export($atom, $post)
 {
     $comments = Comment::find(array("where" => array("post_id" => $post->id)), array("filter" => false));
     foreach ($comments as $comment) {
         $updated = $comment->updated ? $comment->updated_at : $comment->created_at;
         $atom .= "       <chyrp:comment>\r";
         $atom .= '           <updated>' . when("c", $updated) . '</updated>' . "\r";
         $atom .= '           <published>' . when("c", $comment->created_at) . '</published>' . "\r";
         $atom .= '           <author chyrp:user_id="' . $comment->user_id . '">' . "\r";
         $atom .= "               <name>" . fix($comment->author) . "</name>\r";
         if (!empty($comment->author_url)) {
             $atom .= "               <uri>" . fix($comment->author_url) . "</uri>\r";
         }
         $atom .= "               <email>" . fix($comment->author_email) . "</email>\r";
         $atom .= "               <chyrp:login>" . fix(@$comment->user->login) . "</chyrp:login>\r";
         $atom .= "               <chyrp:ip>" . long2ip($comment->author_ip) . "</chyrp:ip>\r";
         $atom .= "               <chyrp:agent>" . fix($comment->author_agent) . "</chyrp:agent>\r";
         $atom .= "           </author>\r";
         $atom .= "           <content>" . fix($comment->body) . "</content>\r";
         foreach (array("status", "signature") as $attr) {
             $atom .= "           <chyrp:" . $attr . ">" . fix($comment->{$attr}) . "</chyrp:" . $attr . ">\r";
         }
         $atom .= "       </chyrp:comment>\r";
     }
     return $atom;
 }
예제 #25
0
        </p>
        <p>
            <label for="created_at"><?php 
echo __("Timestamp");
?>
</label>
            <input class="text" type="text" name="created_at" value="<?php 
echo when("F jS, Y H:i:s", $comment->created_at);
?>
" id="created_at" />
        </p>
        <div class="clear"></div>
    </div>
    <br />
    <input type="hidden" name="id" value="<?php 
echo fix($comment->id);
?>
" id="id" />
    <input type="hidden" name="ajax" value="true" id="ajax" />
    <div class="buttons">
        <input type="submit" value="<?php 
echo __("Update");
?>
" accesskey="s" /> <?php 
echo __("or");
?>
        <a href="javascript:void(0)" id="comment_cancel_edit_<?php 
echo $comment->id;
?>
" class="cancel"><?php 
echo __("Cancel");
예제 #26
0
 function t_fanli($uid, $money)
 {
     global $_G;
     $org_money = $money;
     if ($uid == $this->user['uid']) {
         $user = $this->user;
     } else {
         $user = getuser($uid, 'uid');
     }
     //if($user['uid'] == $this->user[uid]) return $money;
     //if($user['t_uid'] && $user['t_uid'] == $this->user[uid]) return $money;		//防止死循环
     //4,3,1,1,2
     $rank = $user['rank'];
     if (!$rank || !$_G['rank'][$rank]) {
         return $money;
     }
     $group = $_G['rank'][$rank];
     $bili = intval($group['bili']);
     //当前推荐者所在推荐的返利比例
     if ($bili <= 0) {
         return $money;
     }
     $yongjin = fix($money * ($bili / 100), 2);
     $money = $money - $yongjin;
     //给佣金表,增加记录,供用户查询
     $log = array();
     //第'.($k+1).'级
     if (!$this->order['price'] || $yongjin <= 0) {
         return $money;
     }
     $log['desc'] = '您推荐的用户' . $this->user['username'] . '购物消费,您获得:' . $yongjin . '元(' . $bili . '%)';
     $add_money = $user['money'] + $yongjin;
     update_member(array('money' => $add_money), $user['uid']);
     $log['org_money'] = $user['money'];
     $log['money'] = $yongjin;
     $log['status'] = 1;
     $log['uid'] = $user['uid'];
     $log['username'] = $user['username'];
     $this->write_log($log);
     //无限上级推荐人返利
     /*if($user['t_uid']>0){
     			if($user['t_uid'] == $this->user['uid'] || $user['t_uid'] == $user['uid'])continue;	//防止死循环
     			$money =  $this->t_fanli($user['t_uid'],$org_money);
     		}*/
     return $money;
 }
예제 #27
0
파일: feed.php 프로젝트: quanganhdo/chyrp
    echo fix($author);
    ?>
</name>
<?php 
    if (!empty($post->user->website)) {
        ?>
            <uri><?php 
        echo fix($post->user->website);
        ?>
</uri>
<?php 
    }
    ?>
        </author>
        <content type="html">
			<?php 
    echo fix($post->feed_content());
    ?>
			<?php 
    echo fix("<br /><a href='{$original_url}'> ☃ </a>");
    ?>
		</content>
<?php 
    $trigger->call("feed_item", $post);
    ?>
    </entry>
<?php 
}
?>
</feed>
예제 #28
0
파일: photo.php 프로젝트: relisher/chyrp
 public function image_tag($post, $max_width = 500, $max_height = null, $more_args = "quality=100")
 {
     $filename = $post->filename;
     $config = Config::current();
     $alt = !empty($post->alt_text) ? fix($post->alt_text, true) : $filename;
     return '<img src="' . $config->chyrp_url . '/includes/thumb.php?file=..' . $config->uploads_path . urlencode($filename) . '&amp;max_width=' . $max_width . '&amp;max_height=' . $max_height . '&amp;' . $more_args . '" alt="' . $alt . '" />';
 }
예제 #29
0
function value_fallback($index, $fallback = "")
{
    echo isset($_POST[$index]) ? fix($_POST[$index]) : $fallback;
}
예제 #30
0
<?php

define('JAVASCRIPT', true);
require_once "common.php";
error_reporting(0);
header("Content-Type: application/x-javascript");
$route = Route::current(MainController::current());
?>
<!-- --><script>
var Route = {
    action: "<?php 
echo fix($_GET['action']);
?>
"
}

var site_url = "<?php 
echo $config->chyrp_url;
?>
"

$(function(){
    // Scan AJAX responses for errors.
    $(document).ajaxComplete(function(event, request){
        var response = request ? request.responseText : null
        if (isError(response))
            alert(response.replace(/(HEY_JAVASCRIPT_THIS_IS_AN_ERROR_JUST_SO_YOU_KNOW|<([^>]+)>\n?)/gm, ""))
    })<?php 
echo "\n\n\n\n\n";
# Balance out the line numbers in this script and in the output to help debugging.
?>