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


PHP Network::check_already方法代码示例

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


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

示例1: check_error

function check_error($skip = NULL)
{
    global $invalid_network_address;
    $mandatory_vars = array('address' => 'Network Address', 'name' => 'Network Title', 'tagline' => 'Network Sub Title', 'category' => 'Network Category', 'desc' => 'Network Description');
    if (!empty($skip)) {
        if (is_array($skip)) {
            foreach ($skip as $key => $value) {
                if (array_key_exists($value, $mandatory_vars)) {
                    unset($mandatory_vars[$value]);
                }
            }
        } elseif (is_string($skip)) {
            if (array_key_exists($skip, $mandatory_vars)) {
                unset($mandatory_vars[$skip]);
            }
        }
    }
    $error = FALSE;
    $error_msg = 'Network could not be saved due to following errors:<br />';
    if ($_POST['action'] == 'edit') {
        unset($mandatory_vars['address']);
    }
    //check for mandatory vars
    foreach ($mandatory_vars as $key => $value) {
        $_POST[$key] = trim($_POST[$key]);
        if (empty($_POST[$key])) {
            $error = TRUE;
            $error_msg .= $value . ' can\'t be empty<br />';
        }
        if ($key == 'address') {
            if (!empty($_POST[$key])) {
                if (strlen($_POST[$key]) < 3) {
                    $error = TRUE;
                    $error_msg .= $value . ' can\'t be less than 3 characters<br />';
                } elseif (strlen($_POST[$key]) > 20) {
                    $error = TRUE;
                    $error_msg .= $value . ' can\'t be more than 20 characters<br />';
                } elseif (!Validation::validate_alpha_numeric($_POST[$key])) {
                    $error = TRUE;
                    $error_msg .= $value . ' should be alphanumeric and  spaces are not allowed<br />';
                } elseif (Network::check_already($_POST[$key])) {
                    $error = TRUE;
                    $error_msg .= $value . ' is not available<br />';
                } elseif (in_array($_POST[$key], $invalid_network_address)) {
                    $error = TRUE;
                    $error_msg .= ' Special subdomain names like www,ftp, mail, smtp, pop etc. are not allowed in network address.<br />';
                }
            }
        }
    }
    //...end foreach
    if ($error) {
        $r = array('error' => TRUE, 'error_msg' => $error_msg);
    } else {
        $r = FALSE;
    }
    return $r;
}
开发者ID:Cyberspace-Networks,项目名称:PeopleAggregator,代码行数:58,代码来源:network.inc.php

示例2: save

 /**
  * Saves network to databse.
  * used for creating and updating the network
  * @access public.
  * called after $this->set_params()
  */
 public function save()
 {
     global $error, $error_msg;
     $error = false;
     Logger::log("[ Enter: function Network::save]\n");
     //first check whether it is insert or update
     // global var $path_prefix has been removed - please, use PA::$path static variable
     if ($this->network_id) {
         $old_type = Network::find_network_type($this->network_id);
         //update
         $update_fields = array('name', 'tagline', 'category_id', 'description', 'extra', 'type', 'inner_logo_image');
         $sql = " UPDATE {networks} SET changed = ? ";
         $data_array = array(time());
         foreach ($update_fields as $field) {
             if (isset($this->{$field})) {
                 $sql .= " , {$field} = ? ";
                 array_push($data_array, $this->{$field});
             }
         }
         $sql .= " WHERE network_id = ? ";
         array_push($data_array, $this->network_id);
         $res = Dal::query($sql, $data_array);
         //fix for changing a network from private to public
         //the waiting_members must be changed to members
         $new_type = $this->type;
         if ($old_type == PRIVATE_NETWORK_TYPE && $new_type == REGULAR_NETWORK_TYPE) {
             Network::approve_all($this->network_id);
         }
     } else {
         //insert
         // here we have to do a lot of steps
         //first check if network already exists with same address
         if (Network::check_already($this->address)) {
             Logger::log("Thowing Exception NETWORK_ALREADY_EXISTS");
             throw new PAException(NETWORK_ALREADY_EXISTS, "Network with same address already exists");
         }
         // checks the permissions of directory network
         $network_folder = PA::$project_dir . "/networks";
         if (!is_writable($network_folder)) {
             Logger::log("Thowing Exception NETWORK_DIRECTORY_PERMISSION_ERROR");
             throw new PAException(NETWORK_DIRECTORY_PERMISSION_ERROR, "Network folder ({$network_folder}) is not writable. Please check the permissions");
         }
         //if we have come this far we can insert the network easily
         // TODO add acl permission check
         //insert into networks
         $this->created = time();
         $this->type = $this->type ? $this->type : REGULAR_NETWORK_TYPE;
         $res = Dal::query("INSERT INTO {networks} (name, address, tagline, type,category_id, description,is_active, created, changed, extra, member_count, owner_id, inner_logo_image) VALUES ( ?, ?, ?,?, ?, ?, ?, ?, ?, ?, 1, ?, ? )", array($this->name, $this->address, $this->tagline, $this->type, $this->category_id, $this->description, 1, $this->created, $this->changed, $this->extra, $this->user_id, $this->inner_logo_image));
         $this->network_id = Dal::insert_id();
         //insert into networks_users
         $user_created = Dal::query_first("SELECT created FROM users WHERE user_id=?", $this->user_id);
         $res = Dal::query("INSERT INTO {networks_users} (network_id, user_id, user_type, created) VALUES (?, ?, ?, ?)", array($this->network_id, $this->user_id, NETWORK_OWNER, $user_created));
         //Now we have inserted new network we need to create other directory and config files as well
         try {
             $this->do_network_setup();
         } catch (PAException $e) {
             $error = TRUE;
             $error_msg = "{$e->message}";
         }
         if ($error) {
             $this->do_rollback();
             throw new PAException(NETWORK_INTERNAL_ERROR, "Some internal error occured while setting up the network. Message: {$error_msg}");
         }
     }
     //.. insert
     Logger::log("[ Exit: function Network::save]\n");
     return $this->network_id;
 }
开发者ID:Cyberspace-Networks,项目名称:PeopleAggregator,代码行数:74,代码来源:Network.php

示例3: trim

 */
$login_required = TRUE;
include_once "web/includes/page.php";
global $invalid_network_address;
require_once "api/Validation/Validation.php";
if (!empty($_GET['check_address'])) {
    $address = trim($_GET['check_address']);
    if (strlen($address) < 3) {
        print '<span class="required">Network address can not have less than 3 characters.</span>';
    } else {
        if (strlen($address) > 10) {
            print '<span class="required">Network address can not have more than 10 characters.</span>';
        } else {
            if (!Validation::validate_alpha_numeric($address)) {
                print '<span class="required">Network address can not contain non alpha numeric characters.</span>';
            } else {
                if (in_array($address, $invalid_network_address)) {
                    print '<span class="required"> Special subdomain names like ftp, mail, smtp, pop etc. and Special keywords are not allowed in network address.</span>';
                } else {
                    if (Network::check_already($address)) {
                        print '<span class="required">Network address ' . stripslashes($address) . ' is not available.</span>';
                    } else {
                        print '<span class="required">Network address ' . stripslashes($address) . ' is available.</span>';
                    }
                }
            }
        }
    }
} else {
    print '<span class="required">Please enter the network address.</span>';
}
开发者ID:Cyberspace-Networks,项目名称:PeopleAggregator,代码行数:31,代码来源:check_availability.php


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