コード例 #1
0
ファイル: MyLogger.php プロジェクト: phpsource/openclerk
 function handle(array $record)
 {
     $message = $record['message'];
     $class = "";
     if ($record['level'] >= Logger::WARNING) {
         if ($record['level'] >= Logger::ERROR) {
             $class = "error";
             $message = "[ERROR] " . $message;
         } else {
             $class = "warning";
             $message = "[Warning] " . $message;
         }
     }
     echo "<li class=\"{$class}\">";
     // if it's ONLY a link_to(), then render it as a link
     if (preg_match("#^(.*?)(<a href=\"[^\"<]+\">[^<]+</a>)\$#s", $message, $matches)) {
         echo htmlspecialchars($matches[1]) . $matches[2];
     } else {
         if (is_valid_url($message)) {
             echo link_to($message, $message);
         } else {
             echo htmlspecialchars($message);
         }
     }
     echo "</li>\n";
 }
コード例 #2
0
ファイル: UserOpenID.php プロジェクト: openclerk/users
 /**
  * Try do OpenID validation (with the given redirect).
  * @return the validated LightOpenID object on success
  * @throws UserSignupException if anything bad happened
  */
 static function validateOpenID($openid, $redirect)
 {
     if (!is_valid_url($openid)) {
         throw new UserSignupException("That is not a valid OpenID identity.");
     }
     if (!$redirect) {
         throw new \InvalidArgumentException("No redirect provided.");
     }
     $light = new \LightOpenID(\Openclerk\Config::get("openid_host"));
     if (!$light->mode) {
         // we still need to authenticate
         $light->identity = $openid;
         $light->returnUrl = $redirect;
         redirect($light->authUrl());
         return false;
     } else {
         if ($light->mode == 'cancel') {
             // user has cancelled
             throw new UserSignupException("User has cancelled authentication.");
         } else {
             // otherwise login as necessary
             // optionally check for abuse etc
             if (!\Openclerk\Events::trigger('openid_validate', $light)) {
                 throw new UserSignupException("Login was cancelled by the system.");
             }
             if ($light->validate()) {
                 return $light;
             } else {
                 $error = $light->validate_error ? $light->validate_error : "Please try again.";
                 throw new UserSignupException("OpenID validation was not successful: " . $error);
             }
         }
     }
 }
コード例 #3
0
 function addScript($url, $plugin)
 {
     if (!isset($this->scripts)) {
         $this->scripts = array();
     }
     $this->scripts[] = is_valid_url($url) ? $url : get_javascript_url($url, $plugin, true);
 }
コード例 #4
0
 public function executeGet()
 {
     $valid = $this->hasRequiredParameters($this->requiredParams);
     if ($valid instanceof Frapi_Error) {
         return $valid;
     }
     /*
         get the url param and decode it
     */
     $url = $this->getParam('url');
     $url = urldecode($url);
     /*
         if we're missing 'http' at the beginning, add it
     */
     if (!stristr($url, 'http')) {
         $url = 'http://' . $url;
     }
     if (!is_valid_url($url)) {
         throw new Frapi_Error('ERROR_INVALID_URL');
     }
     try {
         $model = new Spaz_Urlinfo($url);
         $res = $model->get();
     } catch (Exception $e) {
         throw new Frapi_Error($e->getMessage());
     }
     $this->data = $res;
     return $this->toArray();
 }
コード例 #5
0
 public function paper_presentation()
 {
     $user_nick = $this->auth->get_user();
     $user_details = $this->model->is_registered_for_paper_presentation($user_nick);
     $errors = [];
     if (!$user_details && $_SERVER['REQUEST_METHOD'] === 'POST') {
         required_post_params(['contact_number', 'paper_link'], $errors);
         if (!empty($_POST['contact_number']) && !is_valid_phone_number($_POST['contact_number'])) {
             $errors['contact_number'] = 'Please enter a valid phone number';
         }
         if (!empty($_POST['paper_link']) && !is_valid_url($_POST['paper_link'])) {
             $errors['paper_link'] = 'Please enter a valid link';
         }
         if (!$errors) {
             $user_details = ['nick' => $user_nick, 'contact_number' => $_POST['contact_number'], 'paper_link' => $_POST['paper_link']];
             $success = $this->model->register_for_paper_presentation($user_details);
             if (!$success) {
                 $errors['common'] = 'Some unexpected error occured';
             }
         }
     }
     $this->load_view('skeleton_template/header', ['title' => __('Register') . ' · ' . __('Paper Presentation'), 'is_authenticated' => true, 'user_nick' => $user_nick]);
     $this->load_view('contest/paper_presentation', ['user_details' => $user_details, 'errors' => $errors]);
     $this->load_view('skeleton_template/footer');
 }
コード例 #6
0
 private function edit_check(&$category_id, &$name, &$url, &$error)
 {
     $error = '';
     $category_id = isset($_POST['category_id']) ? (int) $_POST['category_id'] : '';
     $name = isset($_POST['name']) ? trim($_POST['name']) : '';
     $url = isset($_POST['url']) ? trim($_POST['url']) : '';
     if (empty($category_id)) {
         $error = '所属分类是必需的!';
     } elseif ($name === '') {
         $error = '名称是必需的!';
     } elseif ($url === '') {
         $error = '网址是必需的!';
     } elseif (!is_valid_url($url)) {
         $error = '网址格式不正确!';
     }
 }
コード例 #7
0
 public function executeGet()
 {
     $valid = $this->hasRequiredParameters($this->requiredParams);
     if ($valid instanceof Frapi_Error) {
         return $valid;
     }
     /*
         get the url param and decode it
     */
     $url = $this->getParam('url');
     $url = urldecode($url);
     /*
         if we're missing 'http' at the beginning, add it
     */
     if (!stristr($url, 'http')) {
         $url = 'http://' . $url;
     }
     if (!is_valid_url($url)) {
         throw new Frapi_Error('ERROR_INVALID_URL');
     }
     try {
         $model = new Spaz_Urlinfo($url);
         $res = $model->get();
     } catch (Exception $e) {
         throw new Frapi_Error($e->getMessage());
     }
     /*
         is content type html?
     */
     if (stripos($res['content_type'], 'text/html') !== FALSE || stripos($res['content_type'], 'application/xhtml+xml' !== FALSE)) {
         try {
             $model = new Spaz_Urltitle($url);
             $res = $model->get();
         } catch (Exception $e) {
             throw new Frapi_Error($e->getMessage());
         }
     } else {
         $title = $res['content_type'];
         $size = (int) $res['download_content_length'];
         if ($size > 0) {
             $title .= ' ' . $this->formatBytes($size);
         }
         $res = array('title' => $title);
     }
     $this->data = $res;
     return $this->toArray();
 }
コード例 #8
0
 protected function validate(&$data, $nonce_name)
 {
     # check in parent class if nonce is legal
     $is_valid = parent::validate($data, $nonce_name);
     if ($is_valid && is_array($data)) {
         $is_valid = true;
         if (empty($data["venue_name"])) {
             $is_valid = false;
             $this->add_db_result("venue_name", "required", "Name is missing");
         }
         if (empty($data["venue_country"])) {
             $is_valid = false;
             $this->add_db_result("venue_country", "required", "Country is missing");
         } else {
             $country_code = get_country_by_name($data["venue_country"]);
             if (!$country_code) {
                 $is_valid = false;
                 $this->add_db_result("venue_country", "field", "Country doesn't exist");
             }
         }
         if (!empty($data["venue_state"]) && $country_code == "US") {
             $state_code = get_state_by_name($data["venue_state"]);
             if (!$state_code) {
                 $state_code = get_state_by_code(strtoupper($data["venue_state"]));
             }
             if (!$state_code) {
                 $is_valid = false;
                 $this->add_db_result("venue_state", "field", "The U.S State code is invalid.");
             }
         } else {
             if ($country_code == "US") {
                 $is_valid = false;
                 $this->add_db_result("venue_state", "field", "State is missing");
             }
         }
         if (!empty($data["venue_url"]) && !is_valid_url($data["venue_url"])) {
             $is_valid = false;
             $this->add_db_result("venue_url", "required", "Venue website in not valid, the required format is http://your_website_url");
         }
         if (!$is_valid) {
             $this->db_result("error", null, array("data" => $this->db_response_msg));
         }
     }
     return $is_valid;
 }
コード例 #9
0
ファイル: init.php プロジェクト: NaszvadiG/activecollab_loc
 /**
  * Handle fatal error
  *
  * @param Error $error
  * @return null
  */
 function handle_fatal_error($error)
 {
     if (DEBUG >= DEBUG_DEVELOPMENT) {
         dump_error($error);
     } else {
         if (instance_of($error, 'RoutingError') || instance_of($error, 'RouteNotDefinedError')) {
             header("HTTP/1.1 404 Not Found");
             print '<h1>Not Found</h1>';
             if (instance_of($error, 'RoutingError')) {
                 print '<p>Page "<em>' . clean($error->getRequestString()) . '</em>" not found.</p>';
             } else {
                 print '<p>Route "<em>' . clean($error->getRouteName()) . '</em>" not mapped.</p>';
             }
             // if
             print '<p><a href="' . assemble_url('homepage') . '">&laquo; Back to homepage</a></p>';
             die;
         }
         // if
         // Send email to administrator
         if (defined('ADMIN_EMAIL') && is_valid_email(ADMIN_EMAIL)) {
             $content = '<p>Hi,</p><p>activeCollab setup at ' . clean(ROOT_URL) . ' experienced fatal error. Info:</p>';
             ob_start();
             dump_error($error, false);
             $content .= ob_get_clean();
             @mail(ADMIN_EMAIL, 'activeCollab Crash Report', $content, "Content-Type: text/html; charset=utf-8");
         }
         // if
         // log...
         if (defined('ENVIRONMENT_PATH') && class_exists('Logger')) {
             $logger =& Logger::instance();
             $logger->logToFile(ENVIRONMENT_PATH . '/logs/' . date('Y-m-d') . '.txt');
         }
         // if
     }
     // if
     $error_message = '<div style="text-align: left; background: white; color: red; padding: 7px 15px; border: 1px solid red; font: 12px Verdana; font-weight: normal;">';
     $error_message .= '<p>Fatal error: activeCollab has failed to executed your request (reason: ' . clean(get_class($error)) . '). Information about this error has been logged and sent to administrator.</p>';
     if (is_valid_url(ROOT_URL)) {
         $error_message .= '<p><a href="' . ROOT_URL . '">&laquo; Back to homepage</a></p>';
     }
     // if
     $error_message .= '</div>';
     print $error_message;
     die;
 }
コード例 #10
0
function do_bbcode_url($action, $attributes, $content, $params, &$node_object)
{
    // 1) the code is being valided
    if ($action == 'validate') {
        // the code is specified as follows: [url]http://.../[/url]
        if (!isset($attributes['default'])) {
            // is this a valid URL?
            return is_valid_url($content);
        }
        // the code is specified as follows: [url=http://.../]Text[/url]
        // is this a valid URL?
        return is_valid_url($attributes['default']);
    } else {
        // the code was specified as follows: [url]http://.../[/url]
        if (!isset($attributes['default'])) {
            return '<a href="' . htmlspecialchars($content) . '">' . htmlspecialchars($content) . '</a>';
        }
        // the code was specified as follows: [url=http://.../]Text[/url]
        return '<a href="' . htmlspecialchars($attributes['default']) . '">' . $content . '</a>';
    }
}
コード例 #11
0
function redirect($uri = '', $method = 'location', $http_response_code = 302)
{
    if (IS_CLI) {
        if (!defined('PHPUNIT_TEST')) {
            echo "Redirecting: {$uri}\n";
            exit;
        } else {
            return;
        }
    }
    if (!is_valid_url($uri)) {
        $uri = site_url($uri);
    }
    switch ($method) {
        case 'refresh':
            header("Refresh:0;url=" . $uri);
            break;
        default:
            header("Location: " . $uri, TRUE, $http_response_code);
            break;
    }
    exit;
}
コード例 #12
0
ファイル: assets.php プロジェクト: agreements/neofrag-cms
function path($file, $file_type = '', $paths = array())
{
    if (func_num_args() == 1) {
        static $paths = array();
        if (!isset($paths[$file])) {
            $paths[$file] = NeoFrag::loader()->db->select('path')->from('nf_files')->where('file_id', $file)->row();
        }
        return $paths[$file] ? url($paths[$file]) : '';
    } else {
        if (is_valid_url($file)) {
            return $file;
        }
        if (!$paths) {
            $paths = NeoFrag::loader()->load->paths['assets'];
        }
        if (!in_array($file_type, array('images', 'css', 'js'))) {
            NeoFrag::loader()->profiler->log(NeoFrag::loader()->lang('invalide_filetype'), Profiler::WARNING);
            return url($file_type . '/' . $file);
        }
        //json_encode backslashe les /
        $file = str_replace('\\/', '/', $file);
        static $assets;
        if (!isset($assets[$checksum = md5(serialize($paths))][$file_type][$file])) {
            foreach ($paths as $path) {
                if (file_exists($file_path = $path . '/' . $file_type . '/' . $file)) {
                    return $assets[$checksum][$file_type][$file] = url(trim_word($file_path, './'));
                }
            }
        } else {
            return $assets[$checksum][$file_type][$file];
        }
        if (file_exists($file)) {
            return url($file);
        }
        return url($file_type . '/' . $file);
    }
}
コード例 #13
0
ファイル: index.php プロジェクト: akbarhossain/webid4me
function foaf_password($config, $realm, $authreqissuer)
{
    /*
    print "<pre>";
    print_r($_SERVER);
    print "</pre>";
    */
    if (empty($_SERVER['HTTP_AUTHORIZATION'])) {
        header('HTTP/1.1 401 Unauthorized');
        header('WWW-Authenticate: Digest realm="' . $realm . '",qop="auth,auth-int",nonce="' . uniqid() . '",opaque="' . md5($realm) . '"');
        //        failed_password_check('Authentication was cancelled', $authreqissuer);
        die;
    }
    // analyze the PHP_AUTH_DIGEST variable
    if (!($data = http_digest_parse($_SERVER['HTTP_AUTHORIZATION']))) {
        failed_password_check('HTTP Digest was incomplete', $authreqissuer);
    }
    //$uri = 'http://'. $data['username'];
    $uri = $data['username'];
    $uri = urldecode($uri);
    if (!is_valid_url($uri)) {
        //        $errmsg = "Authentication Failed - $uri is not a valid username for this service";
        //        failed_password_check($errmsg, $authreqissuer);
        $agent = NULL;
    } else {
        $agent = get_agent($uri);
    }
    // set up db
    $db = new db_class();
    $db->connect('localhost', $config['db_user'], $config['db_pwd'], $config['db_name']);
    $webid = isset($agent) ? $agent['agent']['webid'] : '';
    //    $sql ='select password from passwords where webid="'. $webid . '" or mbox = "' . $data['username'] . '" and active = 1 and verified_mbox = 1 ';
    $sql = 'select password from passwords where webid="' . $webid . '" and active = 1 and verified_mbox = 1 ';
    //    print $sql . "<br/>";
    $results = $db->select($sql);
    if ($row = mysql_fetch_assoc($results)) {
        $pin = $row['password'];
        // generate the valid response
        $A1 = md5($data['username'] . ':' . $realm . ':' . $pin);
        $A2 = md5($_SERVER['REQUEST_METHOD'] . ':' . $data['uri']);
        $valid_response = md5($A1 . ':' . $data['nonce'] . ':' . $data['nc'] . ':' . $data['cnonce'] . ':' . $data['qop'] . ':' . $A2);
        /*
            print "<br/>A1 = md5 (  username= "******" :realm= " . $realm . " :password/pin=  ". $pin . ")<br/>";
            print "A2 = md5 (  request_method = " . $_SERVER['REQUEST_METHOD']. " uri = " . $data['uri'] . ")<br/>";
            print "valid = md5 ( A1 : nonce= " . $data['nonce'] . " :nc= " . $data['nc'] . " :cnonce=  " . $data['cnonce'] . " :qop= " .  $data['qop'] . ")<br/>";
            print "valid response = " . $valid_response . "<br/><br/>";
            print "http digest response = " . $data['response'] . "<br/><br/>";
        */
        if ($valid_response == $data['response']) {
            //           print "auth " . $authreqissuer . "<br/><br/>";
            //           print "webid " . $agent['agent']['webid'] . "<br/><br/>";
            if (isset($authreqissuer)) {
                webid_redirect($authreqissuer, $agent['agent']['webid']);
            } else {
                login_screen($agent['agent']['webid']);
            }
        } else {
            failed_password_check('FOAF Password doesnot match', $authreqissuer);
        }
    } else {
        failed_password_check('FOAF Password doesnot match', $authreqissuer);
    }
}
コード例 #14
0
 /**
  * Delete avatar
  *
  * @param void
  * @return null
  */
 function delete_avatar()
 {
     $user = Contacts::findById(get_id());
     if (!($user instanceof Contact && $user->isUser()) || $user->getDisabled()) {
         flash_error(lang('user dnx'));
         ajx_current("empty");
         return;
     }
     // if
     if (!$user->canUpdateProfile(logged_user())) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     // if
     $redirect_to = array_var($_GET, 'redirect_to');
     if (trim($redirect_to) == '' || !is_valid_url($redirect_to)) {
         $redirect_to = $user->getUpdateAvatarUrl();
     }
     // if
     tpl_assign('redirect_to', $redirect_to);
     if (!$user->hasAvatar()) {
         flash_error(lang('avatar dnx'));
         ajx_current("empty");
         return;
     }
     // if
     try {
         DB::beginWork();
         $user->setUpdatedOn(DateTimeValueLib::now());
         $user->deleteAvatar();
         $user->save();
         ApplicationLogs::createLog($user, ApplicationLogs::ACTION_EDIT);
         DB::commit();
         flash_success(lang('success delete avatar'));
         ajx_current("back");
     } catch (Exception $e) {
         DB::rollback();
         flash_error(lang('error delete avatar'));
         ajx_current("empty");
     }
     // try
 }
コード例 #15
0
    echo $content_for_sidebar;
    ?>
</div>
<?php 
}
// if
?>
            <div class="clear"></div>
          </div>
        </div>
        
        <!--Footer -->
        <div id="footer">
          <div id="copy">
<?php 
if (is_valid_url($owner_company_homepage = owner_company()->getHomepage())) {
    ?>
            <?php 
    echo lang('footer copy with homepage', date('Y'), $owner_company_homepage, clean(owner_company()->getName()));
} else {
    ?>
            <?php 
    echo lang('footer copy without homepage', date('Y'), clean(owner_company()->getName()));
}
// if
?>
          </div>
          <div id="productSignature"><?php 
echo product_signature();
?>
<span id="request_duration"><?php 
コード例 #16
0
 /**
  * Toggle favorite status
  *
  * @param void
  * @return null
  */
 function toggle_favorite()
 {
     if (!logged_user()->isAdministrator()) {
         flash_error('no access permisssions');
         $this->redirectToReferer(get_url('dashboard'));
     }
     $company = Companies::findById(get_id());
     if (!$company instanceof Company) {
         flash_error(lang('company dnx'));
         $this->redirectToReferer(get_url('administration'));
     }
     // if
     if ($company->isOwner()) {
         flash_error('no access permissions');
         $this->redirectToReferer(get_url('dashboard'));
     }
     // if
     $company->setIsFavorite(!$company->isFavorite());
     if (!$company->save()) {
         flash_error(lang('could not save info'));
     }
     $redirect_to = urldecode(array_var($_GET, 'redirect_to'));
     if (trim($redirect_to) == '' || !is_valid_url($redirect_to)) {
         $redirect_to = $company->getViewUrl();
     }
     // if
     $this->redirectToUrl($redirect_to);
 }
コード例 #17
0
	/**
	 * Delete picture
	 *
	 * @param void
	 * @return null
	 */
	function delete_picture() {
		if (logged_user()->isGuest()) {
			flash_error(lang('no access permissions'));
			ajx_current("empty");
			return;
		}
		$contact = Contacts::findById(get_id());
		if(!($contact instanceof Contact)) {
			flash_error(lang('contact dnx'));
			ajx_current("empty");
			return;
		} // if

		if(!$contact->canEdit(logged_user())) {
			flash_error(lang('no access permissions'));
			ajx_current("empty");
			return;
		} // if

		$redirect_to = array_var($_GET, 'redirect_to');
		if((trim($redirect_to)) == '' || !is_valid_url($redirect_to)) {
			$redirect_to = $contact->getUpdatePictureUrl();
		} // if
		tpl_assign('redirect_to', $redirect_to);

		if(!$contact->hasPicture()) {
			flash_error(lang('picture dnx'));
			ajx_current("empty");
			return;
		} // if

		try {
			DB::beginWork();
			$contact->deletePicture();
			$contact->save();
			ApplicationLogs::createLog($contact, ApplicationLogs::ACTION_EDIT);

			DB::commit();

			flash_success(lang('success delete picture'));
			ajx_current("back");
		} catch(Exception $e) {
			DB::rollback();
			flash_error(lang('error delete picture'));
			ajx_current("empty");
		} // try

	} // delete_picture
コード例 #18
0
/**
 * Options validation
 */
function ts_atpu_options_validate($input)
{
    $output = array();
    if (isset($input['url'])) {
        if (is_valid_url($input['url'])) {
            $output['url'] = $input['url'];
        } else {
            add_settings_error('URL', 'url', __('Invalid URL'));
        }
    }
    return apply_filters('ts_atpu_options_validate', $output, $input);
}
コード例 #19
0
ファイル: core_.php プロジェクト: ZenoX2012/CyBerFuN-CoDeX
function is_valid_urls($val)
{
    if ($ok = is_array($val)) {
        foreach ($val as $value) {
            if (($ok = is_valid_url($value)) === false) {
                break;
            }
        }
    }
    return $ok;
}
コード例 #20
0
 protected function validate(&$data, $nonce_name)
 {
     # check in parent class if nonce is legal
     $is_valid = parent::validate($data, $nonce_name);
     if ($is_valid && is_array($data)) {
         $is_valid = true;
         if (empty($data["artist_name"])) {
             $is_valid = false;
             $this->add_db_result("artist_name", "required", "Name is missing");
         }
         if (!empty($data["artist_website_url"]) && !is_valid_url($data["artist_website_url"])) {
             $is_valid = false;
             $this->add_db_result("artist_website_url", "required", "Artist website url in not valid, the required format is http://your_website_url");
         }
         if (!empty($data["artist_flickr"]) && !is_valid_url($data["artist_flickr"])) {
             $is_valid = false;
             $this->add_db_result("artist_flickr", "required", "Flickr url in not valid, the required format is http://your_website_url");
         }
         if (!empty($data["artist_youtube"]) && !is_valid_url($data["artist_youtube"])) {
             $is_valid = false;
             $this->add_db_result("artist_youtube", "required", "YouTube url in not valid, the required format is http://your_website_url");
         }
         if (!empty($data["artist_vimeo"]) && !is_valid_url($data["artist_vimeo"])) {
             $is_valid = false;
             $this->add_db_result("artist_vimeo", "required", "Vimeo url in not valid, the required format is http://your_website_url");
         }
         if (!empty($data["artist_facebook"]) && !is_valid_url($data["artist_facebook"])) {
             $is_valid = false;
             $this->add_db_result("artist_facebook", "required", "Facebook url in not valid, the required format is http://your_website_url");
         }
         if (!empty($data["artist_twitter"]) && !is_valid_url($data["artist_twitter"])) {
             $is_valid = false;
             $this->add_db_result("artist_twitter", "required", "Twitter url in not valid, the required format is http://your_website_url");
         }
         if (!empty($data["artist_myspace"]) && !is_valid_url($data["artist_myspace"])) {
             $is_valid = false;
             $this->add_db_result("artist_myspace", "required", "MySpace url in not valid, the required format is http://your_website_url");
         }
         if (!empty($data["artist_lastfm"]) && !is_valid_url($data["artist_lastfm"])) {
             $is_valid = false;
             $this->add_db_result("artist_lastfm", "required", "Last.FM url in not valid, the required format is http://your_website_url");
         }
         if (!empty($data["artist_reverbnation"]) && !is_valid_url($data["artist_reverbnation"])) {
             $is_valid = false;
             $this->add_db_result("artist_reverbnation", "required", "ReverbNation url in not valid, the required format is http://your_website_url");
         }
         if (!empty($data["artist_tumblr"]) && !is_valid_url($data["artist_tumblr"])) {
             $is_valid = false;
             $this->add_db_result("artist_tumblr", "required", "Tumblr url in not valid, the required format is http://your_website_url");
         }
         if (!empty($data["artist_bandcamp"]) && !is_valid_url($data["artist_bandcamp"])) {
             $is_valid = false;
             $this->add_db_result("artist_bandcamp", "required", "BandCamp url in not valid, the required format is http://your_website_url");
         }
         //			if(!empty($data["artist_email"]) && !is_valid_email($data["artist_email"])) {
         //				$is_valid = false ;
         //				$this->add_db_result("artist_email","required","Email address is not valid, the required format is http://your_website_url");
         //			}
         if (!$is_valid) {
             $this->db_result("error", null, array("data" => $this->db_response_msg));
         }
     }
     return $is_valid;
 }
コード例 #21
0
 /**
  * Delete avatar
  *
  * @param void
  * @return null
  */
 function delete_avatar()
 {
     $user = Users::findById(get_id());
     if (!$user instanceof User) {
         flash_error(lang('user dnx'));
         $this->redirectTo('dashboard');
     }
     // if
     if (!$user->canUpdateProfile(logged_user())) {
         flash_error(lang('no access permissions'));
         $this->redirectTo('dashboard');
     }
     // if
     $redirect_to = array_var($_GET, 'redirect_to');
     if (trim($redirect_to) == '' || !is_valid_url($redirect_to)) {
         $redirect_to = $user->getUpdateAvatarUrl();
     }
     // if
     tpl_assign('redirect_to', $redirect_to);
     if (!$user->hasAvatar()) {
         flash_error(lang('avatar dnx'));
         $this->redirectToUrl($redirect_to);
     }
     // if
     try {
         DB::beginWork();
         $user->deleteAvatar();
         $user->save();
         ApplicationLogs::createLog($user, null, ApplicationLogs::ACTION_EDIT);
         DB::commit();
         flash_success(lang('success delete avatar'));
     } catch (Exception $e) {
         DB::rollback();
         flash_error(lang('error delete avatar'));
     }
     // try
     $this->redirectToUrl($redirect_to);
 }
コード例 #22
0
 /**
  * Validate this object before save
  *
  * @param array $errors
  * @return boolean
  */
 function validate(&$errors)
 {
     if (!$this->validatePresenceOf('name')) {
         $errors[] = lang('company name required');
     }
     // if
     if ($this->validatePresenceOf('email')) {
         if (!is_valid_email($this->getEmail())) {
             $errors[] = lang('invalid email address');
         }
         // if
     }
     // if
     if ($this->validatePresenceOf('homepage')) {
         if (!is_valid_url($this->getHomepage())) {
             $errors[] = lang('company homepage invalid');
         }
         // if
     }
     // if
 }
コード例 #23
0
ファイル: general.php プロジェクト: pnagaraju25/fengoffice
/**
 * Redirect to referer
 *
 * @access public
 * @param string $alternative Alternative URL is used if referer is not valid URL
 * @return null
 */
function redirect_to_referer($alternative = nulls)
{
    $referer = get_referer();
    if (true || !is_valid_url($referer)) {
        if (is_ajax_request()) {
            $alternative = make_ajax_url($alternative);
        }
        redirect_to($alternative);
    } else {
        if (is_ajax_request()) {
            $referer = make_ajax_url($referer);
        }
        redirect_to($referer);
    }
    // if
}
コード例 #24
0
ファイル: User.class.php プロジェクト: 469306621/Languages
 /**
  * Validate data before save
  *
  * @access public
  * @param array $errors
  * @return void
  */
 function validate(&$errors)
 {
     // Validate username if present
     if ($this->validatePresenceOf('username')) {
         if (!$this->validateUniquenessOf('username')) {
             $errors[] = lang('username must be unique');
         }
     } else {
         $errors[] = lang('username value required');
     }
     // if
     if (!$this->validatePresenceOf('token')) {
         $errors[] = lang('password value required');
     }
     // Validate email if present
     if ($this->validatePresenceOf('email')) {
         if (!$this->validateFormatOf('email', EMAIL_FORMAT)) {
             $errors[] = lang('invalid email address');
         }
     } else {
         $errors[] = lang('email value is required');
     }
     // if
     // Validate homepage if present
     if ($this->validatePresenceOf('homepage')) {
         if (!is_valid_url($this->getHomepage())) {
             $errors[] = lang('user homepage invalid');
         }
         // if
     }
     // if
     // Company ID
     if (!$this->validatePresenceOf('company_id')) {
         $errors[] = lang('company value required');
     }
 }
コード例 #25
0
ファイル: common.php プロジェクト: WeKiNGSRO/OHSystem
function LinkUserProfile($username, $website, $class = "")
{
    if (!empty($website) and is_valid_url($website)) {
        ?>
  <a <?php 
        echo $class;
        ?>
 href="<?php 
        echo $website;
        ?>
"><?php 
        echo $username;
        ?>
</a>
  <?php 
    } else {
        echo $username;
    }
}
コード例 #26
0
ファイル: index.php プロジェクト: jasonheecs/site-checklist
	<link href='//maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css' rel='stylesheet' type='text/css'>
	<link rel="stylesheet" href="css/custom.css">
</head>
<body>
	<?php 
$page = 'home';
//default page is homepage
$errors = array();
// error messages
$site_url = '';
if (isset($_GET['site']) && !empty($_GET['site'])) {
    $site_url = \Classes\Utility::xss_clean($_GET['site']);
    if (strpos($site_url, 'http') === false && strpos($site_url, 'https') === false) {
        $site_url = 'http://' . $site_url;
    }
    if (is_valid_url($site_url)) {
        $page = 'checklist';
    } else {
        $errors[] = 'The URL ' . $site_url . ' is invalid.';
    }
}
//list of mvcs
$data = array('home' => array('model' => 'IndexModel', 'view' => 'IndexView', 'controller' => 'IndexController'), 'checklist' => array('model' => 'SiteChecklist', 'view' => 'ChecklistView', 'controller' => 'ChecklistController'));
foreach ($data as $key => $components) {
    if ($page == $key) {
        $model = '\\Models\\' . $components['model'];
        $view = '\\Views\\' . $components['view'];
        $controller = '\\Controllers\\' . $components['controller'];
        break;
    }
}
コード例 #27
0
 protected function validate(&$data, $nonce_name)
 {
     # check in parent class if nonce is legal
     global $wpdb;
     $is_valid = parent::validate($data, $nonce_name);
     if ($is_valid && is_array($data)) {
         $is_valid = true;
         // Check if date is empty
         if (empty($data["event_start_date"])) {
             $is_valid = false;
             $this->add_db_result("event_start_date", "required", "Start Date is missing");
         } else {
             if ($data["event_start_date"] === null) {
                 $is_valid = false;
                 $this->add_db_result("event_start_date", "field", "Start Date format is not valid");
             }
         }
         // Multi Day Event
         // Check if date format is valid
         if ($data["event_end_date"] === null) {
             $is_valid = false;
             $this->add_db_result("event_end_date", "field", "End Date is missing");
         }
         // Check if start date is lower\equel to end date
         if (!empty($data["event_start_date"]) && !empty($data["event_end_date"])) {
             if (strtotime($data["event_start_date"]) > strtotime($data["event_end_date"])) {
                 $is_valid = false;
                 $this->add_db_result("event_end_date", "required", "Event can't end before it starts");
             }
         }
         if (isset($data["event_tour_id"])) {
             if (!is_numeric($data["event_tour_id"])) {
                 $is_valid = false;
                 $this->add_db_result("event_tour_id", "required", "Tour information is invalid");
             }
         } else {
             $tour_name = trim($data["tour_name"]);
             if (!empty($tour_name) && !is_numeric($tour_name)) {
                 $is_tour = $wpdb->get_row("SELECT tour_id FROM " . WORDTOUR_TOUR . " WHERE UPPER(tour_name)='" . trim(strtoupper($data["tour_name"]) . "'"), "ARRAY_A");
                 if ($is_tour) {
                     $data["event_tour_id"] = $is_tour["tour_id"];
                 } else {
                     $is_valid = false;
                     $this->add_db_result("tour_name", "required", "Tour '{$data['tour_name']}' doesn't exist");
                 }
             }
         }
         if (isset($data["event_venue_id"])) {
             if (!is_numeric($data["event_venue_id"])) {
                 $is_valid = false;
                 $this->add_db_result("event_venue_id", "required", "Venue information is invalid");
             }
         } else {
             if (empty($data["venue_name"])) {
                 $is_valid = false;
                 $this->add_db_result("venue_name", "required", "Venue is missing");
             } else {
                 if (!is_numeric($data["venue_name"])) {
                     $is_venue = $wpdb->get_row("SELECT venue_id FROM " . WORDTOUR_VENUES . " WHERE UPPER(venue_name)='" . trim(strtoupper($data["venue_name"]) . "'"), "ARRAY_A");
                     if ($is_venue) {
                         $data["event_venue_id"] = $is_venue["venue_id"];
                     } else {
                         $is_valid = false;
                         $this->add_db_result("venue_name", "required", "Venue '{$data['venue_name']}' doesn't exist");
                     }
                 }
             }
         }
         if (isset($data["event_artist_id"])) {
             if (!is_numeric($data["event_artist_id"])) {
                 $is_valid = false;
                 $this->add_db_result("event_artist_id", "required", "Artist information is invalid");
             }
         } else {
             if (empty($data["artist_name"])) {
                 $is_valid = false;
                 $this->add_db_result("artist_name", "required", "Artist is missing");
             } else {
                 if (!is_numeric($data["artist_name"])) {
                     $is_artist = $wpdb->get_row("SELECT artist_id FROM " . WORDTOUR_ARTISTS . " WHERE UPPER(artist_name)='" . trim(strtoupper($data["artist_name"]) . "'"), "ARRAY_A");
                     if ($is_artist) {
                         $data["event_artist_id"] = $is_artist["artist_id"];
                     } else {
                         $is_valid = false;
                         $this->add_db_result("artist_name", "required", "Artist '{$data['artist_name']}' doesn't exist");
                     }
                 }
             }
         }
         if (isset($data["event_more_artists"])) {
             $more_artists = json_decode(stripslashes($data["event_more_artists"]));
             $more_artists_exist_error = array();
             $more_artists_error = array();
             $more_artists_is_valid = 1;
             $more_artists_id = array();
             if (is_array($more_artists)) {
                 foreach ($more_artists as $artist_name) {
                     $name = addslashes(trim(strtoupper($artist_name)));
                     if (!empty($name)) {
                         // check if artist exist in the system
                         $is_artist = $wpdb->get_row($wpdb->prepare("SELECT artist_id FROM " . WORDTOUR_ARTISTS . " WHERE UPPER(artist_name)='" . $name . "'"), "ARRAY_A");
                         //print_r($wpdb);
                         if (!$is_artist) {
                             $is_valid = false;
                             $more_artists_is_valid = 0;
                             $more_artists_exist_error[] = "<i>'{$artist_name}'</i>";
                         } else {
                             if ($name == trim(strtoupper($data["artist_name"]))) {
                                 $is_valid = false;
                                 $more_artists_is_valid = 0;
                                 $more_artists_error[] = "Additional Artist <i>'{$artist_name}'</i> is already assigned";
                             } else {
                                 $more_artists_id[] = $is_artist["artist_id"];
                             }
                         }
                     }
                 }
                 if (!$more_artists_is_valid) {
                     $more_artists_msg = "";
                     if (count($more_artists_exist_error) > 0) {
                         $more_artists_msg .= "Additional Artist " . implode(", ", $more_artists_exist_error) . " doesn't exist, ";
                     }
                     if (count($more_artists_error) > 0) {
                         $more_artists_msg .= implode(", ", $more_artists_error);
                     }
                     $this->add_db_result("event_more_artists", "required", $more_artists_msg);
                 } else {
                     $data["event_more_artists"] = array_unique($more_artists_id);
                 }
             }
         }
         if (!empty($data["tkts_url"]) && !is_valid_url($data["tkts_url"])) {
             $is_valid = false;
             $this->add_db_result("tkts_url", "required", "Buy Tickt url in not valid, the required format is http://your_website_url");
         }
         if (!$is_valid) {
             $this->db_result("error", null, array("data" => $this->db_response_msg));
         }
     }
     return $is_valid;
 }
コード例 #28
0
ファイル: page.php プロジェクト: rjv/Project-Pier
 /**
 * Add external stylesheet file to page
 *
 * @access public
 * @param string $href
 * @param string $title
 * @param string $media
 * @return null
 */
 function add_stylesheet_to_page($href, $title = null, $media = null) {
   if (!is_valid_url($href)) {
     $href = get_stylesheet_url($href);
   }
   $page = PageDescription::instance();
   $attributes = array('type' => 'text/css');
   if ($title) $attributes['title'] = $title;
   if ($media) $attributes['media'] = $media;
   $page->addRelLink($href, 'Stylesheet', $attributes); // addRelLink
 } // add_stylesheet_to_page
コード例 #29
0
 /**
  * Set link value
  *
  * @param string $value
  * @return null
  * @throws InvalidParamError
  */
 function setLink($value)
 {
     if (!is_null($value) && !is_valid_url($value)) {
         throw new InvalidParamError('value', $value, "{$value} is not a valid URL");
     }
     // if
     $this->link = $value;
 }
コード例 #30
0
ファイル: clean.inc.php プロジェクト: henrytrager/Torrage
      */
     unset($trackers[$id]);
     continue;
 }
 // Remove trackers not starting with udp:// http:// dht://
 if (!(stripos(' ' . $tracker, 'udp://') == 1 || stripos(' ' . $tracker, 'dht://') == 1 || stripos(' ' . $tracker, 'http://') == 1)) {
     unset($trackers[$id]);
     continue;
 }
 // Check for double protocol prefixes.
 if (stripos($tracker, '://', 5) !== FALSE) {
     unset($trackers[$id]);
     continue;
 }
 // Check for illegal characters.
 if (!is_valid_url($tracker)) {
     unset($trackers[$id]);
     continue;
 }
 // Remove url's with two .. (dots) in a row..
 if (strstr($trhost, '..')) {
     unset($trackers[$id]);
     continue;
 }
 // Remove url's where any of the last 3 charrs is a number
 if (is_numeric(substr($trhost, strlen($trhost) - 1, 1)) || is_numeric(substr($trhost, strlen($trhost) - 2, 1)) || is_numeric(substr($trhost, strlen($trhost) - 3, 1))) {
     unset($trackers[$id]);
     continue;
 }
 // Remove url's that have no . (dot) in the host part
 if (!strstr($trhost, '.')) {