Jump to content

wheakory

Members
  • Posts

    10
  • Joined

  • Last visited

    Never

Everything posted by wheakory

  1. How would I call this code (below) once in my php script for all services that need to be done on transactions Create account/enable/suspend/delete google accounts. Right now I have this code in every PHP function. I tried putting this in an include file but that didn't work. If I could set this once globally that would be nice. That way I would have to keep getting connected which slows down the transaction process. (RESUED CODE) // load classes require_once 'Zend/Loader.php'; Zend_Loader::loadClass('Zend_Gdata'); Zend_Loader::loadClass('Zend_Gdata_ClientLogin'); Zend_Loader::loadClass('Zend_Gdata_Gapps'); Zend_Loader::loadClass('Zend_Http_Client'); $user = "isuadmin@gdev.isu.edu"; $pass = "*********"; $domain = "gdev.isu.edu"; $client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, Zend_Gdata_Gapps::AUTH_SERVICE_NAME); // $service = new Zend_Gdata_Gapps($client, $domain); (ALL CODE) #!/usr/bin/php -q <?php $loop_id = 1; while ($loop_id > 0) { $fileshutdown = '/home/acctmnt/gmail-SHUTDOWN'; if (file_exists($fileshutdown)) { exit(); } // include ("globals.inc"); $error_flag = "no"; $err_message = ""; $path = '/home/wheakory/ZendGdata-1.5.3/library/Zend'; set_include_path(get_include_path() . PATH_SEPARATOR . $path); $files1 = glob("/home/acctmnt/acctFiles/*.m1ad"); $files2 = glob("/home/acctmnt/acctFiles/*.m1ds"); $files3 = glob("/home/acctmnt/acctFiles/*.m1en"); $files4 = glob("/home/acctmnt/acctFiles/*.m1pg"); $files5 = glob("/home/acctmnt/acctFiles/*.m1ps"); // Call functions to begin Transaction process loadclass(); if ($files1 != null) { gmailAdd($files1); } if ($files2 != null) { gmailDisable($files2); } if ($files3 != null) { gmailEnable($files3); } if ($files4 != null) { gmailPurge($files4); } sleep(10); } //loop function gmailAdd($files1) { // load classes require_once 'Zend/Loader.php'; Zend_Loader::loadClass('Zend_Gdata'); Zend_Loader::loadClass('Zend_Gdata_ClientLogin'); Zend_Loader::loadClass('Zend_Gdata_Gapps'); Zend_Loader::loadClass('Zend_Http_Client'); $user = "isuadmin@gdev.isu.edu"; $pass = "******"; $domain = "gdev.isu.edu"; $client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, Zend_Gdata_Gapps::AUTH_S ERVICE_NAME); // $service = new Zend_Gdata_Gapps($client, $domain); $error_flag = "no"; $err_message = ""; foreach ($files1 as $filename){ if (is_file($filename)) { // echo "$filename\n"; $fp = fopen($filename, "r"); while ($line = fgets($fp)) { $username = strtok($line, ":"); $familyname = strtok(":"); $givenname = strtok(":"); $passwordname = strtok(":"); echo "$filename\n"; echo "<b>User Name:</b> $username\n"; echo "\n"; // construct event object // save to server try { echo "create user<br/>"; $quota = "50M"; $service->createUser($username, $familyname, $givenname, $passwordname, $passwordHash Function=null, $quota=null); } catch (Zend_Gdata_Gapps_ServiceException $e) { if ($e->hasError(Zend_Gdata_Gapps_Error::ENTITY_EXISTS)) { // If this is an ENTITY_DOES_NOT_EXIST error, return null echo "user $username already EXISTS\n>"; $err_message = $err_message . "Already EXISTS \r\n"; $error_flag = "yes"; } elseif ($e->hasError(Zend_Gdata_Gapps_Error::USER_DELETED_RECENTLY)) { // If this is an ENTITY_DOES_NOT_EXIST error, return null $err_message = $err_message . "Email Account Deleted Recently cannot create until 5 day s \r\n"; $error_flag = "yes"; } elseif ($e->hasError(Zend_Gdata_Gapps_Error::ENTITY_NAME_IS_RESERVED)) { // If this is an ENTITY_RESERVED error, return null echo "Email Account Name Reserved \r\n"; $err_message = $err_message . "Email Account Name Reserved \r\n"; $error_flag = "yes"; } else { // Outherwise, just print the errors that occured and exit foreach ($e->getErrors() as $error) { echo "Error encountered: {$error->getReason()} ({$error->getErrorCode() })\n"; } // foreach exit(); } // if ENTITY EXISTS } // Catch echo "user $error_flag \n>"; if ($error_flag == "yes") { // define current time $time = date('H:i:s'); // define the current date (it will be appended to the log file name) $today = date('Y-m-d'); // if the file does not exist, attempt to create it $file = fopen("/home/acctmnt/logs/acctlog.txt", 'a') or die("can't open file"); fwrite($file,"$filename $today:$time $username $err_message \r\n"); fclose($file); $error_flag = "no"; $err_message = ""; // unlink($filename); }else{ // define current time $time = date('H:i:s'); // define the current date (it will be appended to the log file name) $today = date('Y-m-d'); // open log file for writing only; place the file pointer at the end of the file // if the file does not exist, attempt to create it // $this->fp = fopen($lfile . '_' . $today, 'a') or exit("Can't open $lfile!"); $file = fopen("/home/acctmnt/logs/acctlog.txt", 'a') or die("can't open file"); fwrite($file,"$filename $today:$time $username Email Account Successful \r\n"); fclose($file); $error_flag = "no"; $err_message = ""; } // error flag } // while loop exec("/bin/rm $filename"); }// IF FILE } // foreach } // End function function gmailDisable($files2) { // load classes require_once 'Zend/Loader.php'; Zend_Loader::loadClass('Zend_Gdata'); Zend_Loader::loadClass('Zend_Gdata_ClientLogin'); Zend_Loader::loadClass('Zend_Gdata_Gapps'); Zend_Loader::loadClass('Zend_Http_Client'); $user = "isuadmin@gdev.isu.edu"; $pass = "*******"; $domain = "gdev.isu.edu"; $client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, Zend_Gdata_Gapps::AUTH_SE RVICE_NAME); $service = new Zend_Gdata_Gapps($client, $domain); $error_flag = "no"; $err_message = ""; foreach ($files2 as $filename){ if (is_file($filename)) { // echo "$filename\n"; $fp = fopen($filename, "r"); while ($line = fgets($fp)) { $username = strtok($line, ":"); $username2 = $username; $username3 = ""; $query = $service->newUserQuery($username); try { $username3 = $service->getUserEntry($query); } catch (Zend_Gdata_Gapps_ServiceException $e) { // Set the user to null if not found if ($e->hasError(Zend_Gdata_Gapps_Error::ENTITY_DOES_NOT_EXIST)) { $username = NULL; } else { throw $e; } // ENTITY_DOES_NOT_EXIST } // construct event object // save to server if ($username == null) { echo "$username2 does exist no need to suspend\n"; $error_flag = "yes"; }else{ try { echo "Suspend user<br/>"; echo "$username\n"; $service->suspendUser($username); } // try catch (Zend_Gdata_Gapps_ServiceException $e) { if ($e->hasError(Zend_Gdata_Gapps_Error::ENTITY_DOES_NOT_EXIST)) { // If this is an ENTITY_DOES_NOT_EXIST error, return null echo "Delete user $username failed not there\n>"; $error_flag = "yes"; } else { // Outherwise, just print the errors that occured and exit foreach ($e->getErrors() as $error) { echo "Error encountered: {$error->getReason()} ({$error->getErrorCode()})\n"; } // Foreach exit(); } // if ENTITY_DOES_NOT_EXIST } // CATCH } // IF username == nulll echo "3\n"; // may have to undo } if ($error_flag == "yes") { echo "user $username NOT EXISTS\n>"; // define current time $time = date('H:i:s'); // define the current date (it will be appended to the log file name) $today = date('Y-m-d'); // open log file for writing only; place the file pointer at the end of the file // if the file does not exist, attempt to create it $file = fopen("/home/acctmnt/logs/acctlog.txt", 'a') or die("can't open file"); fwrite($file,"$filename $today:$time $username2 Disabled attempt failed no such user \r\n"); fclose($file); $error_flag = "no"; // unlink($filename); }else{ // define current time $time = date('H:i:s'); // define the current date (it will be appended to the log file name) $today = date('Y-m-d'); // open log file for writing only; place the file pointer at the end of the file // if the file does not exist, attempt to create it // $this->fp = fopen($lfile . '_' . $today, 'a') or exit("Can't open $lfile!"); $file = fopen("/home/acctmnt/logs/acctlog.txt", 'a') or die("can't open file"); fwrite($file,"$filename $today:$time $username2 Disable Successful \r\n"); fclose($file); // unlink($filename); } // error flag } // While Loop exec("/bin/rm $filename"); } // IF FILE } // End Foreach } // End Function Disable function gmailEnable($files3) { // load classes require_once 'Zend/Loader.php'; Zend_Loader::loadClass('Zend_Gdata'); Zend_Loader::loadClass('Zend_Gdata_ClientLogin'); Zend_Loader::loadClass('Zend_Gdata_Gapps'); Zend_Loader::loadClass('Zend_Http_Client'); $user = "isuadmin@gdev.isu.edu"; $pass = "*******"; $domain = "gdev.isu.edu"; $client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, Zend_Gdata_Gapps::AUTH_SE RVICE_NAME); $service = new Zend_Gdata_Gapps($client, $domain); $error_flag = "no"; $err_message = ""; foreach ($files3 as $filename){ if (is_file($filename)) { $fp = fopen($filename, "r"); while ($line = fgets($fp)) { echo "$filename\n"; $username = strtok($line, ":"); $username2 = $username; echo "<b>User Name:</b> $username<br>"; $username3 = ""; $query = ""; $query = $service->newUserQuery($username); try { $username3 = $service->getUserEntry($query); } catch (Zend_Gdata_Gapps_ServiceException $e) { // Set the user to null if not found if ($e->hasError(Zend_Gdata_Gapps_Error::ENTITY_DOES_NOT_EXIST)) { $username = NULL; } else { throw $e; } // ENTITY_DOES_NOT_EXIST echo "$username\n"; } // construct event object // save to server if ($username == null) { echo "$username2 does exist no need to Enable\n"; $error_flag = "yes"; }else{ // construct event object // save to server try { echo "Restore user<br/>"; $service->restoreUser($username); } // try catch (Zend_Gdata_Gapps_ServiceException $e) { if ($e->hasError(Zend_Gdata_Gapps_Error::ENTITY_DOES_NOT_EXIST)) { // If this is an ENTITY_DOES_NOT_EXIST error, return null echo "Enable user $username failed not there\n>"; $error_flag = "yes"; } else { // Outherwise, just print the errors that occured and exit foreach ($e->getErrors() as $error) { echo "Error encountered: {$error->getReason()} ({$error->getErrorCode()} )\n"; } // Foreach exit(); } // if ENTITY_DOES_NOT_EXIST } // CATCH } // IF username == nulll // may have to undo } if ($error_flag == "yes") { echo "user $username NOT EXISTS\n>"; // define current time $time = date('H:i:s'); // define the current date (it will be appended to the log file name) $today = date('Y-m-d'); // open log file for writing only; place the file pointer at the end of the file // if the file does not exist, attempt to create it // $this->fp = fopen($lfile . '_' . $today, 'a') or exit("Can't open $lfile!"); $file = fopen("/home/acctmnt/logs/acctlog.txt", 'a') or die("can't open file"); fwrite($file,"$filename $today:$time $username2 Enable attempt failed no such user\r \n" ); fclose($file); $error_flag = "no"; // unlink($filename); }else{ // define current time $time = date('H:i:s'); // define the current date (it will be appended to the log file name) $today = date('Y-m-d'); // open log file for writing only; place the file pointer at the end of the file // if the file does not exist, attempt to create it // $this->fp = fopen($lfile . '_' . $today, 'a') or exit("Can't open $lfile!"); $file = fopen("/home/acctmnt/logs/acctlog.txt", 'a') or die("can't open file"); fwrite($file,"$filename $today:$time $username2 Enable Successful \r\n"); fclose($file); // unlink($filename); } // error flag } // While loop exec("/bin/rm $filename"); } // IF FILE }// foreach loop } // End function function gmailPurge($files4) { // load classes require_once 'Zend/Loader.php'; Zend_Loader::loadClass('Zend_Gdata'); Zend_Loader::loadClass('Zend_Gdata_ClientLogin'); Zend_Loader::loadClass('Zend_Gdata_Gapps'); Zend_Loader::loadClass('Zend_Http_Client'); $user = "isuadmin@gdev.isu.edu"; $pass = "*******"; $domain = "gdev.isu.edu"; $client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, Zend_Gdata_Gapps::AUTH_SE RVICE_NAME); $service = new Zend_Gdata_Gapps($client, $domain); $error_flag = "no"; $err_message = ""; foreach ($files4 as $filename){ if (is_file($filename)) { $fp = fopen($filename, "r"); while ($line = fgets($fp)) { echo "$filename\n"; $username = strtok($line, ":"); echo "<b>User Name:</b> $username<br>"; $username2 = $username; $username3 = ""; $query = ""; $query = $service->newUserQuery($username); try { $username3 = $service->getUserEntry($query); } catch (Zend_Gdata_Gapps_ServiceException $e) { // Set the user to null if not found if ($e->hasError(Zend_Gdata_Gapps_Error::ENTITY_DOES_NOT_EXIST)) { $username = NULL; } else { throw $e; } // ENTITY_DOES_NOT_EXIST echo "$username\n"; } // construct event object // save to server if ($username == null) { $error_flag = "yes"; }else{ // construct event object // save to server try{ echo "Delete user\n>"; $service->deleteUser($username); } catch (Zend_Gdata_Gapps_ServiceException $e) { if ($e->hasError(Zend_Gdata_Gapps_Error::ENTITY_DOES_NOT_EXIST)) { // If this is an ENTITY_DOES_NOT_EXIST error, return null echo "Delete user $username failed not there\n>"; $error_flag = "yes"; } else { // Outherwise, just print the errors that occured and exit foreach ($e->getErrors() as $error) { echo "Error encountered: {$error->getReason()} ({$error->getErrorCode()})\n"; } // Foreach exit(); } // if ENTITY_DOES_NOT_EXIST } // CATCH } // IF username == NULL if ($error_flag == "yes") { echo "user $username NOT EXISTS\n>"; // define current time $time = date('H:i:s'); // define the current date (it will be appended to the log file name) $today = date('Y-m-d'); // open log file for writing only; place the file pointer at the end of the file // if the file does not exist, attempt to create it // $this->fp = fopen($lfile . '_' . $today, 'a') or exit("Can't open $lfile!"); $file = fopen("/home/acctmnt/logs/acctlog.txt", 'a') or die("can't open file"); fwrite($file,"$filename $today:$time $username2 Delete attempt failed no such user\r \n" ); fclose($file); $error_flag = "no"; // unlink($filename); }else{ // define current time $time = date('H:i:s'); // define the current date (it will be appended to the log file name) $today = date('Y-m-d'); // open log file for writing only; place the file pointer at the end of the file // if the file does not exist, attempt to create it // $this->fp = fopen($lfile . '_' . $today, 'a') or exit("Can't open $lfile!"); $file = fopen("/home/acctmnt/logs/acctlog.txt", 'a') or die("can't open file"); fwrite($file,"$filename $today:$time $username2 Delete Successful \r\n"); fclose($file); // unlink($filename); } // error flag } // While Loop // unlink($filename); exec("/bin/rm $filename"); } // IF FILE }// foreach loop } // End function
  2. In your opinion what is the most efficient and effective way? Also speed/performance wise?
  3. The files look like this (and they may have more than one record) (delimiter is a ":") (filename) (record values delimited by a colon). 3333.m1ad tempp.gmail1:temp:google1:temp1234 3333.m1pg tempp.gmail1: 3333.m1en tempp.gmail1: 3333.m1ds tempp.gmail1: So I could do something like this to read the file below (sorry for the stupid questions, but I'm looking for the most efficient method for the production code) $files = glob("dir"); foreach ($files as $file) { preg_match("/\.[^\.]+$/", $filename, $matches); $ext = strtolower($matches[0]); switch ($ext) { case ".m1ds": parseDisable($file); break; case ".m1en": parseEnable($file); break; case ".m1ad": parseCreate($file); break; case ".m1pg": parsePurge($file); break; default: die("error"); } } parseCreate($file) { / /read file $fp = fopen($file, "r"); while ($line = fgets($fp)) { $username = strtok($line, ":"); $familyname = strtok(":"); $givenname = strtok(":"); $passwordname = strtok(":"); / /read file $fp = fopen($file, "r"); while ($line = fgets($fp)) { $username = strtok($line, ":"); $familyname = strtok(":"); $givenname = strtok(":"); $passwordname = strtok(":"); // construct event object // save to server try { $quota = "50M"; $service->createUser($username, $familyname, $givenname, $passwordname, $passwordHashFunction=null, $quota=null); $query2 = "INSERT INTO gmail_add VALUES('$username', '$familyname', '$givenname', '$quota', NOW() )"; mysql_query( $query2 ) or die(mysql_error()); } catch (Zend_Gdata_Gapps_ServiceException $e) { if ($e->hasError(Zend_Gdata_Gapps_Error::ENTITY_EXISTS)) { // If this is an ENTITY_DOES_NOT_EXIST error, return null $err_message = $err_message . "Already EXISTS \r\n"; $error_flag = "yes"; } elseif ($e->hasError(Zend_Gdata_Gapps_Error::USER_DELETED_RECENTLY)) { // If this is an ENTITY_DOES_NOT_EXIST error, return null $err_message = $err_message . "Email Account Deleted Recently cannot create until 5 days \r\n"; $error_flag = "yes"; } elseif ($e->hasError(Zend_Gdata_Gapps_Error::ENTITY_NAME_IS_RESERVED)) { // If this is an ENTITY_RESERVED error, return null $err_message = $err_message . "Email Account Name Reserved \r\n"; $error_flag = "yes"; } else { // Outherwise, just print the errors that occured and exit foreach ($e->getErrors() as $error) { echo "Error encountered: {$error->getReason()} ({$error->getErrorCode()})\n"; } // foreach exit(); } // if ENTITY EXISTS } // Catch echo "user $error_flag \n>"; if ($error_flag == "yes") { // define current time $time = date('H:i:s'); // fwrite($this->fp, "$time ($script_name) $message\n"); // define the current date (it will be appended to the log file name) $today = date('Y-m-d'); // open log file for writing only; place the file pointer at the end of the file $file = fopen("/home/acctmnt/logs/acctlog.txt", 'a') or die("can't open file"); fwrite($file,"$username:m1ad $today:$time $username $err_message \r\n"); fclose($file); $error_flag = "no"; $err_message = ""; }else{ // define current time $time = date('H:i:s'); // define the current date (it will be appended to the log file name) $today = date('Y-m-d'); $file = fopen("/home/acctmnt/logs/acctlog.txt", 'a') or die("can't open file"); fwrite($file,"$username:m1ad $today:$time $username Email Account Successful \r\n"); fclose($file); $error_flag = "no"; $err_message = ""; } // error flag } //while loop ?> }// close while } Or how could I do below and read by extension in order? (I know this isn't the right code) $filem1ad = glob("dir.m1ad"); $filesm1en = glob("dir.m1ad"); $filesm1ds = glob("dir.m1ad"); $filesm1pg = glob("dir.m1ad");
  4. Here's basically what I need to do. The files will be ftp over as transaction and they will be in the directory unique like this (33fdfd.m1ad, 34343.m1pg, afdkljfa.m1en, 334343.m1ds) These are Create, purge, enable, and disable gmail transactions. The .m1ad files are create accounts. The .m1pg are purge accounts. The .m1en are Enable accounts, and .m1ds are disable accounts. I need to list these files from the directory (which shouldn't have any other file extensions than what I specified above), Check the file extension and put each one in its own separate array by file extension. Then read the array file content records and process the account by whatever transaction type it is (.m1ad, ,m1pg, .m1en, .m1ds). Does that make more sense. Thanks for your help.
  5. Could you give me a code example of the whole process of moving it into the different extension arrays and then apply an if statement that would say if the array value equal this extension go to this function. This php type of code is new for me.
  6. I need to know what the extension is for each file because they will be sent to a different function in the script for processing. Example files will be 34434.m1ad 54dfddf.m1ad (add an email account) 34343.m1ds, 3443ddfd.m1ds (disable an email account) so how would I read these different extensions into different arrays and then process the array files for each extension all at once in the differents they will go to by the extension match.
  7. I need to read a directory with files that have certain extensions (4 character extension prior the period . and number scheme) (.m1ad .m1ds, .m1en, .m1pg, .m1ps) into an two dimensional associate array in php. Then I need to read each one of the files contents from the array, because they contain google user create accounts, password changes, enables and disables of gmail accounts using php and ZendFrame Work. This program will be running from the command line in the background (on a linux System), constantly picking up the new files to process the transactions. There could be like 20 (.m1ad or .m1en) files in that directory. That's why I thought putting them in an array would be easier, because the files in the directory needs to be deleted after the transactions in the file content is processed. Current code that does reads one file in the directory #!/usr/bin/php -q <html> <head> <meta name=keywords content="Google Zenda data"> <meta name=description content="Google Zenda Data test"> <title>Google Zend Data Form</title> </head> <body> <?php include("connect-gmail.inc"); // load classes require_once 'Zend/Loader.php'; Zend_Loader::loadClass('Zend_Gdata'); Zend_Loader::loadClass('Zend_Gdata_ClientLogin'); Zend_Loader::loadClass('Zend_Gdata_Gapps'); // Zend_Loader::loadClass('Zend_Gdata_Calendar'); Zend_Loader::loadClass('Zend_Http_Client'); // connect to service // HERES WHERE I"M JUST READING ONE FILE FROM DIRECTORY RIGHT NOW $filestuff = "/home/acctmnt/acctFiles/052809285196.m1ad"; $user = "isuadmin@gdev.isu.edu"; $pass = "S3rV1c3!"; $domain = "gdev.isu.edu"; $client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, Zend_Gdata_Gapps::AUTH_SERVICE_NAME); $service = new Zend_Gdata_Gapps($client, $domain); $error_flag = "no"; $err_message = ""; // read file $fp = fopen($filestuff, "r"); while ($line = fgets($fp)) { $username = strtok($line, ":"); $familyname = strtok(":"); $givenname = strtok(":"); $passwordname = strtok(":"); // construct event object // save to server try { $quota = "50M"; $service->createUser($username, $familyname, $givenname, $passwordname, $passwordHashFunction=null, $quota=null); $query2 = "INSERT INTO gmail_add VALUES('$username', '$familyname', '$givenname', '$quota', NOW() )"; mysql_query( $query2 ) or die(mysql_error()); } catch (Zend_Gdata_Gapps_ServiceException $e) { if ($e->hasError(Zend_Gdata_Gapps_Error::ENTITY_EXISTS)) { // If this is an ENTITY_DOES_NOT_EXIST error, return null $err_message = $err_message . "Already EXISTS \r\n"; $error_flag = "yes"; } elseif ($e->hasError(Zend_Gdata_Gapps_Error::USER_DELETED_RECENTLY)) { // If this is an ENTITY_DOES_NOT_EXIST error, return null $err_message = $err_message . "Email Account Deleted Recently cannot create until 5 days \r\n"; $error_flag = "yes"; } elseif ($e->hasError(Zend_Gdata_Gapps_Error::ENTITY_NAME_IS_RESERVED)) { // If this is an ENTITY_RESERVED error, return null $err_message = $err_message . "Email Account Name Reserved \r\n"; $error_flag = "yes"; } else { // Outherwise, just print the errors that occured and exit foreach ($e->getErrors() as $error) { echo "Error encountered: {$error->getReason()} ({$error->getErrorCode()})\n"; } // foreach exit(); } // if ENTITY EXISTS } // Catch echo "user $error_flag \n>"; if ($error_flag == "yes") { // define current time $time = date('H:i:s'); // fwrite($this->fp, "$time ($script_name) $message\n"); // define the current date (it will be appended to the log file name) $today = date('Y-m-d'); // open log file for writing only; place the file pointer at the end of the file $file = fopen("/home/acctmnt/logs/acctlog.txt", 'a') or die("can't open file"); fwrite($file,"$username:m1ad $today:$time $username $err_message \r\n"); fclose($file); $error_flag = "no"; $err_message = ""; }else{ // define current time $time = date('H:i:s'); // define the current date (it will be appended to the log file name) $today = date('Y-m-d'); $file = fopen("/home/acctmnt/logs/acctlog.txt", 'a') or die("can't open file"); fwrite($file,"$username:m1ad $today:$time $username Email Account Successful \r\n"); fclose($file); $error_flag = "no"; $err_message = ""; } // error flag } //while loop ?> </body> </html>
  8. Why use php at all then? Perl doesn't work with Google's Zend Framework to create automated Email Google Accounts for our University. That's what this code will be used for.
  9. I need to read a linux directory listing and then open those files and read each one's content. Below is how I did it in PERL and I would like to use similar code to do in PHP. Any examples? These Files need to be stored in two dimensional arrays too. This script is embedded with Zend Google data code creating Gmail accounts. This php script would be ran in cron or command line, no web interaction. open(FILES,"ls -1 $acctpath/* 2>/dev/null |"); #change made to log transactions, rather than, keep files on the system while(<FILES>){ chop; $filename = $_; # New transaction file naming convention uses a four character c ode extention to indicate the transaction type. # The first two letters of the extention denote the system and t he next two letters denote the operation to be performed. # The system codes are as follows: CW (Cwis), RA (Remote Access ), M1 (Mail Server 1 -> additional mail systems can be $tmpString = substr($filename, -4, 2); #groupchange if (($tmpString eq "cw") || ($tmpString eq "ra") || ($tmpString eq "rd") || ($tmpString eq "m1") || ($tmpString eq "m2") || ($tmpString eq "ex") || ($tm pString eq "gp")) { ($junk,$junk,$junk,$junk,$junk,$junk,$junk,$size,@junk) = stat($filename); $files2{$filename} = $size; $count2++; } } close(FILES);
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.