当前位置: 首页>>代码示例>>PHP>>正文


PHP SQL::escape方法代码示例

本文整理汇总了PHP中SQL::escape方法的典型用法代码示例。如果您正苦于以下问题:PHP SQL::escape方法的具体用法?PHP SQL::escape怎么用?PHP SQL::escape使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SQL的用法示例。


在下文中一共展示了SQL::escape方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: addComment

 private function addComment($comment, $OpenIDFields = false)
 {
     if (!isset($comment['author']['openid']) || $comment['author']['openid'] == '') {
         $author = $comment['author'];
         $author['openid'] = '';
     } else {
         $author = array('name' => $OpenIDFields['nickname'], 'email' => $OpenIDFields['email'], 'website' => $comment['author']['website']);
         $e = explode('http://', $comment['author']['openid']);
         $author['openid'] = end($e);
         if (preg_match('#(.*?)\\/$#s', $author['openid'])) {
             $author['openid'] = substr($author['openid'], 0, -1);
         }
     }
     if ($author['website'] == 'http://' || $author['website'] == '') {
         if (trim($comment['author']['openid']) == '') {
             $author['website'] = '';
         } else {
             $author['website'] = trim($comment['author']['openid']);
         }
     }
     if ($result = !SQL::query("SELECT MAX([comment_number]) AS [max_number] FROM [blog_comments]p WHERE ([post_id] == " . (int) $comment['post_id'] . ")")) {
         $number = $result->fetchOne();
         $number = (int) $number->max_number;
     } else {
         $number = 0;
     }
     if (!SQL::exec("\r\nINSERT INTO [blog_comments]p\r\n(\r\n[post_id],\r\n[comment_number],\r\n[comment_date],\r\n[comment_content],\r\n[comment_author_openid],\r\n[comment_author_name],\r\n[comment_author_email],\r\n[comment_author_website],\r\n[comment_author_user_agent],\r\n[comment_author_os]\r\n) VALUES (\r\n" . (int) $comment['post_id'] . ",\r\n" . $number . ",\r\n" . time() . ",\r\n'" . SQL::escape(trim($comment['content'])) . "',\r\n'" . SQL::escape(trim($author['openid'])) . "',\r\n'" . SQL::escape(trim($author['name'])) . "',\r\n'" . SQL::escape(strtolower(trim($author['email']))) . "',\r\n'" . SQL::escape(trim($author['website'])) . "',\r\n'" . SQL::escape($_SERVER['HTTP_USER_AGENT']) . "',\r\n'" . '' . "'\r\n)")) {
         throw new Exception('The comment could not be added.');
     }
     $uri = SITE_ROOT_PATH . str_replace(array('%id', '%slug'), array($comment['post_id'], $comment['post_slug']), CFG_URL_BLOG_POST) . '#comments';
     header('Location: ' . $uri);
     echo '<a href="' . $uri . '">' . $uri . '</a>';
 }
开发者ID:jankuca,项目名称:escms,代码行数:33,代码来源:blog.action.mod.php

示例2: add

 /**
  * Adds tags to the database
  * 
  * @param array|string tags to enter
  * @return array keys of the tags entered 
  */
 public function add($tags)
 {
     if (!is_array($tags) && !is_string($tags)) {
         trigger_error("Tags is of unvalid type!", E_USER_ERROR);
     }
     $tags = $this->clean($tags);
     $keys = array();
     $existingTags = array();
     $query = "SELECT id, tag FROM tags WHERE tag = '" . implode("' OR tag = '", $tags) . "'";
     trigger_error($query, E_USER_NOTICE);
     $result = SQL::query($query);
     while ($tag = $result->fetch_object()) {
         $existingTags[] = $tag->tag;
         $keys[] = $tag->id;
     }
     $tagsToAdd = array_diff($tags, $existingTags);
     unset($existingTags);
     trigger_error("Object {$object} is getting linked with tag(s) '" . implode("', '", $tags) . "' whereof the tag(s): '" . implode("', '", $tagsToAdd) . "' are new to the database.", E_USER_NOTICE);
     foreach ($tagsToAdd as $tag) {
         if ($tag != "" && is_string($tag)) {
             $query = "INSERT INTO tags (id, tag)" . "VALUES ('', '" . SQL::escape($tag) . "')";
         }
         trigger_error("Executing query: '{$query}'", E_USER_NOTICE);
         SQL::query($query);
         $keys[] = SQL::insertId();
     }
     if (empty($keys)) {
         return false;
     } else {
         return $keys;
     }
 }
开发者ID:nyson,项目名称:izwei,代码行数:38,代码来源:Tags.php

示例3: cascade

 /**
  * cascade to children
  *
  * @param string referencing of the changed anchor
  * @param string rights to be cascaded (e.g., 'Y', 'R' or 'N')
  */
 public static function cascade($reference, $active)
 {
     global $context;
     // only sections may have sub-sections
     if (strpos($reference, 'section:') === 0) {
         // cascade to sub-sections
         if ($items = Sections::list_for_anchor($reference, 'raw')) {
             // cascade to each section individually
             foreach ($items as $id => $item) {
                 // limit actual rights
                 $item['active'] = Anchors::ceil_rights($active, $item['active_set']);
                 $query = "UPDATE " . SQL::table_name('sections') . " SET active='" . SQL::escape($item['active']) . "' WHERE id = " . SQL::escape($id);
                 SQL::query($query);
                 // cascade to children
                 Anchors::cascade('section:' . $item['id'], $item['active']);
             }
         }
     }
     // only categories may have sub-categories
     if (strpos($reference, 'category:') === 0) {
         // cascade to sub-categories
         if ($items = Categories::list_for_anchor($reference, 'raw')) {
             // cascade to each section individually
             foreach ($items as $id => $item) {
                 // limit actual rights
                 $item['active'] = Anchors::ceil_rights($active, $item['active_set']);
                 $query = "UPDATE " . SQL::table_name('categories') . " SET active='" . SQL::escape($item['active']) . "' WHERE id = " . SQL::escape($id);
                 SQL::query($query);
                 // cascade to children
                 Anchors::cascade('category:' . $item['id'], $item['active']);
             }
         }
     }
     // only sections may have articles
     if (strpos($reference, 'section:') === 0) {
         // cascade to articles --up to 3000
         if ($items =& Articles::list_for_anchor_by('edition', $reference, 0, 3000, 'raw')) {
             // cascade to each section individually
             foreach ($items as $id => $item) {
                 // limit actual rights
                 $item['active'] = Anchors::ceil_rights($active, $item['active_set']);
                 $query = "UPDATE " . SQL::table_name('articles') . " SET active='" . SQL::escape($item['active']) . "' WHERE id = " . SQL::escape($id);
                 SQL::query($query);
                 // cascade to children
                 Anchors::cascade('article:' . $item['id'], $item['active']);
             }
         }
     }
     // cascade to files --up to 3000
     if ($items = Files::list_by_date_for_anchor($reference, 0, 3000, 'raw')) {
         // cascade to each section individually
         foreach ($items as $id => $item) {
             // limit actual rights
             $item['active'] = Anchors::ceil_rights($active, $item['active_set']);
             $query = "UPDATE " . SQL::table_name('files') . " SET active='" . SQL::escape($item['active']) . "' WHERE id = " . SQL::escape($id);
             SQL::query($query);
         }
     }
 }
开发者ID:rair,项目名称:yacs,代码行数:65,代码来源:anchors.php

示例4: stat_for_anchor

 /**
  * get some statistics for one anchor
  *
  * @param the selected anchor (e.g., 'section:12')
  * @return the resulting ($count, $min_date, $max_date) array
  */
 public static function stat_for_anchor($anchor)
 {
     global $context;
     // sanity check
     if (!$anchor) {
         return NULL;
     }
     $anchor = SQL::escape($anchor);
     // select among available items
     $query = "SELECT COUNT(*) as count, MIN(edit_date) as oldest_date, MAX(edit_date) as newest_date" . " FROM " . SQL::table_name('versions') . " AS versions" . " WHERE (versions.anchor LIKE '" . SQL::escape($anchor) . "')";
     $output = SQL::query_first($query);
     return $output;
 }
开发者ID:rair,项目名称:yacs,代码行数:19,代码来源:versions.php

示例5: htmlspecialchars

     }
     // keywords have been found
     if ($keywords && (!isset($item['keywords']) || $item['keywords'] != $keywords)) {
         if (isset($item['keywords']) && $item['keywords']) {
             $context['text'] .= BR . '< ' . htmlspecialchars($item['keywords']) . BR . '> ' . $keywords . BR;
         } else {
             $context['text'] .= BR . 'k ' . $keywords . BR;
         }
         $item['keywords'] = $keywords;
         $ok = FALSE;
     }
     // the link is ok
     if ($ok) {
         $context['text'] .= '.';
     } else {
         $query = "UPDATE " . SQL::table_name('referrals') . " SET" . " referer='" . SQL::escape($item['referer']) . "'," . " domain='" . SQL::escape($item['domain']) . "'," . " keywords='" . SQL::escape($item['keywords']) . "'" . " WHERE id = " . $item['id'];
         SQL::query($query);
         // update statistics
         $changes += 1;
     }
 }
 // we have processed one chunk
 $links_offset += SQL::count($result);
 $context['text'] .= BR . "\n";
 // ensure enough execution time
 Safe::set_time_limit(30);
 // detect the end of the list
 if (SQL::count($result) < CHUNK_SIZE) {
     break;
 }
 // empty list
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:check.php

示例6: queue

 /**
  * defer the processing of one message
  *
  * This function either processes a message immediately, or it saves provided data in the
  * database for later processing.
  *
  * @param string the target address
  * @param string message subject
  * @param string message content
  * @param string optional headers
  * @return int the number of queued messages, or 0 on error
  */
 private static function queue($recipient, $subject, $message, $headers = '')
 {
     global $context;
     // we don't have to rate messages
     if (!isset($context['mail_hourly_maximum']) || $context['mail_hourly_maximum'] < 1) {
         return Mailer::process($recipient, $subject, $message, $headers);
     }
     // transaction attributes
     $query = array();
     $query[] = "edit_date='" . SQL::escape(gmstrftime('%Y-%m-%d %H:%M:%S')) . "'";
     $query[] = "headers='" . SQL::escape($headers) . "'";
     $query[] = "message='" . SQL::escape($message) . "'";
     $query[] = "recipient='" . SQL::escape($recipient) . "'";
     $query[] = "subject='" . SQL::escape($subject) . "'";
     // insert a new record
     $query = "INSERT INTO " . SQL::table_name('messages') . " SET " . implode(', ', $query);
     if (SQL::query($query) === FALSE) {
         return 0;
     }
     return 1;
 }
开发者ID:rair,项目名称:yacs,代码行数:33,代码来源:mailer.php

示例7: rtrim

     $inu[$index] = $is_unsigned;
     // next field
     $index++;
 }
 // remove last comma
 $field_list = rtrim($field_list, ', ');
 //parse out the table's data and generate the SQL INSERT statements in order to replicate the data itself...
 while ($row = SQL::fetch_row($result)) {
     $sql = 'INSERT INTO `' . $table_name . '` (' . $field_list . ') VALUES (';
     for ($d = 0; $d < count($row); $d++) {
         if ($inu[$d] == TRUE) {
             $sql .= $row[$d];
         } elseif ($ina[$d] == TRUE) {
             $sql .= intval($row[$d]);
         } else {
             $sql .= "'" . SQL::escape(strval($row[$d])) . "'";
         }
         if ($d < count($row) - 1) {
             $sql .= ", ";
         }
     }
     $sql .= ");\n";
     if ($compressed) {
         gzwrite($handle, $sql);
     } else {
         fwrite($handle, $sql);
     }
     // ensure we have enough time
     $queries++;
     if (!($queries % 100)) {
         Safe::set_time_limit(30);
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:backup.php

示例8: transcode

 /**
  * transcode some references
  *
  * @param array of pairs of strings to be used in preg_replace()
  *
  * @see images/images.php
  */
 function transcode($transcoded)
 {
     global $context;
     // no item bound
     if (!isset($this->item['id'])) {
         return;
     }
     // prepare preg_replace()
     $from = array();
     $to = array();
     foreach ($transcoded as $pair) {
         $from[] = $pair[0];
         $to[] = $pair[1];
     }
     // transcode various fields
     $this->item['introduction'] = preg_replace($from, $to, $this->item['introduction']);
     $this->item['description'] = preg_replace($from, $to, $this->item['description']);
     // update the database
     $query = "UPDATE " . SQL::table_name('categories') . " SET " . " introduction = '" . SQL::escape($this->item['introduction']) . "'," . " description = '" . SQL::escape($this->item['description']) . "'" . " WHERE id = " . SQL::escape($this->item['id']);
     SQL::query($query);
     // always clear the cache, even on no update
     Categories::clear($this->item);
 }
开发者ID:rair,项目名称:yacs,代码行数:30,代码来源:category.php

示例9: confirm

 /**
  * remember that surfer is enrolled in a meeting
  *
  * @param string reference of the target page
  */
 public static function confirm($reference)
 {
     global $context;
     // sanity check
     if (!$reference) {
         return;
     }
     // ensure that the joiner has been enrolled...
     if (!($item = enrolments::get_record($reference))) {
         if (Surfer::get_id()) {
             // fields to save
             $query = array();
             $query[] = "anchor = '" . $reference . "'";
             $query[] = "approved = 'Y'";
             $query[] = "edit_date = '" . SQL::escape(gmstrftime('%Y-%m-%d %H:%M:%S')) . "'";
             $query[] = "user_id = " . SQL::escape(Surfer::get_id());
             $query[] = "user_email = '" . SQL::escape(Surfer::get_email_address()) . "'";
             // insert a new record
             $query = "INSERT INTO " . SQL::table_name('enrolments') . " SET " . implode(', ', $query);
             SQL::query($query);
         }
         // each joiner takes one seat
     } else {
         $query = "UPDATE " . SQL::table_name('enrolments') . " SET approved = 'Y' WHERE id = " . SQL::escape($item['id']);
         SQL::query($query);
     }
 }
开发者ID:rair,项目名称:yacs,代码行数:32,代码来源:enrolments.php

示例10: elseif

    $context['text'] .= '<p><a href="../setup.php">' . i18n::s('Jump to the installation page') . "</a></p>\n";
    // splash screen
    $context['text'] .= '<p>' . i18n::s('Else follow the link below to load the configuration form.') . "</p>\n";
    // link to the configuration page
    $context['text'] .= '<p><a href="configure.php">' . i18n::s('Jump to the configuration page') . "</a></p>\n";
    // no access to the database server yet
} elseif (!isset($context['database']) || !$context['database'] || !isset($context['connection']) || !$context['connection']) {
    // title
    $context['page_title'] = i18n::s('No access to the database server');
    // splash screen
    $context['text'] .= '<p>' . i18n::s('Impossible to access the database mentioned in your configuration file. Please create a database, or follow the link to change the configuration file.') . "</p>\n";
    // link to the configuration page
    $context['text'] .= '<p><a href="configure.php">' . i18n::s('Jump to the configuration page') . "</a></p>\n";
} else {
    // try to create a database if it does not exist
    $query = "CREATE DATABASE IF NOT EXISTS " . SQL::escape($context['database']);
    SQL::query($query, TRUE, $context['connection']);
    // still no database
    if (!SQL::has_database($context['database'])) {
        // title
        $context['page_title'] = i18n::s('Please create a database');
        // splash screen
        $context['text'] .= '<p>' . i18n::s('Impossible to access the database mentioned in your configuration file. Please create a database, or follow the link to change the configuration file.') . "</p>\n";
        // link to the configuration page
        $context['text'] .= '<p><a href="configure.php">' . i18n::s('Go to the configuration page to change database parameters') . "</a></p>\n";
        // no hooks found yet
    } elseif (!file_exists('../parameters/hooks.include.php')) {
        // title
        $context['page_title'] = i18n::s('Please configure software extensions');
        // splash screen
        $context['text'] .= '<p>' . i18n::s('No configuration file for extensions has been found. If you are installing a brand new server, follow the link to create one.') . "</p>\n";
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:index.php

示例11: addcslashes

 }
 if (isset($_REQUEST['without_internet_visibility'])) {
     $content .= '$context[\'without_internet_visibility\']=\'' . addcslashes($_REQUEST['without_internet_visibility'], "\\'") . "';\n";
 }
 if (isset($_REQUEST['without_language_detection'])) {
     $content .= '$context[\'without_language_detection\']=\'' . addcslashes($_REQUEST['without_language_detection'], "\\'") . "';\n";
 }
 if (isset($_REQUEST['without_outbound_http'])) {
     $content .= '$context[\'without_outbound_http\']=\'' . addcslashes($_REQUEST['without_outbound_http'], "\\'") . "';\n";
 }
 if (isset($_REQUEST['static_subdom'])) {
     $content .= '$context[\'static_subdom\']=\'' . addcslashes($_REQUEST['static_subdom'], "\\'") . "';\n";
 }
 $content .= '?>' . "\n";
 // silently attempt to create the database if it does not exist
 $query = 'CREATE DATABASE IF NOT EXISTS ' . SQL::escape($_REQUEST['database']);
 SQL::query($query, TRUE);
 // alert the end user if we are not able to connect to the database
 if (!($handle = SQL::connect($_REQUEST['database_server'], $_REQUEST['database_user'], $_REQUEST['database_password'], $_REQUEST['database']))) {
     Logger::error(i18n::s('ERROR: Unsuccessful connection to the database. Please check lines below and <a href="configure.php">configure again</a>.'));
     // update the parameters file
 } elseif (!Safe::file_put_contents('parameters/control.include.php', $content)) {
     Logger::error(sprintf(i18n::s('ERROR: Impossible to write to the file %s. The configuration has not been saved.'), 'parameters/control.include.php'));
     // allow for a manual update
     $context['text'] .= '<p style="text-decoration: blink;">' . sprintf(i18n::s('To actually change the configuration, please copy and paste following lines by yourself in file %s.'), 'parameters/control.include.php') . "</p>\n";
     // job done
 } else {
     $context['text'] .= '<p>' . sprintf(i18n::s('The following configuration has been saved into the file %s.'), 'parameters/control.include.php') . "</p>\n";
     // first installation
     if (!file_exists('../parameters/switch.on') && !file_exists('../parameters/switch.off')) {
         $context['text'] .= '<p>' . i18n::s('Review provided information and go to the bottom of the page to move forward.') . "</a></p>\n";
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:configure.php

示例12: while

 $query .= "\n)";
 // actual table creation
 SQL::query($query);
 // process every other line
 $queries = 0;
 $count = 0;
 while ($tokens = fgetcsv($handle, 2048, $delimiter, $enclosure)) {
     // insert one record at a time
     $query = "INSERT INTO " . SQL::escape($_REQUEST['table_name']) . " (" . $headers . ") VALUES (";
     // use all provided tokens
     $index = 0;
     foreach ($tokens as $token) {
         if ($index++) {
             $query .= ', ';
         }
         $query .= "'" . SQL::escape($token) . "'";
     }
     // finalize the statement
     $query .= ')';
     // execute the statement
     if (!SQL::query($query, TRUE) && SQL::errno()) {
         $context['text'] .= '<p>' . $here . ': ' . $query . BR . SQL::error() . "</p>\n";
     }
     $queries++;
     // ensure we have enough time
     if (!($queries % 50)) {
         Safe::set_time_limit(30);
     }
 }
 // clear the cache
 Cache::clear();
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:import.php

示例13: remember

 /**
  * remember an action once it's done
  *
  * This function saves data into the table [code]yacs_issues[/code].
  *
  * @see overlays/overlay.php
  *
  * @param string the action 'insert', 'update' or 'delete'
  * @param array the hosting record
  * @param string reference of the hosting record (e.g., 'article:123')
  * @return FALSE on error, TRUE otherwise
  */
 function remember($action, $host, $reference)
 {
     global $context;
     // locate anchor on 'insert'
     if ($reference) {
         $this->anchor = Anchors::get($reference);
     }
     // remember data from the anchor
     $this->attributes['anchor_reference'] = '';
     $this->attributes['anchor_title'] = '';
     $this->attributes['anchor_url'] = '';
     if (is_callable(array($this->anchor, 'get_url'))) {
         $this->attributes['anchor_reference'] = $this->anchor->get_reference();
         $this->attributes['anchor_title'] = $this->anchor->get_title();
         $this->attributes['anchor_url'] = $this->anchor->get_url();
     }
     // set default values for this editor
     Surfer::check_default_editor($this->attributes);
     // default date values
     if (!isset($this->attributes['create_date']) || $this->attributes['create_date'] <= NULL_DATE) {
         $this->attributes['create_date'] = $this->attributes['edit_date'];
     }
     if (!isset($this->attributes['qualification_date']) || $this->attributes['qualification_date'] <= NULL_DATE) {
         $this->attributes['qualification_date'] = NULL_DATE;
     }
     if (!isset($this->attributes['analysis_date']) || $this->attributes['analysis_date'] <= NULL_DATE) {
         $this->attributes['analysis_date'] = NULL_DATE;
     }
     if (!isset($this->attributes['resolution_date']) || $this->attributes['resolution_date'] <= NULL_DATE) {
         $this->attributes['resolution_date'] = NULL_DATE;
     }
     if (!isset($this->attributes['close_date']) || $this->attributes['close_date'] <= NULL_DATE) {
         $this->attributes['close_date'] = NULL_DATE;
     }
     // add a notification to the anchor page
     $comments = array();
     // build the update query
     switch ($action) {
         case 'delete':
             $query = "DELETE FROM " . SQL::table_name('issues') . " WHERE anchor LIKE '" . $this->attributes['anchor_reference'] . "'";
             break;
         case 'insert':
             $comments[] = i18n::s('Page has been created');
             // set host owner, if any
             if (isset($this->attributes['owner']) && ($user = Users::get($this->attributes['owner'])) && $user['id'] != Surfer::get_id()) {
                 $fields = array();
                 $fields['owner_id'] = $user['id'];
                 $this->anchor->set_values($fields);
                 Members::assign('user:' . $user['id'], $this->anchor->get_reference());
                 Members::assign($this->anchor->get_reference(), 'user:' . $user['id']);
                 $comments[] = sprintf(i18n::s('Owner has been changed to %s'), Skin::build_link(Users::get_permalink($user), $user['full_name']));
             }
             $query = "INSERT INTO " . SQL::table_name('issues') . " SET \n" . "anchor='" . SQL::escape($this->attributes['anchor_reference']) . "', \n" . "anchor_url='" . SQL::escape($this->attributes['anchor_url']) . "', \n" . "color='" . SQL::escape(isset($this->attributes['color']) ? $this->attributes['color'] : 'green') . "', \n" . "status='" . SQL::escape(isset($this->attributes['status']) ? $this->attributes['status'] : 'on-going:suspect') . "', \n" . "title='" . SQL::escape($this->attributes['anchor_title']) . "', \n" . "type='" . SQL::escape(isset($this->attributes['type']) ? $this->attributes['type'] : 'incident') . "', \n" . "create_name='" . SQL::escape(isset($this->attributes['create_name']) ? $this->attributes['create_name'] : $this->attributes['edit_name']) . "', \n" . "create_id=" . SQL::escape(isset($this->attributes['create_id']) ? $this->attributes['create_id'] : $this->attributes['edit_id']) . ", \n" . "create_address='" . SQL::escape(isset($this->attributes['create_address']) ? $this->attributes['create_address'] : $this->attributes['edit_address']) . "', \n" . "create_date='" . SQL::escape(isset($this->attributes['create_date']) ? $this->attributes['create_date'] : $this->attributes['edit_date']) . "', \n" . "edit_name='" . SQL::escape($this->attributes['edit_name']) . "', \n" . "edit_id=" . SQL::escape($this->attributes['edit_id']) . ", \n" . "edit_address='" . SQL::escape($this->attributes['edit_address']) . "', \n" . "edit_action='create', \n" . "edit_date='" . SQL::escape($this->attributes['edit_date']) . "', \n" . "qualification_date='" . SQL::escape(isset($this->attributes['qualification_date']) ? $this->attributes['qualification_date'] : NULL_DATE) . "', \n" . "analysis_date='" . SQL::escape(isset($this->attributes['analysis_date']) ? $this->attributes['analysis_date'] : NULL_DATE) . "', \n" . "resolution_date='" . SQL::escape(isset($this->attributes['resolution_date']) ? $this->attributes['resolution_date'] : NULL_DATE) . "', \n" . "close_date='" . SQL::escape(isset($this->attributes['close_date']) ? $this->attributes['close_date'] : NULL_DATE) . "'";
             break;
         case 'update':
             // only associates and page owners can update the record
             if (is_callable(array($this->anchor, 'is_owned')) && $this->anchor->is_owned()) {
                 // detect type modification
                 if ($this->attributes['type'] != $this->snapshot['type']) {
                     $comments[] = sprintf(i18n::s('Workflow has been changed to "%s"'), $this->get_type_label($this->attributes['type']));
                 }
                 // detect color modification
                 if ($this->attributes['color'] != $this->snapshot['color']) {
                     $comments[] = $this->get_color_label($this->attributes['color']);
                 }
                 // change host owner, if any
                 if ($this->attributes['owner'] && ($user = Users::get($this->attributes['owner'])) && $user['id'] != $this->anchor->get_value('owner_id')) {
                     $fields = array();
                     $fields['owner_id'] = $user['id'];
                     $this->anchor->set_values($fields);
                     Members::assign('user:' . $user['id'], $this->anchor->get_reference());
                     Members::assign($this->anchor->get_reference(), 'user:' . $user['id']);
                     $comments[] = sprintf(i18n::s('Owner has been changed to %s'), Skin::build_link(Users::get_permalink($user), $user['full_name']));
                 }
                 // update the table of issues
                 $query = "UPDATE " . SQL::table_name('issues') . " SET \n" . "anchor='" . SQL::escape($this->attributes['anchor_reference']) . "', \n" . "anchor_url='" . SQL::escape($this->attributes['anchor_url']) . "', \n" . "color='" . SQL::escape($this->attributes['color']) . "', \n" . "status='" . SQL::escape($this->attributes['status']) . "', \n" . "title='" . SQL::escape($this->attributes['anchor_title']) . "', \n" . "type='" . SQL::escape($this->attributes['type']) . "', \n" . "create_date='" . SQL::escape(isset($this->attributes['create_date']) ? $this->attributes['create_date'] : $this->attributes['edit_date']) . "', \n" . "qualification_date='" . SQL::escape(isset($this->attributes['qualification_date']) ? $this->attributes['qualification_date'] : NULL_DATE) . "', \n" . "analysis_date='" . SQL::escape(isset($this->attributes['analysis_date']) ? $this->attributes['analysis_date'] : NULL_DATE) . "', \n" . "resolution_date='" . SQL::escape(isset($this->attributes['resolution_date']) ? $this->attributes['resolution_date'] : NULL_DATE) . "', \n" . "close_date='" . SQL::escape(isset($this->attributes['close_date']) ? $this->attributes['close_date'] : NULL_DATE) . "', \n";
                 // detect status modification
                 if ($this->attributes['status'] != $this->snapshot['status']) {
                     $comments[] = $this->get_status_label($this->attributes['status']);
                     // depending of new status
                     switch ($this->attributes['status']) {
                         // case has been recorded --should not happen
                         case 'on-going:suspect':
                             $query .= "create_name='" . SQL::escape($this->attributes['edit_name']) . "', \n" . "create_id=" . SQL::escape($this->attributes['edit_id']) . ", \n" . "create_address='" . SQL::escape($this->attributes['edit_address']) . "', \n";
                             break;
                             // problem has been validated
                         // problem has been validated
                         case 'cancelled:suspect':
//.........这里部分代码省略.........
开发者ID:rair,项目名称:yacs,代码行数:101,代码来源:issue.php

示例14: sprintf

             Safe::set_time_limit(30);
         }
         // fetch the member
         if ($row['member'] && !($item = Anchors::get($row['member']))) {
             // delete this entry
             $query = "DELETE FROM " . SQL::table_name('members') . " WHERE id = " . SQL::escape($row['id']);
             SQL::query($query);
             $context['text'] .= sprintf(i18n::s('Unknown member %s, record has been deleted'), $row['member']) . BR . "\n";
             if (++$errors_count >= 50) {
                 $context['text'] .= i18n::s('Too many successive errors. Aborted') . BR . "\n";
                 break;
             }
             // check that the anchor exists, if any
         } elseif ($row['anchor'] && !Anchors::get($row['anchor'])) {
             // delete this entry
             $query = "DELETE FROM " . SQL::table_name('members') . " WHERE id = " . SQL::escape($row['id']);
             SQL::query($query);
             $context['text'] .= sprintf(i18n::s('Unknown anchor %s, record has been deleted'), $row['anchor']) . BR . "\n";
             if (++$errors_count >= 50) {
                 $context['text'] .= i18n::s('Too many successive errors. Aborted') . BR . "\n";
                 break;
             }
         } else {
             $errors_count = 0;
         }
     }
 }
 // ending message
 $context['text'] .= sprintf(i18n::s('%d records have been processed'), $count) . BR . "\n";
 // display the execution time
 $time = round(get_micro_time() - $context['start_time'], 2);
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:check.php

示例15: call

 /**
  * start a phone call
  *
  * @param array e.g., array('user' => '123', 'number' => '33146411313')
  * @return mixed some error array with code and message, or the id of the on-going call
  */
 function call($parameters)
 {
     global $context;
     // do we have some API key?
     if (!isset($context['obs_api_key'])) {
         return array('code' => -32000, 'message' => 'Missing credentials to use OBS API');
     }
     // look for a user id
     if (empty($parameters['user'])) {
         return array('code' => -32602, 'message' => 'Invalid parameter "user"');
     }
     // get the matching record
     if (!($user = Users::get($parameters['user']))) {
         return array('code' => -32602, 'message' => 'Unable to find this "user"');
     }
     // get the related phone number
     if (!isset($user['phone_number'])) {
         return array('code' => -32602, 'message' => 'No phone number for this "user"');
     }
     // look for an external number
     if (empty($parameters['number'])) {
         return array('code' => -32602, 'message' => 'Invalid parameter "number"');
     }
     // data to be submitted to OBS
     $data = array();
     $data[] = 'id=' . urlencode($context['obs_api_key']);
     $data[] = 'from=' . urlencode(ltrim($user['phone_number'], '0+'));
     $data[] = 'to=' . urlencode(ltrim($parameters['number'], '0+'));
     // build the endpoint to invoke
     $url = self::build_obs_link('call/createCall', $data);
     // do create the call
     if (!($response = http::proceed_natively($url))) {
         return array('code' => -32603, 'message' => 'Unable to query the OBS API');
     }
     // ensure we receive correct xml
     if (!($xml = simplexml_load_string($response, 'SimpleXMLElement', LIBXML_NOCDATA))) {
         return array('code' => -32603, 'message' => 'Invalid response from OBS API');
     }
     if (!$xml->status->status_code) {
         return array('code' => -32603, 'message' => 'Invalid response from OBS API');
     }
     // stop on error
     if ($xml->status->status_code != 200) {
         return array('code' => -32000, 'message' => 'Error: ' . $xml->status->status_code . ' ' . $xml->status->status_msg);
     }
     // look for call id
     if (!($id = $xml->call_info->call_id)) {
         return array('code' => -32603, 'message' => 'Invalid response from OBS API');
     }
     // if surfer has been authenticated, save his phone number
     if ($user = Users::get(Surfer::get_id())) {
         // update session data
         $_SESSION['surfer_phone_number'] = $parameters['number'];
         // update surfer record too
         $query = "UPDATE " . SQL::table_name('users') . " SET phone_number='" . SQL::escape($parameters['number']) . "'" . " WHERE id = " . SQL::escape(Surfer::get_id());
         SQL::query($query, FALSE, $context['users_connection']);
     }
     // provide id to caller, for subsequent actions on the call
     return array('call_id' => (string) $id);
 }
开发者ID:rair,项目名称:yacs,代码行数:66,代码来源:rpc_obs_hook.php


注:本文中的SQL::escape方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。