Пример #1
0
 public function addProduct($product)
 {
     if ($product->yourprice > 0) {
         $this->prods[$product->productid] = $product;
     } else {
         writeErrorLog('Won\'t add a line-item with a price <= 0 for: ', $product->productid);
     }
 }
Пример #2
0
 public function createDBInstance()
 {
     // always use the db version, no support for the simple file based storage
     include CARTREVISION . '/phphosted/fbase.cls.php';
     if (!class_exists('HostedFBase')) {
         writeErrorLog('Tried to include "phphosted/fbase.cls.php", but "HostedFBase" still doesn\'t exist.');
         return false;
     }
     return new HostedFBase(TTRANS);
 }
Пример #3
0
 function _do_call($fields = '')
 {
     if (!$this->base_url) {
         return;
     }
     curl_setopt($this->curl, CURLOPT_URL, $this->base_url);
     curl_setopt($this->curl, CURLOPT_POSTFIELDS, $this->base_fields . $fields);
     curl_setopt($this->curl, CURLOPT_CONNECTTIMEOUT, 1);
     // ensure the page won't wait too long
     $response = curl_exec($this->curl);
     if (curl_errno($this->curl)) {
         $effurl = curl_getinfo($this->curl, CURLINFO_EFFECTIVE_URL);
         writeErrorLog('Stats Reporter error - ' . curl_errno($this->curl) . ': ' . curl_error($this->curl), $effurl . '   ' . $this->base_fields . $fields);
         return false;
     }
     #echo $this->base_fields;
     #writeErrorLog( 'Stats Reporter success - ' . $response, $fields );
     return true;
 }
Пример #4
0
 private function _Connect()
 {
     // connect to the database
     if ($this->db === false) {
         if (Config::GetInstance()->sdrive) {
             $this->db = new DataAccessSQLite('save_sqlite');
             // attach the transaction database if the form uses payments
             if (Config::GetInstance()->UsePayments()) {
                 $dbfile = TransactionLogger::GetInstance()->GetSqliteFile();
                 if (empty($dbfile) || !file_exists($dbfile)) {
                     writeErrorLog('Tried to attach transaction log, but file is not defined or doesn\'t exist:', $dbfile);
                 } else {
                     $this->transacts = $this->db->AttachTransActions($dbfile);
                 }
             }
         } else {
             $this->db = new DataAccessMySQL('save_database');
         }
     }
 }
Пример #5
0
 private function _CheckSubmitLimitReset()
 {
     $upgrade_date = Config::GetInstance()->getSubmitLimitUpgradeDate();
     if ($upgrade_date && $upgrade_date != $this->GetSetting(FB_SETTING_SUBMITLIMIT)) {
         // store the new date so that we know if it changed or not
         $this->SetSetting(array(FB_SETTING_SUBMITLIMIT => $upgrade_date));
         // clear the flags for the month that the date is set
         $qry = 'UPDATE ' . $this->_EscapeName($this->table) . ' SET _flags_ = _flags_&' . ~FLAG_OVERSUBMITLIMIT . ' WHERE strftime(\'%Y-%m\', _submitted_) = \'' . substr($upgrade_date, 0, 7) . '\';';
         $count = $this->db->exec($qry);
     }
     if ($count === false) {
         writeErrorLog(__METHOD__, $this->db->errorInfo());
         return 0;
     }
     return $count;
 }
Пример #6
0
 function _MoveFile($fieldname, $filedata)
 {
     $fp = fopen($filedata['tmp_name'], 'r');
     $content = fread($fp, $filedata['size']);
     $sql = 'INSERT INTO ' . $this->_EscapeName($this->table . CC_FB_FILEUPLOAD_EXT) . ' (name, fdata) VALUES (?,?)';
     $sth = $this->db->prepare($sql);
     if ($sth === false) {
         writeErrorLog('Failed compile query:', $sql);
     } else {
         if (!$sth->execute(array($fieldname, $content))) {
             writeErrorLog('Failed to insert file data:', $sth->errorInfo());
         } else {
             // remember the id
             $res = $this->db->query('SELECT LAST_INSERT_ID();');
             if ($res !== false) {
                 $this->stored_file_rowids[] = $res->fetchColumn(0);
                 $res->closeCursor();
             }
         }
     }
 }
Пример #7
0
@(include_once 'SdriveConfig.php');
// initialize the singleton with the form-name
// the global $myPage is used in older code, don't remove it!
$myPage = FormPage::GetInstance($myName);
if (isset($sdrive_config)) {
    $errorLoggingType = 0;
    // better send writeErrorLog output to the server log
    // $myPage->sdrive is initialized to false
    Config::GetInstance()->LoadConfig($sdrive_config);
    if (isset($sdrive_model)) {
        Config::GetInstance()->sdrive_model = $sdrive_model;
    }
    // on S-Drive the cart scripts are taken directly from the resources
    $buildnum = Config::GetInstance()->GetConfig('resource_version');
    if (!$buildnum) {
        writeErrorLog('Parameter missing or empty in form.cfg.dat', 'resource_version');
    }
    $cartpath = CC_HOSTING_RESOURCES . DIRECTORY_SEPARATOR . 'FB' . DIRECTORY_SEPARATOR . $buildnum . DIRECTORY_SEPARATOR . 'fb';
    set_include_path(get_include_path() . PATH_SEPARATOR . $cartpath);
    // add this constant to the file names to include instead of adding it to the include path
    // as a type of name spacing
    define('CARTREVISION', 'cartapp');
} else {
    // A version number is added to the folder name for forward compatibility. FB increments this
    // number if changes are NOT backward compatible. FB must also create the corrresponding
    // folder (leaving the old folder for forms made and uploaded with a previous version).
    define('CARTREVISION', 'cartapp_v1');
    Config::GetInstance()->LoadConfig();
}
// catch warnings with our own error handler to ignore them as appropriate
set_error_handler('myErrorHandler', E_WARNING);
Пример #8
0
function sqlGetServerStats($mySQLiConn)
{
    $ServerStats["GameID"] = 0;
    $ServerStats["ServerState"] = 0;
    $ServerStats["SessionStart"] = 0;
    $ServerStats["SessionID"] = 0;
    $ServerStats["SessionState"] = 0;
    $ServerStats["SessionTime"] = 0;
    $ServerStats["SessionEnd"] = 0;
    $ServerStats["CurLaps"] = 0;
    $ServerStats["MaxLaps"] = 0;
    $ServerStats["NumVehicles"] = 0;
    $ServerStats["TrackName"] = "No Session";
    $ServerStats["AmbientTemp"] = 0;
    $ServerStats["TrackTemp"] = 0;
    if (!$mySQLiConn->connect_error) {
        $selectSessionInfos = "SELECT SQL_CACHE * FROM `sessioninfos` LIMIT 1";
        if ($resultSessionInfos = $mySQLiConn->query($selectSessionInfos)) {
            if ($resultSessionInfos->num_rows == 1) {
                while ($rowSessionInfos = $resultSessionInfos->fetch_assoc()) {
                    $ServerStats["GameID"] = $rowSessionInfos["GameID"];
                    $ServerStats["ServerState"] = $rowSessionInfos["ServerState"];
                    $ServerStats["SessionStart"] = $rowSessionInfos["SessionStart"];
                    $ServerStats["SessionID"] = $rowSessionInfos["SessionID"];
                    $ServerStats["SessionState"] = $rowSessionInfos["SessionState"];
                    $ServerStats["SessionTime"] = $rowSessionInfos["SessionTime"];
                    $ServerStats["SessionEnd"] = $rowSessionInfos["SessionEnd"];
                    $ServerStats["CurLaps"] = $rowSessionInfos["CurLaps"];
                    $ServerStats["MaxLaps"] = $rowSessionInfos["MaxLaps"];
                    $ServerStats["NumVehicles"] = $rowSessionInfos["NumVehicles"];
                    $ServerStats["TrackName"] = $rowSessionInfos["TrackName"];
                    $ServerStats["AmbientTemp"] = $rowSessionInfos["AmbientTemp"];
                    $ServerStats["TrackTemp"] = $rowSessionInfos["TrackTemp"];
                }
            }
            $resultSessionInfos->free();
        } else {
            writeErrorLog("inc.common.php", "sqlGetServerStats()", "Error: (" . $mySQLiConn->error . ") Query: (" . $selectSessionInfos . ")");
        }
    } else {
        writeErrorLog("inc.common.php", "sqlGetServerStats()", "Error: (" . $mySQLiConn->connect_error . ")");
    }
    return $ServerStats;
}
Пример #9
0
 function _Archive()
 {
     $i = 1;
     do {
         $newname = str_replace('.', $i . '.', $this->output_file);
         $i++;
     } while (file_exists($newname));
     if (!rename($this->output_file, $newname)) {
         writeErrorLog('Failed to archive ' . $this->output_file . ' to:', $newname);
         $this->errors[] = array('err' => _T('Failed to archive data file.'));
         return false;
     }
     return true;
 }
Пример #10
0
function SaveUploadAsFile($dest, $filedata)
{
    if (!is_dir($dest) && !mkdir($dest, 0755, true)) {
        writeErrorLog('Could not create file upload directory \'' . $dest . '\'');
        return false;
    }
    // filename may or may not have an extension that must be preserved
    $pos = strrpos($filedata['name'], '.');
    $basename = $filedata['name'];
    // replace any dots left with a _ for scripts diguised as an image (e.g. exploit-db.php.jpg)
    if ($pos !== false) {
        $tmp = substr($basename, 0, $pos);
        $basename = str_replace('.', '_', $tmp) . substr($basename, $pos);
    }
    // try the org name first, only if it exists add the random string
    $uploadname = $basename;
    while (file_exists($dest . $uploadname)) {
        $rand = makeRandomString();
        if ($pos === false) {
            $uploadname = $basename . '_' . $rand;
        } else {
            $uploadname = substr($basename, 0, $pos) . '_' . $rand . substr($basename, $pos);
        }
    }
    if (empty($filedata['tmp_name'])) {
        writeErrorLog('Could not move uploaded file because the tmp_name is empty.');
        return false;
    }
    $rc = move_uploaded_file($filedata["tmp_name"], $dest . $uploadname);
    if ($rc) {
        return $uploadname;
    }
    writeErrorLog('Moving file ' . $filedata['tmp_name'] . ' to ' . $uploadname . ' failed.');
    return false;
}
Пример #11
0
 function _SubstituteAddress($name)
 {
     $matches = array();
     $r = preg_match_all('\'\\[([^\\]]+)\\]\'', $name, $matches, PREG_PATTERN_ORDER);
     if ($r === false) {
         writeErrorLog('Error in regex parsing:', $name);
     }
     if (!$r) {
         return trim($name);
     }
     foreach ($matches[1] as $match) {
         // check if this is an email field and get its value if it is
         $match = strtolower($match);
         if ((Config::GetInstance()->GetConfig('rules', $match, 'fieldtype') == 'email' || Config::GetInstance()->GetConfig('rules', $match, 'contactList')) && isset(FormPage::GetInstance()->post[$match])) {
             $name = str_ireplace('[' . $match . ']', FormPage::GetInstance()->post[$match], $name);
         }
     }
     return trim($name);
 }
Пример #12
0
 function SetSelection($selection, $with_limit_exceeded = -1)
 {
     // don't use any alias field names in this where clause because they won't
     // be defined when counting the records with a select count(*) from ... where ...
     switch ((int) $with_limit_exceeded) {
         case -1:
             $this->where = '1';
             break;
         case 0:
             $this->where = '(_flags_&' . FLAG_OVERSUBMITLIMIT . '=0)';
             break;
         case 1:
             $this->where = '_flags_&' . FLAG_OVERSUBMITLIMIT;
             break;
     }
     if ($selection === false) {
         return true;
     }
     // check the syntax and build a where clause
     // possible formats are:
     //		3days						last 3 days
     //		from20to40					from row 20 to row 40
     //		from2011-07-29 10:27:18to2011-07-30 10:27:18
     //									from date_time to date_time
     //		new							rows that don't have the _read_ flag set
     //		starred						rows that have the _starred_ flag set
     //		1,2,3						rows with ids 1, 2 and 3
     $matches = array();
     if ($selection == 'new') {
         $this->where .= ' AND (_flags_&' . FLAG_READ . ')=0';
     } else {
         if ($selection == 'starred') {
             $this->where .= ' AND _flags_&' . FLAG_STARRED;
         } else {
             if ($selection == 'all') {
                 // nothing needed
             } else {
                 if (preg_match('/(\\d+)days?/', $selection, $matches) == 1) {
                     $start = time() - $matches[1] * 24 * 60 * 60;
                     $this->where .= ' AND _submitted_ >=\'' . date('Y-m-d', $start) . ' 00:00:00\'';
                 } else {
                     if (preg_match('/from(\\d+)to(\\d+)/', $selection, $matches) == 1) {
                         $this->where .= ' AND _rowid_>=' . $matches[1] . ' AND ' . '_rowid_<=' . $matches[2];
                     } else {
                         if (preg_match('/from([ \\d-:]+)to([ \\d-:]+)/', $selection, $matches) == 1) {
                             $this->where .= ' AND _submitted_ >=\'' . Config::GetInstance()->MakeUTC($matches[1]) . '\' AND _submitted_ <\'' . Config::GetInstance()->MakeUTC($matches[2]) . '\'';
                         } else {
                             if (preg_match('/[\\d,]/', $selection)) {
                                 $this->where .= ' AND rowid IN (' . $selection . ')';
                             } else {
                                 writeErrorLog('Failed to interpret record selector:', $selection);
                                 $this->error = 'Failed to interpret record selector. Allowed formats are: "all", "4,6,7", "new", "starred", "3days", "from20to40" and "from2011-07-29 10:27:18to2011-07-30 10:27:18"';
                                 return false;
                             }
                         }
                     }
                 }
             }
         }
     }
     return true;
 }
Пример #13
0
 private function _makePublicUrl($fieldname, $filename)
 {
     // ensure the publicly visible folder exists
     if (!file_exists(Config::GetInstance()->getStorageFolder(4))) {
         mkdir(Config::GetInstance()->getStorageFolder(4));
     }
     // use the rules to find out where the file is
     if (Config::GetInstance()->GetRulePropertyByName($fieldname, 'files') == true) {
         if (!copy(Config::GetInstance()->getStorageFolder(1) . $filename, Config::GetInstance()->getStorageFolder(4) . $filename)) {
             writeErrorLog('MailChimp plugin couldn\'t copy the uploaded file to a public folder', $filename);
             $this->setError(_T('Failed to copy the uploaded file %s to a publicly visible folder.', $filename));
             return;
         }
     } else {
         // look for it in the uploads table
         if (isset($_FILES[$fieldname]) && file_exists($_FILES[$fieldname]['tmp_name'])) {
             $filename = SaveUploadAsFile(Config::GetInstance()->getStorageFolder(4), $_FILES[$fieldname]);
             if ($filename == false) {
                 writeErrorLog('MailChimp plugin couldn\'t move the uploaded file to a public folder', $filename);
                 $this->setError(_T('Failed to move the uploaded file %s to a publicly visible folder.', $filename));
                 return;
             }
         }
     }
     $servername = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME'];
     $path = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : $_SERVER['PHP_SELF'];
     $path = substr($path, 0, strrpos($path, '/'));
     // encode the folders, not the '/'!
     $tmp = explode('/', $path);
     for ($i = 0; $i < count($tmp); ++$i) {
         $tmp[$i] = rawurlencode($tmp[$i]);
     }
     $path = implode('/', $tmp);
     // windows servers may set [HTTPS] => off, linux server usually don't set [HTTPS] at all
     if (isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') {
         $protocol = 'https';
     } else {
         $protocol = 'http';
     }
     $url = $protocol . '://' . $servername;
     // only add the serverport when it differs from the default
     if (strpos($servername, ':') === false && ($_SERVER['SERVER_PORT'] != '80' || $protocol != 'http')) {
         $url .= ':' . $_SERVER['SERVER_PORT'];
     }
     return $url . $path . '/' . FormPage::GetInstance()->GetFormName() . CC_FB_STORAGE_FOLDER . CC_FB_PUBLIC_DIRECTORY . $filename;
 }
Пример #14
0
 public function callBack()
 {
     $callback_data = $this->input['data'];
     $shift = json_decode(html_entity_decode($callback_data), 1);
     /*****************************根据时移反馈的信息,更新时移日志的状态*******************************/
     $sql = 'SELECT * FROM ' . DB_PREFIX . 'time_shift_log WHERE id = ' . (int) $shift['id'];
     $shift_info = $this->db->query_first($sql);
     if (empty($shift_info)) {
         $this->errorOutput('时移数据不存在');
     }
     if ($shift) {
         switch ($shift['exit_status']) {
             case 0:
                 $status = 0;
                 break;
             case 1:
                 $status = 1;
                 break;
         }
         //更新时移状态
         $this->mode->update($shift['id'], array('status' => $status));
     }
     if (!$status) {
         writeErrorLog("时移失败:\n" . var_export($shift, 1));
         $this->errorOutput('时移失败');
     }
     /*****************************根据时移反馈的信息,更新时移日志的状态*******************************/
     /****************************将时移好的视频提交到mediaserver进行转码*****************************/
     if (!$this->settings['App_mediaserver']) {
         $this->errorOutput('未安装mediaserver');
     }
     $curl = new curl($this->settings['App_mediaserver']['host'], $this->settings['App_mediaserver']['dir'] . 'admin/');
     $curl->setSubmitType('post');
     $curl->initPostData();
     //构建需要提交的数据
     $data = array('filepath' => $shift['file_path'], 'vod_sort_id' => $shift['vod_sort_id'], 'vod_leixing' => 3, 'start' => '0', 'duration' => '');
     if ($shift_info['live_split_callback']) {
         $data['app_uniqueid'] = 'live_split_data';
         $data['mod_uniqueid'] = 'live_split_data';
     }
     if (!empty($shift) && $shift['extend']) {
         $shift['extend'] = json_decode(base64_decode($shift['extend']), 1);
         foreach ($shift['extend'] as $k => $v) {
             $curl->addRequestData($k, $v);
         }
     }
     foreach ($data as $k => $v) {
         $curl->addRequestData($k, $v);
     }
     $ret = $curl->request('create.php');
     /****************************将时移好的视频提交到mediaserver进行转码*****************************/
     /****************************提交之后的回调处理************************************************/
     if ($ret && $ret[0]['id']) {
         //更新时移的视频id
         $this->mode->update($shift['id'], array('video_id' => $ret[0]['id']));
         $shift_info['live_split_callback'] && $this->live_split_callback($shift_info['live_split_callback'], $callback_data, $ret[0]['id']);
     } else {
         //时移成功,但是提交mediserver失败
         $this->mode->update($shift['id'], array('status' => 3));
         $shift_info['live_split_callback'] && $this->live_split_callback($shift_info['live_split_callback'], $callback_data, 0);
         writeErrorLog("时移成功,提交转码失败:\n" . var_export($ret, 1));
     }
     $this->addItem($ret);
     $this->output();
 }
Пример #15
0
 /**
  * Adds an attachment from a path on the filesystem.
  * Returns false if the file could not be found
  * or accessed.
  * @param string $path Path to the attachment.
  * @param string $name Overrides the attachment name.
  * @param string $encoding File encoding (see $Encoding).
  * @param string $type File extension (MIME) type.
  * @return bool
  */
 public function AddAttachment($path, $name = '', $encoding = 'base64', $type = 'application/octet-stream')
 {
     try {
         if (!@is_file($path)) {
             throw new phpmailerException($this->Lang('file_access') . $path, self::STOP_CONTINUE);
         }
         $filename = basename($path);
         if ($name == '') {
             $name = $filename;
         }
         $this->attachment[] = array(0 => $path, 1 => $filename, 2 => $name, 3 => $encoding, 4 => $type, 5 => false, 6 => 'attachment', 7 => 0);
     } catch (phpmailerException $e) {
         $this->SetError($e->getMessage());
         if ($this->exceptions) {
             throw $e;
         }
         writeErrorLog($e->getMessage());
         if ($e->getCode() == self::STOP_CRITICAL) {
             return false;
         }
     }
     return true;
 }
Пример #16
0
 function PrepareInlineMessage($messagenode, $replaceFormByDiv = false)
 {
     // get the html
     $this->ReadSource();
     $dom = new DOMDocument('1.0', 'UTF-8');
     if ($dom->loadHTML($this->source) === false) {
         writeErrorLog('Failed to parse HTML form.');
         return false;
     }
     // find the container for the message
     $container = $dom->getElementById('fb_confirm_inline');
     if (!$container) {
         writeErrorLog('Parsed HTML form, but can\'t locate element with id "#fb_confirm_inline".');
         return false;
     }
     // remove all child nodes
     while ($container->hasChildNodes()) {
         $container->removeChild($container->firstChild);
     }
     // add our html and change the 'display:none' style to 'display:block'
     $usernode = $dom->importNode($messagenode, true);
     $container->appendChild($usernode);
     $style = str_replace('none', 'block', $container->getAttribute('style'));
     $container->setAttribute('style', $style);
     // remove all siblings, go up to parent ... until we arrive at the form
     do {
         while ($container->previousSibling) {
             $container->parentNode->removeChild($container->previousSibling);
         }
         while ($container->nextSibling) {
             $container->parentNode->removeChild($container->nextSibling);
         }
         $container = $container->parentNode;
     } while ($container->getAttribute('id') != 'docContainer');
     // replace the form by a div container, because forms can't be nested
     if ($replaceFormByDiv) {
         $old = $dom->getElementById('docContainer');
         $new = $dom->createElement('div');
         $new->setAttributeNode($old->getAttributeNode('id'));
         $new->setAttributeNode($old->getAttributeNode('class'));
         if ($old->hasAttribute('style')) {
             $new->setAttributeNode($old->getAttributeNode('style'));
         }
         $new->appendChild($old->firstChild);
         $old->parentNode->replaceChild($new, $old);
     }
     $this->source = $dom->saveHTML();
     return true;
 }
Пример #17
0
 private function _loadOriginalPostNames()
 {
     if ($this->fieldnamesloaded) {
         return;
     }
     $this->fieldnamesloaded = true;
     if (!$this->_TableExists(FB_KEYNAMES_TABLE)) {
         return;
     }
     $qry = 'SELECT * FROM ' . FB_KEYNAMES_TABLE . ';';
     $r = $this->db->query($qry);
     if ($r == false) {
         writeErrorLog('Error in query: ' . $qry, $this->db->errorInfo());
         $this->error = implode(' ,', $this->db->errorInfo());
         return;
     }
     while ($row = $r->fetch(PDO::FETCH_ASSOC)) {
         $this->fieldnameMap[$row['colname']] = $row['orgname'];
     }
     $r->closeCursor();
 }
Пример #18
0
            // 获取管理用户组
            $admin_group_sql = 'SELECT p.* FROM `' . $old_db_conf['DB_PREFIX'] . 'user_group_popedom` AS p LEFT JOIN `' . $old_db_conf['DB_PREFIX'] . 'node` AS n ON p.`node_id` = n.`node_id` WHERE n.`app_name` = \'admin\' AND n.`mod_name` = \'*\' AND n.`act_name` = \'*\'';
            $admin_group_info = $old_db->query($admin_group_sql);
            if (empty($user_group_info) || $user_group_info[0]['user_group_id'] != $admin_group_info[0]['user_group_id']) {
                $user_group_data[] = "(null, '" . $value['uid'] . "', '3')";
            } else {
                if ($user_group_info[0]['user_group_id'] == $admin_group_info[0]['user_group_id']) {
                    $user_group_data[] = "('" . $user_group_info[0]['id'] . "', '" . $user_group_info[0]['uid'] . "', '1')";
                }
            }
        }
        $insert_user = '******' . $db_conf['DB_PREFIX'] . 'user` VALUES ' . implode(',', $data);
        $result = $db->execute($insert_user);
        if ($result === false) {
            foreach ($data as $single_value) {
                $result = $single_insert_user = '******' . $db_conf['DB_PREFIX'] . 'user` VALUES ' . $single_value;
                $db->execute($single_insert_user);
                if ($result === false) {
                    writeErrorLog($single_insert_user);
                }
            }
        }
        $insert_group_link = 'INSERT INTO `' . $db_conf['DB_PREFIX'] . 'user_group_link` VALUES ' . implode(',', $user_group_data);
        $db->execute($insert_group_link);
        // 跳转操作
        $t = 'user';
        $p = $p + 1;
        echo '<script>window.location.href="' . getJumpUrl($t, $p) . '";</script>';
        exit;
    }
}
Пример #19
0
 public function create()
 {
     /*************权限控制***********************************************/
     if ($this->user['group_type'] > MAX_ADMIN_TYPE) {
         $prms['_action'] = 'create';
         if (!$this->input['item'] || intval($this->input['item']) == -1) {
             $this->input['item'] = 3;
             //不存在默认给的分类是直播归档
         }
         $prms['node'] = $this->input['item'];
         $this->verify_self_prms($prms);
     }
     /*************权限控制***********************************************/
     if (!$this->input['channel_id']) {
         $this->errorOutput(NOID);
     }
     /*************选择时移服务器******************************************/
     $shiftServer = new SelectTimeShiftServer();
     $serverSelected = $shiftServer->select();
     if (!$serverSelected) {
         $this->errorOutput('没有可选择的时移服务器');
     }
     /*************选择时移服务器******************************************/
     /*************检测频道流信息******************************************/
     $condition['id'] = $this->input['channel_id'];
     $condition['fetch_live'] = 1;
     $channel = $this->mLive->getChannelInfo($condition);
     $channel = $channel[0];
     if (!$channel) {
         $this->errorOutput('该频道已经不存在!');
     }
     if (!$channel['status']) {
         $this->errorOutput('该频道流未开启');
     }
     if (!$channel['is_mobile_phone']) {
         $this->errorOutput('该频道未启动手机流,无法获取时移数据!');
     }
     /*************监测频道流信息******************************************/
     /*************时移时间正确性监测***************************************/
     $ret = array();
     $ret['title'] = $this->input['title'] ? $this->input['title'] : '精彩节目';
     $ret['starttime'] = strtotime(trim($this->input['start_time']));
     $ret['endtime'] = strtotime(trim($this->input['end_time']));
     $ret['duration'] = $ret['endtime'] - $ret['starttime'];
     if ($ret['starttime'] >= $ret['endtime']) {
         $this->errorOutput('时间设置不正确!');
     }
     $save_time = TIMENOW - ($channel['time_shift'] * 3600 - $channel['delay']);
     if ($ret['starttime'] < $save_time) {
         $this->errorOutput('此条时移已超过回看时间!');
     }
     if ($ret['endtime'] > TIMENOW) {
         $this->errorOutput('时移节目的结束时间必须小于当前时间!');
     }
     /*************时移时间正确性监测***************************************/
     /*************默认类别***********************************************/
     if (intval($this->input['item']) == -1) {
         $this->input['item'] = 3;
         //如果没有传类别默认给直播归档的类别
     }
     /*************默认类别***********************************************/
     /*********************记录一条时移日志*******************************/
     $shift_log = array('title' => $ret['title'], 'channel_id' => $this->input['channel_id'], 'starttime' => $ret['starttime'], 'endtime' => $ret['endtime'], 'live_split_callback' => (int) $this->input['live_split_callback'], 'status' => 2, 'create_time' => TIMENOW, 'user_id' => $this->user['user_id'], 'user_name' => $this->user['user_name']);
     $shiftLogInfo = $this->mode->create($shift_log);
     $this->addLogs('记录时移日志', '', $shiftLogInfo, $shiftLogInfo['title']);
     /*********************记录一条时移日志*******************************/
     /*********************向时移服务器提交数据****************************/
     $duration = $ret['duration'] . '000';
     $starttime = $ret['starttime'] . '000';
     if ($channel['server_type'] != 'nginx') {
         if (strstr($channel['channel_stream'][0]['m3u8'], '?')) {
             $sp = '&';
         } else {
             $sp = '?';
         }
         $url = $channel['channel_stream'][0]['m3u8'] . $sp . 'dvr&duration=' . $duration . '&starttime=' . $starttime;
     } else {
         $pathinfo = pathinfo($channel['channel_stream'][0]['live_m3u8']);
         $url = $pathinfo['dirname'] . '/' . $channel['main_stream_name'] . '/' . $starttime . ',' . $duration . '.m3u8';
     }
     $callback = $this->input['callback_url'] ? trim($this->input['callback_url']) : $this->settings['App_live_time_shift']['protocol'] . $this->settings['App_live_time_shift']['host'] . '/' . $this->settings['App_live_time_shift']['dir'] . 'admin/live_time_shift_callback.php';
     //构建提交的数据
     $data = array('id' => $shiftLogInfo['id'], 'time_shift' => '1', 'action' => 'TIMESHIFT', 'url' => urlencode($url), 'callback' => $callback, 'uploadFile' => '0', 'appid' => $this->input['appid'], 'appkey' => $this->input['appkey'], 'access_token' => $this->user['token'], 'vod_sort_id' => $this->input['item']);
     //额外传递的参数
     $extend_data = $this->input['dataextend'] ? $this->input['dataextend'] : array('_user_id' => $this->user['user_id'], '_user_name' => $this->user['user_name'], 'audit_auto' => $this->input['audit_auto'], 'column_id' => $this->input['column_id'], 'channel_id' => $this->input['channel_id'], 'force_recodec' => $this->input['force_codec'], 'is_mark' => !$this->input['is_mark'], 'starttime' => $this->input['start_time'], 'delay_time' => $channel['time_shift'], 'title' => $ret['title'], 'program' => $ret['title']);
     $data['extend'] = base64_encode(json_encode($extend_data));
     //开始提交
     $this->curl = new curl($serverSelected['host'] . ':' . $serverSelected['port']);
     foreach ($data as $k => $v) {
         $this->curl->addRequestData($k, $v);
     }
     $shift_xml = $this->curl->request('');
     $xmlobj = @simplexml_load_string($shift_xml);
     if (!$xmlobj || !$xmlobj->attributes()->result) {
         $this->mode->update($shiftLogInfo['id'], array('status' => 0));
         //失败了更新状态
         writeErrorLog("提交时移服务器失败:\n" . var_export($xmlobj, 1));
         $this->errorOutput('提交时移服务器失败');
     }
     /*********************向时移服务器提交数据****************************/
     if ($this->input['outputtype'] == 1) {
         $this->addItem($shiftLogInfo);
     } else {
         if (!$this->input['outputtype']) {
             $this->addItem('success');
         }
     }
     $this->output();
 }
Пример #20
0
                "[Data: " . sprintf("%.1F" ,((strlen($MonitorData) * 8) / 1000)) . " kBit]" .
                "[Load: " . $currentServerLoad . "]" .
                "</div>\n"; */
        echo $MonitorData;
        // if(file_exists("./monitordata.html") == false){
        // $fh = fopen("./monitordata.html", 'wt');
        // fwrite($fh, "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN' 'http://www.w3.org/TR/html4/loose.dtd'>\n");
        // fwrite($fh, "<html>\n");
        // fwrite($fh, "<head>\n");
        // fwrite($fh, "<meta http-equiv='content-type' content='text/html; charset=UTF-8'>\n");
        // fwrite($fh, "<title>VM LiveView Lite (Monitor)</title>\n");
        // fwrite($fh, "<link rel='stylesheet' type='text/css' href='http://ftgx.dyndns.org/vmliveview/styles.css'>\n");
        // fwrite($fh, "</head>\n");
        // fwrite($fh, "<body>\n");
        // fwrite($fh, $MonitorData);
        // fwrite($fh, "</body>\n");
        // fwrite($fh, "</html>\n");
        // fclose($fh);
        // }
    } else {
        echo $mySQLiConnError;
    }
    echo "<div class='row'><div class='col-xs-12'>";
    include "inc.copyright.php";
    echo "</div></div>";
} catch (Exception $ex) {
    writeErrorLog($pageName, "General Exception", "Exception Msg: (" . $ex->getMessage() . ")");
}
?>
</div>
Пример #21
0
 function _SendSMTP()
 {
     $config =& $this->config['smtp'];
     $mail = new PHPMailer();
     $mail->IsSMTP();
     $mail->CharSet = 'utf-8';
     $mail->Host = $config['host'];
     $mail->Port = $config['port'];
     $mail->SMTPSecure = $config['secure'];
     $mail->SMTPAuth = $config['auth'];
     $mail->Username = $config['user'];
     $mail->Password = $config['password'];
     $mail->Subject = $this->subject;
     $mail->MsgHTML($this->message);
     $to = preg_split("/[;\\s,]+/", $this->to, -1, PREG_SPLIT_NO_EMPTY);
     foreach ($to as $adr) {
         $mail->AddAddress($adr);
     }
     // reply-to MUST be set before from, or else the phpmailer adds the
     // from address to the reply-to header, which is not what we want for FB
     // see also PHPMailer::SetFrom($address, $name = '',$auto=1), around line 507
     if (!empty($this->replyto)) {
         if (is_array($this->replyto)) {
             foreach ($this->replyto as $adr) {
                 $mail->AddReplyTo($adr);
             }
         } else {
             $mail->AddReplyTo($this->replyto);
         }
     }
     if (!empty($this->from)) {
         // accept formats name@domain.ext or Name <*****@*****.**>
         $pos = strpos($this->from, '<');
         if ($pos === false) {
             //global $myPage;
             //$name = $myPage->getConfigS('shopname');
             //if( $name )			$mail->SetFrom( $this->from, $name );
             //else 				$mail->SetFrom( $this->from );
             $mail->SetFrom($this->from);
         } else {
             $name = substr($this->from, 0, $pos);
             $addr = str_replace('>', '', substr($this->from, $pos + 1));
             $mail->SetFrom($addr, $name);
         }
     }
     if (!empty($this->cc)) {
         if (is_string($this->cc)) {
             $this->cc = preg_split("/[;\\s,]+/", $this->cc, -1, PREG_SPLIT_NO_EMPTY);
         }
         if (is_array($this->cc)) {
             foreach ($this->cc as $adr) {
                 $mail->AddCC($adr);
             }
         }
     }
     if (!empty($this->bcc)) {
         if (is_array($this->bcc)) {
             foreach ($this->bcc as $adr) {
                 $mail->AddBCC($adr);
             }
         } else {
             $mail->AddBCC($this->bcc);
         }
     }
     if ($this->extra_header) {
         $mail->AddCustomHeader($this->extra_header);
     }
     if ($this->files !== false) {
         foreach ($this->files as $name => $path) {
             if (!$mail->AddAttachment($path, $name)) {
                 writeErrorLog('Mailer could locate attachment:', $path);
             }
         }
     }
     if (!$mail->Send()) {
         writeErrorLog($mail->ErrorInfo);
         $this->error = $mail->ErrorInfo;
         return false;
     }
     return true;
 }
Пример #22
0
<?php

$pageNameIO = "inc.mysqli.conn.php";
// -- connect to mysql server
$mySQLiConn = @new mysqli("p:" . $dbHost, $dbReader, $dbReaderPass, $dbName, $dbPort);
$mySQLiConnError = "";
if ($mySQLiConn->connect_error) {
    $mySQLiConnError = "<div class='break6'></div>\n" . "<div class='red'>Database connection error.</div>\n" . "<div class='break6'></div>\n" . "<a href='" . $siteURL . "/monitor.php'>Try again</a>\n";
    writeErrorLog($pageNameIO, "Connect to SQL Server", "Error No: (" . $mySQLiConn->connect_errno . ") Error Msg: (" . $mySQLiConn->connect_error . ")");
} else {
    if (!$mySQLiConn->set_charset($dbCharSet)) {
        writeErrorLog($pageNameIO, "Set connection character set", "Error Msg: (" . $mySQLiConn->error . ")");
    }
}
Пример #23
0
 public function DoGoogleCheckout()
 {
     if (!$this->getConfigS('Google', 'enabled')) {
         writeErrorLog('Warning: received a request for a redirect to Google but Google Checkout is not configured.');
         return 'Google Checkout configuration is missing.';
     }
     include CARTREVISION . '/php/checkoutgc.cls.php';
     $checkout = new CheckoutGC($this);
     $checkout->setReturnUrl(urldecode(Config::GetInstance()->GetSessionVariable(CC_FB_URLEMBEDDED)) . '?action=checkedout');
     //		$checkout->setCancelUrl( getFullUrl( false, false ) . '?action=cancel' );
     // get checkout fields and redirect
     if (!$checkout->doCheckOut()) {
         return $checkout->resArray['MESSAGE'];
     }
 }
Пример #24
0
 public function LoadConfig($sdrive_config = null)
 {
     // load sdrive first, because the setting is needed to load the rest.
     if ($sdrive_config) {
         $this->sdrive =& $sdrive_config;
         if (isset($this->sdrive['sdrive_account_formbuilder_stats']) && !empty($this->sdrive['sdrive_account_formbuilder_stats'])) {
             FormPage::GetInstance()->SetStats($this->sdrive);
         }
     }
     // always record times in UTC, apply time zones only when displaying
     date_default_timezone_set('UTC');
     $txt = file_get_contents($this->sdrive ? CONFIG_FILE_SDRIVE : CONFIG_FILE, FILE_USE_INCLUDE_PATH);
     if ($txt === false) {
         writeErrorLog('Couldn\'t open or read:', CONFIG_FILE);
         echo '<html><body>Configuration missing.</body></html>';
         exit;
     }
     $this->config = json_decode(substr($txt, strpos($txt, "{")));
     if ($this->config == NULL) {
         FormPage::GetInstance()->SetErrors(array(array('err' => 'Failed to read or decode form configuration.')));
         writeErrorLog('Couldn\'t decode:', $this->sdrive ? CONFIG_FILE_SDRIVE : CONFIG_FILE);
         return false;
     }
     // move all settings that are not fields 1 level up
     if (isset($this->config->rules->_special)) {
         $this->config->special = $this->config->rules->_special;
         unset($this->config->rules->_special);
     }
     $tz = $this->GetConfig('settings', 'general_settings', 'timezone');
     if ($tz) {
         try {
             $this->user_timezone = new DateTimeZone($tz);
         } catch (Exception $e) {
             writeErrorLog('Problem setting Timezone "' . $tz . '", error message:', $e->getMessage());
             FormPage::GetInstance()->SetErrors(array(array('err' => 'Failed to set the timezone, check CoffeeCup FormBuilder\'s Settings->General tab for your timezone setting.')));
         }
     }
     #print_r( $this->config );
 }
Пример #25
0
 public function GetSetting($key)
 {
     if (!$this->_TableExists(FB_SETTINGS_TABLE)) {
         return '';
     }
     $qry = 'SELECT value FROM ' . FB_SETTINGS_TABLE . ' WHERE name=?;';
     $sth = $this->db->prepare($qry);
     if ($sth->execute(array($key)) === false) {
         writeErrorLog('Failed to get settings:', $qry);
         return '';
     }
     $row = $sth->fetch(PDO::FETCH_NUM);
     $sth->closeCursor();
     if ($row === false) {
         return '';
     } else {
         return $row[0];
     }
 }
Пример #26
0
<?php

$pageNameIO = "inc.requests.php";
$currentConnections = 0;
$currentServerLoad = 0;
if (!$mySQLiConn->connect_error) {
    $selectCurrentConnections = "SELECT COUNT(`USER`) AS `Connections` FROM `INFORMATION_SCHEMA`.`PROCESSLIST` WHERE `USER` = '" . $dbReader . "'";
    if ($resultCurrentConnections = $mySQLiConn->query($selectCurrentConnections)) {
        if ($resultCurrentConnections->num_rows > 0) {
            while ($rowCurrentConnections = $resultCurrentConnections->fetch_assoc()) {
                $currentConnections = $rowCurrentConnections["Connections"];
            }
        }
        $resultCurrentConnections->free();
    }
    if ($currentConnections > 1) {
        $currentConnections--;
    }
    $mysqliStats = explode("  ", $mySQLiConn->stat());
    $currentServerLoad = str_ireplace("Queries per second avg: ", "", $mysqliStats[7]);
} else {
    writeErrorLog($pageNameIO, "Connect to sql server", "ERROR: (" . $mySQLiConn->connect_error . ")");
}
Пример #27
0
 public function tel($name, $rules)
 {
     $telnum = isset($this->input[$name]) ? $this->input[$name] : '';
     if (strlen($telnum) == 0) {
         $this->post[$name] = '';
         // empty tel. number
         return;
     }
     $method = '_' . strtolower($rules->phone);
     if (!method_exists($this, $method)) {
         writeErrorLog('No format defined for telephone number type:', $rules->phone);
         $this->errors[] = array('field' => $name, 'err' => _T('No format specifier found for "%s".', $rules->phone));
     } else {
         if ($this->{$method}($telnum)) {
             $this->post[$name] = $telnum;
         } else {
             $this->_errormsg($name, $rules, _T('"%s" isn\'t recognized as a valid telephone number format.', empty($rules->label) ? $name : $rules->label));
         }
     }
 }
Пример #28
0
 protected function _Exec($sql)
 {
     $res = $this->db->exec($sql);
     if ($res === false) {
         writeErrorLog('Failed to execute query on table: ' . $this->table . '(' . $sql . ')', $this->db->errorInfo());
         $this->errors[] = array('err' => 'Failed to execute query associated to this form.');
         return false;
     }
     return true;
 }
Пример #29
0
/**
 * CoffeeCup Software's Web Form Builder.
 *
 * Functions to merge posted data into the HTML form definition.
 *
 *
 * @version $Revision: 2456 $
 * @author Cees de Gruijter
 * @category FB
 * @copyright Copyright (c) 2011 CoffeeCup Software, Inc. (http://www.coffeecup.com/)
 */
function MergeFormPost($post = false)
{
    if (!$post) {
        $post =& $_POST;
    }
    $dom = new DOMDocument('1.0', 'UTF-8');
    if (!$dom->loadHTML(FormPage::GetInstance()->source)) {
        writeErrorLog('Failed to parse HTML form.');
        return;
    }
    $errors = FormPage::GetInstance()->GetErrors(true);
    $processed_names = array();
    $display_max_error = Config::GetInstance()->GetConfig('special', 'maxnumerrors');
    if ($display_max_error === false) {
        $display_max_error = 1000;
    }
    // some ridiculously large number
    // get all input nodes with a name
    $xpath = new DOMXpath($dom);
    foreach ($xpath->query('//input[@name]') as $e) {
        $tagname = $e->getAttribute('name');
        $tagname_stripped = str_replace('[]', '', $tagname);
        // checkboxes have a names like "check1[]", but only "check1" is present in $post
        if (isset($post[$tagname]) || isset($post[$tagname_stripped])) {
            switch ($e->getAttribute('type')) {
                case 'radio':
                    if ($e->getAttribute('value') == $post[$tagname]) {
                        $e->setAttributeNode(new DOMAttr('checked', 'checked'));
                    }
                    break;
                case 'checkbox':
                    if (isset($post[$tagname_stripped]) && is_array($post[$tagname_stripped]) && in_array($e->getAttribute('value'), $post[$tagname_stripped])) {
                        $e->setAttributeNode(new DOMAttr('checked', 'checked'));
                    }
                    break;
                case 'file':
                    break;
                default:
                    $e->setAttributeNode(new DOMAttr('value', $post[$tagname]));
            }
        }
        if (!empty($tagname_stripped) && !in_array($tagname_stripped, $processed_names)) {
            if ($display_max_error > 0) {
                InserErrorLabel($dom, $e, $errors);
                --$display_max_error;
            }
            $processed_names[] = $tagname_stripped;
        }
    }
    // get all select nodes with a name
    foreach ($xpath->query('//select[@name]') as $e) {
        // findout if the name is defined as an array[] or as a scalar
        $name = $e->getAttribute('name');
        $is_array = false;
        if (($p = strpos($name, '[]')) !== false) {
            $name = substr($name, 0, -2);
            $is_array = true;
        }
        if (isset($post[$name])) {
            foreach ($e->getElementsByTagName('option') as $child) {
                // set or unset the selected attribute
                if ($is_array) {
                    if (in_array($child->getAttribute('value'), $post[$name]) && !$child->hasAttribute('selected')) {
                        $child->setAttributeNode(new DOMAttr('selected', 'selected'));
                    } else {
                        if ($child->hasAttribute('selected')) {
                            $child->removeAttribute('selected');
                        }
                    }
                } else {
                    if ($child->getAttribute('value') == $post[$name] && !$child->hasAttribute('selected')) {
                        $child->setAttributeNode(new DOMAttr('selected', 'selected'));
                    } else {
                        if ($child->hasAttribute('selected')) {
                            $child->removeAttribute('selected');
                        }
                    }
                }
            }
        }
        if (!empty($name) && !in_array($name, $processed_names)) {
            InserErrorLabel($dom, $e, $errors);
            $processed_names[] = $name;
        }
    }
    // get all textarea nodes with a name
    foreach ($xpath->query('//textarea[@name]') as $e) {
        $name = $e->getAttribute('name');
        if (isset($post[$name])) {
            $e->appendChild($dom->createTextNode($post[$name]));
        }
        if (!in_array($name, $processed_names)) {
            InserErrorLabel($dom, $e, $errors);
            $processed_names[] = $name;
        }
    }
    // reCaptcha error should also be placed underneath the field
    if (isset($errors['reCaptcha'])) {
        $node = $dom->createElement('label', $errors['reCaptcha']);
        $node->setAttributeNode(new DOMAttr('for', 'fb-captcha_control'));
        $node->setAttributeNode(new DOMAttr('class', 'error'));
        $dom->getElementById('fb-captcha_control')->appendChild($node);
        $processed_names[] = 'reCaptcha';
    }
    // add errors from fields that we haven't processed yet to the error div
    MakeErrorNode($dom, $errors, $processed_names);
    return $dom->saveHTML();
}