除去数组中的空值和签名参数

@param $para 签名参数组
@return array 去掉空值与签名参数后的新签名参数组
507968
public static function paraFilter($para, $isNew=false)
    {
        if (!$isNew) {
            unset($para['sign_type']);
        }
        $para_filter = array();
        while (list ($key, $val) = each ($para)) {
            if($key == "sign" || $val == "") {
                continue;
            } else {
                $para_filter[$key] = $para[$key];
            }
        }

        return $para_filter;
    }
159164
public function paraFilter($para) 
    {
        $para_filter = array();
        foreach ($para as $key => $val) {
            if($key == "sign" || $key == "sign_type" || $val == "") continue;
            else    $para_filter[$key] = $para[$key];
        }
        return $para_filter;
    }
1027338
protected function generateMd5Sign($params = [])
    {
        static::sortParams($params);  // 排序

        $arr = [];
        foreach ($params as $k => $v) {
            $arr[] = $k . $v;
        }
        
        $str = $this->app->app_secret . implode('', $arr) . $this->app->app_secret;

        return strtoupper(md5($str));
    }
1130675
public function getQueryString(array $new_params = [])
    {
        $params = $_GET;
        if (!empty($this->input)) {
            $params[$this->getKey()] = $this->input;
        }
        if (!empty($new_params)) {
            if (empty($params[$this->getKey()])) {
                $params[$this->getKey()] = [];
            }
            foreach ($new_params as $key => $value) {
                $params[$this->getKey()][$key] = $value;
            }
        }
        return http_build_query($params);
    }
1082628
public function search($params)
    {
        $subquery = (new Query())
                    ->select(['m2.replyto'])
                    ->from(['m1' => Message::tableName()])
                    ->leftJoin(['m2' => Message::tableName()], 'm1.replyto = m2.id')
                    ->where(['is not', 'm2.replyto', null]);
        $query = static::find()->where(['and',
            ['receiver_id' => User::loggedId()],
            ['!=', 'receiver_status', self::STATUS_DELETED],
            ['not in', 'message_id', $subquery]
        ]);
        $dataProvider = new ActiveDataProvider([
            'query' => $query,
        ]);
        $dataProvider->sort->attributes['senderName'] = [
            'asc' => [
                User::tableName() . '.username' => SORT_ASC,
                User::tableName() . '.id' => SORT_ASC
            ],
            'desc' => [
                User::tableName() . '.username' => SORT_DESC,
                User::tableName() . '.id' => SORT_DESC
            ],
            'default' => SORT_ASC
        ];
        $dataProvider->sort->defaultOrder = ['id' => SORT_DESC];
        $dataProvider->pagination->pageSize = Yii::$app->session->get('per-page', 20);

        if (!($this->load($params) && $this->validate())) {
            $dataProvider->query->joinWith(['message' => function ($q) {
                $q->joinWith(['sender']);
            }]);
            return $dataProvider;
        }

        $dataProvider->query->andFilterWhere(['like', 'topic', $this->topic]);

        if (preg_match('/^(forum|orum|rum|um|m)?#([0-9]+)$/', strtolower($this->senderName), $matches)) {
            $dataProvider->query->joinWith(['message' => function ($q) use ($matches) {
                $q->joinWith(['sender' => function ($q) use ($matches) {
                    $q->andFilterWhere(['and',
                        [User::tableName() . '.id' => $matches[2]],
                        ['or',
                            ['username' => ''],
                            ['username' => null]
                        ]
                    ]);
                }]);
            }]);
        } elseif (preg_match('/^([0-9]+)$/', $this->senderName, $matches)) {
            $dataProvider->query->joinWith(['message' => function ($q) use ($matches) {
                $q->joinWith(['sender' => function ($q) use ($matches) {
                    $q->andFilterWhere(['or',
                        ['like', 'username', $this->senderName],
                        ['and',
                            ['id' => $matches[1]],
                            ['or',
                                ['username' => ''],
                                ['username' => null]
                            ]
                        ],
                    ]);
                }]);
            }]);
        } else {
            $dataProvider->query->joinWith(['message' => function ($q) {
                $q->joinWith(['sender' => function ($q) {
                    $q->andFilterWhere(['like', User::tableName() . '.username', $this->senderName]);
                }]);
            }]);
        }
        return $dataProvider;
    }
34078
public function search($params)
    {
        $query = Supplier::find();

        $dataProvider = new ActiveDataProvider([
            'query' => $query,
        ]);

        $this->load($params);

        if (!$this->validate()) {
            // uncomment the following line if you do not want to return any records when validation fails
            // $query->where('0=1');
            return $dataProvider;
        }

        $query->andFilterWhere([
            'id' => $this->id,
            'user_id' => $this->user_id,
            'birth_date' => $this->birth_date,
            'date_join' => $this->date_join,
            'date_left' => $this->date_left,
            'created_at' => $this->created_at,
            'updated_at' => $this->updated_at,
            'created_by' => $this->created_by,
            'updated_by' => $this->updated_by,
        ]);

        $query->andFilterWhere(['like', 'avatar', $this->avatar])
            ->andFilterWhere(['like', 'name', $this->name])
            ->andFilterWhere(['like', 'phone', $this->phone])
            ->andFilterWhere(['like', 'email', $this->email])
            ->andFilterWhere(['like', 'website', $this->website])
            ->andFilterWhere(['like', 'gender', $this->gender])
            ->andFilterWhere(['like', 'relationship_status', $this->relationship_status])
            ->andFilterWhere(['like', 'vat_number', $this->vat_number])
            ->andFilterWhere(['like', 'language', $this->language])
            ->andFilterWhere(['like', 'address', $this->address])
            ->andFilterWhere(['like', 'country', $this->country])
            ->andFilterWhere(['like', 'city', $this->city])
            ->andFilterWhere(['like', 'state', $this->state])
            ->andFilterWhere(['like', 'zip_code', $this->zip_code])
            ->andFilterWhere(['like', 'status', $this->status])
            ->andFilterWhere(['like', 'type', $this->type])
            ->andFilterWhere(['like', 'currency', $this->currency]);

        return $dataProvider;
    }
664775
public function getParameter($parameter)
    {
        $isRefreshed = false;

        if (!$this->cacheExists()) {
            $this->refresh();
            $isRefreshed = true;
        }

        $values = parse_ini_file($this->cachePath);
        $return = null;

        if (isset($values[$parameter])) {
            $return = $values[$parameter];
        } else {
            if (!$isRefreshed) {
                $this->refresh();
                $values = parse_ini_file($this->cachePath);

                if (isset($values[$parameter])) {
                    $return = $values[$parameter];
                }
            }
        }

        return $return ? $return : false;
    }
718710
protected function genSign(array $para)
    {
        /**
         * a.除sign 字段外，对所有传入参数按照字段名的ASCII 码从小到大排序（字典序）后，
         * 使用URL 键值对的格式（即key1=value1&key2=value2…）拼接成字符串string1，
         * 注意： 值为空的参数不参与签名 ；
         */
        // 过滤不参与签名的参数
        $paraFilter = Helpers::paraFilter($para);
        // 对数组进行（字典序）排序
        $paraFilter = Helpers::argSort($paraFilter);
        // 进行URL键值对的格式拼接成字符串string1
        $str = Helpers::createLinkstring($paraFilter);
        /**
         * b. 在string1 最后拼接上key=Key(商户支付密钥 ) 得到stringSignTemp 字符串，
         * 并对stringSignTemp 进行md5 运算，再将得到的字符串所有字符转换为大写，得到sign 值signValue。
         */
        return hash_hmac('sha256', $str, $this->api_secret);
        // $sign = strtoupper(md5($string1));
        // return $sign;
    }
1194760
public function rename($params, $optParams = [])
    {
        return $this->sendRequest(['cloudId', 'publicId', 'newPublicId'], [
            'restAction' => 'update',
            'uri' => '/c/<cloudId>/o/<publicId>/rename/o/<newPublicId>',
            'params' => $params,
            'getParams' => $optParams,
        ], function ($response) use ($params) {
            if ($response->data && !isset($response->data['cloudId'])) {
                $response->data['cloudId'] = $this->client->getParam($params, 'cloudId');
            }

            return isset($response->data) ? new Image($response->data) : $response;
        });
    }
663090
public function unserializeParams($params) {
		$parts = explode($this->options['param-delimiter'], $params);
		$params = [];
		foreach ($parts as $part) {
			$kv = explode('=', $part);
			if ($kv[0] != '') {
				$value = count($kv) > 1
					? $kv[1] == $this->options['param-true'] ? true
					: ($kv[1] == $this->options['param-false'] ? false : $kv[1]) : true;
				$params = $this->setParam($params, $kv[0], $value);
			}
		}
		
		return $params;
	}
97586
private function detectParameters(string $path):array
    {
        $params = array();

        for ($i = 0; $i < strlen($path); $i++) {
            if ($path[$i] == "{") {
                $param = "";
                for (($p = $i + 1); $p < strlen($path); $p++) {
                    if ($path[$p] == "}") {
                        $p = strlen($path);
                        array_push($params, $param);
                    } else {
                        $param = $param.$path[$p];
                    }
                }
            }
        }
        return ($params);
    }
686903
public static function find($parameters = null)
    {
        $results = parent::find($parameters);
        $newResult = [];

        if ($results) {
            foreach ($results as $result) {
                $customFields = $result->getAllCustomFields();
                if (is_array($customFields)) {
                    //field the object
                    foreach ($customFields as $key => $value) {
                        $result->{$key} = $value;
                    }

                    $newResult[] = $result;
                }
            }

            unset($results);
        }
        return $newResult;
    }
327367
protected function _params_filter($parameters = array()){
    $params = array();
    foreach($parameters as $key => $val) {
        if ($key == "Signature" ||$val === "" || $val === NULL){
          continue;
        } else {
          $params[$key] = $parameters[$key];
        }
    }
    ksort($params);
    reset($params);
    return $params;
  }
1129567
public function getParam(string $param)
    {
        if (! empty($this->match['params'][$param])) {
            return $this->match['params'][$param];
        }
    }
992272
public function buildRequestMysign($para_sort) {
        //把数组所有元素，按照“参数=参数值”的模式用“&”字符拼接成字符串
        $prestr = HelperFunction::createLinkstring($para_sort);

        $mysign = "";
        switch (strtoupper(trim($this->sign_type))) {
            case "MD5" :
                $mysign = HelperFunction::md5Sign($prestr, $this->key);
                break;
            default :
                $mysign = "";
        }

        return $mysign;
    }
1311522
public static function createLinkstringUrlencode($para)
    {
        $arg = "";
        while (list ($key, $val) = each($para)) {
            $arg .= $key . "=" . rawurlencode($val) . "&";
        }
        // 去掉最后一个&字符
        $arg = substr($arg, 0, strlen($arg) - 1);
        
        return $arg;
    }
671658
public function total($param = null)
    {
        $bindParam = [];
        if (is_array($param) && count($param)) {
            $where = null;
            foreach ($param as $key => $value) {
                if (is_int($key)) {  //如果下标是数字，则不用下标拼装sql
                    $where .= $value . ' AND ';
                } else {
                    $where .= "$key=:$key AND ";
                    $bindParam[':' . $key] = $value;
                }
            }
            $where = 'WHERE ' . substr($where, 0, -4);
        } else {
            $where = empty($param) ? '': 'WHERE ' . $param;
        }
        $this->sql = "SELECT COUNT(*) as c FROM {$this->_table} $where";
        $stmt = $this->execute($bindParam);
        return $stmt->fetchObject()->c;
    }