Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-mw committed Jul 28, 2016
1 parent bc40f3d commit a87ed6c
Show file tree
Hide file tree
Showing 8 changed files with 186 additions and 94 deletions.
2 changes: 1 addition & 1 deletion .bowerrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"directory": "vendor/bower_components",
"directory": "userfiles/modules/microweber/api/libs",
"scripts": {
"postinstall": "gulp publish"
}
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"omnipay/common": "*",
"league/csv": "^7.2",
"ezyang/htmlpurifier": "^4.7",
"hashids/hashids": "^1.0",
"giggsey/libphonenumber-for-php": "^7.4"
},
"require-dev": {
Expand Down
195 changes: 126 additions & 69 deletions composer.lock

Large diffs are not rendered by default.

12 changes: 10 additions & 2 deletions src/Microweber/Providers/UrlManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ public function params($skip_ajax = false) {
return $this->param($param = '__MW_GET_ALL_PARAMS__', $skip_ajax);
}




public function param($param, $skip_ajax = false, $force_url = false) {
if ($_POST){
if (isset($_POST['search_by_keyword'])){
Expand Down Expand Up @@ -156,6 +159,8 @@ public function param($param, $skip_ajax = false, $force_url = false) {
return $all_params;
}



public function param_set($param, $value = false, $url = false) {
if ($url==false){
$url = $this->string();
Expand All @@ -170,7 +175,8 @@ public function param_set($param, $value = false, $url = false) {
$segment = explode(':', $segment);
if ($segment[0]==$param){
$segment[1] = $value;
$origsegment = impode(':', $segment);

$origsegment = implode(':', $segment);
$found = true;
$segs_clean[] = $origsegment;
} else {
Expand All @@ -179,11 +185,13 @@ public function param_set($param, $value = false, $url = false) {
}

if ($found==false){

$segment = array();
$segment[] = $param;
$segment[] = $value;
$origsegment = impode(':', $segment);
$origsegment = implode(':', $segment);
$segs_clean[] = $origsegment;

}

$segs_clean = implode('/', $segs_clean);
Expand Down
18 changes: 17 additions & 1 deletion src/Microweber/Utils/Format.php
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ public function clean_html($var, $do_not_strip_tags = false)
$var = $this->strip_unsafe($var);
$purifier = new \HTMLPurifier();
$var = $purifier->purify($var);
// $var = htmlentities($var, ENT_QUOTES, 'UTF-8');
// $var = htmlentities($var, ENT_QUOTES, 'UTF-8');
$var = str_ireplace('<script>', '', $var);
$var = str_ireplace('</script>', '', $var);
$var = str_replace('<?', '&lt;?', $var);
Expand Down Expand Up @@ -755,8 +755,24 @@ public function encrypt($string)
{
return Crypt::encrypt($string);
}

public function decrypt($string)
{
return Crypt::decrypt($string);
}


public function encode_ids($data)
{
$hashids = new \Hashids\Hashids();
return $hashids->encode($data);;
}

public function decode_ids($data)
{
$hashids = new \Hashids\Hashids();
return $hashids->decode($data);
}


}
1 change: 1 addition & 0 deletions src/Microweber/Utils/lib/DisposableEmailChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class DisposableEmailChecker
public function check($mail)
{

// list is from here https://gist.github.com/hassanazimi/d6e49469258d7d06f9f4
$file = __DIR__ . DS . 'disposable_email_addresses.txt';
$file = normalize_path($file, false);

Expand Down
2 changes: 1 addition & 1 deletion src/Microweber/functions/api_callbacks.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

// content

api_expose('get_content_admin');
api_expose_admin('get_content_admin');
api_expose_admin('get_content');
api_expose_admin('get_posts');
api_expose_admin('content_title');
Expand Down
49 changes: 29 additions & 20 deletions src/Microweber/functions/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function site_url($add_string = false)
if (isset($_SERVER['HTTP_HOST'])) {
$pageURL .= $_SERVER['HTTP_HOST'];
} elseif (isset($_SERVER['SERVER_NAME']) and isset($_SERVER['SERVER_PORT']) and $_SERVER['SERVER_PORT'] != '80' and $_SERVER['SERVER_PORT'] != '443') {
$pageURL .= $_SERVER['SERVER_NAME'].':'.$_SERVER['SERVER_PORT'];
$pageURL .= $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT'];
} elseif (isset($_SERVER['SERVER_NAME'])) {
$pageURL .= $_SERVER['SERVER_NAME'];
} elseif (isset($_SERVER['HOSTNAME'])) {
Expand All @@ -70,10 +70,10 @@ function site_url($add_string = false)
if ($d == '') {
$pageURL = $pageURL_host;
} else {
$pageURL_host = rtrim($pageURL_host, '/').'/';
$pageURL_host = rtrim($pageURL_host, '/') . '/';
$d = ltrim($d, '/');
$d = ltrim($d, DIRECTORY_SEPARATOR);
$pageURL = $pageURL_host.$d;
$pageURL = $pageURL_host . $d;
}
if (isset($_SERVER['QUERY_STRING'])) {
$pageURL = str_replace($_SERVER['QUERY_STRING'], '', $pageURL);
Expand All @@ -91,7 +91,7 @@ function site_url($add_string = false)
$unset = false;
foreach ($url_segs as $v) {
if ($unset == true and $d != '') {
unset($url_segs[ $i ]);
unset($url_segs[$i]);
}
if ($v == $d and $d != '') {
$unset = true;
Expand All @@ -103,7 +103,7 @@ function site_url($add_string = false)
$site_url = implode('/', $url_segs);
}

return $site_url.$add_string;
return $site_url . $add_string;
}
}

Expand All @@ -112,7 +112,7 @@ function site_url($add_string = false)
*
* @param string $path
* The directory path.
* @param bool $slash_it
* @param bool $slash_it
* If true, ads a slash at the end, false by default
*
* @return string The formatted string
Expand All @@ -122,22 +122,22 @@ function normalize_path($path, $slash_it = true)
$path_original = $path;
$s = DIRECTORY_SEPARATOR;
$path = preg_replace('/[\/\\\]/', $s, $path);
$path = str_replace($s.$s, $s, $path);
$path = str_replace($s . $s, $s, $path);
if (strval($path) == '') {
$path = $path_original;
}
if ($slash_it == false) {
$path = rtrim($path, DIRECTORY_SEPARATOR);
} else {
$path .= DIRECTORY_SEPARATOR;
$path = rtrim($path, DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR);
$path = rtrim($path, DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR);
}
if (strval(trim($path)) == '' or strval(trim($path)) == '/') {
$path = $path_original;
}
if ($slash_it == false) {
} else {
$path = $path.DIRECTORY_SEPARATOR;
$path = $path . DIRECTORY_SEPARATOR;
$path = reduce_double_slashes($path);
}

Expand Down Expand Up @@ -195,7 +195,7 @@ function lipsum($number_of_characters = false)
function microtime_float()
{
list($msec, $sec) = explode(' ', microtime());
$microtime = (float) $msec + (float) $sec;
$microtime = (float)$msec + (float)$sec;

return $microtime;
}
Expand All @@ -204,7 +204,7 @@ function microtime_float()
* Limits a string to a number of characters.
*
* @param $str
* @param int $n
* @param int $n
* @param string $end_char
*
* @return string
Expand All @@ -225,12 +225,12 @@ function character_limiter($str, $n = 500, $end_char = '&#8230;')

$out = '';
foreach (explode(' ', trim($str)) as $val) {
$out .= $val.' ';
$out .= $val . ' ';

if (strlen($out) >= $n) {
$out = trim($out);

return (strlen($out) == strlen($str)) ? $out : $out.$end_char;
return (strlen($out) == strlen($str)) ? $out : $out . $end_char;
}
}
}
Expand All @@ -239,14 +239,14 @@ function api_url($str = '')
{
$str = ltrim($str, '/');

return site_url('api/'.$str);
return site_url('api/' . $str);
}

function api_nosession_url($str = '')
{
$str = ltrim($str, '/');

return site_url('api_nosession/'.$str);
return site_url('api_nosession/' . $str);
}

function auto_link($text)
Expand Down Expand Up @@ -318,6 +318,15 @@ function url_param($param, $skip_ajax = false)
return mw()->url_manager->param($param, $skip_ajax);
}

function url_set_param($param, $value)
{
return site_url(mw()->url_manager->param_set($param, $value));
}
function url_unset_param($param)
{
return site_url(mw()->url_manager->param_unset($param));
}

/**
* Gets the data from the cache.
*
Expand All @@ -332,9 +341,9 @@ function url_param($param, $skip_ajax = false)
*
* </code>
*
* @param string $cache_id id of the cache
* @param string $cache_group (default is 'global') - this is the subfolder in the cache dir.
* @param bool $expiration_in_seconds You can pass custom cache object or leave false.
* @param string $cache_id id of the cache
* @param string $cache_group (default is 'global') - this is the subfolder in the cache dir.
* @param bool $expiration_in_seconds You can pass custom cache object or leave false.
*
* @return mixed returns array of cached data or false
*/
Expand All @@ -355,14 +364,14 @@ function cache_get($cache_id, $cache_group = 'global', $expiration = false)
* $cache_content = cache_save($data, $cache_id, 'my_cache_group');
* </code>
*
* @param mixed $data_to_cache
* @param mixed $data_to_cache
* your data, anything that can be serialized
* @param string $cache_id
* id of the cache, you must define it because you will use it later to
* retrieve the cached content.
* @param string $cache_group
* (default is 'global') - this is the subfolder in the cache dir.
* @param bool $expiration_in_seconds
* @param bool $expiration_in_seconds
*
* @return bool
*/
Expand Down

0 comments on commit a87ed6c

Please sign in to comment.