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


PHP Log::insert方法代码示例

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


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

示例1: factory

 /**
  * Factory method.
  *
  * @static
  * @access   public
  * @since    1.0.0-alpha
  * @version  1.0.0-alpha
  */
 public static function factory()
 {
     self::$defaultLifeTime = Config::get('cache.lifetime', 3600);
     $driverName = ucfirst(Config::get('cache.driver'));
     $driver = '\\Plethora\\Cache\\Drivers\\' . $driverName . 'CacheDriver';
     static::$driver = new $driver();
     Log::insert('Cache type "' . Config::get('cache.driver') . '" initialized!');
 }
开发者ID:ktrzos,项目名称:plethora,代码行数:16,代码来源:Cache.php

示例2: conditional_insert

 static function conditional_insert($type, $ref_id, $user_id = 0, $seconds = 0, $annotation = false)
 {
     global $db, $globals;
     if (!Log::get_date($type, $ref_id, $user_id, $seconds)) {
         return Log::insert($type, $ref_id, $user_id, $annotation);
     }
     return false;
 }
开发者ID:manelio,项目名称:woolr,代码行数:8,代码来源:log.php

示例3: register

 function register($accion, $parametro = '')
 {
     $log = new Log();
     $log->id_accion = $accion;
     $log->fecha = date("Y/m/d");
     $log->hora = date("H:i:s");
     $log->parametro = $parametro ? $parametro : NULL;
     $log->id_usuario = RegistryHelper::getIdUsuario();
     return $log->insert();
 }
开发者ID:Nilphy,项目名称:moteguardian,代码行数:10,代码来源:clase.Logger.php

示例4: do_login

function do_login()
{
    global $current_user, $globals;
    $form_ip_check = check_form_auth_ip();
    $previous_login_failed = Log::get_date('login_failed', $globals['form_user_ip_int'], 0, 300);
    echo '<form action="' . get_auth_link() . 'login.php" id="xxxthisform" method="post">' . "\n";
    if ($_POST["processlogin"] == 1) {
        // Check the IP, otherwise redirect
        if (!$form_ip_check) {
            header('HTTP/1.1 303 Load');
            header("Location: http://" . $_COOKIE['return_site'] . $globals['base_url'] . "login.php");
            die;
        }
        $username = clean_input_string(trim($_POST['username']));
        $password = trim($_POST['password']);
        // Check form
        if (($previous_login_failed > 2 || $globals['captcha_first_login'] == true && !UserAuth::user_cookie_data()) && !ts_is_human()) {
            Log::insert('login_failed', $globals['form_user_ip_int'], 0);
            recover_error(_('el código de seguridad no es correcto'));
        } elseif (strlen($password) > 0 && $current_user->Authenticate($username, $password, $_POST['persistent']) == false) {
            Log::insert('login_failed', $globals['form_user_ip_int'], 0);
            recover_error(_('usuario o email inexistente, sin validar, o clave incorrecta'));
            $previous_login_failed++;
        } else {
            UserAuth::check_clon_from_cookies();
            header('HTTP/1.1 303 Load');
            if (!empty($_REQUEST['return'])) {
                header('Location: http://' . $_COOKIE['return_site'] . $_REQUEST['return']);
            } else {
                header('Location: http://' . $_COOKIE['return_site'] . $globals['base_url']);
            }
            die;
        }
    }
    echo '<p><label for="name">' . _('usuario o email') . ':</label><br />' . "\n";
    echo '<input type="text" name="username" size="25" tabindex="1" id="name" value="' . htmlentities($username) . '" /></p>' . "\n";
    echo '<p><label for="password">' . _('clave') . ':</label><br />' . "\n";
    echo '<input type="password" name="password" id="password" size="25" tabindex="2"/></p>' . "\n";
    echo '<p><label for="remember">' . _('recuérdame') . ': </label><input type="checkbox" name="persistent" id="remember" tabindex="3"/></p>' . "\n";
    // Print captcha
    if ($previous_login_failed > 2 || $globals['captcha_first_login'] == true && !UserAuth::user_cookie_data()) {
        ts_print_form();
    }
    get_form_auth_ip();
    echo '<p><input type="submit" value="login" tabindex="4" />' . "\n";
    echo '<input type="hidden" name="processlogin" value="1"/></p>' . "\n";
    echo '<input type="hidden" name="return" value="' . htmlspecialchars($_REQUEST['return']) . '"/>' . "\n";
    echo '</form>' . "\n";
    echo '<div><strong><a href="login.php?op=recover">' . _('¿has olvidado la contraseña?') . '</a></strong></div>' . "\n";
    echo '<div style="margin-top: 30px">';
    print_oauth_icons($_REQUEST['return']);
    echo '</div>' . "\n";
}
开发者ID:brainsqueezer,项目名称:fffff,代码行数:53,代码来源:login.php

示例5: loginAction

 public function loginAction()
 {
     $request = $this->getRequest();
     $config = Zend_Registry::get('config');
     // Check if we have a POST request
     if (!$request->isPost()) {
         $this->_helper->redirector('index', 'index');
     }
     $lang = $this->getRequest()->getPost('lang');
     if (isset($lang) && $lang != null) {
         $langNamespace = new Zend_Session_Namespace('Lang');
         $langNamespace->lang = $lang;
     }
     // Get our form and validate it
     $form = new LoginForm();
     if (!$form->isValid($request->getPost())) {
         // Invalid entries
         $this->_flashMessenger->addMessage('Email or Password is required and its length should between 6 and 20');
         $this->view->form = $form;
         $this->_helper->redirector('loginfailed', 'index');
     }
     // Get our authentication adapter and check credentials
     $adapter = new LoginAuthAdapter($form->getValue('email'), $form->getValue('password'));
     $auth = Zend_Auth::getInstance();
     $result = $auth->authenticate($adapter);
     if ($result->isValid()) {
         // We're authenticated! Redirect to the home page
         $db = Zend_Registry::get('db');
         $consumer_id = $db->fetchOne("SELECT id FROM consumer WHERE email = :temp or login_phone = :temp and state='ACTIVE'", array('temp' => $form->getValue('email')));
         $consumerModel = new Consumer();
         $consumer = $consumerModel->find($consumer_id)->current();
         $authNamespace = new Zend_Session_Namespace('Zend_Auth');
         $authNamespace->user = $consumer;
         $authNamespace->role = 'consumer';
         //log
         $logModel = new Log();
         $logId = $logModel->insert(array('consumer_id' => $consumer->id, 'date' => date("Y-m-d H:i:s"), 'event' => 'LOGIN'));
         $url = $form->getValue('url');
         if (isset($url) && !empty($url)) {
             $this->_redirector = $this->_helper->getHelper('Redirector');
             $this->_redirector->gotoUrl($url);
         } else {
             $this->_helper->redirector('index', 'home');
         }
     } else {
         // Invalid credentials
         $this->_flashMessenger->addMessage('Invalid credentials provided');
         $this->view->form = $form;
         $this->_helper->redirector('loginfailed', 'index');
     }
 }
开发者ID:omusico,项目名称:wildfire_php,代码行数:51,代码来源:LoginController.php

示例6: Login

 public function Login()
 {
     try {
         if (!empty($_POST['usuario']) and !empty($_POST['password']) and !empty($_POST['session'])) {
             $db = new Conexion();
             $this->usuario = $db->real_escape_string($_POST['usuario']);
             $this->password = $db->real_escape_string($_POST['password']);
             //$this->password = $this->Encript($_POST['password']);
             $sql = $db->query("SELECT * FROM claves WHERE Nombre='{$this->usuario}' AND Clave='{$this->password}';");
             if ($db->rows($sql) > 0) {
                 $datos = $db->recorrer($sql);
                 $id = $datos['Id'];
                 $_SESSION['id'] = $id;
                 $_SESSION['usuario'] = $datos['Nombre'];
                 $_SESSION['nivel'] = $datos['Nivel'];
                 $_SESSION['controlfases'] = $datos['ControlFases'];
                 $_SESSION['cuentaverexpedientes'] = $datos['CuentaVerExpedientes'];
                 $_SESSION['indemnizacion'] = $datos['Indemnizacion'];
                 $_SESSION['modificaraseguradora'] = $datos['Modaseguradora'];
                 $_SESSION['verfacturas'] = $datos['VerFacturas'];
                 $_SESSION['beneficio'] = $datos['beneficio'];
                 $_SESSION['facturas'] = $datos['facturas'];
                 $_SESSION['modificarsiniestro'] = $datos['modsiniestro'];
                 $_SESSION['tramitadores'] = $datos['tramitadores'];
                 $log = new Log("log", "./logs/");
                 $log->insert('Acceso al programa por el usuario ' . $_SESSION['usuario'], false, false, false);
                 if ($_POST['session'] == true) {
                     ini_set('session.cookie_lifetime', time() + 60 * 60 * 24 * 2);
                 }
                 echo 1;
             } else {
                 $log = new Log("log", "./logs/");
                 $log->insert('Acceso no autorizado', false, false, false);
                 throw new Exception(2);
             }
             $db->liberar($sql);
             $db->close();
         } else {
             throw new exception('Error: Datos vacios');
         }
     } catch (exception $login) {
         echo $login->getMessage();
     }
 }
开发者ID:loro102,项目名称:rumbo-core,代码行数:44,代码来源:class.Acceso.php

示例7: save_profile

function save_profile()
{
    global $db, $user, $current_user, $globals, $admin_mode, $site_key, $bio_max;
    $errors = 0;
    // benjami: control added (2005-12-22)
    $new_pass = false;
    $messages = array();
    $form_hash = md5($site_key . $user->id . $current_user->user_id);
    if (isset($_POST['disabledme']) && intval($_POST['disable']) == 1 && $_POST['form_hash'] == $form_hash && $_POST['user_id'] == $current_user->user_id) {
        $old_user_login = $user->username;
        $old_user_id = $user->id;
        $user->disable(true);
        Log::insert('user_delete', $old_user_id, $old_user_id);
        syslog(LOG_NOTICE, "Meneame, disabling {$old_user_id} ({$old_user_login}) by {$current_user->user_login} -> {$user->username} ");
        $current_user->Logout(get_user_uri($user->username));
        die;
    }
    if (!isset($_POST['save_profile']) || !isset($_POST['process']) || $_POST['user_id'] != $current_user->user_id && !$admin_mode) {
        return;
    }
    if (empty($_POST['form_hash']) || $_POST['form_hash'] != $form_hash) {
        array_push($messages, _('Falta la clave de control'));
        $errors++;
    }
    if (!empty($_POST['username']) && trim($_POST['username']) != $user->username) {
        $newname = trim($_POST['username']);
        if (strlen($newname) < 3) {
            array_push($messages, _('nombre demasiado corto'));
            $errors++;
        }
        if (!check_username($newname)) {
            array_push($messages, _('nombre de usuario erróneo, caracteres no admitidos'));
            $errors++;
        } elseif (user_exists($newname, $user->id)) {
            array_push($messages, _('el usuario ya existe'));
            $errors++;
        } else {
            $user->username = $newname;
        }
    }
    if (!empty($_POST['bio']) || $user->bio) {
        $bio = clean_text($_POST['bio'], 0, false, $bio_max);
        if ($bio != $user->bio) {
            $user->bio = $bio;
        }
    }
    if ($user->email != trim($_POST['email']) && !check_email(trim($_POST['email']))) {
        array_push($messages, _('el correo electrónico no es correcto'));
        $errors++;
    } elseif (!$admin_mode && trim($_POST['email']) != $current_user->user_email && email_exists(trim($_POST['email']), false)) {
        array_push($messages, _('ya existe otro usuario con esa dirección de correo'));
        $errors++;
    } else {
        $user->email = trim($_POST['email']);
    }
    $user->url = htmlspecialchars(clean_input_url($_POST['url']));
    // Check IM address
    if (!empty($_POST['public_info'])) {
        $_POST['public_info'] = htmlspecialchars(clean_input_url($_POST['public_info']));
        $public = $db->escape($_POST['public_info']);
        $im_count = intval($db->get_var("select count(*) from users where user_id != {$user->id} and user_level != 'disabled' and user_level != 'autodisabled' and user_public_info='{$public}'"));
        if ($im_count > 0) {
            array_push($messages, _('ya hay otro usuario con la misma dirección de MI, no se ha grabado'));
            $_POST['public_info'] = '';
            $errors++;
        }
    }
    $user->phone = $_POST['phone'];
    $user->public_info = htmlspecialchars(clean_input_url($_POST['public_info']));
    // End check IM address
    if ($user->id == $current_user->user_id) {
        // Check phone number
        if (!empty($_POST['phone'])) {
            if (!preg_match('/^\\+[0-9]{9,16}$/', $_POST['phone'])) {
                array_push($messages, _('número telefónico erróneo, no se ha grabado'));
                $_POST['phone'] = '';
                $errors++;
            } else {
                $phone = $db->escape($_POST['phone']);
                $phone_count = intval($db->get_var("select count(*) from users where user_id != {$user->id} and user_level != 'disabled' and user_level != 'autodisabled' and user_phone='{$phone}'"));
                if ($phone_count > 0) {
                    array_push($messages, _('ya hay otro usuario con el mismo número, no se ha grabado'));
                    $_POST['phone'] = '';
                    $errors++;
                }
            }
        }
        $user->phone = $_POST['phone'];
        // End check phone number
    }
    // Verifies adsense code
    if ($globals['external_user_ads']) {
        $_POST['adcode'] = trim($_POST['adcode']);
        $_POST['adchannel'] = trim($_POST['adchannel']);
        if (!empty($_POST['adcode']) && $user->adcode != $_POST['adcode']) {
            if (!preg_match('/pub-[0-9]{16}$/', $_POST['adcode'])) {
                array_push($messages, _('código AdSense incorrecto, no se ha grabado'));
                $_POST['adcode'] = '';
                $errors++;
            } else {
//.........这里部分代码省略.........
开发者ID:GallardoAlba,项目名称:Meneame,代码行数:101,代码来源:profile.php

示例8: store_user

 function store_user()
 {
     global $db, $globals;
     // syslog(LOG_INFO, "store_user: ". $this->return. "  COOKIE: ".$_COOKIE['return']);
     $user = $this->user;
     if (!$this->secret) {
         $this->secret = $this->service . "-" . $globals['now'];
     }
     if (user_exists($this->username)) {
         $i = 1;
         while (user_exists($this->username . "_{$i}")) {
             $i++;
         }
         $user->username = $this->username . "_{$i}";
     } else {
         $user->username = $this->username;
     }
     if (!$user->pass || preg_match('/$\\$/', $user->pass)) {
         $user->pass = "\${$this->service}\${$this->secret}";
     }
     if (!$user->names && $this->names) {
         $user->names = $this->names;
     }
     if (!$user->url && $this->url) {
         $user->url = $this->url;
     }
     if ($user->id == 0) {
         $user->date = $globals['now'];
         $user->ip = $globals['user_ip'];
         $user->email = $this->username . '@' . $this->service;
         $user->email_register = $this->username . '@' . $this->service;
         $user->username_register = $user->username;
     }
     syslog(LOG_NOTICE, "Meneame new user from {$this->service}: {$user->username}, {$user->names}");
     $user->store();
     Log::insert('user_new', $user->id, $user->id);
     $db->query("update users set user_validated_date = now() where user_id = {$user->id} and user_validated_date is null");
     if ($this->avatar) {
         require_once mnminclude . 'avatars.php';
         avatars_get_from_url($user->id, $this->avatar);
     }
 }
开发者ID:brainsqueezer,项目名称:fffff,代码行数:42,代码来源:base.php

示例9: first

 function first()
 {
     $db = Zend_Registry::get('db');
     $str = $_COOKIE;
     $uid = substr($str["weibojs_1864117054"], -10);
     if (isset($uid)) {
         $adapter = new WeiboLoginAuthAdapter($uid);
         $auth = Zend_Auth::getInstance();
         $result = $auth->authenticate($adapter);
         $consumerModel = new Consumer();
         $consumer_id = $db->fetchOne("SELECT id FROM consumer WHERE weiboid = :temp and state='ACTIVE'", array('temp' => $uid));
         $consumer = $consumerModel->find($consumer_id)->current();
         if ($result->isValid()) {
             $authNamespace = new Zend_Session_Namespace('Zend_Auth');
             $authNamespace->user = $consumer;
             $authNamespace->role = 'consumer';
             $logModel = new Log();
             $logId = $logModel->insert(array('consumer_id' => $consumer->id, 'date' => date("Y-m-d H:i:s"), 'event' => 'LOGIN'));
             $this->_helper->redirector('index', 'tag');
         }
     }
 }
开发者ID:omusico,项目名称:wildfire_php,代码行数:22,代码来源:WeibologinController.php

示例10: callbackAction

 function callbackAction()
 {
     // 		if($this->_request->getParam('state')== $_SESSION['state']) //csrf
     // 	    {
     $token_url = "https://graph.qq.com/oauth2.0/token?grant_type=authorization_code&" . "client_id=" . $_SESSION["appid"] . "&redirect_uri=" . urlencode($_SESSION["callback"]) . "&client_secret=" . $_SESSION["appkey"] . "&code=" . $_REQUEST["code"];
     $response = get_url_contents($token_url);
     if (strpos($response, "callback") !== false) {
         $lpos = strpos($response, "(");
         $rpos = strrpos($response, ")");
         $response = substr($response, $lpos + 1, $rpos - $lpos - 1);
         $msg = json_decode($response);
         if (isset($msg->error)) {
             echo "<h3>error:</h3>" . $msg->error;
             echo "<h3>msg  :</h3>" . $msg->error_description;
             exit;
         }
     }
     $params = array();
     parse_str($response, $params);
     //debug
     //print_r($params);
     //set access token to session
     $_SESSION["access_token"] = $params["access_token"];
     include_once "user/get_user_info.php";
     $graph_url = "https://graph.qq.com/oauth2.0/me?access_token=" . $_SESSION['access_token'];
     $str = get_url_contents($graph_url);
     if (strpos($str, "callback") !== false) {
         $lpos = strpos($str, "(");
         $rpos = strrpos($str, ")");
         $str = substr($str, $lpos + 1, $rpos - $lpos - 1);
     }
     $me = json_decode($str);
     if (isset($me->error)) {
         echo "<h3>error:</h3>" . $me->error;
         echo "<h3>msg  :</h3>" . $me->error_description;
         exit;
     }
     //debug
     //echo("Hello " . $user->openid);
     //set openid to session
     $_SESSION["openid"] = $me->openid;
     $user = get_user_info();
     $uid = $me->openid;
     $adapter = new QQLoginAuthAdapter($uid);
     $auth = Zend_Auth::getInstance();
     $result = $auth->authenticate($adapter);
     $consumerModel = new Consumer();
     $db = Zend_Registry::get('db');
     $consumer_id = $db->fetchOne("SELECT id FROM consumer WHERE qqid = :temp and state='ACTIVE'", array('temp' => $uid));
     $consumer = $consumerModel->find($consumer_id)->current();
     if ($result->isValid()) {
         $authNamespace = new Zend_Session_Namespace('Zend_Auth');
         $authNamespace->user = $consumer;
         $authNamespace->role = 'consumer';
         $logModel = new Log();
         $logId = $logModel->insert(array('consumer_id' => $consumer->id, 'date' => date("Y-m-d H:i:s"), 'event' => 'LOGIN'));
         $this->_helper->redirector('index', 'home');
     } else {
         $this->_helper->redirector('register', 'register');
     }
     // 	    }
     // 	    else
     // 	    {
     // 	        echo("The state does not match. You may be a victim of CSRF.");
     // 	    }
 }
开发者ID:omusico,项目名称:wildfire_php,代码行数:66,代码来源:QqloginController.php

示例11: do_save

function do_save($link)
{
    global $dblang, $globals, $current_user, $db;
    $link->status = $link->sub_status;
    $site_properties = SitesMgr::get_extended_properties();
    // Store previous value for the log
    $link_old = new stdClass();
    $link_old->url = $link->url;
    $link_old->title = $link->title;
    $link_old->content = $link->content;
    $link_old->tags = $link->tags;
    $link_old->status = $link->status;
    $link_old->sub_id = $link->sub_id;
    $link->read_content_type_buttons($_POST['type']);
    $link->sub_id = intval($_POST['sub_id']);
    if ($link->sub_id != $link_old->sub_id) {
        $link->sub_changed = true;
        // To force to delete old statuses with another origin
    }
    if ($current_user->admin || $current_user->user_level == 'blogger' || SitesMgr::is_owner()) {
        if (!empty($_POST['url'])) {
            $link->url = clean_input_url($_POST['url']);
        }
        if ($_POST['thumb_delete']) {
            $link->delete_thumb();
        }
        if ($_POST['uri_update']) {
            $link->get_uri();
        }
        if ($_POST['thumb_get']) {
            $link->get_thumb();
        } elseif (!empty($_POST['thumb_url'])) {
            $url = clean_input_url($_POST['thumb_url']);
            $link->get_thumb(false, $url);
        }
    }
    $link->title = $_POST['title'];
    $link->content = $_POST['bodytext'];
    $link->tags = tags_normalize_string($_POST['tags']);
    $errors = link_edit_errors($link);
    // change the status
    if ($_POST['status'] != $link->status && ($_POST['status'] == 'autodiscard' || $current_user->admin || SitesMgr::is_owner()) && preg_match('/^[a-z]{4,}$/', $_POST['status']) && (!$link->is_discarded() || $current_user->admin || SitesMgr::is_owner())) {
        if (preg_match('/discard|abuse|duplicated|autodiscard/', $_POST['status'])) {
            // Insert a log entry if the link has been manually discarded
            $insert_discard_log = true;
        }
        $link->status = $_POST['status'];
    }
    if (!$errors) {
        if (empty($link->uri)) {
            $link->get_uri();
        }
        // Check the blog_id
        $blog_id = Blog::find_blog($link->url, $link->id);
        if ($blog_id > 0 && $blog_id != $link->blog) {
            $link->blog = $blog_id;
        }
        $db->transaction();
        $link->store();
        // Disabled table tags
        // tags_insert_string($link->id, $dblang, $link->tags, $link->date);
        // Insert edit log/event if the link it's newer than 15 days
        if ($globals['now'] - $link->date < 86400 * 15) {
            if ($insert_discard_log) {
                // Insert always a link and discard event if the status has been changed to discard
                Log::insert('link_discard', $link->id, $current_user->user_id);
                if ($link->author == $current_user->user_id) {
                    // Don't save edit log if it's discarded by an admin
                    Log::insert('link_edit', $link->id, $current_user->user_id);
                }
            } elseif ($link->votes > 0) {
                Log::conditional_insert('link_edit', $link->id, $current_user->user_id, 60, serialize($link_old));
            }
        }
        // Check this one is a draft, allows the user to save and send it to the queue
        if ($link->votes == 0 && $link->status != 'queued' && $link->author == $current_user->user_id) {
            $link->enqueue();
        }
        $db->commit();
    }
    $link->read();
    $link->permalink = $link->get_permalink();
    Haanga::Load('link/edit_result.html', compact('link', 'errors'));
}
开发者ID:manelio,项目名称:woolr,代码行数:84,代码来源:editlink.php

示例12: set

 /**
  * Set a value in current user session
  *
  * @static
  * @access   public
  * @param    string $name  new session variable name
  * @param    mixed  $value new session variable value
  * @throws   Exception
  * @since    1.0.0-alpha
  * @version  1.0.0-alpha
  */
 public static function set($name, $value)
 {
     if ($name == 'perm') {
         $msg = __('Name "perm" is reserved and cannot be used!');
         Log::insert($msg, 'ERROR');
         throw new Exception($msg);
     }
     static::$vars[$name] = $value;
     static::update();
 }
开发者ID:ktrzos,项目名称:plethora,代码行数:21,代码来源:Session.php

示例13: audit

 /**
  * Audit model.
  */
 public function audit(array $log)
 {
     $logAuditing = ['old_value' => json_encode($log['old_value']), 'new_value' => json_encode($log['new_value']), 'owner_type' => get_class($this), 'owner_id' => $this->getKey(), 'user_id' => $this->getUserId(), 'type' => $log['type'], 'created_at' => new \DateTime(), 'updated_at' => new \DateTime()];
     return Log::insert($logAuditing);
 }
开发者ID:petrovitch,项目名称:smoothing,代码行数:8,代码来源:AuditingTrait.php

示例14: publish

function publish($link)
{
    global $globals, $db;
    //return;
    if (DEBUG) {
        return;
    }
    // Calculate votes average
    // it's used to calculate and check future averages
    $votes_avg = (double) $db->get_var("select SQL_NO_CACHE avg(vote_value) from votes, users where vote_type='links' AND vote_link_id={$link->id} and vote_user_id > 0 and vote_value > 0 and vote_user_id = user_id and user_level !='disabled'");
    if ($votes_avg < $globals['users_karma_avg']) {
        $link->votes_avg = max($votes_avg, $globals['users_karma_avg'] * 0.97);
    } else {
        $link->votes_avg = $votes_avg;
    }
    $link->status = 'published';
    $link->date = $link->published_date = time();
    $db->query("update links set link_status='published', link_date=now(), link_votes_avg={$link->votes_avg} where link_id={$link->id}");
    SitesMgr::deploy($link);
    // Increase user's karma
    $user = new User($link->author);
    if ($user->read) {
        $user->add_karma($globals['instant_karma_per_published'], _('noticia publicada'));
    }
    // Add the publish event/log
    Log::insert('link_publish', $link->id, $link->author);
    $link->annotation .= _('publicación') . "<br/>";
    $link->save_annotation('link-karma');
    // Publish to all sub sites: this and children who import the link category
    $my_id = SitesMgr::my_id();
    // Get all sites that are "children" and try to post links
    // And that "import" the link->category
    $sites = array_intersect(SitesMgr::get_children($my_id), SitesMgr::get_receivers($link->category));
    // Add my own
    $sites[] = $my_id;
    foreach ($sites as $s) {
        $server_name = SitesMgr::get_info($s)->server_name;
        syslog(LOG_INFO, "Meneame, calling: " . dirname(__FILE__) . "/post_link.php {$server_name} {$link->id}");
        passthru(dirname(__FILE__) . "/post_link.php {$server_name} {$link->id}");
    }
}
开发者ID:brainsqueezer,项目名称:fffff,代码行数:41,代码来源:promote9.php

示例15: store

 function store($full = true)
 {
     global $db, $current_user, $globals;
     if (!$this->date) {
         $this->date = $globals['now'];
     }
     $comment_content = $db->escape($this->normalize_content());
     if ($this->type == 'admin') {
         $comment_type = 'admin';
     } else {
         $comment_type = 'normal';
     }
     $db->transaction();
     if ($this->id === 0) {
         $this->ip = $db->escape($globals['user_ip']);
         $this->ip_int = $db->escape($globals['user_ip_int']);
         $previous = $db->get_var("select count(*) from comments where comment_link_id={$this->link} FOR UPDATE");
         if (!$previous > 0 && $previous !== '0') {
             syslog(LOG_INFO, "Failed to assign order to comment {$this->id} in insert");
             $this->order = 0;
         } else {
             $this->order = intval($previous) + 1;
         }
         $r = $db->query("INSERT INTO comments (comment_user_id, comment_link_id, comment_type, comment_karma, comment_ip_int, comment_ip, comment_date, comment_randkey, comment_content, comment_order) VALUES ({$this->author}, {$this->link}, '{$comment_type}', {$this->karma}, {$this->ip_int}, '{$this->ip}', FROM_UNIXTIME({$this->date}), {$this->randkey}, '{$comment_content}', {$this->order})");
         $new_id = $db->insert_id;
         if ($r) {
             $this->id = $new_id;
             // Insert comment_new event into logs
             if ($full) {
                 Log::insert('comment_new', $this->id, $current_user->user_id);
             }
         }
     } else {
         $r = $db->query("UPDATE comments set comment_user_id={$this->author}, comment_link_id={$this->link}, comment_type='{$comment_type}', comment_karma={$this->karma}, comment_date=FROM_UNIXTIME({$this->date}), comment_modified=now(), comment_randkey={$this->randkey}, comment_content='{$comment_content}' WHERE comment_id={$this->id}");
         if ($r) {
             // Insert comment_new event into logs
             if ($full) {
                 if ($globals['now'] - $this->date < 86400) {
                     Log::conditional_insert('comment_edit', $this->id, $current_user->user_id, 60);
                 }
                 $this->update_order();
             }
         }
     }
     if (!$r) {
         syslog(LOG_INFO, "Error storing comment {$this->id}");
         $db->rollback();
         return false;
     }
     if ($full) {
         $this->update_conversation();
     }
     // Check we got a good order value
     if (!$this->order) {
         syslog(LOG_INFO, "Trying to assign order to comment {$this->id} after commit");
         $this->update_order();
     }
     $db->commit();
     return true;
 }
开发者ID:GallardoAlba,项目名称:Meneame,代码行数:60,代码来源:comment.php


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