當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Misc::randNumber方法代碼示例

本文整理匯總了PHP中Misc::randNumber方法的典型用法代碼示例。如果您正苦於以下問題:PHP Misc::randNumber方法的具體用法?PHP Misc::randNumber怎麽用?PHP Misc::randNumber使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Misc的用法示例。


在下文中一共展示了Misc::randNumber方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: createUpgradedTicket

 function createUpgradedTicket()
 {
     global $cfg;
     //Create a ticket to make the system warm and happy.
     $dept_id = $cfg->getDefaultDeptId();
     $prio_id = $cfg->getDefaultPriorityId();
     $sql = 'INSERT INTO ' . TICKET_TABLE . ' SET created=NOW(), status="open", source="Web" ' . " ,priority_id={$prio_id}, dept_id={$dept_id}, topic_id=0 " . ' ,ticketID=' . db_input(Misc::randNumber(6)) . ' ,email="support@osticket.com" ' . ' ,name="osTicket Support" ' . ' ,subject="osTicket Upgraded!"';
     if (db_query($sql, false) && ($tid = db_insert_id())) {
         if (!($msg = file_get_contents(UPGRADE_DIR . 'msg/upgraded.txt'))) {
             $msg = 'Congratulations and Thank you for choosing osTicket!';
         }
         $sql = 'INSERT INTO ' . TICKET_THREAD_TABLE . ' SET created=NOW()' . ', source="Web" ' . ', thread_type="M" ' . ', ticket_id=' . db_input($tid) . ', title=' . db_input('osTicket Upgraded') . ', body=' . db_input($msg);
         db_query($sql, false);
     }
 }
開發者ID:pkdevboxy,項目名稱:osTicket-1.7,代碼行數:15,代碼來源:class.upgrader.php

示例2: __next

 function __next($digits = 6)
 {
     if ($digits < 6) {
         $digits = 6;
     }
     return Misc::randNumber($digits);
 }
開發者ID:KingsleyGU,項目名稱:osticket,代碼行數:7,代碼來源:class.sequence.php

示例3: db_query

                        db_query($sql);
                    }
                    //Update
                    $sql = 'UPDATE ' . PREFIX . 'email_template SET updated=NOW() ' . ',ticket_notice_subj = "[#%ticket] %subject"' . ',ticket_notice_body = "%name,\\r\\n\\r\\nOur customer care team personnel has created a ticket #%ticket on your behalf, with the following message;\\r\\n\\r\\n%message\\r\\n\\r\\nIf you wish to provide additional comments or information regarding this issue, please don\'t open a new ticket. You can update or view this ticket\'s progress online here: %url/view.php?e=%email&t=%ticket.\\r\\n\\r\\n%signature"';
                    db_query($sql);
                }
            }
    }
    if (!$errors) {
        //upgrade went smooth!
        //Log a message.
        $log = sprintf("Congratulations osTicket upgraded to version %s by %s \n\nThank you for choosing osTicket!", VERSION, $thisuser->getName());
        $sql = 'INSERT INTO ' . PREFIX . 'syslog SET created=NOW(),updated=NOW() ' . ',title="osTicket upgraded!",log_type="Debug" ' . ',log=' . db_input($log) . ',ip_address=' . db_input($_SERVER['REMOTE_ADDR']);
        mysql_query($sql);
        //Create a ticket
        $sql = 'INSERT INTO ' . PREFIX . 'ticket SET created=NOW(),ticketID=' . db_input(Misc::randNumber(6)) . ',dept_id=' . db_input($deptId ? $deptId : $cfg->getDefaultDeptId()) . ",priority_id=2,email='support@osticket.com',name='osTicket Support' " . ",subject='osTicket Upgraded!',helptopic='osTicket Support',status='open',source='Web'";
        if (db_query($sql) && ($id = db_insert_id())) {
            $sql = 'INSERT INTO ' . PREFIX . 'ticket_message SET created=NOW(), updated=NOW(), source="Web" ' . ',ticket_id=' . db_input($id) . ',message=' . db_input(OSTICKET_UPGRADED);
            db_query($sql);
        }
        //Report the good news.
        $inc = 'upgradedone.inc.php';
        $msg = 'osTicket upgraded to version ' . VERSION;
    } else {
        //errors....aborting.
        $inc = 'abortedupgrade.inc.php';
        $errors['err'] = $errors['err'] ? $errors['err'] : 'Yikes! upgrade error(s) occured';
        $_SESSION['abort'] = true;
    }
}
$title = sprintf('osTicket upgrade wizard v %s', '1.6 ST (stable)');
開發者ID:KingsleyGU,項目名稱:OSTicket-Reloaded,代碼行數:31,代碼來源:upgrade.php

示例4: genExtRandID

 function genExtRandID()
 {
     global $cfg;
     //We can allow collissions...extId and email must be unique ...so same id with diff emails is ok..
     // But for clarity...we are going to make sure it is unique.
     $id = Misc::randNumber(EXT_TICKET_ID_LEN);
     if (db_num_rows(db_query('SELECT ticket_id FROM ' . TICKET_TABLE . ' WHERE ticketID=' . db_input($id)))) {
         return Ticket::genExtRandID();
     }
     return $id;
 }
開發者ID:supaket,項目名稱:helpdesk,代碼行數:11,代碼來源:class.ticket.php

示例5: mysql_query

     mysql_query($sql);
     //3 - noreply email
     $sql='INSERT INTO '.PREFIX.'email SET created=NOW(),updated=NOW(),priority_id=1,dept_id=1'.
          ',name='.db_input('').',email='.db_input('noreply@'.$domain);
     mysql_query($sql);
     //config info 
     $sql='INSERT INTO '.PREFIX.'config SET updated=NOW() '.
          ',isonline=0,default_email_id=1,alert_email_id=2,default_dept_id=1,default_template_id=1'.
          ',timezone_offset='.db_input($tzoffset).
          ',ostversion='.db_input(VERSION).
          ',admin_email='.db_input($_POST['email']).
          ',helpdesk_url='.db_input(URL).
          ',helpdesk_title='.db_input($_POST['title']);
     mysql_query($sql);
     //Create a ticket to make the system warm and happy.
     $sql='INSERT INTO '.PREFIX.'ticket SET created=NOW(),ticketID='.db_input(Misc::randNumber(6)).
         ",priority_id=2,dept_id=1,email='support@osticket.com',name='osTicket Support' ".
         ",subject='osTicket Installed!',helptopic='Commercial support',status='open',source='Web'";
     if(db_query($sql) && ($id=db_insert_id())){
         db_query('INSERT INTO '.PREFIX."ticket_message VALUES (1,$id,NULL,".db_input(OSTICKET_INSTALLED).",NULL,'Web','',NOW(),NULL)");
     }
     //Log a message.
     $sql='INSERT INTO '.PREFIX.'syslog SET created=NOW(),updated=NOW() '.
          ',title="osTicket installed!",log_type="Debug" '.
          ',log='.db_input("Congratulations osTicket basic installation completed!\n\nThank you for choosing osTicket!").
          ',ip_address='.db_input($_SERVER['REMOTE_ADDR']);
     mysql_query($sql);
     $msg='Congratulations osTicket basic installation completed!';
     $inc='done.inc.php';
 }else{
     $errors['err']='Unable to write to config file!';
開發者ID:hungnv0789,項目名稱:vhtm,代碼行數:31,代碼來源:install.php

示例6: str_replace

         $configfile = str_replace('%CONFIG-DBPASS', $_POST['dbpass'], $configfile);
         $configfile = str_replace('%CONFIG-PREFIX', $_POST['prefix'], $configfile);
         if (ftruncate($fp, 0) && fwrite($fp, $configfile)) {
             $tzoffset = date("Z") / 3600;
             //Server's offset.
             list($uname, $domain) = explode('@', $_POST['sysemail']);
             //Create admin user. Dummy last name.
             $sql = 'INSERT INTO ' . PREFIX . 'staff SET created=NOW(), isadmin=1,change_passwd=0,group_id=1,dept_id=1 ' . ',email=' . db_input($_POST['email']) . ',lastname=' . db_input('Admin') . ',username=' . db_input($_POST['username']) . ',passwd=' . db_input(MD5($_POST['password'])) . ',timezone_offset=' . db_input($tzoffset);
             db_query($sql);
             //Add support email.
             db_query('INSERT INTO ' . PREFIX . 'email VALUES (1,0,2,1,' . db_input($_POST['sysemail']) . ',"",NOW(),NOW())');
             //Update config info
             $sql = 'UPDATE ' . PREFIX . 'config SET default_email=1,default_dept=1,timezone_offset=' . db_input($tzoffset) . ',ostversion=' . db_input(VERSION) . ',admin_email=' . db_input($_POST['email']) . ',alert_email=' . db_input('alerts@' . $domain) . ',noreply_email=' . db_input('noreply@' . $domain) . ',helpdesk_url=' . db_input($_POST['url']) . ',helpdesk_title=' . db_input($_POST['title']);
             db_query($sql);
             //Create a ticket to make the system warm and happy.
             $tid = Misc::randNumber(6);
             $sql = 'INSERT INTO ' . PREFIX . 'ticket SET created=NOW(),ticketID=' . db_input($tid) . ",priority_id=2,dept_id=1,email='support@osticket.com',name='osTicket Support' " . ",subject='osTicket Installed!',status='open',source='Web'";
             if (db_query($sql) && ($id = db_insert_id())) {
                 $intro = "\nThank you for choosing osTicket.\n\n                            Make sure you join osTicket forums http://osticket.com/forums to stay upto date on the latest news, security alerts and updates. osTicket forums is also a great place to get assistance, guidance and help. In addition to the forums, osTicket wiki provides useful collection of educational materials, documentation, and notes from the community.\n\n If you are looking for greater level of support, we provide professional services and custom commercial support with guaranteed response times and access to the core development team. We can also customize the system to meet your unique needs.\n\n                                For more information or to discuss your needs, please contact us today. Any feedback will be appreciated!\n                                \nosTicket Team";
                 db_query('INSERT INTO ' . PREFIX . "ticket_message VALUES (1,{$id}," . db_input($intro) . ",NULL,'Web','',NOW(),NULL)");
             }
             $msg = 'Congratulations osTicket basic installation completed!';
             $inc = 'done.inc.php';
         } else {
             $errors['err'] = 'Unable to write to config file!';
         }
     }
     @fclose($fp);
 } else {
     $errors['err'] = $errors['err'] ? $errors['err'] : 'Error(s) occured. Please correct them and try again';
 }
開發者ID:googlecode-mirror,項目名稱:barbos,代碼行數:31,代碼來源:index.php

示例7: genRandTicketNumber

 function genRandTicketNumber($len = EXT_TICKET_ID_LEN)
 {
     //We can allow collissions...number and email must be unique ...so
     // same number with diff emails is ok.. But for clarity...we are going to make sure it is unique.
     $number = Misc::randNumber($len);
     if (db_num_rows(db_query('SELECT ticket_id FROM ' . TICKET_TABLE . '
                     WHERE `number`=' . db_input($number)))) {
         return Ticket::genRandTicketNumber($len);
     }
     return $number;
 }
開發者ID:ed00m,項目名稱:osTicket-1.8,代碼行數:11,代碼來源:class.ticket.php

示例8: install


//.........這裏部分代碼省略.........
     if (!file_exists($this->getConfigFile()) || !($configFile = file_get_contents($this->getConfigFile()))) {
         $this->errors['err'] = 'Unable to read config file. Permission denied! (#2)';
     } elseif (!($fp = @fopen($this->getConfigFile(), 'r+'))) {
         $this->errors['err'] = 'Unable to open config file for writing. Permission denied! (#3)';
     } else {
         $streams = DatabaseMigrater::getUpgradeStreams(INCLUDE_DIR . 'upgrader/streams/');
         foreach ($streams as $stream => $signature) {
             $schemaFile = INC_DIR . "streams/{$stream}/install-mysql.sql";
             if (!file_exists($schemaFile) || !($fp2 = fopen($schemaFile, 'rb'))) {
                 $this->errors['err'] = $stream . ': Internal Error - please make sure your download is the latest (#1)';
             } elseif (!($hash = md5(fread($fp2, filesize($schemaFile)))) || strcasecmp($signature, $hash)) {
                 $this->errors['err'] = $stream . ': Unknown or invalid schema signature (' . $signature . ' .. ' . $hash . ')';
             } elseif (!$this->load_sql_file($schemaFile, $vars['prefix'], true, $debug)) {
                 $this->errors['err'] = $stream . ': Error parsing SQL schema! Get help from developers (#4)';
             }
         }
     }
     $sql = 'SELECT `id` FROM ' . PREFIX . 'sla ORDER BY `id` LIMIT 1';
     $sla_id_1 = db_result(db_query($sql, false), 0);
     $sql = 'SELECT `dept_id` FROM ' . PREFIX . 'department ORDER BY `dept_id` LIMIT 1';
     $dept_id_1 = db_result(db_query($sql, false), 0);
     $sql = 'SELECT `tpl_id` FROM ' . PREFIX . 'email_template_group ORDER BY `tpl_id` LIMIT 1';
     $template_id_1 = db_result(db_query($sql, false), 0);
     $sql = 'SELECT `group_id` FROM ' . PREFIX . 'groups ORDER BY `group_id` LIMIT 1';
     $group_id_1 = db_result(db_query($sql, false), 0);
     $sql = 'SELECT `id` FROM ' . PREFIX . 'timezone WHERE offset=-5.0 LIMIT 1';
     $eastern_timezone = db_result(db_query($sql, false), 0);
     if (!$this->errors) {
         //Create admin user.
         $sql = 'INSERT INTO ' . PREFIX . 'staff SET created=NOW() ' . ", isactive=1, isadmin=1, group_id={$group_id_1}, dept_id={$dept_id_1}" . ", timezone_id={$eastern_timezone}, max_page_size=25" . ', email=' . db_input($vars['admin_email']) . ', firstname=' . db_input($vars['fname']) . ', lastname=' . db_input($vars['lname']) . ', username=' . db_input($vars['username']) . ', passwd=' . db_input(Passwd::hash($vars['passwd']));
         if (!db_query($sql, false) || !($uid = db_insert_id())) {
             $this->errors['err'] = 'Unable to create admin user (#6)';
         }
     }
     if (!$this->errors) {
         //Create default emails!
         $email = $vars['email'];
         list(, $domain) = explode('@', $vars['email']);
         $sql = 'INSERT INTO ' . PREFIX . 'email (`name`,`email`,`created`,`updated`) VALUES ' . " ('Support','{$email}',NOW(),NOW())" . ",('osTicket Alerts','alerts@{$domain}',NOW(),NOW())" . ",('','noreply@{$domain}',NOW(),NOW())";
         $support_email_id = db_query($sql, false) ? db_insert_id() : 0;
         $sql = 'SELECT `email_id` FROM ' . PREFIX . "email WHERE `email`='alerts@{$domain}' LIMIT 1";
         $alert_email_id = db_result(db_query($sql, false), 0);
         //Create config settings---default settings!
         //XXX: rename ostversion  helpdesk_* ??
         // XXX: Some of this can go to the core install file
         $defaults = array('isonline' => '0', 'default_email_id' => $support_email_id, 'alert_email_id' => $alert_email_id, 'default_dept_id' => $dept_id_1, 'default_sla_id' => $sla_id_1, 'default_timezone_id' => $eastern_timezone, 'default_template_id' => $template_id_1, 'admin_email' => db_input($vars['admin_email']), 'schema_signature' => db_input($streams['core']), 'helpdesk_url' => db_input(URL), 'helpdesk_title' => db_input($vars['name']));
         foreach ($defaults as $key => $value) {
             $sql = 'UPDATE ' . PREFIX . 'config SET updated=NOW(), value=' . $value . ' WHERE namespace="core" AND `key`=' . db_input($key);
             if (!db_query($sql, false)) {
                 $this->errors['err'] = 'Unable to create config settings (#7)';
             }
         }
         foreach ($streams as $stream => $signature) {
             if ($stream != 'core') {
                 $sql = 'INSERT INTO ' . PREFIX . 'config (`namespace`, `key`, `value`, `updated`) ' . 'VALUES (' . db_input($stream) . ', ' . db_input('schema_signature') . ', ' . db_input($signature) . ', NOW())';
                 if (!db_query($sql, false)) {
                     $this->errors['err'] = 'Unable to create config settings (#7)';
                 }
             }
         }
     }
     if ($this->errors) {
         return false;
     }
     //Abort on internal errors.
     //Rewrite the config file - MUST be done last to allow for installer recovery.
     $configFile = str_replace("define('OSTINSTALLED',FALSE);", "define('OSTINSTALLED',TRUE);", $configFile);
     $configFile = str_replace('%ADMIN-EMAIL', $vars['admin_email'], $configFile);
     $configFile = str_replace('%CONFIG-DBHOST', $vars['dbhost'], $configFile);
     $configFile = str_replace('%CONFIG-DBNAME', $vars['dbname'], $configFile);
     $configFile = str_replace('%CONFIG-DBUSER', $vars['dbuser'], $configFile);
     $configFile = str_replace('%CONFIG-DBPASS', $vars['dbpass'], $configFile);
     $configFile = str_replace('%CONFIG-PREFIX', $vars['prefix'], $configFile);
     $configFile = str_replace('%CONFIG-SIRI', Misc::randCode(32), $configFile);
     if (!$fp || !ftruncate($fp, 0) || !fwrite($fp, $configFile)) {
         $this->errors['err'] = 'Unable to write to config file. Permission denied! (#5)';
         return false;
     }
     @fclose($fp);
     /************* Make the system happy ***********************/
     $sql = 'UPDATE ' . PREFIX . "email SET dept_id={$dept_id_1}";
     db_query($sql, false);
     $sql = 'UPDATE ' . PREFIX . "department SET email_id={$support_email_id}" . ", autoresp_email_id={$support_email_id}";
     db_query($sql, false);
     //Create a ticket to make the system warm and happy.
     $sql = 'INSERT INTO ' . PREFIX . 'ticket SET created=NOW(), status="open", source="Web" ' . " ,priority_id=0, dept_id={$dept_id_1}, topic_id=0 " . ' ,ticketID=' . db_input(Misc::randNumber(6)) . ' ,email="support@osticket.com" ' . ' ,name="osTicket Support" ' . ' ,subject="osTicket Installed!"';
     if (db_query($sql, false) && ($tid = db_insert_id())) {
         if (!($msg = file_get_contents(INC_DIR . 'msg/installed.txt'))) {
             $msg = 'Congratulations and Thank you for choosing osTicket!';
         }
         $sql = 'INSERT INTO ' . PREFIX . 'ticket_thread SET created=NOW()' . ', source="Web" ' . ', thread_type="M" ' . ', ticket_id=' . db_input($tid) . ', title=' . db_input('osTicket Installed') . ', body=' . db_input($msg);
         db_query($sql, false);
     }
     //TODO: create another personalized ticket and assign to admin??
     //Log a message.
     $msg = "Congratulations osTicket basic installation completed!\n\nThank you for choosing osTicket!";
     $sql = 'INSERT INTO ' . PREFIX . 'syslog SET created=NOW(), updated=NOW(), log_type="Debug" ' . ', title="osTicket installed!"' . ', log=' . db_input($msg) . ', ip_address=' . db_input($_SERVER['REMOTE_ADDR']);
     db_query($sql, false);
     return true;
 }
開發者ID:pkdevboxy,項目名稱:osTicket-1.7,代碼行數:101,代碼來源:class.installer.php

示例9: list

             //Add emails - hopefully the domain is actually valid
             list($uname, $domain) = explode('@', $_POST['sysemail']);
             //1 - main support email
             $sql = 'INSERT INTO ' . PREFIX . 'email SET created=NOW(),updated=NOW(),priority_id=2,dept_id=1' . ',name=' . db_input('Katak-support') . ',email=' . db_input($_POST['sysemail']);
             db_query($sql);
             //2 - alert email
             $sql = 'INSERT INTO ' . PREFIX . 'email SET created=NOW(),updated=NOW(),priority_id=1,dept_id=1' . ',name=' . db_input('Katak-support Alerts') . ',email=' . db_input('alerts@' . $domain);
             db_query($sql);
             //3 - noreply email
             $sql = 'INSERT INTO ' . PREFIX . 'email SET created=NOW(),updated=NOW(),priority_id=1,dept_id=1' . ',name=' . db_input('') . ',email=' . db_input('noreply@' . $domain);
             db_query($sql);
             //config info
             $sql = 'INSERT INTO ' . PREFIX . 'config SET updated=NOW() ' . ',isonline=0,default_email_id=1,alert_email_id=2,default_dept_id=1,default_template_id=1' . ',staff_language=' . db_input($_POST['language']) . ',user_language=' . db_input($_POST['language']) . ',timezone_offset=' . db_input($tzoffset) . ',ktsversion=' . db_input(VERSION) . ',helpdesk_url=' . db_input(URL) . ',helpdesk_title=' . db_input($_POST['title']);
             db_query($sql);
             //Create a first ticket as welcome and example.
             $sql = 'INSERT INTO ' . PREFIX . 'ticket SET created=NOW(),ticketID=' . db_input(Misc::randNumber(6)) . ',priority_id=2,topic_id=1,dept_id=1,email="' . $_POST['sysemail'] . '",name="Katak-support" ' . ',subject="Katak-support installed!",status="open",source="Web"';
             if (db_query($sql) && ($id = db_insert_id())) {
                 db_query('INSERT INTO ' . PREFIX . 'ticket_message SET ticket_id=1,msg_type="F",message="' . db_input(KATAK_INSTALLED) . '",source="web",created=NOW()');
             }
             //Log a message.
             $sql = 'INSERT INTO ' . PREFIX . 'syslog SET created=NOW() ' . ',title="Katak-support installed",log_type="Debug" ' . ',log=' . db_input("Katak-support " . VERSION . " basic installation completed\n\nThank you for choosing Katak-support!") . ',ip_address=' . db_input($_SERVER['REMOTE_ADDR']);
             db_query($sql);
             $msg = 'Congratulations: Katak-support basic installation completed!';
             $inc = 'done.inc.php';
         } else {
             $errors['err'] = 'Unable to write to config file!';
         }
     }
     @fclose($fp);
 } else {
     $errors['err'] = $errors['err'] ? $errors['err'] : 'Error(s) occured. Please correct them and try again';
開發者ID:jahanzaibbahadur,項目名稱:Katak-support,代碼行數:31,代碼來源:install.php

示例10: install


//.........這裏部分代碼省略.........
     if ($vars['prefix'] && substr($vars['prefix'], -1) != '_') {
         $this->errors['prefix'] = 'Bad prefix. Must have underscore (_) at the end. e.g \'ost_\'';
     }
     //Make sure admin username is not very predictable. XXX: feels dirty but necessary
     if (!$this->errors['username'] && in_array(strtolower($vars['username']), array('admin', 'admins', 'username', 'osticket'))) {
         $this->errors['username'] = 'Bad username';
     }
     //MYSQL: Connect to the DB and check the version & database (create database if it doesn't exist!)
     if (!$this->errors) {
         if (!db_connect($vars['dbhost'], $vars['dbuser'], $vars['dbpass'])) {
             $this->errors['db'] = 'Unable to connect to MySQL server. Possibly invalid login info.';
         } elseif (db_version() < $this->getMySQLVersion()) {
             $this->errors['db'] = sprintf('osTicket requires MySQL %s or better!', $this->getMySQLVersion());
         } elseif (!db_select_database($vars['dbname']) && !db_create_database($vars['dbname'])) {
             $this->errors['dbname'] = 'Database doesn\'t exist';
             $this->errors['db'] = 'Unable to create the database.';
         } elseif (!db_select_database($vars['dbname'])) {
             $this->errors['dbname'] = 'Unable to select the database';
         }
     }
     //bailout on errors.
     if ($this->errors) {
         return false;
     }
     /*************** We're ready to install ************************/
     define('ADMIN_EMAIL', $vars['admin_email']);
     //Needed to report SQL errors during install.
     define('PREFIX', $vars['prefix']);
     //Table prefix
     $schemaFile = INC_DIR . 'sql/osTicket-mysql.sql';
     //DB dump.
     $debug = true;
     //XXX:Change it to true to show SQL errors.
     //Last minute checks.
     if (!file_exists($schemaFile)) {
         $this->errors['err'] = 'Internal Error - please make sure your download is the latest (#1)';
     } elseif (!($signature = trim(file_get_contents("{$schemaFile}.md5"))) || strcasecmp($signature, md5_file($schemaFile))) {
         $this->errors['err'] = 'Unknown or invalid schema signature (' . $signature . ' .. ' . md5_file($schemaFile) . ')';
     } elseif (!file_exists($this->getConfigFile()) || !($configFile = file_get_contents($this->getConfigFile()))) {
         $this->errors['err'] = 'Unable to read config file. Permission denied! (#2)';
     } elseif (!($fp = @fopen($this->getConfigFile(), 'r+'))) {
         $this->errors['err'] = 'Unable to open config file for writing. Permission denied! (#3)';
     } elseif (!$this->load_sql_file($schemaFile, $vars['prefix'], true, $debug)) {
         $this->errors['err'] = 'Error parsing SQL schema! Get help from developers (#4)';
     }
     if (!$this->errors) {
         //Create admin user.
         $sql = 'INSERT INTO ' . PREFIX . 'staff SET created=NOW() ' . ', isactive=1, isadmin=1, group_id=1, dept_id=1, timezone_id=8, max_page_size=25 ' . ', email=' . db_input($_POST['admin_email']) . ', firstname=' . db_input($vars['fname']) . ', lastname=' . db_input($vars['lname']) . ', username=' . db_input($vars['username']) . ', passwd=' . db_input(Passwd::hash($vars['passwd']));
         if (!mysql_query($sql) || !($uid = mysql_insert_id())) {
             $this->errors['err'] = 'Unable to create admin user (#6)';
         }
     }
     if (!$this->errors) {
         //Create config settings---default settings!
         //XXX: rename ostversion  helpdesk_* ??
         $sql = 'INSERT INTO ' . PREFIX . 'config SET updated=NOW(), isonline=0 ' . ', default_email_id=1, alert_email_id=2, default_dept_id=1 ' . ', default_sla_id=1, default_timezone_id=8, default_template_id=1 ' . ', admin_email=' . db_input($vars['admin_email']) . ', schema_signature=' . db_input($signature) . ', helpdesk_url=' . db_input(URL) . ', helpdesk_title=' . db_input($vars['name']);
         if (!mysql_query($sql) || !($cid = mysql_insert_id())) {
             $this->errors['err'] = 'Unable to create config settings (#7)';
         }
     }
     if ($this->errors) {
         return false;
     }
     //Abort on internal errors.
     //Rewrite the config file - MUST be done last to allow for installer recovery.
     $configFile = str_replace("define('OSTINSTALLED',FALSE);", "define('OSTINSTALLED',TRUE);", $configFile);
     $configFile = str_replace('%ADMIN-EMAIL', $vars['admin_email'], $configFile);
     $configFile = str_replace('%CONFIG-DBHOST', $vars['dbhost'], $configFile);
     $configFile = str_replace('%CONFIG-DBNAME', $vars['dbname'], $configFile);
     $configFile = str_replace('%CONFIG-DBUSER', $vars['dbuser'], $configFile);
     $configFile = str_replace('%CONFIG-DBPASS', $vars['dbpass'], $configFile);
     $configFile = str_replace('%CONFIG-PREFIX', $vars['prefix'], $configFile);
     $configFile = str_replace('%CONFIG-SIRI', Misc::randcode(32), $configFile);
     if (!$fp || !ftruncate($fp, 0) || !fwrite($fp, $configFile)) {
         $this->errors['err'] = 'Unable to write to config file. Permission denied! (#5)';
         return false;
     }
     @fclose($fp);
     /************* Make the system happy ***********************/
     //Create default emails!
     $email = $vars['email'];
     list(, $domain) = explode('@', $vars['email']);
     $sql = 'INSERT INTO ' . PREFIX . 'email (`email_id`, `dept_id`, `name`,`email`,`created`,`updated`) VALUES ' . " (1,1,'Support','{$email}',NOW(),NOW())" . ",(2,1,'osTicket Alerts','alerts@{$domain}',NOW(),NOW())" . ",(3,1,'','noreply@{$domain}',NOW(),NOW())";
     @mysql_query($sql);
     //Create a ticket to make the system warm and happy.
     $sql = 'INSERT INTO ' . PREFIX . 'ticket SET created=NOW(), status="open", source="Web" ' . ' ,priority_id=2, dept_id=1, topic_id=1 ' . ' ,ticketID=' . db_input(Misc::randNumber(6)) . ' ,email="support@osticket.com" ' . ' ,name="osTicket Support" ' . ' ,subject="osTicket Installed!"';
     if (mysql_query($sql) && ($tid = mysql_insert_id())) {
         if (!($msg = file_get_contents(INC_DIR . 'msg/installed.txt'))) {
             $msg = 'Congratulations and Thank you for choosing osTicket!';
         }
         $sql = 'INSERT INTO ' . PREFIX . 'ticket_thread SET created=NOW()' . ', source="Web" ' . ', thread_type="M" ' . ', ticket_id=' . db_input($tid) . ', title=' . db_input('osTicket Installed') . ', body=' . db_input($msg);
         @mysql_query($sql);
     }
     //TODO: create another personalized ticket and assign to admin??
     //Log a message.
     $msg = "Congratulations osTicket basic installation completed!\n\nThank you for choosing osTicket!";
     $sql = 'INSERT INTO ' . PREFIX . 'syslog SET created=NOW(), updated=NOW(), log_type="Debug" ' . ', title="osTicket installed!"' . ', log=' . db_input($msg) . ', ip_address=' . db_input($_SERVER['REMOTE_ADDR']);
     @mysql_query($sql);
     return true;
 }
開發者ID:nunomartins,項目名稱:osTicket-1.7,代碼行數:101,代碼來源:class.installer.php

示例11: list

             //Add emails - hopefully the domain is actually valid
             list($uname, $domain) = explode('@', $_POST['sysemail']);
             //1 - main support email
             $sql = 'INSERT INTO ' . PREFIX . 'email SET created=NOW(),updated=NOW(),priority_id=2,dept_id=1' . ',name=' . db_input('Support') . ',email=' . db_input($_POST['sysemail']);
             mysql_query($sql);
             //2 - alert email
             $sql = 'INSERT INTO ' . PREFIX . 'email SET created=NOW(),updated=NOW(),priority_id=1,dept_id=1' . ',name=' . db_input('osTicket Alerts') . ',email=' . db_input('alerts@' . $domain);
             mysql_query($sql);
             //3 - noreply email
             $sql = 'INSERT INTO ' . PREFIX . 'email SET created=NOW(),updated=NOW(),priority_id=1,dept_id=1' . ',name=' . db_input('') . ',email=' . db_input('noreply@' . $domain);
             mysql_query($sql);
             //config info
             $sql = 'INSERT INTO ' . PREFIX . 'config SET updated=NOW() ' . ',isonline=0,default_email_id=1,alert_email_id=2,default_dept_id=1,default_template_id=1' . ',timezone_offset=' . db_input($tzoffset) . ',ostversion=' . db_input(VERSION) . ',admin_email=' . db_input($_POST['email']) . ',helpdesk_url=' . db_input(URL) . ',helpdesk_title=' . db_input($_POST['title']);
             mysql_query($sql);
             //Create a ticket to make the system warm and happy.
             $sql = 'INSERT INTO ' . PREFIX . 'ticket SET created=NOW(),ticketID=' . db_input(Misc::randNumber(6)) . ",priority_id=2,dept_id=1,email='support@osticket.com',name='osTicket Support' " . ",subject='osTicket Installed!',helptopic='Commercial support',status='open',source='Web'";
             if (db_query($sql) && ($id = db_insert_id())) {
                 db_query('INSERT INTO ' . PREFIX . "ticket_message VALUES (1,{$id},NULL," . db_input(OSTICKET_INSTALLED) . ",NULL,'Web','',NOW(),NULL)");
             }
             //Log a message.
             $sql = 'INSERT INTO ' . PREFIX . 'syslog SET created=NOW(),updated=NOW() ' . ',title="osTicket installed!",log_type="Debug" ' . ',log=' . db_input("Congratulations osTicket basic installation completed!\n\nThank you for choosing osTicket!") . ',ip_address=' . db_input($_SERVER['REMOTE_ADDR']);
             mysql_query($sql);
             $msg = 'Congratulations osTicket basic installation completed!';
             $inc = 'done.inc.php';
         } else {
             $errors['err'] = 'Unable to write to config file!';
         }
     }
     @fclose($fp);
 } else {
     $errors['err'] = $errors['err'] ? $errors['err'] : 'Error(s) occured. Please correct them and try again';
開發者ID:supaket,項目名稱:helpdesk,代碼行數:31,代碼來源:install.php


注:本文中的Misc::randNumber方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。